$resources->addScriptFile('civicrm', 'js/jquery/jquery.dashboard.js', 0, 'html-header', FALSE);
$resources->addStyleFile('civicrm', 'css/dashboard.css');
- $config = CRM_Core_Config::singleton();
-
$resetCache = CRM_Utils_Request::retrieve('resetCache', 'Positive', CRM_Core_DAO::$_nullObject);
CRM_Utils_System::setTitle(ts('CiviCRM Home'));
$this->assign('hookContentPlacement', $contentPlacement);
}
- //check that default FROM email address, owner (domain) organization name and default mailbox are configured.
- $fromEmailOK = TRUE;
- $ownerOrgOK = TRUE;
- $defaultMailboxOK = TRUE;
-
- // Don't put up notices if user doesn't have administer CiviCRM permission
- if (CRM_Core_Permission::check('administer CiviCRM')) {
- $destination = CRM_Utils_System::url(
- 'civicrm/dashboard',
- 'reset=1',
- FALSE, NULL, FALSE
- );
-
- $destination = urlencode($destination);
-
- list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail(TRUE);
-
- if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') {
- $fixEmailUrl = CRM_Utils_System::url("civicrm/admin/domain", "action=update&reset=1&civicrmDestination={$destination}");
- $this->assign('fixEmailUrl', $fixEmailUrl);
- $fromEmailOK = FALSE;
- }
-
- $domain = CRM_Core_BAO_Domain::getDomain();
- $domainName = $domain->name;
- if (!$domainName || $domainName == 'Default Domain Name') {
- $fixOrgUrl = CRM_Utils_System::url("civicrm/admin/domain", "action=update&reset=1&civicrmDestination={$destination}");
- $this->assign('fixOrgUrl', $fixOrgUrl);
- $ownerOrgOK = FALSE;
- }
-
- if (in_array('CiviMail', $config->enableComponents) &&
- CRM_Core_BAO_MailSettings::defaultDomain() == "EXAMPLE.ORG"
- ) {
- $fixDefaultMailbox = CRM_Utils_System::url('civicrm/admin/mailSettings', "reset=1&civicrmDestination={$destination}");
- $this->assign('fixDefaultMailbox', $fixDefaultMailbox);
- $defaultMailboxOK = FALSE;
- }
- }
-
- $this->assign('fromEmailOK', $fromEmailOK);
- $this->assign('ownerOrgOK', $ownerOrgOK);
- $this->assign('defaultMailboxOK', $defaultMailboxOK);
-
$communityMessages = CRM_Core_CommunityMessages::create();
if ($communityMessages->isEnabled()) {
$message = $communityMessages->pick();
$statusMessages = array();
$statusType = 'alert';
+ uasort($messages, array(__CLASS__, 'severitySort'));
foreach ($messages as $message) {
if ($filter === TRUE || call_user_func($filter, $message->getSeverity()) >= 3) {
$statusType = (call_user_func($filter, $message->getSeverity()) >= 4) ? 'error' : $statusType;
- $statusMessages[] = $message->getMessage();
- $statusTitle = $message->getTitle();
+ $statusMessage = $message->getMessage();
+ $statusMessages[] = $statusTitle = $message->getTitle();
}
}
$statusTitle = ts('Multiple Alerts');
$statusMessage = '<ul><li>' . implode('</li><li>',$statusMessages) . '</li></ul>';
}
- else {
- $statusMessage = array_shift($statusMessages);
- }
+
// TODO: add link to status page
CRM_Core_Session::setStatus($statusMessage, $statusTitle, $statusType);
}
}
}
+ /**
+ * Sort messages based upon severity
+ *
+ * @param CRM_Utils_Check_Message $a
+ * @param CRM_Utils_Check_Message $b
+ * @return integer
+ */
+ public function severitySort($a, $b) {
+ $aSeverity = $a->getSeverity();
+ $bSeverity = $b->getSeverity();
+ if ($aSeverity == $bSeverity) {
+ return 0;
+ }
+ return (self::severityMap($aSeverity) > self::severityMap($bSeverity));
+ }
+
/**
* Get the integer value (useful for thresholds) of the severity.
*
$messages = array_merge(
$this->checkMysqlTime(),
$this->checkDebug(),
- $this->checkOutboundMail()
+ $this->checkOutboundMail(),
+ $this->checkDomainNameEmail(),
+ $this->checkDefaultMailbox()
);
return $messages;
}
2 => $sqlNow,
3 => $phpNow,
)),
- ts('Environment Settings'),
+ ts('Timestamp Mismatch'),
\Psr\Log\LogLevel::ERROR
);
}
'checkDebug',
ts('Warning: Debug is enabled in <a href="%1">system settings</a>. This should not be enabled on production servers.',
array(1 => CRM_Utils_System::url('civicrm/admin/setting/debug', 'reset=1'))),
- ts('Debug Mode'),
+ ts('Debug Mode Enabled'),
\Psr\Log\LogLevel::WARNING
);
}
'checkOutboundMail',
ts('Warning: Outbound email is disabled in <a href="%1">system settings</a>. Proper settings should be enabled on production servers.',
array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1'))),
- ts('Outbound Email Settings'),
+ ts('Outbound Email Disabled'),
\Psr\Log\LogLevel::WARNING
);
}
return $messages;
}
+ /**
+ * Check that domain email and org name are set
+ * @return array
+ */
+
+ public function checkDomainNameEmail() {
+ $messages = array();
+
+ list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail(TRUE);
+ $domain = CRM_Core_BAO_Domain::getDomain();
+ $domainName = $domain->name;
+ $fixEmailUrl = CRM_Utils_System::url("civicrm/admin/domain", "action=update&reset=1");
+
+ if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') {
+ if (!$domainName || $domainName == 'Default Domain Name') {
+ $msg = ts("Please enter your organization's <a href=\"%1\">name, primary address, and default FROM Email Address</a> (for system-generated emails).",
+ array(1 => $fixEmailUrl));
+ }
+ else {
+ $msg = ts('Please enter a <a href="%1">default FROM Email Address</a> (for system-generated emails).',
+ array(1 => $fixEmailUrl));
+ }
+ }
+ elseif (!$domainName || $domainName == 'Default Domain Name') {
+ $msg = ts("Please enter your organization's <a href=\"%1\">name and primary address</a>.",
+ array(1 => $fixEmailUrl));
+ }
+ $messages[] = new CRM_Utils_Check_Message(
+ 'checkDomainNameEmail',
+ $msg,
+ ts('Complete Setup'),
+ \Psr\Log\LogLevel::WARNING
+ );
+
+ return $messages;
+ }
+
+ /**
+ * Checks if a default bounce handling mailbox is set up
+ * @return array
+ */
+
+ public function checkDefaultMailbox() {
+ $messages = array();
+ $config = CRM_Core_Config::singleton();
+
+ if (in_array('CiviMail', $config->enableComponents) &&
+ CRM_Core_BAO_MailSettings::defaultDomain() == "EXAMPLE.ORG"
+ ) {
+ $message = new CRM_Utils_Check_Message(
+ 'checkDefaultMailbox',
+ ts('Please configure a default mailbox for CiviMail.',
+ array(1 => CRM_Utils_System::url('civicrm/admin/mailSettings', "reset=1"))),
+ ts('Configure Default Mailbox'),
+ \Psr\Log\LogLevel::WARNING
+ );
+ $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/')));
+ $messages[] = $message;
+ }
+
+ return $messages;
+ }
}
*/
private $level;
+ /**
+ * @var string
+ * help text (to be presented separately from the message)
+ */
+ private $help;
+
/**
* @param string $name
* Symbolic name for the check.
/**
* Alias for Level
* @return string
- **/
+ */
public function getSeverity() {
return $this->getLevel();
}
+ /**
+ * Set optional additional help text
+ * @param string help
+ */
+ public function addHelp($help) {
+ $this->help = $help;
+ }
+
/**
* @return array
*/
public function toArray() {
- return array(
+ $array = array(
'name' => $this->name,
'message' => $this->message,
'title' => $this->title,
- 'level' => $this->level,
+ 'severity' => $this->level,
);
+ if (!empty($this->help)) {
+ $array['help'] = $this->help;
+ }
+ return $array;
}
}
$messages[] = new CRM_Utils_Check_Message(
'checkLogFileIsNotAccessible',
ts($msg, array(1 => $log_url, 2 => $docs_url)),
- ts('Security Warning'),
+ ts('Debug Log Downloadable'),
\Psr\Log\LogLevel::CRITICAL
);
}
2 => $privateDir,
3 => $heuristicUrl,
)),
- ts('Security Warning'),
+ ts('Private Files Readable'),
\Psr\Log\LogLevel::WARNING
);
}
$messages[] = new CRM_Utils_Check_Message(
'checkDirectoriesAreNotBrowseable',
ts($msg, array(1 => $publicDir, 2 => $publicDir, 3 => $docs_url)),
- ts('Security Warning'),
+ ts('Browseable Directories'),
\Psr\Log\LogLevel::ERROR
);
}
$messages[] = new CRM_Utils_Check_Message(
'checkFilesAreNotPresent',
ts('File \'%1\' presents a security risk and should be deleted.', array(1 => $file)),
- ts('Security Warning'),
+ ts('Unsafe Files'),
$file[1]
);
}
#crm-container .crm-fb-tweet-buttons {
width: 93%;
}
-#crm-container div.finalconf-button {
- float: right;
- padding: 5px 0 0 0;
-}
-#crm-container div.finalconf-button input {
- margin: 0;
-}
-#crm-container div.finalconf-intro {
- padding-bottom: 12px;
- font-style: italic;
-}
-#crm-container h4.finalconf-item {
- border-top: 1px solid #ccc;
- padding: 8px 0 8px 10px;
- margin: 0;
-}
-#crm-container div.finalconf-itemdesc {
- font-style: italic;
- padding: 6px 12px 6px 12px;
- color: #666;
- float: right;
- width: 60%;
-}
-#crm-container h4.finalconf-btm {
- border-bottom: 1px solid #ccc;
- margin-bottom: 20px;
-}
/* classes related to batch entry operation */
.crm-container span.batch-edit,
{include file="CRM/common/dashboard.tpl"}
{include file="CRM/common/openFlashChart.tpl"}
{* Alerts for critical configuration settings. *}
-{if ! $fromEmailOK || ! $ownerOrgOK || ! $defaultMailboxOK}
- <div class="help">
- <div class="finalconf-intro">
- {ts}There are a few things to setup before using your site ...{/ts}
- </div>
- {if ! $ownerOrgOK}
- <div class="finalconf-button">
- <a href="{$fixOrgUrl}" id="fixOrgUrl" class="button"><span><div class="icon ui-icon-wrench"></div>{ts}Go{/ts}</span></a>
- </div>
- <div class="finalconf-itemdesc">{ts}Please enter your organization's name and primary address.{/ts}</div>
- <h4 class="finalconf-item"><div class="icon ui-icon-alert"></div> {ts}Organization Name{/ts}</h4>
- <div style="clear:both"></div>
- {/if}
- {if ! $fromEmailOK}
- <div class="finalconf-button">
- <a href="{$fixEmailUrl}" id="fixOrgUrl" class="button"><span><div class="icon ui-icon-wrench"></div>{ts}Go{/ts}</span></a>
- </div>
- <div class="finalconf-itemdesc">{ts}Please enter a default FROM Email Address (for system-generated emails).{/ts}</div>
- <h4 class="finalconf-item"><div class="icon ui-icon-alert"></div> {ts}From Email Address{/ts}</h4>
- <div style="clear:both"></div>
- {/if}
- {if ! $defaultMailboxOK}
- <div class="finalconf-button">
- <a href="{$fixDefaultMailbox}" id="fixDefaultMailbox" class="button"><span><div class="icon ui-icon-wrench"></div>{ts}Go{/ts}</span></a>
- </div>
- <div class="finalconf-itemdesc">{ts}Please configure a default mailbox for CiviMail.{/ts} (<a href="http://book.civicrm.org/user/advanced-configuration/email-system-configuration/" title="{ts}opens online user guide in a new window{/ts}" target="_blank">{ts}learn more{/ts}</a>)</div>
- <h4 class="finalconf-item"><div class="icon ui-icon-alert"></div> {ts}Default CiviMail Mailbox{/ts}</h4>
- <div style="clear:both"></div>
- {/if}
- </div>
-{/if}
{$communityMessages}
<div class="crm-submit-buttons">
<a href="#" id="crm-dashboard-configure" class="crm-hover-button show-add">