From 6e7632d1568059b9374fe6b8ad47156fb41f0e04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Noack?= <noack@data-quest.de> Date: Mon, 17 Jul 2023 16:04:58 +0000 Subject: [PATCH] =?UTF-8?q?Resolve=20#2856=20=20"Belegungspl=C3=A4ne=20sin?= =?UTF-8?q?d=20f=C3=BCr=20Stud.IP=20Benutzer=20nur=20sichtbar,=20wenn=20di?= =?UTF-8?q?e=20Pl=C3=A4ne=20auch=20=C3=B6ffentlich=20gemacht=20werden"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #2856 Merge request studip/studip!1974 --- app/controllers/resources/admin.php | 5 ---- app/views/resources/admin/configuration.php | 8 ------ app/views/resources/search/rooms.php | 3 +-- db/migrations/5.1.50_fix_for_biest2856.php | 29 +++++++++++++++++++++ lib/models/resources/Room.class.php | 4 +-- 5 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 db/migrations/5.1.50_fix_for_biest2856.php diff --git a/app/controllers/resources/admin.php b/app/controllers/resources/admin.php index 2f6e34edf9f..f5834b3a670 100644 --- a/app/controllers/resources/admin.php +++ b/app/controllers/resources/admin.php @@ -1148,11 +1148,6 @@ class Resources_AdminController extends AuthenticatedController 'RESOURCES_ENABLE', (bool)Request::get('resources_enable') ); - $this->config->store( - 'RESOURCES_ALLOW_VIEW_RESOURCE_OCCUPATION', - (bool)Request::get('resources_allow_view_resource_occupation') - ); - $this->config->store( 'RESOURCES_ALLOW_ROOM_PROPERTY_REQUESTS', (bool)Request::get('resources_allow_room_property_requests') diff --git a/app/views/resources/admin/configuration.php b/app/views/resources/admin/configuration.php index 23ade8d19c0..5fb3e8916a4 100644 --- a/app/views/resources/admin/configuration.php +++ b/app/views/resources/admin/configuration.php @@ -14,14 +14,6 @@ </fieldset> <fieldset> <legend><?= _('Anzeigeoptionen') ?></legend> - <label> - <input type="checkbox" name="resources_allow_view_resource_occupation" - value="1" - <?= $config->RESOURCES_ALLOW_VIEW_RESOURCE_OCCUPATION == '1' - ? 'checked="checked"' - : ''?>> - <?= _('Belegungen sind sichtbar für alle Nutzer') ?> - </label> <? if ($colours): ?> <? foreach ($colours as $colour): ?> <label> diff --git a/app/views/resources/search/rooms.php b/app/views/resources/search/rooms.php index d35f0304edb..1149a1927be 100644 --- a/app/views/resources/search/rooms.php +++ b/app/views/resources/search/rooms.php @@ -47,8 +47,7 @@ Icon::create('info-circle'), ['data-dialog' => ''] ); - if (($room->booking_plan_is_public && Config::get()->RESOURCES_SHOW_PUBLIC_ROOM_PLANS) - || ($room->userHasPermission($current_user, 'autor'))) { + if ($room->bookingPlanVisibleForUser($current_user)) { $actions->addLink( $room->getActionURL('booking_plan', $booking_plan_action_params), ( diff --git a/db/migrations/5.1.50_fix_for_biest2856.php b/db/migrations/5.1.50_fix_for_biest2856.php new file mode 100644 index 00000000000..b6aea955104 --- /dev/null +++ b/db/migrations/5.1.50_fix_for_biest2856.php @@ -0,0 +1,29 @@ +<?php +/** + * @see https://gitlab.studip.de/studip/studip/-/issues/2856 + */ +final class FixForBiest2856 extends Migration +{ + public function description() + { + return 'Removes the obsolete configuration RESOURCES_ALLOW_VIEW_RESOURCE_OCCUPATION'; + } + + protected function up() + { + $query = "DELETE `config`, `config_values` + FROM `config` + LEFT JOIN `config_values` USING (`field`) + WHERE `field` = 'RESOURCES_ALLOW_VIEW_RESOURCE_OCCUPATION'"; + DBManager::get()->exec($query); + } + + protected function down() + { + $query = "INSERT INTO `config` (`field`, `value`, `type`, `range`, `section`, `mkdate`, `chdate`, `description`) + VALUES ('RESOURCES_ALLOW_VIEW_RESOURCE_OCCUPATION', '1', 'boolean', 'global', 'resources', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), 'Dürfen alle Nutzer Ressourcenbelegungen einsehen?')"; + DBManager::get()->exec($query); + } +} + + diff --git a/lib/models/resources/Room.class.php b/lib/models/resources/Room.class.php index 1c9a0e401d7..2cea825561d 100644 --- a/lib/models/resources/Room.class.php +++ b/lib/models/resources/Room.class.php @@ -647,8 +647,8 @@ class Room extends Resource */ public function bookingPlanVisibleForUser(?User $user, $time_range = []) { - return parent::bookingPlanVisibleForUser($user, $time_range) - || $this->booking_plan_is_public && Config::get()->RESOURCES_SHOW_PUBLIC_ROOM_PLANS; + return $this->booking_plan_is_public + || parent::bookingPlanVisibleForUser($user, $time_range); } -- GitLab