當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRM_Core_BAO_CustomGroup::_getTableName方法代碼示例

本文整理匯總了PHP中CRM_Core_BAO_CustomGroup::_getTableName方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Core_BAO_CustomGroup::_getTableName方法的具體用法?PHP CRM_Core_BAO_CustomGroup::_getTableName怎麽用?PHP CRM_Core_BAO_CustomGroup::_getTableName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CRM_Core_BAO_CustomGroup的用法示例。


在下文中一共展示了CRM_Core_BAO_CustomGroup::_getTableName方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: updateCustomData

 /**
  * Update custom data.
  *
  *  - custom data is modified as follows
  *    - if custom data is changed it's updated.
  *    - if custom data is newly entered in field, it's inserted into db, finally
  *    - if existing custom data is cleared, it is deleted from the table.
  *
  * @param  array  &$groupTree - array of all custom groups, fields and values.
  * @param  string $entityType - type of entity being extended
  * @param  int    $entityId   - id of the contact whose custom data is to be updated
  * @return void
  *
  * @access public
  * @static
  *
  */
 function updateCustomData(&$groupTree, $entityType, $entityId)
 {
     $tableName = CRM_Core_BAO_CustomGroup::_getTableName($entityType);
     // traverse the group tree
     foreach ($groupTree as $group) {
         $groupId = $group['id'];
         // traverse fields
         foreach ($group['fields'] as $field) {
             $fieldId = $field['id'];
             /**
              * $field['customValue'] is set in the tree in the following cases
              *     - data existed in db for that field
              *     - new data was entered in the "form" for that field
              */
             if (isset($field['customValue'])) {
                 // customValue exists hence we need a DAO.
                 $customValueDAO =& new CRM_Core_DAO_CustomValue();
                 $customValueDAO->entity_table = $tableName;
                 $customValueDAO->custom_field_id = $fieldId;
                 $customValueDAO->entity_id = $entityId;
                 // check if it's an update or new one
                 if (isset($field['customValue']['id'])) {
                     // get the id of row in civicrm_custom_value
                     $customValueDAO->id = $field['customValue']['id'];
                 }
                 $data = $field['customValue']['data'];
                 // since custom data is empty, delete it from db.
                 // note we cannot use a plain if($data) since data could have a value "0"
                 // which will result in a !false expression
                 // and accidental deletion of data.
                 // especially true in the case of radio buttons where we are using the values
                 // 1 - true and 0 for false.
                 if (!strlen(trim($data))) {
                     $customValueDAO->delete();
                     continue;
                 }
                 // data is not empty
                 switch ($field['data_type']) {
                     case 'String':
                         $customValueDAO->char_data = $data;
                         break;
                     case 'Int':
                     case 'Boolean':
                     case 'StateProvince':
                     case 'Country':
                         $customValueDAO->int_data = $data;
                         break;
                     case 'Float':
                         $customValueDAO->float_data = $data;
                         break;
                     case 'Money':
                         $customValueDAO->decimal_data = number_format($data, 2, '.', '');
                         break;
                     case 'Memo':
                         $customValueDAO->memo_data = $data;
                         break;
                     case 'Date':
                         $customValueDAO->date_data = $data;
                         break;
                 }
                 // insert/update of custom value
                 $customValueDAO->save();
             }
         }
     }
 }
開發者ID:bhirsch,項目名稱:voipdrupal-4.7-1.0,代碼行數:83,代碼來源:CustomGroup.php


注:本文中的CRM_Core_BAO_CustomGroup::_getTableName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。