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


PHP CRM_Core_BAO_CustomField::createField方法代码示例

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


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

示例1: createField

 function createField($params, $fields = null)
 {
     if (empty($params)) {
         $params = array('custom_group_id' => $fields['groupId'], 'label' => 'test_' . $fields['dataType'], 'html_type' => $fields['htmlType'], 'data_type' => $fields['dataType'], 'weight' => 4, 'is_required' => 1, 'is_searchable' => 0, 'is_active' => 1);
     }
     $customFieldBAO =& new CRM_Core_BAO_CustomField();
     $customFieldBAO->copyValues($params);
     $customField = $customFieldBAO->save();
     $customFieldBAO->column_name = 'test_' . $params['data_type'] . '_' . $customField->id;
     $customFieldObject = $customFieldBAO;
     $customField = $customFieldBAO->save();
     require_once 'CRM/Core/BAO/CustomField.php';
     $createField = CRM_Core_BAO_CustomField::createField($customFieldObject, 'add');
     return $customField;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:15,代码来源:Custom.php

示例2: customFields

 /**
  * @param $xml
  * @param $idMap
  */
 public function customFields(&$xml, &$idMap)
 {
     // Re-index by group id so we can build out the custom fields one table
     // at a time, and then rebuild the table triggers at the end, rather than
     // rebuilding the table triggers after each field is added (which is
     // painfully slow).
     $fields_indexed_by_group_id = array();
     foreach ($xml->CustomFields as $customFieldsXML) {
         $total = count($customFieldsXML->CustomField);
         foreach ($customFieldsXML->CustomField as $customFieldXML) {
             $id = $idMap['custom_group'][(string) $customFieldXML->custom_group_name];
             $fields_indexed_by_group_id[$id][] = $customFieldXML;
         }
     }
     while (list($group_id, $fields) = each($fields_indexed_by_group_id)) {
         $total = count($fields);
         $count = 0;
         while (list(, $customFieldXML) = each($fields)) {
             $count++;
             $customField = new CRM_Core_DAO_CustomField();
             $customField->custom_group_id = $group_id;
             $skipStore = FALSE;
             if (!$this->copyData($customField, $customFieldXML, FALSE, 'label')) {
                 $skipStore = TRUE;
             }
             if (empty($customField->option_group_id) && isset($customFieldXML->option_group_name)) {
                 $customField->option_group_id = $idMap['option_group'][(string) $customFieldXML->option_group_name];
             }
             if ($skipStore) {
                 continue;
             }
             $customField->save();
             // Only rebuild the table's trigger on the last field added to avoid un-necessary
             // and slow rebuilds when adding many fields at the same time.
             $triggerRebuild = FALSE;
             if ($count == $total) {
                 $triggerRebuild = TRUE;
             }
             $indexExist = FALSE;
             CRM_Core_BAO_CustomField::createField($customField, 'add', $indexExist, $triggerRebuild);
         }
     }
 }
开发者ID:kidaa30,项目名称:yes,代码行数:47,代码来源:Import.php

示例3: customFields

 function customFields(&$xml, &$idMap)
 {
     require_once 'CRM/Core/BAO/CustomField.php';
     foreach ($xml->CustomFields as $customFieldsXML) {
         foreach ($customFieldsXML->CustomField as $customFieldXML) {
             $customField = new CRM_Core_DAO_CustomField();
             $customField->custom_group_id = $idMap['custom_group'][(string) $customFieldXML->custom_group_name];
             $skipStore = false;
             if (!$this->copyData($customField, $customFieldXML, false, 'label')) {
                 $skipStore = true;
             }
             if (empty($customField->option_group_id) && isset($customFieldXML->option_group_name)) {
                 $customField->option_group_id = $idMap['option_group'][(string) $customFieldXML->option_group_name];
             }
             if ($skipStore) {
                 continue;
             }
             $customField->save();
             CRM_Core_BAO_CustomField::createField($customField, 'add');
         }
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:22,代码来源:import.php

示例4: testActivityGetGoodIDCustom

 /**
  *  Test civicrm_activity_get() with a good activity ID which
  *  has associated custom data
  */
 function testActivityGetGoodIDCustom()
 {
     //  Insert rows in civicrm_activity creating activities 4 and
     //  13
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, new PHPUnit_Extensions_Database_DataSet_XMLDataSet(dirname(__FILE__) . '/dataset/activity_4_13.xml'));
     //  Insert rows in civicrm_custom_group and civicrm_custom_field
     //  creating Activity Custom to extend activity type 5
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn, new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet(dirname(__FILE__) . '/dataset/custom_group_activity_type_5.xml'));
     //  Drop and create table civicrm_value_activity_custom_9
     $query = 'DROP TABLE IF EXISTS civicrm_value_activity_custom_9';
     AllTests::$utils->do_query($query);
     $group = new CRM_Core_DAO_CustomGroup();
     $group->extends = "Activity";
     $group->table_name = 'civicrm_value_activity_custom_9';
     $group->is_multiple = 0;
     $group->is_active = 1;
     CRM_Core_BAO_CustomGroup::createTable($group);
     //  Add column activity_custom_11 to the custom table
     $customField =& new CRM_Core_DAO_CustomField();
     $customField->column_name = 'activity_custom_11';
     $customField->custom_group_id = 9;
     $customField->is_required = 0;
     $customField->is_active = 1;
     $customField->data_type = 'String';
     $customField->text_length = 255;
     CRM_Core_BAO_CustomField::createField($customField, 'add');
     //  Insert a test value into the new table
     $query = "INSERT INTO civicrm_value_activity_custom_9" . "( entity_id, activity_custom_11 )" . " VALUES ( 4,  'bite my test data' )";
     AllTests::$utils->do_query($query);
     //  Retrieve the test value
     $params = array('activity_id' => 4, 'activity_type_id' => 5);
     $result = civicrm_activity_get($params, true);
     $this->assertEquals(0, $result['is_error'], "Error message: " . $result['error_message']);
     $this->assertEquals(4, $result['result']['id'], 'In line ' . __LINE__);
     $this->assertEquals(17, $result['result']['source_contact_id'], 'In line ' . __LINE__);
     $this->assertEquals(5, $result['result']['activity_type_id'], 'In line ' . __LINE__);
     $this->assertEquals('test activity type id', $result['result']['subject'], 'In line ' . __LINE__);
     $this->assertEquals('bite my test data', $result['result']['custom_11_1'], 'In line ' . __LINE__);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:45,代码来源:ActivityTest.php

示例5: customFields

 function customFields(&$xml, &$idMap)
 {
     require_once 'CRM/Core/BAO/CustomField.php';
     foreach ($xml->CustomFields as $customFieldsXML) {
         foreach ($customFieldsXML->CustomField as $customFieldXML) {
             $customField = new CRM_Core_DAO_CustomField();
             $this->copyData($customField, $customFieldXML, false);
             $customField->custom_group_id = $idMap['custom_group'][(string) $customFieldXML->custom_group_title];
             if (isset($customFieldXML->option_group_label)) {
                 $customField->option_group_id = $idMap['option_group'][(string) $customFieldXML->option_group_label];
             }
             $customField->save();
             // fix column name
             $customField->table_name = strtolower(CRM_Utils_String::munge($customField->label, '_', 32)) . "_{$customField->id}";
             $customField->save();
             CRM_Core_BAO_CustomField::createField($customField, 'add');
         }
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:19,代码来源:import.php


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