X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FConfig.php;h=ee12caba087bb1a71aecc402b900ac427e319478;hb=8381af809c027065ceb28f18b5530ffb3a51ada3;hp=cfda390e50130e61973839169b44b265613c27c6;hpb=28d886a901f30748f4c75552095fd4379fd3c35d;p=civicrm-core.git diff --git a/CRM/Core/Config.php b/CRM/Core/Config.php index cfda390e50..ee12caba08 100644 --- a/CRM/Core/Config.php +++ b/CRM/Core/Config.php @@ -1,7 +1,7 @@ setCoreVariables(); + self::$_singleton->_initVariables(); - // retrieve and overwrite stuff from the settings file - self::$_singleton->setCoreVariables(); + // I dont think we need to do this twice + // however just keeping this commented for now in 4.4 + // in case we hit any issues - CRM-13064 + // We can safely delete this once we release 4.4.4 + // self::$_singleton->setCoreVariables(); } $cache->set('CRM_Core_Config' . CRM_Core_Config::domainID(), self::$_singleton); } @@ -236,6 +242,9 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { array(1 => array($userID, 'Integer')) ); } + + // initialize authentication source + self::$_singleton->initAuthSrc(); } return self::$_singleton; } @@ -497,12 +506,10 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { } /** - * retrieve a mailer to send any mail from the applciation + * Retrieve a mailer to send any mail from the application * * @param boolean $persist open a persistent smtp connection, should speed up mailings - * * @access private - * * @return object */ static function &getMailer($persist = FALSE) { @@ -514,11 +521,12 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { if ($mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_REDIRECT_TO_DB || (defined('CIVICRM_MAILER_SPOOL') && CIVICRM_MAILER_SPOOL) ) { - self::$_mail = new CRM_Mailing_BAO_Spool(); + self::$_mail = self::_createMailer('CRM_Mailing_BAO_Spool', array()); } elseif ($mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_SMTP) { if ($mailingInfo['smtpServer'] == '' || !$mailingInfo['smtpServer']) { - CRM_Core_Error::fatal(ts('There is no valid smtp server setting. Click Administer CiviCRM >> Global Settings to set the SMTP Server.', array(1 => CRM_Utils_System::url('civicrm/admin/setting', 'reset=1')))); + CRM_Core_Error::debug_log_message(ts('There is no valid smtp server setting. Click Administer >> System Setting >> Outbound Email to set the SMTP Server.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')))); + CRM_Core_Error::fatal(ts('There is no valid smtp server setting. Click Administer >> System Setting >> Outbound Email to set the SMTP Server.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')))); } $params['host'] = $mailingInfo['smtpServer'] ? $mailingInfo['smtpServer'] : 'localhost'; @@ -543,33 +551,57 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { // CRM-9349 $params['persist'] = $persist; - self::$_mail = Mail::factory('smtp', $params); + self::$_mail = self::_createMailer('smtp', $params); } elseif ($mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_SENDMAIL) { if ($mailingInfo['sendmail_path'] == '' || !$mailingInfo['sendmail_path'] ) { - CRM_Core_Error::fatal(ts('There is no valid sendmail path setting. Click Administer CiviCRM >> Global Settings to set the Sendmail Server.', array(1 => CRM_Utils_System::url('civicrm/admin/setting', 'reset=1')))); + CRM_Core_Error::debug_log_message(ts('There is no valid sendmail path setting. Click Administer >> System Setting >> Outbound Email to set the sendmail server.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')))); + CRM_Core_Error::fatal(ts('There is no valid sendmail path setting. Click Administer >> System Setting >> Outbound Email to set the sendmail server.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')))); } $params['sendmail_path'] = $mailingInfo['sendmail_path']; $params['sendmail_args'] = $mailingInfo['sendmail_args']; - self::$_mail = Mail::factory('sendmail', $params); + self::$_mail = self::_createMailer('sendmail', $params); } elseif ($mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_MAIL) { - $params = array(); - self::$_mail = Mail::factory('mail', $params); + self::$_mail = self::_createMailer('mail', array()); } elseif ($mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_MOCK) { - self::$_mail = Mail::factory('mock', $params); + self::$_mail = self::_createMailer('mock', array()); + } + elseif ($mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED) { + CRM_Core_Error::debug_log_message(ts('Outbound mail has been disabled. Click Administer >> System Setting >> Outbound Email to set the OutBound Email.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')))); + CRM_Core_Session::setStatus(ts('Outbound mail has been disabled. Click Administer >> System Setting >> Outbound Email to set the OutBound Email.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')))); } else { - CRM_Core_Session::setStatus(ts('There is no valid SMTP server Setting Or SendMail path setting. Click Administer CiviCRM >> Global Settings to set the OutBound Email.', array(1 => CRM_Utils_System::url('civicrm/admin/setting', 'reset=1'))), ts('Check Settings'), 'alert'); + CRM_Core_Error::debug_log_message(ts('There is no valid SMTP server Setting Or SendMail path setting. Click Administer >> System Setting >> Outbound Email to set the OutBound Email.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')))); + CRM_Core_Session::setStatus(ts('There is no valid SMTP server Setting Or sendMail path setting. Click Administer >> System Setting >> Outbound Email to set the OutBound Email.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')))); + CRM_Core_Error::debug_var('mailing_info', $mailingInfo); } } return self::$_mail; } + /** + * Create a new instance of a PEAR Mail driver + * + * @param string $driver 'CRM_Mailing_BAO_Spool' or a name suitable for Mail::factory() + * @param array $params + * @return Mail (More specifically, a class which implements the "send()" function) + */ + public static function _createMailer($driver, $params) { + if ($driver == 'CRM_Mailing_BAO_Spool') { + $mailer = new CRM_Mailing_BAO_Spool($params); + } + else { + $mailer = Mail::factory($driver, $params); + } + CRM_Utils_Hook::alterMail($mailer, $driver, $params); + return $mailer; + } + /** * delete the web server writable directories * @@ -623,6 +655,17 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { CRM_Core_DAO::executeQuery($query); } + // This method should initialize auth sources + function initAuthSrc() { + $session = CRM_Core_Session::singleton(); + if ($session->get('userID') && !$session->get('authSrc')) { + $session->set('authSrc', CRM_Core_Permission::AUTH_SRC_LOGIN); + } + + // checksum source + CRM_Contact_BAO_Contact_Permission::initChecksumAuthSrc(); + } + /** * one function to get domain ID */