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
$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;
......
......@@ -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')): ?>
......
<?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
}
//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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment