X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FOptionGroup.php;h=93e0993345de36db77fdaae63b86a244380d91b4;hb=4c9b6178d4a1a1b93ae1302f606903117a52e87b;hp=961d7aa9427690f5095ba383bc1d28e4b3f0aae7;hpb=1219e6af26646ad548b2d7e97a7f345af4655c21;p=civicrm-core.git diff --git a/CRM/Core/OptionGroup.php b/CRM/Core/OptionGroup.php index 961d7aa942..93e0993345 100644 --- a/CRM/Core/OptionGroup.php +++ b/CRM/Core/OptionGroup.php @@ -92,16 +92,25 @@ class CRM_Core_OptionGroup { * (radio, select, checkbox etc). OptionGroups for most cases have the * 'label' in the label colum and the 'id' or 'name' in the value column * - * @param $name string name of the option group - * @param $flip boolean results are return in id => label format if false + * @param $name + * String name of the option group. + * @param $flip + * Boolean results are return in id => label format if false. * if true, the results are reversed - * @param $grouping boolean if true, return the value in 'grouping' column - * @param $localize boolean if true, localize the results before returning - * @param $condition string add another condition to the sql query - * @param $labelColumnName string the column to use for 'label' - * @param $onlyActive boolean return only the action option values - * @param $fresh boolean ignore cache entries and go back to DB - * @param $keyColumnName string the column to use for 'key' + * @param $grouping + * Boolean if true, return the value in 'grouping' column. + * @param $localize + * Boolean if true, localize the results before returning. + * @param $condition + * String add another condition to the sql query. + * @param $labelColumnName + * String the column to use for 'label'. + * @param $onlyActive + * Boolean return only the action option values. + * @param $fresh + * Boolean ignore cache entries and go back to DB. + * @param $keyColumnName + * String the column to use for 'key'. * * @return array the values as specified by the above params * @static @@ -195,12 +204,17 @@ WHERE v.option_group_id = g.id * (radio, select, checkbox etc). OptionGroups for most cases have the * 'label' in the label colum and the 'id' or 'name' in the value column * - * @param $id integer id of the option group - * @param $flip boolean results are return in id => label format if false + * @param $id + * Integer id of the option group. + * @param $flip + * Boolean results are return in id => label format if false. * if true, the results are reversed - * @param $grouping boolean if true, return the value in 'grouping' column - * @param $localize boolean if true, localize the results before returning - * @param $labelColumnName string the column to use for 'label' + * @param $grouping + * Boolean if true, return the value in 'grouping' column. + * @param $localize + * Boolean if true, localize the results before returning. + * @param $labelColumnName + * String the column to use for 'label'. * * @param bool $onlyActive * @param bool $fresh @@ -246,19 +260,21 @@ WHERE v.option_group_id = g.id * is assigned a new fieldname by id or id's by title * (each within a specificied option_group) * - * @param array $params Reference array of values submitted by the form. Based on + * @param array $params + * Reference array of values submitted by the form. Based on. * $flip, creates new elements in $params for each field in * the $names array. * If $flip = false, adds root field name => title * If $flip = true, adds actual field name => id * - * @param array $names Reference array of fieldnames we want transformed. + * @param array $names + * Reference array of fieldnames we want transformed. * Array key = 'postName' (field name submitted by form in $params). * Array value = array( - 'newName' => $newName, 'groupName' => $groupName). + 'newName' => $newName, 'groupName' => $groupName). * * - * @param boolean $flip + * @param bool $flip * * @return void * @@ -342,7 +358,8 @@ WHERE v.option_group_id = g.id if ($onlyActiveValue) { $query .= " AND v.is_active = 1 "; } - $p = array(1 => array($groupName, 'String'), + $p = array( + 1 => array($groupName, 'String'), 2 => array($value, 'Integer'), ); $dao = CRM_Core_DAO::executeQuery($query, $p); @@ -361,10 +378,11 @@ WHERE v.option_group_id = g.id * * @return null */ - static function getValue($groupName, + static function getValue( + $groupName, $label, $labelField = 'label', - $labelType = 'String', + $labelType = 'String', $valueField = 'value' ) { if (empty($label)) { @@ -382,7 +400,8 @@ WHERE v.option_group_id = g.id AND v.$labelField = %2 "; - $p = array(1 => array($groupName, 'String'), + $p = array( + 1 => array($groupName, 'String'), 2 => array($label, $labelType), ); $dao = CRM_Core_DAO::executeQuery($query, $p); @@ -397,7 +416,8 @@ WHERE v.option_group_id = g.id /** * Get option_value.value from default option_value row for an option group * - * @param string $groupName the name of the option group + * @param string $groupName + * The name of the option group. * * @static * @@ -430,8 +450,10 @@ WHERE v.option_group_id = g.id * @TODO: Should update the group if it already exists intelligently, so multi-lingual is * not messed up. Currently deletes the old group * - * @param string $groupName the name of the option group - make sure there is no conflict - * @param array $values the associative array that has information on the option values + * @param string $groupName + * The name of the option group - make sure there is no conflict. + * @param array $values + * The associative array that has information on the option values. * the keys of this array are: * string 'title' (required) * string 'value' (required) @@ -440,8 +462,10 @@ WHERE v.option_group_id = g.id * int 'weight' (optional) - the order in which the value are displayed * bool 'is_default' (optional) - is this the default one to display when rendered in form * bool 'is_active' (optional) - should this element be rendered - * @param int $defaultID (reference) - the option value ID of the default element (if set) is returned else 'null' - * @param null $groupTitle the optional label of the option group else set to group name + * @param int $defaultID + * (reference) - the option value ID of the default element (if set) is returned else 'null'. + * @param null $groupTitle + * The optional label of the option group else set to group name. * * @static * @@ -558,7 +582,8 @@ SELECT v.label WHERE g.id = v.option_group_id AND g.name = %1 AND v.value = %2"; - $params = array(1 => array($groupName, 'String'), + $params = array( + 1 => array($groupName, 'String'), 2 => array($value, 'String'), ); return CRM_Core_DAO::singleValueQuery($query, $params); @@ -573,7 +598,8 @@ SELECT v.label * * @return array */ - static function getRowValues($groupName, $fieldValue, $field = 'name', + static function getRowValues( + $groupName, $fieldValue, $field = 'name', $fieldType = 'String', $active = TRUE ) { $query = " @@ -590,7 +616,8 @@ WHERE v.option_group_id = g.id $query .= " AND v.is_active = 1"; } - $p = array(1 => array($groupName, 'String'), + $p = array( + 1 => array($groupName, 'String'), 2 => array($fieldValue, $fieldType), ); $dao = CRM_Core_DAO::executeQuery($query, $p); @@ -618,7 +645,7 @@ WHERE v.option_group_id = g.id * @param $name * @param array $params */ - public static function flush($name, $params = array()){ + public static function flush($name, $params = array()) { $defaults = array( 'flip' => FALSE, 'grouping' => FALSE,