diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php
index f76157d4..e8aaa4ca 100644
--- a/includes/pages/user_shifts.php
+++ b/includes/pages/user_shifts.php
@@ -412,17 +412,18 @@ function view_user_shifts() {
$shifts_row .= ' [edit] [x]';
$shifts_row.= '
';
$shift_has_special_needs = 0 < sql_num_query("SELECT `id` FROM `NeededAngelTypes` WHERE `shift_id` = " . $shift['SID']);
- $query = "SELECT *
+ $query = "SELECT `NeededAngelTypes`.`count`, `AngelTypes`.`id`, `AngelTypes`.`restricted`, `UserAngelTypes`.`confirm_user_id`, `AngelTypes`.`name`
FROM `NeededAngelTypes`
- JOIN `AngelTypes`
- ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id`)
+ JOIN `AngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id`)
+ LEFT JOIN `UserAngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `UserAngelTypes`.`angeltype_id`)
WHERE ";
if ($shift_has_special_needs)
$query .= "`shift_id` = " . sql_escape($shift['SID']);
else
$query .= "`room_id` = " . sql_escape($shift['RID']);
- $query .= " AND `count` > 0 ";
- $query .= " AND `angel_type_id` IN (" . implode(',', $_SESSION['user_shifts']['types']) . ")";
+ $query .= " AND `count` > 0 AND `UserAngelTypes`.`user_id`=" . sql_escape($user['UID']) . " ";
+ if (!empty($_SESSION['user_shifts']['types']))
+ $query .= "AND `angel_type_id` IN (" . implode(',', $_SESSION['user_shifts']['types']) . ") ";
$query .= "ORDER BY `AngelTypes`.`name`";
$angeltypes = sql_select($query);
@@ -442,6 +443,7 @@ function view_user_shifts() {
$entry_list[] = "" . $entry['Nick']."";
}
if ($angeltype['count'] - count($entries) > 0) {
+ $inner_text = ($angeltype['count'] - count($entries)) . ' ' . Get_Text($angeltype['count'] - count($entries) == 1 ? 'helper' : 'helpers') . ' ' . Get_Text('needed');
// is the shift still running or alternatively is the user shift admin?
$user_may_join_shift = true;
@@ -457,15 +459,18 @@ function view_user_shifts() {
// User shift admins may join anybody in every shift
$user_may_join_shift |= in_array('user_shifts_admin', $privileges);
- if ($user_may_join_shift) {
- $entry_list[] = '' . ($angeltype['count'] - count($entries)) . ' Helfer' . ($angeltype['count'] - count($entries) != 1 ? '' : '') . ' gebraucht »';
- } else {
+ if ($user_may_join_shift)
+ $entry_list[] = '' . $inner_text . ' »';
+ else {
if(!in_array('user_shifts_admin', $privileges) && $angeltype['restricted'] == 1 && !isset($angeltype['confirm_user_id'])) {
- $entry_list[] = ($angeltype['count'] - count($entries)) . ' Helfer gebraucht' . ' ';
+ $entry_list[] = $inner_text . ' ';
+ } elseif(time() < $shift['end']) {
+ $entry_list[] = $inner_text . ' (Werde ' . $angeltype['name'] .')';
} else {
- $entry_list[] = ($angeltype['count'] - count($entries)) . ' Helfer gebraucht' . ' (Werde ' . $angeltype['name'] .')';
+ $entry_list[] = $inner_text;
}
}
+
$is_free = true;
}
@@ -523,21 +528,20 @@ function view_user_shifts() {
$shift_row['entries'] .= '
';
$is_free = false;
$shift_has_special_needs = 0 < sql_num_query("SELECT `id` FROM `NeededAngelTypes` WHERE `shift_id` = " . $shift['SID']);
- $query = "SELECT *
+ $query = "SELECT `NeededAngelTypes`.`count`, `AngelTypes`.`id`, `AngelTypes`.`restricted`, `UserAngelTypes`.`confirm_user_id`, `AngelTypes`.`name`
FROM `NeededAngelTypes`
JOIN `AngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id`)
- LEFT JOIN `UserAngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `UserAngelTypes`.`angeltype_id` AND `UserAngelTypes`.`user_id`=" . sql_escape($user['UID']) . ")
+ LEFT JOIN `UserAngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `UserAngelTypes`.`angeltype_id`)
WHERE ";
if ($shift_has_special_needs)
$query .= "`shift_id` = " . sql_escape($shift['SID']);
else
$query .= "`room_id` = " . sql_escape($shift['RID']);
- $query .= " AND `count` > 0 ";
+ $query .= " AND `count` > 0 AND `UserAngelTypes`.`user_id`=" . sql_escape($user['UID']) . " ";
if (!empty($_SESSION['user_shifts']['types']))
$query .= "AND `angel_type_id` IN (" . implode(',', $_SESSION['user_shifts']['types']) . ") ";
$query .= "ORDER BY `AngelTypes`.`name`";
$angeltypes = sql_select($query);
-
if (count($angeltypes) > 0) {
$my_shift = sql_num_query("SELECT * FROM `ShiftEntry` WHERE `SID`=" . sql_escape($shift['SID']) . " AND `UID`=" . sql_escape($user['UID']) . " LIMIT 1") > 0;
foreach ($angeltypes as $angeltype) {
@@ -572,8 +576,10 @@ function view_user_shifts() {
else {
if(!in_array('user_shifts_admin', $privileges) && $angeltype['restricted'] == 1 && !isset($angeltype['confirm_user_id'])) {
$entry_list[] = $inner_text . ' ';
- } else {
+ } elseif(time() < $shift['end']) {
$entry_list[] = $inner_text . ' (Werde ' . $angeltype['name'] .')';
+ } else {
+ $entry_list[] = $inner_text;
}
}