public function preProcess() { parent::preProcess(); $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); $this->assign('context', $this->_context); $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this); if ($this->_action & CRM_Core_Action::UPDATE) { CRM_Utils_System::setTitle(ts('Configure Survey') . ' - ' . $this->_surveyTitle); } // when custom data is included in this page if (!empty($_POST['hidden_custom'])) { CRM_Custom_Form_CustomData::preProcess($this); CRM_Custom_Form_CustomData::buildQuickForm($this); } if ($this->_name != 'Petition') { $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey'); CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Survey Dashboard'), 'url' => $url))); } $this->_values = $this->get('values'); if (!is_array($this->_values)) { $this->_values = array(); if ($this->_surveyId) { $params = array('id' => $this->_surveyId); CRM_Campaign_BAO_Survey::retrieve($params, $this->_values); } $this->set('values', $this->_values); } $this->assign('action', $this->_action); $this->assign('surveyId', $this->_surveyId); // for custom data $this->assign('entityID', $this->_surveyId); }
/** * Function to set variables up before form is built * * @return void * @access public */ function preProcess() { //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); } parent::preProcess(); if ($this->_id) { $this->assign('entityID', $this->_id); $eventType = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'event_type_id'); } else { $eventType = 'null'; } $showLocation = false; // when custom data is included in this page if (CRM_Utils_Array::value("hidden_custom", $_POST)) { $this->set('type', 'Event'); $this->set('subType', CRM_Utils_Array::value('event_type_id', $_POST)); $this->set('entityId', $this->_id); CRM_Custom_Form_Customdata::preProcess($this); CRM_Custom_Form_Customdata::buildQuickForm($this); CRM_Custom_Form_Customdata::setDefaultValues($this); } }
public function preProcess() { if (!CRM_Campaign_BAO_Campaign::accessCampaign()) { CRM_Utils_System::permissionDenied(); } $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST'); $this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE); if ($this->_surveyId) { $this->_single = TRUE; $params = array('id' => $this->_surveyId); CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo); $this->_surveyTitle = $surveyInfo['title']; $this->assign('surveyTitle', $this->_surveyTitle); CRM_Utils_System::setTitle(ts('Configure Survey - %1', array(1 => $this->_surveyTitle))); } $this->assign('action', $this->_action); $this->assign('surveyId', $this->_surveyId); // when custom data is included in this page if (!empty($_POST['hidden_custom'])) { $this->set('type', 'Event'); $this->set('entityId', $this->_surveyId); CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Survey', $this->_surveyId); CRM_Custom_Form_CustomData::buildQuickForm($this); CRM_Custom_Form_CustomData::setDefaultValues($this); } // CRM-11480, CRM-11682 // Preload libraries required by the "Questions" tab CRM_UF_Page_ProfileEditor::registerProfileScripts(); CRM_UF_Page_ProfileEditor::registerSchemas(array('IndividualModel', 'ActivityModel')); CRM_Campaign_Form_Survey_TabHeader::build($this); }
public function preProcess() { // we do not want to display recently viewed items, so turn off $this->assign('displayRecent', FALSE); // component null in controller object - fix? dgg // $this->_component = $this->controller->get('component'); $this->_component = CRM_Utils_Request::retrieve('component', 'String', $this); $this->assign('component', $this->_component); $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); $this->assign('context', $this->_context); $this->_pageId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE); $title = ts('Setup a Personal Campaign Page - Step 2'); if ($this->_pageId) { $title = ts('Edit Your Personal Campaign Page'); } CRM_Utils_System::setTitle($title); //MV: to get the Custom Data preProcess if (CRM_Core_Permission::check('administer CiviCRM')) { $this->_cdType = 'PCP'; $this->_customValueCount = 1; CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, $this->_cdType, $this->_pageId, NULL); } //END parent::preProcess(); }
public function preProcess() { if (!CRM_Campaign_BAO_Campaign::accessCampaign()) { CRM_Utils_System::permissionDenied(); } $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); $this->assign('context', $this->_context); $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this); if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::DELETE)) { $this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); if ($this->_action & CRM_Core_Action::UPDATE) { CRM_Utils_System::setTitle(ts('Edit Survey')); } else { CRM_Utils_System::setTitle(ts('Delete Survey')); } } $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); } // when custom data is included in this page if (!empty($_POST['hidden_custom'])) { CRM_Custom_Form_CustomData::preProcess($this); CRM_Custom_Form_CustomData::buildQuickForm($this); } $session = CRM_Core_Session::singleton(); $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey'); $session->pushUserContext($url); $this->_values = $this->get('values'); if (!is_array($this->_values)) { $this->_values = array(); if ($this->_surveyId) { $params = array('id' => $this->_surveyId); CRM_Campaign_BAO_Survey::retrieve($params, $this->_values); } $this->set('values', $this->_values); } $this->assign('action', $this->_action); $this->assign('surveyId', $this->_surveyId); // for custom data $this->assign('entityID', $this->_surveyId); if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::DELETE)) { $this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); if ($this->_action & CRM_Core_Action::UPDATE) { CRM_Utils_System::setTitle(ts('Edit Petition')); } else { CRM_Utils_System::setTitle(ts('Delete Petition')); } } $session = CRM_Core_Session::singleton(); $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=petition'); $session->pushUserContext($url); CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Petition Dashboard'), 'url' => $url))); }
/** * Call preprocess. */ public function preProcess() { parent::preProcess(); $this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this, TRUE, NULL, $_REQUEST); $this->assign('customGroupId', $this->_groupID); $customRecId = CRM_Utils_Request::retrieve('customRecId', 'Positive', $this, FALSE, 1, $_REQUEST); $cgcount = CRM_Utils_Request::retrieve('cgcount', 'Positive', $this, FALSE, 1, $_REQUEST); $subType = CRM_Contact_BAO_Contact::getContactSubType($this->_contactId, ','); CRM_Custom_Form_CustomData::preProcess($this, NULL, $subType, $cgcount, $this->_contactType, $this->_contactId); }
/** * call preprocess */ public function preProcess() { //get all the existing email addresses $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE, NULL, $_REQUEST); $this->assign('contactId', $this->_contactId); $this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this, TRUE, NULL, $_REQUEST); $this->assign('customGroupId', $this->_groupID); $type = CRM_Contact_BAO_Contact::getContactType($this->_contactId); $subType = CRM_Contact_BAO_Contact::getContactSubType($this->_contactId, ','); CRM_Custom_Form_CustomData::preProcess($this, null, $subType, 1, $type, $this->_contactId); }
/** * Build all the data structures needed to build the form. * * @param CRM_Core_Form $form */ public static function preProcess(&$form) { $form->_type = CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject); $form->_subType = CRM_Utils_Request::retrieve('subType', 'String', CRM_Core_DAO::$_nullObject); //build the custom data as other blocks. //$form->assign( "addBlock", false ); if ($form->_type) { $form->_addBlockName = 'CustomData'; $form->assign("addBlock", TRUE); $form->assign("blockName", $form->_addBlockName); } CRM_Custom_Form_CustomData::preProcess($form, NULL, $form->_subType, NULL, $form->_type ? $form->_type : $form->_contactType); //assign group tree after build. $form->assign('groupTree', $form->_groupTree); }
/** * Set variables up before form is built. */ public function preProcess() { parent::preProcess(); if ($this->_id) { $this->assign('entityID', $this->_id); $eventType = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'event_type_id'); } else { $eventType = 'null'; } $showLocation = FALSE; // when custom data is included in this page if (!empty($_POST['hidden_custom'])) { $this->set('type', 'Event'); $this->set('subType', CRM_Utils_Array::value('event_type_id', $_POST)); $this->set('entityId', $this->_id); CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_eventType, 1, 'Event', $this->_id); CRM_Custom_Form_CustomData::buildQuickForm($this); CRM_Custom_Form_CustomData::setDefaultValues($this); } }
public function preProcess() { //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); } // get price set id. $this->_priceSetId = CRM_Utils_Array::value('priceSetId', $_GET); $this->set('priceSetId', $this->_priceSetId); $this->assign('priceSetId', $this->_priceSetId); // action $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add'); $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this); $this->_processors = array(); CRM_Core_Resources::singleton()->addSetting(array('ids' => array('contact' => $this->_contactID))); // 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')); } if ($this->_action & CRM_Core_Action::DELETE) { $contributionID = CRM_Member_BAO_Membership::getMembershipContributionId($this->_id); // check delete permission for contribution if ($this->_id && $contributionID && !CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) { CRM_Core_Error::fatal(ts("This Membership is linked to a contribution. You must have 'delete in CiviContribute' permission in order to delete this record.")); } } $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); $this->assign('context', $this->_context); if ($this->_id) { $this->_memType = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_id, 'membership_type_id'); $this->_membershipIDs[] = $this->_id; } $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this); $this->assign('membershipMode', $this->_mode); if ($this->_mode) { $this->_paymentProcessor = array('billing_mode' => 1); $validProcessors = array(); $processors = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, 'billing_mode IN ( 1, 3 )'); foreach ($processors as $ppID => $label) { $paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($ppID, $this->_mode); if ($paymentProcessor['payment_processor_type'] == 'PayPal' && !$paymentProcessor['user_name']) { continue; } elseif ($paymentProcessor['payment_processor_type'] == 'Dummy' && $this->_mode == 'live') { continue; } else { $paymentObject = CRM_Core_Payment::singleton($this->_mode, $paymentProcessor, $this); $error = $paymentObject->checkConfig(); if (empty($error)) { $validProcessors[$ppID] = $label; } $paymentObject = NULL; } } if (empty($validProcessors)) { CRM_Core_Error::fatal(ts('Could not find valid payment processor for this page')); } else { $this->_processors = $validProcessors; } // also check for billing information // get the billing location type $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate'); // CRM-8108 remove ts around Billing location type //$this->_bltID = array_search( ts('Billing'), $locationTypes ); $this->_bltID = array_search('Billing', $locationTypes); if (!$this->_bltID) { CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing'))); } $this->set('bltID', $this->_bltID); $this->assign('bltID', $this->_bltID); $this->_fields = array(); CRM_Core_Payment_Form::setCreditCardFields($this); // this required to show billing block $this->assign_by_ref('paymentProcessor', $paymentProcessor); $this->assign('hidePayPalExpress', TRUE); } if ($this->_action & CRM_Core_Action::ADD) { if (!CRM_Member_BAO_Membership::statusAvailabilty($this->_contactID)) { // all possible statuses are disabled - redirect back to contact form CRM_Core_Error::statusBounce(ts('There are no configured membership statuses. You cannot add this membership until your membership statuses are correctly configured')); } if ($this->_contactID) { //check whether contact has a current membership so we can alert user that they may want to do a renewal instead $contactMemberships = array(); $memParams = array('contact_id' => $this->_contactID); CRM_Member_BAO_Membership::getValues($memParams, $contactMemberships, TRUE); $cMemTypes = array(); foreach ($contactMemberships as $mem) { $cMemTypes[] = $mem['membership_type_id']; } if (count($cMemTypes) > 0) { $memberorgs = CRM_Member_BAO_MembershipType::getMemberOfContactByMemTypes($cMemTypes); $mems_by_org = array(); foreach ($contactMemberships as $memid => $mem) { $mem['member_of_contact_id'] = CRM_Utils_Array::value($mem['membership_type_id'], $memberorgs); if (CRM_Utils_Array::value('membership_end_date', $mem)) { $mem['membership_end_date'] = CRM_Utils_Date::customformat($mem['membership_end_date']); } $mem['membership_type'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $mem['membership_type_id'], 'name', 'id'); $mem['membership_status'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $mem['status_id'], 'label', 'id'); if ($this->_mode) { $mem['renewUrl'] = CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$mem['id']}&context=membership&selectedChild=member&mode=live"); } else { $mem['renewUrl'] = CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$mem['id']}&context=membership&selectedChild=member"); } $mem['membershipTab'] = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$this->_contactID}&selectedChild=member"); $mems_by_org[$mem['member_of_contact_id']] = $mem; } $resources = CRM_Core_Resources::singleton(); $resources->addSetting(array('existingMems' => array('memberorgs' => $mems_by_org))); $resources->addScriptFile('civicrm', 'templates/CRM/Member/Form/Membership.js'); } } else { $resources = CRM_Core_Resources::singleton(); $resources->addScriptFile('civicrm', 'templates/CRM/Member/Form/MembershipStandalone.js'); $statuses = array(); $membershipStatus = new CRM_Member_DAO_MembershipStatus(); $membershipStatus->is_current_member = 1; $membershipStatus->find(); $membershipStatus->selectAdd(); $membershipStatus->selectAdd('id'); while ($membershipStatus->fetch()) { $statuses[$membershipStatus->id] = $membershipStatus->label; } $membershipStatus->free(); $passthru = array('typeorgs' => CRM_Member_BAO_MembershipType::getMembershipTypeOrganization(), 'memtypes' => CRM_Member_BAO_MembershipType::getMembershipTypes(FALSE), 'statuses' => $statuses); $resources->addSetting(array('existingMems' => $passthru)); } } // when custom data is included in this page if (CRM_Utils_Array::value('hidden_custom', $_POST)) { CRM_Custom_Form_CustomData::preProcess($this); 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, 'Membership'); } $this->assign('onlinePendingContributionId', $this->_onlinePendingContributionId); $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail(); // Set title if ($this->_contactID) { $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactID); // Check if this is default domain contact CRM-10482 if (CRM_Contact_BAO_Contact::checkDomainContact($this->_contactID)) { $displayName .= ' (' . ts('default organization') . ')'; } // omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container CRM_Utils_System::setTitle(ts('Membership for') . ' ' . $displayName); } parent::preProcess(); }
/** * @param string $type * Eg 'Contribution'. * @param string $subType * @param int $entityId */ public function applyCustomData($type, $subType, $entityId) { $this->set('type', $type); $this->set('subType', $subType); $this->set('entityId', $entityId); CRM_Custom_Form_CustomData::preProcess($this, NULL, $subType, 1, $type, $entityId); CRM_Custom_Form_CustomData::buildQuickForm($this); CRM_Custom_Form_CustomData::setDefaultValues($this); }
/** * Function to build the form * * @return None * @access public */ function preProcess() { $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); } $this->_caseId = CRM_Utils_Request::retrieve('id', 'Positive', $this); $this->_currentlyViewedContactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this); if ($this->_action & CRM_Core_Action::ADD && !$this->_currentlyViewedContactId) { // check for add contacts permissions if (!CRM_Core_Permission::check('add contacts')) { CRM_Utils_System::permissionDenied(); return; } } //CRM-4418 if (!CRM_Core_Permission::checkActionPermission('CiviCase', $this->_action)) { CRM_Core_Error::fatal(ts('You do not have permission to access this page')); } if ($this->_action & CRM_Core_Action::DELETE || $this->_action & CRM_Core_Action::RENEW) { return TRUE; } if (!$this->_caseId) { $caseAttributes = array('case_type' => CRM_Case_PseudoConstant::caseType(), 'case_status' => CRM_Case_PseudoConstant::caseStatus(), 'encounter_medium' => CRM_Case_PseudoConstant::encounterMedium()); foreach ($caseAttributes as $key => $values) { if (empty($values)) { CRM_Core_Error::fatal(ts('You do not have any active %1', array(1 => str_replace('_', ' ', $key)))); break; } } } if ($this->_action & CRM_Core_Action::ADD) { $this->_activityTypeId = CRM_Core_OptionGroup::getValue('activity_type', 'Open Case', 'name'); if (!$this->_activityTypeId) { CRM_Core_Error::fatal(ts('The Open Case activity type is missing or disabled. Please have your site administrator check Administer > Option Lists > Activity Types for the CiviCase component.')); } } //check for case permissions. if (!CRM_Case_BAO_Case::accessCiviCase()) { CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); } if ($this->_action & CRM_Core_Action::ADD && (!CRM_Core_Permission::check('access all cases and activities') && !CRM_Core_Permission::check('add cases'))) { CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); } if ($this->_activityTypeFile = CRM_Activity_BAO_Activity::getFileForActivityTypeId($this->_activityTypeId, 'Case')) { $this->assign('activityTypeFile', $this->_activityTypeFile); } $details = CRM_Case_PseudoConstant::caseActivityType(FALSE); CRM_Utils_System::setTitle($details[$this->_activityTypeId]['label']); $this->assign('activityType', $details[$this->_activityTypeId]['label']); $this->assign('activityTypeDescription', $details[$this->_activityTypeId]['description']); if (isset($this->_currentlyViewedContactId)) { $contact = new CRM_Contact_DAO_Contact(); $contact->id = $this->_currentlyViewedContactId; if (!$contact->find(TRUE)) { CRM_Core_Error::statusBounce(ts('Client contact does not exist: %1', array(1 => $this->_currentlyViewedContactId))); } $this->assign('clientName', $contact->display_name); } $session = CRM_Core_Session::singleton(); $this->_currentUserId = $session->get('userID'); //when custom data is included in this page CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_activityTypeId, 1, 'Activity'); eval("CRM_Case_Form_Activity_{$this->_activityTypeFile}::preProcess( \$this );"); $activityGroupTree = $this->_groupTree; // for case custom fields to populate with defaults if (CRM_Utils_Array::value('hidden_custom', $_POST)) { CRM_Custom_Form_CustomData::preProcess($this); CRM_Custom_Form_CustomData::buildQuickForm($this); } // so that grouptree is not populated with case fields, since the grouptree is used // for populating activity custom fields. $this->_groupTree = $activityGroupTree; }
function preProcess() { //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); } $this->_contactId = $this->get('contactId'); $this->_relationshipId = $this->get('id'); $this->_rtype = CRM_Utils_Request::retrieve('rtype', 'String', $this); $this->_rtypeId = CRM_Utils_Request::retrieve('relTypeId', 'String', $this); $this->_display_name_a = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'display_name'); $this->assign('sort_name_a', $this->_display_name_a); $this->_caseId = CRM_Utils_Request::retrieve('caseID', 'Integer', $this); //get the relationship values. $this->_values = array(); if ($this->_relationshipId) { $params = array('id' => $this->_relationshipId); CRM_Core_DAO::commonRetrieve('CRM_Contact_DAO_Relationship', $params, $this->_values); } if (!$this->_rtypeId) { $params = $this->controller->exportValues($this->_name); if (isset($params['relationship_type_id'])) { $this->_rtypeId = $params['relationship_type_id']; } else { if (!empty($this->_values)) { $this->_rtypeId = $this->_values['relationship_type_id'] . '_' . $this->_rtype; } } } //get the relationship type id $this->_relationshipTypeId = str_replace(array('_a_b', '_b_a'), array('', ''), $this->_rtypeId); //get the relationship type if (!$this->_rtype) { $this->_rtype = str_replace($this->_relationshipTypeId . '_', '', $this->_rtypeId); } $this->assign("rtype", $this->_rtype); require_once 'CRM/Core/PseudoConstant.php'; //use name as it remain constant, CRM-3336 $this->_allRelationshipNames = CRM_Core_PseudoConstant::relationshipType('name'); // when custom data is included in this page if (CRM_Utils_Array::value("hidden_custom", $_POST)) { CRM_Custom_Form_Customdata::preProcess($this); CRM_Custom_Form_Customdata::buildQuickForm($this); CRM_Custom_Form_Customdata::setDefaultValues($this); } }
/** * pre processing work done here. * * gets session variables for table name, id of entity in table, type of entity and stores them. * * @param * @return void * * @access public * */ function preProcess() { $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); } $this->_groupID = CRM_Utils_Request::retrieve('groupId', 'Positive', $this, true); $this->_tableID = CRM_Utils_Request::retrieve('tableId', 'Positive', $this, true); require_once "CRM/Contact/BAO/Contact.php"; $this->_contactType = CRM_Contact_BAO_Contact::getContactType($this->_tableID); $this->_contactSubType = CRM_Contact_BAO_Contact::getContactSubType($this->_tableID); $this->assign('contact_type', $this->_contactType); $this->assign('contact_subtype', $this->_contactSubType); list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_tableID); CRM_Utils_System::setTitle($displayName, $contactImage . ' ' . $displayName); // when custom data is included in this page if (CRM_Utils_Array::value("hidden_custom", $_POST)) { for ($i; $i <= $_POST['hidden_custom_group_count'][$this->_groupID]; $i++) { CRM_Custom_Form_CustomData::preProcess($this, null, null, $i); CRM_Custom_Form_CustomData::buildQuickForm($this); CRM_Custom_Form_CustomData::setDefaultValues($this); } } }
/** * Set up variables to build the form. */ public function preProcess() { $this->_id = $this->get('id'); if ($this->_id) { $breadCrumb = array(array('title' => ts('Manage Groups'), 'url' => CRM_Utils_System::url('civicrm/group', 'reset=1'))); CRM_Utils_System::appendBreadCrumb($breadCrumb); $this->_groupValues = array(); $params = array('id' => $this->_id); $this->_group = CRM_Contact_BAO_Group::retrieve($params, $this->_groupValues); $this->_title = $this->_groupValues['title']; } $this->assign('action', $this->_action); $this->assign('showBlockJS', TRUE); if ($this->_action == CRM_Core_Action::DELETE) { if (isset($this->_id)) { $this->assign('title', $this->_title); $this->assign('count', CRM_Contact_BAO_Group::memberCount($this->_id)); CRM_Utils_System::setTitle(ts('Confirm Group Delete')); } if ($this->_groupValues['is_reserved'] == 1 && !CRM_Core_Permission::check('administer reserved groups')) { CRM_Core_Error::statusBounce(ts("You do not have sufficient permission to delete this reserved group.")); } } else { if ($this->_groupValues['is_reserved'] == 1 && !CRM_Core_Permission::check('administer reserved groups')) { CRM_Core_Error::statusBounce(ts("You do not have sufficient permission to change settings for this reserved group.")); } if (isset($this->_id)) { $groupValues = array('id' => $this->_id, 'title' => $this->_title, 'saved_search_id' => isset($this->_groupValues['saved_search_id']) ? $this->_groupValues['saved_search_id'] : ''); if (isset($this->_groupValues['saved_search_id'])) { $groupValues['mapping_id'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_groupValues['saved_search_id'], 'mapping_id'); $groupValues['search_custom_id'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_groupValues['saved_search_id'], 'search_custom_id'); } if (!empty($this->_groupValues['created_id'])) { $groupValues['created_by'] = CRM_Core_DAO::getFieldValue("CRM_Contact_DAO_Contact", $this->_groupValues['created_id'], 'sort_name', 'id'); } if (!empty($this->_groupValues['modified_id'])) { $groupValues['modified_by'] = CRM_Core_DAO::getFieldValue("CRM_Contact_DAO_Contact", $this->_groupValues['modified_id'], 'sort_name', 'id'); } $this->assign_by_ref('group', $groupValues); CRM_Utils_System::setTitle(ts('Group Settings: %1', array(1 => $this->_title))); } $session = CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url('civicrm/group', 'reset=1')); } //build custom data CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Group', $this->_id); }
/** * set up variables to build the form * * @return void * @acess protected */ function preProcess() { $this->_id = $this->get('id'); if ($this->_id) { $breadCrumb = array(array('title' => ts('Manage Groups'), 'url' => CRM_Utils_System::url('civicrm/group', 'reset=1'))); CRM_Utils_System::appendBreadCrumb($breadCrumb); $this->_groupValues = array(); $params = array('id' => $this->_id); $this->_group =& CRM_Contact_BAO_Group::retrieve($params, $this->_groupValues); $this->_title = $this->_groupValues['title']; } $this->assign('action', $this->_action); $this->assign('showBlockJS', TRUE); if ($this->_action == CRM_Core_Action::DELETE) { if (isset($this->_id)) { $this->assign('title', $this->_title); $this->assign('count', CRM_Contact_BAO_Group::memberCount($this->_id)); CRM_Utils_System::setTitle(ts('Confirm Group Delete')); } } else { if (isset($this->_id)) { $groupValues = array('id' => $this->_id, 'title' => $this->_title, 'saved_search_id' => isset($this->_groupValues['saved_search_id']) ? $this->_groupValues['saved_search_id'] : ''); if (isset($this->_groupValues['saved_search_id'])) { $groupValues['mapping_id'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_groupValues['saved_search_id'], 'mapping_id'); $groupValues['search_custom_id'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_groupValues['saved_search_id'], 'search_custom_id'); } $this->assign_by_ref('group', $groupValues); CRM_Utils_System::setTitle(ts('Group Settings: %1', array(1 => $this->_title))); } $session = CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url('civicrm/group', 'reset=1')); } //build custom data CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Group', $this->_id); }
/** * Pre-process form. * * @throws \Exception */ public function preProcess() { // This string makes up part of the class names, differentiating them (not sure why) from the membership fields. $this->assign('formClass', 'membershiprenew'); parent::preProcess(); // check for edit permission if (!CRM_Core_Permission::check('edit memberships')) { CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); } $this->assign('endDate', CRM_Utils_Date::customFormat(CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_id, 'end_date'))); $this->assign('membershipStatus', CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_id, 'status_id'), 'name')); if ($this->_mode) { $membershipFee = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'minimum_fee'); if (!$membershipFee) { $statusMsg = ts('Membership Renewal using a credit card requires a Membership fee. Since there is no fee associated with the selected membership type, you can use the normal renewal mode.'); CRM_Core_Session::setStatus($statusMsg, '', 'info'); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$this->_id}&context=membership")); } } // when custom data is included in this page if (!empty($_POST['hidden_custom'])) { CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_memType, 1, 'Membership', $this->_id); CRM_Custom_Form_CustomData::buildQuickForm($this); CRM_Custom_Form_CustomData::setDefaultValues($this); } CRM_Utils_System::setTitle(ts('Renew Membership')); parent::preProcess(); }
/** * Function to set variables up before form is built * * @return void * @access public */ function preProcess() { $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this); $this->_jobHoursTime = CRM_Hrjobcontract_Page_JobContractTab::getJobHoursTime(); $this->assign('jobHoursTime', $this->_jobHoursTime); $this->_aid = CRM_Utils_Request::retrieve('aid', 'Int', $this); $session = CRM_Core_Session::singleton(); $this->_loginUserID = $session->get('userID'); if (CRM_Utils_Request::retrieve('cid', 'Positive', $this)) { $this->assign('contactId', CRM_Utils_Request::retrieve('cid', 'Positive', $this)); } $activityTypes = CRM_Core_PseudoConstant::activityType(); $resultHoliday = civicrm_api3('Activity', 'get', array('activity_type_id' => array_search('Public Holiday', $activityTypes))); $publicHolidays = array(); foreach ($resultHoliday['values'] as $key => $val) { $pubDate = date("M j, Y", strtotime($val['activity_date_time'])); $publicHolidays[$pubDate] = $val['subject']; } $publicHolidays = json_encode($publicHolidays); $this->assign('publicHolidays', $publicHolidays); // Load the activity entity $main_activity = entity_load_single('civicrm_activity', $this->_aid); // Check if attachment is set if (isset($main_activity->field_attachment['und'][0]['uri'])) { $imgpath = $main_activity->field_attachment['und'][0]['uri']; $markup = '<div class="show-attached-file"><div class="show-attached-file-label"><b>' . t('Attached file: ') . '</b></div>' . l("View Attachment", file_create_url($imgpath), array('html' => TRUE, 'attributes' => array('target' => '_blank'))) . '</div>'; } else { $markup = ts('No File Attached!'); } // Assign the attached file URL $this->assign('attachedFile', $markup); if ($this->_action == CRM_Core_Action::VIEW || $this->_action == CRM_Core_Action::UPDATE) { $this->_activityId = CRM_Utils_Request::retrieve('aid', 'String', $this); $this->assign('upActivityId', $this->_activityId); $resultAct = civicrm_api3('Activity', 'get', array('sequential' => 1, 'id' => $this->_activityId, 'return.target_contact_id' => 1, 'return.assignee_contact_id' => 1, 'return.source_contact_id' => 1, 'option.limit' => 365)); $this->_activityTypeID = $resultAct['values'][0]['activity_type_id']; $this->_targetContactID = $resultAct['values'][0]['target_contact_id'][0]; $this->_actStatusId = $resultAct['values'][0]['status_id']; //condition to check if it has any manager against this absence if (array_key_exists(0, $resultAct['values'][0]['assignee_contact_id'])) { $this->_managerContactID = self::getManagerContacts($this->_targetContactID); } //Mode is edit if user has edit or admisniter permission or is manager to this absence or //(target/requested user and action is update and has manage own Absence permission) //(else mode is view if the action is view or already reviewed) and has (view permission //or (manage own absence permission and logged in user is target contact itself) $absenceStatuses = CRM_HRAbsence_BAO_HRAbsenceType::getActivityStatus(); if (CRM_Core_Permission::check('administer CiviCRM') || CRM_Core_Permission::check('edit HRAbsences') || in_array($this->_loginUserID, $this->_managerContactID) || $absenceStatuses[$this->_actStatusId] == 'Requested' && $this->_action == CRM_Core_Action::UPDATE && $this->_targetContactID == $this->_loginUserID && CRM_Core_Permission::check('manage own HRAbsences')) { $this->_mode = 'edit'; } elseif (($this->_action == CRM_Core_Action::VIEW || $absenceStatuses[$this->_actStatusId] != 'Requested') && (CRM_Core_Permission::check('view HRAbsences') || CRM_Core_Permission::check('manage own HRAbsences') && ($this->_targetContactID = $this->_loginUserID))) { $this->_mode = 'view'; } //check for ACL View/Edit permission if (empty($this->_mode)) { if (self::isContactAccessible($this->_targetContactID) == CRM_Core_Permission::EDIT) { $this->_mode = 'edit'; } elseif (self::isContactAccessible($this->_targetContactID) == CRM_Core_Permission::VIEW) { $this->_mode = 'view'; } } $displayName = CRM_Contact_BAO_Contact::displayName($this->_targetContactID); $activityTypes = CRM_HRAbsence_BAO_HRAbsenceType::getActivityTypes(); $activityType = $activityTypes[$this->_activityTypeID]; $activity = CRM_HRAbsence_BAO_HRAbsenceType::getActivityStatus(); $activityStatus = $activity[$this->_actStatusId]; CRM_Utils_System::setTitle(ts("Absence for %1 (%2, %3)", array(1 => $displayName, 2 => $activityType, 3 => $activityStatus))); if ($this->_action == CRM_Core_Action::VIEW) { $groupTree = CRM_Core_BAO_CustomGroup::getTree('Activity', $this, $this->_activityId, 0, $this->_activityTypeID); CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree); } else { $this->assign('activityType', $this->_activityTypeID); CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_activityTypeID, 1, 'Activity', $this->_activityId, TRUE); $this->assign('customValueCount', $this->_customValueCount); } } elseif ($this->_action == CRM_Core_Action::ADD) { $this->_mode = 'edit'; CRM_Utils_System::setTitle(ts('Absence Request: Add')); $this->_activityTypeID = CRM_Utils_Request::retrieve('atype', 'Positive', $this); if ($this->_activityTypeID) { //only custom data has preprocess hence directly call it $this->assign('activityType', $this->_activityTypeID); CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_activityTypeID, 1, 'Activity', NULL, TRUE); $this->assign('customValueCount', $this->_customValueCount); } $this->_targetContactID = 0; if (CRM_Utils_Request::retrieve('cid', 'Positive', $this) !== NULL) { $this->_targetContactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this); } else { //if there is no cid passed then consider target contact as logged in user //who will applying leave for himself $this->_targetContactID = $this->_loginUserID; } $this->_managerContactID = self::getManagerContacts($this->_targetContactID); } $this->assign('mode', $this->_mode); CRM_Core_Resources::singleton()->addStyleFile('org.civicrm.hrabsence', 'css/hrabsence.css'); parent::preProcess(); }
/** * build all the data structures needed to build the form * * @return void * @access public */ function preProcess() { $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'add'); $this->_dedupeButtonName = $this->getButtonName('refresh', 'dedupe'); $this->_duplicateButtonName = $this->getButtonName('upload', 'duplicate'); $session =& CRM_Core_Session::singleton(); if ($this->_action == CRM_Core_Action::ADD) { // check for add contacts permissions require_once 'CRM/Core/Permission.php'; if (!CRM_Core_Permission::check('add contacts')) { CRM_Utils_System::permissionDenied(); return; } $this->_contactType = CRM_Utils_Request::retrieve('ct', 'String', $this, true, null, 'REQUEST'); if (!in_array($this->_contactType, array('Individual', 'Household', 'Organization'))) { CRM_Core_Error::statusBounce(ts('Could not get a contact_id and/or contact_type')); } $this->_contactSubType = CRM_Utils_Request::retrieve('cst', 'String', $this); $this->_gid = CRM_Utils_Request::retrieve('gid', 'Integer', CRM_Core_DAO::$_nullObject, false, null, 'GET'); $this->_tid = CRM_Utils_Request::retrieve('tid', 'Integer', CRM_Core_DAO::$_nullObject, false, null, 'GET'); if ($this->_contactSubType) { CRM_Utils_System::setTitle(ts('New %1', array(1 => $this->_contactSubType))); } else { $title = ts('New Individual'); if ($this->_contactType == 'Household') { $title = ts('New Household'); } else { if ($this->_contactType == 'Organization') { $title = ts('New Organization'); } } CRM_Utils_System::setTitle($title); } $session->pushUserContext(CRM_Utils_System::url('civicrm/dashboard', 'reset=1')); $this->_contactId = null; } else { //update mode if (!$this->_contactId) { $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, true); } if ($this->_contactId) { require_once 'CRM/Contact/BAO/Contact.php'; $contact =& new CRM_Contact_DAO_Contact(); $contact->id = $this->_contactId; if (!$contact->find(true)) { CRM_Core_Error::statusBounce(ts('contact does not exist: %1', array(1 => $this->_contactId))); } $this->_contactType = $contact->contact_type; $this->_contactSubType = $contact->contact_sub_type; // check for permissions require_once 'CRM/Contact/BAO/Contact/Permission.php'; if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) { CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.')); } list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_contactId); CRM_Utils_System::setTitle($displayName, $contactImage . ' ' . $displayName); $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId)); $values = $this->get('values'); // get contact values. if (!empty($values)) { $this->_values = $values; } else { $params = array('id' => $this->_contactId, 'contact_id' => $this->_contactId); $contact = CRM_Contact_BAO_Contact::retrieve($params, $this->_values, true); $this->set('values', $this->_values); } } else { CRM_Core_Error::statusBounce(ts('Could not get a contact_id and/or contact_type')); } } $this->_editOptions = $this->get('contactEditOptions'); if (CRM_Utils_System::isNull($this->_editOptions)) { require_once 'CRM/Core/BAO/Preferences.php'; $this->_editOptions = CRM_Core_BAO_Preferences::valueOptions('contact_edit_options', true, null, false, 'name', true, 'AND v.filter = 0'); $this->set('contactEditOptions', $this->_editOptions); } // build demographics only for Individual contact type if ($this->_contactType != 'Individual' && array_key_exists('Demographics', $this->_editOptions)) { unset($this->_editOptions['Demographics']); } // in update mode don't show notes if ($this->_contactId && array_key_exists('Notes', $this->_editOptions)) { unset($this->_editOptions['Notes']); } $this->assign('editOptions', $this->_editOptions); $this->assign('contactType', $this->_contactType); $this->assign('contactSubType', $this->_contactSubType); // get the location blocks. $this->_blocks = $this->get('blocks'); if (CRM_Utils_System::isNull($this->_blocks)) { $this->_blocks = CRM_Core_BAO_Preferences::valueOptions('contact_edit_options', true, null, false, 'name', true, 'AND v.filter = 1'); $this->set('blocks', $this->_blocks); } $this->assign('blocks', $this->_blocks); if (array_key_exists('CustomData', $this->_editOptions)) { //only custom data has preprocess hence directly call it CRM_Custom_Form_CustomData::preProcess($this, null, $this->_contactSubType, 1, $this->_contactType, $this->_contactId); } // this is needed for custom data. $this->assign('entityID', $this->_contactId); // also keep the convention. $this->assign('contactId', $this->_contactId); // location blocks. CRM_Contact_Form_Location::preProcess($this); }
/** * build all the data structures needed to build the form * * @return void * @access public */ function preProcess() { $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add'); $this->_dedupeButtonName = $this->getButtonName('refresh', 'dedupe'); $this->_duplicateButtonName = $this->getButtonName('upload', 'duplicate'); $session = CRM_Core_Session::singleton(); if ($this->_action == CRM_Core_Action::ADD) { // check for add contacts permissions if (!CRM_Core_Permission::check('add contacts')) { CRM_Utils_System::permissionDenied(); CRM_Utils_System::civiExit(); } $this->_contactType = CRM_Utils_Request::retrieve('ct', 'String', $this, TRUE, NULL, 'REQUEST'); if (!in_array($this->_contactType, array('Individual', 'Household', 'Organization'))) { CRM_Core_Error::statusBounce(ts('Could not get a contact id and/or contact type')); } $this->_isContactSubType = FALSE; if ($this->_contactSubType = CRM_Utils_Request::retrieve('cst', 'String', $this)) { $this->_isContactSubType = TRUE; } if ($this->_contactSubType && !CRM_Contact_BAO_ContactType::isExtendsContactType($this->_contactSubType, $this->_contactType, TRUE)) { CRM_Core_Error::statusBounce(ts("Could not get a valid contact subtype for contact type '%1'", array(1 => $this->_contactType))); } $this->_gid = CRM_Utils_Request::retrieve('gid', 'Integer', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET'); $this->_tid = CRM_Utils_Request::retrieve('tid', 'Integer', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET'); $typeLabel = CRM_Contact_BAO_ContactType::contactTypePairs(TRUE, $this->_contactSubType ? $this->_contactSubType : $this->_contactType); $typeLabel = implode(' / ', $typeLabel); CRM_Utils_System::setTitle(ts('New %1', array(1 => $typeLabel))); $session->pushUserContext(CRM_Utils_System::url('civicrm/dashboard', 'reset=1')); $this->_contactId = NULL; } else { //update mode if (!$this->_contactId) { $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE); } if ($this->_contactId) { $defaults = array(); $params = array('id' => $this->_contactId); $returnProperities = array('id', 'contact_type', 'contact_sub_type'); CRM_Core_DAO::commonRetrieve('CRM_Contact_DAO_Contact', $params, $defaults, $returnProperities); if (!CRM_Utils_Array::value('id', $defaults)) { CRM_Core_Error::statusBounce(ts('A Contact with that ID does not exist: %1', array(1 => $this->_contactId))); } $this->_contactType = CRM_Utils_Array::value('contact_type', $defaults); $this->_contactSubType = CRM_Utils_Array::value('contact_sub_type', $defaults); // check for permissions $session = CRM_Core_Session::singleton(); if ($session->get('userID') != $this->_contactId && !CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) { CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.')); } list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_contactId); CRM_Utils_System::setTitle($displayName, $contactImage . ' ' . $displayName); $context = CRM_Utils_Request::retrieve('context', 'String', $this); $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this); $urlParams = 'reset=1&cid=' . $this->_contactId; if ($context) { $urlParams .= "&context={$context}"; } if (CRM_Utils_Rule::qfKey($qfKey)) { $urlParams .= "&key={$qfKey}"; } $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/view', $urlParams)); $values = $this->get('values'); // get contact values. if (!empty($values)) { $this->_values = $values; } else { $params = array('id' => $this->_contactId, 'contact_id' => $this->_contactId, 'noRelationships' => TRUE, 'noNotes' => TRUE, 'noGroups' => TRUE); $contact = CRM_Contact_BAO_Contact::retrieve($params, $this->_values, TRUE); $this->set('values', $this->_values); } } else { CRM_Core_Error::statusBounce(ts('Could not get a contact_id and/or contact_type')); } } // parse street address, CRM-5450 $this->_parseStreetAddress = $this->get('parseStreetAddress'); if (!isset($this->_parseStreetAddress)) { $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options'); $this->_parseStreetAddress = FALSE; if (CRM_Utils_Array::value('street_address', $addressOptions) && CRM_Utils_Array::value('street_address_parsing', $addressOptions)) { $this->_parseStreetAddress = TRUE; } $this->set('parseStreetAddress', $this->_parseStreetAddress); } $this->assign('parseStreetAddress', $this->_parseStreetAddress); $this->_editOptions = $this->get('contactEditOptions'); if (CRM_Utils_System::isNull($this->_editOptions)) { $this->_editOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 0'); $this->set('contactEditOptions', $this->_editOptions); } // build demographics only for Individual contact type if ($this->_contactType != 'Individual' && array_key_exists('Demographics', $this->_editOptions)) { unset($this->_editOptions['Demographics']); } // in update mode don't show notes if ($this->_contactId && array_key_exists('Notes', $this->_editOptions)) { unset($this->_editOptions['Notes']); } $this->assign('editOptions', $this->_editOptions); $this->assign('contactType', $this->_contactType); $this->assign('contactSubType', $this->_contactSubType); //build contact subtype form element, CRM-6864 $buildContactSubType = TRUE; if ($this->_contactSubType && $this->_action & CRM_Core_Action::ADD) { $buildContactSubType = FALSE; } $this->assign('buildContactSubType', $buildContactSubType); // get the location blocks. $this->_blocks = $this->get('blocks'); if (CRM_Utils_System::isNull($this->_blocks)) { $this->_blocks = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 1'); $this->set('blocks', $this->_blocks); } $this->assign('blocks', $this->_blocks); // this is needed for custom data. $this->assign('entityID', $this->_contactId); // also keep the convention. $this->assign('contactId', $this->_contactId); // location blocks. CRM_Contact_Form_Location::preProcess($this); // execute preProcess dynamically by js else execute normal preProcess if (array_key_exists('CustomData', $this->_editOptions)) { if (CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject)) { CRM_Contact_Form_Edit_CustomData::preProcess($this); } else { $contactSubType = $this->_contactSubType; // need contact sub type to build related grouptree array during post process if (CRM_Utils_Array::value('contact_sub_type', $_POST)) { $contactSubType = $_POST['contact_sub_type']; } //only custom data has preprocess hence directly call it CRM_Custom_Form_CustomData::preProcess($this, NULL, $contactSubType, 1, $this->_contactType, $this->_contactId); } } }
/** * Function to set variables up before form is built * * @return void * @access public */ 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); // omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container CRM_Utils_System::setTitle(ts('Event Registration for') . ' ' . $displayName); } // 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->_paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'id', 'participant_id'); // 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->_paymentProcessor = array('billing_mode' => 1); $validProcessors = array(); $processors = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, "billing_mode IN ( 1, 3 )"); foreach ($processors as $ppID => $label) { $paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($ppID, $this->_mode); if ($paymentProcessor['payment_processor_type'] == 'PayPal' && !$paymentProcessor['user_name']) { continue; } elseif ($paymentProcessor['payment_processor_type'] == 'Dummy' && $this->_mode == 'live') { continue; } else { $paymentObject = CRM_Core_Payment::singleton($this->_mode, $paymentProcessor, $this); $error = $paymentObject->checkConfig(); if (empty($error)) { $validProcessors[$ppID] = $label; } $paymentObject = NULL; } } if (empty($validProcessors)) { CRM_Core_Error::fatal(ts('Could not find valid payment processor for this page')); } else { $this->_processors = $validProcessors; } // also check for billing information // get the billing location type $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate'); // CRM-8108 remove ts around Billing location type //$this->_bltID = array_search( ts('Billing'), $locationTypes ); $this->_bltID = array_search('Billing', $locationTypes); if (!$this->_bltID) { CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing'))); } $this->set('bltID', $this->_bltID); $this->assign('bltID', $this->_bltID); $this->_fields = array(); CRM_Core_Payment_Form::setCreditCardFields($this); // this required to show billing block $this->assign_by_ref('paymentProcessor', $paymentProcessor); $this->assign('hidePayPalExpress', TRUE); } 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 (CRM_Utils_Array::value('hidden_feeblock', $_POST) || CRM_Utils_Array::value('send_receipt', $_POST)) { 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 (CRM_Utils_Array::value('hidden_custom', $_POST)) { //custom data of type participant role if (CRM_Utils_Array::value('role_id', $_POST)) { foreach ($_POST['role_id'] as $k => $val) { $roleID = $val; CRM_Custom_Form_CustomData::preProcess($this, $this->_roleCustomDataTypeID, $k, 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); $roleIds = CRM_Event_PseudoConstant::participantRole(); if (!empty($roleIds)) { $query = "\nSELECT civicrm_custom_group.name as name,\n civicrm_custom_group.id as id,\n extends_entity_column_value as value\n FROM civicrm_custom_group\n WHERE ( extends_entity_column_value REGEXP '[[:<:]]" . implode('[[:>:]]|[[:<:]]', array_keys($roleIds)) . "[[:>:]]'\n OR extends_entity_column_value IS NULL )\n AND extends_entity_column_id = '{$this->_roleCustomDataTypeID}'\n AND extends = 'Participant'\n AND is_active = 1"; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { if ($dao->value) { $getRole = explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->value); foreach ($getRole as $r) { if (!$r) { continue; } if (isset($this->_participantRoleIds[$r])) { $this->_participantRoleIds[$r] .= ',' . $dao->name; } else { $this->_participantRoleIds[$r] = $dao->name; } } } else { if (isset($this->_participantRoleIds[0])) { $this->_participantRoleIds[0] .= ',' . $dao->name; } else { $this->_participantRoleIds[0] = $dao->name; } } } $dao->free(); } foreach ($roleIds as $k => $v) { if (!isset($this->_participantRoleIds[$k])) { $this->_participantRoleIds[$k] = ''; } } $this->assign('participantRoleIds', $this->_participantRoleIds); }
/** * Pre processing work done here. * * Gets session variables for table name, id of entity in table, type of entity and stores them. */ public function preProcess() { $this->_cdType = CRM_Utils_Array::value('type', $_GET); $this->assign('cdType', FALSE); $this->_multiRecordDisplay = CRM_Utils_Request::retrieve('multiRecordDisplay', 'String', $this); if ($this->_cdType || $this->_multiRecordDisplay == 'single') { if ($this->_cdType) { $this->assign('cdType', TRUE); } // NOTE : group id is not stored in session from within CRM_Custom_Form_CustomData::preProcess func // this is due to some condition inside it which restricts it from saving in session // so doing this for multi record edit action $entityId = CRM_Utils_Request::retrieve('entityID', 'Positive', $this); if (!empty($entityId)) { $subType = CRM_Contact_BAO_Contact::getContactSubType($entityId, ','); } CRM_Custom_Form_CustomData::preProcess($this, NULL, $subType, NULL, NULL, $entityId); if ($this->_multiRecordDisplay) { $this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this); $this->_tableID = $this->_entityId; $this->_contactType = CRM_Contact_BAO_Contact::getContactType($this->_tableID); $mode = CRM_Utils_Request::retrieve('mode', 'String', $this); $hasReachedMax = CRM_Core_BAO_CustomGroup::hasReachedMaxLimit($this->_groupID, $this->_tableID); if ($hasReachedMax && $mode == 'add') { CRM_Core_Error::statusBounce(ts('The maximum record limit is reached')); } $this->_copyValueId = CRM_Utils_Request::retrieve('copyValueId', 'Positive', $this); $groupTitle = CRM_Core_BAO_CustomGroup::getTitle($this->_groupID); $mode = CRM_Utils_Request::retrieve('mode', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET'); $mode = ucfirst($mode); CRM_Utils_System::setTitle(ts('%1 %2 Record', array(1 => $mode, 2 => $groupTitle))); if (!empty($_POST['hidden_custom'])) { $this->assign('postedInfo', TRUE); } } return; } $this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this, TRUE); $this->_tableID = CRM_Utils_Request::retrieve('tableId', 'Positive', $this, TRUE); $this->_contactType = CRM_Contact_BAO_Contact::getContactType($this->_tableID); $this->_contactSubType = CRM_Contact_BAO_Contact::getContactSubType($this->_tableID, ','); $this->assign('contact_type', $this->_contactType); $this->assign('contact_subtype', $this->_contactSubType); list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_tableID); CRM_Utils_System::setTitle($displayName, $contactImage . ' ' . $displayName); // when custom data is included in this page if (!empty($_POST['hidden_custom'])) { for ($i = 1; $i <= $_POST['hidden_custom_group_count'][$this->_groupID]; $i++) { CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_contactSubType, $i, $this->_contactType, $this->_tableID); CRM_Custom_Form_CustomData::buildQuickForm($this); CRM_Custom_Form_CustomData::setDefaultValues($this); } } }
/** * Build the form object. */ public function preProcess() { CRM_Core_Form_RecurringEntity::preProcess('civicrm_activity'); $this->_atypefile = CRM_Utils_Array::value('atypefile', $_GET); $this->assign('atypefile', FALSE); if ($this->_atypefile) { $this->assign('atypefile', TRUE); } $session = CRM_Core_Session::singleton(); $this->_currentUserId = $session->get('userID'); $this->_currentlyViewedContactId = $this->get('contactId'); if (!$this->_currentlyViewedContactId) { $this->_currentlyViewedContactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this); } $this->assign('contactId', $this->_currentlyViewedContactId); // Give the context. if (!isset($this->_context)) { $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); if (CRM_Contact_Form_Search::isSearchContext($this->_context)) { $this->_context = 'search'; } elseif (!in_array($this->_context, array('dashlet', 'dashletFullscreen')) && $this->_currentlyViewedContactId) { $this->_context = 'activity'; } $this->_compContext = CRM_Utils_Request::retrieve('compContext', 'String', $this); } $this->assign('context', $this->_context); $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this); if ($this->_action & CRM_Core_Action::DELETE) { if (!CRM_Core_Permission::check('delete activities')) { CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); } } // CRM-6957 // When we come from contact search, activity id never comes. // So don't try to get from object, it might gives you wrong one. // if we're not adding new one, there must be an id to // an activity we're trying to work on. if ($this->_action != CRM_Core_Action::ADD && get_class($this->controller) != 'CRM_Contact_Controller_Search') { $this->_activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this); } $this->_activityTypeId = CRM_Utils_Request::retrieve('atype', 'Positive', $this); $this->assign('atype', $this->_activityTypeId); $this->assign('activityId', $this->_activityId); // Check for required permissions, CRM-6264. if ($this->_activityId && in_array($this->_action, array(CRM_Core_Action::UPDATE, CRM_Core_Action::VIEW)) && !CRM_Activity_BAO_Activity::checkPermission($this->_activityId, $this->_action)) { CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); } if ($this->_action & CRM_Core_Action::VIEW && CRM_Activity_BAO_Activity::checkPermission($this->_activityId, CRM_Core_Action::UPDATE)) { $this->assign('permission', 'edit'); } if (!$this->_activityTypeId && $this->_activityId) { $this->_activityTypeId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'activity_type_id'); } // Assigning Activity type name. if ($this->_activityTypeId) { $activityTName = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, 'AND v.value = ' . $this->_activityTypeId, 'label'); if ($activityTName[$this->_activityTypeId]) { $this->_activityTypeName = $activityTName[$this->_activityTypeId]; $this->assign('activityTName', $activityTName[$this->_activityTypeId]); } } // Set title. if (isset($activityTName)) { $activityName = CRM_Utils_Array::value($this->_activityTypeId, $activityTName); $this->assign('pageTitle', ts('%1 Activity', array(1 => $activityName))); if ($this->_currentlyViewedContactId) { $displayName = CRM_Contact_BAO_Contact::displayName($this->_currentlyViewedContactId); // Check if this is default domain contact CRM-10482. if (CRM_Contact_BAO_Contact::checkDomainContact($this->_currentlyViewedContactId)) { $displayName .= ' (' . ts('default organization') . ')'; } CRM_Utils_System::setTitle($displayName . ' - ' . $activityName); } else { CRM_Utils_System::setTitle(ts('%1 Activity', array(1 => $activityName))); } } // Check the mode when this form is called either single or as // search task action. if ($this->_activityTypeId || $this->_context == 'standalone' || $this->_currentlyViewedContactId) { $this->_single = TRUE; $this->assign('urlPath', 'civicrm/activity'); } else { // Set the appropriate action. $url = CRM_Utils_System::currentPath(); $urlArray = explode('/', $url); $searchPath = array_pop($urlArray); $searchType = 'basic'; $this->_action = CRM_Core_Action::BASIC; switch ($searchPath) { case 'basic': $searchType = $searchPath; $this->_action = CRM_Core_Action::BASIC; break; case 'advanced': $searchType = $searchPath; $this->_action = CRM_Core_Action::ADVANCED; break; case 'builder': $searchType = $searchPath; $this->_action = CRM_Core_Action::PROFILE; break; case 'custom': $this->_action = CRM_Core_Action::COPY; $searchType = $searchPath; break; } parent::preProcess(); $this->_single = FALSE; $this->assign('urlPath', "civicrm/contact/search/{$searchType}"); $this->assign('urlPathVar', "_qf_Activity_display=true&qfKey={$this->controller->_key}"); } $this->assign('single', $this->_single); $this->assign('action', $this->_action); if ($this->_action & CRM_Core_Action::VIEW) { // Get the tree of custom fields. $this->_groupTree =& CRM_Core_BAO_CustomGroup::getTree('Activity', $this, $this->_activityId, 0, $this->_activityTypeId); } if ($this->_activityTypeId) { // Set activity type name and description to template. list($this->_activityTypeName, $activityTypeDescription) = CRM_Core_BAO_OptionValue::getActivityTypeDetails($this->_activityTypeId); $this->assign('activityTypeName', $this->_activityTypeName); $this->assign('activityTypeDescription', $activityTypeDescription); } // set user context $urlParams = $urlString = NULL; $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this); if (!$qfKey) { $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this); } // Validate the qfKey. if (!CRM_Utils_Rule::qfKey($qfKey)) { $qfKey = NULL; } if ($this->_context == 'fulltext') { $keyName = '&qfKey'; $urlParams = 'force=1'; $urlString = 'civicrm/contact/search/custom'; if ($this->_action == CRM_Core_Action::UPDATE) { $keyName = '&key'; $urlParams .= '&context=fulltext&action=view'; $urlString = 'civicrm/contact/view/activity'; } if ($qfKey) { $urlParams .= "{$keyName}={$qfKey}"; } $this->assign('searchKey', $qfKey); } elseif (in_array($this->_context, array('standalone', 'home', 'dashlet', 'dashletFullscreen'))) { $urlParams = 'reset=1'; $urlString = 'civicrm/dashboard'; } elseif ($this->_context == 'search') { $urlParams = 'force=1'; if ($qfKey) { $urlParams .= "&qfKey={$qfKey}"; } $path = CRM_Utils_System::currentPath(); if ($this->_compContext == 'advanced') { $urlString = 'civicrm/contact/search/advanced'; } elseif ($path == 'civicrm/group/search' || $path == 'civicrm/contact/search' || $path == 'civicrm/contact/search/advanced' || $path == 'civicrm/contact/search/custom' || $path == 'civicrm/group/search') { $urlString = $path; } else { $urlString = 'civicrm/activity/search'; } $this->assign('searchKey', $qfKey); } elseif ($this->_context != 'caseActivity') { $urlParams = "action=browse&reset=1&cid={$this->_currentlyViewedContactId}&selectedChild=activity"; $urlString = 'civicrm/contact/view'; } if ($urlString) { $session->pushUserContext(CRM_Utils_System::url($urlString, $urlParams)); } // hack to retrieve activity type id from post variables if (!$this->_activityTypeId) { $this->_activityTypeId = CRM_Utils_Array::value('activity_type_id', $_POST); } // when custom data is included in this page if (!empty($_POST['hidden_custom'])) { // We need to set it in the session for the code below to work. // CRM-3014 // Need to assign custom data subtype to the template. $this->set('type', 'Activity'); $this->set('subType', $this->_activityTypeId); $this->set('entityId', $this->_activityId); CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_activityTypeId, 1, 'Activity', $this->_activityId); CRM_Custom_Form_CustomData::buildQuickForm($this); CRM_Custom_Form_CustomData::setDefaultValues($this); } // add attachments part CRM_Core_BAO_File::buildAttachment($this, 'civicrm_activity', $this->_activityId, NULL, TRUE); // figure out the file name for activity type, if any if ($this->_activityTypeId && ($this->_activityTypeFile = CRM_Activity_BAO_Activity::getFileForActivityTypeId($this->_activityTypeId, $this->_crmDir))) { $this->assign('activityTypeFile', $this->_activityTypeFile); $this->assign('crmDir', $this->_crmDir); } $this->setFields(); if ($this->_activityTypeFile) { $className = "CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}"; $className::preProcess($this); } $this->_values = $this->get('values'); if (!is_array($this->_values)) { $this->_values = array(); if (isset($this->_activityId) && $this->_activityId) { $params = array('id' => $this->_activityId); CRM_Activity_BAO_Activity::retrieve($params, $this->_values); } $this->set('values', $this->_values); } if ($this->_action & CRM_Core_Action::UPDATE) { CRM_Core_Form_RecurringEntity::preProcess('civicrm_activity'); } }
/** * 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.')); } // @todo - if anyone ever figures out what this _cdType subroutine is about // (or even if it still applies) please add comments!!!!!!!!!! $this->_cdType = CRM_Utils_Array::value('type', $_GET); $this->assign('cdType', FALSE); if ($this->_cdType) { $this->assign('cdType', TRUE); CRM_Custom_Form_CustomData::preProcess($this); return; } $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); // Get the contact id $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this); // Get the action. $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add'); $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); } //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; } CRM_Contact_Form_Task::preProcessCommon($this); $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); }
/** * Function to set variables up before form is built * * @return void * @access public */ public function preProcess() { $this->_showFeeBlock = CRM_Utils_Array::value('eventId', $_GET); $this->assign('showFeeBlock', false); $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this); $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this); $this->_participantId = CRM_Utils_Request::retrieve('id', 'Positive', $this); $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); $this->assign('context', $this->_context); // 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->assign('roleCustomDataTypeID', $this->_roleCustomDataTypeID); $this->assign('eventNameCustomDataTypeID', $this->_eventNameCustomDataTypeID); if ($this->_mode) { $this->assign('participantMode', $this->_mode); $this->_paymentProcessor = array('billing_mode' => 1); $validProcessors = array(); $processors = CRM_Core_PseudoConstant::paymentProcessor(false, false, "billing_mode IN ( 1, 3 )"); foreach ($processors as $ppID => $label) { require_once 'CRM/Core/BAO/PaymentProcessor.php'; require_once 'CRM/Core/Payment.php'; $paymentProcessor =& CRM_Core_BAO_PaymentProcessor::getPayment($ppID, $this->_mode); if ($paymentProcessor['payment_processor_type'] == 'PayPal' && !$paymentProcessor['user_name']) { continue; } else { if ($paymentProcessor['payment_processor_type'] == 'Dummy' && $this->_mode == 'live') { continue; } else { $paymentObject =& CRM_Core_Payment::singleton($this->_mode, 'Contribute', $paymentProcessor, $this); $error = $paymentObject->checkConfig(); if (empty($error)) { $validProcessors[$ppID] = $label; } $paymentObject = null; } } } if (empty($validProcessors)) { CRM_Core_Error::fatal(ts('Could not find valid payment processor for this page')); } else { $this->_processors = $validProcessors; } // also check for billing information // get the billing location type $locationTypes =& CRM_Core_PseudoConstant::locationType(); $this->_bltID = array_search('Billing', $locationTypes); if (!$this->_bltID) { CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing'))); } $this->set('bltID', $this->_bltID); $this->assign('bltID', $this->_bltID); $this->_fields = array(); require_once 'CRM/Core/Payment/Form.php'; CRM_Core_Payment_Form::setCreditCardFields($this); // this required to show billing block $this->assign_by_ref('paymentProcessor', $paymentProcessor); $this->assign('hidePayPalExpress', true); } if ($this->_showFeeBlock) { $this->assign('showFeeBlock', true); $this->assign('paid', 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); } //check the mode when this form is called either single or as //search task action if ($this->_participantId || $this->_contactID || $this->_context == 'standalone') { $this->_single = true; $this->assign('urlPath', 'civicrm/contact/view/participant'); if (!$this->_participantId && !$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 $advanced = null; $builder = null; $session =& CRM_Core_Session::singleton(); $advanced = $session->get('isAdvanced'); $builder = $session->get('isSearchBuilder'); $searchType = "basic"; if ($advanced == 1) { $this->_action = CRM_Core_Action::ADVANCED; $searchType = "advanced"; } else { if ($advanced == 2 && ($builder = 1)) { $this->_action = CRM_Core_Action::PROFILE; $searchType = "builder"; } else { if ($advanced == 3) { $searchType = "custom"; } } } parent::preProcess(); $this->_single = false; $this->_contactID = null; //set ajax path, this used for custom data building $this->assign('urlPath', "civicrm/contact/search/{$searchType}"); $this->assign('urlPathVar', "_qf_Participant_display=true&qfKey={$this->controller->_key}"); } $this->assign('single', $this->_single); $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) { return; } if ($this->_participantId) { // assign participant id to the template $this->assign('participantId', $this->_participantId); $this->_roleId = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $this->_participantId, 'role_id'); } // when fee amount is included in form if (CRM_Utils_Array::value('hidden_feeblock', $_POST) || CRM_Utils_Array::value('send_receipt', $_POST)) { 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 (CRM_Utils_Array::value("hidden_custom", $_POST)) { //custom data of type participant role CRM_Custom_Form_Customdata::preProcess($this, $this->_roleCustomDataTypeID, $_POST['role_id'], 1, 'Participant', $this->_participantId); 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->_participantId); 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->_participantId); 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->_participantId && $this->_action & CRM_Core_Action::UPDATE) { require_once 'CRM/Contribute/BAO/Contribution.php'; $this->_onlinePendingContributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($this->_participantId, 'Event'); } $this->set('onlinePendingContributionId', $this->_onlinePendingContributionId); }
public function preProcess() { //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); } parent::preProcess(); // get price set id. $this->_priceSetId = CRM_Utils_Array::value('priceSetId', $_GET); $this->set('priceSetId', $this->_priceSetId); $this->assign('priceSetId', $this->_priceSetId); // 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.')); } if ($this->_action & CRM_Core_Action::DELETE) { $contributionID = CRM_Member_BAO_Membership::getMembershipContributionId($this->_id); // check delete permission for contribution if ($this->_id && $contributionID && !CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) { CRM_Core_Error::fatal(ts("This Membership is linked to a contribution. You must have 'delete in CiviContribute' permission in order to delete this record.")); } } if ($this->_action & CRM_Core_Action::ADD) { if (!CRM_Member_BAO_Membership::statusAvailabilty($this->_contactID)) { // all possible statuses are disabled - redirect back to contact form CRM_Core_Error::statusBounce(ts('There are no configured membership statuses. You cannot add this membership until your membership statuses are correctly configured')); } if ($this->_contactID) { //check whether contact has a current membership so we can alert user that they may want to do a renewal instead $contactMemberships = array(); $memParams = array('contact_id' => $this->_contactID); CRM_Member_BAO_Membership::getValues($memParams, $contactMemberships, TRUE); $cMemTypes = array(); foreach ($contactMemberships as $mem) { $cMemTypes[] = $mem['membership_type_id']; } if (count($cMemTypes) > 0) { $memberorgs = CRM_Member_BAO_MembershipType::getMemberOfContactByMemTypes($cMemTypes); $mems_by_org = array(); foreach ($contactMemberships as $memid => $mem) { $mem['member_of_contact_id'] = CRM_Utils_Array::value($mem['membership_type_id'], $memberorgs); if (!empty($mem['membership_end_date'])) { $mem['membership_end_date'] = CRM_Utils_Date::customformat($mem['membership_end_date']); } $mem['membership_type'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $mem['membership_type_id'], 'name', 'id'); $mem['membership_status'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $mem['status_id'], 'label', 'id'); $mem['renewUrl'] = CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$mem['id']}&context=membership&selectedChild=member" . ($this->_mode ? '&mode=live' : '')); $mem['membershipTab'] = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$this->_contactID}&selectedChild=member"); $mems_by_org[$mem['member_of_contact_id']] = $mem; } $this->assign('existingContactMemberships', $mems_by_org); } } else { // In standalone mode we don't have a contact id yet so lookup will be done client-side with this script: $resources = CRM_Core_Resources::singleton(); $resources->addScriptFile('civicrm', 'templates/CRM/Member/Form/MembershipStandalone.js'); $passthru = array('typeorgs' => CRM_Member_BAO_MembershipType::getMembershipTypeOrganization(), 'memtypes' => CRM_Core_PseudoConstant::get('CRM_Member_BAO_Membership', 'membership_type_id'), 'statuses' => CRM_Core_PseudoConstant::get('CRM_Member_BAO_Membership', 'status_id')); $resources->addSetting(array('existingMems' => $passthru)); } } // when custom data is included in this page if (!empty($_POST['hidden_custom'])) { CRM_Custom_Form_CustomData::preProcess($this); 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, 'Membership'); } $this->assign('onlinePendingContributionId', $this->_onlinePendingContributionId); $this->setPageTitle(ts('Membership')); }
public function preProcess() { //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); } // get price set id. $this->_priceSetId = CRM_Utils_Array::value('priceSetId', $_GET); $this->set('priceSetId', $this->_priceSetId); $this->assign('priceSetId', $this->_priceSetId); // action $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add'); $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this); $this->_processors = array(); // 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')); } $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); $this->assign('context', $this->_context); if ($this->_id) { $this->_memType = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $this->_id, "membership_type_id"); $this->_membershipIDs[] = $this->_id; } $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this); $this->assign('membershipMode', $this->_mode); if ($this->_mode) { $this->_paymentProcessor = array('billing_mode' => 1); $validProcessors = array(); $processors = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, "billing_mode IN ( 1, 3 )"); foreach ($processors as $ppID => $label) { $paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment($ppID, $this->_mode); if ($paymentProcessor['payment_processor_type'] == 'PayPal' && !$paymentProcessor['user_name']) { continue; } elseif ($paymentProcessor['payment_processor_type'] == 'Dummy' && $this->_mode == 'live') { continue; } else { $paymentObject = CRM_Core_Payment::singleton($this->_mode, $paymentProcessor, $this); $error = $paymentObject->checkConfig(); if (empty($error)) { $validProcessors[$ppID] = $label; } $paymentObject = NULL; } } if (empty($validProcessors)) { CRM_Core_Error::fatal(ts('Could not find valid payment processor for this page')); } else { $this->_processors = $validProcessors; } // also check for billing information // get the billing location type $locationTypes = CRM_Core_PseudoConstant::locationType(); // CRM-8108 remove ts around Billing location type //$this->_bltID = array_search( ts('Billing'), $locationTypes ); $this->_bltID = array_search('Billing', $locationTypes); if (!$this->_bltID) { CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing'))); } $this->set('bltID', $this->_bltID); $this->assign('bltID', $this->_bltID); $this->_fields = array(); CRM_Core_Payment_Form::setCreditCardFields($this); // this required to show billing block $this->assign_by_ref('paymentProcessor', $paymentProcessor); $this->assign('hidePayPalExpress', TRUE); } if ($this->_action & CRM_Core_Action::ADD) { //check whether any active membership statuses are available - redirects back to contact summary if not CRM_Member_BAO_Membership::statusAvilability($this->_contactID); if ($this->_contactID) { //check whether contact has a current membership so we can alert user that they may want to do a renewal instead $hasMembership = CRM_Member_BAO_Membership::getContactMembership($this->_contactID, NULL, 0); if (!empty($hasMembership)) { $hasMembership['membership_type'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $hasMembership['membership_type_id'], 'name', 'id'); $hasMembership['membership_status'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $hasMembership['status_id'], 'label', 'id'); $membershipTab = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$this->_contactID}&selectedChild=member"); if ($this->_mode) { $renewUrl = CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$hasMembership['id']}&context=membership&selectedChild=member&mode=live"); } else { $renewUrl = CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$hasMembership['id']}&context=membership&selectedChild=member"); } if (CRM_Utils_Array::value('membership_end_date', $hasMembership)) { CRM_Core_Session::setStatus(ts('This contact has an existing %1 membership record with %2 status and end date of %3. <a href="%4">Click here if you want to renew this membership</a> (rather than creating a new membership record). <a href="%5">Click here to view all existing and / or expired memberships for this contact.</a>', array(1 => $hasMembership['membership_type'], 2 => $hasMembership['membership_status'], 3 => CRM_Utils_Date::customformat($hasMembership['membership_end_date']), 4 => $renewUrl, 5 => $membershipTab))); } else { CRM_Core_Session::setStatus(ts('This contact has an existing %1 membership record with %2 status. <a href="%3">Click here if you want to renew this membership</a> (rather than creating a new membership record). <a href="%4">Click here to view all existing and / or expired memberships for this contact.</a>', array(1 => $hasMembership['membership_type'], 2 => $hasMembership['membership_status'], 3 => $renewUrl, 4 => $membershipTab))); } } } } // when custom data is included in this page if (CRM_Utils_Array::value("hidden_custom", $_POST)) { CRM_Custom_Form_CustomData::preProcess($this); 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, 'Membership'); } $this->assign('onlinePendingContributionId', $this->_onlinePendingContributionId); $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail(); parent::preProcess(); }
/** * Build all the data structures needed to build the form. */ public function preProcess() { $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add'); $this->_dedupeButtonName = $this->getButtonName('refresh', 'dedupe'); $this->_duplicateButtonName = $this->getButtonName('upload', 'duplicate'); CRM_Core_Resources::singleton()->addStyleFile('civicrm', 'css/contactSummary.css', 2, 'html-header'); $session = CRM_Core_Session::singleton(); if ($this->_action == CRM_Core_Action::ADD) { // check for add contacts permissions if (!CRM_Core_Permission::check('add contacts')) { CRM_Utils_System::permissionDenied(); CRM_Utils_System::civiExit(); } $this->_contactType = CRM_Utils_Request::retrieve('ct', 'String', $this, TRUE, NULL, 'REQUEST'); if (!in_array($this->_contactType, array('Individual', 'Household', 'Organization'))) { CRM_Core_Error::statusBounce(ts('Could not get a contact id and/or contact type')); } $this->_isContactSubType = FALSE; if ($this->_contactSubType = CRM_Utils_Request::retrieve('cst', 'String', $this)) { $this->_isContactSubType = TRUE; } if ($this->_contactSubType && !CRM_Contact_BAO_ContactType::isExtendsContactType($this->_contactSubType, $this->_contactType, TRUE)) { CRM_Core_Error::statusBounce(ts("Could not get a valid contact subtype for contact type '%1'", array(1 => $this->_contactType))); } $this->_gid = CRM_Utils_Request::retrieve('gid', 'Integer', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET'); $this->_tid = CRM_Utils_Request::retrieve('tid', 'Integer', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET'); $typeLabel = CRM_Contact_BAO_ContactType::contactTypePairs(TRUE, $this->_contactSubType ? $this->_contactSubType : $this->_contactType); $typeLabel = implode(' / ', $typeLabel); CRM_Utils_System::setTitle(ts('New %1', array(1 => $typeLabel))); $session->pushUserContext(CRM_Utils_System::url('civicrm/dashboard', 'reset=1')); $this->_contactId = NULL; } else { //update mode if (!$this->_contactId) { $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE); } if ($this->_contactId) { $defaults = array(); $params = array('id' => $this->_contactId); $returnProperities = array('id', 'contact_type', 'contact_sub_type', 'modified_date', 'is_deceased'); CRM_Core_DAO::commonRetrieve('CRM_Contact_DAO_Contact', $params, $defaults, $returnProperities); if (empty($defaults['id'])) { CRM_Core_Error::statusBounce(ts('A Contact with that ID does not exist: %1', array(1 => $this->_contactId))); } $this->_contactType = CRM_Utils_Array::value('contact_type', $defaults); $this->_contactSubType = CRM_Utils_Array::value('contact_sub_type', $defaults); // check for permissions $session = CRM_Core_Session::singleton(); if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) { CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.')); } $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); if ($defaults['is_deceased']) { $displayName .= ' <span class="crm-contact-deceased">(deceased)</span>'; } $displayName = ts('Edit %1', array(1 => $displayName)); // Check if this is default domain contact CRM-10482 if (CRM_Contact_BAO_Contact::checkDomainContact($this->_contactId)) { $displayName .= ' (' . ts('default organization') . ')'; } // omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container CRM_Utils_System::setTitle($displayName); $context = CRM_Utils_Request::retrieve('context', 'String', $this); $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this); $urlParams = 'reset=1&cid=' . $this->_contactId; if ($context) { $urlParams .= "&context={$context}"; } if (CRM_Utils_Rule::qfKey($qfKey)) { $urlParams .= "&key={$qfKey}"; } $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/view', $urlParams)); $values = $this->get('values'); // get contact values. if (!empty($values)) { $this->_values = $values; } else { $params = array('id' => $this->_contactId, 'contact_id' => $this->_contactId, 'noRelationships' => TRUE, 'noNotes' => TRUE, 'noGroups' => TRUE); $contact = CRM_Contact_BAO_Contact::retrieve($params, $this->_values, TRUE); $this->set('values', $this->_values); } } else { CRM_Core_Error::statusBounce(ts('Could not get a contact_id and/or contact_type')); } } // parse street address, CRM-5450 $this->_parseStreetAddress = $this->get('parseStreetAddress'); if (!isset($this->_parseStreetAddress)) { $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options'); $this->_parseStreetAddress = FALSE; if (!empty($addressOptions['street_address']) && !empty($addressOptions['street_address_parsing'])) { $this->_parseStreetAddress = TRUE; } $this->set('parseStreetAddress', $this->_parseStreetAddress); } $this->assign('parseStreetAddress', $this->_parseStreetAddress); $this->_editOptions = $this->get('contactEditOptions'); if (CRM_Utils_System::isNull($this->_editOptions)) { $this->_editOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 0'); $this->set('contactEditOptions', $this->_editOptions); } // build demographics only for Individual contact type if ($this->_contactType != 'Individual' && array_key_exists('Demographics', $this->_editOptions)) { unset($this->_editOptions['Demographics']); } // in update mode don't show notes if ($this->_contactId && array_key_exists('Notes', $this->_editOptions)) { unset($this->_editOptions['Notes']); } $this->assign('editOptions', $this->_editOptions); $this->assign('contactType', $this->_contactType); $this->assign('contactSubType', $this->_contactSubType); //build contact subtype form element, CRM-6864 $buildContactSubType = TRUE; if ($this->_contactSubType && $this->_action & CRM_Core_Action::ADD) { $buildContactSubType = FALSE; } $this->assign('buildContactSubType', $buildContactSubType); // get the location blocks. $this->_blocks = $this->get('blocks'); if (CRM_Utils_System::isNull($this->_blocks)) { $this->_blocks = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 1'); $this->set('blocks', $this->_blocks); } $this->assign('blocks', $this->_blocks); // this is needed for custom data. $this->assign('entityID', $this->_contactId); // also keep the convention. $this->assign('contactId', $this->_contactId); // location blocks. CRM_Contact_Form_Location::preProcess($this); // retain the multiple count custom fields value if (!empty($_POST['hidden_custom'])) { $customGroupCount = CRM_Utils_Array::value('hidden_custom_group_count', $_POST); if ($contactSubType = CRM_Utils_Array::value('contact_sub_type', $_POST)) { $paramSubType = implode(',', $contactSubType); } $this->_getCachedTree = FALSE; unset($customGroupCount[0]); foreach ($customGroupCount as $groupID => $groupCount) { if ($groupCount > 1) { $this->set('groupID', $groupID); //loop the group for ($i = 0; $i <= $groupCount; $i++) { CRM_Custom_Form_CustomData::preProcess($this, NULL, $contactSubType, $i, $this->_contactType); CRM_Contact_Form_Edit_CustomData::buildQuickForm($this); } } } //reset all the ajax stuff, for normal processing if (isset($this->_groupTree)) { $this->_groupTree = NULL; } $this->set('groupID', NULL); $this->_getCachedTree = TRUE; } // execute preProcess dynamically by js else execute normal preProcess if (array_key_exists('CustomData', $this->_editOptions)) { //assign a parameter to pass for sub type multivalue //custom field to load if ($this->_contactSubType || isset($paramSubType)) { $paramSubType = isset($paramSubType) ? $paramSubType : str_replace(CRM_Core_DAO::VALUE_SEPARATOR, ',', trim($this->_contactSubType, CRM_Core_DAO::VALUE_SEPARATOR)); $this->assign('paramSubType', $paramSubType); } if (CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject)) { CRM_Contact_Form_Edit_CustomData::preProcess($this); } else { $contactSubType = $this->_contactSubType; // need contact sub type to build related grouptree array during post process if (!empty($_POST['contact_sub_type'])) { $contactSubType = $_POST['contact_sub_type']; } //only custom data has preprocess hence directly call it CRM_Custom_Form_CustomData::preProcess($this, NULL, $contactSubType, 1, $this->_contactType, $this->_contactId); $this->assign('customValueCount', $this->_customValueCount); } } }
/** * Set variables up before form is built. */ public function preProcess() { $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this); $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add'); $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); // check for action permissions. if (!CRM_Core_Permission::checkActionPermission('CiviPledge', $this->_action)) { CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); } $this->assign('action', $this->_action); $this->assign('context', $this->_context); if ($this->_action & CRM_Core_Action::DELETE) { return; } $this->userDisplayName = $this->userEmail = NULL; if ($this->_contactID) { list($this->userDisplayName, $this->userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID); $this->assign('displayName', $this->userDisplayName); } $this->setPageTitle(ts('Pledge')); // build custom data CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Pledge', $this->_id); $this->_values = array(); // current pledge id if ($this->_id) { // get the contribution id $this->_contributionID = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $this->_id, 'contribution_id', 'pledge_id'); $params = array('id' => $this->_id); CRM_Pledge_BAO_Pledge::getValues($params, $this->_values); $this->_isPending = CRM_Pledge_BAO_Pledge::pledgeHasFinancialTransactions($this->_id, CRM_Utils_Array::value('status_id', $this->_values)) ? FALSE : TRUE; } // get the pledge frequency units. $this->_freqUnits = CRM_Core_OptionGroup::values('recur_frequency_units'); $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail(); }