Select Git revision
ResourceNavigation.php
Forked from
Stud.IP / Stud.IP
Source project has a limited visibility.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
ResourceNavigation.php 11.99 KiB
<?php
/**
* ResourceNavigation.php - Room management area navigation class
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* @author Moritz Strohm
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @copyright 2017
* @category Stud.IP
* @since TODO
*/
/**
* This navigagion class provides all standard navigation items for the
* room management.
*/
class ResourceNavigation extends Navigation
{
public function __construct()
{
parent::__construct(_('Raumverwaltung'));
}
public function initItem()
{
$user = User::findCurrent();
if (ResourceManager::userHasGlobalPermission($user, 'user')) {
$this->setURL('dispatch.php/room_management/overview/index');
} else {
$this->setURL('dispatch.php/room_management/overview/rooms');
}
$this->setImage(
Icon::create('resources', 'navigation', ['title' => _('Raumverwaltung')])
);
}
public function initSubNavigation()
{
$user = User::findCurrent();
$show_global_admin_actions = ResourceManager::userHasGlobalPermission(
$user,
'admin'
);
//Check if the user has permissions one at lease one room:
$user_has_rooms = RoomManager::userHasRooms($user);
$user_is_global_resource_user = ResourceManager::userHasGlobalPermission($user, 'user');
if (!$show_global_admin_actions && !$user_has_rooms && !$user_is_global_resource_user) {
return;
}
$user_is_global_resource_autor = ResourceManager::userHasGlobalPermission($user, 'autor');
parent::initSubNavigation();
//Overview tab:
if ($show_global_admin_actions) {
$overview_navigation = new Navigation(
_('Übersicht'),
'dispatch.php/room_management/overview/index'
);
$this->addSubNavigation('overview', $overview_navigation);
} else {