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


PHP CRM_Core_BAO_CustomGroup::create方法代码示例

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


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

示例1: civicrm_api3_custom_group_create

/**
* Use this API to create a new group.  The 'extends' value accepts an array or a comma separated string.
* e.g array(
  'Individual','Contact') or 'Individual,Contact'
* See the CRM Data Model for custom_group property definitions
* $params['class_name'] is a required field, class being extended.
*
* @param $params     array   Associative array of property name/value pairs to insert in group.
* {@getfields CustomGroup_create}
*
* @return   Newly create custom_group object
* @todo $params['extends'] is array format - is that std compatible
* @access public
*/
function civicrm_api3_custom_group_create($params)
{
    if (isset($params['extends']) && is_string($params['extends'])) {
        $extends = explode(",", $params['extends']);
        unset($params['extends']);
        $params['extends'] = $extends;
    }
    if (!isset($params['extends'][0]) || !trim($params['extends'][0])) {
        return civicrm_api3_create_error("First item in params['extends'] must be a class name (e.g. 'Contact').");
    }
    if (isset($params['extends_entity_column_value']) && !is_array($params['extends_entity_column_value'])) {
        // BAO fails if this is a string, but API getFields says this must be a string, so we'll do a double backflip
        $params['extends_entity_column_value'] = CRM_Utils_Array::explodePadded($params['extends_entity_column_value']);
    }
    $customGroup = CRM_Core_BAO_CustomGroup::create($params);
    _civicrm_api3_object_to_array($customGroup, $values[$customGroup->id]);
    return civicrm_api3_create_success($values, $params, 'custom_group', $customGroup);
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:32,代码来源:CustomGroup.php

示例2: civicrm_api3_custom_group_create

/**
* Use this API to create a new group.  The 'extends' value accepts an array or a comma separated string.
* e.g array(
  'Individual','Contact') or 'Individual,Contact'
* See the CRM Data Model for custom_group property definitions
* $params['class_name'] is a required field, class being extended.
*
* @param $params     array   Associative array of property name/value pairs to insert in group.
* {@getfields CustomGroup_create}
*
* @return   Newly create custom_group object
* @todo $params['extends'] is array format - is that std compatible
* @todo review custom field create if 'html' approx line 110
* @access public
*/
function civicrm_api3_custom_group_create($params)
{
    if (is_string($params['extends'])) {
        $extends = explode(",", $params['extends']);
        unset($params['extends']);
        $params['extends'] = $extends;
    }
    if (!isset($params['extends'][0]) || !trim($params['extends'][0])) {
        return civicrm_api3_create_error("First item in params['extends'] must be a class name (e.g. 'Contact').");
    }
    $customGroup = CRM_Core_BAO_CustomGroup::create($params);
    _civicrm_api3_object_to_array($customGroup, $values[$customGroup->id]);
    if (CRM_Utils_Array::value('html_type', $params)) {
        $fparams = array('custom_group_id' => $customGroup->id, 'version' => $params['version'], 'label' => 'api created field');
        require_once 'api/v3/CustomField.php';
        $fieldValues = civicrm_api3_custom_field_create($fparams);
        $values[$fieldValues['id']] = array_merge($values[$customGroup->id], $fieldValues['values'][$fieldValues['id']]);
    }
    return civicrm_api3_create_success($values, $params, 'custom_group', $customGroup);
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:35,代码来源:CustomGroup.php

示例3: testCreate

 function testCreate()
 {
     $params = array('title' => 'Test_Group_1', 'name' => 'test_group_1', 'extends' => array('Individual'), 'weight' => 4, 'collapse_display' => 1, 'style' => 'Inline', 'help_pre' => 'This is Pre Help For Test Group 1', 'help_post' => 'This is Post Help For Test Group 1', 'is_active' => 1);
     require_once 'CRM/Core/BAO/CustomGroup.php';
     $customGroup = CRM_Core_BAO_CustomGroup::create($params);
     $dbCustomGroupTitle = $this->assertDBNotNull('CRM_Core_DAO_CustomGroup', $customGroup->id, 'title', 'id', 'Database check for custom group record.');
     $this->assertEquals($params['title'], $dbCustomGroupTitle);
     Custom::deleteGroup($customGroup);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:9,代码来源:CustomGroupTest.php

示例4: testCreateTableName

 /**
  * Test create() given a table_name
  */
 public function testCreateTableName()
 {
     $params = array('title' => 'Test_Group_2', 'name' => 'test_group_2', 'table_name' => 'test_otherTableName', 'extends' => array(0 => 'Individual', 1 => array()), 'weight' => 4, 'collapse_display' => 1, 'style' => 'Inline', 'help_pre' => 'This is Pre Help For Test Group 1', 'help_post' => 'This is Post Help For Test Group 1', 'is_active' => 1, 'version' => 3);
     $customGroup = CRM_Core_BAO_CustomGroup::create($params);
     $dbCustomGroupTitle = $this->assertDBNotNull('CRM_Core_DAO_CustomGroup', $customGroup->id, 'title', 'id', 'Database check for custom group record.');
     $this->assertEquals($params['title'], $dbCustomGroupTitle);
     $dbCustomGroupTableName = $this->assertDBNotNull('CRM_Core_DAO_CustomGroup', $customGroup->id, 'table_name', 'id', 'Database check for custom group record.');
     $this->assertEquals($params['table_name'], $dbCustomGroupTableName);
     Custom::deleteGroup($customGroup);
 }
开发者ID:scardinius,项目名称:civicrm-core,代码行数:13,代码来源:CustomGroupTest.php

示例5: crm_create_custom_group

/**
 * Use this API to create a new group. See the CRM Data Model for custom_group property definitions
 * 
 * @param $class_name String  Which class is being extended.
 *
 * @param $params     array   Associative array of property name/value pairs to insert in group.
 *
 * @return   Newly create custom_group object
 *
 * @access public 
 */
function crm_create_custom_group($class_name, $params)
{
    _crm_initialize();
    if (!trim($class_name)) {
        return _crm_error("class_name is not set");
    }
    if (!is_array($params)) {
        return _crm_error("params is not an array ");
    }
    $params['extends'] = $class_name;
    $error = _crm_check_required_fields($params, 'CRM_Core_DAO_CustomGroup');
    if (is_a($error, 'CRM_Core_Error')) {
        return $error;
    }
    require_once 'CRM/Core/BAO/CustomGroup.php';
    $customGroup = CRM_Core_BAO_CustomGroup::create($params);
    return $customGroup;
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:29,代码来源:CustomGroup.php

示例6: postProcess

 /**
  * Process the form.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues('Group');
     $params['overrideFKConstraint'] = 0;
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $params['id'] = $this->_id;
         if ($this->_defaults['extends'][0] != $params['extends'][0]) {
             $params['overrideFKConstraint'] = 1;
         }
         if (!empty($this->_subtypes)) {
             $subtypesToBeRemoved = array_diff($this->_subtypes, array_intersect($this->_subtypes, $params['extends'][1]));
             CRM_Contact_BAO_ContactType::deleteCustomRowsOfSubtype($this->_id, $subtypesToBeRemoved);
         }
     } elseif ($this->_action & CRM_Core_Action::ADD) {
         //new custom set , so lets set the created_id
         $session = CRM_Core_Session::singleton();
         $params['created_id'] = $session->get('userID');
         $params['created_date'] = date('YmdHis');
     }
     $group = CRM_Core_BAO_CustomGroup::create($params);
     // reset the cache
     CRM_Core_BAO_Cache::deleteGroup('contact fields');
     if ($this->_action & CRM_Core_Action::UPDATE) {
         CRM_Core_Session::setStatus(ts('Your custom field set \'%1 \' has been saved.', array(1 => $group->title)), ts('Saved'), 'success');
     } else {
         // Jump directly to adding a field if popups are disabled
         $action = CRM_Core_Resources::singleton()->ajaxPopupsEnabled ? '' : '/add';
         $url = CRM_Utils_System::url("civicrm/admin/custom/group/field{$action}", 'reset=1&new=1&gid=' . $group->id . '&action=' . ($action ? 'add' : 'browse'));
         CRM_Core_Session::setStatus(ts("Your custom field set '%1' has been added. You can add custom fields now.", array(1 => $group->title)), ts('Saved'), 'success');
         $session = CRM_Core_Session::singleton();
         $session->replaceUserContext($url);
     }
     // prompt Drupal Views users to update $db_prefix in settings.php, if necessary
     global $db_prefix;
     $config = CRM_Core_Config::singleton();
     if (is_array($db_prefix) && $config->userSystem->is_drupal && module_exists('views')) {
         // get table_name for each custom group
         $tables = array();
         $sql = "SELECT table_name FROM civicrm_custom_group WHERE is_active = 1";
         $result = CRM_Core_DAO::executeQuery($sql);
         while ($result->fetch()) {
             $tables[$result->table_name] = $result->table_name;
         }
         // find out which tables are missing from the $db_prefix array
         $missingTableNames = array_diff_key($tables, $db_prefix);
         if (!empty($missingTableNames)) {
             CRM_Core_Session::setStatus(ts("To ensure that all of your custom data groups are available to Views, you may need to add the following key(s) to the db_prefix array in your settings.php file: '%1'.", array(1 => implode(', ', $missingTableNames))), ts('Note'), 'info');
         }
     }
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:57,代码来源:Group.php

示例7: civicrm_custom_group_create

/**
 * Use this API to create a new group. See the CRM Data Model for custom_group property definitions
 * $params['class_name'] is a required field, class being extended.
 *
 * @param $params     array   Associative array of property name/value pairs to insert in group.
 *
 *
 * @return   Newly create custom_group object
 *
 * @access public 
 */
function civicrm_custom_group_create($params)
{
    _civicrm_initialize();
    if (!is_array($params)) {
        return civicrm_create_error("params is not an array");
    }
    // Require either param['class_name'] (string) - for backwards compatibility - OR parm['extends'] (array)
    // If passing extends array - set class_name (e.g. 'Contact', 'Participant'...) as extends[0]. You may optionally
    // pass an extends_entity_column_value as extends[1] (e.g. an Activity Type ID).
    if (isset($params['class_name']) && trim($params['class_name'])) {
        $params['extends'][0] = trim($params['class_name']);
    } else {
        if (!isset($params['extends']) || !is_array($params['extends'])) {
            return civicrm_create_error("Params must include either 'class_name' (string) or 'extends' (array).");
        } else {
            if (!isset($params['extends'][0]) || !trim($params['extends'][0])) {
                return civicrm_create_error("First item in params['extends'] must be a class name (e.g. 'Contact').");
            }
        }
    }
    $error = _civicrm_check_required_fields($params, 'CRM_Core_DAO_CustomGroup');
    require_once 'CRM/Utils/String.php';
    if (!isset($params['title']) || !trim($params['title'])) {
        return civicrm_create_error("Title parameter is required.");
    }
    if (!isset($params['style']) || !trim($params['style'])) {
        $params['style'] = 'Inline';
    }
    if (is_a($error, 'CRM_Core_Error')) {
        return civicrm_create_error($error->_errors[0]['message']);
    }
    require_once 'CRM/Core/BAO/CustomGroup.php';
    $customGroup = CRM_Core_BAO_CustomGroup::create($params);
    _civicrm_object_to_array($customGroup, $values);
    if (is_a($customGroup, 'CRM_Core_Error')) {
        return civicrm_create_error($customGroup->_errors[0]['message']);
    } else {
        $values['is_error'] = 0;
    }
    if (CRM_Utils_Array::value('html_type', $params)) {
        $params['custom_group_id'] = $customGroup->id;
        $fieldValues = civicrm_custom_field_create($params);
        $values = array_merge($values, $fieldValues['result']);
    }
    return $values;
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:57,代码来源:CustomGroup.php

示例8: postProcess

 /**
  * Process the form
  * 
  * @param null
  * 
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues('Group');
     $params['overrideFKConstraint'] = 0;
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $params['id'] = $this->_id;
         if ($this->_defaults['extends'][0] != $params['extends'][0]) {
             $params['overrideFKConstraint'] = 1;
         }
     } elseif ($this->_action & CRM_Core_Action::ADD) {
         //new custom set , so lets set the created_id
         $session = CRM_Core_Session::singleton();
         $params['created_id'] = $session->get('userID');
         $params['created_date'] = date('YmdHis');
     }
     $group = CRM_Core_BAO_CustomGroup::create($params);
     // reset the cache
     require_once 'CRM/Core/BAO/Cache.php';
     CRM_Core_BAO_Cache::deleteGroup('contact fields');
     if ($this->_action & CRM_Core_Action::UPDATE) {
         CRM_Core_Session::setStatus(ts('Your custom field set \'%1 \' has been saved.', array(1 => $group->title)));
     } else {
         $url = CRM_Utils_System::url('civicrm/admin/custom/group/field/add', 'reset=1&action=add&gid=' . $group->id);
         CRM_Core_Session::setStatus(ts('Your custom field set \'%1\' has been added. You can add it custom fields now.', array(1 => $group->title)));
         $session = CRM_Core_Session::singleton();
         $session->replaceUserContext($url);
     }
     // prompt Drupal Views users to update $db_prefix in settings.php, if necessary
     global $db_prefix;
     if (is_array($db_prefix) && CIVICRM_UF == 'Drupal' && module_exists('views')) {
         // get table_name for each custom group
         $tables = array();
         $sql = "SELECT table_name FROM civicrm_custom_group WHERE is_active = 1";
         $result = CRM_Core_DAO::executeQuery($sql);
         while ($result->fetch()) {
             $tables[$result->table_name] = $result->table_name;
         }
         // find out which tables are missing from the $db_prefix array
         $missingTableNames = array_diff_key($tables, $db_prefix);
         if (!empty($missingTableNames)) {
             CRM_Core_Session::setStatus('<br />' . ts('Note:To ensure that all of your custom data groups are available to Views, you may need to add the following key(s) to the $db_prefix array in your settings.php file: \'%1\'.', array(1 => implode(', ', $missingTableNames))));
         }
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:53,代码来源:Group.php

示例9: postProcess

 /**
  * Process the form
  * 
  * @param null
  * 
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues('Group');
     $params['overrideFKConstraint'] = 0;
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $params['id'] = $this->_id;
         if ($this->_defaults['extends'][0] != $params['extends'][0]) {
             $params['overrideFKConstraint'] = 1;
         }
     } elseif ($this->_action & CRM_Core_Action::ADD) {
         //new custom group, so lets set the created_id
         $session =& CRM_Core_Session::singleton();
         $params['created_id'] = $session->get('userID');
         $params['created_date'] = date('YmdHis');
     }
     $group = CRM_Core_BAO_CustomGroup::create($params);
     // reset the cache
     require_once 'CRM/Core/BAO/Cache.php';
     CRM_Core_BAO_Cache::deleteGroup('contact fields');
     if ($this->_action & CRM_Core_Action::UPDATE) {
         CRM_Core_Session::setStatus(ts('Your custom data group \'%1 \' has been saved.', array(1 => $group->title)));
     } else {
         $url = CRM_Utils_System::url('civicrm/admin/custom/group/field', 'reset=1&action=add&gid=' . $group->id);
         CRM_Core_Session::setStatus(ts('Your custom data group \'%1\' has been added. You can add custom fields to this group now.', array(1 => $group->title)));
         $session =& CRM_Core_Session::singleton();
         $session->replaceUserContext($url);
     }
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:37,代码来源:Group.php


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