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


PHP CRM_Core_BAO_Address::find方法代码示例

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


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

示例1: array

 /**
  * Given the list of params in the params array, fetch the object
  * and store the values in the values array
  *
  * @param array $entityBlock
  *   Associated array of fields.
  * @param bool $microformat
  *   If microformat output is required.
  * @param int|string $fieldName conditional field name
  *
  * @return array
  *   array with address fields
  */
 public static function &getValues($entityBlock, $microformat = FALSE, $fieldName = 'contact_id')
 {
     if (empty($entityBlock)) {
         return NULL;
     }
     $addresses = array();
     $address = new CRM_Core_BAO_Address();
     if (empty($entityBlock['entity_table'])) {
         $address->{$fieldName} = CRM_Utils_Array::value($fieldName, $entityBlock);
     } else {
         $addressIds = array();
         $addressIds = self::allEntityAddress($entityBlock);
         if (!empty($addressIds[1])) {
             $address->id = $addressIds[1];
         } else {
             return $addresses;
         }
     }
     //get primary address as a first block.
     $address->orderBy('is_primary desc, id');
     $address->find();
     $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
     $count = 1;
     while ($address->fetch()) {
         // deprecate reference.
         if ($count > 1) {
             foreach (array('state', 'state_name', 'country', 'world_region') as $fld) {
                 if (isset($address->{$fld})) {
                     unset($address->{$fld});
                 }
             }
         }
         $stree = $address->street_address;
         $values = array();
         CRM_Core_DAO::storeValues($address, $values);
         // add state and country information: CRM-369
         if (!empty($address->location_type_id)) {
             $values['location_type'] = CRM_Utils_Array::value($address->location_type_id, $locationTypes);
         }
         if (!empty($address->state_province_id)) {
             $address->state = CRM_Core_PseudoConstant::stateProvinceAbbreviation($address->state_province_id, FALSE);
             $address->state_name = CRM_Core_PseudoConstant::stateProvince($address->state_province_id, FALSE);
         }
         if (!empty($address->country_id)) {
             $address->country = CRM_Core_PseudoConstant::country($address->country_id);
             //get world region
             $regionId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Country', $address->country_id, 'region_id');
             $address->world_region = CRM_Core_PseudoConstant::worldregion($regionId);
         }
         $address->addDisplay($microformat);
         $values['display'] = $address->display;
         $values['display_text'] = $address->display_text;
         if (is_numeric($address->master_id)) {
             $values['use_shared_address'] = 1;
         }
         $addresses[$count] = $values;
         //unset is_primary after first block. Due to some bug in earlier version
         //there might be more than one primary blocks, hence unset is_primary other than first
         if ($count > 1) {
             unset($addresses[$count]['is_primary']);
         }
         $count++;
     }
     return $addresses;
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:78,代码来源:Address.php

示例2: processSharedAddress

 /**
  * Function handles shared contact address processing.
  * In this function we just modify submitted values so that new address created for the user
  * has same address as shared contact address. We copy the address so that search etc will be
  * much efficient.
  *
  * @param array $address
  *   This is associated array which contains submitted form values.
  */
 public static function processSharedAddress(&$address)
 {
     if (!is_array($address)) {
         return;
     }
     // Sharing contact address during create mode is pretty straight forward.
     // In update mode we should check following:
     // - We should check if user has uncheck shared contact address
     // - If yes then unset the master_id or may be just delete the address that copied master
     //    Normal update process will automatically create new address with submitted values
     // 1. loop through entire subnitted address array
     $masterAddress = array();
     $skipFields = array('is_primary', 'location_type_id', 'is_billing', 'master_id');
     foreach ($address as &$values) {
         // 2. check if master id exists, if not continue
         if (empty($values['master_id']) || empty($values['use_shared_address'])) {
             // we should unset master id when use uncheck share address for existing address
             $values['master_id'] = 'null';
             continue;
         }
         // 3. get the address details for master_id
         $masterAddress = new CRM_Core_BAO_Address();
         $masterAddress->id = CRM_Utils_Array::value('master_id', $values);
         $masterAddress->find(TRUE);
         // 4. modify submitted params and update it with shared contact address
         // make sure you preserve specific form values like location type, is_primary_ is_billing, master_id
         // CRM-10336: Also empty any fields from the existing address block if they don't exist in master (otherwise they will persist)
         foreach ($values as $field => $submittedValue) {
             if (!in_array($field, $skipFields)) {
                 if (isset($masterAddress->{$field})) {
                     $values[$field] = $masterAddress->{$field};
                 } else {
                     $values[$field] = '';
                 }
             }
         }
         //5. modify the params to include county_id if it exist in master contact.
         // CRM-16152: This is a hack since QF does not submit disabled field.
         if (!empty($masterAddress->county_id) && empty($values['county_id'])) {
             $values['county_id'] = $masterAddress->county_id;
         }
     }
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:52,代码来源:Utils.php

示例3: processSharedAddress

 /**
  * Function handles shared contact address processing
  * In this function we just modify submitted values so that new address created for the user
  * has same address as shared contact address. We copy the address so that search etc will be 
  * much efficient.
  *
  * @param array $address this is associated array which contains submitted form values
  *                       
  * @return void
  * @static
  * @access public
  */
 static function processSharedAddress(&$address)
 {
     if (!is_array($address)) {
         return;
     }
     // Sharing contact address during create mode is pretty straight forward.
     // In update mode we should check following:
     // - We should check if user has uncheck shared contact address
     // - If yes then unset the master_id or may be just delete the address that copied master
     //    Normal update process will automatically create new address with submitted values
     // 1. loop through entire subnitted address array
     $masterAddress = array();
     $skipFields = array('is_primary', 'location_type_id', 'is_billing', 'master_id');
     foreach ($address as &$values) {
         // 2. check if master id exists, if not continue
         if (!CRM_Utils_Array::value('master_id', $values) || !CRM_Utils_Array::value('use_shared_address', $values)) {
             // we should unset master id when use uncheck share address for existing address
             $values['master_id'] = 'null';
             continue;
         }
         // 3. get the address details for master_id
         $masterAddress = new CRM_Core_BAO_Address();
         $masterAddress->id = CRM_Utils_Array::value('master_id', $values);
         $masterAddress->find(true);
         // 4. modify submitted params and update it with shared contact address
         // make sure you preserve specific form values like location type, is_primary_ is_billing, master_id
         foreach ($values as $field => $submittedValue) {
             if (!in_array($field, $skipFields) && isset($masterAddress->{$field})) {
                 $values[$field] = $masterAddress->{$field};
             }
         }
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:45,代码来源:Utils.php


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