allow angels to sign up for shifts whose types are not selected as preferred in settings and auto-prefer these types
This commit is contained in:
parent
346209fbc2
commit
0c9dccacfb
|
@ -191,7 +191,7 @@ function user_shifts() {
|
||||||
if (in_array('user_shifts_admin', $privileges))
|
if (in_array('user_shifts_admin', $privileges))
|
||||||
$type = sql_select("SELECT * FROM `AngelTypes` WHERE `id`=" . sql_escape($type_id) . " LIMIT 1");
|
$type = sql_select("SELECT * FROM `AngelTypes` WHERE `id`=" . sql_escape($type_id) . " LIMIT 1");
|
||||||
else
|
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");
|
$type = sql_select("SELECT * FROM `UserAngelTypes` JOIN `AngelTypes` ON (`UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`) WHERE `AngelTypes`.`id` = " . sql_escape($type_id) . " AND (`AngelTypes`.`restricted` = 0 OR (`UserAngelTypes`.`user_id` = " . sql_escape($user['UID']) . " AND 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'));
|
||||||
|
@ -214,13 +214,13 @@ function user_shifts() {
|
||||||
$user_id = $user['UID'];
|
$user_id = $user['UID'];
|
||||||
|
|
||||||
// TODO: Kollisionserkennung, andere Schichten zur gleichen Uhrzeit darf der Engel auch nicht belegt haben...
|
// TODO: Kollisionserkennung, andere Schichten zur gleichen Uhrzeit darf der Engel auch nicht belegt haben...
|
||||||
$entries = sql_select("SELECT * FROM `ShiftEntry` WHERE `SID`=" . sql_escape($shift['SID']));
|
if (sql_num_query("SELECT * FROM `ShiftEntry` WHERE `SID`='" . sql_escape($shift['SID']) . "' AND `UID` = '" . sql_escape($user_id) . "'"))
|
||||||
foreach ($entries as $entry)
|
|
||||||
if ($entry['UID'] == $user_id)
|
|
||||||
return error("This angel does already have an entry for this shift.", true);
|
return error("This angel does already have an entry for this shift.", true);
|
||||||
|
|
||||||
$comment = strip_request_item_nl('comment');
|
$comment = strip_request_item_nl('comment');
|
||||||
sql_query("INSERT INTO `ShiftEntry` SET `Comment`='" . sql_escape($comment) . "', `UID`=" . sql_escape($user_id) . ", `TID`=" . sql_escape($selected_type_id) . ", `SID`=" . sql_escape($shift_id));
|
sql_query("INSERT INTO `ShiftEntry` SET `Comment`='" . sql_escape($comment) . "', `UID`=" . sql_escape($user_id) . ", `TID`=" . sql_escape($selected_type_id) . ", `SID`=" . sql_escape($shift_id));
|
||||||
|
if (sql_num_query("SELECT * FROM `UserAngelTypes` INNER JOIN `AngelTypes` ON `AngelTypes`.`id` = `UserAngelTypes`.`angeltype_id` WHERE `AngelTypes`.`restricted` = 0 AND `user_id` = '" . sql_escape($user_id) . "' AND `angeltype_id` = '" . sql_escape($selected_type_id) . "'") == 0)
|
||||||
|
sql_query("INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`) VALUES ('" . sql_escape($user_id) . "', '" . sql_escape($selected_type_id) . "')");
|
||||||
|
|
||||||
success("Du bist eingetragen. Danke!" . ' <a href="' . page_link_to('user_myshifts') . '">Meine Schichten »</a>');
|
success("Du bist eingetragen. Danke!" . ' <a href="' . page_link_to('user_myshifts') . '">Meine Schichten »</a>');
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
|
|
Loading…
Reference in New Issue