From b01ab50367a61dbb8b6fd9a6f9c9b645d2bdc4ff Mon Sep 17 00:00:00 2001 From: Jan-Philipp Litza Date: Thu, 27 Dec 2012 16:57:03 +0100 Subject: Revert "simplified shift view" This reverts commit 43970df0f3edf7ccef2652cda4c5688e4e78f5dd. --- includes/pages/user_settings.php | 2 +- includes/pages/user_shifts.php | 66 ++++++++-------------------------------- 2 files changed, 14 insertions(+), 54 deletions(-) (limited to 'includes/pages') diff --git a/includes/pages/user_settings.php b/includes/pages/user_settings.php index 7aaad79a..999b890d 100644 --- a/includes/pages/user_settings.php +++ b/includes/pages/user_settings.php @@ -182,7 +182,7 @@ function user_settings() { form_text('jabber', "Jabber", $jabber), form_text('hometown', Get_Text("makeuser_Hometown"), $hometown), $enable_tshirt_size ? form_select('tshirt_size', Get_Text("makeuser_T-Shirt"), $tshirt_sizes, $tshirt_size) : '', - form_checkboxes('angel_types', "What do you want to do?
(Description of job types)", $angel_types, $selected_angel_types), + form_checkboxes('angel_types', "What do you want to do?
(Description of job types)", $angel_types, $selected_angel_types), form_submit('submit', Get_Text("save")) )), form(array ( diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php index f76157d4..07db1d57 100644 --- a/includes/pages/user_shifts.php +++ b/includes/pages/user_shifts.php @@ -282,11 +282,10 @@ function view_user_shifts() { $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`"); $rooms = sql_select("SELECT `RID` AS `id`, `Name` AS `name` FROM `Room` WHERE `show`='Y' ORDER BY `Name`"); - - if(in_array('user_shifts_admin', $privileges)) + if (in_array('admin_shifts', $privileges)) $types = sql_select("SELECT `id`, `name` FROM `AngelTypes` ORDER BY `AngelTypes`.`name`"); else - $types = sql_select("SELECT `AngelTypes`.`id`, `AngelTypes`.`name`, (`AngelTypes`.`restricted`=0 OR NOT `UserAngelTypes`.`confirm_user_id` IS NULL) as `enabled` FROM `AngelTypes` LEFT JOIN `UserAngelTypes` ON (`UserAngelTypes`.`angeltype_id`=`AngelTypes`.`id` AND `UserAngelTypes`.`user_id`=" . sql_escape($user['UID']) . ") ORDER BY `AngelTypes`.`name`"); + $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) ORDER BY `AngelTypes`.`name`"); if (empty($types)) $types = sql_select("SELECT `id`, `name` FROM `AngelTypes` WHERE `restricted` = 0"); $filled = array ( @@ -421,9 +420,9 @@ function view_user_shifts() { $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 .= "ORDER BY `AngelTypes`.`name`"; + $query .= " AND `count` > 0 + AND `angel_type_id` IN (" . implode(',', $_SESSION['user_shifts']['types']) . ") + ORDER BY `AngelTypes`.`name`"; $angeltypes = sql_select($query); if (count($angeltypes) > 0) { @@ -442,29 +441,10 @@ function view_user_shifts() { $entry_list[] = "" . $entry['Nick'].""; } if ($angeltype['count'] - count($entries) > 0) { - // is the shift still running or alternatively is the user shift admin? - $user_may_join_shift = true; - - /* you cannot join if user already joined this shift */ - $user_may_join_shift &= !$my_shift; - - // you cannot join if user is not of this angel type - $user_may_join_shift &= in_array($angeltype['id'], $_SESSION['user_shifts']['types']); - - // you can only join if the shift is in future or running - $user_may_join_shift &= time() < $shift['end']; - - // User shift admins may join anybody in every shift - $user_may_join_shift |= in_array('user_shifts_admin', $privileges); - - if ($user_may_join_shift) { + if ((time() < $shift['end'] && !$my_shift) || in_array('user_shifts_admin', $privileges)) { $entry_list[] = '' . ($angeltype['count'] - count($entries)) . ' Helfer' . ($angeltype['count'] - count($entries) != 1 ? '' : '') . ' gebraucht »'; } else { - if(!in_array('user_shifts_admin', $privileges) && $angeltype['restricted'] == 1 && !isset($angeltype['confirm_user_id'])) { - $entry_list[] = ($angeltype['count'] - count($entries)) . ' Helfer gebraucht' . ' unconfirmed'; - } else { - $entry_list[] = ($angeltype['count'] - count($entries)) . ' Helfer gebraucht' . ' (Werde ' . $angeltype['name'] .')'; - } + $entry_list[] = ($angeltype['count'] - count($entries)) . ' Helfer gebraucht'; } $is_free = true; } @@ -525,8 +505,8 @@ function view_user_shifts() { $shift_has_special_needs = 0 < sql_num_query("SELECT `id` FROM `NeededAngelTypes` WHERE `shift_id` = " . $shift['SID']); $query = "SELECT * 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']) . ") + JOIN `AngelTypes` + ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id`) WHERE "; if ($shift_has_special_needs) $query .= "`shift_id` = " . sql_escape($shift['SID']); @@ -553,30 +533,10 @@ function view_user_shifts() { 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; - - /* you cannot join if user already joined this shift */ - $user_may_join_shift &= !$my_shift; - - // you cannot join if user is not of this angel type - $user_may_join_shift &= in_array($angeltype['id'], $_SESSION['user_shifts']['types']); - - // you can only join if the shift is in future or running - $user_may_join_shift &= time() < $shift['end']; - - // User shift admins may join anybody in every shift - $user_may_join_shift |= in_array('user_shifts_admin', $privileges); - - if ($user_may_join_shift) + if ((time() < $shift['end'] && !$my_shift) || in_array('user_shifts_admin', $privileges)) $entry_list[] = '' . $inner_text . ' »'; - else { - if(!in_array('user_shifts_admin', $privileges) && $angeltype['restricted'] == 1 && !isset($angeltype['confirm_user_id'])) { - $entry_list[] = $inner_text . ' unconfirmed'; - } else { - $entry_list[] = $inner_text . ' (Werde ' . $angeltype['name'] .')'; - } - } - + else + $entry_list[] = $inner_text; unset($inner_text); $is_free = true; } @@ -639,7 +599,7 @@ function make_select($items, $selected, $name, $title = null) { $html_items[] = '
  • ' . $title . '
  • ' . "\n"; foreach ($items as $i) - $html_items[] = '
  • ' . (!isset($i['enabled']) || $i['enabled'] ? '' : ' unconfirmed') . '
  • '; + $html_items[] = '
  • '; $html = '
    ' . "\n"; $html .= '