summaryrefslogtreecommitdiff
path: root/includes/model/Room_model.php
diff options
context:
space:
mode:
authorPhilip Häusler <msquare@notrademark.de>2015-05-14 17:20:46 +0200
committerPhilip Häusler <msquare@notrademark.de>2015-05-14 17:20:46 +0200
commit0a59089e2b3e16923b80cf071c769d628053e59e (patch)
tree0b7736e41ddceb3381a4c96b61f7897a5c5607e5 /includes/model/Room_model.php
parent284ed12f594ee4001eafaff57c626df37a077f0a (diff)
add room model tests
Diffstat (limited to 'includes/model/Room_model.php')
-rw-r--r--includes/model/Room_model.php34
1 files changed, 26 insertions, 8 deletions
diff --git a/includes/model/Room_model.php b/includes/model/Room_model.php
index 523436c6..2868916e 100644
--- a/includes/model/Room_model.php
+++ b/includes/model/Room_model.php
@@ -1,15 +1,33 @@
<?php
/**
- * Returns room id array
+ * Delete a room
+ * @param int $room_id
*/
-function Room_ids() {
- $room_source = sql_select("SELECT `RID` FROM `Room` WHERE `show` = 'Y'");
- if ($room_source === false)
+function Room_delete($room_id) {
+ return sql_query("DELETE FROM `Room` WHERE `RID`=" . sql_escape($room_id));
+}
+
+/**
+ * Create a new room
+ *
+ * @param string $name
+ * Name of the room
+ * @param boolean $from_frab
+ * Is this a frab imported room?
+ * @param boolean $public
+ * Is the room visible for angels?
+ */
+function Room_create($name, $from_frab, $public) {
+ $result = sql_query("
+ INSERT INTO `Room` SET
+ `Name`='" . sql_escape($name) . "',
+ `FromPentabarf`='" . sql_escape($from_frab ? 'Y' : 'N') . "',
+ `show`='" . sql_escape($public ? 'Y' : 'N') . "',
+ `Number`=0");
+ if ($result === false)
return false;
- if (count($room_source) > 0)
- return $room_source;
- return null;
+ return sql_id();
}
/**
@@ -18,7 +36,7 @@ function Room_ids() {
* @param $id RID
*/
function Room($id) {
- $room_source = sql_select("SELECT * FROM `Room` WHERE `RID`='" . sql_escape($id) . "' AND `show` = 'Y' LIMIT 1");
+ $room_source = sql_select("SELECT * FROM `Room` WHERE `RID`='" . sql_escape($id) . "' AND `show` = 'Y'");
if ($room_source === false)
return false;