/** * Build the price set form. * * @param CRM_Core_Form $form * * @return void */ public static function buildPriceSet(&$form) { $priceSetId = $form->get('priceSetId'); $userid = $form->getVar('_userID'); if (!$priceSetId) { return; } $validFieldsOnly = TRUE; $className = CRM_Utils_System::getClassName($form); if (in_array($className, array('CRM_Contribute_Form_Contribution', 'CRM_Member_Form_Membership'))) { $validFieldsOnly = FALSE; } $priceSet = self::getSetDetail($priceSetId, TRUE, $validFieldsOnly); $form->_priceSet = CRM_Utils_Array::value($priceSetId, $priceSet); $form->_quickConfig = $quickConfig = 0; if (CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $priceSetId, 'is_quick_config')) { $quickConfig = 1; } $form->assign('quickConfig', $quickConfig); if ($className == "CRM_Contribute_Form_Contribution_Main") { $form->_quickConfig = $quickConfig; } $form->assign('priceSet', $form->_priceSet); $component = 'contribution'; if ($className == 'CRM_Member_Form_Membership') { $component = 'membership'; } if ($className == 'CRM_Contribute_Form_Contribution_Main') { $feeBlock =& $form->_values['fee']; if (!empty($form->_useForMember)) { $component = 'membership'; } } else { $feeBlock =& $form->_priceSet['fields']; } // call the hook. CRM_Utils_Hook::buildAmount($component, $form, $feeBlock); foreach ($feeBlock as $field) { if (CRM_Utils_Array::value('visibility', $field) == 'public' || !$validFieldsOnly) { $options = CRM_Utils_Array::value('options', $field); if ($className == 'CRM_Contribute_Form_Contribution_Main' && ($component = 'membership')) { $checklifetime = self::checkCurrentMembership($options, $userid); if ($checklifetime) { $form->assign('ispricelifetime', TRUE); } } if (!is_array($options)) { continue; } CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::addQuickFormElement($form, 'price_' . $field['id'], $field['id'], FALSE, CRM_Utils_Array::value('is_required', $field, FALSE), NULL, $options); } } }