];
$config = CRM_Core_Config::singleton();
- if (in_array('CiviContribute', $config->enableComponents)) {
- $groups['CiviContribute'] = ts('CiviContribute');
- }
-
- if (in_array('CiviMember', $config->enableComponents)) {
- $groups['CiviMember'] = ts('CiviMember');
- }
-
- if (in_array('CiviEvent', $config->enableComponents)) {
- $groups['CiviEvent'] = ts('CiviEvent');
- }
-
- if (in_array('CiviMail', $config->enableComponents)) {
- $groups['CiviMail'] = ts('CiviMail');
- }
-
- if (in_array('CiviCase', $config->enableComponents)) {
- $groups['CiviCase'] = ts('CiviCase');
- }
-
- if (in_array('CiviReport', $config->enableComponents)) {
- $groups['CiviReport'] = ts('CiviReport');
- }
- if (in_array('CiviCampaign', $config->enableComponents)) {
- $groups['CiviCampaign'] = ts('CiviCampaign');
+ foreach ($config->enableComponents as $component) {
+ $comp = CRM_Core_Component::get($component);
+ $groups[$comp->info['name']] = $comp->info['translatedName'];
}
$values = CRM_Core_Menu::getAdminLinks();
- $this->_showHide = new CRM_Core_ShowHideBlocks();
foreach ($groups as $group => $title) {
$groupId = str_replace(' ', '_', $group);
-
- $this->_showHide->addShow("id_{$groupId}_show");
- $this->_showHide->addHide("id_{$groupId}");
- $v = CRM_Core_ShowHideBlocks::links($this, $groupId, '', '', FALSE);
- if (isset($values[$group])) {
- $adminPanel[$groupId] = $values[$group];
- $adminPanel[$groupId]['show'] = $v['show'];
- $adminPanel[$groupId]['hide'] = $v['hide'];
- $adminPanel[$groupId]['title'] = $title;
- }
- else {
- $adminPanel[$groupId] = [];
- $adminPanel[$groupId]['show'] = '';
- $adminPanel[$groupId]['hide'] = '';
- $adminPanel[$groupId]['title'] = $title;
- }
+ $adminPanel[$groupId] = array_merge($values[$group] ?? [], ['title' => $title]);
}
CRM_Utils_Hook::alterAdminPanel($adminPanel);
+ foreach ($adminPanel as $groupId => $group) {
+ if (count($group) == 1) {
+ // Presumably the only thing is the title; remove the section.
+ // This is done here to give the hook a chance to edit the section.
+ unset($adminPanel[$groupId]);
+ }
+ }
$this->assign('adminPanel', $adminPanel);
- $this->_showHide->addToTemplate();
return parent::run();
}