summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2016-11-30 17:43:55 +0100
committerGitHub <noreply@github.com>2016-11-30 17:43:55 +0100
commit39f9c2e34cd2fb44a3ea66e363045b250a0e4b07 (patch)
tree8b80ffc0170d80a07ca5391b832865ed0d895abb
parent53e12065c76af4e5a0a2690e92e6724eed9f2895 (diff)
parent1324260e0f43622c7c6f7170bdda702bb587df6e (diff)
Merge pull request #284 from jwacalex/unset_user_id_in_shift_entries_controller
fixed broken logic in controller (cf. to mail to @msquare)
-rw-r--r--includes/controller/shift_entries_controller.php21
1 files changed, 11 insertions, 10 deletions
diff --git a/includes/controller/shift_entries_controller.php b/includes/controller/shift_entries_controller.php
index 1b1a4d02..adb40c58 100644
--- a/includes/controller/shift_entries_controller.php
+++ b/includes/controller/shift_entries_controller.php
@@ -36,12 +36,20 @@ function shift_entry_add_controller() {
} else {
$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) {
redirect(page_link_to('user_shifts'));
}
$type = $type[0];
-
+
+ if (isset($_REQUEST['user_id']) && preg_match("/^[0-9]*$/", $_REQUEST['user_id']) &&
+ in_array('user_shifts_admin', $privileges)) {
+ $user_id = $_REQUEST['user_id'];
+ } else {
+ $user_id = $user['UID'];
+ }
+
$shift_signup_allowed = Shift_signup_allowed(User($user_id), $shift, $type);
if (! $shift_signup_allowed->isSignupAllowed()) {
error(_("You are not allowed to sign up for this shift. Maybe shift is full or already running."));
@@ -51,12 +59,7 @@ function shift_entry_add_controller() {
if (isset($_REQUEST['submit'])) {
$selected_type_id = $type_id;
if (in_array('user_shifts_admin', $privileges)) {
- if (isset($_REQUEST['user_id']) && preg_match("/^[0-9]*$/", $_REQUEST['user_id'])) {
- $user_id = $_REQUEST['user_id'];
- } else {
- $user_id = $user['UID'];
- }
-
+
if (sql_num_query("SELECT * FROM `User` WHERE `UID`='" . sql_escape($user_id) . "' LIMIT 1") == 0) {
redirect(page_link_to('user_shifts'));
}
@@ -64,8 +67,6 @@ function shift_entry_add_controller() {
if (isset($_REQUEST['angeltype_id']) && test_request_int('angeltype_id') && sql_num_query("SELECT * FROM `AngelTypes` WHERE `id`='" . sql_escape($_REQUEST['angeltype_id']) . "' LIMIT 1") > 0) {
$selected_type_id = $_REQUEST['angeltype_id'];
}
- } else {
- $user_id = $user['UID'];
}
if (sql_num_query("SELECT * FROM `ShiftEntry` WHERE `SID`='" . sql_escape($shift['SID']) . "' AND `UID` = '" . sql_escape($user_id) . "'")) {