From 53ad1b5110e22bdbb57960aec7d29b824dda7b5b Mon Sep 17 00:00:00 2001 From: msquare Date: Sun, 21 Aug 2016 18:00:24 +0200 Subject: [PATCH] fix codacy unused code --- includes/controller/angeltypes_controller.php | 2 +- includes/controller/user_angeltypes_controller.php | 2 +- .../controller/user_driver_licenses_controller.php | 2 +- includes/controller/users_controller.php | 2 +- includes/mailer/shifts_mailer.php | 2 +- includes/mysqli_provider.php | 1 - includes/pages/admin_active.php | 4 ++-- includes/pages/admin_arrive.php | 3 +-- includes/pages/admin_groups.php | 2 -- includes/pages/admin_questions.php | 2 +- includes/pages/admin_rooms.php | 2 -- includes/pages/admin_shifts.php | 1 - includes/pages/guest_login.php | 4 ++-- includes/pages/user_atom.php | 2 +- includes/pages/user_myshifts.php | 1 - includes/pages/user_news.php | 2 +- includes/pages/user_settings.php | 1 - includes/pages/user_shifts.php | 6 ++---- includes/sys_menu.php | 13 ------------- includes/view/User_view.php | 1 - 20 files changed, 15 insertions(+), 40 deletions(-) diff --git a/includes/controller/angeltypes_controller.php b/includes/controller/angeltypes_controller.php index d6da427e..74a191a7 100644 --- a/includes/controller/angeltypes_controller.php +++ b/includes/controller/angeltypes_controller.php @@ -42,7 +42,7 @@ function angeltype_link($angeltype_id) { * Job description for all angeltypes (public to everyone) */ function angeltypes_about_controller() { - global $privileges, $user; + global $user; if (isset($user)) $angeltypes = AngelTypes_with_user($user); diff --git a/includes/controller/user_angeltypes_controller.php b/includes/controller/user_angeltypes_controller.php index c6115b6c..1c7addc9 100644 --- a/includes/controller/user_angeltypes_controller.php +++ b/includes/controller/user_angeltypes_controller.php @@ -23,7 +23,7 @@ function user_angeltypes_unconfirmed_hint() { * Remove all unconfirmed users from a specific angeltype. */ function user_angeltypes_delete_all_controller() { - global $user, $privileges; + global $user; if (! isset($_REQUEST['angeltype_id'])) { error(_("Angeltype doesn't exist.")); diff --git a/includes/controller/user_driver_licenses_controller.php b/includes/controller/user_driver_licenses_controller.php index d13d84d9..0118eeb4 100644 --- a/includes/controller/user_driver_licenses_controller.php +++ b/includes/controller/user_driver_licenses_controller.php @@ -30,7 +30,7 @@ function user_driver_license_required_hint() { * Route user driver licenses actions. */ function user_driver_licenses_controller() { - global $privileges, $user; + global $user; if (! isset($user)) redirect(page_link_to('')); diff --git a/includes/controller/users_controller.php b/includes/controller/users_controller.php index 404b7f9b..672cbb0f 100644 --- a/includes/controller/users_controller.php +++ b/includes/controller/users_controller.php @@ -4,7 +4,7 @@ * Route user actions. */ function users_controller() { - global $privileges, $user; + global $user; if (! isset($user)) redirect(page_link_to('')); diff --git a/includes/mailer/shifts_mailer.php b/includes/mailer/shifts_mailer.php index e50cd1a1..8189883a 100644 --- a/includes/mailer/shifts_mailer.php +++ b/includes/mailer/shifts_mailer.php @@ -60,7 +60,7 @@ function mail_shift_delete($shift) { $message = _("A Shift you are registered on was deleted:") . "\n"; $message .= $shift["name"] . "\n"; - $message .= $new_shift["title"] . "\n"; + $message .= $shift["title"] . "\n"; $message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n"; $message .= $room["Name"] . "\n"; diff --git a/includes/mysqli_provider.php b/includes/mysqli_provider.php index d27a1d58..4a3f2a45 100644 --- a/includes/mysqli_provider.php +++ b/includes/mysqli_provider.php @@ -189,7 +189,6 @@ function sql_bool($boolean) { * @return int Count of result lines */ function sql_num_query($query) { - global $sql_connection; return sql_query($query)->num_rows; } diff --git a/includes/pages/admin_active.php b/includes/pages/admin_active.php index 3ff3e0fb..ab962a93 100644 --- a/includes/pages/admin_active.php +++ b/includes/pages/admin_active.php @@ -5,7 +5,7 @@ function admin_active_title() { } function admin_active() { - global $tshirt_sizes, $shift_sum_formula; + global $tshirt_sizes; $msg = ""; $search = ""; @@ -146,7 +146,7 @@ function admin_active() { } $shirt_statistics = []; - foreach ($tshirt_sizes as $size => $_) { + foreach (array_keys($tshirt_sizes) as $size) { if ($size != '') { $shirt_statistics[] = [ 'size' => $size, diff --git a/includes/pages/admin_arrive.php b/includes/pages/admin_arrive.php index a061df6a..9dcf8e4e 100644 --- a/includes/pages/admin_arrive.php +++ b/includes/pages/admin_arrive.php @@ -36,7 +36,6 @@ function admin_arrive() { $arrival_count_at_day = []; $planned_arrival_count_at_day = []; $planned_departure_count_at_day = []; - $table = ""; $users_matched = []; if ($search == "") $tokens = []; @@ -104,7 +103,7 @@ function admin_arrive() { ]; } - $planned_arrival_sum_at_day = []; + $planned_arrival_at_day = []; $planned_arrival_sum = 0; foreach ($planned_arrival_count_at_day as $day => $count) { $planned_arrival_sum += $count; diff --git a/includes/pages/admin_groups.php b/includes/pages/admin_groups.php index f43c63e9..bf6d08d0 100644 --- a/includes/pages/admin_groups.php +++ b/includes/pages/admin_groups.php @@ -4,8 +4,6 @@ function admin_groups_title() { } function admin_groups() { - global $user; - $html = ""; $groups = sql_select("SELECT * FROM `Groups` ORDER BY `Name`"); if (! isset($_REQUEST["action"])) { diff --git a/includes/pages/admin_questions.php b/includes/pages/admin_questions.php index e2fef880..6154cd6e 100644 --- a/includes/pages/admin_questions.php +++ b/includes/pages/admin_questions.php @@ -4,7 +4,7 @@ function admin_questions_title() { } function admin_new_questions() { - global $user, $privileges; + global $privileges; if (in_array("admin_questions", $privileges)) { $new_messages = sql_num_query("SELECT * FROM `Questions` WHERE `AID` IS NULL"); diff --git a/includes/pages/admin_rooms.php b/includes/pages/admin_rooms.php index 5621ba8f..2fc094f9 100644 --- a/includes/pages/admin_rooms.php +++ b/includes/pages/admin_rooms.php @@ -5,8 +5,6 @@ function admin_rooms_title() { } function admin_rooms() { - global $user; - $rooms_source = sql_select("SELECT * FROM `Room` ORDER BY `Name`"); $rooms = array(); foreach ($rooms_source as $room) diff --git a/includes/pages/admin_shifts.php b/includes/pages/admin_shifts.php index 346e9046..692f79a7 100644 --- a/includes/pages/admin_shifts.php +++ b/includes/pages/admin_shifts.php @@ -290,7 +290,6 @@ function admin_shifts() { if (! isset($_REQUEST['rid'])) $_REQUEST['rid'] = null; - $room_select = html_select_key('rid', 'rid', $room_array, $_REQUEST['rid']); $angel_types = ""; foreach ($types as $type) $angel_types .= '
' . form_spinner('type_' . $type['id'], $type['name'], $needed_angel_types[$type['id']]) . '
'; diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php index ed8b4dae..1d8a34dd 100644 --- a/includes/pages/guest_login.php +++ b/includes/pages/guest_login.php @@ -105,7 +105,7 @@ function guest_register() { } $selected_angel_types = array(); - foreach ($angel_types as $angel_type_id => $angel_type_name) + foreach (array_keys($angel_types) as $angel_type_id) if (isset($_REQUEST['angel_types_' . $angel_type_id])) $selected_angel_types[] = $angel_type_id; @@ -252,7 +252,7 @@ function guest_logout() { } function guest_login() { - global $user, $privileges; + global $privileges; $nick = ""; diff --git a/includes/pages/user_atom.php b/includes/pages/user_atom.php index c9420c91..e0093886 100644 --- a/includes/pages/user_atom.php +++ b/includes/pages/user_atom.php @@ -2,7 +2,7 @@ // publically available page to feed the news to feedreaders function user_atom() { - global $ical_shifts, $user, $DISPLAY_NEWS; + global $user, $DISPLAY_NEWS; if (isset ($_REQUEST['key']) && preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) $key = $_REQUEST['key']; diff --git a/includes/pages/user_myshifts.php b/includes/pages/user_myshifts.php index 7d2472aa..946ff2e0 100644 --- a/includes/pages/user_myshifts.php +++ b/includes/pages/user_myshifts.php @@ -8,7 +8,6 @@ function myshifts_title() { function user_myshifts() { global $LETZTES_AUSTRAGEN; global $user, $privileges; - $msg = ""; if (isset($_REQUEST['id']) && in_array("user_shifts_admin", $privileges) && preg_match("/^[0-9]{1,}$/", $_REQUEST['id']) && sql_num_query("SELECT * FROM `User` WHERE `UID`='" . sql_escape($_REQUEST['id']) . "'") > 0) { $id = $_REQUEST['id']; diff --git a/includes/pages/user_news.php b/includes/pages/user_news.php index 7c104095..289cd326 100644 --- a/includes/pages/user_news.php +++ b/includes/pages/user_news.php @@ -12,7 +12,7 @@ function meetings_title() { } function user_meetings() { - global $DISPLAY_NEWS, $privileges, $user; + global $DISPLAY_NEWS, $user; $html = '

' . meetings_title() . '

' . msg(); diff --git a/includes/pages/user_settings.php b/includes/pages/user_settings.php index 466d3c3e..69b9d005 100644 --- a/includes/pages/user_settings.php +++ b/includes/pages/user_settings.php @@ -21,7 +21,6 @@ function user_settings() { $jabber = $user['jabber']; $hometown = $user['Hometown']; $tshirt_size = $user['Size']; - $password_hash = ""; $selected_theme = $user['color']; $selected_language = $user['Sprache']; $planned_arrival_date = $user['planned_arrival_date']; diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php index 63ca2543..e4d20fdc 100644 --- a/includes/pages/user_shifts.php +++ b/includes/pages/user_shifts.php @@ -5,7 +5,7 @@ function shifts_title() { } function user_shifts() { - global $user, $privileges, $max_freeloadable_shifts; + global $user, $privileges; if (User_is_freeloader($user)) redirect(page_link_to('user_myshifts')); @@ -162,7 +162,7 @@ function user_shifts() { $needed_angel_types_info[] = $angel_types[$type_id]['name'] . ": " . $count; } - engelsystem_log("Updated shift '" . $name . "' from " . date("Y-m-d H:i", $start) . " to " . date("Y-m-d H:i", $end) . " with angel types " . join(", ", $needed_angel_types_info)); + engelsystem_log("Updated shift '" . $shifttypes[$shifttype_id] . ", " . $title . "' from " . date("Y-m-d H:i", $start) . " to " . date("Y-m-d H:i", $end) . " with angel types " . join(", ", $needed_angel_types_info)); success(_("Shift updated.")); redirect(shift_link([ @@ -171,8 +171,6 @@ function user_shifts() { } } - $room_select = html_select_key('rid', 'rid', $room_array, $rid); - $angel_types = ""; foreach ($types as $type) $angel_types .= form_spinner('type_' . $type['id'], $type['name'], $needed_angel_types[$type['id']]); diff --git a/includes/sys_menu.php b/includes/sys_menu.php index cf5b76fc..96522fa7 100644 --- a/includes/sys_menu.php +++ b/includes/sys_menu.php @@ -139,19 +139,6 @@ function make_navigation() { return toolbar($menu); } -function make_navigation_for($name, $pages) { - global $privileges, $p; - - $menu = ""; - foreach ($pages as $page) - if (in_array($page, $privileges)) - $menu .= '' . $title . ''; - - if ($menu != "") - $menu = ''; - return $menu; -} - function make_menu() { return make_navigation(); } diff --git a/includes/view/User_view.php b/includes/view/User_view.php index 1c4d4abd..fca21e37 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -132,7 +132,6 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel $user_name = htmlspecialchars($user_source['Vorname']) . " " . htmlspecialchars($user_source['Name']); $myshifts_table = array(); - $html = ""; $timesum = 0; foreach ($shifts as $shift) { $shift_info = '' . $shift['name'] . '';