From 002abf87df0ed58183ab6f794b9b620cbe9cf083 Mon Sep 17 00:00:00 2001 From: plegall Date: Fri, 26 Aug 2022 16:58:11 +0200 Subject: [PATCH] fixes #911 new method pwg.history.log (to be used by PhotoSwipe, in SmartPocket or BootstrapDarkroom) --- include/ws_functions/pwg.php | 27 +++++++++++++++++++++++++++ ws.php | 13 +++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/ws_functions/pwg.php b/include/ws_functions/pwg.php index fe9a9ebd6..b714f1fb5 100644 --- a/include/ws_functions/pwg.php +++ b/include/ws_functions/pwg.php @@ -585,6 +585,33 @@ SELECT ); } +/** + * API method + * Log a new line in visit history + * @since 13 + */ +function ws_history_log($params, &$service) +{ + global $logger, $page; + + if (!empty($params['section']) and in_array($params['section'], get_enums(HISTORY_TABLE, 'section'))) + { + $page['section'] = $params['section']; + } + + if (!empty($params['cat_id'])) + { + $page['category'] = array('id' => $params['cat_id']); + } + + if (!empty($params['tags_string']) and preg_match('/^\d+(,\d+)*$/', $params['tags_string'])) + { + $page['tag_ids'] = explode(',', $params['tags_string']); + } + + pwg_log($params['image_id'], 'picture'); +} + /** * API method * Returns lines of an history search diff --git a/ws.php b/ws.php index 6cb3428cf..31e2d88d8 100644 --- a/ws.php +++ b/ws.php @@ -1293,6 +1293,19 @@ enabled_high, registration_date, registration_date_string, registration_date_sin $ws_functions_root . 'pwg.users.php' ); + $service->addMethod( + 'pwg.history.log', + 'ws_history_log', + array( + 'image_id' => array('type'=>WS_TYPE_ID), + 'cat_id' => array('type'=>WS_TYPE_ID, 'default'=>null), + 'section' => array('default'=>null), + 'tags_string' => array('default'=>null), + ), + 'Log visit in history', + $ws_functions_root . 'pwg.php' + ); + $service->addMethod( 'pwg.history.search', 'ws_history_search',