Merge pull request #16946 from civicrm/5.24
[civicrm-core.git] / CRM / Contact / Page / Dashlet.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17
18/**
616eac7e 19 * CiviCRM Dashlet.
6a488035
TO
20 */
21class CRM_Contact_Page_Dashlet extends CRM_Core_Page {
22
23 /**
fe482240 24 * Run dashboard.
6a488035 25 */
00be9182 26 public function run() {
6a488035
TO
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();
be2fb01f 36 $contactDashlets = $availableDashlets = [];
6a488035 37
dd3770bc 38 foreach ($currentDashlets as $item) {
242055d3 39 $key = "{$item['dashboard_id']}-0";
be2fb01f 40 $contactDashlets[$item['column_no']][$key] = [
dd3770bc
CW
41 'label' => $item['label'],
42 'is_reserved' => $allDashlets[$item['dashboard_id']]['is_reserved'],
be2fb01f 43 ];
dd3770bc 44 unset($allDashlets[$item['dashboard_id']]);
6a488035
TO
45 }
46
47 foreach ($allDashlets as $dashletID => $values) {
48 $key = "{$dashletID}-0";
be2fb01f 49 $availableDashlets[$key] = [
6a488035
TO
50 'label' => $values['label'],
51 'is_reserved' => $values['is_reserved'],
be2fb01f 52 ];
6a488035
TO
53 }
54
55 $this->assign('contactDashlets', $contactDashlets);
56 $this->assign('availableDashlets', $availableDashlets);
57
58 return parent::run();
59 }
96025800 60
6a488035 61}