コード例 #1
0
 /**
  * Global validation rules for the form.
  *
  * @param array $values
  * @param $files
  * @param CRM_Core_Form $form
  *
  * @return array
  *   list of errors to be posted back to the form
  */
 public static function formRule($values, $files, $form)
 {
     if (!empty($values['is_online_registration'])) {
         if (!$values['confirm_title']) {
             $errorMsg['confirm_title'] = ts('Please enter a Title for the registration Confirmation Page');
         }
         if (!$values['thankyou_title']) {
             $errorMsg['thankyou_title'] = ts('Please enter a Title for the registration Thank-you Page');
         }
         if ($values['is_email_confirm']) {
             if (!$values['confirm_from_name']) {
                 $errorMsg['confirm_from_name'] = ts('Please enter Confirmation Email FROM Name.');
             }
             if (!$values['confirm_from_email']) {
                 $errorMsg['confirm_from_email'] = ts('Please enter Confirmation Email FROM Email Address.');
             }
         }
         if (isset($values['registration_start_date']) && isset($values['registration_end_date'])) {
             $start = CRM_Utils_Date::processDate($values['registration_start_date']);
             $end = CRM_Utils_Date::processDate($values['registration_end_date']);
             if ($end < $start) {
                 $errorMsg['registration_end_date'] = ts('Registration end date should be after Registration start date');
             }
         }
         //check that the selected profiles have either firstname+lastname or email required
         $profileIds = array(CRM_Utils_Array::value('custom_pre_id', $values), CRM_Utils_Array::value('custom_post_id', $values));
         $additionalProfileIds = array(CRM_Utils_Array::value('additional_custom_pre_id', $values), CRM_Utils_Array::value('additional_custom_post_id', $values));
         //additional profile fields default to main if not set
         if (!is_numeric($additionalProfileIds[0])) {
             $additionalProfileIds[0] = $profileIds[0];
         }
         if (!is_numeric($additionalProfileIds[1])) {
             $additionalProfileIds[1] = $profileIds[1];
         }
         //add multiple profiles if set
         self::addMultipleProfiles($profileIds, $values, 'custom_post_id_multiple');
         self::addMultipleProfiles($additionalProfileIds, $values, 'additional_custom_post_id_multiple');
         $isProfileComplete = self::isProfileComplete($profileIds);
         $isAdditionalProfileComplete = self::isProfileComplete($additionalProfileIds);
         //Check main profiles have an email address available if 'send confirmation email' is selected
         if ($values['is_email_confirm']) {
             $emailFields = self::getEmailFields($profileIds);
             if (!count($emailFields)) {
                 $errorMsg['is_email_confirm'] = ts("Please add a profile with an email address if 'Send Confirmation Email?' is selected");
             }
         }
         $additionalCustomPreId = $additionalCustomPostId = NULL;
         $isPreError = $isPostError = TRUE;
         if (!empty($values['allow_same_participant_emails']) && !empty($values['is_multiple_registrations'])) {
             $types = array_merge(array('Individual'), CRM_Contact_BAO_ContactType::subTypes('Individual'));
             $profiles = CRM_Core_BAO_UFGroup::getProfiles($types);
             //check for additional custom pre profile
             $additionalCustomPreId = CRM_Utils_Array::value('additional_custom_pre_id', $values);
             if (!empty($additionalCustomPreId)) {
                 if (!($additionalCustomPreId == 'none')) {
                     $customPreId = $additionalCustomPreId;
                 } else {
                     $isPreError = FALSE;
                 }
             } else {
                 $customPreId = !empty($values['custom_pre_id']) ? $values['custom_pre_id'] : NULL;
             }
             //check whether the additional custom pre profile is of type 'Individual' and its subtypes
             if (!empty($customPreId)) {
                 $profileTypes = CRM_Core_BAO_UFGroup::profileGroups($customPreId);
                 foreach ($types as $individualTypes) {
                     if (in_array($individualTypes, $profileTypes)) {
                         $isPreError = FALSE;
                         break;
                     }
                 }
             } else {
                 $isPreError = FALSE;
             }
             // We don't have required Individual fields in the pre-custom profile, so now check the post-custom profile
             if ($isPreError) {
                 $additionalCustomPostId = CRM_Utils_Array::value('additional_custom_post_id', $values);
                 if (!empty($additionalCustomPostId)) {
                     if (!($additionalCustomPostId == 'none')) {
                         $customPostId = $additionalCustomPostId;
                     } else {
                         $isPostError = FALSE;
                     }
                 } else {
                     $customPostId = !empty($values['custom_post_id']) ? $values['custom_post_id'] : NULL;
                 }
                 //check whether the additional custom post profile is of type 'Individual' and its subtypes
                 if (!empty($customPostId)) {
                     $profileTypes = CRM_Core_BAO_UFGroup::profileGroups($customPostId);
                     foreach ($types as $individualTypes) {
                         if (in_array($individualTypes, $profileTypes)) {
                             $isPostError = FALSE;
                             break;
                         }
                     }
                 } else {
                     $isPostError = FALSE;
                 }
                 if (empty($customPreId) && empty($customPostId)) {
                     $errorMsg['additional_custom_pre_id'] = ts("Allow multiple registrations from the same email address requires a profile of type 'Individual'");
                 }
                 if ($isPostError) {
                     $errorMsg['additional_custom_post_id'] = ts("Allow multiple registrations from the same email address requires a profile of type 'Individual'");
                 }
             }
         }
         if (!$isProfileComplete) {
             $errorMsg['custom_pre_id'] = ts("Please include a Profile for online registration that contains an Email Address field and / or First Name + Last Name fields.");
         }
         if (!$isAdditionalProfileComplete) {
             $errorMsg['additional_custom_pre_id'] = ts("Please include a Profile for online registration of additional participants that contains an Email Address field and / or First Name + Last Name fields.");
         }
         // // CRM-8485
         // $config = CRM_Core_Config::singleton();
         // if ( $config->doNotAttachPDFReceipt ) {
         //     if (!empty($values['custom_post_id_multiple'])) {
         //         foreach( $values['custom_post_id_multiple'] as $count => $customPostMultiple ) {
         //             if ( $customPostMultiple ) {
         //                 $errorMsg["custom_post_id_multiple[{$count}]"] = ts('Please disable PDF receipt as an attachment in <a href="%1">Miscellaneous Settings</a> if you want to add additional profiles.', array( 1 => CRM_Utils_System::url( 'civicrm/admin/setting/misc', 'reset=1' ) ) );
         //                 break;
         //             }
         //         }
         //     }
         //
         //     if (!empty($values['is_multiple_registrations']) &&
         //          CRM_Utils_Array::value('additional_custom_post_id_multiple',  $values) ) {
         //         foreach( $values['additional_custom_post_id_multiple'] as $count => $customPostMultiple ) {
         //             if ( $customPostMultiple ) {
         //                $errorMsg["additional_custom_post_id_multiple[{$count}]"] = ts('Please disable PDF receipt as an attachment in <a href="%1">Miscellaneous Settings</a> if you want to add additional profiles.', array( 1 => CRM_Utils_System::url( 'civicrm/admin/setting/misc', 'reset=1' ) ) );
         //                 break;
         //             }
         //         }
         //     }
         // }
         if (!empty($errorMsg)) {
             if (!empty($values['custom_post_id_multiple'])) {
                 foreach ($values['custom_post_id_multiple'] as $count => $customPostMultiple) {
                     self::buildMultipleProfileBottom($form, $count);
                 }
                 $form->assign('profilePostMultiple', $values['custom_post_id_multiple']);
             }
             if (!empty($values['additional_custom_post_id_multiple'])) {
                 foreach ($values['additional_custom_post_id_multiple'] as $count => $customPostMultiple) {
                     self::buildMultipleProfileBottom($form, $count, 'additional_', ts('Profile for Additional Participants'));
                 }
                 $form->assign('profilePostMultipleAdd', $values['additional_custom_post_id_multiple']);
             }
         }
     }
     if (!empty($errorMsg)) {
         return $errorMsg;
     }
     return TRUE;
 }
