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


PHP CRM_Core_BAO_Address::orderBy方法代码示例

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


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


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