diff --git a/CRM/Admin/Form/Options.php b/CRM/Admin/Form/Options.php index 5a595e47d4e6..c7e39575cf12 100644 --- a/CRM/Admin/Form/Options.php +++ b/CRM/Admin/Form/Options.php @@ -177,10 +177,12 @@ public function buildQuickForm() { 'addressee', )) && !$isReserved ) { + $domainSepcificOptionGroups = array('from_email_address'); + $domainSpecific = in_array($this->_gName, $domainSepcificOptionGroups) ? TRUE : FALSE $this->addRule('label', ts('This Label already exists in the database for this option group. Please select a different Value.'), 'optionExists', - array('CRM_Core_DAO_OptionValue', $this->_id, $this->_gid, 'label') + array('CRM_Core_DAO_OptionValue', $this->_id, $this->_gid, 'label', $domainSpecific) ); } diff --git a/CRM/Core/OptionValue.php b/CRM/Core/OptionValue.php index df4a386029b7..be150369f806 100644 --- a/CRM/Core/OptionValue.php +++ b/CRM/Core/OptionValue.php @@ -258,15 +258,20 @@ public static function addOptionValue(&$params, &$groupParams, &$action, &$optio * @param int $optionGroupID * @param string $fieldName * The name of the field in the DAO. + * @param bool $domainSpecific * * @return bool * true if object exists */ - public static function optionExists($value, $daoName, $daoID, $optionGroupID, $fieldName = 'name') { + public static function optionExists($value, $daoName, $daoID, $optionGroupID, $fieldName = 'name', $domainSpecific) { $object = new $daoName(); $object->$fieldName = $value; $object->option_group_id = $optionGroupID; + if ($domainSpecific) { + $object->domain_id = CRM_Core_Config::domainID(); + } + if ($object->find(TRUE)) { return ($daoID && $object->id == $daoID) ? TRUE : FALSE; } diff --git a/CRM/Utils/Rule.php b/CRM/Utils/Rule.php index 0ea7c32e3cc3..034ba0be8941 100644 --- a/CRM/Utils/Rule.php +++ b/CRM/Utils/Rule.php @@ -715,7 +715,7 @@ public static function objectExists($value, $options) { * @return bool */ public static function optionExists($value, $options) { - return CRM_Core_OptionValue::optionExists($value, $options[0], $options[1], $options[2], CRM_Utils_Array::value(3, $options, 'name')); + return CRM_Core_OptionValue::optionExists($value, $options[0], $options[1], $options[2], CRM_Utils_Array::value(3, $options, 'name'), CRM_Utils_Array::value(4, $options, FALSE)); } /**