$select = implode(',', $selectArr);
$dao->selectAdd($select);
}
+ $dao->whereAdd("(domain_id = " . CRM_Core_Config::domainID() . " OR domain_id IS NULL)");
$dao->orderBy($orderBy);
$dao->find();
while ($dao->fetch()) {
}
/**
+ * Save a new record into the database
+ * @todo create a create function to do this work
* @param $values
*/
public static function saveRecord($values) {
+ $values['domain_id'] = CRM_Utils_Array::value('domain_id', $values, CRM_Core_Config::domainID());
$dao = new CRM_SMS_DAO_Provider();
$dao->copyValues($values);
$dao->save();
}
/**
+ * 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) {
+ $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)) {
$dao = new CRM_SMS_DAO_Provider();
$dao->id = $providerID;
+ $dao->whereAdd = "(domain_id = " . CRM_Core_Config::domainID() . "OR domain_id IS NULL)";
if (!$dao->find(TRUE)) {
return NULL;
}
if ($rev == '4.7.13') {
$preUpgradeMessage .= '<p>' . ts('A new permission has been added called %1 This Permission is now used to control access to the Manage Tags screen', array(1 => 'manage tags')) . '</p>';
}
- if ($rev == '4.7.19') {
- $check = CRM_Core_DAO::singleValueQuery("SELECT count(id) FROM civicrm_domain");
- $smsCheck = CRM_Core_DAO::singleValueQuery("SELECT count(id) FROM civicrm_sms_provider");
- if ($check > 1 && (bool) $smsCheck) {
- $postUpgradeMessage .= '<p>civicrm_sms_provider ' . ts('has now had a domain id column added. As there is more than 1 domains in this install you need to manually set the domain id for the providers in this install') . '</p>';
- }
- }
}
/**
}
if ($rev == '4.7.19') {
$postUpgradeMessage .= '<br /><br />' . ts('Default version of the following System Workflow Message Templates have been modified: <ul><li>Additional Payment Receipt or Refund Notification</li></ul> If you have modified these templates, please review the new default versions and implement updates as needed to your copies (Administer > Communications > Message Templates > System Workflow Messages).');
+ $check = CRM_Core_DAO::singleValueQuery("SELECT count(id) FROM civicrm_domain");
+ $smsCheck = CRM_Core_DAO::singleValueQuery("SELECT count(id) FROM civicrm_sms_provider");
+ if ($check > 1 && (bool) $smsCheck) {
+ $postUpgradeMessage .= '<p>civicrm_sms_provider ' . ts('has now had a domain id column added. As there is more than 1 domains in this install you need to manually set the domain id for the providers in this install') . '</p>';
+ }
}
}
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
+/**
+ * Adjust Metadata for Create action.
+ *
+ * The metadata is used for setting defaults, documentation & validation.
+ *
+ * @param array $params
+ * Array of parameters determined by getfields.
+ */
+function _civicrm_api3_sms_provider_create_spec(&$params) {
+ $params['domain_id']['api.default'] = CRM_Core_Config::domainID();
+}
+
/**
* Get an sms_provider.
*