shift join right fuckup

This commit is contained in:
Philip Häusler 2012-12-03 22:47:08 +01:00
parent f62bd8e56b
commit 9e7c2dfeca
1 changed files with 9 additions and 2 deletions

View File

@ -188,7 +188,11 @@ function user_shifts() {
header("Location: " . page_link_to('user_shifts')); header("Location: " . page_link_to('user_shifts'));
} }
$type = sql_select("SELECT * FROM `AngelTypes` WHERE `id`=" . sql_escape($type_id) . " LIMIT 1"); if (in_array('user_shifts_admin', $privileges))
$type = sql_select("SELECT * FROM `AngelTypes` WHERE `id`=" . sql_escape($type_id) . " LIMIT 1");
else
$type = sql_select("SELECT * FROM `UserAngelTypes` JOIN `AngelTypes` ON (`UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`) WHERE `AngelTypes`.`id` = " . sql_escape($type_id) . " AND `UserAngelTypes`.`user_id` = " . sql_escape($user['UID']) . " AND (`AngelTypes`.`restricted` = 0 OR NOT `UserAngelTypes`.`confirm_user_id` IS NULL) LIMIT 1");
if (count($type) == 0) if (count($type) == 0)
header("Location: " . page_link_to('user_shifts')); header("Location: " . page_link_to('user_shifts'));
$type = $type[0]; $type = $type[0];
@ -260,7 +264,10 @@ function view_user_shifts() {
$ical_shifts = array (); $ical_shifts = array ();
$days = sql_select("SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) AS `id`, DATE(FROM_UNIXTIME(`start`)) AS `name` FROM `Shifts` ORDER BY `start`"); $days = sql_select("SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) AS `id`, DATE(FROM_UNIXTIME(`start`)) AS `name` FROM `Shifts` ORDER BY `start`");
$rooms = sql_select("SELECT `RID` AS `id`, `Name` AS `name` FROM `Room` WHERE `show`='Y' ORDER BY `Name`"); $rooms = sql_select("SELECT `RID` AS `id`, `Name` AS `name` FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
$types = sql_select("SELECT `id`, `name` FROM `AngelTypes`"); if (in_array('admin_shifts', $privileges))
$types = sql_select("SELECT `id`, `name` FROM `AngelTypes`");
else
$types = sql_select("SELECT `AngelTypes`.`id`, `AngelTypes`.`name` FROM `UserAngelTypes` JOIN `AngelTypes` ON (`UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`) WHERE `UserAngelTypes`.`user_id` = " . sql_escape($user['UID']) . " AND (`AngelTypes`.`restricted` = 0 OR NOT `UserAngelTypes`.`confirm_user_id` IS NULL)");
$filled = array ( $filled = array (
array ( array (
'id' => '1', 'id' => '1',