From 0603d0dd4eee2e051c1cab235ef32b5e147495ad Mon Sep 17 00:00:00 2001 From: msquare Date: Wed, 28 Dec 2016 12:11:35 +0100 Subject: [PATCH] remove unused code --- includes/controller/rooms_controller.php | 8 ++++---- includes/model/Shifts_model.php | 14 +++++++------- includes/mysqli_provider.php | 2 +- includes/pages/user_shifts.php | 12 +++++++----- includes/view/Shifts_view.php | 4 ++-- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/includes/controller/rooms_controller.php b/includes/controller/rooms_controller.php index 7a4f543b..24bf5220 100644 --- a/includes/controller/rooms_controller.php +++ b/includes/controller/rooms_controller.php @@ -11,7 +11,7 @@ use Engelsystem\ShiftCalendarRenderer; * View a room with its shifts. */ function room_controller() { - global $privileges, $user; + global $privileges; if (! in_array('view_rooms', $privileges)) { redirect(page_link_to()); @@ -43,9 +43,9 @@ function room_controller() { $shiftsFilterRenderer = new ShiftsFilterRenderer($shiftsFilter); $shiftsFilterRenderer->enableDaySelection($days); - $shifts = Shifts_by_ShiftsFilter($shiftsFilter, $user); - $needed_angeltypes = NeededAngeltypes_by_ShiftsFilter($shiftsFilter, $user); - $shift_entries = ShiftEntries_by_ShiftsFilter($shiftsFilter, $user); + $shifts = Shifts_by_ShiftsFilter($shiftsFilter); + $needed_angeltypes = NeededAngeltypes_by_ShiftsFilter($shiftsFilter); + $shift_entries = ShiftEntries_by_ShiftsFilter($shiftsFilter); return [ $room['Name'], diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index c23e4c0a..c5eab1fd 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -10,7 +10,7 @@ function Shifts_by_room($room) { return $result; } -function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter, $user) { +function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter) { $SQL = "SELECT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` as `room_name` FROM `Shifts` JOIN `Room` USING (`RID`) @@ -69,7 +69,7 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter, $user) { return $result; } -function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter, $user) { +function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter) { $SQL = "SELECT `NeededAngelTypes`.*, `Shifts`.`SID`, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup` FROM `Shifts` JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID` @@ -121,7 +121,7 @@ function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype) { return $result[0]; } -function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter, $user) { +function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter) { $SQL = "SELECT `User`.`Nick`, `User`.`email`, `User`.`email_shiftinfo`, `User`.`Sprache`, `User`.`Gekommen`, `ShiftEntry`.`UID`, `ShiftEntry`.`TID`, `ShiftEntry`.`SID`, `ShiftEntry`.`Comment`, `ShiftEntry`.`freeloaded` FROM `Shifts` JOIN `ShiftEntry` ON `ShiftEntry`.`SID`=`Shifts`.`SID` @@ -235,7 +235,7 @@ function Shift_signup_allowed_angel($user, $shift, $angeltype, $user_angeltype, /** * Check if an angeltype supporter can sign up a user to a shift. */ -function Shift_signup_allowed_angeltype_supporter($shift, $angeltype, $needed_angeltype, $shift_entries) { +function Shift_signup_allowed_angeltype_supporter($angeltype, $needed_angeltype, $shift_entries) { $free_entries = Shift_free_entries($needed_angeltype, $shift_entries); if ($free_entries == 0) { return new ShiftSignupState(ShiftSignupState::OCCUPIED, $free_entries); @@ -252,7 +252,7 @@ function Shift_signup_allowed_angeltype_supporter($shift, $angeltype, $needed_an * @param AngelType $angeltype * The angeltype to which the user wants to sign up */ -function Shift_signup_allowed_admin($shift, $angeltype, $needed_angeltype, $shift_entries) { +function Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entries) { $free_entries = Shift_free_entries($needed_angeltype, $shift_entries); if ($free_entries == 0) { // User shift admins may join anybody in every shift @@ -276,11 +276,11 @@ function Shift_signup_allowed($signup_user, $shift, $angeltype, $user_angeltype global $user, $privileges; if (in_array('user_shifts_admin', $privileges)) { - return Shift_signup_allowed_admin($shift, $angeltype, $needed_angeltype, $shift_entries); + return Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entries); } if (in_array('shiftentry_edit_angeltype_supporter', $privileges) && User_is_AngelType_supporter($user, $angeltype)) { - return Shift_signup_allowed_angeltype_supporter($shift, $angeltype, $needed_angeltype, $shift_entries); + return Shift_signup_allowed_angeltype_supporter($angeltype, $needed_angeltype, $shift_entries); } return Shift_signup_allowed_angel($signup_user, $shift, $angeltype, $user_angeltype, $user_shifts, $needed_angeltype, $shift_entries); diff --git a/includes/mysqli_provider.php b/includes/mysqli_provider.php index b77f6815..c81f157f 100644 --- a/includes/mysqli_provider.php +++ b/includes/mysqli_provider.php @@ -129,7 +129,7 @@ function sql_select_db($db_name) { * @return Result array or false on error */ function sql_select($query) { - global $sql_connection, $query_count; + global $sql_connection; // echo $query . ";\n"; // echo debug_string_backtrace() . "\n"; diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php index 3c37a63a..8a3dedb4 100644 --- a/includes/pages/user_shifts.php +++ b/includes/pages/user_shifts.php @@ -122,16 +122,18 @@ function view_user_shifts() { $types = load_types(); if (! isset($_SESSION['ShiftsFilter'])) { - $room_ids = array_map('get_ids_from_array', $rooms); + $room_ids = [ + $rooms[0]['id'] + ]; $type_ids = array_map('get_ids_from_array', $types); - $_SESSION['ShiftsFilter'] = new ShiftsFilter(in_array('user_shifts_admin', $privileges), [$rooms[0]['id']], $type_ids); + $_SESSION['ShiftsFilter'] = new ShiftsFilter(in_array('user_shifts_admin', $privileges), $room_ids, $type_ids); } update_ShiftsFilter($_SESSION['ShiftsFilter'], in_array('user_shifts_admin', $privileges), $days); $shiftsFilter = $_SESSION['ShiftsFilter']; - $shifts = Shifts_by_ShiftsFilter($shiftsFilter, $user); - $needed_angeltypes = NeededAngeltypes_by_ShiftsFilter($shiftsFilter, $user); - $shift_entries = ShiftEntries_by_ShiftsFilter($shiftsFilter, $user); + $shifts = Shifts_by_ShiftsFilter($shiftsFilter); + $needed_angeltypes = NeededAngeltypes_by_ShiftsFilter($shiftsFilter); + $shift_entries = ShiftEntries_by_ShiftsFilter($shiftsFilter); if ($user['api_key'] == "") { User_reset_api_key($user, false); diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php index c2c0912e..765a6f3b 100644 --- a/includes/view/Shifts_view.php +++ b/includes/view/Shifts_view.php @@ -12,9 +12,9 @@ function Shift_editor_info_render($shift) { return join('
', $info); } -function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null, $user_shifts = null) { +function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null) { global $user; - + if ($user_angeltype == null) { $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype); }