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


PHP CRM_Core_BAO_CustomGroup::createTable方法代码示例

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


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

示例1: createGroup

 function createGroup($group, $extends = null, $isMultiple = false)
 {
     if (empty($group)) {
         $group = array('title' => 'Test_Group', 'name' => 'test_group', 'extends' => $extends, 'style' => 'Inline', 'is_multiple' => $isMultiple, 'is_active' => 1);
     }
     require_once 'CRM/Core/BAO/CustomGroup.php';
     require_once 'CRM/Utils/String.php';
     $customGroupBAO =& new CRM_Core_BAO_CustomGroup();
     $customGroupBAO->copyValues($group);
     $customGroup = $customGroupBAO->save();
     $customGroup->table_name = "civicrm_value_" . strtolower(CRM_Utils_String::munge($group['title'], '_', 32));
     $customGroup->table_name = $customGroup->table_name . '_' . $customGroup->id;
     $customGroup = $customGroupBAO->save();
     $customTable = CRM_Core_BAO_CustomGroup::createTable($customGroup);
     return $customGroup;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:16,代码来源:Custom.php

示例2: customGroups

 /**
  * @param $xml
  * @param $idMap
  */
 public function customGroups(&$xml, &$idMap)
 {
     foreach ($xml->CustomGroups as $customGroupsXML) {
         foreach ($customGroupsXML->CustomGroup as $customGroupXML) {
             $customGroup = new CRM_Core_DAO_CustomGroup();
             if (!$this->copyData($customGroup, $customGroupXML, TRUE, 'name')) {
                 $idMap['custom_group'][$customGroup->name] = $customGroup->id;
                 continue;
             }
             $saveAgain = FALSE;
             if (!isset($customGroup->table_name) || empty($customGroup->table_name)) {
                 // fix table name
                 $customGroup->table_name = "civicrm_value_" . strtolower(CRM_Utils_String::munge($customGroup->title, '_', 32)) . "_{$customGroup->id}";
                 $saveAgain = TRUE;
             }
             // fix extends stuff if it exists
             if (isset($customGroupXML->extends_entity_column_value_option_group) && isset($customGroupXML->extends_entity_column_value)) {
                 $valueIDs = array();
                 $optionValues = explode(",", $customGroupXML->extends_entity_column_value);
                 $optValues = implode("','", $optionValues);
                 if (trim($customGroup->extends) != 'Participant') {
                     if ($customGroup->extends == 'Relationship') {
                         foreach ($optionValues as $key => $value) {
                             $relTypeId = CRM_Core_DAO::getFieldValue('CRM_Contact_BAO_RelationshipType', $value, 'id', 'name_a_b');
                             $valueIDs[] = $relTypeId;
                         }
                     } elseif (in_array($customGroup->extends, array('Individual', 'Organization', 'Household'))) {
                         $valueIDs = $optionValues;
                     } else {
                         $sql = "\nSELECT     v.value\nFROM       civicrm_option_value v\nINNER JOIN civicrm_option_group g ON g.id = v.option_group_id\nWHERE      g.name = %1\nAND        v.name IN ('{$optValues}')\n";
                         $params = array(1 => array((string) $customGroupXML->extends_entity_column_value_option_group, 'String'));
                         $dao =& CRM_Core_DAO::executeQuery($sql, $params);
                         while ($dao->fetch()) {
                             $valueIDs[] = $dao->value;
                         }
                     }
                     if (!empty($valueIDs)) {
                         $customGroup->extends_entity_column_value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $valueIDs) . CRM_Core_DAO::VALUE_SEPARATOR;
                         unset($valueIDs);
                         // Note: No need to set extends_entity_column_id here.
                         $saveAgain = TRUE;
                     }
                 } else {
                     // when custom group extends 'Participant'
                     $sql = "\nSELECT     v.value\nFROM       civicrm_option_value v\nINNER JOIN civicrm_option_group g ON g.id = v.option_group_id\nWHERE      g.name = 'custom_data_type'\nAND        v.name = %1\n";
                     $params = array(1 => array((string) $customGroupXML->extends_entity_column_value_option_group, 'String'));
                     $valueID = (int) CRM_Core_DAO::singleValueQuery($sql, $params);
                     if ($valueID) {
                         $customGroup->extends_entity_column_id = $valueID;
                     }
                     $optionIDs = array();
                     switch ($valueID) {
                         case 1:
                             // ParticipantRole
                             $condition = "AND v.name IN ( '{$optValues}' )";
                             $optionIDs = CRM_Core_OptionGroup::values('participant_role', FALSE, FALSE, FALSE, $condition, 'name');
                             break;
                         case 2:
                             // ParticipantEventName
                             $condition = "( is_template IS NULL OR is_template != 1 ) AND title IN( '{$optValues}' )";
                             $optionIDs = CRM_Event_PseudoConstant::event(NULL, FALSE, $condition);
                             break;
                         case 3:
                             // ParticipantEventType
                             $condition = "AND v.name IN ( '{$optValues}' )";
                             $optionIDs = CRM_Core_OptionGroup::values('event_type', FALSE, FALSE, FALSE, $condition, 'name');
                             break;
                     }
                     if (is_array($optionIDs) && !empty($optionIDs)) {
                         $customGroup->extends_entity_column_value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($optionIDs)) . CRM_Core_DAO::VALUE_SEPARATOR;
                         $saveAgain = TRUE;
                     }
                 }
             }
             if ($saveAgain) {
                 $customGroup->save();
             }
             CRM_Core_BAO_CustomGroup::createTable($customGroup);
             $idMap['custom_group'][$customGroup->name] = $customGroup->id;
         }
     }
 }
