From 1bd003e67ff53d865e166830d88618bc3a27e910 Mon Sep 17 00:00:00 2001 From: Matthieu Leproux Date: Wed, 9 Nov 2022 15:46:21 +0100 Subject: [PATCH] (cp 9a4f927) fixed #1784 added button in user edit popin to go on te history page with the user as filter --- admin/history.php | 15 +++++++++++++++ admin/themes/default/js/history.js | 3 +++ admin/themes/default/js/user_list.js | 1 + admin/themes/default/template/history.tpl | 6 ++++-- admin/themes/default/template/user_list.tpl | 11 +++++++++++ admin/user_list.php | 1 + language/en_UK/admin.lang.php | 1 + language/fr_FR/admin.lang.php | 1 + 8 files changed, 37 insertions(+), 2 deletions(-) diff --git a/admin/history.php b/admin/history.php index ed0969930..90806d091 100644 --- a/admin/history.php +++ b/admin/history.php @@ -102,9 +102,24 @@ else $form_param['ip'] = isset($_GET['filter_ip']) ? $_GET['filter_ip'] : @$form['ip']; $form_param['image_id'] = isset($_GET['filter_image_id']) ? $_GET['filter_image_id'] : @$form['image_id']; +$form_param['user_id'] = isset($_GET['filter_user_id']) ? $_GET['filter_user_id'] : "-1"; + +if ($form_param['user_id'] != "-1") { + $query = ' + SELECT + username + FROM '.USERS_TABLE.' + WHERE id = '.$form_param['user_id'].' + ;'; + + list($form_param['user_name']) = pwg_db_fetch_row(pwg_query($query)); + $form_param['user_id'] = empty(pwg_db_fetch_row(pwg_query($query))) ? "-1" : $form_param['user_id']; +} $template->assign( array( + 'USER_ID' => $form_param['user_id'], + 'USER_NAME' => @$form_param['user_name'], 'IMAGE_ID' => $form_param['image_id'], 'FILENAME' => @$form['filename'], 'IP' => $form_param['ip'], diff --git a/admin/themes/default/js/history.js b/admin/themes/default/js/history.js index c27494a1a..8c1792c4f 100644 --- a/admin/themes/default/js/history.js +++ b/admin/themes/default/js/history.js @@ -9,6 +9,9 @@ $(document).ready(() => { if (current_param.image_id != "") { addImageFilter(current_param.image_id); } + if (current_param.user_id != "-1") { + addUserFilter(filter_user_name); + } $(".elem-type-select").on("change", function (e) { console.log($(".elem-type-select option:selected").attr("value")); diff --git a/admin/themes/default/js/user_list.js b/admin/themes/default/js/user_list.js index ad7067c28..cfe8efe87 100644 --- a/admin/themes/default/js/user_list.js +++ b/admin/themes/default/js/user_list.js @@ -1002,6 +1002,7 @@ function fill_user_edit_summary(user_to_edit, pop_in, isGuest) { pop_in.find('.user-property-register').tipTip({content:`${registered_str}
${user_to_edit.registration_date_since}`}); pop_in.find('.user-property-last-visit').html(get_formatted_date(user_to_edit.last_visit)); pop_in.find('.user-property-last-visit').tipTip({content: `${last_visit_str}
${user_to_edit.last_visit_since}`}); + pop_in.find('.user-property-history a').attr('href', history_base_url + user_to_edit.id); } function fill_user_edit_properties(user_to_edit, pop_in) { diff --git a/admin/themes/default/template/history.tpl b/admin/themes/default/template/history.tpl index 70a7bc182..607d5c85f 100644 --- a/admin/themes/default/template/history.tpl +++ b/admin/themes/default/template/history.tpl @@ -11,6 +11,8 @@ var month = dateObj.getUTCMonth() + 1; //months from 1-12 var day = dateObj.getUTCDate(); var year = dateObj.getUTCFullYear(); +var filter_user_name = "{$USER_NAME}"; + if (month < 10) month = "0" + month; if (day < 10) day = "0" + day; @@ -24,10 +26,10 @@ var current_param = { 2: "high", 3: "other" }, - user_id: "-1", + user_id: {$USER_ID}, image_id: {if isset($IMAGE_ID)}"{$IMAGE_ID}"{else}""{/if}, filename: "", - ip:{if isset($IP)}"{$IP}"{else}""{/if}, + ip: {if isset($IP)}"{$IP}"{else}""{/if}, display_thumbnail: "display_thumbnail_classic", pageNumber: 0 {* fetch lines from line 0 to line 100*} } diff --git a/admin/themes/default/template/user_list.tpl b/admin/themes/default/template/user_list.tpl index 7ced62739..2df6b5d23 100644 --- a/admin/themes/default/template/user_list.tpl +++ b/admin/themes/default/template/user_list.tpl @@ -34,6 +34,7 @@ const hide_str = '{'Hide'|@translate}'; const show_str = '{'Show'|@translate}'; const user_added_str = '{'User %s added'|@translate}'; const str_popin_update_btn = '{'Update'|@translate}'; +const history_base_url = "{$U_HISTORY}"; const view_selector = '{$view_selector}'; @@ -637,6 +638,11 @@ $(document).ready(function() {

{'Permissions'|@translate}

+
+ +
@@ -817,6 +823,11 @@ $(document).ready(function() { +
diff --git a/admin/user_list.php b/admin/user_list.php index a8d9c0f99..7d7f80548 100644 --- a/admin/user_list.php +++ b/admin/user_list.php @@ -102,6 +102,7 @@ SELECT $template->assign( array( + 'U_HISTORY' => get_root_url().'admin.php?page=history&filter_user_id=', 'PWG_TOKEN' => get_pwg_token(), 'NB_IMAGE_PAGE' => $default_user['nb_image_page'], 'RECENT_PERIOD' => $default_user['recent_period'], diff --git a/language/en_UK/admin.lang.php b/language/en_UK/admin.lang.php index f717e26a7..f96442345 100644 --- a/language/en_UK/admin.lang.php +++ b/language/en_UK/admin.lang.php @@ -1324,4 +1324,5 @@ $lang['The best is to have them made automatically on a regular basis.'] = 'The $lang['If anything bad happens during the update, you would be able to restore a backup.'] = 'If anything bad happens during the update, you would be able to restore a backup.'; $lang['Apply to root albums'] = 'Apply to root albums'; $lang['Album name must not be empty'] = 'Album name must not be empty'; +$lang['Visit history'] = 'Visit history'; // Leave this line empty diff --git a/language/fr_FR/admin.lang.php b/language/fr_FR/admin.lang.php index 1e8d7763f..c7c862ec1 100644 --- a/language/fr_FR/admin.lang.php +++ b/language/fr_FR/admin.lang.php @@ -1324,4 +1324,5 @@ $lang['The best is to have them made automatically on a regular basis.'] = 'Le m $lang['If anything bad happens during the update, you would be able to restore a backup.'] = 'Si quelque chose arrive pendant la mise à jour, il sera possible de restaurer la sauvegarde'; $lang['Apply to root albums'] = 'Appliquer aux albums racine'; $lang['Album name must not be empty'] = 'Le nom de l\'album ne doit pas être vide'; +$lang['Visit history'] = 'Historique des visites'; // Leave this line empty