本文整理汇总了PHP中CRM_Core_BAO_CustomOption::updateValue方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_CustomOption::updateValue方法的具体用法?PHP CRM_Core_BAO_CustomOption::updateValue怎么用?PHP CRM_Core_BAO_CustomOption::updateValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_CustomOption
的用法示例。
在下文中一共展示了CRM_Core_BAO_CustomOption::updateValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* Add an Option Value.
*
* @param array $params
* Reference array contains the values submitted by the form.
* @param array $ids
* Reference array contains the id.
*
*
* @return CRM_Core_DAO_OptionValue
*/
public static function add(&$params, &$ids)
{
// CRM-10921: do not reset attributes to default if this is an update
//@todo consider if defaults are being set in the right place. 'dumb' defaults like
// these would be usefully set @ the api layer so they are visible to api users
// complex defaults like the domain id below would make sense in the setDefauls function
// but unclear what other ways this function is being used
if (empty($ids['optionValue'])) {
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
$params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE);
$params['is_optgroup'] = CRM_Utils_Array::value('is_optgroup', $params, FALSE);
$params['filter'] = CRM_Utils_Array::value('filter', $params, FALSE);
} elseif (isset($params['value'])) {
CRM_Core_BAO_CustomOption::updateValue($ids['optionValue'], $params['value']);
}
// action is taken depending upon the mode
$optionValue = new CRM_Core_DAO_OptionValue();
$optionValue->copyValues($params);
if (!empty($params['is_default'])) {
$query = 'UPDATE civicrm_option_value SET is_default = 0 WHERE option_group_id = %1';
// tweak default reset, and allow multiple default within group.
if ($resetDefaultFor = CRM_Utils_Array::value('reset_default_for', $params)) {
if (is_array($resetDefaultFor)) {
$colName = key($resetDefaultFor);
$colVal = $resetDefaultFor[$colName];
$query .= " AND ( {$colName} IN ( {$colVal} ) )";
}
}
$p = array(1 => array($params['option_group_id'], 'Integer'));
CRM_Core_DAO::executeQuery($query, $p);
}
// CRM-13814 : evalute option group id
if (!array_key_exists('option_group_id', $params) && !empty($ids['optionValue'])) {
$groupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $ids['optionValue'], 'option_group_id', 'id');
} else {
$groupId = $params['option_group_id'];
}
$groupName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $groupId, 'name', 'id');
if (in_array($groupName, CRM_Core_OptionGroup::$_domainIDGroups)) {
$optionValue->domain_id = CRM_Utils_Array::value('domain_id', $params, CRM_Core_Config::domainID());
}
$optionValue->id = CRM_Utils_Array::value('optionValue', $ids);
$optionValue->save();
CRM_Core_PseudoConstant::flush();
return $optionValue;
}