Merge pull request #17151 from eileenmcnaughton/actsched
[civicrm-core.git] / CRM / Contact / Page / Dashlet.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17
18 /**
19 * CiviCRM Dashlet.
20 */
21 class CRM_Contact_Page_Dashlet extends CRM_Core_Page {
22
23 /**
24 * Run dashboard.
25 */
26 public function run() {
27 CRM_Utils_System::setTitle(ts('Dashlets'));
28
29 $this->assign('admin', CRM_Core_Permission::check('administer CiviCRM'));
30
31 // get all dashlets
32 $allDashlets = CRM_Core_BAO_Dashboard::getDashlets(FALSE);
33
34 // get dashlets for logged in contact
35 $currentDashlets = CRM_Core_BAO_Dashboard::getContactDashlets();
36 $contactDashlets = $availableDashlets = [];
37
38 foreach ($currentDashlets as $item) {
39 $key = "{$item['dashboard_id']}-0";
40 $contactDashlets[$item['column_no']][$key] = [
41 'label' => $item['label'],
42 'is_reserved' => $allDashlets[$item['dashboard_id']]['is_reserved'],
43 ];
44 unset($allDashlets[$item['dashboard_id']]);
45 }
46
47 foreach ($allDashlets as $dashletID => $values) {
48 $key = "{$dashletID}-0";
49 $availableDashlets[$key] = [
50 'label' => $values['label'],
51 'is_reserved' => $values['is_reserved'],
52 ];
53 }
54
55 $this->assign('contactDashlets', $contactDashlets);
56 $this->assign('availableDashlets', $availableDashlets);
57
58 return parent::run();
59 }
60
61 }