Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-18515 - Allow Payment Processor with same name when using multi-d… #8344

Merged
merged 2 commits into from
Oct 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CRM/Admin/Form/PaymentProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ public function buildQuickForm($check = FALSE) {
$this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array(
'CRM_Financial_DAO_PaymentProcessor',
$this->_id,
'name',
CRM_Core_Config::domainID(),
));

$this->add('text', 'description', ts('Description'),
Expand Down
10 changes: 7 additions & 3 deletions CRM/Core/DAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -723,14 +723,18 @@ public static function transaction($type) {
* @param string $fieldName
* The name of the field in the DAO.
*
* @param string $domainID
* The id of the domain. Object exists only for the given domain.
*
* @return bool
* true if object exists
*/
public static function objectExists($value, $daoName, $daoID, $fieldName = 'name') {
public static function objectExists($value, $daoName, $daoID, $fieldName = 'name', $domainID = NULL) {
$object = new $daoName();
$object->$fieldName = $value;

$config = CRM_Core_Config::singleton();
if ($domainID) {
$object->domain_id = $domainID;
}

if ($object->find(TRUE)) {
return ($daoID && $object->id == $daoID) ? TRUE : FALSE;
Expand Down
4 changes: 2 additions & 2 deletions CRM/Utils/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ public static function htmlFile($elementValue) {
* @param string $value
* The value of the field we are checking.
* @param array $options
* The daoName and fieldName (optional ).
* The daoName, fieldName (optional) and DomainID (optional).
*
* @return bool
* true if object exists
Expand All @@ -706,7 +706,7 @@ public static function objectExists($value, $options) {
$name = $options[2];
}

return CRM_Core_DAO::objectExists($value, CRM_Utils_Array::value(0, $options), CRM_Utils_Array::value(1, $options), CRM_Utils_Array::value(2, $options, $name));
return CRM_Core_DAO::objectExists($value, CRM_Utils_Array::value(0, $options), CRM_Utils_Array::value(1, $options), CRM_Utils_Array::value(2, $options, $name), CRM_Utils_Array::value(3, $options));
}

/**
Expand Down