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


PHP CRM_Core_BAO_CustomField::formatCustomField方法代码示例

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


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

示例1: doMembershipProcessing

 /**
  * Membership processing section.
  *
  * This is in a separate function as part of a move towards refactoring.
  *
  * @param int $contactID
  * @param array $membershipParams
  * @param array $premiumParams
  * @param bool $isPayLater
  */
 protected function doMembershipProcessing($contactID, $membershipParams, $premiumParams, $isPayLater)
 {
     // This could be set by a hook.
     if (!empty($this->_params['installments'])) {
         $membershipParams['installments'] = $this->_params['installments'];
     }
     // added new parameter for cms user contact id, needed to distinguish behaviour for on behalf of sign-ups
     if (isset($this->_params['related_contact'])) {
         $membershipParams['cms_contactID'] = $this->_params['related_contact'];
     } else {
         $membershipParams['cms_contactID'] = $contactID;
     }
     if (!empty($membershipParams['onbehalf']) && is_array($membershipParams['onbehalf']) && !empty($membershipParams['onbehalf']['member_campaign_id'])) {
         $this->_params['campaign_id'] = $membershipParams['onbehalf']['member_campaign_id'];
     }
     $customFieldsFormatted = $fieldTypes = array();
     if (!empty($membershipParams['onbehalf']) && is_array($membershipParams['onbehalf'])) {
         foreach ($membershipParams['onbehalf'] as $key => $value) {
             if (strstr($key, 'custom_')) {
                 $customFieldId = explode('_', $key);
                 CRM_Core_BAO_CustomField::formatCustomField($customFieldId[1], $customFieldsFormatted, $value, 'Membership', NULL, $contactID);
             }
         }
         $fieldTypes = array('Contact', 'Organization', 'Membership');
     }
     $priceFieldIds = $this->get('memberPriceFieldIDS');
     if (!empty($priceFieldIds)) {
         $contributionTypeID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceFieldIds['id'], 'financial_type_id');
         unset($priceFieldIds['id']);
         $membershipTypeIds = array();
         $membershipTypeTerms = array();
         foreach ($priceFieldIds as $priceFieldId) {
             if ($id = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldId, 'membership_type_id')) {
                 $membershipTypeIds[] = $id;
                 //@todo the value for $term is immediately overwritten. It is unclear from the code whether it was intentional to
                 // do this or a double = was intended (this ambiguity is the reason many IDEs complain about 'assignment in condition'
                 $term = 1;
                 if ($term = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldId, 'membership_num_terms')) {
                     $membershipTypeTerms[$id] = $term > 1 ? $term : 1;
                 } else {
                     $membershipTypeTerms[$id] = 1;
                 }
             }
         }
         $membershipParams['selectMembership'] = $membershipTypeIds;
         $membershipParams['financial_type_id'] = $contributionTypeID;
         $membershipParams['types_terms'] = $membershipTypeTerms;
     }
     if (!empty($membershipParams['selectMembership'])) {
         // CRM-12233
         $membershipLineItems = array();
         if ($this->_separateMembershipPayment && $this->_values['amount_block_is_active']) {
             foreach ($this->_values['fee'] as $key => $feeValues) {
                 if ($feeValues['name'] == 'membership_amount') {
                     $fieldId = $this->_params['price_' . $key];
                     $membershipLineItems[$this->_priceSetId][$fieldId] = $this->_lineItem[$this->_priceSetId][$fieldId];
                     unset($this->_lineItem[$this->_priceSetId][$fieldId]);
                     break;
                 }
             }
         }
         try {
             $this->processMembership($membershipParams, $contactID, $customFieldsFormatted, $fieldTypes, $premiumParams, $membershipLineItems, $isPayLater);
         } catch (CRM_Core_Exception $e) {
             CRM_Core_Session::singleton()->setStatus($e->getMessage());
             CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Main_display=true&qfKey={$this->_params['qfKey']}"));
         }
         if (!$this->_amount > 0.0 || !$membershipParams['amount']) {
             // we need to explicitly create a CMS user in case of free memberships
             // since it is done under processConfirm for paid memberships
             CRM_Contribute_BAO_Contribution_Utils::createCMSUser($membershipParams, $membershipParams['cms_contactID'], 'email-' . $this->_bltID);
         }
     }
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:84,代码来源:Confirm.php

