remove room number and visible flag, rename pentabarf to frab and introduce map/c3nav integration as well as markdown description for rooms
This commit is contained in:
parent
ef0dbe8a1b
commit
4143680297
|
@ -35,3 +35,13 @@ ALTER TABLE `LogEntries` CHANGE COLUMN `nick` `level` VARCHAR(20) NOT NULL;
|
||||||
-- Angeltype contact update
|
-- Angeltype contact update
|
||||||
ALTER TABLE `AngelTypes` DROP FOREIGN KEY angeltypes_ibfk_1;
|
ALTER TABLE `AngelTypes` DROP FOREIGN KEY angeltypes_ibfk_1;
|
||||||
ALTER TABLE `AngelTypes` DROP `contact_user_id`;
|
ALTER TABLE `AngelTypes` DROP `contact_user_id`;
|
||||||
|
|
||||||
|
-- Room update
|
||||||
|
ALTER TABLE `Room` DROP `Number`;
|
||||||
|
ALTER TABLE `Room` DROP `show`;
|
||||||
|
ALTER TABLE `Room` DROP `Man`;
|
||||||
|
ALTER TABLE `Room` ADD `from_frab` BOOLEAN NOT NULL AFTER `FromPentabarf`;
|
||||||
|
update Room set `from_frab`=(`FromPentabarf`='Y');
|
||||||
|
ALTER TABLE `Room` DROP `FromPentabarf`;
|
||||||
|
ALTER TABLE `Room` ADD `map_url` VARCHAR(300) NULL AFTER `from_frab`;
|
||||||
|
ALTER TABLE `Room` ADD `description` TEXT NULL AFTER `map_url`;
|
||||||
|
|
|
@ -21,10 +21,7 @@ function room_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = request();
|
$request = request();
|
||||||
$room = load_room(false);
|
$room = load_room();
|
||||||
if ($room['show'] != 'Y' && !in_array('admin_rooms', $privileges)) {
|
|
||||||
redirect(page_link_to());
|
|
||||||
}
|
|
||||||
|
|
||||||
$all_shifts = Shifts_by_room($room);
|
$all_shifts = Shifts_by_room($room);
|
||||||
$days = [];
|
$days = [];
|
||||||
|
@ -104,16 +101,15 @@ function room_edit_link($room)
|
||||||
/**
|
/**
|
||||||
* Loads room by request param room_id
|
* Loads room by request param room_id
|
||||||
*
|
*
|
||||||
* @param bool $onlyVisible
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function load_room($onlyVisible = true)
|
function load_room()
|
||||||
{
|
{
|
||||||
if (!test_request_int('room_id')) {
|
if (!test_request_int('room_id')) {
|
||||||
redirect(page_link_to());
|
redirect(page_link_to());
|
||||||
}
|
}
|
||||||
|
|
||||||
$room = Room(request()->input('room_id'), $onlyVisible);
|
$room = Room(request()->input('room_id'));
|
||||||
if ($room == null) {
|
if ($room == null) {
|
||||||
redirect(page_link_to());
|
redirect(page_link_to());
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,11 @@ use Engelsystem\Database\DB;
|
||||||
/**
|
/**
|
||||||
* returns a list of rooms.
|
* returns a list of rooms.
|
||||||
*
|
*
|
||||||
* @param boolean $show_all returns also hidden rooms when true
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function Rooms($show_all = false)
|
function Rooms()
|
||||||
{
|
{
|
||||||
return DB::select('SELECT * FROM `Room`' . ($show_all ? '' : ' WHERE `show`=\'Y\'') . ' ORDER BY `Name`');
|
return DB::select('SELECT * FROM `Room` ORDER BY `Name`');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,21 +38,21 @@ function Room_delete($room_id)
|
||||||
*
|
*
|
||||||
* @param string $name Name of the room
|
* @param string $name Name of the room
|
||||||
* @param boolean $from_frab Is this a frab imported room?
|
* @param boolean $from_frab Is this a frab imported room?
|
||||||
* @param boolean $public Is the room visible for angels?
|
* @param string $map_url URL to a map tha can be displayed in an iframe
|
||||||
* @param int $number Room number
|
* @param description markdown description
|
||||||
* @return false|int
|
* @return false|int
|
||||||
*/
|
*/
|
||||||
function Room_create($name, $from_frab, $public, $number = null)
|
function Room_create($name, $from_frab, $map_url, $description)
|
||||||
{
|
{
|
||||||
DB::insert('
|
DB::insert('
|
||||||
INSERT INTO `Room` (`Name`, `FromPentabarf`, `show`, `Number`)
|
INSERT INTO `Room` (`Name`, `from_frab`, `map_url`, `description`)
|
||||||
VALUES (?, ?, ?, ?)
|
VALUES (?, ?, ?, ?)
|
||||||
',
|
',
|
||||||
[
|
[
|
||||||
$name,
|
$name,
|
||||||
$from_frab ? 'Y' : '',
|
(int) $from_frab,
|
||||||
$public ? 'Y' : '',
|
$map_url,
|
||||||
(int)$number,
|
$description,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -67,13 +66,12 @@ function Room_create($name, $from_frab, $public, $number = null)
|
||||||
* @param bool $onlyVisible
|
* @param bool $onlyVisible
|
||||||
* @return array|false
|
* @return array|false
|
||||||
*/
|
*/
|
||||||
function Room($room_id, $onlyVisible = true)
|
function Room($room_id)
|
||||||
{
|
{
|
||||||
return DB::selectOne('
|
return DB::selectOne('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `Room`
|
FROM `Room`
|
||||||
WHERE `RID` = ?
|
WHERE `RID` = ?',
|
||||||
' . ($onlyVisible ? 'AND `show` = \'Y\'' : ''),
|
|
||||||
[$room_id]
|
[$room_id]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,7 +251,7 @@ function admin_import()
|
||||||
|
|
||||||
list($rooms_new, $rooms_deleted) = prepare_rooms($import_file);
|
list($rooms_new, $rooms_deleted) = prepare_rooms($import_file);
|
||||||
foreach ($rooms_new as $room) {
|
foreach ($rooms_new as $room) {
|
||||||
$result = Room_create($room, true, true);
|
$result = Room_create($room, true, null, null);
|
||||||
|
|
||||||
$rooms_import[trim($room)] = $result;
|
$rooms_import[trim($room)] = $result;
|
||||||
}
|
}
|
||||||
|
@ -309,7 +309,7 @@ function prepare_rooms($file)
|
||||||
$data = read_xml($file);
|
$data = read_xml($file);
|
||||||
|
|
||||||
// Load rooms from db for compare with input
|
// Load rooms from db for compare with input
|
||||||
$rooms = DB::select('SELECT `Name`, `RID` FROM `Room` WHERE `FromPentabarf`=\'Y\'');
|
$rooms = DB::select('SELECT `Name`, `RID` FROM `Room` WHERE `from_frab`=TRUE');
|
||||||
$rooms_db = [];
|
$rooms_db = [];
|
||||||
$rooms_import = [];
|
$rooms_import = [];
|
||||||
foreach ($rooms as $room) {
|
foreach ($rooms as $room) {
|
||||||
|
@ -348,7 +348,7 @@ function prepare_events($file, $shifttype_id, $add_minutes_start, $add_minutes_e
|
||||||
global $rooms_import;
|
global $rooms_import;
|
||||||
$data = read_xml($file);
|
$data = read_xml($file);
|
||||||
|
|
||||||
$rooms = Rooms(true);
|
$rooms = Rooms();
|
||||||
$rooms_db = [];
|
$rooms_db = [];
|
||||||
foreach ($rooms as $room) {
|
foreach ($rooms as $room) {
|
||||||
$rooms_db[$room['Name']] = $room['RID'];
|
$rooms_db[$room['Name']] = $room['RID'];
|
||||||
|
|
|
@ -22,8 +22,8 @@ function admin_rooms()
|
||||||
foreach ($rooms_source as $room) {
|
foreach ($rooms_source as $room) {
|
||||||
$rooms[] = [
|
$rooms[] = [
|
||||||
'name' => Room_name_render($room),
|
'name' => Room_name_render($room),
|
||||||
'from_pentabarf' => glyph_bool($room['FromPentabarf'] == 'Y'),
|
'from_frab' => glyph_bool($room['from_frab']),
|
||||||
'public' => glyph_bool($room['show'] == 'Y'),
|
'map_url' => glyph_bool(!empty($room['map_url'])),
|
||||||
'actions' => table_buttons([
|
'actions' => table_buttons([
|
||||||
button(page_link_to('admin_rooms', ['show' => 'edit', 'id' => $room['RID']]), _('edit'), 'btn-xs'),
|
button(page_link_to('admin_rooms', ['show' => 'edit', 'id' => $room['RID']]), _('edit'), 'btn-xs'),
|
||||||
button(page_link_to('admin_rooms', ['show' => 'delete', 'id' => $room['RID']]), _('delete'), 'btn-xs')
|
button(page_link_to('admin_rooms', ['show' => 'delete', 'id' => $room['RID']]), _('delete'), 'btn-xs')
|
||||||
|
@ -35,9 +35,9 @@ function admin_rooms()
|
||||||
if ($request->has('show')) {
|
if ($request->has('show')) {
|
||||||
$msg = '';
|
$msg = '';
|
||||||
$name = '';
|
$name = '';
|
||||||
$from_pentabarf = '';
|
$from_frab = false;
|
||||||
$public = 'Y';
|
$map_url = null;
|
||||||
$number = '';
|
$description = null;
|
||||||
$room_id = 0;
|
$room_id = 0;
|
||||||
|
|
||||||
$angeltypes_source = DB::select('SELECT `id`, `name` FROM `AngelTypes` ORDER BY `name`');
|
$angeltypes_source = DB::select('SELECT `id`, `name` FROM `AngelTypes` ORDER BY `name`');
|
||||||
|
@ -49,16 +49,16 @@ function admin_rooms()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_request_int('id')) {
|
if (test_request_int('id')) {
|
||||||
$room = Room($request->input('id'), false);
|
$room = Room($request->input('id'));
|
||||||
if ($room == null) {
|
if ($room == null) {
|
||||||
redirect(page_link_to('admin_rooms'));
|
redirect(page_link_to('admin_rooms'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$room_id = $request->input('id');
|
$room_id = $request->input('id');
|
||||||
$name = $room['Name'];
|
$name = $room['Name'];
|
||||||
$from_pentabarf = $room['FromPentabarf'];
|
$from_frab = $room['from_frab'];
|
||||||
$public = $room['show'];
|
$map_url = $room['map_url'];
|
||||||
$number = $room['Number'];
|
$description = $room['description'];
|
||||||
|
|
||||||
$needed_angeltypes = DB::select(
|
$needed_angeltypes = DB::select(
|
||||||
'SELECT `angel_type_id`, `count` FROM `NeededAngelTypes` WHERE `room_id`=?',
|
'SELECT `angel_type_id`, `count` FROM `NeededAngelTypes` WHERE `room_id`=?',
|
||||||
|
@ -90,20 +90,14 @@ function admin_rooms()
|
||||||
$msg .= error(_('Please enter a name.'), true);
|
$msg .= error(_('Please enter a name.'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$from_pentabarf = '';
|
$from_frab = $request->has('from_frab');
|
||||||
if ($request->has('from_pentabarf')) {
|
|
||||||
$from_pentabarf = 'Y';
|
if ($request->has('map_url')) {
|
||||||
|
$map_url = strip_request_item('map_url');
|
||||||
}
|
}
|
||||||
|
|
||||||
$public = '';
|
if ($request->has('description')) {
|
||||||
if ($request->has('public')) {
|
$description= strip_request_item_nl('description');
|
||||||
$public = 'Y';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($request->has('number')) {
|
|
||||||
$number = strip_request_item('number');
|
|
||||||
} else {
|
|
||||||
$valid = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($angeltypes as $angeltype_id => $angeltype) {
|
foreach ($angeltypes as $angeltype_id => $angeltype) {
|
||||||
|
@ -127,33 +121,32 @@ function admin_rooms()
|
||||||
UPDATE `Room`
|
UPDATE `Room`
|
||||||
SET
|
SET
|
||||||
`Name`=?,
|
`Name`=?,
|
||||||
`FromPentabarf`=?,
|
`from_frab`=?,
|
||||||
`show`=?,
|
`map_url`=?,
|
||||||
`Number`=?
|
`description`=?
|
||||||
WHERE `RID`=?
|
WHERE `RID`=?
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
', [
|
', [
|
||||||
$name,
|
$name,
|
||||||
$from_pentabarf,
|
(int) $from_frab,
|
||||||
$public,
|
$map_url,
|
||||||
$number,
|
$description,
|
||||||
$room_id,
|
$room_id,
|
||||||
]);
|
]);
|
||||||
engelsystem_log(
|
engelsystem_log(
|
||||||
'Room updated: ' . $name
|
'Room updated: ' . $name
|
||||||
. ', pentabarf import: ' . $from_pentabarf
|
. ', frab import: ' . ($from_frab ? 'Yes' : '')
|
||||||
. ', public: ' . $public
|
. ', map_url: ' . $map_url
|
||||||
. ', number: ' . $number
|
. ', description: ' . $description
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$room_id = Room_create($name, $from_pentabarf, $public, $number);
|
$room_id = Room_create($name, $from_frab, $map_url, $description);
|
||||||
|
|
||||||
engelsystem_log(
|
engelsystem_log(
|
||||||
'Room created: ' . $name
|
'Room created: ' . $name
|
||||||
. ', pentabarf import: '
|
. ', frab import: ' . ($from_frab ? 'Yes' : '')
|
||||||
. $from_pentabarf
|
. ', map_url: ' . $map_url
|
||||||
. ', public: ' . $public
|
. ', description: ' . $description
|
||||||
. ', number: ' . $number
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,9 +184,11 @@ function admin_rooms()
|
||||||
div('row', [
|
div('row', [
|
||||||
div('col-md-6', [
|
div('col-md-6', [
|
||||||
form_text('name', _('Name'), $name),
|
form_text('name', _('Name'), $name),
|
||||||
form_checkbox('from_pentabarf', _('Frab import'), $from_pentabarf),
|
form_checkbox('from_frab', _('Frab import'), $from_frab),
|
||||||
form_checkbox('public', _('Public'), $public),
|
form_text('map_url', _('Map URL'), $map_url),
|
||||||
form_text('number', _('Room number'), $number)
|
form_info('', _('The map url is used to display an iframe on the room page.')),
|
||||||
|
form_textarea('description', _('Description'), $description),
|
||||||
|
form_info('', _('Please use markdown for the description.')),
|
||||||
]),
|
]),
|
||||||
div('col-md-6', [
|
div('col-md-6', [
|
||||||
div('row', [
|
div('row', [
|
||||||
|
@ -239,8 +234,8 @@ function admin_rooms()
|
||||||
msg(),
|
msg(),
|
||||||
table([
|
table([
|
||||||
'name' => _('Name'),
|
'name' => _('Name'),
|
||||||
'from_pentabarf' => _('Frab import'),
|
'from_frab' => _('Frab import'),
|
||||||
'public' => _('Public'),
|
'map_url' => _('Map'),
|
||||||
'actions' => ''
|
'actions' => ''
|
||||||
], $rooms)
|
], $rooms)
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -92,7 +92,7 @@ function update_ShiftsFilter(ShiftsFilter $shiftsFilter, $user_shifts_admin, $da
|
||||||
function load_rooms()
|
function load_rooms()
|
||||||
{
|
{
|
||||||
$rooms = DB::select(
|
$rooms = DB::select(
|
||||||
'SELECT `RID` AS `id`, `Name` AS `name` FROM `Room` WHERE `show`=\'Y\' ORDER BY `Name`'
|
'SELECT `RID` AS `id`, `Name` AS `name` FROM `Room` ORDER BY `Name`'
|
||||||
);
|
);
|
||||||
if (empty($rooms)) {
|
if (empty($rooms)) {
|
||||||
error(_('The administration has not configured any rooms yet.'));
|
error(_('The administration has not configured any rooms yet.'));
|
||||||
|
|
|
@ -186,7 +186,7 @@ function make_room_navigation($menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a list of all rooms
|
// Get a list of all rooms
|
||||||
$rooms = Rooms(true);
|
$rooms = Rooms();
|
||||||
$room_menu = [];
|
$room_menu = [];
|
||||||
if (in_array('admin_rooms', $privileges)) {
|
if (in_array('admin_rooms', $privileges)) {
|
||||||
$room_menu[] = toolbar_item_link(page_link_to('admin_rooms'), 'list', _('Manage rooms'));
|
$room_menu[] = toolbar_item_link(page_link_to('admin_rooms'), 'list', _('Manage rooms'));
|
||||||
|
@ -195,17 +195,8 @@ function make_room_navigation($menu)
|
||||||
$room_menu[] = toolbar_item_divider();
|
$room_menu[] = toolbar_item_divider();
|
||||||
}
|
}
|
||||||
foreach ($rooms as $room) {
|
foreach ($rooms as $room) {
|
||||||
if (
|
|
||||||
$room['show'] == 'Y' // room is public
|
|
||||||
|| (
|
|
||||||
// room is not public, but user can admin_rooms
|
|
||||||
$room['show'] != 'Y'
|
|
||||||
&& in_array('admin_rooms', $privileges)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
$room_menu[] = toolbar_item_link(room_link($room), 'map-marker', $room['Name']);
|
$room_menu[] = toolbar_item_link(room_link($room), 'map-marker', $room['Name']);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (count($room_menu) > 0) {
|
if (count($room_menu) > 0) {
|
||||||
$menu[] = toolbar_dropdown('map-marker', _('Rooms'), $room_menu);
|
$menu[] = toolbar_dropdown('map-marker', _('Rooms'), $room_menu);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Engelsystem\ShiftCalendarRenderer;
|
use Engelsystem\ShiftCalendarRenderer;
|
||||||
use Engelsystem\ShiftsFilterRenderer;
|
use Engelsystem\ShiftsFilterRenderer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @param array $room
|
* @param array $room
|
||||||
* @param ShiftsFilterRenderer $shiftsFilterRenderer
|
* @param ShiftsFilterRenderer $shiftsFilterRenderer
|
||||||
* @param ShiftCalendarRenderer $shiftCalendarRenderer
|
* @param ShiftCalendarRenderer $shiftCalendarRenderer
|
||||||
|
@ -14,21 +14,46 @@ function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalen
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$assignNotice = '';
|
$assignNotice = '';
|
||||||
if (config('signup_requires_arrival') && !$user['Gekommen']) {
|
if (config('signup_requires_arrival') && ! $user['Gekommen']) {
|
||||||
$assignNotice = info(render_user_arrived_hint(), true);
|
$assignNotice = info(render_user_arrived_hint(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_with_title(glyph('map-marker') . $room['Name'], [
|
$description = '';
|
||||||
|
if (! empty($room['description'])) {
|
||||||
|
$description = '<h3>' . _('Description') . '</h3>';
|
||||||
|
$parsedown = new Parsedown();
|
||||||
|
$description .= '<div class="well">' . $parsedown->parse($room['description']) . '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$tabs = [];
|
||||||
|
$selected = 0;
|
||||||
|
if (! empty($room['map_url'])) {
|
||||||
|
$tabs[_('Map')] = '<div class="map"><iframe style="width: 100%; min-height: 400px; border: 0px none;" src="' . $room['map_url'] . '"></iframe></div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$tabs[_('Shifts')] = div('first', [
|
||||||
$shiftsFilterRenderer->render(page_link_to('rooms', [
|
$shiftsFilterRenderer->render(page_link_to('rooms', [
|
||||||
'action' => 'view',
|
'action' => 'view',
|
||||||
'room_id' => $room['RID']
|
'room_id' => $room['RID']
|
||||||
])),
|
])),
|
||||||
$assignNotice,
|
|
||||||
$shiftCalendarRenderer->render()
|
$shiftCalendarRenderer->render()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$selected_tab = 0;
|
||||||
|
$request = request();
|
||||||
|
if ($request->has('shifts_filter_day')) {
|
||||||
|
$selected_tab = count($tabs) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return page_with_title(glyph('map-marker') . $room['Name'], [
|
||||||
|
$assignNotice,
|
||||||
|
$description,
|
||||||
|
tabs($tabs, $selected_tab)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @param array $room
|
* @param array $room
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -15,7 +15,7 @@ class RoomModelTest extends TestCase
|
||||||
|
|
||||||
public function createRoom()
|
public function createRoom()
|
||||||
{
|
{
|
||||||
$this->room_id = Room_create('test', false, true, '');
|
$this->room_id = Room_create('test', false, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRoom()
|
public function testRoom()
|
||||||
|
|
Loading…
Reference in New Issue