summaryrefslogtreecommitdiffstats
path: root/inc
diff options
context:
space:
mode:
authorSimon Rettberg2016-07-07 11:13:33 +0200
committerSimon Rettberg2016-07-07 11:13:33 +0200
commit9b73975ceb68ec7d91d3a20ba618b2b192d2dc35 (patch)
treec9ed58d6e005c0638cffdbe48a8bedab090ec65d /inc
parent[exams] Add button to zoom to selected exam period; autofill end day; show de... (diff)
downloadslx-admin-9b73975ceb68ec7d91d3a20ba618b2b192d2dc35.tar.gz
slx-admin-9b73975ceb68ec7d91d3a20ba618b2b192d2dc35.tar.xz
slx-admin-9b73975ceb68ec7d91d3a20ba618b2b192d2dc35.zip
Change menu overriding mechanism; simpler, now also supports changing the category of a module
Diffstat (limited to 'inc')
-rw-r--r--inc/dashboard.inc.php38
-rw-r--r--inc/module.inc.php12
2 files changed, 30 insertions, 20 deletions
diff --git a/inc/dashboard.inc.php b/inc/dashboard.inc.php
index 3c913b76..01572461 100644
--- a/inc/dashboard.inc.php
+++ b/inc/dashboard.inc.php
@@ -8,23 +8,37 @@ class Dashboard
public static function createMenu()
{
- global $MENU_SETTING_SORT_ORDER, $MENU_CAT_SORT_ORDER;
+ global $MENU_CAT_OVERRIDE;
$modByCategory = array();
- $all = Module::getEnabled();
+ $modById = array();
+ if (isset($MENU_CAT_OVERRIDE)) {
+ foreach ($MENU_CAT_OVERRIDE as $cat => $list) {
+ foreach ($list as $mod) {
+ $modByCategory[$cat][$mod] = false;
+ $modById[$mod] =& $modByCategory[$cat][$mod];
+ }
+ }
+ }
+ $all = Module::getEnabled(true);
foreach ($all as $module) {
$cat = $module->getCategory();
if ($cat === false)
continue;
- $modByCategory[$cat][] = $module;
+ $modId = $module->getIdentifier();
+ if (isset($modById[$modId])) {
+ $modById[$modId] = $module;
+ } else {
+ $modByCategory[$cat][$modId] = $module;
+ }
}
$currentPage = Page::getModule()->getIdentifier();
$categories = array();
$catSort = array();
foreach ($modByCategory as $catId => $modList) {
$modules = array();
- $sectionSort = array();
- foreach ($modList as $module) {
- $modId = $module->getIdentifier();
+ foreach ($modList as $modId => $module) {
+ if ($module === false)
+ continue; // Was set in $MENU_CAT_OVERRIDE, but is not enabled
$newEntry = array(
'displayName' => $module->getDisplayName(),
'identifier' => $module->getIdentifier()
@@ -34,25 +48,13 @@ class Dashboard
$newEntry['subMenu'] = self::$subMenu;
}
$modules[] = $newEntry;
- if (isset($MENU_SETTING_SORT_ORDER[$modId])) {
- $sectionSort[] = (string)($MENU_SETTING_SORT_ORDER[$modId] + 1000);
- } else {
- $sectionSort[] = '9999' . $modId;
- }
}
- array_multisort($sectionSort, SORT_ASC, $modules);
$categories[] = array(
'icon' => self::getCategoryIcon($catId),
'displayName' => Dictionary::getCategoryName($catId),
'modules' => $modules
);
- if (isset($MENU_CAT_SORT_ORDER[$catId])) {
- $catSort[] = (string)($MENU_CAT_SORT_ORDER[$catId] + 1000);
- } else {
- $catSort[] = '9999' . $catId;
- }
}
- array_multisort($catSort, SORT_ASC, $categories);
Render::setDashboard(array(
'categories' => $categories,
'url' => urlencode($_SERVER['REQUEST_URI']),
diff --git a/inc/module.inc.php b/inc/module.inc.php
index a7a767ef..960a0a87 100644
--- a/inc/module.inc.php
+++ b/inc/module.inc.php
@@ -68,12 +68,20 @@ class Module
/**
* @return \Module[] List of valid, enabled modules
*/
- public static function getEnabled()
+ public static function getEnabled($sortById = false)
{
$ret = array();
+ $sort = array();
foreach (self::$modules as $module) {
- if (self::resolveDeps($module))
+ if (self::resolveDeps($module)) {
$ret[] = $module;
+ }
+ if ($sortById) {
+ $sort[] = $module->name;
+ }
+ }
+ if ($sortById) {
+ array_multisort($sort, SORT_ASC, $ret);
}
return $ret;
}