summaryrefslogtreecommitdiff
path: root/includes/pages/admin_rooms.php
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2016-10-03 18:32:25 +0200
committermsquare <msquare@notrademark.de>2016-10-03 18:32:25 +0200
commitf3a0ce865deb9603b77adc9c9237a55cd4d87eeb (patch)
tree2fb5cc4658fd8ff9b379c2bb6227e8bf8c9a7f37 /includes/pages/admin_rooms.php
parent09c931dcf585da440879c52bb32b5eb9ef0fb9b4 (diff)
move sql queries from shifts controller to model
Diffstat (limited to 'includes/pages/admin_rooms.php')
-rw-r--r--includes/pages/admin_rooms.php32
1 files changed, 18 insertions, 14 deletions
diff --git a/includes/pages/admin_rooms.php b/includes/pages/admin_rooms.php
index d34d4386..7641eb18 100644
--- a/includes/pages/admin_rooms.php
+++ b/includes/pages/admin_rooms.php
@@ -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,7 +110,7 @@ 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);
@@ -114,7 +118,7 @@ function admin_rooms() {
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, $count);
$needed_angeltype_info[] = $angeltype['name'] . ": " . $angeltype_count;
}
}