Skip to content

Commit

Permalink
Merge pull request civicrm#8 from ginkgostreet/status-page-1
Browse files Browse the repository at this point in the history
CRM-13823 Move dashboard notices to system check
  • Loading branch information
agh1 committed Apr 26, 2015
2 parents ee5bcbc + 9e3fed3 commit 09e1efe
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 120 deletions.
46 changes: 0 additions & 46 deletions CRM/Contact/Page/DashBoard.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ public function run() {
$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'));
Expand All @@ -71,50 +69,6 @@ public function run() {
$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();
Expand Down
25 changes: 20 additions & 5 deletions CRM/Utils/Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@ public function showPeriodicAlerts($messages = NULL, $filter = array(__CLASS__,
$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();
}
}

Expand All @@ -97,16 +98,30 @@ public function showPeriodicAlerts($messages = NULL, $filter = array(__CLASS__,
$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.
*
Expand Down
72 changes: 68 additions & 4 deletions CRM/Utils/Check/Env.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public function checkAll() {
$messages = array_merge(
$this->checkMysqlTime(),
$this->checkDebug(),
$this->checkOutboundMail()
$this->checkOutboundMail(),
$this->checkDomainNameEmail(),
$this->checkDefaultMailbox()
);
return $messages;
}
Expand All @@ -66,7 +68,7 @@ public function checkMysqlTime() {
2 => $sqlNow,
3 => $phpNow,
)),
ts('Environment Settings'),
ts('Timestamp Mismatch'),
\Psr\Log\LogLevel::ERROR
);
}
Expand All @@ -86,7 +88,7 @@ public function checkDebug() {
'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
);
}
Expand All @@ -110,12 +112,74 @@ public function checkOutboundMail() {
'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;
}
}
24 changes: 21 additions & 3 deletions CRM/Utils/Check/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ class CRM_Utils_Check_Message {
*/
private $level;

/**
* @var string
* help text (to be presented separately from the message)
*/
private $help;

/**
* @param string $name
* Symbolic name for the check.
Expand Down Expand Up @@ -105,21 +111,33 @@ public function getLevel() {
/**
* 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;
}

}
8 changes: 4 additions & 4 deletions CRM/Utils/Check/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function checkLogFileIsNotAccessible() {
$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
);
}
Expand Down Expand Up @@ -159,7 +159,7 @@ public function checkUploadsAreNotAccessible() {
2 => $privateDir,
3 => $heuristicUrl,
)),
ts('Security Warning'),
ts('Private Files Readable'),
\Psr\Log\LogLevel::WARNING
);
}
Expand Down Expand Up @@ -206,7 +206,7 @@ public function checkDirectoriesAreNotBrowseable() {
$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
);
}
Expand Down Expand Up @@ -255,7 +255,7 @@ public function checkFilesAreNotPresent() {
$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]
);
}
Expand Down
27 changes: 0 additions & 27 deletions css/civicrm.css
Original file line number Diff line number Diff line change
Expand Up @@ -3362,33 +3362,6 @@ div.m ul#civicrm-menu,
#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,
Expand Down
31 changes: 0 additions & 31 deletions templates/CRM/Contact/Page/DashBoardDashlet.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,6 @@
{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> &nbsp;{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> &nbsp;{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> &nbsp;{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">
Expand Down

0 comments on commit 09e1efe

Please sign in to comment.