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


PHP CRM_Core_BAO_OptionValue::add方法代码示例

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


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

示例1: createEntry

 public function createEntry($id, $key)
 {
     $e = self::$_extensions;
     $ids = array();
     $groupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', self::OPTION_GROUP_NAME, 'id', 'name');
     $params = array('option_group_id' => $groupId, 'weight' => CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', array('option_group_id' => $groupId)), 'label' => $e['per_id'][$id]['label'], 'name' => $e['per_id'][$id]['label'], 'value' => $key, 'grouping' => $e['per_id'][$id]['type'], 'is_active' => 1);
     $optionValue = CRM_Core_BAO_OptionValue::add($params, $ids);
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:8,代码来源:ExtensionType.php

示例2: install

 public function install()
 {
     if (array_key_exists($this->ext->key, $this->customSearches)) {
         CRM_Core_Error::fatal('This custom search is already registered.');
     }
     $weight = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', array('option_group_id' => $this->groupId));
     $params = array('option_group_id' => $this->groupId, 'weight' => $weight, 'description' => $this->ext->label . ' (' . $this->ext->key . ')', 'name' => $this->ext->key, 'value' => max($this->customSearches) + 1, 'label' => $this->ext->key, 'is_active' => 1);
     $ids = array();
     $optionValue = CRM_Core_BAO_OptionValue::add($params, $ids);
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:10,代码来源:Search.php

示例3: create

 /**
  * Create option value - note that the create function calls 'add' but
  * has more business logic
  *
  * @param array $params
  *   Input parameters.
  *
  * @return object
  */
 public static function create($params)
 {
     if (empty($params['id'])) {
         self::setDefaults($params);
     }
     $ids = array();
     if (!empty($params['id'])) {
         $ids = array('optionValue' => $params['id']);
     }
     return CRM_Core_BAO_OptionValue::add($params, $ids);
 }
开发者ID:kidaa30,项目名称:yes,代码行数:20,代码来源:OptionValue.php

示例4: onPreInstall

 /**
  * @param CRM_Extension_Info $info
  *
  * @return bool
  * @throws Exception
  */
 public function onPreInstall(CRM_Extension_Info $info)
 {
     $customSearchesByName = $this->getCustomSearchesByName();
     if (array_key_exists($info->key, $customSearchesByName)) {
         CRM_Core_Error::fatal('This custom search is already registered.');
     }
     $weight = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', array('option_group_id' => $this->groupId));
     $params = array('option_group_id' => $this->groupId, 'weight' => $weight, 'description' => $info->label . ' (' . $info->key . ')', 'name' => $info->key, 'value' => max($customSearchesByName) + 1, 'label' => $info->key, 'is_active' => 1);
     $ids = array();
     $optionValue = CRM_Core_BAO_OptionValue::add($params, $ids);
     return $optionValue ? TRUE : FALSE;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:18,代码来源:Search.php

示例5: install

 public function install()
 {
     if (array_key_exists($this->ext->key, $this->customReports)) {
         CRM_Core_Error::fatal('This report is already registered.');
     }
     if ($this->ext->typeInfo['component'] === 'Contact') {
         $compId = 'null';
     } else {
         $comp = CRM_Core_Component::get($this->ext->typeInfo['component']);
         $compId = $comp->componentID;
     }
     if (empty($compId)) {
         CRM_Core_Error::fatal("Component for which you're trying to install the extension (" . $this->ext->typeInfo['component'] . ") is currently disabled.");
     }
     $weight = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', array('option_group_id' => $this->groupId));
     $ids = array();
     $params = array('label' => $this->ext->label . ' (' . $this->ext->key . ')', 'value' => $this->ext->typeInfo['reportUrl'], 'name' => $this->ext->key, 'weight' => $weight, 'description' => $this->ext->label . ' (' . $this->ext->key . ')', 'component_id' => $compId, 'option_group_id' => $this->groupId, 'is_active' => 1);
     $optionValue = CRM_Core_BAO_OptionValue::add($params, $ids);
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:19,代码来源:Report.php

示例6: civicrm_api3_option_value_create

/**
 *  Add a OptionValue. OptionValues are used to classify CRM entities (including Contacts, Groups and Actions).
 *
 * Allowed @params array keys are:
 *
 * {@example OptionValueCreate.php}
 *
 * @return array of newly created option_value property values.
 * {@getfields OptionValue_create}
 * @access public
 */
function civicrm_api3_option_value_create($params)
{
    $weight = 0;
    if (!array_key_exists('label', $params) && array_key_exists('name', $params)) {
        // no idea why that's a "mandatory" field
        $params['label'] = $params['name'];
    }
    if (!CRM_Utils_Array::value('value', $params) && array_key_exists('option_group_id', $params)) {
        require_once 'CRM/Utils/Weight.php';
        $fieldValues = array('option_group_id' => $params['option_group_id']);
        // use the next available value
        /* CONVERT(value, DECIMAL) is used to convert varchar
           field 'value' to decimal->integer                    */
        $params['value'] = (int) CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues, 'CONVERT(value, DECIMAL)');
        $weight = $params['value'];
    }
    if (!array_key_exists('weight', $params) && array_key_exists('value', $params)) {
        // no idea why that's a "mandatory" field
        $params['weight'] = $params['value'];
    } elseif (array_key_exists('weight', $params) && $params['weight'] == 'next') {
        // weight is numeric, so it's safe-ish to treat symbol 'next' as magical value
        $params['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', array('option_group_id' => $params['option_group_id']));
    }
    if (array_key_exists('component', $params)) {
        if (empty($params['component'])) {
            $params['component_id'] = '';
        } else {
            $params['component_id'] = array_search($params['component'], CRM_Core_PseudoConstant::component());
        }
        unset($params['component']);
    }
    if (CRM_Utils_Array::value('id', $params)) {
        $ids = array('optionValue' => $params['id']);
    }
    $optionValueBAO = CRM_Core_BAO_OptionValue::add($params, $ids);
    civicrm_api('option_value', 'getfields', array('version' => 3, 'cache_clear' => 1));
    $values = array();
    _civicrm_api3_object_to_array($optionValueBAO, $values[$optionValueBAO->id]);
    return civicrm_api3_create_success($values, $params);
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:51,代码来源:OptionValue.php

示例7: addOptionValue

 /**
  * Add/edit option-value of a particular group
  *
  * @param array $params
  *   Array containing exported values from the invoking form.
  * @param array $groupParams
  *   Array containing group fields whose option-values is to retrieved/saved.
  * @param $action
  * @param int $optionValueID Has the id of the optionValue being edited, disabled ..etc.
  *   Has the id of the optionValue being edited, disabled ..etc.
  *
  * @return CRM_Core_DAO_OptionValue
  *
  */
 public static function addOptionValue(&$params, &$groupParams, &$action, &$optionValueID)
 {
     $ids = array();
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
     // checking if the group name with the given id or name (in $groupParams) exists
     if (!empty($groupParams)) {
         $config = CRM_Core_Config::singleton();
         $groupParams['is_active'] = 1;
         $optionGroup = CRM_Core_BAO_OptionGroup::retrieve($groupParams, $defaults);
     }
     // if the corresponding group doesn't exist, create one, provided $groupParams has 'name' in it.
     if (!$optionGroup->id) {
         if ($groupParams['name']) {
             $newOptionGroup = CRM_Core_BAO_OptionGroup::add($groupParams, $defaults);
             $params['weight'] = 1;
             $optionGroupID = $newOptionGroup->id;
         }
     } else {
         $optionGroupID = $optionGroup->id;
         $oldWeight = NULL;
         if ($optionValueID) {
             $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $optionValueID, 'weight', 'id');
         }
         $fieldValues = array('option_group_id' => $optionGroupID);
         $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_OptionValue', $oldWeight, CRM_Utils_Array::value('weight', $params), $fieldValues);
     }
     $params['option_group_id'] = $optionGroupID;
     if ($action & CRM_Core_Action::ADD && empty($params['value'])) {
         $fieldValues = array('option_group_id' => $optionGroupID);
         // use the next available value
         /* CONVERT(value, DECIMAL) is used to convert varchar
            field 'value' to decimal->integer                    */
         $params['value'] = (int) CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues, 'CONVERT(value, DECIMAL)');
     }
     if (!$params['label'] && $params['name']) {
         $params['label'] = $params['name'];
     }
     // set name to label if it's not set - but *only* for ADD action (CRM-3522)
     if ($action & CRM_Core_Action::ADD && empty($params['name']) && $params['label']) {
         $params['name'] = $params['label'];
     }
     if ($action & CRM_Core_Action::UPDATE) {
         $ids['optionValue'] = $optionValueID;
     }
     $optionValue = CRM_Core_BAO_OptionValue::add($params, $ids);
     return $optionValue;
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:61,代码来源:OptionValue.php

示例8: _createExtensionEntry

 private function _createExtensionEntry()
 {
     $groupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', self::OPTION_GROUP_NAME, 'id', 'name');
     $weight = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', array('option_group_id' => $groupId));
     $params = array('option_group_id' => $groupId, 'weight' => $weight, 'label' => $this->label, 'name' => $this->name, 'value' => $this->key, 'grouping' => $this->type, 'description' => $this->file, 'is_active' => 1);
     $ids = array();
     $optionValue = CRM_Core_BAO_OptionValue::add($params, $ids);
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:8,代码来源:Extension.php

示例9: postProcess

 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     $params = $this->exportValues();
     require_once 'CRM/Core/BAO/OptionValue.php';
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Core_BAO_OptionValue::del($this->_id);
         CRM_Core_Session::setStatus(ts('Selected option value has been deleted.'));
     } else {
         $params = $ids = array();
         // store the submitted values in an array
         $params = $this->exportValues();
         $params['option_group_id'] = $this->_gid;
         if ($this->_action & CRM_Core_Action::UPDATE) {
             $ids['optionValue'] = $this->_id;
         }
         //set defaultGreeting option in params to save default value as per contactOption-defaultValue mapping
         if (CRM_Utils_Array::value('contactOptions', $params)) {
             $params['filter'] = CRM_Utils_Array::value('contactOptions', $params);
             $params['defaultGreeting'] = 1;
         }
         $optionValue = CRM_Core_BAO_OptionValue::add($params, $ids);
         CRM_Core_Session::setStatus(ts('The Option Value \'%1\' has been saved.', array(1 => $optionValue->label)));
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:30,代码来源:OptionValue.php

示例10: postProcess

 /**
  * Function to process the form
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     CRM_Utils_System::flushCache();
     $params = $this->exportValues();
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Core_BAO_OptionValue::del($this->_id);
         CRM_Core_Session::setStatus(ts('Selected option value has been deleted.'), ts('Record Deleted'), 'success');
     } else {
         $params = $ids = array();
         // store the submitted values in an array
         $params = $this->exportValues();
         $params['option_group_id'] = $this->_gid;
         if ($this->_action & CRM_Core_Action::UPDATE) {
             $ids['optionValue'] = $this->_id;
         }
         //set defaultGreeting option in params to save default value as per contactOption-defaultValue mapping
         if (CRM_Utils_Array::value('contactOptions', $params)) {
             $params['filter'] = CRM_Utils_Array::value('contactOptions', $params);
             $params['defaultGreeting'] = 1;
         }
         $optionValue = CRM_Core_BAO_OptionValue::add($params, $ids);
         // CRM-11516
         if (CRM_Utils_Array::value('financial_account_id', $params)) {
             $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
             $params = array('entity_table' => 'civicrm_option_value', 'entity_id' => $optionValue->id, 'account_relationship' => $relationTypeId, 'financial_account_id' => $params['financial_account_id']);
             CRM_Financial_BAO_FinancialTypeAccount::add($params);
         }
         CRM_Core_Session::setStatus(ts('The Option Value \'%1\' has been saved.', array(1 => $optionValue->label)), ts('Saved'), 'success');
     }
 }
开发者ID:hguru,项目名称:224Civi,代码行数:37,代码来源:OptionValue.php


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