From 8f5e3d5efb486a556de3e09a35b1e6b9f527f9cf Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 29 Nov 2014 15:18:47 +0000 Subject: [PATCH 1/7] [ticket/13147] Allow changing the result of calling get_global_visibility_sql PHPBB3-13147 --- phpBB/phpbb/content_visibility.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index de0e389dd1..9647095f78 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -244,6 +244,26 @@ class content_visibility $approve_forums = array_diff(array_keys($this->auth->acl_getf('m_approve', true)), $exclude_forum_ids); + /** + * Allow changing the result of calling get_global_visibility_sql + * + * @event core.phpbb_content_visibility_get_global_visibility_before + * @var array where_sqls The action the user tried to execute + * @var string mode Either "topic" or "post" depending on the query this is being used in + * @var array forum_ids Array of forum ids which the posts/topics are limited to + * @var string table_alias Table alias to prefix in SQL queries + * @var array approve_forums Array of forums where the user has m_approve permissions + * @since 3.1.3-RC1 + */ + $vars = array( + 'where_sqls', + 'mode', + 'forum_ids', + 'table_alias', + 'approve_forums', + ); + extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_global_visibility_before', compact($vars))); + if (sizeof($exclude_forum_ids)) { $where_sqls[] = '(' . $this->db->sql_in_set($table_alias . 'forum_id', $exclude_forum_ids, true) . ' From 0f6a0d820e435c3d61f165d8ed1e70c4110123af Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 29 Nov 2014 15:22:15 +0000 Subject: [PATCH 2/7] [ticket/13147] Using $phpbb_dispatcher global var PHPBB3-13147 --- phpBB/phpbb/content_visibility.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index 9647095f78..fafb564b79 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -240,10 +240,13 @@ class content_visibility */ public function get_global_visibility_sql($mode, $exclude_forum_ids = array(), $table_alias = '') { + global $phpbb_dispatcher; + $where_sqls = array(); $approve_forums = array_diff(array_keys($this->auth->acl_getf('m_approve', true)), $exclude_forum_ids); + $content_replaced = null; /** * Allow changing the result of calling get_global_visibility_sql * @@ -253,6 +256,7 @@ class content_visibility * @var array forum_ids Array of forum ids which the posts/topics are limited to * @var string table_alias Table alias to prefix in SQL queries * @var array approve_forums Array of forums where the user has m_approve permissions + * @var string content_replaced Forces the function to return an implosion of where_sqls (joined by "OR") * @since 3.1.3-RC1 */ $vars = array( @@ -261,8 +265,15 @@ class content_visibility 'forum_ids', 'table_alias', 'approve_forums', + 'content_replaced', ); - extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_global_visibility_before', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_global_visibility_before', compact($vars))); + + if ($content_replaced) + { + return $content_replaced; + } + if (sizeof($exclude_forum_ids)) { From a09c38f1cc2f19d2e475fdaa5b2be259565768ac Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 29 Nov 2014 15:25:16 +0000 Subject: [PATCH 3/7] [ticket/13147] Removing globals and using injection Using globals is NG. Using a parameter instead. PHPBB3-13147 --- phpBB/phpbb/content_visibility.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index fafb564b79..53ba50ef7c 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -240,8 +240,6 @@ class content_visibility */ public function get_global_visibility_sql($mode, $exclude_forum_ids = array(), $table_alias = '') { - global $phpbb_dispatcher; - $where_sqls = array(); $approve_forums = array_diff(array_keys($this->auth->acl_getf('m_approve', true)), $exclude_forum_ids); @@ -267,7 +265,7 @@ class content_visibility 'approve_forums', 'content_replaced', ); - extract($phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_global_visibility_before', compact($vars))); + extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_global_visibility_before', compact($vars))); if ($content_replaced) { From 9caec668afa2ecadb38bc5440a064d4fa69bf8b1 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 29 Nov 2014 15:26:16 +0000 Subject: [PATCH 4/7] [ticket/13147] Renaming content_replaced->get_global_visibility_sql_overwrite Renamed content_replaced to get_global_visibility_sql_overwrite in order to follow the convention in other events' variables that have the same basic function PHPBB3-13147 --- phpBB/phpbb/content_visibility.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index 53ba50ef7c..5443283f23 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -244,17 +244,17 @@ class content_visibility $approve_forums = array_diff(array_keys($this->auth->acl_getf('m_approve', true)), $exclude_forum_ids); - $content_replaced = null; + $get_global_visibility_sql_overwrite = null; /** * Allow changing the result of calling get_global_visibility_sql * * @event core.phpbb_content_visibility_get_global_visibility_before - * @var array where_sqls The action the user tried to execute - * @var string mode Either "topic" or "post" depending on the query this is being used in - * @var array forum_ids Array of forum ids which the posts/topics are limited to - * @var string table_alias Table alias to prefix in SQL queries - * @var array approve_forums Array of forums where the user has m_approve permissions - * @var string content_replaced Forces the function to return an implosion of where_sqls (joined by "OR") + * @var array where_sqls The action the user tried to execute + * @var string mode Either "topic" or "post" depending on the query this is being used in + * @var array forum_ids Array of forum ids which the posts/topics are limited to + * @var string table_alias Table alias to prefix in SQL queries + * @var array approve_forums Array of forums where the user has m_approve permissions + * @var string get_global_visibility_sql_overwrite Forces the function to return an implosion of where_sqls (joined by "OR") * @since 3.1.3-RC1 */ $vars = array( @@ -263,13 +263,13 @@ class content_visibility 'forum_ids', 'table_alias', 'approve_forums', - 'content_replaced', + 'get_global_visibility_sql_overwrite', ); extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_global_visibility_before', compact($vars))); - if ($content_replaced) + if ($get_global_visibility_sql_overwrite) { - return $content_replaced; + return $get_global_visibility_sql_overwrite; } From 8ed5a047ecfd4ad3b8f87e2adcff577015e6470a Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 10 Jan 2015 11:48:01 +0000 Subject: [PATCH 5/7] [ticket/13147] Wrong extra new line PHPBB3-13147 --- phpBB/phpbb/content_visibility.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index 5443283f23..06f2975fb9 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -272,7 +272,6 @@ class content_visibility return $get_global_visibility_sql_overwrite; } - if (sizeof($exclude_forum_ids)) { $where_sqls[] = '(' . $this->db->sql_in_set($table_alias . 'forum_id', $exclude_forum_ids, true) . ' From ef9abd7165f67abea74243a72aefb806d7b9be7a Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 10 Jan 2015 17:15:22 +0000 Subject: [PATCH 6/7] [ticket/13147] Override variable name changed by request PHPBB3-13147 --- phpBB/phpbb/content_visibility.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index 06f2975fb9..58becf33d9 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -244,7 +244,7 @@ class content_visibility $approve_forums = array_diff(array_keys($this->auth->acl_getf('m_approve', true)), $exclude_forum_ids); - $get_global_visibility_sql_overwrite = null; + $visibility_sql_overwrite = null; /** * Allow changing the result of calling get_global_visibility_sql * @@ -254,7 +254,7 @@ class content_visibility * @var array forum_ids Array of forum ids which the posts/topics are limited to * @var string table_alias Table alias to prefix in SQL queries * @var array approve_forums Array of forums where the user has m_approve permissions - * @var string get_global_visibility_sql_overwrite Forces the function to return an implosion of where_sqls (joined by "OR") + * @var string visibility_sql_overwrite Forces the function to return an implosion of where_sqls (joined by "OR") * @since 3.1.3-RC1 */ $vars = array( @@ -263,13 +263,13 @@ class content_visibility 'forum_ids', 'table_alias', 'approve_forums', - 'get_global_visibility_sql_overwrite', + 'visibility_sql_overwrite', ); extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_global_visibility_before', compact($vars))); - if ($get_global_visibility_sql_overwrite) + if ($visibility_sql_overwrite) { - return $get_global_visibility_sql_overwrite; + return $visibility_sql_overwrite; } if (sizeof($exclude_forum_ids)) From e0733ae435afed03a05bbfd6ebf88de534d549d2 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 10 Jan 2015 17:15:54 +0000 Subject: [PATCH 7/7] [ticket/13147] New line before comment block PHPBB3-13147 --- phpBB/phpbb/content_visibility.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index 58becf33d9..c8516d6c85 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -245,6 +245,7 @@ class content_visibility $approve_forums = array_diff(array_keys($this->auth->acl_getf('m_approve', true)), $exclude_forum_ids); $visibility_sql_overwrite = null; + /** * Allow changing the result of calling get_global_visibility_sql *