<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
$params += array(
'grouping' => FALSE,
'localize' => FALSE,
- 'onlyActive' => ($context == 'validate' || $context == 'create') ? FALSE : TRUE,
+ 'onlyActive' => ($context == 'validate' || $context == 'get') ? FALSE : TRUE,
'fresh' => FALSE,
);
// Support "unique names" as well as sql names
$fieldKey = $fieldName;
if (empty($fields[$fieldKey])) {
- $fieldKey = $fieldKeys[$fieldName];
+ $fieldKey = CRM_Utils_Array::value($fieldName, $fieldKeys);
}
// If neither worked then this field doesn't exist. Return false.
if (empty($fields[$fieldKey])) {
}
/**
- * Fetch the label (or other value) for a field given its key
+ * Fetch the translated label for a field given its key
*
- * @param String $daoName
+ * @param String $baoName
* @param String $fieldName
* @param String|Int $key
- * @param Array $params will be passed into self::get
+ *
+ * TODO: Accept multivalued input?
*
* @return bool|null|string
* FALSE if the given field has no associated option list
* NULL if the given key has no corresponding option
* String if label is found
*/
- static function getValue($daoName, $fieldName, $key, $params = array()) {
- $values = self::get($daoName, $fieldName, $params);
+ static function getLabel($baoName, $fieldName, $key) {
+ $values = $baoName::buildOptions($fieldName, 'get');
if ($values === FALSE) {
return FALSE;
}
}
/**
- * Fetch the key for a field option given its label/name
+ * Fetch the machine name for a field given its key
*
- * @param String $daoName
+ * @param String $baoName
+ * @param String $fieldName
+ * @param String|Int $key
+ *
+ * @return bool|null|string
+ * FALSE if the given field has no associated option list
+ * NULL if the given key has no corresponding option
+ * String if label is found
+ */
+ static function getName($baoName, $fieldName, $key) {
+ $values = $baoName::buildOptions($fieldName, 'validate');
+ if ($values === FALSE) {
+ return FALSE;
+ }
+ return CRM_Utils_Array::value($key, $values);
+ }
+
+ /**
+ * Fetch the key for a field option given its name
+ *
+ * @param String $baoName
* @param String $fieldName
* @param String|Int $value
- * @param Array $params will be passed into self::get
*
* @return bool|null|string|number
* FALSE if the given field has no associated option list
* NULL if the given key has no corresponding option
* String|Number if key is found
*/
- static function getKey($daoName, $fieldName, $value, $params = array()) {
- $values = self::get($daoName, $fieldName, $params);
+ static function getKey($baoName, $fieldName, $value) {
+ $values = $baoName::buildOptions($fieldName, 'validate');
if ($values === FALSE) {
return FALSE;
}
while ($relationshipTypeDAO->fetch()) {
self::$relationshipType[$valueColumnName][$relationshipTypeDAO->id] = array(
+ 'id' => $relationshipTypeDAO->id,
$column_a_b => $relationshipTypeDAO->$column_a_b,
$column_b_a => $relationshipTypeDAO->$column_b_a,
'contact_type_a' => "$relationshipTypeDAO->contact_type_a",