开发者ID:kidaa30,项目名称:yes,代码行数:86,代码来源:Import.php

示例3: customGroups

 function customGroups(&$xml, &$idMap)
 {
     require_once 'CRM/Core/BAO/CustomGroup.php';
     require_once 'CRM/Utils/String.php';
     foreach ($xml->CustomGroups as $customGroupsXML) {
         foreach ($customGroupsXML->CustomGroup as $customGroupXML) {
             $customGroup = new CRM_Core_DAO_CustomGroup();
             if (!$this->copyData($customGroup, $customGroupXML, true, 'name')) {
                 $idMap['custom_group'][$customGroup->name] = $customGroup->id;
                 continue;
             }
             $saveAgain = false;
             if (!isset($customGroup->table_name) || empty($customGroup->table_name)) {
                 // fix table name
                 $customGroup->table_name = "civicrm_value_" . strtolower(CRM_Utils_String::munge($customGroup->title, '_', 32)) . "_{$customGroup->id}";
                 $saveAgain = true;
             }
             // fix extends stuff if it exists
             if (isset($customGroupXML->extends_entity_column_value_option_group) && isset($customGroupXML->extends_entity_column_value_option_value)) {
                 $optValues = explode(",", $customGroupXML->extends_entity_column_value_option_value);
                 $optValues = implode("','", $optValues);
                 if (trim($customGroup->extends) != 'Participant') {
                     $sql = "\nSELECT     v.value\nFROM       civicrm_option_value v\nINNER JOIN civicrm_option_group g ON g.id = v.option_group_id\nWHERE      g.name = %1\nAND        v.name IN (%2)\n";
                     $params = array(1 => array((string) $customGroupXML->extends_entity_column_value_option_group, 'String'), 2 => array((string) $optValues, 'String'));
                     $dao =& CRM_Core_DAO::executeQuery($sql, $params);
                     $valueIDs = array();
                     while ($dao->fetch()) {
                         $valueIDs[] = $dao->value;
                     }
                     if (!empty($valueIDs)) {
                         $customGroup->extends_entity_column_value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $valueIDs) . CRM_Core_DAO::VALUE_SEPARATOR;
                         // Note: No need to set extends_entity_column_id here.
                         $saveAgain = true;
                     }
                 } else {
                     // when custom group extends 'Participant'
                     $sql = "\nSELECT     v.value\nFROM       civicrm_option_value v\nINNER JOIN civicrm_option_group g ON g.id = v.option_group_id\nWHERE      g.name = 'custom_data_type'\nAND        v.name = %1\n";
                     $params = array(1 => array((string) $customGroupXML->extends_entity_column_value_option_group, 'String'));
                     $valueID = (int) CRM_Core_DAO::singleValueQuery($sql, $params);
                     if ($valueID) {
                         $customGroup->extends_entity_column_id = $valueID;
                     }
                     $optionIDs = array();
                     switch ($valueID) {
                         case 1:
                             // ParticipantRole
                             require_once 'CRM/Core/OptionGroup.php';
                             $condition = "AND v.name IN ( '{$optValues}' )";
                             $optionIDs = CRM_Core_OptionGroup::values('participant_role', false, false, false, $condition, 'name');
                             break;
                         case 2:
                             // ParticipantEventName
                             require_once 'CRM/Event/PseudoConstant.php';
                             $condition = "( is_template IS NULL OR is_template != 1 ) AND title IN( '{$optValues}' )";
                             $optionIDs = CRM_Event_PseudoConstant::event(null, false, $condition);
                             break;
                         case 3:
                             // ParticipantEventType
                             require_once 'CRM/Core/OptionGroup.php';
                             $condition = "AND v.name IN ( '{$optValues}' )";
                             $optionIDs = CRM_Core_OptionGroup::values('event_type', false, false, false, $condition, 'name');
                             break;
                     }
                     if (is_array($optionIDs) && !empty($optionIDs)) {
                         $customGroup->extends_entity_column_value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($optionIDs)) . CRM_Core_DAO::VALUE_SEPARATOR;
                         $saveAgain = true;
                     }
                 }
             }
             if ($saveAgain) {
                 $customGroup->save();
             }
             CRM_Core_BAO_CustomGroup::createTable($customGroup);
             $idMap['custom_group'][$customGroup->name] = $customGroup->id;
         }
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:77,代码来源:import.php