コード例 #2
0
 /**
  * Add onbehalf/honoree profile fields and native module fields.
  *
  * @param int $id
  * @param CRM_Core_Form $form
  */
 public function buildComponentForm($id, $form)
 {
     if (empty($id)) {
         return;
     }
     $contactID = $this->getContactID();
     foreach (array('soft_credit', 'on_behalf') as $module) {
         if ($module == 'soft_credit') {
             if (empty($form->_values['honoree_profile_id'])) {
                 continue;
             }
             if (!CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $form->_values['honoree_profile_id'], 'is_active')) {
                 CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of honoree and the selected honoree profile is either disabled or not found.'));
             }
             $profileContactType = CRM_Core_BAO_UFGroup::getContactType($form->_values['honoree_profile_id']);
             $requiredProfileFields = array('Individual' => array('first_name', 'last_name'), 'Organization' => array('organization_name', 'email'), 'Household' => array('household_name', 'email'));
             $validProfile = CRM_Core_BAO_UFGroup::checkValidProfile($form->_values['honoree_profile_id'], $requiredProfileFields[$profileContactType]);
             if (!$validProfile) {
                 CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of honoree and the required fields of the selected honoree profile are disabled or doesn\'t exist.'));
             }
             foreach (array('honor_block_title', 'honor_block_text') as $name) {
                 $form->assign($name, $form->_values[$name]);
             }
             $softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
             // radio button for Honor Type
             foreach ($form->_values['soft_credit_types'] as $value) {
                 $honorTypes[$value] = $form->createElement('radio', NULL, NULL, $softCreditTypes[$value], $value);
             }
             $form->addGroup($honorTypes, 'soft_credit_type_id', NULL)->setAttribute('allowClear', TRUE);
             $honoreeProfileFields = CRM_Core_BAO_UFGroup::getFields($this->_values['honoree_profile_id'], FALSE, NULL, NULL, NULL, FALSE, NULL, TRUE, NULL, CRM_Core_Permission::CREATE);
             $form->assign('honoreeProfileFields', $honoreeProfileFields);
             // add the form elements
             foreach ($honoreeProfileFields as $name => $field) {
                 // If soft credit type is not chosen then make omit requiredness from honoree profile fields
                 if (count($form->_submitValues) && empty($form->_submitValues['soft_credit_type_id']) && !empty($field['is_required'])) {
                     $field['is_required'] = FALSE;
                 }
                 CRM_Core_BAO_UFGroup::buildProfile($form, $field, CRM_Profile_Form::MODE_CREATE, NULL, FALSE, FALSE, NULL, 'honor');
             }
         } else {
             if (empty($form->_values['onbehalf_profile_id'])) {
                 continue;
             }
             if (!CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $form->_values['onbehalf_profile_id'], 'is_active')) {
                 CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of an organization and the selected onbehalf profile is either disabled or not found.'));
             }
             $member = CRM_Member_BAO_Membership::getMembershipBlock($form->_id);
             if (empty($member['is_active'])) {
                 $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.');
                 $onBehalfProfile = CRM_Core_BAO_UFGroup::profileGroups($form->_values['onbehalf_profile_id']);
                 foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                     if (in_array($contactType, $onBehalfProfile) && (in_array('Membership', $onBehalfProfile) || in_array('Contribution', $onBehalfProfile))) {
                         CRM_Core_Error::fatal($msg);
                     }
                 }
             }
             if ($contactID) {
                 // retrieve all permissioned organizations of contact $contactID
                 $organizations = CRM_Contact_BAO_Relationship::getPermissionedContacts($contactID, NULL, NULL, 'Organization');
                 if (count($organizations)) {
                     // Related org url - pass checksum if needed
                     $args = array('ufId' => $form->_values['onbehalf_profile_id'], 'cid' => '');
                     if (!empty($_GET['cs'])) {
                         $args = array('ufId' => $form->_values['onbehalf_profile_id'], 'uid' => $this->_contactID, 'cs' => $_GET['cs'], 'cid' => '');
                     }
                     $locDataURL = CRM_Utils_System::url('civicrm/ajax/permlocation', $args, FALSE, NULL, FALSE);
                     $form->assign('locDataURL', $locDataURL);
                 }
                 if (count($organizations) > 0) {
                     $form->add('select', 'onbehalfof_id', '', CRM_Utils_Array::collect('name', $organizations));
                     $orgOptions = array(0 => ts('Select an existing organization'), 1 => ts('Enter a new organization'));
                     $form->addRadio('org_option', ts('options'), $orgOptions);
                     $form->setDefaults(array('org_option' => 0));
                 }
             }
             $form->assign('fieldSetTitle', ts('Organization Details'));
             if (CRM_Utils_Array::value('is_for_organization', $form->_values)) {
                 if ($form->_values['is_for_organization'] == 2) {
                     $form->assign('onBehalfRequired', TRUE);
                 } else {
                     $form->addElement('checkbox', 'is_for_organization', $form->_values['for_organization'], NULL);
                 }
             }
             $profileFields = CRM_Core_BAO_UFGroup::getFields($form->_values['onbehalf_profile_id'], FALSE, CRM_Core_Action::VIEW, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL);
             $form->assign('onBehalfOfFields', $profileFields);
             if (!empty($form->_submitValues['onbehalf'])) {
                 if (!empty($form->_submitValues['onbehalfof_id'])) {
                     $form->assign('submittedOnBehalf', $form->_submitValues['onbehalfof_id']);
                 }
                 $form->assign('submittedOnBehalfInfo', json_encode($form->_submitValues['onbehalf']));
             }
             $fieldTypes = array('Contact', 'Organization');
             $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization');
             $fieldTypes = array_merge($fieldTypes, $contactSubType);
             foreach ($profileFields as $name => $field) {
                 if (in_array($field['field_type'], $fieldTypes)) {
                     list($prefixName, $index) = CRM_Utils_System::explode('-', $name, 2);
                     if (in_array($prefixName, array('organization_name', 'email')) && empty($field['is_required'])) {
                         $field['is_required'] = 1;
                     }
                     if (count($form->_submitValues) && empty($form->_submitValues['is_for_organization']) && $form->_values['is_for_organization'] == 1 && !empty($field['is_required'])) {
                         $field['is_required'] = FALSE;
                     }
                     CRM_Core_BAO_UFGroup::buildProfile($form, $field, NULL, NULL, FALSE, 'onbehalf', NULL, 'onbehalf');
                 }
             }
         }
     }
 }
