Skip to content

Commit

Permalink
CRM-19380 allow for multiple from email addresses but only one per do…
Browse files Browse the repository at this point in the history
…main
  • Loading branch information
seamuslee001 committed Sep 17, 2016
1 parent 6c65445 commit 91b07c9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CRM/Admin/Form/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}

Expand Down
7 changes: 6 additions & 1 deletion CRM/Core/OptionValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Utils/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down

0 comments on commit 91b07c9

Please sign in to comment.