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


PHP CRM_Contact_DAO_Contact::free方法代码示例

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


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

示例1: processNormalization

 static function processNormalization($fromContactId, $toContactId)
 {
     $processInfo = array('name' => 0, 'phone' => 0, 'address' => 0);
     if (empty($fromContactId) || empty($toContactId)) {
         return $processInfo;
     }
     $contactIds = range($fromContactId, $toContactId);
     $normalization = CRM_Utils_Normalize::singleton();
     $formattedContactIds = $formattedPhoneIds = $formattedAddressIds = array();
     foreach ($contactIds as $contactId) {
         $contact = new CRM_Contact_DAO_Contact();
         $contact->id = $contactId;
         if ($contact->find()) {
             $params = array('id' => $contactId, 'contact_id' => $contactId);
             $orgContactValues = array();
             CRM_Contact_BAO_Contact::retrieve($params, $orgContactValues);
             //update contacts name fields.
             $formatNameValues = array();
             foreach ($normalization->getNameFields() as $field) {
                 $nameValue = CRM_Utils_Array::value($field, $orgContactValues);
                 if (empty($nameValue)) {
                     continue;
                 }
                 $formatNameValues[$field] = $nameValue;
             }
             if (!empty($formatNameValues)) {
                 $formatNameValues['contact_type'] = $orgContactValues['contact_type'];
                 $formattedNameValues = $formatNameValues;
                 //format name values
                 $normalization->normalize_contact($formattedNameValues);
                 //check formatted diff, only update if there is difference.
                 $formatDiff = array_diff($formatNameValues, $formattedNameValues);
                 if (!empty($formatDiff)) {
                     $formattedNameValues['id'] = $formattedNameValues['contact_id'] = $orgContactValues['id'];
                     $formattedNameValues['contact_type'] = $orgContactValues['contact_type'];
                     $contactUpdated = CRM_Contact_BAO_Contact::add($formattedNameValues);
                     if ($contactUpdated->id) {
                         $formattedContactIds[$contactUpdated->id] = $contactUpdated->id;
                     }
                     $contactUpdated->free();
                 }
             }
             //update phone fields.
             if (isset($orgContactValues['phone']) && is_array($orgContactValues['phone'])) {
                 foreach ($orgContactValues['phone'] as $cnt => $orgPhoneValues) {
                     if (!isset($orgPhoneValues['id']) || empty($orgPhoneValues['id']) || empty($orgPhoneValues['phone'])) {
                         continue;
                     }
                     $formattedPhoneValues = $orgPhoneValues;
                     //format phone fields
                     $normalization->normalize_phone($formattedPhoneValues);
                     //do check for formatted difference, than only update.
                     $formattedDiff = array_diff_assoc($orgPhoneValues, $formattedPhoneValues);
                     if (!empty($formattedDiff)) {
                         $phoneUpdated = CRM_Core_BAO_Phone::add($formattedPhoneValues);
                         if ($phoneUpdated->id) {
                             $formattedPhoneIds[$phoneUpdated->id] = $phoneUpdated->id;
                         }
                         $phoneUpdated->free();
                     }
                 }
             }
             //update address.
             if (isset($orgContactValues['address']) && is_array($orgContactValues['address'])) {
                 foreach ($orgContactValues['address'] as $cnt => $orgAddressValues) {
                     if (!isset($orgAddressValues['id']) || empty($orgAddressValues['id'])) {
                         continue;
                     }
                     $formattedAddressValues = $orgAddressValues;
                     //format addrees fields
                     $normalization->normalize_address($formattedAddressValues);
                     //do check for formatted difference, than only update.
                     $formattedDiff = array_diff($orgAddressValues, $formattedAddressValues);
                     if (!empty($formattedDiff)) {
                         $addressUpdated = CRM_Core_BAO_Address::add($formattedAddressValues, FALSE);
                         if ($addressUpdated->id) {
                             $formattedAddressIds[$addressUpdated->id] = $addressUpdated->id;
                         }
                         $addressUpdated->free();
                     }
                 }
             }
         }
         $contact->free();
     }
     $processInfo = array('name' => $formattedContactIds, 'phone' => $formattedPhoneIds, 'address' => $formattedAddressIds);
     return $processInfo;
 }
开发者ID:progressivetech,项目名称:com.cividesk.normalize,代码行数:88,代码来源:Normalize.php


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