コード例 #3
0
ファイル: Main.php プロジェクト: vakeesan26/civicrm-core
 /**
  * Set variables up before form is built.
  */
 public function preProcess()
 {
     parent::preProcess();
     self::preProcessPaymentOptions($this);
     // Make the contributionPageID available to the template
     $this->assign('contributionPageID', $this->_id);
     $this->assign('isShare', CRM_Utils_Array::value('is_share', $this->_values));
     $this->assign('isConfirmEnabled', CRM_Utils_Array::value('is_confirm_enabled', $this->_values));
     $this->assign('reset', CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject));
     $this->assign('mainDisplay', CRM_Utils_Request::retrieve('_qf_Main_display', 'Boolean', CRM_Core_DAO::$_nullObject));
     // Possible values for 'is_for_organization':
     // * 0 - org profile disabled
     // * 1 - org profile optional
     // * 2 - org profile required
     $this->_onbehalf = FALSE;
     if (!empty($this->_values['is_for_organization'])) {
         if ($this->_values['is_for_organization'] == 2) {
             $this->_onBehalfRequired = TRUE;
         }
         // Add organization profile if 1 of the following are true:
         // If the org profile is required
         if ($this->_onBehalfRequired || empty($_POST) || !empty($_POST['is_for_organization'])) {
             $this->_onbehalf = TRUE;
             CRM_Contribute_Form_Contribution_OnBehalfOf::preProcess($this);
         }
     }
     $this->assign('onBehalfRequired', $this->_onBehalfRequired);
     if ($this->_honor_block_is_active) {
         CRM_Contact_Form_ProfileContact::preprocess($this);
     }
     if ($this->_snippet) {
         $this->assign('isOnBehalfCallback', CRM_Utils_Array::value('onbehalf', $_GET, FALSE));
         return;
     }
     if (!empty($this->_pcpInfo['id']) && !empty($this->_pcpInfo['intro_text'])) {
         $this->assign('intro_text', $this->_pcpInfo['intro_text']);
     } elseif (!empty($this->_values['intro_text'])) {
         $this->assign('intro_text', $this->_values['intro_text']);
     }
     $qParams = "reset=1&amp;id={$this->_id}";
     if ($pcpId = CRM_Utils_Array::value('pcp_id', $this->_pcpInfo)) {
         $qParams .= "&amp;pcpId={$pcpId}";
     }
     $this->assign('qParams', $qParams);
     if (!empty($this->_values['footer_text'])) {
         $this->assign('footer_text', $this->_values['footer_text']);
     }
     //CRM-5001
     //CRM-15787
     $member = CRM_Member_BAO_Membership::getMembershipBlock($this->_id);
     if (!empty($this->_values['is_for_organization']) && empty($member['is_active'])) {
         $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.');
         $ufJoinParams = array('module' => 'onBehalf', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id);
         $onBehalfProfileIDs = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
         // getUFGroupIDs returns an array with the first item being the ID we need
         $onBehalfProfileID = $onBehalfProfileIDs[0];
         if ($onBehalfProfileID) {
             $onBehalfProfile = CRM_Core_BAO_UFGroup::profileGroups($onBehalfProfileID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $onBehalfProfile) && (in_array('Membership', $onBehalfProfile) || in_array('Contribution', $onBehalfProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
         if ($postID = CRM_Utils_Array::value('custom_post_id', $this->_values)) {
             $postProfile = CRM_Core_BAO_UFGroup::profileGroups($postID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $postProfile) && (in_array('Membership', $postProfile) || in_array('Contribution', $postProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
     }
 }
コード例 #4
0
ファイル: Relationship.php プロジェクト: hguru/224Civi
 static function getValidContactTypeList($relType)
 {
     // string looks like 4_a_b
     $rel_parts = explode('_', $relType);
     $allRelationshipType = CRM_Core_PseudoConstant::relationshipType('label');
     $contactProfiles = CRM_Core_BAO_UFGroup::getReservedProfiles('Contact', NULL);
     if ($rel_parts[1] == 'a') {
         $leftType = $allRelationshipType[$rel_parts[0]]['contact_type_b'];
     } else {
         $leftType = $allRelationshipType[$rel_parts[0]]['contact_type_a'];
     }
     // Handle 'All Contacts' contact type for left side of relationship ($leftType is empty in this case)
     // In this case all reserved profiles are available
     if ($leftType == '') {
         $contactTypes = $contactProfiles;
     } else {
         $contactTypes = array();
         foreach ($contactProfiles as $key => $value) {
             $groupTypes = CRM_Core_BAO_UFGroup::profileGroups($key);
             if (in_array($leftType, $groupTypes)) {
                 $contactTypes = array($key => $value);
             }
         }
     }
     return $contactTypes;
 }
コード例 #5
0
 /**
  * global validation rules for the form
  *
  * @param array $fields posted values of the form
  *
  * @return array list of errors to be posted back to the form
  * @static
  * @access public
  */
 static function formRule($values)
 {
     if (CRM_Utils_Array::value('is_online_registration', $values)) {
         if (!$values['confirm_title']) {
             $errorMsg['confirm_title'] = ts('Please enter a Title for the registration Confirmation Page');
         }
         if (!$values['thankyou_title']) {
             $errorMsg['thankyou_title'] = ts('Please enter a Title for the registration Thank-you Page');
         }
         if ($values['is_email_confirm']) {
             if (!$values['confirm_from_name']) {
                 $errorMsg['confirm_from_name'] = ts('Please enter Confirmation Email FROM Name.');
             }
             if (!$values['confirm_from_email']) {
                 $errorMsg['confirm_from_email'] = ts('Please enter Confirmation Email FROM Email Address.');
             }
         }
         $additionalCustomPreId = $additionalCustomPostId = null;
         $isPreError = $isPostError = true;
         if (CRM_Utils_Array::value('allow_same_participant_emails', $values) && CRM_Utils_Array::value('is_multiple_registrations', $values)) {
             $types = array_merge(array('Individual'), CRM_Contact_BAO_ContactType::subTypes('Individual'));
             $profiles = CRM_Core_BAO_UFGroup::getProfiles($types);
             //check for additional custom pre profile
             $additionalCustomPreId = CRM_Utils_Array::value('additional_custom_pre_id', $values);
             if (!empty($additionalCustomPreId)) {
                 if (!($additionalCustomPreId == 'none')) {
                     $customPreId = $additionalCustomPreId;
                 } else {
                     $isPreError = false;
                 }
             } else {
                 $customPreId = CRM_Utils_Array::value('custom_pre_id', $values) ? $values['custom_pre_id'] : null;
             }
             //check whether the additional custom pre profile is of type 'Individual' and its subtypes
             if (!empty($customPreId)) {
                 $profileTypes = CRM_Core_BAO_UFGroup::profileGroups($customPreId);
                 foreach ($types as $individualTypes) {
                     if (in_array($individualTypes, $profileTypes)) {
                         $isPreError = false;
                         break;
                     }
                 }
             } else {
                 $isPreError = false;
             }
             //check for additional custom post profile
             $additionalCustomPostId = CRM_Utils_Array::value('additional_custom_post_id', $values);
             if (!empty($additionalCustomPostId)) {
                 if (!($additionalCustomPostId == 'none')) {
                     $customPostId = $additionalCustomPostId;
                 } else {
                     $isPostError = false;
                 }
             } else {
                 $customPostId = CRM_Utils_Array::value('custom_post_id', $values) ? $values['custom_post_id'] : null;
             }
             //check whether the additional custom post profile is of type 'Individual' and its subtypes
             if (!empty($customPostId)) {
                 $profileTypes = CRM_Core_BAO_UFGroup::profileGroups($customPostId);
                 foreach ($types as $individualTypes) {
                     if (in_array($individualTypes, $profileTypes)) {
                         $isPostError = false;
                         break;
                     }
                 }
             } else {
                 $isPostError = false;
             }
             if ($isPreError || empty($customPreId) && empty($customPostId)) {
                 $errorMsg['additional_custom_pre_id'] = ts("Allow multiple registrations from the same email address requires a profile of type 'Individual'");
             }
             if ($isPostError) {
                 $errorMsg['additional_custom_post_id'] = ts("Allow multiple registrations from the same email address requires a profile of type 'Individual'");
             }
         }
     }
     if (!empty($errorMsg)) {
         return $errorMsg;
     }
     return true;
 }
コード例 #6
0
 /**
  * Send the emails.
  *
  * @param int $contactID
  *   Contact id.
  * @param array $values
  *   Associated array of fields.
  * @param bool $isTest
  *   If in test mode.
  * @param bool $returnMessageText
  *   Return the message text instead of sending the mail.
  *
  * @param null $fieldTypes
  *
  * @return void
  */
 public static function sendMail($contactID, $values, $isTest = FALSE, $returnMessageText = FALSE, $fieldTypes = NULL)
 {
     $gIds = $params = array();
     $email = NULL;
     if (isset($values['custom_pre_id'])) {
         $preProfileType = CRM_Core_BAO_UFField::getProfileType($values['custom_pre_id']);
         if ($preProfileType == 'Membership' && !empty($values['membership_id'])) {
             $params['custom_pre_id'] = array(array('member_id', '=', $values['membership_id'], 0, 0));
         } elseif ($preProfileType == 'Contribution' && !empty($values['contribution_id'])) {
             $params['custom_pre_id'] = array(array('contribution_id', '=', $values['contribution_id'], 0, 0));
         }
         $gIds['custom_pre_id'] = $values['custom_pre_id'];
     }
     if (isset($values['custom_post_id'])) {
         $postProfileType = CRM_Core_BAO_UFField::getProfileType($values['custom_post_id']);
         if ($postProfileType == 'Membership' && !empty($values['membership_id'])) {
             $params['custom_post_id'] = array(array('member_id', '=', $values['membership_id'], 0, 0));
         } elseif ($postProfileType == 'Contribution' && !empty($values['contribution_id'])) {
             $params['custom_post_id'] = array(array('contribution_id', '=', $values['contribution_id'], 0, 0));
         }
         $gIds['custom_post_id'] = $values['custom_post_id'];
     }
     if (!empty($values['is_for_organization'])) {
         if (!empty($values['membership_id'])) {
             $params['onbehalf_profile'] = array(array('member_id', '=', $values['membership_id'], 0, 0));
         } elseif (!empty($values['contribution_id'])) {
             $params['onbehalf_profile'] = array(array('contribution_id', '=', $values['contribution_id'], 0, 0));
         }
     }
     //check whether it is a test drive
     if ($isTest && !empty($params['custom_pre_id'])) {
         $params['custom_pre_id'][] = array('contribution_test', '=', 1, 0, 0);
     }
     if ($isTest && !empty($params['custom_post_id'])) {
         $params['custom_post_id'][] = array('contribution_test', '=', 1, 0, 0);
     }
     if (!$returnMessageText && !empty($gIds)) {
         //send notification email if field values are set (CRM-1941)
         foreach ($gIds as $key => $gId) {
             if ($gId) {
                 $email = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gId, 'notify');
                 if ($email) {
                     $val = CRM_Core_BAO_UFGroup::checkFieldsEmptyValues($gId, $contactID, CRM_Utils_Array::value($key, $params), TRUE);
                     CRM_Core_BAO_UFGroup::commonSendMail($contactID, $val);
                 }
             }
         }
     }
     if (!empty($values['is_email_receipt']) || !empty($values['onbehalf_dupe_alert']) || $returnMessageText) {
         $template = CRM_Core_Smarty::singleton();
         // get the billing location type
         if (!array_key_exists('related_contact', $values)) {
             $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
             $billingLocationTypeId = array_search('Billing', $locationTypes);
         } else {
             // presence of related contact implies onbehalf of org case,
             // where location type is set to default.
             $locType = CRM_Core_BAO_LocationType::getDefault();
             $billingLocationTypeId = $locType->id;
         }
         if (!array_key_exists('related_contact', $values)) {
             list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID, FALSE, $billingLocationTypeId);
         }
         // get primary location email if no email exist( for billing location).
         if (!$email) {
             list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
         }
         if (empty($displayName)) {
             list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
         }
         //for display profile need to get individual contact id,
         //hence get it from related_contact if on behalf of org true CRM-3767
         //CRM-5001 Contribution/Membership:: On Behalf of Organization,
         //If profile GROUP contain the Individual type then consider the
         //profile is of Individual ( including the custom data of membership/contribution )
         //IF Individual type not present in profile then it is consider as Organization data.
         $userID = $contactID;
         if ($preID = CRM_Utils_Array::value('custom_pre_id', $values)) {
             if (!empty($values['related_contact'])) {
                 $preProfileTypes = CRM_Core_BAO_UFGroup::profileGroups($preID);
                 //@todo - following line should not refer to undefined $postProfileTypes? figure out way to test
                 if (in_array('Individual', $preProfileTypes) || in_array('Contact', $postProfileTypes)) {
                     //Take Individual contact ID
                     $userID = CRM_Utils_Array::value('related_contact', $values);
                 }
             }
             self::buildCustomDisplay($preID, 'customPre', $userID, $template, $params['custom_pre_id']);
         }
         $userID = $contactID;
         if ($postID = CRM_Utils_Array::value('custom_post_id', $values)) {
             if (!empty($values['related_contact'])) {
                 $postProfileTypes = CRM_Core_BAO_UFGroup::profileGroups($postID);
                 if (in_array('Individual', $postProfileTypes) || in_array('Contact', $postProfileTypes)) {
                     //Take Individual contact ID
                     $userID = CRM_Utils_Array::value('related_contact', $values);
                 }
             }
             self::buildCustomDisplay($postID, 'customPost', $userID, $template, $params['custom_post_id']);
         }
         if (isset($values['honor'])) {
             $honorValues = $values['honor'];
             CRM_Contribute_BAO_ContributionSoft::formatHonoreeProfileFields($template, $honorValues['honor_profile_values'], $honorValues['honor_profile_id'], $honorValues['honor_id']);
         }
         $title = isset($values['title']) ? $values['title'] : CRM_Contribute_PseudoConstant::contributionPage($values['contribution_page_id']);
         // set email in the template here
         $tplParams = array('email' => $email, 'receiptFromEmail' => CRM_Utils_Array::value('receipt_from_email', $values), 'contactID' => $contactID, 'displayName' => $displayName, 'contributionID' => CRM_Utils_Array::value('contribution_id', $values), 'contributionOtherID' => CRM_Utils_Array::value('contribution_other_id', $values), 'lineItem' => CRM_Utils_Array::value('lineItem', $values), 'priceSetID' => CRM_Utils_Array::value('priceSetID', $values), 'title' => $title, 'isShare' => CRM_Utils_Array::value('is_share', $values), 'thankyou_title' => CRM_Utils_Array::value('thankyou_title', $values));
         if ($contributionTypeId = CRM_Utils_Array::value('financial_type_id', $values)) {
             $tplParams['contributionTypeId'] = $contributionTypeId;
             $tplParams['contributionTypeName'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $contributionTypeId);
         }
         if ($contributionPageId = CRM_Utils_Array::value('id', $values)) {
             $tplParams['contributionPageId'] = $contributionPageId;
         }
         // address required during receipt processing (pdf and email receipt)
         if ($displayAddress = CRM_Utils_Array::value('address', $values)) {
             $tplParams['address'] = $displayAddress;
         }
         // CRM-6976
         $originalCCReceipt = CRM_Utils_Array::value('cc_receipt', $values);
         // cc to related contacts of contributor OR the one who
         // signs up. Is used for cases like - on behalf of
         // contribution / signup ..etc
         if (array_key_exists('related_contact', $values)) {
             list($ccDisplayName, $ccEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($values['related_contact']);
             $ccMailId = "{$ccDisplayName} <{$ccEmail}>";
             //@todo - this is the only place in this function where  $values is altered - but I can't find any evidence it is used
             $values['cc_receipt'] = !empty($values['cc_receipt']) ? $values['cc_receipt'] . ',' . $ccMailId : $ccMailId;
             // reset primary-email in the template
             $tplParams['email'] = $ccEmail;
             $tplParams['onBehalfName'] = $displayName;
             $tplParams['onBehalfEmail'] = $email;
             $ufJoinParams = array('module' => 'onBehalf', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $values['id']);
             $OnBehalfProfile = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
             $profileId = $OnBehalfProfile[0];
             $userID = $contactID;
             self::buildCustomDisplay($profileId, 'onBehalfProfile', $userID, $template, $params['onbehalf_profile'], $fieldTypes);
         }
         // use either the contribution or membership receipt, based on whether it’s a membership-related contrib or not
         $sendTemplateParams = array('groupName' => !empty($values['isMembership']) ? 'msg_tpl_workflow_membership' : 'msg_tpl_workflow_contribution', 'valueName' => !empty($values['isMembership']) ? 'membership_online_receipt' : 'contribution_online_receipt', 'contactId' => $contactID, 'tplParams' => $tplParams, 'isTest' => $isTest, 'PDFFilename' => 'receipt.pdf');
         if ($returnMessageText) {
             list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
             return array('subject' => $subject, 'body' => $message, 'to' => $displayName, 'html' => $html);
         }
         if ($values['is_email_receipt']) {
             $sendTemplateParams['from'] = CRM_Utils_Array::value('receipt_from_name', $values) . ' <' . $values['receipt_from_email'] . '>';
             $sendTemplateParams['toName'] = $displayName;
             $sendTemplateParams['toEmail'] = $email;
             $sendTemplateParams['cc'] = CRM_Utils_Array::value('cc_receipt', $values);
             $sendTemplateParams['bcc'] = CRM_Utils_Array::value('bcc_receipt', $values);
             //send email with pdf invoice
             $template = CRM_Core_Smarty::singleton();
             $taxAmt = $template->get_template_vars('dataArray');
             $prefixValue = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
             $invoicing = CRM_Utils_Array::value('invoicing', $prefixValue);
             if (count($taxAmt) > 0 && (isset($invoicing) && isset($prefixValue['is_email_pdf']))) {
                 $sendTemplateParams['isEmailPdf'] = TRUE;
                 $sendTemplateParams['contributionId'] = $values['contribution_id'];
             }
             list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
         }
         // send duplicate alert, if dupe match found during on-behalf-of processing.
         if (!empty($values['onbehalf_dupe_alert'])) {
             $sendTemplateParams['groupName'] = 'msg_tpl_workflow_contribution';
             $sendTemplateParams['valueName'] = 'contribution_dupalert';
             $sendTemplateParams['from'] = ts('Automatically Generated') . " <{$values['receipt_from_email']}>";
             $sendTemplateParams['toName'] = CRM_Utils_Array::value('receipt_from_name', $values);
             $sendTemplateParams['toEmail'] = CRM_Utils_Array::value('receipt_from_email', $values);
             $sendTemplateParams['tplParams']['onBehalfID'] = $contactID;
             $sendTemplateParams['tplParams']['receiptMessage'] = $message;
             // fix cc and reset back to original, CRM-6976
             $sendTemplateParams['cc'] = $originalCCReceipt;
             CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
         }
     }
 }
コード例 #7
0
ファイル: Main.php プロジェクト: archcidburnziso/civicrm-core
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     parent::preProcess();
     self::preProcessPaymentOptions($this);
     // Make the contributionPageID avilable to the template
     $this->assign('contributionPageID', $this->_id);
     $this->assign('isShare', CRM_Utils_Array::value('is_share', $this->_values));
     $this->assign('isConfirmEnabled', CRM_Utils_Array::value('is_confirm_enabled', $this->_values));
     // make sure we have right permission to edit this user
     $csContactID = $this->getContactID();
     $reset = CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject);
     $mainDisplay = CRM_Utils_Request::retrieve('_qf_Main_display', 'Boolean', CRM_Core_DAO::$_nullObject);
     if ($reset) {
         $this->assign('reset', $reset);
     }
     if ($mainDisplay) {
         $this->assign('mainDisplay', $mainDisplay);
     }
     // Possible values for 'is_for_organization':
     // * 0 - org profile disabled
     // * 1 - org profile optional
     // * 2 - org profile required
     $this->_onbehalf = FALSE;
     if (!empty($this->_values['is_for_organization'])) {
         if ($this->_values['is_for_organization'] == 2) {
             $this->_onBehalfRequired = TRUE;
         }
         // Add organization profile if 1 of the following are true:
         // If the org profile is required
         if ($this->_onBehalfRequired || empty($_POST) || !empty($_POST['is_for_organization'])) {
             $this->_onbehalf = TRUE;
             CRM_Contribute_Form_Contribution_OnBehalfOf::preProcess($this);
         }
     }
     $this->assign('onBehalfRequired', $this->_onBehalfRequired);
     if (!empty($this->_values['honor_block_is_active'])) {
         CRM_Contact_Form_ProfileContact::preprocess($this);
     }
     if ($this->_snippet) {
         $this->assign('isOnBehalfCallback', CRM_Utils_Array::value('onbehalf', $_GET, FALSE));
         return;
     }
     if (!empty($this->_pcpInfo['id']) && !empty($this->_pcpInfo['intro_text'])) {
         $this->assign('intro_text', $this->_pcpInfo['intro_text']);
     } elseif (!empty($this->_values['intro_text'])) {
         $this->assign('intro_text', $this->_values['intro_text']);
     }
     $qParams = "reset=1&amp;id={$this->_id}";
     if ($pcpId = CRM_Utils_Array::value('pcp_id', $this->_pcpInfo)) {
         $qParams .= "&amp;pcpId={$pcpId}";
     }
     $this->assign('qParams', $qParams);
     if (!empty($this->_values['footer_text'])) {
         $this->assign('footer_text', $this->_values['footer_text']);
     }
     //CRM-5001
     if (!empty($this->_values['is_for_organization'])) {
         $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.');
         if ($preID = CRM_Utils_Array::value('custom_pre_id', $this->_values)) {
             $preProfile = CRM_Core_BAO_UFGroup::profileGroups($preID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $preProfile) && (in_array('Membership', $preProfile) || in_array('Contribution', $preProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
         if ($postID = CRM_Utils_Array::value('custom_post_id', $this->_values)) {
             $postProfile = CRM_Core_BAO_UFGroup::profileGroups($postID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $postProfile) && (in_array('Membership', $postProfile) || in_array('Contribution', $postProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
     }
 }
コード例 #8
0
ファイル: ContributionPage.php プロジェクト: ksecor/civicrm
 /**
  * Function to send the emails
  * 
  * @param int     $contactID         contact id 
  * @param array   $values            associated array of fields
  * @param boolean $isTest            if in test mode
  * @param boolean $returnMessageText return the message text instead of sending the mail
  *
  * @return void
  * @access public
  * @static
  */
 static function sendMail($contactID, &$values, $isTest = false, $returnMessageText = false)
 {
     require_once "CRM/Core/BAO/UFField.php";
     $gIds = array();
     $params = array();
     if (isset($values['custom_pre_id'])) {
         $preProfileType = CRM_Core_BAO_UFField::getProfileType($values['custom_pre_id']);
         if ($preProfileType == 'Membership' && CRM_Utils_Array::value('membership_id', $values)) {
             $params['custom_pre_id'] = array(array('membership_id', '=', $values['membership_id'], 0, 0));
         } else {
             if ($preProfileType == 'Contribution' && CRM_Utils_Array::value('contribution_id', $values)) {
                 $params['custom_pre_id'] = array(array('contribution_id', '=', $values['contribution_id'], 0, 0));
             }
         }
         $gIds['custom_pre_id'] = $values['custom_pre_id'];
     }
     if (isset($values['custom_post_id'])) {
         $postProfileType = CRM_Core_BAO_UFField::getProfileType($values['custom_post_id']);
         if ($postProfileType == 'Membership' && CRM_Utils_Array::value('membership_id', $values)) {
             $params['custom_post_id'] = array(array('membership_id', '=', $values['membership_id'], 0, 0));
         } else {
             if ($postProfileType == 'Contribution' && CRM_Utils_Array::value('contribution_id', $values)) {
                 $params['custom_post_id'] = array(array('contribution_id', '=', $values['contribution_id'], 0, 0));
             }
         }
         $gIds['custom_post_id'] = $values['custom_post_id'];
     }
     //check whether it is a test drive
     if ($isTest && !empty($params['custom_pre_id'])) {
         $params['custom_pre_id'][] = array('contribution_test', '=', 1, 0, 0);
     }
     if ($isTest && !empty($params['custom_post_id'])) {
         $params['custom_post_id'][] = array('contribution_test', '=', 1, 0, 0);
     }
     if (!$returnMessageText) {
         //send notification email if field values are set (CRM-1941)
         require_once 'CRM/Core/BAO/UFGroup.php';
         foreach ($gIds as $key => $gId) {
             $email = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gId, 'notify');
             if ($email) {
                 $val = CRM_Core_BAO_UFGroup::checkFieldsEmptyValues($gId, $contactID, $params[$key]);
                 CRM_Core_BAO_UFGroup::commonSendMail($contactID, $val);
             }
         }
     }
     if (CRM_Utils_Array::value('is_email_receipt', $values) || CRM_Utils_Array::value('onbehalf_dupe_alert', $values)) {
         $template =& CRM_Core_Smarty::singleton();
         // get the billing location type
         if (!array_key_exists('related_contact', $values)) {
             $locationTypes =& CRM_Core_PseudoConstant::locationType();
             $billingLocationTypeId = array_search('Billing', $locationTypes);
         } else {
             // presence of related contact implies onbehalf of org case,
             // where location type is set to default.
             require_once 'CRM/Core/BAO/LocationType.php';
             $locType = CRM_Core_BAO_LocationType::getDefault();
             $billingLocationTypeId = $locType->id;
         }
         require_once 'CRM/Contact/BAO/Contact/Location.php';
         if (!array_key_exists('related_contact', $values)) {
             list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID, false, $billingLocationTypeId);
         } else {
             list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
         }
         //for display profile need to get individual contact id,
         //hence get it from related_contact if on behalf of org true CRM-3767.
         //CRM-5001 Contribution/Membership:: On Behalf of Organization,
         //If profile GROUP contain the Individual type then consider the
         //profile is of Individual ( including the custom data of membership/contribution )
         //IF Individual type not present in profile then it is consider as Organization data.
         require_once 'CRM/Core/BAO/UFGroup.php';
         $userID = $contactID;
         if ($preID = CRM_Utils_Array::value('custom_pre_id', $values)) {
             if (CRM_Utils_Array::value('related_contact', $values)) {
                 $preProfileTypes = CRM_Core_BAO_UFGroup::profileGroups($preID);
                 if (in_array('Individual', $preProfileTypes)) {
                     //Take Individual contact ID
                     $userID = CRM_Utils_Array::value('related_contact', $values);
                 }
             }
             self::buildCustomDisplay($preID, 'customPre', $userID, $template, $params['custom_pre_id']);
         }
         $userID = $contactID;
         if ($postID = CRM_Utils_Array::value('custom_post_id', $values)) {
             if (CRM_Utils_Array::value('related_contact', $values)) {
                 $postProfileTypes = CRM_Core_BAO_UFGroup::profileGroups($postID);
                 if (in_array('Individual', $postProfileTypes)) {
                     //Take Individual contact ID
                     $userID = CRM_Utils_Array::value('related_contact', $values);
                 }
             }
             self::buildCustomDisplay($postID, 'customPost', $userID, $template, $params['custom_post_id']);
         }
         // set email in the template here
         $tplParams = array('email' => $email, 'receiptFromEmail' => $values['receipt_from_email'], 'contactID' => $contactID, 'contributionID' => $values['contribution_id'], 'membershipID' => CRM_Utils_Array::value('membership_id', $values), 'lineItem' => CRM_Utils_Array::value('lineItem', $values), 'priceSetID' => CRM_Utils_Array::value('priceSetID', $values));
         // cc to related contacts of contributor OR the one who
         // signs up. Is used for cases like - on behalf of
         // contribution / signup ..etc
         if (array_key_exists('related_contact', $values)) {
             list($ccDisplayName, $ccEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($values['related_contact']);
             $ccMailId = "{$ccDisplayName} <{$ccEmail}>";
             $values['cc_receipt'] = CRM_Utils_Array::value('cc_receipt', $values) ? $values['cc_receipt'] . ',' . $ccMailId : $ccMailId;
             // reset primary-email in the template
             $tplParams['email'] = $ccEmail;
             $tplParams['onBehalfName'] = $displayName;
             $tplParams['onBehalfEmail'] = $email;
         }
         $sendTemplateParams = array('groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'contribution_receipt', 'contactId' => $contactID, 'tplParams' => $tplParams, 'isTest' => $isTest);
         require_once 'CRM/Core/BAO/MessageTemplates.php';
         if ($returnMessageText) {
             list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplates::sendTemplate($sendTemplateParams);
             return array('subject' => $subject, 'body' => $message, 'to' => $displayName);
         }
         if ($values['is_email_receipt']) {
             $sendTemplateParams['from'] = CRM_Utils_Array::value('receipt_from_name', $values) . ' <' . $values['receipt_from_email'] . '>';
             $sendTemplateParams['toName'] = $displayName;
             $sendTemplateParams['toEmail'] = $email;
             $sendTemplateParams['cc'] = CRM_Utils_Array::value('cc_receipt', $values);
             $sendTemplateParams['bcc'] = CRM_Utils_Array::value('bcc_receipt', $values);
             list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplates::sendTemplate($sendTemplateParams);
         }
         // send duplicate alert, if dupe match found during on-behalf-of processing.
         if (CRM_Utils_Array::value('onbehalf_dupe_alert', $values)) {
             $sendTemplateParams['groupName'] = 'msg_tpl_workflow_contribution';
             $sendTemplateParams['valueName'] = 'contribution_dupalert';
             $sendTemplateParams['from'] = ts('Automatically Generated') . " <{$values['receipt_from_email']}>";
             $sendTemplateParams['toName'] = CRM_Utils_Array::value('receipt_from_name', $values);
             $sendTemplateParams['toEmail'] = $values['receipt_from_email'];
             $sendTemplateParams['tplParams']['onBehalfID'] = $contactID;
             $sendTemplateParams['tplParams']['receiptMessage'] = $message;
             CRM_Core_BAO_MessageTemplates::sendTemplate($sendTemplateParams);
         }
     }
 }
コード例 #9
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     parent::preProcess();
     $this->_ppType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('ppType', FALSE);
     if ($this->_ppType) {
         $this->assign('ppType', TRUE);
         return CRM_Core_Payment_ProcessorForm::preProcess($this);
     }
     //get payPal express id and make it available to template
     $paymentProcessors = $this->get('paymentProcessors');
     if (!empty($paymentProcessors)) {
         foreach ($paymentProcessors as $ppId => $values) {
             $payPalExpressId = $values['payment_processor_type'] == 'PayPal_Express' ? $values['id'] : 0;
             $this->assign('payPalExpressId', $payPalExpressId);
             if ($payPalExpressId) {
                 break;
             }
         }
     }
     // Make the contributionPageID avilable to the template
     $this->assign('contributionPageID', $this->_id);
     $this->assign('isShare', CRM_Utils_Array::value('is_share', $this->_values));
     $this->assign('isConfirmEnabled', CRM_Utils_Array::value('is_confirm_enabled', $this->_values));
     // make sure we have right permission to edit this user
     $csContactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE, $this->_userID);
     $reset = CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject);
     $mainDisplay = CRM_Utils_Request::retrieve('_qf_Main_display', 'Boolean', CRM_Core_DAO::$_nullObject);
     if ($csContactID != $this->_userID) {
         if (CRM_Contact_BAO_Contact_Permission::validateChecksumContact($csContactID, $this)) {
             $session = CRM_Core_Session::singleton();
             $session->set('userID', $csContactID);
             $this->_userID = $csContactID;
         }
     }
     if ($reset) {
         $this->assign('reset', $reset);
     }
     if ($mainDisplay) {
         $this->assign('mainDisplay', $mainDisplay);
     }
     $this->_onbehalf = FALSE;
     if (CRM_Utils_Array::value('is_for_organization', $this->_values)) {
         $urlParams = "&id={$this->_id}&qfKey={$this->controller->_key}";
         $this->assign('urlParams', $urlParams);
         $this->_onbehalf = CRM_Utils_Array::value('onbehalf', $_GET);
         CRM_Contribute_Form_Contribution_OnBehalfOf::preProcess($this);
         if (CRM_Utils_Array::value('hidden_onbehalf_profile', $_POST) && (CRM_Utils_Array::value('is_for_organization', $_POST) || CRM_Utils_Array::value('is_for_organization', $this->_values) == 2)) {
             CRM_Contribute_Form_Contribution_OnBehalfOf::buildQuickForm($this);
         }
     }
     if (CRM_Utils_Array::value('id', $this->_pcpInfo) && CRM_Utils_Array::value('intro_text', $this->_pcpInfo)) {
         $this->assign('intro_text', $this->_pcpInfo['intro_text']);
     } elseif (CRM_Utils_Array::value('intro_text', $this->_values)) {
         $this->assign('intro_text', $this->_values['intro_text']);
     }
     $qParams = "reset=1&amp;id={$this->_id}";
     if ($pcpId = CRM_Utils_Array::value('pcp_id', $this->_pcpInfo)) {
         $qParams .= "&amp;pcpId={$pcpId}";
     }
     $this->assign('qParams', $qParams);
     if (CRM_Utils_Array::value('footer_text', $this->_values)) {
         $this->assign('footer_text', $this->_values['footer_text']);
     }
     //CRM-5001
     if (CRM_Utils_Array::value('is_for_organization', $this->_values)) {
         $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.');
         if ($preID = CRM_Utils_Array::value('custom_pre_id', $this->_values)) {
             $preProfile = CRM_Core_BAO_UFGroup::profileGroups($preID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $preProfile) && (in_array('Membership', $preProfile) || in_array('Contribution', $preProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
         if ($postID = CRM_Utils_Array::value('custom_post_id', $this->_values)) {
             $postProfile = CRM_Core_BAO_UFGroup::profileGroups($postID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $postProfile) && (in_array('Membership', $postProfile) || in_array('Contribution', $postProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
     }
     if (CRM_Utils_Array::value('hidden_processor', $_POST)) {
         $this->set('type', CRM_Utils_Array::value('payment_processor', $_POST));
         $this->set('mode', $this->_mode);
         $this->set('paymentProcessor', $this->_paymentProcessor);
         CRM_Core_Payment_ProcessorForm::preProcess($this);
         CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
     }
 }
コード例 #10
0
 /** 
  * Function to set variables up before form is built 
  *                                                           
  * @return void 
  * @access public 
  */
 public function preProcess()
 {
     parent::preProcess();
     // make sure we have right permission to edit this user
     $csContactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false, $this->_userID);
     $reset = CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject);
     $mainDisplay = CRM_Utils_Request::retrieve('_qf_Main_display', 'Boolean', CRM_Core_DAO::$_nullObject);
     require_once 'CRM/Contact/BAO/Contact.php';
     if ($csContactID != $this->_userID) {
         require_once 'CRM/Contact/BAO/Contact/Permission.php';
         if (CRM_Contact_BAO_Contact_Permission::validateChecksumContact($csContactID, $this)) {
             $session = CRM_Core_Session::singleton();
             $session->set('userID', $csContactID);
             $this->_userID = $csContactID;
         }
     }
     if ($reset) {
         $this->assign('reset', $reset);
     }
     if ($mainDisplay) {
         $this->assign('mainDisplay', $mainDisplay);
     }
     $this->_onbehalf = false;
     if (CRM_Utils_Array::value('is_for_organization', $this->_values)) {
         $urlParams = "&id={$this->_id}&qfKey={$this->controller->_key}";
         $this->assign('urlParams', $urlParams);
         $this->_onbehalf = CRM_Utils_Array::value('onbehalf', $_GET);
         require_once 'CRM/Contribute/Form/Contribution/OnBehalfOf.php';
         CRM_Contribute_Form_Contribution_OnBehalfOf::preProcess($this);
         if (CRM_Utils_Array::value('hidden_onbehalf_profile', $_POST) && CRM_Utils_Array::value('is_for_organization', $_POST)) {
             CRM_Contribute_Form_Contribution_OnBehalfOf::buildQuickForm($this);
         }
     }
     if (CRM_Utils_Array::value('id', $this->_pcpInfo) && CRM_Utils_Array::value('intro_text', $this->_pcpInfo)) {
         $this->assign('intro_text', $this->_pcpInfo['intro_text']);
     } else {
         if (CRM_Utils_Array::value('intro_text', $this->_values)) {
             $this->assign('intro_text', $this->_values['intro_text']);
         }
     }
     if (CRM_Utils_Array::value('footer_text', $this->_values)) {
         $this->assign('footer_text', $this->_values['footer_text']);
     }
     //CRM-5001
     if ($this->_values['is_for_organization']) {
         $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.');
         require_once 'CRM/Core/BAO/UFGroup.php';
         if ($preID = CRM_Utils_Array::value('custom_pre_id', $this->_values)) {
             $preProfile = CRM_Core_BAO_UFGroup::profileGroups($preID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $preProfile) && (in_array('Membership', $preProfile) || in_array('Contribution', $preProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
         if ($postID = CRM_Utils_Array::value('custom_post_id', $this->_values)) {
             $postProfile = CRM_Core_BAO_UFGroup::profileGroups($postID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $postProfile) && (in_array('Membership', $postProfile) || in_array('Contribution', $postProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
     }
 }
コード例 #11
0
ファイル: Main.php プロジェクト: hampelm/Ginsberg-CiviDemo
 /** 
  * Function to set variables up before form is built 
  *                                                           
  * @return void 
  * @access public 
  */
 public function preProcess()
 {
     parent::preProcess();
     // make sure we have right permission to edit this user
     $csContactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false, $this->_userID);
     require_once 'CRM/Contact/BAO/Contact.php';
     if ($csContactID != $this->_userID) {
         require_once 'CRM/Contact/BAO/Contact/Permission.php';
         if (CRM_Contact_BAO_Contact_Permission::validateChecksumContact($csContactID, $this)) {
             $session = CRM_Core_Session::singleton();
             $session->set('userID', $csContactID);
             $this->_userID = $csContactID;
         }
     }
     if (CRM_Utils_Array::value('id', $this->_pcpInfo) && CRM_Utils_Array::value('intro_text', $this->_pcpInfo)) {
         $this->assign('intro_text', $this->_pcpInfo['intro_text']);
     } else {
         if (CRM_Utils_Array::value('intro_text', $this->_values)) {
             $this->assign('intro_text', $this->_values['intro_text']);
         }
     }
     if (CRM_Utils_Array::value('footer_text', $this->_values)) {
         $this->assign('footer_text', $this->_values['footer_text']);
     }
     //CRM-5001
     if ($this->_values['is_for_organization']) {
         $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.');
         require_once 'CRM/Core/BAO/UFGroup.php';
         if ($preID = CRM_Utils_Array::value('custom_pre_id', $this->_values)) {
             $preProfile = CRM_Core_BAO_UFGroup::profileGroups($preID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $preProfile) && (in_array('Membership', $preProfile) || in_array('Contribution', $preProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
         if ($postID = CRM_Utils_Array::value('custom_post_id', $this->_values)) {
             $postProfile = CRM_Core_BAO_UFGroup::profileGroups($postID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $postProfile) && (in_array('Membership', $postProfile) || in_array('Contribution', $postProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
     }
 }