3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2015
35 class CRM_Utils_Check_Env
{
38 * Run some sanity checks.
40 * @return array<CRM_Utils_Check_Message>
42 public function checkAll() {
43 $messages = array_merge(
44 $this->checkMysqlTime(),
46 $this->checkOutboundMail(),
47 $this->checkDomainNameEmail(),
48 $this->checkDefaultMailbox()
54 * Check that the MySQL time settings match the PHP time settings.
56 * @return array<CRM_Utils_Check_Message> an empty array, or a list of warnings
58 public function checkMysqlTime() {
61 $phpNow = date('Y-m-d H:i');
62 $sqlNow = CRM_Core_DAO
::singleValueQuery("SELECT date_format(now(), '%Y-%m-%d %H:%i')");
63 if (!CRM_Utils_Time
::isEqual($phpNow, $sqlNow, 2.5 * 60)) {
64 $messages[] = new CRM_Utils_Check_Message(
66 ts('Timestamps reported by MySQL (eg "%2") and PHP (eg "%3" ) are mismatched.<br /><a href="%1">Read more about this warning</a>', array(
67 1 => CRM_Utils_System
::getWikiBaseURL() . 'checkMysqlTime',
71 ts('Timestamp Mismatch'),
72 \Psr\Log\LogLevel
::ERROR
82 public function checkDebug() {
85 $config = CRM_Core_Config
::singleton();
87 $messages[] = new CRM_Utils_Check_Message(
89 ts('Warning: Debug is enabled in <a href="%1">system settings</a>. This should not be enabled on production servers.',
90 array(1 => CRM_Utils_System
::url('civicrm/admin/setting/debug', 'reset=1'))),
91 ts('Debug Mode Enabled'),
92 \Psr\Log\LogLevel
::WARNING
102 public function checkOutboundMail() {
105 $mailingInfo = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::MAILING_PREFERENCES_NAME
, 'mailing_backend');
106 if (($mailingInfo['outBound_option'] == CRM_Mailing_Config
::OUTBOUND_OPTION_REDIRECT_TO_DB
107 ||
(defined('CIVICRM_MAIL_LOG') && CIVICRM_MAIL_LOG
)
108 ||
$mailingInfo['outBound_option'] == CRM_Mailing_Config
::OUTBOUND_OPTION_DISABLED
109 ||
$mailingInfo['outBound_option'] == CRM_Mailing_Config
::OUTBOUND_OPTION_MOCK
)
111 $messages[] = new CRM_Utils_Check_Message(
113 ts('Warning: Outbound email is disabled in <a href="%1">system settings</a>. Proper settings should be enabled on production servers.',
114 array(1 => CRM_Utils_System
::url('civicrm/admin/setting/smtp', 'reset=1'))),
115 ts('Outbound Email Disabled'),
116 \Psr\Log\LogLevel
::WARNING
124 * Check that domain email and org name are set
128 public function checkDomainNameEmail() {
131 list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain
::getNameAndEmail(TRUE);
132 $domain = CRM_Core_BAO_Domain
::getDomain();
133 $domainName = $domain->name
;
134 $fixEmailUrl = CRM_Utils_System
::url("civicrm/admin/domain", "action=update&reset=1");
136 if (!$domainEmailAddress ||
$domainEmailAddress == 'info@EXAMPLE.ORG') {
137 if (!$domainName ||
$domainName == 'Default Domain Name') {
138 $msg = ts("Please enter your organization's <a href=\"%1\">name, primary address, and default FROM Email Address</a> (for system-generated emails).",
139 array(1 => $fixEmailUrl));
142 $msg = ts('Please enter a <a href="%1">default FROM Email Address</a> (for system-generated emails).',
143 array(1 => $fixEmailUrl));
146 elseif (!$domainName ||
$domainName == 'Default Domain Name') {
147 $msg = ts("Please enter your organization's <a href=\"%1\">name and primary address</a>.",
148 array(1 => $fixEmailUrl));
152 $messages[] = new CRM_Utils_Check_Message(
153 'checkDomainNameEmail',
155 ts('Complete Setup'),
156 \Psr\Log\LogLevel
::WARNING
164 * Checks if a default bounce handling mailbox is set up
168 public function checkDefaultMailbox() {
170 $config = CRM_Core_Config
::singleton();
172 if (in_array('CiviMail', $config->enableComponents
) &&
173 CRM_Core_BAO_MailSettings
::defaultDomain() == "EXAMPLE.ORG"
175 $message = new CRM_Utils_Check_Message(
176 'checkDefaultMailbox',
177 ts('Please configure a default mailbox for CiviMail.',
178 array(1 => CRM_Utils_System
::url('civicrm/admin/mailSettings', "reset=1"))),
179 ts('Configure Default Mailbox'),
180 \Psr\Log\LogLevel
::WARNING
182 $message->addHelp(ts('Learn more in the <a href="%1">user guide</a>', array(1 => 'http://book.civicrm.org/user/advanced-configuration/email-system-configuration/')));
183 $messages[] = $message;