Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06b69b18 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
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 | |
06b69b18 | 31 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
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 | * | |
355ba699 | 45 | * @return void |
6a488035 | 46 | */ |
00be9182 | 47 | public function run() { |
6a488035 | 48 | // Add dashboard js and css |
cf6f10ce | 49 | $resources = CRM_Core_Resources::singleton(); |
3d80d622 | 50 | $resources->addScriptFile('civicrm', 'js/jquery/jquery.dashboard.js', 0, 'html-header', FALSE); |
a5c5a349 | 51 | $resources->addStyleFile('civicrm', 'css/dashboard.css'); |
cf6f10ce CW |
52 | |
53 | $config = CRM_Core_Config::singleton(); | |
54 | ||
6a488035 TO |
55 | $resetCache = CRM_Utils_Request::retrieve('resetCache', 'Positive', CRM_Core_DAO::$_nullObject); |
56 | ||
57 | CRM_Utils_System::setTitle(ts('CiviCRM Home')); | |
58 | $session = CRM_Core_Session::singleton(); | |
59 | $contactID = $session->get('userID'); | |
60 | ||
61 | if ($resetCache) { | |
62 | CRM_Core_BAO_Dashboard::resetDashletCache($contactID); | |
63 | } | |
64 | ||
65 | // call hook to get html from other modules | |
66 | // ignored but needed to prevent warnings | |
67 | $contentPlacement = CRM_Utils_Hook::DASHBOARD_BELOW; | |
68 | $html = CRM_Utils_Hook::dashboard($contactID, $contentPlacement); | |
69 | if (is_array($html)) { | |
70 | $this->assign_by_ref('hookContent', $html); | |
71 | $this->assign('hookContentPlacement', $contentPlacement); | |
72 | } | |
73 | ||
74 | //check that default FROM email address, owner (domain) organization name and default mailbox are configured. | |
353ffa53 TO |
75 | $fromEmailOK = TRUE; |
76 | $ownerOrgOK = TRUE; | |
6a488035 TO |
77 | $defaultMailboxOK = TRUE; |
78 | ||
79 | // Don't put up notices if user doesn't have administer CiviCRM permission | |
80 | if (CRM_Core_Permission::check('administer CiviCRM')) { | |
81 | $destination = CRM_Utils_System::url( | |
82 | 'civicrm/dashboard', | |
83 | 'reset=1', | |
84 | FALSE, NULL, FALSE | |
85 | ); | |
86 | ||
87 | $destination = urlencode($destination); | |
88 | ||
89 | list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail(TRUE); | |
90 | ||
91 | if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') { | |
92 | $fixEmailUrl = CRM_Utils_System::url("civicrm/admin/domain", "action=update&reset=1&civicrmDestination={$destination}"); | |
93 | $this->assign('fixEmailUrl', $fixEmailUrl); | |
94 | $fromEmailOK = FALSE; | |
95 | } | |
96 | ||
97 | $domain = CRM_Core_BAO_Domain::getDomain(); | |
98 | $domainName = $domain->name; | |
99 | if (!$domainName || $domainName == 'Default Domain Name') { | |
100 | $fixOrgUrl = CRM_Utils_System::url("civicrm/admin/domain", "action=update&reset=1&civicrmDestination={$destination}"); | |
101 | $this->assign('fixOrgUrl', $fixOrgUrl); | |
102 | $ownerOrgOK = FALSE; | |
103 | } | |
104 | ||
6a488035 TO |
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 | ||
9d9fa5bc TO |
118 | $communityMessages = CRM_Core_CommunityMessages::create(); |
119 | if ($communityMessages->isEnabled()) { | |
120 | $message = $communityMessages->pick(); | |
121 | if ($message) { | |
122 | $this->assign('communityMessages', $communityMessages->evalMarkup($message['markup'])); | |
123 | } | |
124 | } | |
125 | ||
6a488035 TO |
126 | return parent::run(); |
127 | } | |
128 | } |