Merge pull request #19727 from totten/master-authx-rest
[civicrm-core.git] / CRM / Member / Form / MembershipBlock.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035 11
6a488035
TO
12/**
13 * form to process actions on Membership
14 */
15class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPage {
16
17 /**
100fef9d 18 * Store membership price set id
971e129b 19 * @var int
6a488035
TO
20 */
21 protected $_memPriceSetId = NULL;
22
7885e669
MW
23 /**
24 * Set variables up before form is built.
25 */
26 public function preProcess() {
27 parent::preProcess();
28 $this->setSelectedChild('membership');
29 }
30
6a488035 31 /**
c490a46a 32 * Set default values for the form. Note that in edit/view mode
6a488035 33 * the default values are retrieved from the database
fd726496 34 */
00be9182 35 public function setDefaultValues() {
be2fb01f 36 $defaults = [];
6a488035
TO
37 if (isset($this->_id)) {
38 $defaults = CRM_Member_BAO_Membership::getMembershipBlock($this->_id);
39 }
ade77f2b 40 $defaults['member_is_active'] = $defaults['is_active'] ?? FALSE;
6a488035
TO
41
42 // Set Display Minimum Fee default to true if we are adding a new membership block
43 if (!isset($defaults['id'])) {
44 $defaults['display_min_fee'] = 1;
45 }
46 else {
47 $this->assign('membershipBlockId', $defaults['id']);
48 }
49 if ($this->_id &&
9da8dc8c 50 ($priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, 3, 1))
6a488035
TO
51 ) {
52 $defaults['member_price_set_id'] = $priceSetId;
53 $this->_memPriceSetId = $priceSetId;
54 }
55 else {
56 // for membership_types
57 // if ( isset( $defaults['membership_types'] ) ) {
9da8dc8c 58 $priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, 3);
6a488035
TO
59 $this->assign('isQuick', 1);
60 $this->_memPriceSetId = $priceSetId;
be2fb01f 61 $pFIDs = [];
6a488035 62 if ($priceSetId) {
be2fb01f 63 CRM_Core_DAO::commonRetrieveAll('CRM_Price_DAO_PriceField', 'price_set_id', $priceSetId, $pFIDs, $return = [
c5c263ca
AH
64 'html_type',
65 'name',
66 'label',
be2fb01f 67 ]);
6a488035
TO
68 foreach ($pFIDs as $pid => $pValue) {
69 if ($pValue['html_type'] == 'Radio' && $pValue['name'] == 'membership_amount') {
70 $defaults['mem_price_field_id'] = $pValue['id'];
21f4797a 71 $defaults['membership_type_label'] = $pValue['label'];
6a488035
TO
72 }
73 }
74
a7488080 75 if (!empty($defaults['mem_price_field_id'])) {
be2fb01f 76 $options = [];
9da8dc8c 77 $priceFieldOptions = CRM_Price_BAO_PriceFieldValue::getValues($defaults['mem_price_field_id'], $options, 'id', 1);
6a488035
TO
78 foreach ($options as $k => $v) {
79 $newMembershipType[$v['membership_type_id']] = 1;
3476772a 80 if (!empty($defaults['auto_renew'])) {
92fcb95f 81 $defaults["auto_renew_" . $v['membership_type_id']] = $defaults['auto_renew'][$v['membership_type_id']];
6a488035
TO
82 }
83 }
84 $defaults['membership_type'] = $newMembershipType;
85 }
86 }
87 }
88
89 return $defaults;
90 }
91
92 /**
fe482240 93 * Build the form object.
6a488035 94 *
7885e669
MW
95 * @throws \CRM_Core_Exception
96 * @throws \CiviCRM_API3_Exception
6a488035
TO
97 */
98 public function buildQuickForm() {
99 $membershipTypes = CRM_Member_BAO_MembershipType::getMembershipTypes();
100
101 if (!empty($membershipTypes)) {
102 $this->addElement('checkbox', 'member_is_active', ts('Membership Section Enabled?'));
103
104 $this->addElement('text', 'new_title', ts('Title - New Membership'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'new_title'));
105
5d51a2f9 106 $this->add('wysiwyg', 'new_text', ts('Introductory Message - New Memberships'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'new_text'));
6a488035
TO
107
108 $this->addElement('text', 'renewal_title', ts('Title - Renewals'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'renewal_title'));
109
5d51a2f9 110 $this->add('wysiwyg', 'renewal_text', ts('Introductory Message - Renewals'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'renewal_text'));
6a488035
TO
111
112 $this->addElement('checkbox', 'is_required', ts('Require Membership Signup'));
113 $this->addElement('checkbox', 'display_min_fee', ts('Display Membership Fee'));
114 $this->addElement('checkbox', 'is_separate_payment', ts('Separate Membership Payment'));
be2fb01f 115 $this->addElement('text', 'membership_type_label', ts('Membership Types Label'), ['placeholder' => ts('Membership')]);
6a488035
TO
116
117 $paymentProcessor = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, 'is_recur = 1');
118 $paymentProcessorIds = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage',
119 $this->_id, 'payment_processor'
120 );
121 $paymentProcessorId = explode(CRM_Core_DAO::VALUE_SEPARATOR, $paymentProcessorIds);
122 $isRecur = TRUE;
123 foreach ($paymentProcessorId as $dontCare => $id) {
124 if (!array_key_exists($id, $paymentProcessor)) {
125 $isRecur = FALSE;
126 continue;
127 }
128 }
129
be2fb01f 130 $membership = $membershipDefault = $params = [];
6a488035
TO
131 foreach ($membershipTypes as $k => $v) {
132 $membership[] = $this->createElement('advcheckbox', $k, NULL, $v);
ca5603d5 133 $membershipDefault[$k] = NULL;
3476772a 134 $membershipRequired[$k] = NULL;
6a488035 135 if ($isRecur) {
353ffa53 136 $autoRenew = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $k, 'auto_renew');
3476772a 137 $membershipRequired[$k] = $autoRenew;
be2fb01f 138 $autoRenewOptions = [];
6a488035 139 if ($autoRenew) {
be2fb01f 140 $autoRenewOptions = [ts('Not offered'), ts('Give option'), ts('Required')];
6a488035 141 $this->addElement('select', "auto_renew_$k", ts('Auto-renew'), $autoRenewOptions);
3476772a 142 //CRM-15573
22e263ad 143 if ($autoRenew == 2) {
3476772a 144 $this->freeze("auto_renew_$k");
b09fe5ed 145 $params['id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipBlock', $this->_id, 'id', 'entity_id');
3476772a 146 }
6a488035
TO
147 $this->_renewOption[$k] = $autoRenew;
148 }
149 }
150 }
151
3476772a 152 //CRM-15573
153 if (!empty($params['id'])) {
154 $params['membership_types'] = serialize($membershipRequired);
155 CRM_Member_BAO_MembershipBlock::create($params);
156 }
be2fb01f 157 $this->add('hidden', "mem_price_field_id", '', ['id' => "mem_price_field_id"]);
6a488035
TO
158 $this->assign('is_recur', $isRecur);
159 if (isset($this->_renewOption)) {
160 $this->assign('auto_renew', $this->_renewOption);
161 }
162 $this->addGroup($membership, 'membership_type', ts('Membership Types'));
ca5603d5 163 $this->addRadio('membership_type_default', ts('Membership Types Default'), $membershipDefault, ['allowClear' => TRUE]);
6a488035 164
be2fb01f 165 $this->addFormRule(['CRM_Member_Form_MembershipBlock', 'formRule'], $this->_id);
6a488035 166 }
9da8dc8c 167 $price = CRM_Price_BAO_PriceSet::getAssoc(FALSE, 'CiviMember');
6a488035
TO
168 if (CRM_Utils_System::isNull($price)) {
169 $this->assign('price', FALSE);
170 }
171 else {
172 $this->assign('price', TRUE);
173 }
a0a2c91d
MWMC
174 //$this->add('select', 'member_price_set_id', ts('Membership Price Set'), (['' => ts('- none -')] + $price));
175
176 $this->addField('member_price_set_id', [
2e2f2fec 177 'entity' => 'PriceField',
a0a2c91d
MWMC
178 'name' => 'price_set_id',
179 'options' => $price,
180 ]);
6a488035
TO
181
182 $session = CRM_Core_Session::singleton();
183 $single = $session->get('singleForm');
184 if ($single) {
be2fb01f
CW
185 $this->addButtons([
186 [
c5c263ca
AH
187 'type' => 'next',
188 'name' => ts('Save'),
189 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
190 'isDefault' => TRUE,
be2fb01f
CW
191 ],
192 [
c5c263ca
AH
193 'type' => 'cancel',
194 'name' => ts('Cancel'),
be2fb01f
CW
195 ],
196 ]);
6a488035
TO
197 }
198 else {
199 parent::buildQuickForm();
200 }
201 }
202
203 /**
fe482240 204 * Validation.
6a488035 205 *
b2363ea8
TO
206 * @param array $params
207 * (ref.) an assoc array of name/value pairs.
da6b46f4 208 * @param $files
100fef9d 209 * @param int $contributionPageId
da6b46f4 210 *
72b3a70c
CW
211 * @return bool|array
212 * mixed true or array of errors
7885e669
MW
213 * @throws \CRM_Core_Exception
214 * @throws \CiviCRM_API3_Exception
6a488035 215 */
00be9182 216 public static function formRule($params, $files, $contributionPageId = NULL) {
be2fb01f 217 $errors = [];
6a488035 218
a7488080 219 if (!empty($params['member_price_set_id'])) {
fd726496 220 //check if this price set has membership type both auto-renew and non-auto-renew memberships.
f72e6e2c 221 $bothTypes = CRM_Price_BAO_PriceSet::isMembershipPriceSetContainsMixOfRenewNonRenew($params['member_price_set_id']);
6a488035
TO
222
223 //check for supporting payment processors
224 //if both auto-renew and non-auto-renew memberships
225 if ($bothTypes) {
b09fe5ed 226 $paymentProcessorIds = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage',
353ffa53
TO
227 $contributionPageId, 'payment_processor'
228 );
6a488035 229
b09fe5ed 230 $paymentProcessorId = explode(CRM_Core_DAO::VALUE_SEPARATOR, $paymentProcessorIds);
6a488035
TO
231
232 if (!empty($paymentProcessorId)) {
22e263ad 233 foreach ($paymentProcessorId as $pid) {
6a488035 234 if ($pid) {
b6ffdf22
EM
235 $processor = Civi\Payment\System::singleton()->getById($pid);
236 if (!$processor->supports('MultipleConcurrentPayments')) {
237 $errors['member_price_set_id'] = ts('The membership price set associated with this online contribution allows a user to select BOTH an auto-renew AND a non-auto-renew membership. This requires submitting multiple processor transactions, and is not supported for one or more of the payment processors enabled under the Amounts tab.');
238 }
6a488035 239 }
6a488035
TO
240 }
241 }
fd726496 242 }
6a488035 243 }
a7488080 244 if (!empty($params['member_is_active'])) {
6a488035
TO
245
246 // don't allow price set w/ membership signup, CRM-5095
9da8dc8c 247 if ($contributionPageId && ($setID = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $contributionPageId, NULL, 1))) {
6a488035 248
9da8dc8c 249 $extends = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $setID, 'extends');
6a488035
TO
250 if ($extends != CRM_Core_Component::getComponentID('CiviMember')) {
251 $errors['member_is_active'] = ts('You cannot enable both Membership Signup and a Contribution Price Set on the same online contribution page.');
252 return $errors;
253 }
254 }
255
a7488080 256 if (!empty($params['member_price_set_id'])) {
6a488035
TO
257 return $errors;
258 }
259
260 if (!isset($params['membership_type']) ||
261 (!is_array($params['membership_type']))
262 ) {
263 $errors['membership_type'] = ts('Please select at least one Membership Type to include in the Membership section of this page.');
264 }
265 else {
266 $membershipType = array_values($params['membership_type']);
9cc96227 267 $isRecur = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $contributionPageId, 'is_recur');
6a488035
TO
268 if (array_sum($membershipType) == 0) {
269 $errors['membership_type'] = ts('Please select at least one Membership Type to include in the Membership section of this page.');
270 }
0c165e1c
DG
271 elseif (array_sum($membershipType) > CRM_Price_Form_Field::NUM_OPTION) {
272 // for CRM-13079
be2fb01f 273 $errors['membership_type'] = ts('You cannot select more than %1 choices. For more complex functionality, please use a Price Set.', [1 => CRM_Price_Form_Field::NUM_OPTION]);
0c165e1c 274 }
9cc96227 275 elseif ($isRecur) {
276 if (empty($params['is_separate_payment']) && array_sum($membershipType) != 0) {
277 $errors['is_separate_payment'] = ts('You need to enable Separate Membership Payment when online contribution page is configured for both Membership and Recurring Contribution');
278 }
279 elseif (!empty($params['is_separate_payment'])) {
280 foreach ($params['membership_type'] as $mt => $dontCare) {
281 if (!empty($params["auto_renew_$mt"])) {
282 $errors["auto_renew_$mt"] = ts('You cannot enable both Recurring Contributions and Auto-renew memberships on the same online contribution page');
283 break;
284 }
285 }
286 }
287 }
6a488035
TO
288 }
289
290 //for CRM-1302
291 //if Membership status is not present, then display an error message
292 $dao = new CRM_Member_BAO_MembershipStatus();
293 if (!$dao->find()) {
294 $errors['_qf_default'] = ts('Add status rules, before configuring membership');
295 }
296
297 //give error if default is selected for an unchecked membership type
0c165e1c 298 if (!empty($params['membership_type_default']) && !$params['membership_type'][$params['membership_type_default']]) {
6a488035
TO
299 $errors['membership_type_default'] = ts('Can\'t set default option for an unchecked membership type.');
300 }
301
302 if ($contributionPageId) {
303 $amountBlock = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $contributionPageId, 'amount_block_is_active');
304
8cc574cf 305 if (!$amountBlock && !empty($params['is_separate_payment'])) {
6a488035
TO
306 $errors['is_separate_payment'] = ts('Please enable the contribution amount section to use this option.');
307 }
308 }
fd726496 309
6a488035
TO
310 }
311
312 return empty($errors) ? TRUE : $errors;
313 }
314
315 /**
fe482240 316 * Process the form.
6a488035
TO
317 */
318 public function postProcess() {
319 // get the submitted form values.
320 $params = $this->controller->exportValues($this->_name);
321 $deletePriceSet = 0;
322 if ($params['membership_type']) {
323 // we do this in case the user has hit the forward/back button
353ffa53 324 $dao = new CRM_Member_DAO_MembershipBlock();
6a488035 325 $dao->entity_table = 'civicrm_contribution_page';
353ffa53 326 $dao->entity_id = $this->_id;
6a488035
TO
327 $dao->find(TRUE);
328 $membershipID = $dao->id;
329 if ($membershipID) {
330 $params['id'] = $membershipID;
331 }
332
be2fb01f 333 $membershipTypes = [];
6a488035
TO
334 if (is_array($params['membership_type'])) {
335 foreach ($params['membership_type'] as $k => $v) {
336 if ($v) {
9c1bc317 337 $membershipTypes[$k] = $params["auto_renew_$k"] ?? NULL;
6a488035
TO
338 }
339 }
340 }
341
2d8ae2ae
CW
342 if ($this->_id && !empty($params['member_price_set_id'])) {
343 CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'amount_block_is_active', 0);
344 }
345
6a488035 346 // check for price set.
9c1bc317 347 $priceSetID = $params['member_price_set_id'] ?? NULL;
a7488080 348 if (!empty($params['member_is_active']) && is_array($membershipTypes) && !$priceSetID) {
9da8dc8c 349 $usedPriceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, 2);
a7488080 350 if (empty($params['mem_price_field_id']) && !$usedPriceSetId) {
6a488035
TO
351 $pageTitle = strtolower(CRM_Utils_String::munge($this->_values['title'], '_', 245));
352 $setParams['title'] = $this->_values['title'];
9da8dc8c 353 if (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $pageTitle, 'id', 'name')) {
6a488035
TO
354 $setParams['name'] = $pageTitle;
355 }
9da8dc8c 356 elseif (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $pageTitle . '_' . $this->_id, 'id', 'name')) {
6a488035
TO
357 $setParams['name'] = $pageTitle . '_' . $this->_id;
358 }
359 else {
b09fe5ed 360 $timeSec = explode(".", microtime(TRUE));
6a488035
TO
361 $setParams['name'] = $pageTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
362 }
363 $setParams['is_quick_config'] = 1;
364 $setParams['extends'] = CRM_Core_Component::getComponentID('CiviMember');
9c1bc317 365 $setParams['financial_type_id'] = $this->_values['financial_type_id'] ?? NULL;
9da8dc8c 366 $priceSet = CRM_Price_BAO_PriceSet::create($setParams);
6a488035
TO
367 $priceSetID = $priceSet->id;
368 $fieldParams['price_set_id'] = $priceSet->id;
369 }
370 elseif ($usedPriceSetId) {
371 $setParams['extends'] = CRM_Core_Component::getComponentID('CiviMember');
9c1bc317 372 $setParams['financial_type_id'] = $this->_values['financial_type_id'] ?? NULL;
6a488035 373 $setParams['id'] = $usedPriceSetId;
9da8dc8c 374 $priceSet = CRM_Price_BAO_PriceSet::create($setParams);
6a488035
TO
375 $priceSetID = $priceSet->id;
376 $fieldParams['price_set_id'] = $priceSet->id;
377 }
378 else {
9c1bc317 379 $fieldParams['id'] = $params['mem_price_field_id'] ?? NULL;
9da8dc8c 380 $priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('mem_price_field_id', $params), 'price_set_id');
6a488035 381 }
be2fb01f 382 $editedFieldParams = [
6a488035
TO
383 'price_set_id' => $priceSetID,
384 'name' => 'membership_amount',
be2fb01f
CW
385 ];
386 $editedResults = [];
9da8dc8c 387 CRM_Price_BAO_PriceField::retrieve($editedFieldParams, $editedResults);
a7488080 388 if (empty($editedResults['id'])) {
19659b5a 389 $fieldParams['name'] = 'membership_amount';
a7488080 390 if (empty($params['mem_price_field_id'])) {
be2fb01f 391 CRM_Utils_Weight::updateOtherWeights('CRM_Price_DAO_PriceField', 0, 1, ['price_set_id' => $priceSetID]);
6a488035
TO
392 }
393 $fieldParams['weight'] = 1;
394 }
395 else {
9c1bc317 396 $fieldParams['id'] = $editedResults['id'] ?? NULL;
6a488035
TO
397 }
398
21f4797a 399 $fieldParams['label'] = !empty($params['membership_type_label']) ? $params['membership_type_label'] : ts('Membership');
6a488035
TO
400 $fieldParams['is_active'] = 1;
401 $fieldParams['html_type'] = 'Radio';
0d8afee2
CW
402 $fieldParams['is_required'] = !empty($params['is_required']) ? 1 : 0;
403 $fieldParams['is_display_amounts'] = !empty($params['display_min_fee']) ? 1 : 0;
6a488035 404 $rowCount = 1;
be2fb01f 405 $options = [];
a7488080 406 if (!empty($fieldParams['id'])) {
9da8dc8c 407 CRM_Core_PseudoConstant::populate($options, 'CRM_Price_DAO_PriceFieldValue', TRUE, 'membership_type_id', NULL, " price_field_id = {$fieldParams['id']} ");
6a488035
TO
408 }
409
410 foreach ($membershipTypes as $memType => $memAutoRenew) {
411 if ($priceFieldID = CRM_Utils_Array::key($memType, $options)) {
412 $fieldParams['option_id'][$rowCount] = $priceFieldID;
413 unset($options[$priceFieldID]);
414 }
415 $membetype = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($memType);
9c1bc317 416 $fieldParams['option_label'][$rowCount] = $membetype['name'] ?? NULL;
353ffa53 417 $fieldParams['option_amount'][$rowCount] = CRM_Utils_Array::value('minimum_fee', $membetype, 0);
9c1bc317
CW
418 $fieldParams['option_weight'][$rowCount] = $membetype['weight'] ?? NULL;
419 $fieldParams['option_description'][$rowCount] = $membetype['description'] ?? NULL;
420 $fieldParams['default_option'] = $params['membership_type_default'] ?? NULL;
421 $fieldParams['option_financial_type_id'][$rowCount] = $membetype['financial_type_id'] ?? NULL;
6a488035
TO
422
423 $fieldParams['membership_type_id'][$rowCount] = $memType;
424 // [$rowCount] = $membetype[''];
425 $rowCount++;
426 }
427 foreach ($options as $priceFieldID => $memType) {
9da8dc8c 428 CRM_Price_BAO_PriceFieldValue::setIsActive($priceFieldID, '0');
6a488035 429 }
9da8dc8c 430 $priceField = CRM_Price_BAO_PriceField::create($fieldParams);
6a488035 431 }
9b873358 432 elseif (!$priceSetID) {
6a488035
TO
433 $deletePriceSet = 1;
434 }
435
436 $params['is_required'] = CRM_Utils_Array::value('is_required', $params, FALSE);
437 $params['is_active'] = CRM_Utils_Array::value('member_is_active', $params, FALSE);
438
439 if ($priceSetID) {
440 $params['membership_types'] = 'null';
441 $params['membership_type_default'] = CRM_Utils_Array::value('membership_type_default', $params, 'null');
353ffa53
TO
442 $params['membership_types'] = serialize($membershipTypes);
443 $params['display_min_fee'] = CRM_Utils_Array::value('display_min_fee', $params, FALSE);
444 $params['is_separate_payment'] = CRM_Utils_Array::value('is_separate_payment', $params, FALSE);
6a488035
TO
445 }
446 $params['entity_table'] = 'civicrm_contribution_page';
447 $params['entity_id'] = $this->_id;
448
449 $dao = new CRM_Member_DAO_MembershipBlock();
450 $dao->copyValues($params);
451 $dao->save();
452
453 if ($priceSetID && $params['is_active']) {
9da8dc8c 454 CRM_Price_BAO_PriceSet::addTo('civicrm_contribution_page', $this->_id, $priceSetID);
6a488035
TO
455 }
456
457 if ($deletePriceSet || !CRM_Utils_Array::value('member_is_active', $params, FALSE)) {
458
459 if ($this->_memPriceSetId) {
be2fb01f
CW
460 $pFIDs = [];
461 $conditionParams = [
6a488035
TO
462 'price_set_id' => $this->_memPriceSetId,
463 'html_type' => 'radio',
464 'name' => 'contribution_amount',
be2fb01f 465 ];
6a488035 466
9da8dc8c 467 CRM_Core_DAO::commonRetrieve('CRM_Price_DAO_PriceField', $conditionParams, $pFIDs);
a7488080 468 if (empty($pFIDs['id'])) {
9da8dc8c 469 CRM_Price_BAO_PriceSet::removeFrom('civicrm_contribution_page', $this->_id);
470 CRM_Price_BAO_PriceSet::setIsQuickConfig($this->_memPriceSetId, '0');
6a488035
TO
471 }
472 else {
473
9da8dc8c 474 CRM_Price_BAO_PriceField::setIsActive($params['mem_price_field_id'], '0');
6a488035
TO
475 }
476 }
477 }
478 }
479 parent::endPostProcess();
480 }
481
482 /**
483 * Return a descriptive name for the page, used in wizard header
484 *
485 * @return string
6a488035
TO
486 */
487 public function getTitle() {
488 return ts('Memberships');
489 }
96025800 490
6a488035 491}