pics/models/AdminMenu.php

63 lines
1.4 KiB
PHP

<?php
/*****************************************************************************
* AdminMenu.php
* Contains the admin navigation logic.
*
* Global Data Lab code (C) Radboud University Nijmegen
* Programming (C) Aaron van Geffen, 2015-2022
*****************************************************************************/
class AdminMenu extends Menu
{
public function __construct()
{
$user = Registry::has('user') ? Registry::get('user') : new Guest();
if (!$user->isAdmin())
return;
$this->items[0] = [
'label' => 'Admin',
'icon' => 'gear',
'badge' => ErrorLog::getCount(),
'subs' => [
[
'uri' => '/managealbums/',
'label' => 'Albums',
],
[
'uri' => '/manageassets/',
'label' => 'Assets',
],
[
'uri' => '/managetags/',
'label' => 'Tags',
],
[
'uri' => '/manageusers/',
'label' => 'Users',
],
[
'uri' => '/manageerrors/',
'label' => 'Errors',
'badge' => ErrorLog::getCount(),
],
],
];
if ($this->items[0]['badge'] == 0)
unset($this->items[0]['badge']);
foreach ($this->items as $i => $item)
{
if (isset($item['uri']))
$this->items[$i]['url'] = BASEURL . $item['uri'];
if (!isset($item['subs']))
continue;
foreach ($item['subs'] as $j => $subitem)
$this->items[$i]['subs'][$j]['url'] = BASEURL . $subitem['uri'];
}
}
}