X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FConfig.php;h=377cec0afeb013ce2ae0dc7d1b2cca129dccdf78;hb=52df19870805bf5a2bae2388a1f6c5a0309c2d92;hp=3356f009743c654929c3ef5e4671ce633b8f552d;hpb=36ae12aed7e37a22c0a5b21b0a98ff06aa1983d3;p=civicrm-core.git diff --git a/CRM/Core/Config.php b/CRM/Core/Config.php index 3356f00974..377cec0afe 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 */ @@ -728,9 +771,12 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { SELECT TABLE_NAME as tableName FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = %1 -AND ( TABLE_NAME LIKE 'civicrm_import_job_%' -OR TABLE_NAME LIKE 'civicrm_export_temp%' -OR TABLE_NAME LIKE 'civicrm_task_action_temp%' ) +AND + ( TABLE_NAME LIKE 'civicrm_import_job_%' + OR TABLE_NAME LIKE 'civicrm_export_temp%' + OR TABLE_NAME LIKE 'civicrm_task_action_temp%' + OR TABLE_NAME LIKE 'civicrm_report_temp%' + ) "; $params = array(1 => array($dao->database(), 'String'));