Skip to content

Commit

Permalink
Use value from database if provided even if null otherwise fall back …
Browse files Browse the repository at this point in the history
…to current domain as default but use the value submitted first
  • Loading branch information
seamuslee001 committed Apr 10, 2017
1 parent aa2a782 commit cccf9ae
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion CRM/SMS/BAO/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public static function getProviders($selectArr = NULL, $filter = NULL, $getActiv
}

/**
& Save a new record into the database
* @todo create a create function to do this work
* @param $values
*/
public static function saveRecord($values) {
Expand All @@ -98,11 +100,17 @@ public static function saveRecord($values) {
}

/**
* Update an SMS provider in the database.
* @todo combine with saveRecord in a create function
* @param $values
* @param int $providerId
*/
public static function updateRecord($values, $providerId) {
$values['domain_id'] = CRM_Utils_Array::value('domain_id', $values, CRM_Core_Config::domainID());
$current_domain_id = CRM_Core_DAO::getFieldValue('CRM_SMS_DAO_Provider', $providerId, 'domain_id');
if (!isset($current_domain_id) && !is_null($current_domain_id)) {
$current_domain_id = CRM_Core_Config::domainID();
}
$values['domain_id'] = CRM_Utils_Array::value('domain_id', $values, $current_domain_id);
$dao = new CRM_SMS_DAO_Provider();
$dao->id = $providerId;
if ($dao->find(TRUE)) {
Expand Down

0 comments on commit cccf9ae

Please sign in to comment.