From fb07012b0683aa5ffccf470fe9f8c79e7c68b019 Mon Sep 17 00:00:00 2001 From: Matthieu Leproux Date: Wed, 12 Jan 2022 15:08:46 +0100 Subject: [PATCH] related to #1595 cleaner code, removed unused functions --- .../themes/default/template/user_activity.tpl | 31 +---------------- include/ws_functions/pwg.php | 33 +++++++++---------- 2 files changed, 16 insertions(+), 48 deletions(-) diff --git a/admin/themes/default/template/user_activity.tpl b/admin/themes/default/template/user_activity.tpl index f2ce4cdce..c3fa0a23a 100644 --- a/admin/themes/default/template/user_activity.tpl +++ b/admin/themes/default/template/user_activity.tpl @@ -123,7 +123,7 @@ function get_user_activity(page, uid) { }, success: (data) => { /* console log to help debug */ - console.log(data); + {* console.log(data); *} uid_filter = uid; setCreationDate(data.result['result_lines'][data.result['result_lines'].length-1].date, data.result['result_lines'][0].date); @@ -137,8 +137,6 @@ function get_user_activity(page, uid) { $(".user-update-spinner").removeClass("icon-spin6"); $(".pagination-item-container").show(); update_pagination_menu(); - {* createUserFilter(); - fillUserFilter(data.result['filterable_users'], create_selecter, data.result['id_of']); *} }, error: (e) => { console.log("ajax call failed"); @@ -147,7 +145,6 @@ function get_user_activity(page, uid) { }) } - function lineConstructor(line) { let newLine = $("#-1").clone(); @@ -588,32 +585,6 @@ function get_initials(username) { return res; } -function filterUsers(username) { - let lines = $(".line"); - - showAllLines() - let resultLines = []; - - for (let index = 1; index < lines.length; index++) { - - if (username != lines[index].children[2].children[1].innerHTML) { - $("#" + lines[index].id).hide(); - } else { - resultLines.push(lines[index].getElementsByClassName("date-day")[0].textContent) - } - } - setCreationDate((!resultLines[resultLines.length-1]) ? "{'N/A'|translate}" : resultLines[resultLines.length-1], (!resultLines[0]) ? "{'N/A'|translate}" : resultLines[0]) -} - -function showAllLines() { - let lines = $(".line"); - for (let index = 1; index < lines.length; index++) { - $("#" + lines[index].id).show(); - } - - $("#-1").hide(); -} - function setCreationDate(startDate, endDate) { $(".start-date").html(startDate) diff --git a/include/ws_functions/pwg.php b/include/ws_functions/pwg.php index de62c7884..4a1a9e476 100644 --- a/include/ws_functions/pwg.php +++ b/include/ws_functions/pwg.php @@ -469,8 +469,6 @@ SELECT ;'; } - - $line_id = 0; $result = pwg_query($query); while ($row = pwg_db_fetch_assoc($result)) @@ -492,7 +490,7 @@ SELECT if ($line_key === $current_key) { - // j'incrémente le counter de la ligne précédente + // I increment the counter of the previous line $output_lines[count($output_lines)-1]['counter']++; $output_lines[count($output_lines)-1]['object_id'][] = $row['object_id']; } @@ -556,24 +554,23 @@ SELECT } } -if (isset($param['uid'])) { - $query = ' -SELECT - count(*) - FROM '.ACTIVITY_TABLE.' - WHERE performed_by = '.$param['uid'].' -;'; -} else { - $query = ' -SELECT - count(*) - FROM '.ACTIVITY_TABLE.' -;'; -} + if (isset($param['uid'])) { + $query = ' + SELECT + count(*) + FROM '.ACTIVITY_TABLE.' + WHERE performed_by = '.$param['uid'].' + ;'; + } else { + $query = ' + SELECT + count(*) + FROM '.ACTIVITY_TABLE.' + ;'; + } $result = (pwg_db_fetch_row(pwg_query($query))[0])/$page_size; - // return $output_lines; return array( 'result_lines' => $output_lines, 'max_page' => floor($result),