Skip to content
Snippets Groups Projects
Commit 343d84fa authored by Dave Greenberg's avatar Dave Greenberg
Browse files

CRM-12276 Use default option_value to set default activity.status_id when...

CRM-12276 Use default option_value to set default activity.status_id when creating an activity. Created a method in OptionGroup to retrieve this value since one didn't exist.

----------------------------------------
* CRM-12276: Changing default option in Activity Status does not change the default when creating an activity
  http://issues.civicrm.org/jira/browse/CRM-12276
parent a96556af
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