+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
+ | Copyright CiviCRM LLC (c) 2004-2016 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
+ * @copyright CiviCRM LLC (c) 2004-2016
* $Id$
*
*/
* Value we want to set the is_active field.
*
* @return Object
- * DAO object on sucess, null otherwise
+ * DAO object on success, null otherwise
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_OptionGroup', $id, 'is_active', $is_active);
return $optionGroup->name;
}
+ /**
+ * Ensure an option group exists.
+ *
+ * This function is intended to be called from the upgrade script to ensure
+ * that an option group exists, without hitting an error if it already exists.
+ *
+ * This is sympathetic to sites who might pre-add it.
+ *
+ * @param array $params
+ *
+ * @return int
+ * ID of the option group.
+ */
+ public static function ensureOptionGroupExists($params) {
+ $existingValues = civicrm_api3('OptionGroup', 'get', array(
+ 'name' => $params['name'],
+ ));
+ if (!$existingValues['count']) {
+ $result = civicrm_api3('OptionGroup', 'create', $params);
+ return $result['id'];
+ }
+ else {
+ return $existingValues['id'];
+ }
+ }
+
}
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
+ * @copyright CiviCRM LLC (c) 2004-2016
*/
class CRM_Core_OptionGroup {
static $_values = array();
* This function retrieves all the values for the specific option group by name
* this is primarily used to create various html based form elements
* (radio, select, checkbox etc). OptionGroups for most cases have the
- * 'label' in the label colum and the 'id' or 'name' in the value column
+ * 'label' in the label column and the 'id' or 'name' in the value column
*
* @param string $name
* name of the option group.
* This function retrieves all the values for the specific option group by id.
* this is primarily used to create various html based form elements
* (radio, select, checkbox etc). OptionGroups for most cases have the
- * 'label' in the label colum and the 'id' or 'name' in the value column
+ * 'label' in the label column and the 'id' or 'name' in the value column
*
* @param int $id
* id of the option group.
*
*
* @param bool $flip
- *
- * @return void
- *
*/
public static function lookupValues(&$params, &$names, $flip = FALSE) {
foreach ($names as $postName => $value) {
}
/**
+ * @deprecated
+ *
+ * This function is not cached.
+ *
* @param string $groupName
* @param $label
* @param string $labelField