public function preProcess() { // Check for edit permission. if (!CRM_Core_Permission::checkActionPermission('CiviMember', $this->_action)) { CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); } parent::preProcess(); $params = array(); $params['context'] = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'membership'); $params['id'] = CRM_Utils_Request::retrieve('id', 'Positive', $this); $params['mode'] = CRM_Utils_Request::retrieve('mode', 'String', $this); $this->setContextVariables($params); $this->assign('context', $this->_context); $this->assign('membershipMode', $this->_mode); }
public function preProcess() { // Check for edit permission. if (!CRM_Core_Permission::checkActionPermission('CiviMember', $this->_action)) { CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); } parent::preProcess(); $params = array(); $params['context'] = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'membership'); $params['id'] = CRM_Utils_Request::retrieve('id', 'Positive', $this); $params['mode'] = CRM_Utils_Request::retrieve('mode', 'String', $this); $this->setContextVariables($params); $this->assign('context', $this->_context); $this->assign('membershipMode', $this->_mode); $this->allMembershipTypeDetails = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, array(), TRUE); foreach ($this->allMembershipTypeDetails as $index => $membershipType) { if ($membershipType['auto_renew']) { $this->_recurMembershipTypes[$index] = $membershipType; $this->membershipTypeRenewalStatus[$index] = $membershipType['auto_renew']; } } }
/** * @param CRM_Contribute_Form_AbstractEditPayment|CRM_Contribute_Form_Contribution_Main|CRM_Core_Payment_ProcessorForm|CRM_Contribute_Form_UpdateBilling $form * @param array $processor * Array of properties including 'object' as loaded from CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors. * @param int|string $billing_profile_id * Id of a profile to be passed to the processor for the processor to merge with it's required fields. * (currently only implemented by manual/ pay-later processor) * * @param bool $isBackOffice * Is this a backoffice form. This could affect the display of the cvn or whether some processors show, * although the distinction is losing it's meaning as front end forms are used for back office and a permission * for the 'enter without cvn' is probably more appropriate. Paypal std does not support another user * entering details but once again the issue is not back office but 'another user'. * * @return bool */ public static function buildPaymentForm(&$form, $processor, $billing_profile_id, $isBackOffice) { //if the form has address fields assign to the template so the js can decide what billing fields to show $profileAddressFields = $form->get('profileAddressFields'); if (!empty($profileAddressFields)) { $form->assign('profileAddressFields', $profileAddressFields); } if (!empty($processor['object']) && $processor['object']->buildForm($form)) { return NULL; } self::setPaymentFieldsByProcessor($form, $processor, $billing_profile_id, $isBackOffice); self::addCommonFields($form, $form->_paymentFields); self::addRules($form, $form->_paymentFields); return !empty($form->_paymentFields); }
/** * Set variables up before form is built. */ public function preProcess() { // Check permission for action. if (!CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) { CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); } parent::preProcess(); $this->_formType = CRM_Utils_Array::value('formType', $_GET); // Get price set id. $this->_priceSetId = CRM_Utils_Array::value('priceSetId', $_GET); $this->set('priceSetId', $this->_priceSetId); $this->assign('priceSetId', $this->_priceSetId); // Get the pledge payment id $this->_ppID = CRM_Utils_Request::retrieve('ppid', 'Positive', $this); $this->assign('action', $this->_action); // Get the contribution id if update $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); if (!empty($this->_id)) { $this->assign('contribID', $this->_id); } $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); $this->assign('context', $this->_context); $this->_compId = CRM_Utils_Request::retrieve('compId', 'Positive', $this); $this->_compContext = CRM_Utils_Request::retrieve('compContext', 'String', $this); //set the contribution mode. $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this); $this->assign('contributionMode', $this->_mode); if ($this->_action & CRM_Core_Action::DELETE) { return; } $this->assign('showCheckNumber', TRUE); $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail(); $this->assignPaymentRelatedVariables(); if (in_array('CiviPledge', CRM_Core_Config::singleton()->enableComponents) && !$this->_formType) { $this->preProcessPledge(); } if ($this->_id) { $this->showRecordLinkMesssage($this->_id); } $this->_values = array(); // Current contribution id. if ($this->_id) { $this->assignPremiumProduct($this->_id); $this->buildValuesAndAssignOnline_Note_Type($this->_id, $this->_values); } // when custom data is included in this page if (!empty($_POST['hidden_custom'])) { $this->applyCustomData('Contribution', CRM_Utils_Array::value('financial_type_id', $_POST), $this->_id); } $this->_lineItems = array(); if ($this->_id) { if (!empty($this->_compId) && $this->_compContext == 'participant') { $this->assign('compId', $this->_compId); $lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_compId); } else { $lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'contribution', 1, TRUE, TRUE); } empty($lineItem) ? NULL : ($this->_lineItems[] = $lineItem); } $this->assign('lineItem', empty($this->_lineItems) ? FALSE : $this->_lineItems); // Set title if ($this->_mode) { $this->setPageTitle($this->_ppID ? ts('Credit Card Pledge Payment') : ts('Credit Card Contribution')); } else { $this->setPageTitle($this->_ppID ? ts('Pledge Payment') : ts('Contribution')); } if ($this->_id) { CRM_Contribute_Form_SoftCredit::preprocess($this); } }
/** * @param CRM_Contribute_Form_AbstractEditPayment|CRM_Contribute_Form_Contribution_Main|CRM_Core_Payment_ProcessorForm|CRM_Contribute_Form_UpdateBilling $form * @param array $processor * Array of properties including 'object' as loaded from CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors. * @param bool $isBillingDataOptional * This manifests for 'NULL' (pay later) payment processor as the addition of billing fields to the form and. * for payment processors that gather payment data on site as rendering the fields as not being required. (not entirely sure why but this * is implemented for back office forms) * * @return bool */ public static function buildPaymentForm(&$form, $processor, $isBillingDataOptional) { //if the form has address fields assign to the template so the js can decide what billing fields to show $profileAddressFields = $form->get('profileAddressFields'); if (!empty($profileAddressFields)) { $form->assign('profileAddressFields', $profileAddressFields); } // $processor->buildForm appears to be an undocumented (possibly unused) option for payment processors // which was previously available only in some form flows if (!empty($form->_paymentProcessor) && !empty($form->_paymentProcessor['object']) && $form->_paymentProcessor['object']->isSupported('buildForm')) { $form->_paymentProcessor['object']->buildForm($form); return NULL; } self::setPaymentFieldsByProcessor($form, $processor, empty($isBillingDataOptional)); self::addCommonFields($form, !$isBillingDataOptional, $form->_paymentFields); self::addRules($form, $form->_paymentFields); self::addPaypalExpressCode($form); return !empty($form->_paymentFields); }
/** * Set variables up before form is built. * * @return void */ public function preProcess() { $this->_showFeeBlock = CRM_Utils_Array::value('eventId', $_GET); $this->assign('showFeeBlock', FALSE); $this->assign('feeBlockPaid', FALSE); $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this); $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this); $this->_eID = CRM_Utils_Request::retrieve('eid', 'Positive', $this); $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); $this->assign('context', $this->_context); if ($this->_contactId) { $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); $this->assign('displayName', $displayName); $this->setPageTitle(ts('Event Registration for %1', array(1 => $displayName))); } else { $this->setPageTitle(ts('Event Registration')); } // check the current path, if search based, then dont get participantID // CRM-5792 $path = CRM_Utils_System::currentPath(); if (strpos($path, 'civicrm/contact/search') === 0 || strpos($path, 'civicrm/group/search') === 0) { $this->_id = NULL; } else { $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); } if ($this->_id) { $this->assign('participantId', $this->_id); $this->_paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'id', 'participant_id'); $this->assign('hasPayment', $this->_paymentId); // CRM-12615 - Get payment information from the primary registration if (!$this->_paymentId && $this->_action == CRM_Core_Action::UPDATE) { $registered_by_id = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'registered_by_id', 'id'); if ($registered_by_id) { $this->_paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $registered_by_id, 'id', 'participant_id'); $this->assign('registeredByParticipantId', $registered_by_id); } } } // get the option value for custom data type $this->_roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name'); $this->_eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name'); $this->_eventTypeCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventType', 'name'); $this->assign('roleCustomDataTypeID', $this->_roleCustomDataTypeID); $this->assign('eventNameCustomDataTypeID', $this->_eventNameCustomDataTypeID); $this->assign('eventTypeCustomDataTypeID', $this->_eventTypeCustomDataTypeID); if ($this->_mode) { $this->assign('participantMode', $this->_mode); $this->assignPaymentRelatedVariables(); } if ($this->_showFeeBlock) { $this->assign('showFeeBlock', TRUE); $isMonetary = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_showFeeBlock, 'is_monetary'); if ($isMonetary) { $this->assign('feeBlockPaid', TRUE); } return CRM_Event_Form_EventFees::preProcess($this); } //custom data related code $this->_cdType = CRM_Utils_Array::value('type', $_GET); $this->assign('cdType', FALSE); if ($this->_cdType) { $this->assign('cdType', TRUE); return CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, NULL, NULL, NULL, TRUE); } //check the mode when this form is called either single or as //search task action if ($this->_id || $this->_contactId || $this->_context == 'standalone') { $this->_single = TRUE; $this->assign('urlPath', 'civicrm/contact/view/participant'); if (!$this->_id && !$this->_contactId) { $breadCrumbs = array(array('title' => ts('CiviEvent Dashboard'), 'url' => CRM_Utils_System::url('civicrm/event', 'reset=1'))); CRM_Utils_System::appendBreadCrumb($breadCrumbs); } } else { //set the appropriate action $context = $this->get('context'); $urlString = 'civicrm/contact/search'; $this->_action = CRM_Core_Action::BASIC; switch ($context) { case 'advanced': $urlString = 'civicrm/contact/search/advanced'; $this->_action = CRM_Core_Action::ADVANCED; break; case 'builder': $urlString = 'civicrm/contact/search/builder'; $this->_action = CRM_Core_Action::PROFILE; break; case 'basic': $urlString = 'civicrm/contact/search/basic'; $this->_action = CRM_Core_Action::BASIC; break; case 'custom': $urlString = 'civicrm/contact/search/custom'; $this->_action = CRM_Core_Action::COPY; break; } parent::preProcess(); $this->_single = FALSE; $this->_contactId = NULL; //set ajax path, this used for custom data building $this->assign('urlPath', $urlString); $this->assign('urlPathVar', "_qf_Participant_display=true&qfKey={$this->controller->_key}"); } $this->assign('single', $this->_single); if (!$this->_id) { $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add'); } $this->assign('action', $this->_action); // check for edit permission if (!CRM_Core_Permission::checkActionPermission('CiviEvent', $this->_action)) { CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); } if ($this->_action & CRM_Core_Action::DELETE) { // check delete permission for contribution if ($this->_id && $this->_paymentId && !CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) { CRM_Core_Error::fatal(ts("This Participant is linked to a contribution. You must have 'delete in CiviContribute' permission in order to delete this record.")); } return; } if ($this->_id) { // assign participant id to the template $this->assign('participantId', $this->_id); $this->_roleId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'role_id'); } // when fee amount is included in form if (!empty($_POST['hidden_feeblock']) || !empty($_POST['send_receipt'])) { CRM_Event_Form_EventFees::preProcess($this); CRM_Event_Form_EventFees::buildQuickForm($this); CRM_Event_Form_EventFees::setDefaultValues($this); } // when custom data is included in this page if (!empty($_POST['hidden_custom'])) { // Custom data of type participant role // Note: Some earlier commits imply $_POST['role_id'] could be a comma separated string, // not sure if that ever really happens if (!empty($_POST['role_id'])) { foreach ($_POST['role_id'] as $roleID) { CRM_Custom_Form_CustomData::preProcess($this, $this->_roleCustomDataTypeID, $roleID, 1, 'Participant', $this->_id); CRM_Custom_Form_CustomData::buildQuickForm($this); CRM_Custom_Form_CustomData::setDefaultValues($this); } } //custom data of type participant event CRM_Custom_Form_CustomData::preProcess($this, $this->_eventNameCustomDataTypeID, $_POST['event_id'], 1, 'Participant', $this->_id); CRM_Custom_Form_CustomData::buildQuickForm($this); CRM_Custom_Form_CustomData::setDefaultValues($this); // custom data of type participant event type $eventTypeId = NULL; if ($eventId = CRM_Utils_Array::value('event_id', $_POST)) { $eventTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventId, 'event_type_id', 'id'); } CRM_Custom_Form_CustomData::preProcess($this, $this->_eventTypeCustomDataTypeID, $eventTypeId, 1, 'Participant', $this->_id); CRM_Custom_Form_CustomData::buildQuickForm($this); CRM_Custom_Form_CustomData::setDefaultValues($this); //custom data of type participant, ( we 'null' to reset subType and subName) CRM_Custom_Form_CustomData::preProcess($this, 'null', 'null', 1, 'Participant', $this->_id); CRM_Custom_Form_CustomData::buildQuickForm($this); CRM_Custom_Form_CustomData::setDefaultValues($this); } // CRM-4395, get the online pending contribution id. $this->_onlinePendingContributionId = NULL; if (!$this->_mode && $this->_id && $this->_action & CRM_Core_Action::UPDATE) { $this->_onlinePendingContributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($this->_id, 'Event'); } $this->set('onlinePendingContributionId', $this->_onlinePendingContributionId); }
/** * process the form after the input has been submitted and validated * * @access public * @return None */ public function postProcess() { $session = CRM_Core_Session::singleton(); if ($this->_action & CRM_Core_Action::DELETE) { // Delete the linked contributions $contribution = new CRM_Contribute_DAO_Contribution(); $contribution->contribution_recur_id = $this->_id; $contribution->find(); while ($contribution->fetch()) { CRM_Contribute_BAO_Contribution::deleteContribution($contribution->id); } // Delete recurring contribution record CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($this->_id); $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactID}&selectedChild=contribute-recur")); return NULL; } // get the submitted form values. $submittedValues = $this->controller->exportValues($this->_name); // get the required field value only. $formValues = $submittedValues; $ids = array(); if ($this->_contactID) { $params['contact_id'] = $this->_contactID; } $params['currency'] = CRM_Contribute_Form_AbstractEditPayment::getCurrency($submittedValues); $dates = array('start_date', 'end_date', 'cancel_date', 'next_sched_contribution_date'); foreach ($dates as $d) { $params[$d] = CRM_Utils_Date::processDate($formValues[$d], $formValues[$d . '_time'], TRUE); } if (empty($this->_id)) { $params['create_date'] = CRM_Utils_Date::processDate(date('Y-m-d')); } if ($this->_action & CRM_Core_Action::ADD) { $params['next_sched_contribution_date'] = $params['start_date']; } $fields = array('payment_processor_id', 'processor_id', 'trxn_id', 'financial_type_id', 'amount', 'payment_instrument_id', 'frequency_interval', 'frequency_unit', 'cycle_day', 'contribution_status_id'); foreach ($fields as $f) { $params[$f] = CRM_Utils_Array::value($f, $formValues); } $params['id'] = $this->_id; // build custom data getFields array $customFields = CRM_Core_BAO_CustomField::getFields('ContributionRecur', FALSE, FALSE, NULL, NULL, TRUE); $params['custom'] = CRM_Core_BAO_CustomField::postProcess($_POST, $this->_id, 'ContributionRecur'); $contributionRecur = CRM_Contribute_BAO_ContributionRecur::create($params); // Link the recurring contribution with membership record, if selected if ($this->_action == 1 && !empty($formValues['membership_id'])) { civicrm_api3('Membership', 'create', array('id' => $formValues['membership_id'], 'contribution_recur_id' => $contributionRecur->id)); } // Move the recurring record if (isset($submittedValues['move_recurring_record']) && $submittedValues['move_recurring_record'] == 1) { self::moveRecurringRecord($submittedValues); } $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactID}&selectedChild=contribute-recur")); }