Merge pull request #159 from lcdservices/master
[civicrm-core.git] / CRM / Contact / Page / DashBoard.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2013
32 * $Id$
33 *
34 */
35
36 /**
37 * CiviCRM Dashboard
38 *
39 */
40 class CRM_Contact_Page_DashBoard extends CRM_Core_Page {
41
42 /**
43 * Run dashboard
44 *
45 * @return none
46 * @access public
47 */
48 function run() {
49 // Add dashboard js and css
50 CRM_Core_Resources::singleton()
51 ->addScriptFile('civicrm', 'packages/jquery/plugins/jquery.dashboard.js', 0, 'html-header', FALSE)
52 ->addStyleFile('civicrm', 'packages/jquery/css/dashboard.css');
53
54 $resetCache = CRM_Utils_Request::retrieve('resetCache', 'Positive', CRM_Core_DAO::$_nullObject);
55
56 CRM_Utils_System::setTitle(ts('CiviCRM Home'));
57 $session = CRM_Core_Session::singleton();
58 $contactID = $session->get('userID');
59
60 if ($resetCache) {
61 CRM_Core_BAO_Dashboard::resetDashletCache($contactID);
62 }
63
64 // call hook to get html from other modules
65 // ignored but needed to prevent warnings
66 $contentPlacement = CRM_Utils_Hook::DASHBOARD_BELOW;
67 $html = CRM_Utils_Hook::dashboard($contactID, $contentPlacement);
68 if (is_array($html)) {
69 $this->assign_by_ref('hookContent', $html);
70 $this->assign('hookContentPlacement', $contentPlacement);
71 }
72
73 //check that default FROM email address, owner (domain) organization name and default mailbox are configured.
74 $fromEmailOK = TRUE;
75 $ownerOrgOK = TRUE;
76 $defaultMailboxOK = TRUE;
77
78 // Don't put up notices if user doesn't have administer CiviCRM permission
79 if (CRM_Core_Permission::check('administer CiviCRM')) {
80 $destination = CRM_Utils_System::url(
81 'civicrm/dashboard',
82 'reset=1',
83 FALSE, NULL, FALSE
84 );
85
86 $destination = urlencode($destination);
87
88 list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail(TRUE);
89
90 if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') {
91 $fixEmailUrl = CRM_Utils_System::url("civicrm/admin/domain", "action=update&reset=1&civicrmDestination={$destination}");
92 $this->assign('fixEmailUrl', $fixEmailUrl);
93 $fromEmailOK = FALSE;
94 }
95
96 $domain = CRM_Core_BAO_Domain::getDomain();
97 $domainName = $domain->name;
98 if (!$domainName || $domainName == 'Default Domain Name') {
99 $fixOrgUrl = CRM_Utils_System::url("civicrm/admin/domain", "action=update&reset=1&civicrmDestination={$destination}");
100 $this->assign('fixOrgUrl', $fixOrgUrl);
101 $ownerOrgOK = FALSE;
102 }
103
104 $config = CRM_Core_Config::singleton();
105 if (in_array('CiviMail', $config->enableComponents) &&
106 CRM_Core_BAO_MailSettings::defaultDomain() == "EXAMPLE.ORG"
107 ) {
108 $fixDefaultMailbox = CRM_Utils_System::url('civicrm/admin/mailSettings', "reset=1&civicrmDestination={$destination}");
109 $this->assign('fixDefaultMailbox', $fixDefaultMailbox);
110 $defaultMailboxOK = FALSE;
111 }
112 }
113
114 $this->assign('fromEmailOK', $fromEmailOK);
115 $this->assign('ownerOrgOK', $ownerOrgOK);
116 $this->assign('defaultMailboxOK', $defaultMailboxOK);
117
118 return parent::run();
119 }
120 }
121