Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
CiviCRM Core
Commits
6ba59698
Unverified
Commit
6ba59698
authored
4 years ago
by
colemanw
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #19784 from eileenmcnaughton/member
[REF] Extract code to get generic membership parameters
parents
d6009096
d04c9885
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Member/Form/Membership.php
+33
-22
33 additions, 22 deletions
CRM/Member/Form/Membership.php
tests/phpunit/CRM/Member/Form/MembershipTest.php
+1
-3
1 addition, 3 deletions
tests/phpunit/CRM/Member/Form/MembershipTest.php
with
34 additions
and
25 deletions
CRM/Member/Form/Membership.php
+
33
−
22
View file @
6ba59698
...
...
@@ -1067,24 +1067,7 @@ DESC limit 1");
$params
[
'contact_id'
]
=
$this
->
_contactID
;
$fields
=
[
'status_id'
,
'source'
,
'is_override'
,
'status_override_end_date'
,
'campaign_id'
,
];
foreach
(
$fields
as
$f
)
{
$params
[
$f
]
=
$formValues
[
$f
]
??
NULL
;
}
// fix for CRM-3724
// when is_override false ignore is_admin statuses during membership
// status calculation. similarly we did fix for import in CRM-3570.
if
(
empty
(
$params
[
'is_override'
]))
{
$params
[
'exclude_is_admin'
]
=
TRUE
;
}
$params
=
array_merge
(
$params
,
$this
->
getFormMembershipParams
());
$joinDate
=
$formValues
[
'join_date'
];
$startDate
=
$formValues
[
'start_date'
];
...
...
@@ -1119,10 +1102,6 @@ DESC limit 1");
// max related memberships - take from form or inherit from membership type
$membershipTypeValues
[
$memType
][
'max_related'
]
=
$formValues
[
'max_related'
]
??
NULL
;
}
$membershipTypeValues
[
$memType
][
'custom'
]
=
CRM_Core_BAO_CustomField
::
postProcess
(
$formValues
,
$this
->
_id
,
'Membership'
);
}
// Retrieve the name and email of the current user - this will be the FROM for the receipt email
...
...
@@ -1894,4 +1873,36 @@ DESC limit 1");
return
(
int
)
$this
->
getSubmittedValue
(
'financial_type_id'
)
?:
$this
->
order
->
getFinancialTypeID
();
}
/**
* Get values that should be passed to all membership create actions.
*
* These parameters are generic to all memberships created from the form,
* whether a single membership or multiple by price set (although
* the form will not expose all in the latter case.
*
* By referencing the submitted values directly we can call this
* from anywhere in postProcess and get the same result (protects
* against breakage if code is moved around).
*
* @return array
*/
protected
function
getFormMembershipParams
():
array
{
$submittedValues
=
$this
->
controller
->
exportValues
(
$this
->
_name
);
return
[
'status_id'
=>
$this
->
getSubmittedValue
(
'status_id'
),
'source'
=>
$this
->
getSubmittedValue
(
'source'
),
'is_override'
=>
$this
->
getSubmittedValue
(
'is_override'
),
'status_override_end_date'
=>
$this
->
getSubmittedValue
(
'status_override_end_date'
),
'campaign_id'
=>
$this
->
getSubmittedValue
(
'campaign_id'
),
'custom'
=>
CRM_Core_BAO_CustomField
::
postProcess
(
$submittedValues
,
$this
->
_id
,
'Membership'
),
// fix for CRM-3724
// when is_override false ignore is_admin statuses during membership
// status calculation. similarly we did fix for import in CRM-3570.
'exclude_is_admin'
=>
!
$this
->
getSubmittedValue
(
'is_override'
),
];
}
}
This diff is collapsed.
Click to expand it.
tests/phpunit/CRM/Member/Form/MembershipTest.php
+
1
−
3
View file @
6ba59698
...
...
@@ -1221,9 +1221,7 @@ Expires: ',
if
(
isset
(
$_REQUEST
[
'cid'
]))
{
unset
(
$_REQUEST
[
'cid'
]);
}
$form
=
new
CRM_Member_Form_Membership
();
$_SERVER
[
'REQUEST_METHOD'
]
=
'GET'
;
$form
->
controller
=
new
CRM_Core_Controller
();
$form
=
$this
->
getFormObject
(
'CRM_Member_Form_Membership'
);
$form
->
preProcess
();
return
$form
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment