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']; } } }
/** * 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); } }
/** * 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); }
/** * build all the data structures needed to build the form * * @return void * @access public */ 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.')); } $this->setPageTitle(ts('Recurring Contribution record')); // Get the contact id $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this); $this->assign('contactID', $this->_contactID); // Get the action. $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add'); $this->assign('action', $this->_action); // Get the contribution recur id if update $this->_id = CRM_Utils_Request::retrieve('crid', 'Positive', $this); if (!empty($this->_id)) { $this->assign('contribRecurID', $this->_id); } $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); $this->assign('context', $this->_context); if ($this->_contactID) { list($this->userDisplayName, $this->userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID); $this->assign('displayName', $this->userDisplayName); } if ($this->_action & CRM_Core_Action::DELETE) { return; } // Get backoffice payment processors $this->assignPaymentRelatedVariables(); $this->_paymentProcessors = $this->getValidProcessors(); // Get recurring processors $this->_mode = 'live'; $this->assignProcessors(); $this->_values = array(); $ids = array(); $params = array('id' => $this->_id); if (!empty($this->_id)) { $recurring = new CRM_Contribute_BAO_ContributionRecur(); $recurring->copyValues($params); $recurring->find(TRUE); $ids['contributionrecur'] = $recurring->id; CRM_Core_DAO::storeValues($recurring, $this->_values); $membership = new CRM_Member_DAO_Membership(); $membership->contribution_recur_id = $this->_id; $membership->is_test = 0; if ($membership->find(TRUE)) { $this->_membershipID = $membership->id; $this->assign('membershipID', $this->_membershipID); } // Done allow Edit, if no back office support if (!array_key_exists($this->_values['payment_processor_id'], $this->_paymentProcessors)) { CRM_Core_Error::fatal(ts('You are not allowed to edit this recurring record, as back office edit is not supported by the related payment processor.')); } } // when custom data is included in this page if (!empty($_POST['hidden_custom'])) { $this->assign('type', 'ContributionRecur'); $this->assign('entityId', $this->_id); CRM_Custom_Form_CustomData::preProcess($this); CRM_Custom_Form_CustomData::buildQuickForm($this); CRM_Custom_Form_CustomData::setDefaultValues($this); } parent::preProcess(); }