Merge pull request #23467 from christianwach/event-caps
[civicrm-core.git] / CRM / Admin / Page / Admin.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 * Page for displaying Administer CiviCRM Control Panel.
20 */
21 class CRM_Admin_Page_Admin extends CRM_Core_Page {
22
23 /**
24 * Run page.
25 *
26 * @return string
27 */
28 public function run() {
29 Civi::resources()->addStyleFile('civicrm', 'css/admin.css');
30
31 $groups = [
32 'Customize Data and Screens' => ts('Customize Data and Screens'),
33 'Communications' => ts('Communications'),
34 'Localization' => ts('Localization'),
35 'Users and Permissions' => ts('Users and Permissions'),
36 'System Settings' => ts('System Settings'),
37 ];
38
39 $config = CRM_Core_Config::singleton();
40
41 foreach ($config->enableComponents as $component) {
42 $comp = CRM_Core_Component::get($component);
43 $groups[$comp->info['name']] = $comp->info['translatedName'];
44 }
45
46 $values = CRM_Core_Menu::getAdminLinks();
47
48 foreach ($groups as $group => $title) {
49 $groupId = str_replace(' ', '_', $group);
50 $adminPanel[$groupId] = array_merge($values[$group] ?? [], ['title' => $title]);
51 }
52
53 CRM_Utils_Hook::alterAdminPanel($adminPanel);
54 foreach ($adminPanel as $groupId => $group) {
55 if (count($group) == 1) {
56 // Presumably the only thing is the title; remove the section.
57 // This is done here to give the hook a chance to edit the section.
58 unset($adminPanel[$groupId]);
59 }
60 }
61 $this->assign('adminPanel', $adminPanel);
62 return parent::run();
63 }
64
65 }