* Return the DAO object containing to the default row of
* civicrm_mail_settings and cache it for further calls
*
- * @return object DAO with the default mail settings set
+ * @param bool $reset
+ *
+ * @return CRM_Core_BAO_MailSettings DAO with the default mail settings set
*/
- static function &defaultDAO() {
- static $dao = NULL;
- if (!$dao) {
- $dao = new self;
+ static function defaultDAO($reset = FALSE) {
+ static $mailSettings = array();
+ $domainID = CRM_Core_Config::domainID();
+ if (empty($mailSettings[$domainID]) || $reset) {
+ $dao = new self;
$dao->is_default = 1;
- $dao->domain_id = CRM_Core_Config::domainID();
+ $dao->domain_id = $domainID;
$dao->find(TRUE);
+ $mailSettings[$domainID] = $dao;
}
- return $dao;
+ return $mailSettings[$domainID];
}
/**
return $result;
}
- $params['is_ssl'] = CRM_Utils_Array::value('is_ssl', $params, FALSE);
- $params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE);
+ if(empty($params['id'])) {
+ $params['is_ssl'] = CRM_Utils_Array::value('is_ssl', $params, FALSE);
+ $params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE);
+ }
//handle is_default.
- if ($params['is_default']) {
+ if (!empty($params['is_default'])) {
$query = 'UPDATE civicrm_mail_settings SET is_default = 0 WHERE domain_id = %1';
$queryParams = array(1 => array(CRM_Core_Config::domainID(), 'Integer'));
CRM_Core_DAO::executeQuery($query, $queryParams);
* @access public
* @static
*/
- static function &create(&$params) {
+ static function create(&$params) {
$transaction = new CRM_Core_Transaction();
$mailSettings = self::add($params);
}
$transaction->commit();
-
+ CRM_Core_BAO_MailSettings::defaultDAO(TRUE);
return $mailSettings;
}
*
* @param int $id mail settings id
*
+ * @return mixed|null
* @access public
* @static
*
return $results;
}
}
-