aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElmar Ludwig <elmar.ludwig@uni-osnabrueck.de>2022-07-15 21:30:23 +0200
committerElmar Ludwig <elmar.ludwig@uni-osnabrueck.de>2022-07-15 21:30:23 +0200
commit213be145b03c7ba2172e9f28d13acf03c0ea26ab (patch)
tree01ced191cb033b50f494d364c1d1850e781dc9e9
parent3ce9a8e970eeae0895a5efbc4337f5deeea351c2 (diff)
Revert "add features to public room-list, closes #1306"v5.0.2
This reverts commit e251678bb8ba8ab8d5c99acac6123edf24445a39.
-rw-r--r--app/controllers/room_management/overview.php50
-rw-r--r--app/views/resources/_common/_action_menu.php118
-rw-r--r--app/views/resources/_common/_grouped_room_list.php61
-rw-r--r--app/views/resources/_common/_resource_tr.php144
4 files changed, 186 insertions, 187 deletions
diff --git a/app/controllers/room_management/overview.php b/app/controllers/room_management/overview.php
index d98ba9f..b4f1d63 100644
--- a/app/controllers/room_management/overview.php
+++ b/app/controllers/room_management/overview.php
@@ -36,31 +36,19 @@ class RoomManagement_OverviewController extends AuthenticatedController
}
}
parent::before_filter($action, $args);
- $this->user = User::findCurrent();
- $this->show_resource_actions = (
- ResourceManager::userHasGlobalPermission($this->user, 'autor')
- ||
- ResourceManager::userHasResourcePermissions($this->user, 'autor')
- );
- $this->show_admin_actions = (
- $this->user_is_global_resource_admin
- ||
- ResourceManager::userHasResourcePermissions($this->user)
- ||
- $GLOBALS['perm']->have_perm('root')
- );
+ if ($action == 'public_booking_plans') {
+ //Nothing else to be done in that case.
+ return;
+ }
+
+ $this->user = User::findCurrent();
$this->user_is_global_resource_user = ResourceManager::userHasGlobalPermission($this->user);
$this->user_is_root = $GLOBALS['perm']->have_perm('root');
$this->user_is_global_resource_admin = ResourceManager::userHasGlobalPermission(
$this->user,
'admin'
) || $this->user_is_root;
- $this->show_global_admin_actions = $this->user_is_global_resource_admin
- && ResourceManager::userHasGlobalPermission(
- $this->user,
- 'admin'
- );
}
public function index_action()
@@ -77,6 +65,20 @@ class RoomManagement_OverviewController extends AuthenticatedController
throw new AccessDeniedException();
}
+ $this->show_resource_actions = (
+ ResourceManager::userHasGlobalPermission($this->user, 'autor')
+ ||
+ ResourceManager::userHasResourcePermissions($this->user, 'autor')
+ );
+
+ $this->show_admin_actions = (
+ $this->user_is_global_resource_admin
+ ||
+ ResourceManager::userHasResourcePermissions($this->user)
+ ||
+ $GLOBALS['perm']->have_perm('root')
+ );
+
if (!$this->show_admin_actions) {
$this->redirect($this->url_for('/rooms'));
return;
@@ -383,6 +385,11 @@ class RoomManagement_OverviewController extends AuthenticatedController
} else {
$this->rooms = Room::findAll();
}
+
+ $this->show_global_admin_actions = ResourceManager::userHasGlobalPermission(
+ $this->user,
+ 'admin'
+ );
} else {
//Get only the locations for which
//the user has at least user permissions:
@@ -410,6 +417,11 @@ class RoomManagement_OverviewController extends AuthenticatedController
ORDER BY sort_position DESC, name ASC, mkdate ASC";
$this->rooms = Room::findBySql($rooms_sql, $rooms_parameter);
+
+ $this->show_global_admin_actions = ResourceManager::userHasGlobalPermission(
+ $this->user,
+ 'admin'
+ );
}
if (!$this->rooms) {
@@ -467,4 +479,4 @@ class RoomManagement_OverviewController extends AuthenticatedController
);
}
}
-}
+} \ No newline at end of file
diff --git a/app/views/resources/_common/_action_menu.php b/app/views/resources/_common/_action_menu.php
deleted file mode 100644
index cdd63c9..0000000
--- a/app/views/resources/_common/_action_menu.php
+++ /dev/null
@@ -1,118 +0,0 @@
-<?php
-//Build the actions as array. Ordering is done by array indexes.
-
-$actions = [];
-if ($show_user_actions) {
- $actions['0010'] = [
- $resource->getActionLink('show'),
- _('Details'),
- Icon::create('info-circle'),
- ['data-dialog' => 'size=auto']
- ];
-
- $actions['0020'] = [
- $resource->getActionLink('booking_plan'),
- _('Belegungsplan'),
- Icon::create('timetable')
- ];
-
- $actions['0030'] = [
- $resource->getActionLink('semester_plan'),
- _('Semester-Belegungsplan'),
- Icon::create('timetable'),
- ['target' => '_blank']
- ];
- if ($show_admin_actions) {
- $actions['0040'] = [
- $resource->getActionLink('permissions'),
- _('Berechtigungen verwalten'),
- Icon::create('roles2'),
- ['data-dialog' => 'size=auto']
- ];
- $actions['0050'] = [
- $resource->getActionLink('temporary_permissions'),
- _('Temporäre Berechtigungen verwalten'),
- Icon::create('roles2'),
- ['data-dialog' => 'size=auto']
- ];
- $actions['0060'] = [
- $resource->getActionLink('edit'),
- _('Bearbeiten'),
- Icon::create('edit'),
- ['data-dialog' => 'size=auto']
- ];
- }
- if ($show_autor_actions) {
- $actions['0070'] = [
- $resource->getActionLink(
- 'assign-undecided',
- ['no_reload' => 1]
- ),
- _('Buchen'),
- Icon::create('lock-locked'),
- ['data-dialog' => 'size=big']
- ];
- if ($show_global_admin_actions) {
- $actions['0080'] = [
- $resource->getActionLink(
- 'delete_bookings',
- ['no_reload' => 1]
- ),
- _('Buchungen löschen'),
- Icon::create('trash'),
- ['data-dialog' => 'size=auto']
- ];
- }
- }
- if ($show_user_actions) {
- $actions['0090'] = [
- $resource->getActionLink('export_bookings'),
- _('Buchungen exportieren'),
- Icon::create('file-excel'),
- ['data-dialog' => 'size=auto']
- ];
- }
- $actions['0100'] = [
- $resource->getActionLink('files'),
- _('Dateien anzeigen'),
- Icon::create($resource->hasFiles() ? 'folder-full' : 'folder-empty')
- ];
- if ($show_global_admin_actions) {
- $actions['0110'] = [
- $resource->getActionLink('delete'),
- _('Löschen'),
- Icon::create('trash'),
- ['data-dialog' => '']
- ];
- }
-} else {
- if ($resource->propertyExists('booking_plan_is_public')) {
- if ($resource->getProperty('booking_plan_is_public')) {
- $actions['0020'] = [
- $resource->getActionLink('booking_plan'),
- _('Belegungsplan anzeigen'),
- Icon::create('timetable'),
- ['target' => '_blank']
- ];
- }
- }
-}
-//Add additional actions for the action menu, if set:
-if (isset($additional_actions) && is_array($additional_actions)) {
- $actions = array_merge($actions, $additional_actions);
-}
-//Now we filter and sort the actions by key:
-$actions = array_filter($actions, 'is_array');
-ksort($actions);
-$action_menu = ActionMenu::get()->setContext($resource);
-//And finally we add the actions to the action menu:
-foreach ($actions as $action) {
- $action_menu->addLink(
- $action[0],
- $action[1],
- $action[2],
- (isset($action[3]) && is_array($action[3])) ? $action[3] : []
- );
-}
-?>
-<?= $action_menu->render() ?>
diff --git a/app/views/resources/_common/_grouped_room_list.php b/app/views/resources/_common/_grouped_room_list.php
index d31fd31..c9a1237 100644
--- a/app/views/resources/_common/_grouped_room_list.php
+++ b/app/views/resources/_common/_grouped_room_list.php
@@ -1,15 +1,15 @@
<?
/**
- * Template parameters:
- * - $title: The list title
- * - $grouped_rooms: The rooms, grouped by RoomManager::groupRooms
- * - $link_template: An optional link template where the room-ID is
- * represented by the only "%s" placeholder.
- * If $link_template is not set, the link to the booking plan
- * of the room is generated.
- * - $show_in_dialog: Whether to show the room link in a dialog (true)
- * or not (false).
- */
+Template parameters:
+- $title: The list title
+- $grouped_rooms: The rooms, grouped by RoomManager::groupRooms
+- $link_template: An optional link template where the room-ID is
+ represented by the only "%s" placeholder.
+ If $link_template is not set, the link to the booking plan
+ of the room is generated.
+- $show_in_dialog: Whether to show the room link in a dialog (true)
+ or not (false).
+*/
?>
<? if ($grouped_rooms) : ?>
<? if ($title) : ?>
@@ -17,63 +17,46 @@
<? endif ?>
<? foreach ($grouped_rooms as $group) : ?>
<?
- $location = $group['location'];
+ $location = $group['location'];
$buildings = $group['buildings'];
?>
<div class="studip-widget-wrapper">
<article class="studip">
<header><h1><?= htmlReady($location->name) ?></h1></header>
<? foreach ($buildings as $building_group) : ?>
+ <?
+ $building = $building_group['building'];
+ $rooms = $building_group['rooms'];
+ ?>
<article class="studip toggle">
- <header><h1><a href="#"><?= htmlReady($building_group['building']->name) ?></a></h1></header>
+ <header><h1><a href="#"><?= htmlReady($building->name) ?></a></h1></header>
<section>
<table class="default">
<thead>
- <tr>
- <th>
- <?= _('Raum') ?>
- </th>
- <th class="actions">
- <?= _('Aktionen') ?>
- </th>
- </tr>
+ <tr><th><?= _('Raum') ?></th></tr>
</thead>
<tbody>
- <? foreach ($building_group['rooms'] as $resource) : ?>
+ <? foreach ($rooms as $room) : ?>
<?
$room_link = '';
if ($link_template) {
$room_link = $controller->link_for(
sprintf(
$link_template,
- $resource->id
+ $room->id
)
);
} else {
- $room_link = $resource->getActionLink('booking_plan');
+ $room_link = $room->getActionLink('booking_plan');
}
?>
<tr>
<td>
<a href="<?= $room_link ?>"
- <?= $show_in_dialog ? 'data-dialog="size=big"' : '' ?>>
- <?= htmlReady($resource->name) ?>
+ <?= $show_in_dialog ? 'data-dialog="size=big"' : '' ?>>
+ <?= htmlReady($room->name) ?>
</a>
</td>
- <td class="actions">
- <?
- $perms = [
- 'show_global_admin_actions' => $show_global_admin_actions,
- 'show_admin_actions' => $resource->userHasPermission($user, 'admin'),
- 'show_tutor_actions' => $resource->userHasPermission($user, 'tutor'),
- 'show_autor_actions' => $resource->userHasPermission($user, 'autor'),
- 'show_user_actions' => $resource->userHasPermission($user, 'user'),
- 'user_has_booking_rights' => $resource->userHasBookingRights($user)];
- ?>
- <?= $this->render_partial('resources/_common/_action_menu.php',
- compact('resource') + $perms
- );?>
- </td>
</tr>
<? endforeach ?>
</tbody>
diff --git a/app/views/resources/_common/_resource_tr.php b/app/views/resources/_common/_resource_tr.php
index 7201d23..4210e39 100644
--- a/app/views/resources/_common/_resource_tr.php
+++ b/app/views/resources/_common/_resource_tr.php
@@ -153,17 +153,139 @@
|| $show_tutor_actions || $show_admin_actions
|| $show_global_admin_actions || $additional_actions): ?>
<td class="actions">
- <?= $this->render_partial('resources/_common/_action_menu.php',
- compact(
- 'show_user_actions',
- 'show_autor_actions',
- 'show_autor_actions',
- 'show_admin_actions',
- 'show_global_admin_actions',
- 'additional_actions',
- 'resource'
- )
- );?>
+ <?
+ //Build the actions as array. Ordering is done by array indexes.
+
+ $actions = [];
+ $action_menu = ActionMenu::get();
+ if ($show_user_actions) {
+ $actions['0010'] = [
+ $resource->getActionLink('show'),
+ _('Details'),
+ Icon::create('info-circle'),
+ ['data-dialog' => 'size=auto']
+ ];
+
+ $actions['0020'] = [
+ $resource->getActionLink('booking_plan'),
+ _('Belegungsplan'),
+ Icon::create('timetable')
+ ];
+
+ $actions['0030'] = [
+ $resource->getActionLink('semester_plan'),
+ _('Semester-Belegungsplan'),
+ Icon::create('timetable'),
+ ['target' => '_blank']
+ ];
+ if ($show_admin_actions) {
+ $actions['0040'] = [
+ $resource->getActionLink('permissions'),
+ _('Berechtigungen verwalten'),
+ Icon::create('roles2'),
+ ['data-dialog' => 'size=auto']
+ ];
+ $actions['0050'] = [
+ $resource->getActionLink('temporary_permissions'),
+ _('Temporäre Berechtigungen verwalten'),
+ Icon::create('roles2'),
+ ['data-dialog' => 'size=auto']
+ ];
+ $actions['0060'] = [
+ $resource->getActionLink('edit'),
+ _('Bearbeiten'),
+ Icon::create('edit'),
+ ['data-dialog' => 'size=auto']
+ ];
+ }
+ if ($show_autor_actions) {
+ $actions['0070'] = [
+ $resource->getActionLink(
+ 'assign-undecided',
+ [
+ 'no_reload' => '1'
+ ]
+ ),
+ _('Buchen'),
+ Icon::create('lock-locked'),
+ [
+ 'data-dialog' => 'size=big'
+ ]
+ ];
+ if ($show_global_admin_actions) {
+ $actions['0080'] = [
+ $resource->getActionLink(
+ 'delete_bookings',
+ [
+ 'no_reload' => '1'
+ ]
+ ),
+ _('Buchungen löschen'),
+ Icon::create('trash'),
+ ['data-dialog' => 'size=auto']
+ ];
+ }
+ }
+ if ($show_user_actions) {
+ $actions['0090'] = [
+ $resource->getActionLink('export_bookings'),
+ _('Buchungen exportieren'),
+ Icon::create('file-excel'),
+ ['data-dialog' => 'size=auto']
+ ];
+ }
+ $actions['0100'] = [
+ $resource->getActionLink('files'),
+ _('Dateien anzeigen'),
+ Icon::create(
+ $resource->hasFiles()
+ ? 'folder-full'
+ : 'folder-empty'
+ ),
+ []
+ ];
+ if ($show_global_admin_actions) {
+ $actions['0110'] = [
+ $resource->getActionLink('delete'),
+ _('Löschen'),
+ Icon::create('trash'),
+ ['data-dialog' => '']
+ ];
+ }
+ } else {
+ if ($resource->propertyExists('booking_plan_is_public')) {
+ if ($resource->getProperty('booking_plan_is_public')) {
+ $actions['0020'] = [
+ $resource->getActionLink('booking_plan'),
+ _('Belegungsplan anzeigen'),
+ Icon::create('timetable'),
+ [
+ 'target' => '_blank'
+ ]
+ ];
+ }
+ }
+ }
+ //Add additional actions for the action menu, if set:
+ if (is_array($additional_actions)) {
+ $actions = array_merge($actions, $additional_actions);
+ }
+ //Now we sort the actions by key:
+ ksort($actions);
+
+ //And finally we add the actions to the action menu:
+ foreach ($actions as $action) {
+ if (is_array($action)) {
+ $action_menu->addLink(
+ $action[0],
+ $action[1],
+ $action[2],
+ is_array($action[3]) ? $action[3] : []
+ );
+ }
+ }
+ ?>
+ <?= $action_menu->render() ?>
</td>
<? endif ?>
</tr>