Skip to content
Snippets Groups Projects
Commit c3feadf0 authored by lobo's avatar lobo
Browse files

Merge pull request #334 from davecivicrm/CRM-12276

CRM-12276 Use default option_value to set default activity.status_id whe...
parents a3f6b977 343d84fa
No related branches found
No related tags found
No related merge requests found
......@@ -600,6 +600,9 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
$priority = CRM_Core_PseudoConstant::priority();
$defaults['priority_id'] = array_search('Normal', $priority);
}
if (!CRM_Utils_Array::value('status_id', $defaults)) {
$defaults['status_id'] = CRM_Core_OptionGroup::getDefaultValue('activity_status');
}
return $defaults;
}
......
......@@ -354,6 +354,38 @@ WHERE v.option_group_id = g.id
return NULL;
}
/**
* Get option_value.value from default option_value row for an option group
*
* @param string $groupName the name of the option group
*
* @access public
* @static
*
* @return string the value from the row where is_default = true
*/
static function getDefaultValue($groupName) {
if (empty($groupName)) {
return NULL;
}
$query = "
SELECT v.value
FROM civicrm_option_value v,
civicrm_option_group g
WHERE v.option_group_id = g.id
AND g.name = %1
AND v.is_active = 1
AND g.is_active = 1
AND v.is_default = 1
";
if (in_array($groupName, self::$_domainIDGroups)) {
$query .= " AND v.domain_id = " . CRM_Core_Config::domainID();
}
$p = array(1 => array($groupName, 'String'));
return CRM_Core_DAO::singleValueQuery($query, $p);
}
/**
* Creates a new option group with the passed in values
* @TODO: Should update the group if it already exists intelligently, so multi-lingual is
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment