<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
* the handle on the mail handler that we are using
* @var object
*/
- private static $_mail = NULL;
+ public static $_mail = NULL;
/**
* We only need one instance of this object. So we use the singleton
//initialize variables. for gencode we cannot load from the
//db since the db might not be initialized
if ($loadFromDB) {
+ // initialize stuff from the settings file
+ self::$_singleton->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);
}
array(1 => array($userID, 'Integer'))
);
}
+
+ // initialize authentication source
+ self::$_singleton->initAuthSrc();
}
return self::$_singleton;
}
}
/**
- * 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) {
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 <a href=\'%1\'>Administer CiviCRM >> Global Settings</a> 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 <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> 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 <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> to set the SMTP Server.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1'))));
}
$params['host'] = $mailingInfo['smtpServer'] ? $mailingInfo['smtpServer'] : 'localhost';
// 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 <a href=\'%1\'>Administer CiviCRM >> Global Settings</a> 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 <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> 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 <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> 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 <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> 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 <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> 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 <a href=\'%1\'>Administer CiviCRM >> Global Settings</a> 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 <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> 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 <a href=\'%1\'>Administer >> System Setting >> Outbound Email</a> 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
*
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
*/
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'));