From d92986a13d22f38133e267e0ba138e82754396f7 Mon Sep 17 00:00:00 2001 From: plegall Date: Thu, 3 Aug 2023 11:19:44 +0200 Subject: [PATCH] fixes #1920 new output parameter save_visits for pwg.session.getStatus --- include/functions.inc.php | 43 +++++++++++++++++++++++++----------- include/ws_functions/pwg.php | 1 + 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/include/functions.inc.php b/include/functions.inc.php index e5278da7c..a26cc7406 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -385,6 +385,35 @@ SELECT id, name return $languages; } +/** + * Does the current user must log visits in history table + * + * @since 14 + * + * @param int $image_id + * @param string $image_type + * + * @return bool + */ +function do_log($image_id = null, $image_type = null) +{ + global $conf; + + $do_log = $conf['log']; + if (is_admin()) + { + $do_log = $conf['history_admin']; + } + if (is_a_guest()) + { + $do_log = $conf['history_guest']; + } + + $do_log = trigger_change('pwg_log_allowed', $do_log, $image_id, $image_type); + + return $do_log; +} + /** * log the visit into history table * @@ -414,19 +443,7 @@ UPDATE '.USER_INFOS_TABLE.' pwg_query($query); } - $do_log = $conf['log']; - if (is_admin()) - { - $do_log = $conf['history_admin']; - } - if (is_a_guest()) - { - $do_log = $conf['history_guest']; - } - - $do_log = trigger_change('pwg_log_allowed', $do_log, $image_id, $image_type); - - if (!$do_log) + if (!do_log($image_id, $image_type)) { return false; } diff --git a/include/ws_functions/pwg.php b/include/ws_functions/pwg.php index 416b8c53f..7fc174364 100644 --- a/include/ws_functions/pwg.php +++ b/include/ws_functions/pwg.php @@ -389,6 +389,7 @@ function ws_session_getStatus($params, &$service) list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); $res['current_datetime'] = $dbnow; $res['version'] = PHPWG_VERSION; + $res['save_visits'] = do_log(); // Piwigo Remote Sync does not support receiving the available sizes $piwigo_remote_sync_agent = 'Apache-HttpClient/';