当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Core_BAO_UFGroup::profileGroups方法代码示例

本文整理汇总了PHP中CRM_Core_BAO_UFGroup::profileGroups方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFGroup::profileGroups方法的具体用法?PHP CRM_Core_BAO_UFGroup::profileGroups怎么用?PHP CRM_Core_BAO_UFGroup::profileGroups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_BAO_UFGroup的用法示例。


在下文中一共展示了CRM_Core_BAO_UFGroup::profileGroups方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: formRule

 /**
  * 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) {
//.........这里部分代码省略.........
开发者ID:vakeesan26,项目名称:civicrm-core,代码行数:101,代码来源:Registration.php

示例2: buildComponentForm

 /**
  * 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);
//.........这里部分代码省略.........
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:101,代码来源:ContributionBase.php

示例3: preProcess

 /**
  * 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);
                 }
             }
         }
     }
 }
开发者ID:vakeesan26,项目名称:civicrm-core,代码行数:77,代码来源:Main.php

示例4: getValidContactTypeList

 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;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:26,代码来源:Relationship.php

示例5: formRule

 /**
  * 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;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:90,代码来源:Registration.php

示例6: sendMail

 /**
  * 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);
//.........这里部分代码省略.........
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:101,代码来源:ContributionPage.php

示例7: preProcess

 /**
  * 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);
                 }
             }
         }
     }
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:82,代码来源:Main.php

示例8: sendMail

 /**
  * 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
//.........这里部分代码省略.........
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:ContributionPage.php

示例9: preProcess

 /**
  * 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);
     }
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:98,代码来源:Main.php

示例10: preProcess

 /** 
  * 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);
                 }
             }
         }
     }
 }
开发者ID:rajeshrhino,项目名称:Civicrm-Direct-Debit-Integration,代码行数:71,代码来源:Main.php

示例11: preProcess

 /** 
  * 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);
                 }
             }
         }
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:52,代码来源:Main.php


注:本文中的CRM_Core_BAO_UFGroup::profileGroups方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。