* 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];
}
/**
* @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::defaultDomain(TRUE);
return $mailSettings;
}
return $results;
}
}
-