2013-12-29 15:08:33 +01:00
|
|
|
<?php
|
|
|
|
|
2016-10-03 18:32:25 +02:00
|
|
|
/**
|
|
|
|
* returns a list of rooms.
|
|
|
|
* @param boolean $show_all returns also hidden rooms when true
|
|
|
|
*/
|
|
|
|
function Rooms($show_all = false) {
|
|
|
|
return sql_select("SELECT * FROM `Room`" . ($show_all ? "" : " WHERE `show`='Y'") . " ORDER BY `Name`");
|
|
|
|
}
|
|
|
|
|
2013-12-29 15:08:33 +01:00
|
|
|
/**
|
2015-05-14 17:20:46 +02:00
|
|
|
* Delete a room
|
2016-10-03 18:32:25 +02:00
|
|
|
*
|
|
|
|
* @param int $room_id
|
2013-12-29 15:08:33 +01:00
|
|
|
*/
|
2015-05-14 17:20:46 +02:00
|
|
|
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) . "',
|
2015-12-29 17:57:16 +01:00
|
|
|
`FromPentabarf`='" . sql_escape($from_frab ? 'Y' : '') . "',
|
|
|
|
`show`='" . sql_escape($public ? 'Y' : '') . "',
|
2015-05-14 17:20:46 +02:00
|
|
|
`Number`=0");
|
2016-09-29 11:18:17 +02:00
|
|
|
if ($result === false) {
|
2013-12-29 15:08:33 +01:00
|
|
|
return false;
|
2016-09-29 11:18:17 +02:00
|
|
|
}
|
2015-05-14 17:20:46 +02:00
|
|
|
return sql_id();
|
2013-12-29 15:08:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns room by id.
|
|
|
|
*
|
2016-09-29 12:45:06 +02:00
|
|
|
* @param $room_id RID
|
2013-12-29 15:08:33 +01:00
|
|
|
*/
|
2016-09-29 12:45:06 +02:00
|
|
|
function Room($room_id) {
|
|
|
|
$room_source = sql_select("SELECT * FROM `Room` WHERE `RID`='" . sql_escape($room_id) . "' AND `show` = 'Y'");
|
2014-12-28 14:56:02 +01:00
|
|
|
|
2016-09-29 11:18:17 +02:00
|
|
|
if ($room_source === false) {
|
2013-12-29 15:08:33 +01:00
|
|
|
return false;
|
2016-09-29 11:18:17 +02:00
|
|
|
}
|
|
|
|
if (count($room_source) > 0) {
|
2013-12-29 15:08:33 +01:00
|
|
|
return $room_source[0];
|
2016-09-29 11:18:17 +02:00
|
|
|
}
|
2013-12-29 15:08:33 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|