Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/**
* search.php - contains Resources_SearchController
*
* 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_SearchController contains search actions for resources.
*/
class Resources_SearchController extends AuthenticatedController
{
public function rooms_action()
{
if (!$GLOBALS['perm']->have_perm('autor')) {
throw new AccessDeniedException();
}
PageLayout::setTitle(
_('Raumsuche')
);
if (Navigation::hasItem('/search/rooms')) {
Navigation::activateItem('/search/rooms');
}
//Build sidebar:
$sidebar = Sidebar::get();
$room_search_widget = new RoomSearchWidget(
URLHelper::getLink(
'dispatch.php/resources/search/rooms'
)
);
$sidebar->addWidget($room_search_widget);
$resource_tree_widget = new RoomSearchTreeWidget(
Location::findAll()
);
$search_ressource = explode('_', Request::get('special__building_location'));
if ($room_search_widget->searchResetRequested() || count($search_ressource) != 2) {
$resource_tree_widget->setCurrentResourceId();
} else {
$resource_tree_widget->setCurrentResourceId($search_ressource[1]);
}
$sidebar->addWidget($resource_tree_widget);
$this->current_user = User::findCurrent();
if (ResourceManager::userHasGlobalPermission($this->current_user)) {
$room_clipboard_widget = new RoomClipboardWidget();
$sidebar->addWidget($room_clipboard_widget);
$this->clipboard_widget_id = $room_clipboard_widget->getClipboardWidgetId();
}
$this->tree_selected_resource = Request::get('tree_selected_resource');
$this->form_submitted = false;
if ($this->tree_selected_resource) {
$resource = Resource::find($this->tree_selected_resource);
if (!$resource) {
PageLayout::postError(
_('Die gewählte Ressource wurde nicht in der Datenbank gefunden!')
);
return;
}
$resource = $resource->getDerivedClassInstance();
if ($resource) {
$this->redirect(
$resource->getActionURL('show')
);
}
} else {
$this->form_submitted = $room_search_widget->searchRequested();
$this->rooms = $room_search_widget->getResults();
$messages = PageLayout::getMessages();
$this->has_errors = false;
foreach ($messages as $message) {
if ($message->class == 'error') {
$this->has_errors = true;
}
PageLayout::postMessage($message);
}
}
}
}