Skip to content
Snippets Groups Projects
Commit 0fb2af37 authored by Viktoria Wiebe's avatar Viktoria Wiebe Committed by Elmar Ludwig
Browse files

fix #348 - re-add option to exclude resource from global locks

parent 739bc30f
No related branches found
No related tags found
No related merge requests found
...@@ -289,6 +289,7 @@ class Resources_RoomController extends AuthenticatedController ...@@ -289,6 +289,7 @@ class Resources_RoomController extends AuthenticatedController
$this->name = Request::get('name'); $this->name = Request::get('name');
$this->description = Request::get('description'); $this->description = Request::get('description');
$this->requestable = Request::int('requestable'); $this->requestable = Request::int('requestable');
$this->lockable = Request::int('lockable', 0);
$this->room_type = Request::get('room_type'); $this->room_type = Request::get('room_type');
$this->seats = Request::int('seats'); $this->seats = Request::int('seats');
$this->booking_plan_is_public = Request::get('booking_plan_is_public'); $this->booking_plan_is_public = Request::get('booking_plan_is_public');
...@@ -363,6 +364,7 @@ class Resources_RoomController extends AuthenticatedController ...@@ -363,6 +364,7 @@ class Resources_RoomController extends AuthenticatedController
$this->room->name = $this->name; $this->room->name = $this->name;
$this->room->description = $this->description; $this->room->description = $this->description;
$this->room->requestable = strval($this->requestable); $this->room->requestable = strval($this->requestable);
$this->room->lockable = $this->lockable;
if ($GLOBALS['perm']->have_perm('root')) { if ($GLOBALS['perm']->have_perm('root')) {
$this->room->sort_position = $this->sort_position; $this->room->sort_position = $this->sort_position;
} }
...@@ -458,6 +460,7 @@ class Resources_RoomController extends AuthenticatedController ...@@ -458,6 +460,7 @@ class Resources_RoomController extends AuthenticatedController
$this->name = $this->room->name; $this->name = $this->room->name;
$this->description = $this->room->description; $this->description = $this->room->description;
$this->requestable = '1'; $this->requestable = '1';
$this->lockable = 1;
$this->room_type = $this->room->room_type; $this->room_type = $this->room->room_type;
$this->seats = $this->room->seats; $this->seats = $this->room->seats;
$this->booking_plan_is_public = (bool)$this->room->booking_plan_is_public; $this->booking_plan_is_public = (bool)$this->room->booking_plan_is_public;
......
...@@ -29,9 +29,14 @@ ...@@ -29,9 +29,14 @@
</label> </label>
<label> <label>
<input type="checkbox" name="requestable" value="1" <input type="checkbox" name="requestable" value="1"
<?= $room->requestable ? 'checked="checked"' : '' ?>> <?= $room->requestable ? 'checked' : '' ?>>
<?= _('Raum ist wünschbar') ?> <?= _('Raum ist wünschbar') ?>
</label> </label>
<label>
<input type="checkbox" name="lockable" value="1"
<?= $room->lockable ? 'checked' : '' ?>>
<?= _('Globale Buchungssperren gelten für diesen Raum') ?>
</label>
<label> <label>
<?= _('Raumtyp') ?> <?= _('Raumtyp') ?>
<input type="text" name="room_type" value="<?= htmlReady($room_type) ?>"> <input type="text" name="room_type" value="<?= htmlReady($room_type) ?>">
...@@ -42,7 +47,7 @@ ...@@ -42,7 +47,7 @@
</label> </label>
<label> <label>
<input type="checkbox" name="booking_plan_is_public" value="1" <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') ?> <?= _('Raumplan ist öffentlich zugänglich') ?>
</label> </label>
<? if ($GLOBALS['perm']->have_perm('root')): ?> <? if ($GLOBALS['perm']->have_perm('root')): ?>
......
<?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'");
}
}
...@@ -2371,7 +2371,7 @@ class Resource extends SimpleORMap implements StudipItem ...@@ -2371,7 +2371,7 @@ class Resource extends SimpleORMap implements StudipItem
} }
//Now we must check for global resource locks: //Now we must check for global resource locks:
if (GlobalResourceLock::currentlyLocked()) { if ($this->lockable && GlobalResourceLock::currentlyLocked()) {
//The resource management system is currently locked. //The resource management system is currently locked.
//permission level 'user' for all other permission //permission level 'user' for all other permission
//levels. //levels.
...@@ -2431,7 +2431,7 @@ class Resource extends SimpleORMap implements StudipItem ...@@ -2431,7 +2431,7 @@ class Resource extends SimpleORMap implements StudipItem
return false; return false;
} }
} elseif ($permission === 'autor') { } elseif ($permission === 'autor') {
if (GlobalResourceLock::currentlyLocked()) { if ($this->lockable && GlobalResourceLock::currentlyLocked()) {
//A global resource lock means no writing actions are permitted. //A global resource lock means no writing actions are permitted.
return false; return false;
} }
...@@ -2441,7 +2441,7 @@ class Resource extends SimpleORMap implements StudipItem ...@@ -2441,7 +2441,7 @@ class Resource extends SimpleORMap implements StudipItem
return false; return false;
} }
} elseif ($permission === 'tutor') { } elseif ($permission === 'tutor') {
if (GlobalResourceLock::currentlyLocked()) { if ($this->lockable && GlobalResourceLock::currentlyLocked()) {
//A global resource lock means no writing actions are permitted. //A global resource lock means no writing actions are permitted.
return false; return false;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment