From cf651ef81d611865a06d93c9db7c4dfcd680405c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 17 Mar 2012 23:50:28 +0100 Subject: [ticket/10714] Implement a class to add logs to the database. PHPBB3-10714 --- phpBB/includes/log/interface.php | 55 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 phpBB/includes/log/interface.php (limited to 'phpBB/includes/log/interface.php') diff --git a/phpBB/includes/log/interface.php b/phpBB/includes/log/interface.php new file mode 100644 index 0000000000..897b8a8211 --- /dev/null +++ b/phpBB/includes/log/interface.php @@ -0,0 +1,55 @@ + Date: Sun, 18 Mar 2012 13:42:08 +0100 Subject: [ticket/10714] Add @return null to doc blocks PHPBB3-10714 --- phpBB/includes/log/interface.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'phpBB/includes/log/interface.php') diff --git a/phpBB/includes/log/interface.php b/phpBB/includes/log/interface.php index 897b8a8211..7eda4b9710 100644 --- a/phpBB/includes/log/interface.php +++ b/phpBB/includes/log/interface.php @@ -31,11 +31,15 @@ interface phpbb_log_interface /** * This function allows disable the log-system. When add_log is called, the log will not be added to the database. + * + * @return null */ public function disable(); /** * This function allows re-enable the log-system. + * + * @return null */ public function enable(); -- cgit v1.2.1 From 55b94af82ecb7e73535bfbed6c278f1d992efecb Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 24 Mar 2012 16:27:52 +0100 Subject: [ticket/10714] Implement get_logs() based on view_log() I moved some stuff into its own function to make the code a bit clearer. PHPBB3-10714 --- phpBB/includes/log/interface.php | 64 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'phpBB/includes/log/interface.php') diff --git a/phpBB/includes/log/interface.php b/phpBB/includes/log/interface.php index 7eda4b9710..fde718b71a 100644 --- a/phpBB/includes/log/interface.php +++ b/phpBB/includes/log/interface.php @@ -56,4 +56,68 @@ interface phpbb_log_interface * @return int|bool Returns the log_id, if the entry was added to the database, false otherwise. */ public function add($mode, $user_id, $log_ip, $log_operation, $log_time, $additional_data); + + /** + * Grab the logs from the database + * + * @param string $mode The mode defines which log_type is used and in which log the entry is displayed. + * @param bool $count_logs Shall we count all matching log entries? + * @param int $limit Limit the number of entries that are returned + * @param int $offset Offset when fetching the log entries, f.e. on paginations + * @param mixed $forum_id Restrict the log entries to the given forum_id (can also be an array of forum_ids) + * @param int $topic_id Restrict the log entries to the given topic_id + * @param int $user_id Restrict the log entries to the given user_id + * @param int $log_time Only get log entries newer than the given timestamp + * @param string $sort_by SQL order option, e.g. 'l.log_time DESC' + * @param string $keywords Will only return log entries that have the keywords in log_operation or log_data + * + * @return array The result array with the logs + */ + public function get_logs($mode, $count_logs = true, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $log_time = 0, $sort_by = 'l.log_time DESC', $keywords = ''); + + /** + * Generates a sql condition out of the specified keywords + * + * @param string $keywords The keywords the user specified to search for + * + * @return string Returns the SQL condition searching for the keywords + */ + static public function generate_sql_keyword($keywords); + + /** + * Determinate whether the user is allowed to read and/or moderate the forum of the topic + * + * @param array $topic_ids Array with the topic ids + * + * @return array Returns an array with two keys 'm_' and 'read_f' which are also an array of topic_id => forum_id sets when the permissions are given. Sample: + * array( + * 'permission' => array( + * topic_id => forum_id + * ), + * ), + */ + static public function get_topic_auth($topic_ids); + + /** + * Get the data for all reportee form the database + * + * @param array $reportee_ids Array with the user ids of the reportees + * + * @return array Returns an array with the reportee data + */ + static public function get_reportee_data($reportee_ids); + + /** + * Get total log count + * + * @return int Returns the number of matching logs from the last call to get_logs() + */ + public function get_log_count(); + + /** + * Get offset of the last valid page + * + * @return int Returns the offset of the last valid page from the last call to get_logs() + */ + public function get_valid_offset(); } -- cgit v1.2.1 From 3170845a5011ea76af7f4f8359acafb43ad7e19e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 28 Mar 2012 15:48:45 +0200 Subject: [ticket/10714] Refactor disable mechanism to only disable certain types Only disable admin log when adding multiple users, so critical errors are still logged. PHPBB3-10714 --- phpBB/includes/log/interface.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/log/interface.php') diff --git a/phpBB/includes/log/interface.php b/phpBB/includes/log/interface.php index fde718b71a..feeab585bf 100644 --- a/phpBB/includes/log/interface.php +++ b/phpBB/includes/log/interface.php @@ -25,23 +25,31 @@ interface phpbb_log_interface /** * This function returns the state of the log-system. * - * @return bool True if log is enabled + * @param string $type The log type we want to check. Empty to get global log status. + * + * @return bool True if log for the type is enabled */ - public function is_enabled(); + public function is_enabled($type = ''); /** * This function allows disable the log-system. When add_log is called, the log will not be added to the database. * + * @param mixed $type The log type we want to disable. Empty to disable all logs. + * Can also be an array of types + * * @return null */ - public function disable(); + public function disable($type = ''); /** * This function allows re-enable the log-system. * + * @param mixed $type The log type we want to enable. Empty to enable all logs. + * Can also be an array of types + * * @return null */ - public function enable(); + public function enable($type = ''); /** * Adds a log to the database -- cgit v1.2.1 From 35089bc0136e019724ee4b6c301fb94da52173cf Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 11 Nov 2012 12:18:04 +0100 Subject: [ticket/10714] Fix some comments PHPBB3-10714 --- phpBB/includes/log/interface.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/log/interface.php') diff --git a/phpBB/includes/log/interface.php b/phpBB/includes/log/interface.php index feeab585bf..dd0df236f6 100644 --- a/phpBB/includes/log/interface.php +++ b/phpBB/includes/log/interface.php @@ -23,7 +23,7 @@ if (!defined('IN_PHPBB')) interface phpbb_log_interface { /** - * This function returns the state of the log-system. + * This function returns the state of the log system. * * @param string $type The log type we want to check. Empty to get global log status. * @@ -32,7 +32,7 @@ interface phpbb_log_interface public function is_enabled($type = ''); /** - * This function allows disable the log-system. When add_log is called, the log will not be added to the database. + * This function allows disable the log system. When add_log is called, the log will not be added to the database. * * @param mixed $type The log type we want to disable. Empty to disable all logs. * Can also be an array of types @@ -42,7 +42,7 @@ interface phpbb_log_interface public function disable($type = ''); /** - * This function allows re-enable the log-system. + * This function allows re-enable the log system. * * @param mixed $type The log type we want to enable. Empty to enable all logs. * Can also be an array of types @@ -93,7 +93,7 @@ interface phpbb_log_interface static public function generate_sql_keyword($keywords); /** - * Determinate whether the user is allowed to read and/or moderate the forum of the topic + * Determine whether the user is allowed to read and/or moderate the forum of the topic * * @param array $topic_ids Array with the topic ids * -- cgit v1.2.1 From 72d1cae3f35d6f72f341b06761642545c6c663d2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 11 Nov 2012 12:29:25 +0100 Subject: [ticket/10714] Remove some private functions from the log interface PHPBB3-10714 --- phpBB/includes/log/interface.php | 32 -------------------------------- 1 file changed, 32 deletions(-) (limited to 'phpBB/includes/log/interface.php') diff --git a/phpBB/includes/log/interface.php b/phpBB/includes/log/interface.php index dd0df236f6..b85dc3a474 100644 --- a/phpBB/includes/log/interface.php +++ b/phpBB/includes/log/interface.php @@ -83,38 +83,6 @@ interface phpbb_log_interface */ public function get_logs($mode, $count_logs = true, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $log_time = 0, $sort_by = 'l.log_time DESC', $keywords = ''); - /** - * Generates a sql condition out of the specified keywords - * - * @param string $keywords The keywords the user specified to search for - * - * @return string Returns the SQL condition searching for the keywords - */ - static public function generate_sql_keyword($keywords); - - /** - * Determine whether the user is allowed to read and/or moderate the forum of the topic - * - * @param array $topic_ids Array with the topic ids - * - * @return array Returns an array with two keys 'm_' and 'read_f' which are also an array of topic_id => forum_id sets when the permissions are given. Sample: - * array( - * 'permission' => array( - * topic_id => forum_id - * ), - * ), - */ - static public function get_topic_auth($topic_ids); - - /** - * Get the data for all reportee form the database - * - * @param array $reportee_ids Array with the user ids of the reportees - * - * @return array Returns an array with the reportee data - */ - static public function get_reportee_data($reportee_ids); - /** * Get total log count * -- cgit v1.2.1 From 37014abd022be4f7824a590b93a329f74aef442c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 16 Jan 2013 14:18:09 +0100 Subject: [ticket/10714] Fix several comments and variable names PHPBB3-10714 --- phpBB/includes/log/interface.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'phpBB/includes/log/interface.php') diff --git a/phpBB/includes/log/interface.php b/phpBB/includes/log/interface.php index b85dc3a474..254b65cb19 100644 --- a/phpBB/includes/log/interface.php +++ b/phpBB/includes/log/interface.php @@ -25,40 +25,42 @@ interface phpbb_log_interface /** * This function returns the state of the log system. * - * @param string $type The log type we want to check. Empty to get global log status. + * @param string $type The log type we want to check. Empty to get + * global log status. * * @return bool True if log for the type is enabled */ public function is_enabled($type = ''); /** - * This function allows disable the log system. When add_log is called, the log will not be added to the database. + * This function allows disabling the log system. When add_log is called + * and the type is disabled, the log will not be added to the database. * - * @param mixed $type The log type we want to disable. Empty to disable all logs. - * Can also be an array of types + * @param mixed $type The log type we want to disable. Empty to + * disable all logs. Can also be an array of types. * * @return null */ public function disable($type = ''); /** - * This function allows re-enable the log system. + * This function allows re-enabling the log system. * - * @param mixed $type The log type we want to enable. Empty to enable all logs. - * Can also be an array of types + * @param mixed $type The log type we want to enable. Empty to + * enable all logs. Can also be an array of types. * * @return null */ public function enable($type = ''); /** - * Adds a log to the database + * Adds a log entry to the database * * @param string $mode The mode defines which log_type is used and in which log the entry is displayed. * @param int $user_id User ID of the user * @param string $log_ip IP address of the user * @param string $log_operation Name of the operation - * @param int $log_time Timestamp when the log was added. + * @param int $log_time Timestamp when the log entry was added. * @param array $additional_data More arguments can be added, depending on the log_type * * @return int|bool Returns the log_id, if the entry was added to the database, false otherwise. -- cgit v1.2.1 From c0ab3f3ddddefa8f902ffa57c864e6db5bf1f440 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 22 Jan 2013 15:45:20 +0100 Subject: [ticket/10714] Fix several doc blocks and comments PHPBB3-10714 --- phpBB/includes/log/interface.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/log/interface.php') diff --git a/phpBB/includes/log/interface.php b/phpBB/includes/log/interface.php index 254b65cb19..24bf412ce0 100644 --- a/phpBB/includes/log/interface.php +++ b/phpBB/includes/log/interface.php @@ -56,24 +56,24 @@ interface phpbb_log_interface /** * Adds a log entry to the database * - * @param string $mode The mode defines which log_type is used and in which log the entry is displayed. + * @param string $mode The mode defines which log_type is used and from which log the entry is retrieved * @param int $user_id User ID of the user * @param string $log_ip IP address of the user * @param string $log_operation Name of the operation - * @param int $log_time Timestamp when the log entry was added. + * @param int $log_time Timestamp when the log entry was added, if empty time() will be used * @param array $additional_data More arguments can be added, depending on the log_type * * @return int|bool Returns the log_id, if the entry was added to the database, false otherwise. */ - public function add($mode, $user_id, $log_ip, $log_operation, $log_time, $additional_data); + public function add($mode, $user_id, $log_ip, $log_operation, $log_time = false, $additional_data = array()); /** * Grab the logs from the database * - * @param string $mode The mode defines which log_type is used and in which log the entry is displayed. + * @param string $mode The mode defines which log_type is used and ifrom which log the entry is retrieved * @param bool $count_logs Shall we count all matching log entries? * @param int $limit Limit the number of entries that are returned - * @param int $offset Offset when fetching the log entries, f.e. on paginations + * @param int $offset Offset when fetching the log entries, f.e. when paginating * @param mixed $forum_id Restrict the log entries to the given forum_id (can also be an array of forum_ids) * @param int $topic_id Restrict the log entries to the given topic_id * @param int $user_id Restrict the log entries to the given user_id -- cgit v1.2.1 From 46c4ff46e00e4f050a5c987027a4b05e72456162 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 3 Mar 2013 20:30:17 +0100 Subject: [ticket/10714] Logs are disabled for this page call only PHPBB3-10714 --- phpBB/includes/log/interface.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/log/interface.php') diff --git a/phpBB/includes/log/interface.php b/phpBB/includes/log/interface.php index 24bf412ce0..3b459c9bdf 100644 --- a/phpBB/includes/log/interface.php +++ b/phpBB/includes/log/interface.php @@ -33,8 +33,11 @@ interface phpbb_log_interface public function is_enabled($type = ''); /** - * This function allows disabling the log system. When add_log is called - * and the type is disabled, the log will not be added to the database. + * Disable log + * + * This function allows disabling the log system or parts of it, for this + * page call. When add_log is called and the type is disabled, + * the log will not be added to the database. * * @param mixed $type The log type we want to disable. Empty to * disable all logs. Can also be an array of types. @@ -44,6 +47,8 @@ interface phpbb_log_interface public function disable($type = ''); /** + * Enable log + * * This function allows re-enabling the log system. * * @param mixed $type The log type we want to enable. Empty to -- cgit v1.2.1