$rooms = sql_select("SELECT `RID` AS `id`, `Name` AS `name` FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
global $ical_shifts;
if (count($rooms) == 0) {
error(_("The administration has not configured any rooms yet."));
redirect('?');
}
return $rooms;
}
$ical_shifts = [];
function load_days() {
$days = sql_select_single_col("
$days = sql_select_single_col("
SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) AS `id`, DATE(FROM_UNIXTIME(`start`)) AS `name`
SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) AS `id`, DATE(FROM_UNIXTIME(`start`)) AS `name`
FROM `Shifts`
FROM `Shifts`
ORDER BY `start`");
ORDER BY `start`");
if (count($days) == 0) {
if (count($days) == 0) {
error(_("The administration has not configured any shifts yet."));
error(_("The administration has not configured any shifts yet."));
redirect('?');
redirect('?');
}
}
return $days;
}
$rooms = sql_select("SELECT `RID` AS `id`, `Name` AS `name` FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
function load_types() {
if (count($rooms) == 0) {
global $user;
error(_("The administration has not configured any rooms yet."));
redirect('?');
}
if (in_array('user_shifts_admin', $privileges)) {
if (sql_num_query("SELECT `id`, `name` FROM `AngelTypes` WHERE `restricted` = 0") == 0) {
$types = sql_select("SELECT `id`, `name` FROM `AngelTypes` ORDER BY `AngelTypes`.`name`");
error(_("The administration has not configured any angeltypes yet - or you are not subscribed to any angeltype."));
} else {
redirect('?');
$types = sql_select("SELECT `AngelTypes`.`id`, `AngelTypes`.`name`, (`AngelTypes`.`restricted`=0 OR (NOT `UserAngelTypes`.`confirm_user_id` IS NULL OR `UserAngelTypes`.`id` IS NULL)) as `enabled` FROM `AngelTypes` LEFT JOIN `UserAngelTypes` ON (`UserAngelTypes`.`angeltype_id`=`AngelTypes`.`id` AND `UserAngelTypes`.`user_id`='" . sql_escape($user['UID']) . "') ORDER BY `AngelTypes`.`name`");
}
}
$types = sql_select("SELECT `AngelTypes`.`id`, `AngelTypes`.`name`, (`AngelTypes`.`restricted`=0 OR (NOT `UserAngelTypes`.`confirm_user_id` IS NULL OR `UserAngelTypes`.`id` IS NULL)) as `enabled` FROM `AngelTypes` LEFT JOIN `UserAngelTypes` ON (`UserAngelTypes`.`angeltype_id`=`AngelTypes`.`id` AND `UserAngelTypes`.`user_id`='" . sql_escape($user['UID']) . "') ORDER BY `AngelTypes`.`name`");
if (empty($types)) {
if (empty($types)) {
$types = sql_select("SELECT `id`, `name` FROM `AngelTypes` WHERE `restricted` = 0");
return sql_select("SELECT `id`, `name` FROM `AngelTypes` WHERE `restricted` = 0");
}
}
return $types;
}
if (count($types) == 0) {
function view_user_shifts() {
error(_("The administration has not configured any angeltypes yet - or you are not subscribed to any angeltype."));