Commit | Line | Data |
---|---|---|
6a488035 TO |
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 | |
cf6f10ce CW |
50 | $resources = CRM_Core_Resources::singleton(); |
51 | $resources->addScriptFile('civicrm', 'packages/jquery/plugins/jquery.dashboard.js', 0, 'html-header', FALSE); | |
52 | $resources->addStyleFile('civicrm', 'packages/jquery/css/dashboard.css'); | |
53 | ||
54 | $config = CRM_Core_Config::singleton(); | |
55 | ||
56 | // Add dashlet-specific js files | |
57 | // TODO: Need a much better way of managing on-the-fly js requirements. Require.js perhaps? | |
58 | // Checking if a specific dashlet is enabled is a pain and including the js here sucks anyway | |
59 | // So here's a compromise: | |
60 | if (in_array('CiviCase', $config->enableComponents)) { | |
61 | $resources->addScriptFile('civicrm', 'templates/CRM/Case/Form/ActivityChangeStatus.js'); | |
62 | } | |
6a488035 TO |
63 | |
64 | $resetCache = CRM_Utils_Request::retrieve('resetCache', 'Positive', CRM_Core_DAO::$_nullObject); | |
65 | ||
66 | CRM_Utils_System::setTitle(ts('CiviCRM Home')); | |
67 | $session = CRM_Core_Session::singleton(); | |
68 | $contactID = $session->get('userID'); | |
69 | ||
70 | if ($resetCache) { | |
71 | CRM_Core_BAO_Dashboard::resetDashletCache($contactID); | |
72 | } | |
73 | ||
74 | // call hook to get html from other modules | |
75 | // ignored but needed to prevent warnings | |
76 | $contentPlacement = CRM_Utils_Hook::DASHBOARD_BELOW; | |
77 | $html = CRM_Utils_Hook::dashboard($contactID, $contentPlacement); | |
78 | if (is_array($html)) { | |
79 | $this->assign_by_ref('hookContent', $html); | |
80 | $this->assign('hookContentPlacement', $contentPlacement); | |
81 | } | |
82 | ||
83 | //check that default FROM email address, owner (domain) organization name and default mailbox are configured. | |
84 | $fromEmailOK = TRUE; | |
85 | $ownerOrgOK = TRUE; | |
86 | $defaultMailboxOK = TRUE; | |
87 | ||
88 | // Don't put up notices if user doesn't have administer CiviCRM permission | |
89 | if (CRM_Core_Permission::check('administer CiviCRM')) { | |
90 | $destination = CRM_Utils_System::url( | |
91 | 'civicrm/dashboard', | |
92 | 'reset=1', | |
93 | FALSE, NULL, FALSE | |
94 | ); | |
95 | ||
96 | $destination = urlencode($destination); | |
97 | ||
98 | list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail(TRUE); | |
99 | ||
100 | if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') { | |
101 | $fixEmailUrl = CRM_Utils_System::url("civicrm/admin/domain", "action=update&reset=1&civicrmDestination={$destination}"); | |
102 | $this->assign('fixEmailUrl', $fixEmailUrl); | |
103 | $fromEmailOK = FALSE; | |
104 | } | |
105 | ||
106 | $domain = CRM_Core_BAO_Domain::getDomain(); | |
107 | $domainName = $domain->name; | |
108 | if (!$domainName || $domainName == 'Default Domain Name') { | |
109 | $fixOrgUrl = CRM_Utils_System::url("civicrm/admin/domain", "action=update&reset=1&civicrmDestination={$destination}"); | |
110 | $this->assign('fixOrgUrl', $fixOrgUrl); | |
111 | $ownerOrgOK = FALSE; | |
112 | } | |
113 | ||
6a488035 TO |
114 | if (in_array('CiviMail', $config->enableComponents) && |
115 | CRM_Core_BAO_MailSettings::defaultDomain() == "EXAMPLE.ORG" | |
116 | ) { | |
117 | $fixDefaultMailbox = CRM_Utils_System::url('civicrm/admin/mailSettings', "reset=1&civicrmDestination={$destination}"); | |
118 | $this->assign('fixDefaultMailbox', $fixDefaultMailbox); | |
119 | $defaultMailboxOK = FALSE; | |
120 | } | |
121 | } | |
122 | ||
123 | $this->assign('fromEmailOK', $fromEmailOK); | |
124 | $this->assign('ownerOrgOK', $ownerOrgOK); | |
125 | $this->assign('defaultMailboxOK', $defaultMailboxOK); | |
126 | ||
9d9fa5bc TO |
127 | $communityMessages = CRM_Core_CommunityMessages::create(); |
128 | if ($communityMessages->isEnabled()) { | |
129 | $message = $communityMessages->pick(); | |
130 | if ($message) { | |
131 | $this->assign('communityMessages', $communityMessages->evalMarkup($message['markup'])); | |
132 | } | |
133 | } | |
134 | ||
6a488035 TO |
135 | return parent::run(); |
136 | } | |
137 | } | |
138 |