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


PHP CRM_Core_DAO_AllCoreTables::isCoreTable方法代码示例

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


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

示例1: create

 /**
  * Takes an associative array and creates a custom group object.
  *
  * This function is invoked from within the web form layer and also from the api layer
  *
  * @param array $params
  *   (reference) an assoc array of name/value pairs.
  *
  * @return CRM_Core_DAO_CustomGroup
  */
 public static function create(&$params)
 {
     // create custom group dao, populate fields and then save.
     $group = new CRM_Core_DAO_CustomGroup();
     if (isset($params['title'])) {
         $group->title = $params['title'];
     }
     if (in_array($params['extends'][0], array('ParticipantRole', 'ParticipantEventName', 'ParticipantEventType'))) {
         $group->extends = 'Participant';
     } else {
         $group->extends = $params['extends'][0];
     }
     $group->extends_entity_column_id = 'null';
     if ($params['extends'][0] == 'ParticipantRole' || $params['extends'][0] == 'ParticipantEventName' || $params['extends'][0] == 'ParticipantEventType') {
         $group->extends_entity_column_id = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $params['extends'][0], 'value', 'name');
     }
     //this is format when form get submit.
     $extendsChildType = CRM_Utils_Array::value(1, $params['extends']);
     //lets allow user to pass direct child type value, CRM-6893
     if (!empty($params['extends_entity_column_value'])) {
         $extendsChildType = $params['extends_entity_column_value'];
     }
     if (!CRM_Utils_System::isNull($extendsChildType)) {
         $extendsChildType = implode(CRM_Core_DAO::VALUE_SEPARATOR, $extendsChildType);
         if (CRM_Utils_Array::value(0, $params['extends']) == 'Relationship') {
             $extendsChildType = str_replace(array('_a_b', '_b_a'), array('', ''), $extendsChildType);
         }
         if (substr($extendsChildType, 0, 1) != CRM_Core_DAO::VALUE_SEPARATOR) {
             $extendsChildType = CRM_Core_DAO::VALUE_SEPARATOR . $extendsChildType . CRM_Core_DAO::VALUE_SEPARATOR;
         }
     } else {
         $extendsChildType = 'null';
     }
     $group->extends_entity_column_value = $extendsChildType;
     if (isset($params['id'])) {
         $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $params['id'], 'weight', 'id');
     } else {
         $oldWeight = 0;
     }
     $group->weight = CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_CustomGroup', $oldWeight, CRM_Utils_Array::value('weight', $params, FALSE));
     $fields = array('style', 'collapse_display', 'collapse_adv_display', 'help_pre', 'help_post', 'is_active', 'is_multiple');
     foreach ($fields as $field) {
         if (isset($params[$field]) || $field == 'is_multiple') {
             $group->{$field} = CRM_Utils_Array::value($field, $params, FALSE);
         }
     }
     $group->max_multiple = isset($params['is_multiple']) ? isset($params['max_multiple']) && $params['max_multiple'] >= '0' ? $params['max_multiple'] : 'null' : 'null';
     $tableName = $oldTableName = NULL;
     if (isset($params['id'])) {
         $group->id = $params['id'];
         //check whether custom group was changed from single-valued to multiple-valued
         $isMultiple = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $params['id'], 'is_multiple');
         if ((!empty($params['is_multiple']) || $isMultiple) && $params['is_multiple'] != $isMultiple) {
             $oldTableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $params['id'], 'table_name');
         }
     } else {
         $group->created_id = CRM_Utils_Array::value('created_id', $params);
         $group->created_date = CRM_Utils_Array::value('created_date', $params);
         // we do this only once, so name never changes
         if (isset($params['name'])) {
             $group->name = CRM_Utils_String::munge($params['name'], '_', 64);
         } else {
             $group->name = CRM_Utils_String::munge($group->title, '_', 64);
         }
         if (isset($params['table_name'])) {
             $tableName = $params['table_name'];
             if (CRM_Core_DAO_AllCoreTables::isCoreTable($tableName)) {
                 // Bad idea.  Prevent group creation because it might lead to a broken configuration.
                 CRM_Core_Error::fatal(ts("Cannot create custom table because %1 is already a core table.", array('1' => $tableName)));
             }
         }
     }
     if (array_key_exists('is_reserved', $params)) {
         $group->is_reserved = $params['is_reserved'] ? 1 : 0;
     }
     $op = isset($params['id']) ? 'edit' : 'create';
     CRM_Utils_Hook::pre($op, 'CustomGroup', CRM_Utils_Array::value('id', $params), $params);
     // enclose the below in a transaction
     $transaction = new CRM_Core_Transaction();
     $group->save();
     if (!isset($params['id'])) {
         if (!isset($params['table_name'])) {
             $munged_title = strtolower(CRM_Utils_String::munge($group->title, '_', 42));
             $tableName = "civicrm_value_{$munged_title}_{$group->id}";
         }
         $group->table_name = $tableName;
         CRM_Core_DAO::setFieldValue('CRM_Core_DAO_CustomGroup', $group->id, 'table_name', $tableName);
         // now create the table associated with this group
         self::createTable($group);
     } elseif ($oldTableName) {
//.........这里部分代码省略.........
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:101,代码来源:CustomGroup.php


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