示例4: testCreateTable

 /**
  * Function to test createTable()
  */
 function testCreateTable()
 {
     $customGrouptitle = 'My Custom Group';
     $groupParams = array('title' => $customGrouptitle, 'name' => 'my_custom_group', 'style' => 'Tab', 'extends' => 'Individual', 'is_active' => 1);
     require_once 'CRM/Core/BAO/CustomGroup.php';
     $customGroupBAO =& new CRM_Core_BAO_CustomGroup();
     $customGroupBAO->copyValues($groupParams);
     $customGroup = $customGroupBAO->save();
     $tableName = 'civicrm_value_test_group_' . $customGroup->id;
     $customGroup->table_name = $tableName;
     $customGroup = $customGroupBAO->save();
     $customTable = CRM_Core_BAO_CustomGroup::createTable($customGroup);
     $customGroupId = $customGroup->id;
     //check db for custom group.
     $dbCustomGroupTitle = $this->assertDBNotNull('CRM_Core_DAO_CustomGroup', $customGroupId, 'title', 'id', 'Database check for custom group record.');
     //check for custom group table name
     $this->assertDBCompareValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'table_name', 'id', $tableName, 'Database check for custom group table name.');
     //check for group title
     $this->assertEquals($customGrouptitle, $dbCustomGroupTitle);
     //cleanup DB by deleting customGroup
     Custom::deleteGroup($customGroup);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:25,代码来源:CustomGroupTest.php

示例5: 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

示例6: testCreateTable

 /**
  * Test createTable()
  */
 public function testCreateTable()
 {
     $groupParams = array('title' => 'My Custom Group', 'name' => 'my_custom_group', 'style' => 'Tab', 'extends' => 'Individual', 'is_active' => 1, 'version' => 3);
     $customGroupBAO = new CRM_Core_BAO_CustomGroup();
     $customGroupBAO->copyValues($groupParams);
     $customGroup = $customGroupBAO->save();
     $tableName = 'civicrm_value_test_group_' . $customGroup->id;
     $customGroup->table_name = $tableName;
     $customGroup = $customGroupBAO->save();
     CRM_Core_BAO_CustomGroup::createTable($customGroup);
     $customGroupId = $customGroup->id;
     //check db for custom group.
     $dbCustomGroupTitle = $this->assertDBNotNull('CRM_Core_DAO_CustomGroup', $customGroupId, 'title', 'id', 'Database check for custom group record.');
     //check for custom group table name
     $this->assertDBCompareValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'table_name', 'id', $tableName, 'Database check for custom group table name.');
     $this->customGroupDelete($customGroup->id);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:20,代码来源:CustomGroupTest.php

示例7: customGroups

 function customGroups(&$xml, &$idMap)
 {
     require_once 'CRM/Core/BAO/CustomGroup.php';
     require_once 'CRM/Utils/String.php';
     foreach ($xml->CustomGroups as $customGroupsXML) {
         foreach ($customGroupsXML->CustomGroup as $customGroupXML) {
             $customGroup = new CRM_Core_DAO_CustomGroup();
             $this->copyData($customGroup, $customGroupXML, true);
             // fix table name
             $customGroup->table_name = "civicrm_value_" . strtolower(CRM_Utils_String::munge($customGroup->title, '_', 32)) . "_{$customGroup->id}";
             $customGroup->save();
             CRM_Core_BAO_CustomGroup::createTable($customGroup);
             $idMap['custom_group'][$customGroup->title] = $customGroup->id;
         }
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:16,代码来源:import.php


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