You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.6 KiB
PHTML

<?php
/**
* returns a list of rooms.
8 years ago
*
* @param boolean $show_all returns also hidden rooms when true
* @return array|false
*/
8 years ago
function Rooms($show_all = false)
{
return sql_select("SELECT * FROM `Room`" . ($show_all ? "" : " WHERE `show`='Y'") . " ORDER BY `Name`");
}
/**
* Delete a room
*
8 years ago
* @param int $room_id
* @return mysqli_result|false
*/
8 years ago
function Room_delete($room_id)
{
return sql_query('DELETE FROM `Room` WHERE `RID`=' . sql_escape($room_id));
}
/**
* Create a new room
*
8 years ago
* @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?
* @param int $number
* Room number
* @return false|int
*/
function Room_create($name, $from_frab, $public, $number = null)
8 years ago
{
$result = sql_query("
INSERT INTO `Room` SET
`Name`='" . sql_escape($name) . "',
`FromPentabarf`='" . sql_escape($from_frab ? 'Y' : '') . "',
`show`='" . sql_escape($public ? 'Y' : '') . "',
`Number`=" . (int)$number
);
8 years ago
if ($result === false) {
return false;
}
return sql_id();
}
/**
* Returns room by id.
*
* @param int $room_id RID
* @param bool $show_only
* @return array|false
*/
function Room($room_id, $show_only = true)
8 years ago
{
$room_source = sql_select("
SELECT *
FROM `Room`
WHERE `RID`='" . sql_escape($room_id) . "'
" . ($show_only ? "AND `show` = 'Y'" : '')
);
8 years ago
8 years ago
if ($room_source === false) {
return false;
}
if (count($room_source) > 0) {
return $room_source[0];
}
return null;
}