diff --git a/app/controllers/resources/room.php b/app/controllers/resources/room.php index 33b259c5d93fe4f57380f4f0a1fe2fa941f1d8d0..7b1ad87d543c8e729a088c22ad4950c45a47a2a9 100644 --- a/app/controllers/resources/room.php +++ b/app/controllers/resources/room.php @@ -289,6 +289,7 @@ class Resources_RoomController extends AuthenticatedController $this->name = Request::get('name'); $this->description = Request::get('description'); $this->requestable = Request::int('requestable'); + $this->lockable = Request::int('lockable', 0); $this->room_type = Request::get('room_type'); $this->seats = Request::int('seats'); $this->booking_plan_is_public = Request::get('booking_plan_is_public'); @@ -363,6 +364,7 @@ class Resources_RoomController extends AuthenticatedController $this->room->name = $this->name; $this->room->description = $this->description; $this->room->requestable = strval($this->requestable); + $this->room->lockable = $this->lockable; if ($GLOBALS['perm']->have_perm('root')) { $this->room->sort_position = $this->sort_position; } @@ -458,6 +460,7 @@ class Resources_RoomController extends AuthenticatedController $this->name = $this->room->name; $this->description = $this->room->description; $this->requestable = '1'; + $this->lockable = 1; $this->room_type = $this->room->room_type; $this->seats = $this->room->seats; $this->booking_plan_is_public = (bool)$this->room->booking_plan_is_public; diff --git a/app/views/resources/room/_add_edit_form.php b/app/views/resources/room/_add_edit_form.php index 6cd3fd2bbdad050b8c33cba4fd183d5bf83b8d3b..f0a640bb0b2e9ea852aae980a75ff705f52ae65d 100644 --- a/app/views/resources/room/_add_edit_form.php +++ b/app/views/resources/room/_add_edit_form.php @@ -29,9 +29,14 @@ </label> <label> <input type="checkbox" name="requestable" value="1" - <?= $room->requestable ? 'checked="checked"' : '' ?>> + <?= $room->requestable ? 'checked' : '' ?>> <?= _('Raum ist wünschbar') ?> </label> + <label> + <input type="checkbox" name="lockable" value="1" + <?= $room->lockable ? 'checked' : '' ?>> + <?= _('Globale Buchungssperren gelten für diesen Raum') ?> + </label> <label> <?= _('Raumtyp') ?> <input type="text" name="room_type" value="<?= htmlReady($room_type) ?>"> @@ -42,7 +47,7 @@ </label> <label> <input type="checkbox" name="booking_plan_is_public" value="1" - <?= $booking_plan_is_public ? 'checked="checked"' : '' ?>> + <?= $booking_plan_is_public ? 'checked' : '' ?>> <?= _('Raumplan ist öffentlich zugänglich') ?> </label> <? if ($GLOBALS['perm']->have_perm('root')): ?> diff --git a/db/migrations/5.1.24_biest_348.php b/db/migrations/5.1.24_biest_348.php new file mode 100644 index 0000000000000000000000000000000000000000..67f854fc69b18023fb3552f56642dbdfaf938465 --- /dev/null +++ b/db/migrations/5.1.24_biest_348.php @@ -0,0 +1,30 @@ +<?php +class Biest348 extends Migration +{ + public function description () + { + return 'Adds a column to the resources table to mark resources as lockable, default is 1.'; + } + + public function up() + { + if ($this->columnExists()) { + return; + } + + $query = 'ALTER TABLE `resources` + ADD `lockable` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1 AFTER `requestable`'; + DBManager::get()->exec($query); + } + + public function down() + { + $query = 'ALTER TABLE `resources` DROP `lockable`'; + DBManager::get()->exec($query); + } + + private function columnExists() + { + return DBManager::get()->fetchFirst("SHOW COLUMNS FROM `resources` LIKE 'lockable'"); + } +} diff --git a/lib/models/resources/Resource.class.php b/lib/models/resources/Resource.class.php index 90690397a1a4d8b70a2db005083f3022c55afb50..7fbaf575fc15b08f0fb9d2fa9e2ffe631d39cbf1 100644 --- a/lib/models/resources/Resource.class.php +++ b/lib/models/resources/Resource.class.php @@ -2371,7 +2371,7 @@ class Resource extends SimpleORMap implements StudipItem } //Now we must check for global resource locks: - if (GlobalResourceLock::currentlyLocked()) { + if ($this->lockable && GlobalResourceLock::currentlyLocked()) { //The resource management system is currently locked. //permission level 'user' for all other permission //levels. @@ -2431,7 +2431,7 @@ class Resource extends SimpleORMap implements StudipItem return false; } } elseif ($permission === 'autor') { - if (GlobalResourceLock::currentlyLocked()) { + if ($this->lockable && GlobalResourceLock::currentlyLocked()) { //A global resource lock means no writing actions are permitted. return false; } @@ -2441,7 +2441,7 @@ class Resource extends SimpleORMap implements StudipItem return false; } } elseif ($permission === 'tutor') { - if (GlobalResourceLock::currentlyLocked()) { + if ($this->lockable && GlobalResourceLock::currentlyLocked()) { //A global resource lock means no writing actions are permitted. return false; }