示例2: postProcess

 function postProcess(&$params, &$customFields, $entityID, $customFieldExtends, $inline = false)
 {
     $customData = array();
     foreach ($params as $key => $value) {
         if ($customFieldInfo = CRM_Core_BAO_CustomField::getKeyID($key, true)) {
             // for autocomplete transfer hidden value instead of label
             if ($params[$key] && isset($params[$key . '_id'])) {
                 $value = $params[$key . '_id'];
             }
             // we need to append time with date
             if ($params[$key] && isset($params[$key . '_time'])) {
                 $value .= ' ' . $params[$key . '_time'];
             }
             CRM_Core_BAO_CustomField::formatCustomField($customFieldInfo[0], $customData, $value, $customFieldExtends, $customFieldInfo[1], $entityID, $inline);
         }
     }
     return $customData;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:18,代码来源:CustomField.php

示例3: postProcess


//.........这里部分代码省略.........
     $session = CRM_Core_Session::singleton();
     if (!$session->get('userID')) {
         $session->set('transaction.userID', $contactID);
     } else {
         $session->set('transaction.userID', NULL);
     }
     $this->_useForMember = $this->get('useForMember');
     // store the fact that this is a membership and membership type is selected
     $processMembership = FALSE;
     if (!empty($membershipParams['selectMembership']) && $membershipParams['selectMembership'] != 'no_thanks' || $this->_useForMember) {
         $processMembership = TRUE;
         if (!$this->_useForMember) {
             $this->assign('membership_assign', TRUE);
             $this->set('membershipTypeID', $this->_params['selectMembership']);
         }
         if ($this->_action & CRM_Core_Action::PREVIEW) {
             $membershipParams['is_test'] = 1;
         }
         if ($this->_params['is_pay_later']) {
             $membershipParams['is_pay_later'] = 1;
         }
     }
     if ($processMembership) {
         CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $membershipParams, TRUE);
         // added new parameter for cms user contact id, needed to distinguish behaviour for on behalf of sign-ups
         if (isset($this->_params['related_contact'])) {
             $membershipParams['cms_contactID'] = $this->_params['related_contact'];
         } else {
             $membershipParams['cms_contactID'] = $contactID;
         }
         //inherit campaign from contirb page.
         if (!array_key_exists('campaign_id', $membershipParams)) {
             $membershipParams['campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values);
         }
         if (!empty($membershipParams['onbehalf']) && is_array($membershipParams['onbehalf']) && !empty($membershipParams['onbehalf']['member_campaign_id'])) {
             $this->_params['campaign_id'] = $membershipParams['onbehalf']['member_campaign_id'];
         }
         $customFieldsFormatted = $fieldTypes = array();
         if (!empty($membershipParams['onbehalf']) && is_array($membershipParams['onbehalf'])) {
             foreach ($membershipParams['onbehalf'] as $key => $value) {
                 if (strstr($key, 'custom_')) {
                     $customFieldId = explode('_', $key);
                     CRM_Core_BAO_CustomField::formatCustomField($customFieldId[1], $customFieldsFormatted, $value, 'Membership', NULL, $contactID);
                 }
             }
             $fieldTypes = array('Contact', 'Organization', 'Membership');
         }
         $priceFieldIds = $this->get('memberPriceFieldIDS');
         if (!empty($priceFieldIds)) {
             $contributionTypeID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceFieldIds['id'], 'financial_type_id');
             unset($priceFieldIds['id']);
             $membershipTypeIds = array();
             $membershipTypeTerms = array();
             foreach ($priceFieldIds as $priceFieldId) {
                 if ($id = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldId, 'membership_type_id')) {
                     $membershipTypeIds[] = $id;
                     $term = 1;
                     if ($term = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldId, 'membership_num_terms')) {
                         $membershipTypeTerms[$id] = $term > 1 ? $term : 1;
                     } else {
                         $membershipTypeTerms[$id] = 1;
                     }
                 }
             }
             $membershipParams['selectMembership'] = $membershipTypeIds;
             $membershipParams['financial_type_id'] = $contributionTypeID;
             $membershipParams['types_terms'] = $membershipTypeTerms;
         }
         if (!empty($membershipParams['selectMembership'])) {
             // CRM-12233
             if ($this->_separateMembershipPayment && $this->_values['amount_block_is_active']) {
                 foreach ($this->_values['fee'] as $key => $feeValues) {
                     if ($feeValues['name'] == 'membership_amount') {
                         $fieldId = $this->_params['price_' . $key];
                         $this->_memLineItem[$this->_priceSetId][$fieldId] = $this->_lineItem[$this->_priceSetId][$fieldId];
                         unset($this->_lineItem[$this->_priceSetId][$fieldId]);
                         break;
                     }
                 }
             }
             CRM_Member_BAO_Membership::postProcessMembership($membershipParams, $contactID, $this, $premiumParams, $customFieldsFormatted, $fieldTypes);
         }
     } else {
         // at this point we've created a contact and stored its address etc
         // all the payment processors expect the name and address to be in the
         // so we copy stuff over to first_name etc.
         $paymentParams = $this->_params;
         $contributionTypeId = $this->_values['financial_type_id'];
         $fieldTypes = array();
         if (!empty($paymentParams['onbehalf']) && is_array($paymentParams['onbehalf'])) {
             foreach ($paymentParams['onbehalf'] as $key => $value) {
                 if (strstr($key, 'custom_')) {
                     $this->_params[$key] = $value;
                 }
             }
             $fieldTypes = array('Contact', 'Organization', 'Contribution');
         }
         CRM_Contribute_BAO_Contribution_Utils::processConfirm($this, $paymentParams, $premiumParams, $contactID, $contributionTypeId, 'contribution', $fieldTypes);
     }
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:101,代码来源:Confirm.php

