当前位置: 首页>>代码示例>>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;未经允许,请勿转载。