summaryrefslogtreecommitdiff
path: root/includes/pages/admin_rooms.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/pages/admin_rooms.php')
-rw-r--r--includes/pages/admin_rooms.php39
1 files changed, 20 insertions, 19 deletions
diff --git a/includes/pages/admin_rooms.php b/includes/pages/admin_rooms.php
index d34d4386..129ed423 100644
--- a/includes/pages/admin_rooms.php
+++ b/includes/pages/admin_rooms.php
@@ -9,10 +9,10 @@ function admin_rooms() {
$rooms = [];
foreach ($rooms_source as $room) {
$rooms[] = [
- 'name' => $room['Name'],
+ 'name' => Room_name_render($room),
'from_pentabarf' => $room['FromPentabarf'] == 'Y' ? '✓' : '',
'public' => $room['show'] == 'Y' ? '✓' : '',
- 'actions' => 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=delete&id=' . $room['RID'], _("delete"), 'btn-xs')
])
@@ -36,20 +36,24 @@ function admin_rooms() {
}
if (test_request_int('id')) {
- $room = sql_select("SELECT * FROM `Room` WHERE `RID`='" . sql_escape($_REQUEST['id']) . "'");
- if (count($room) > 0) {
- $room_id = $_REQUEST['id'];
- $name = $room[0]['Name'];
- $from_pentabarf = $room[0]['FromPentabarf'];
- $public = $room[0]['show'];
- $number = $room[0]['Number'];
- $needed_angeltypes = sql_select("SELECT * FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($room_id) . "'");
- foreach ($needed_angeltypes as $needed_angeltype) {
- $angeltypes_count[$needed_angeltype['angel_type_id']] = $needed_angeltype['count'];
- }
- } else {
+ $room = Room($_REQUEST['id']);
+ if ($room === false) {
+ engelsystem_error("Unable to load room.");
+ }
+ if ($room == null) {
redirect(page_link_to('admin_rooms'));
}
+
+ $room_id = $_REQUEST['id'];
+ $name = $room['Name'];
+ $from_pentabarf = $room['FromPentabarf'];
+ $public = $room['show'];
+ $number = $room['Number'];
+
+ $needed_angeltypes = sql_select("SELECT * FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($room_id) . "'");
+ foreach ($needed_angeltypes as $needed_angeltype) {
+ $angeltypes_count[$needed_angeltype['angel_type_id']] = $needed_angeltype['count'];
+ }
}
if ($_REQUEST['show'] == 'edit') {
@@ -106,15 +110,12 @@ function admin_rooms() {
engelsystem_log("Room created: " . $name . ", pentabarf import: " . $from_pentabarf . ", public: " . $public . ", number: " . $number);
}
- sql_query("DELETE FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($room_id) . "'");
+ NeededAngelTypes_delete_by_room($room_id);
$needed_angeltype_info = [];
foreach ($angeltypes_count as $angeltype_id => $angeltype_count) {
$angeltype = AngelType($angeltype_id);
- if ($angeltype === false) {
- engelsystem_error("Unable to load angeltype.");
- }
if ($angeltype != null) {
- sql_query("INSERT INTO `NeededAngelTypes` SET `room_id`='" . sql_escape($room_id) . "', `angel_type_id`='" . sql_escape($angeltype_id) . "', `count`='" . sql_escape($angeltype_count) . "'");
+ NeededAngelType_add(null, $angeltype_id, $room_id, $angeltype_count);
$needed_angeltype_info[] = $angeltype['name'] . ": " . $angeltype_count;
}
}