示例4: formatProfileContactParams


//.........这里部分代码省略.........
                     $data['address'][$loc][substr($fieldName, 8)] = $value;
                 } else {
                     $data['address'][$loc][$fieldName] = $value;
                 }
             }
         } else {
             if (substr($key, 0, 4) === 'url-') {
                 $websiteField = explode('-', $key);
                 $data['website'][$websiteField[1]]['website_type_id'] = $websiteField[1];
                 $data['website'][$websiteField[1]]['url'] = $value;
             } elseif (in_array($key, self::$_greetingTypes, TRUE)) {
                 //save email/postal greeting and addressee values if any, CRM-4575
                 $data[$key . '_id'] = $value;
             } elseif (!$skipCustom && ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($key))) {
                 // for autocomplete transfer hidden value instead of label
                 if ($params[$key] && isset($params[$key . '_id'])) {
                     $value = $params[$key . '_id'];
                 }
                 // we need to append time with date
                 if ($params[$key] && isset($params[$key . '_time'])) {
                     $value .= ' ' . $params[$key . '_time'];
                 }
                 // if auth source is not checksum / login && $value is blank, do not proceed - CRM-10128
                 if (($session->get('authSrc') & CRM_Core_Permission::AUTH_SRC_CHECKSUM + CRM_Core_Permission::AUTH_SRC_LOGIN) == 0 && ($value == '' || !isset($value))) {
                     continue;
                 }
                 $valueId = NULL;
                 if (!empty($params['customRecordValues'])) {
                     if (is_array($params['customRecordValues']) && !empty($params['customRecordValues'])) {
                         foreach ($params['customRecordValues'] as $recId => $customFields) {
                             if (is_array($customFields) && !empty($customFields)) {
                                 foreach ($customFields as $customFieldName) {
                                     if ($customFieldName == $key) {
                                         $valueId = $recId;
                                         break;
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $type = $data['contact_type'];
                 if (!empty($data['contact_sub_type'])) {
                     $type = $data['contact_sub_type'];
                     $type = explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($type, CRM_Core_DAO::VALUE_SEPARATOR));
                     // generally a contact even if, has multiple subtypes the parent-type is going to be one only
                     // and since formatCustomField() would be interested in parent type, lets consider only one subtype
                     // as the results going to be same.
                     $type = $type[0];
                 }
                 CRM_Core_BAO_CustomField::formatCustomField($customFieldId, $data['custom'], $value, $type, $valueId, $contactID);
             } elseif ($key == 'edit') {
                 continue;
             } else {
                 if ($key == 'location') {
                     foreach ($value as $locationTypeId => $field) {
                         foreach ($field as $block => $val) {
                             if ($block == 'address' && array_key_exists('address_name', $val)) {
                                 $value[$locationTypeId][$block]['name'] = $value[$locationTypeId][$block]['address_name'];
                             }
                         }
                     }
                 }
                 if ($key == 'phone' && isset($params['phone_ext'])) {
                     $data[$key] = $value;
                     foreach ($value as $cnt => $phoneBlock) {
                         if ($params[$key][$cnt]['location_type_id'] == $params['phone_ext'][$cnt]['location_type_id']) {
                             $data[$key][$cnt]['phone_ext'] = CRM_Utils_Array::retrieveValueRecursive($params['phone_ext'][$cnt], 'phone_ext');
                         }
                     }
                 } elseif (in_array($key, array('nick_name', 'job_title', 'middle_name', 'birth_date', 'gender_id', 'current_employer', 'prefix_id', 'suffix_id')) && ($value == '' || !isset($value)) && ($session->get('authSrc') & CRM_Core_Permission::AUTH_SRC_CHECKSUM + CRM_Core_Permission::AUTH_SRC_LOGIN) == 0) {
                     // CRM-10128: if auth source is not checksum / login && $value is blank, do not fill $data with empty value
                     // to avoid update with empty values
                     continue;
                 } else {
                     $data[$key] = $value;
                 }
             }
         }
     }
     if (!isset($data['contact_type'])) {
         $data['contact_type'] = 'Individual';
     }
     //set the values for checkboxes (do_not_email, do_not_mail, do_not_trade, do_not_phone)
     $privacy = CRM_Core_SelectValues::privacy();
     foreach ($privacy as $key => $value) {
         if (array_key_exists($key, $fields)) {
             // do not reset values for existing contacts, if fields are added to a profile
             if (array_key_exists($key, $params)) {
                 $data[$key] = $params[$key];
                 if (empty($params[$key])) {
                     $data[$key] = 0;
                 }
             } elseif (!$contactID) {
                 $data[$key] = 0;
             }
         }
     }
     return array($data, $contactDetails);
 }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:101,代码来源:Contact.php

示例5: _civicrm_api3_custom_format_params

/**
 * Format custom parameters.
 *
 * @param array $params
 * @param array $values
 * @param string $extends
 *   Entity that this custom field extends (e.g. contribution, event, contact).
 * @param string $entityId
 *   ID of entity per $extends.
 */
function _civicrm_api3_custom_format_params($params, &$values, $extends, $entityId = NULL)
{
    $values['custom'] = array();
    $checkCheckBoxField = FALSE;
    $entity = $extends;
    if (in_array($extends, array('Household', 'Individual', 'Organization'))) {
        $entity = 'Contact';
    }
    $fields = civicrm_api($entity, 'getfields', array('version' => 3, 'action' => 'create'));
    if (!$fields['is_error']) {
        // not sure if fields could be error - maybe change to using civicrm_api3 wrapper later - this is conservative
        $fields = $fields['values'];
        $checkCheckBoxField = TRUE;
    }
    foreach ($params as $key => $value) {
        list($customFieldID, $customValueID) = CRM_Core_BAO_CustomField::getKeyID($key, TRUE);
        if ($customFieldID && !is_null($value)) {
            if ($checkCheckBoxField && !empty($fields['custom_' . $customFieldID]) && $fields['custom_' . $customFieldID]['html_type'] == 'CheckBox') {
                formatCheckBoxField($value, 'custom_' . $customFieldID, $entity);
            }
            CRM_Core_BAO_CustomField::formatCustomField($customFieldID, $values['custom'], $value, $extends, $customValueID, $entityId, FALSE, FALSE, TRUE);
        }
    }
}
开发者ID:sugan2111,项目名称:Drupal_code,代码行数:34,代码来源:utils.php

示例6: _civicrm_api3_custom_format_params

/**
 *
 * @param array $params
 * @param array $values
 * @param string $extends entity that this custom field extends (e.g. contribution, event, contact)
 * @param string $entityId ID of entity per $extends
 */
function _civicrm_api3_custom_format_params($params, &$values, $extends, $entityId = NULL)
{
    $values['custom'] = array();
    require_once 'CRM/Core/BAO/CustomField.php';
    foreach ($params as $key => $value) {
        list($customFieldID, $customValueID) = CRM_Core_BAO_CustomField::getKeyID($key, TRUE);
        if ($customFieldID) {
            CRM_Core_BAO_CustomField::formatCustomField($customFieldID, $values['custom'], $value, $extends, $customValueID, $entityId, FALSE, FALSE);
        }
    }
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:18,代码来源:utils.php

示例7: _civicrm_custom_format_params

/**
 *
 * @param <type> $params
 * @param <type> $values
 * @param <type> $extends
 * @param <type> $entityId 
 */
function _civicrm_custom_format_params(&$params, &$values, $extends, $entityId = null)
{
    $values['custom'] = array();
    require_once 'CRM/Core/BAO/CustomField.php';
    $customFields = CRM_Core_BAO_CustomField::getFields($extends);
    require_once 'CRM/Core/BAO/CustomField.php';
    foreach ($params as $key => $value) {
        if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
            CRM_Core_BAO_CustomField::formatCustomField($customFieldID, $values['custom'], $value, $extends, null, $entityId);
        }
    }
}
开发者ID:ksecor,项目名称:civicrm,代码行数:19,代码来源:utils.php

示例8: createProfileContact


//.........这里部分代码省略.........
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         } else {
             if ($key === 'individual_suffix') {
                 $data['suffix_id'] = $value;
             } else {
                 if ($key === 'individual_prefix') {
                     $data['prefix_id'] = $value;
                 } else {
                     if ($key === 'gender') {
                         $data['gender_id'] = $value;
                     } else {
                         if ($key === 'email_greeting') {
                             //save email/postal greeting and addressee values if any, CRM-4575
                             $data['email_greeting_id'] = $value;
                         } else {
                             if ($key === 'postal_greeting') {
                                 $data['postal_greeting_id'] = $value;
                             } else {
                                 if ($key === 'addressee') {
                                     $data['addressee_id'] = $value;
                                 } else {
                                     if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($key)) {
                                         // for autocomplete transfer hidden value instead of label
                                         if (isset($params[$key . '_id'])) {
                                             $value = $params[$key . '_id'];
                                         }
                                         $type = CRM_Utils_Array::value('contact_sub_type', $data) ? $data['contact_sub_type'] : $data['contact_type'];
                                         CRM_Core_BAO_CustomField::formatCustomField($customFieldId, $data['custom'], $value, $type, null, $contactID);
                                     } else {
                                         if ($key == 'edit') {
                                             continue;
                                         } else {
                                             if ($key == 'location') {
                                                 foreach ($value as $locationTypeId => $field) {
                                                     foreach ($field as $block => $val) {
                                                         if ($block == 'address' && array_key_exists('address_name', $val)) {
                                                             $value[$locationTypeId][$block]['name'] = $value[$locationTypeId][$block]['address_name'];
                                                         }
                                                     }
                                                 }
                                             }
                                             $data[$key] = $value;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // FIX ME: need to check if we need this code
     // //make sure primary location is at first position in location array
     // if ( isset( $data['location'] ) && count( $data['location'] ) > 1 ) {
     //     // if first location is primary skip manipulation
     //     if ( !isset($data['location'][1]['is_primary']) ) {
     //         //find the key for primary location
     //         foreach ( $data['location'] as $primaryLocationKey => $value ) {
     //             if ( isset( $value['is_primary'] ) ) {
开发者ID:ksecor,项目名称:civicrm,代码行数:67,代码来源:Contact.php


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