From ed001633e6e784a039068708905fe9165fc4c244 Mon Sep 17 00:00:00 2001 From: Felix Favre Date: Sat, 13 Dec 2014 01:54:05 +0100 Subject: [PATCH] Own Shifts ignore the filled filter. issue #134 --- includes/pages/user_shifts.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php index 155a3a7c..eecd1fc3 100644 --- a/includes/pages/user_shifts.php +++ b/includes/pages/user_shifts.php @@ -417,13 +417,14 @@ function view_user_shifts() { LEFT JOIN (SELECT se.`SID`, se.`TID`, COUNT(*) as count FROM `ShiftEntry` AS se GROUP BY se.`SID`, se.`TID`) AS entries ON entries.`SID` = `Shifts`.`SID` AND entries.`TID` = nat.`angel_type_id` WHERE `Shifts`.`RID` IN (" . implode(',', $_SESSION['user_shifts']['rooms']) . ") AND `start` BETWEEN " . $starttime . " AND " . $endtime; + if (count($_SESSION['user_shifts']['filled']) == 1) { if ($_SESSION['user_shifts']['filled'][0] == 0) $SQL .= " - AND (nat.`count` > entries.`count` OR entries.`count` IS NULL) "; + AND (nat.`count` > entries.`count` OR entries.`count` IS NULL OR EXISTS (SELECT `SID` FROM `ShiftEntry` WHERE `UID` = " .sql_escape($user['UID']) . " AND `ShiftEntry`.`SID` = `Shifts`.`SID`))"; elseif ($_SESSION['user_shifts']['filled'][0] == 1) $SQL .= " - AND (nat.`count` <= entries.`count`) "; + AND (nat.`count` <= entries.`count` OR EXISTS (SELECT `SID` FROM `ShiftEntry` WHERE `UID` = " .sql_escape($user['UID']) . " AND `ShiftEntry`.`SID` = `Shifts`.`SID`))"; } $SQL .= " ORDER BY `start`"; @@ -613,9 +614,7 @@ function view_user_shifts() { else $class = 'occupied'; $shifts_table .= ''; - if (($is_free && in_array(0, $_SESSION['user_shifts']['filled'])) || (! $is_free && in_array(1, $_SESSION['user_shifts']['filled']))) { - $shifts_table .= $shifts_row; - } + $shifts_table .= $shifts_row; $shifts_table .= ""; for ($j = 0; $j < $blocks && $i + $j < $maxshow; $j ++) { $todo[$rid][$i + $j] --; @@ -733,11 +732,9 @@ function view_user_shifts() { if (in_array('user_shifts_admin', $privileges)) { $shift_row['entries'] .= 'Weitere Helfer eintragen »'; } - if (($is_free && in_array(0, $_SESSION['user_shifts']['filled'])) || (! $is_free && in_array(1, $_SESSION['user_shifts']['filled']))) { - $shifts_table[] = $shift_row; - $shift['angeltypes'] = $angeltypes; - $ical_shifts[] = $shift; - } + $shifts_table[] = $shift_row; + $shift['angeltypes'] = $angeltypes; + $ical_shifts[] = $shift; } } $shifts_table = table(array(