|
|
@ -1,6 +1,30 @@
|
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
use Engelsystem\Database\DB;
|
|
|
|
use Engelsystem\Database\DB;
|
|
|
|
|
|
|
|
use Engelsystem\ValidationResult;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Validate a name for a room.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param string $name
|
|
|
|
|
|
|
|
* The new name
|
|
|
|
|
|
|
|
* @param int $room_id
|
|
|
|
|
|
|
|
* The room id
|
|
|
|
|
|
|
|
* @return ValidationResult
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function Room_validate_name($name, $room_id)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$valid = true;
|
|
|
|
|
|
|
|
if (empty($name)) {
|
|
|
|
|
|
|
|
$valid = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count(DB::select('SELECT RID FROM `Room` WHERE `Name`=? AND NOT `RID`=?', [
|
|
|
|
|
|
|
|
$name,
|
|
|
|
|
|
|
|
$room_id
|
|
|
|
|
|
|
|
])) > 0) {
|
|
|
|
|
|
|
|
$valid = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return new ValidationResult($valid, $name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* returns a list of rooms.
|
|
|
|
* returns a list of rooms.
|
|
|
@ -30,16 +54,34 @@ function Room_ids()
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function Room_delete($room_id)
|
|
|
|
function Room_delete($room_id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DB::delete('DELETE FROM `Room` WHERE `RID` = ?', [$room_id]);
|
|
|
|
DB::delete('DELETE FROM `Room` WHERE `RID` = ?', [
|
|
|
|
|
|
|
|
$room_id
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Delete a room by its name
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param string $name
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function Room_delete_by_name($name)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DB::delete('DELETE FROM `Room` WHERE `Name` = ?', [
|
|
|
|
|
|
|
|
$name
|
|
|
|
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Create a new room
|
|
|
|
* Create a new room
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param string $name Name of the room
|
|
|
|
* @param string $name
|
|
|
|
* @param boolean $from_frab Is this a frab imported room?
|
|
|
|
* Name of the room
|
|
|
|
* @param string $map_url URL to a map tha can be displayed in an iframe
|
|
|
|
* @param boolean $from_frab
|
|
|
|
* @param description markdown description
|
|
|
|
* Is this a frab imported room?
|
|
|
|
|
|
|
|
* @param string $map_url
|
|
|
|
|
|
|
|
* URL to a map tha can be displayed in an iframe
|
|
|
|
|
|
|
|
* @param
|
|
|
|
|
|
|
|
* description markdown description
|
|
|
|
* @return false|int
|
|
|
|
* @return false|int
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function Room_create($name, $from_frab, $map_url, $description)
|
|
|
|
function Room_create($name, $from_frab, $map_url, $description)
|
|
|
@ -47,22 +89,69 @@ function Room_create($name, $from_frab, $map_url, $description)
|
|
|
|
DB::insert('
|
|
|
|
DB::insert('
|
|
|
|
INSERT INTO `Room` (`Name`, `from_frab`, `map_url`, `description`)
|
|
|
|
INSERT INTO `Room` (`Name`, `from_frab`, `map_url`, `description`)
|
|
|
|
VALUES (?, ?, ?, ?)
|
|
|
|
VALUES (?, ?, ?, ?)
|
|
|
|
',
|
|
|
|
', [
|
|
|
|
[
|
|
|
|
$name,
|
|
|
|
|
|
|
|
(int) $from_frab,
|
|
|
|
|
|
|
|
$map_url,
|
|
|
|
|
|
|
|
$description
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
$result = DB::getPdo()->lastInsertId();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
engelsystem_log(
|
|
|
|
|
|
|
|
'Room created: ' . $name
|
|
|
|
|
|
|
|
. ', frab import: ' . ($from_frab ? 'Yes' : '')
|
|
|
|
|
|
|
|
. ', map_url: ' . $map_url
|
|
|
|
|
|
|
|
. ', description: ' . $description
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* update a room
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param string $name
|
|
|
|
|
|
|
|
* Name of the room
|
|
|
|
|
|
|
|
* @param boolean $from_frab
|
|
|
|
|
|
|
|
* Is this a frab imported room?
|
|
|
|
|
|
|
|
* @param string $map_url
|
|
|
|
|
|
|
|
* URL to a map tha can be displayed in an iframe
|
|
|
|
|
|
|
|
* @param
|
|
|
|
|
|
|
|
* description markdown description
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function Room_update($room_id, $name, $from_frab, $map_url, $description)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$result = DB::update('
|
|
|
|
|
|
|
|
UPDATE `Room`
|
|
|
|
|
|
|
|
SET
|
|
|
|
|
|
|
|
`Name`=?,
|
|
|
|
|
|
|
|
`from_frab`=?,
|
|
|
|
|
|
|
|
`map_url`=?,
|
|
|
|
|
|
|
|
`description`=?
|
|
|
|
|
|
|
|
WHERE `RID`=?
|
|
|
|
|
|
|
|
LIMIT 1', [
|
|
|
|
$name,
|
|
|
|
$name,
|
|
|
|
(int) $from_frab,
|
|
|
|
(int) $from_frab,
|
|
|
|
$map_url,
|
|
|
|
$map_url,
|
|
|
|
$description,
|
|
|
|
$description,
|
|
|
|
]
|
|
|
|
$room_id
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
engelsystem_log(
|
|
|
|
|
|
|
|
'Room updated: ' . $name .
|
|
|
|
|
|
|
|
', frab import: ' . ($from_frab ? 'Yes' : '') .
|
|
|
|
|
|
|
|
', map_url: ' . $map_url .
|
|
|
|
|
|
|
|
', description: ' . $description
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
return DB::getPdo()->lastInsertId();
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns room by id.
|
|
|
|
* Returns room by id.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param int $room_id RID
|
|
|
|
* @param int $room_id
|
|
|
|
|
|
|
|
* RID
|
|
|
|
* @param bool $onlyVisible
|
|
|
|
* @param bool $onlyVisible
|
|
|
|
* @return array|false
|
|
|
|
* @return array|false
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -71,7 +160,7 @@ function Room($room_id)
|
|
|
|
return DB::selectOne('
|
|
|
|
return DB::selectOne('
|
|
|
|
SELECT *
|
|
|
|
SELECT *
|
|
|
|
FROM `Room`
|
|
|
|
FROM `Room`
|
|
|
|
WHERE `RID` = ?',
|
|
|
|
WHERE `RID` = ?', [
|
|
|
|
[$room_id]
|
|
|
|
$room_id
|
|
|
|
);
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|