Select Git revision
room_request.php
Forked from
Stud.IP / Stud.IP
Source project has a limited visibility.
-
Moritz Strohm authoredMoritz Strohm authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
room_request.php 97.64 KiB
<?php
/**
* request.php - contains Resources_RequestController
*
* 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 <strohm@data-quest.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @copyright 2017-2019
* @category Stud.IP
* @since 4.5
*/
/**
* Resources_RequestController contains resource request functionality.
*/
class Resources_RoomRequestController extends AuthenticatedController
{
public function before_filter(&$action, &$args)
{
parent::before_filter($action, $args);
$this->current_user = User::findCurrent();
if (in_array($action, ['overview', 'planning', 'export_list', 'resolve', 'decline'])) {
$this->current_user = User::findCurrent();
$user_is_global_resource_autor = ResourceManager::userHasGlobalPermission($this->current_user, 'autor');
if (!RoomManager::userHasRooms($this->current_user, 'autor', true) && !$user_is_global_resource_autor) {
throw new AccessDeniedException(_('Ihre Berechtigungen an Räumen reichen nicht aus, um die Anfrageliste anzeigen zu können!'));
}
$this->available_rooms = RoomManager::getUserRooms($this->current_user, 'autor', true);
$this->selected_room_ids = [];
$this->filter =& $_SESSION[__CLASS__]['filter'];
if (in_array($action, ['resolve', 'decline'])) {
$this->filter['get_only_request_ids'] = true;
$this->filter['filter_request_id'] = $args[0];
} else {
$this->filter['get_only_request_ids'] = false;
}
if ($action === 'planning') {
$this->filter['request_periods'] ='periodic';
}
if (Request::get('reset_filter')) {
$this->filter = [
'marked' => -1,
'own_requests' => 1,
'request_status' => 'open'
];
} else {
if (Request::option('institut_id')) {
$GLOBALS['user']->cfg->store('MY_INSTITUTES_DEFAULT', Request::option('institut_id'));
}
if (Request::option('semester_id')) {
$GLOBALS['user']->cfg->store('MY_COURSES_SELECTED_CYCLE', Request::option('semester_id'));
}
if (Request::option('request_status')) {
$this->filter['request_status'] = Request::get('request_status');
}
if (!Semester::find($GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE)) {
$GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE = Semester::findCurrent()->id;