From 909bb523bf1d7d3d517bf94404e0e4f1707512d7 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 29 Nov 2014 10:55:53 +0000 Subject: [ticket/13146] Allow changing the result of calling get_forums_visibility_sql PHPBB3-13146 --- phpBB/phpbb/content_visibility.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'phpBB') diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index 8bd537586e..cab3d2952d 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -158,6 +158,25 @@ class content_visibility { $where_sql = '('; + /** + * Allow changing the result of calling get_forums_visibility_sql + * + * @event core.phpbb_content_visibility_get_forums_visibility_before + * @var string where_sql 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 + * @since 3.1.3-RC1 + */ + $vars = array( + 'where_sql', + 'mode', + 'forum_ids', + 'table_alias', + 'content_replaced', + ); + extract($phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_forums_visibility_before', compact($vars))); + $approve_forums = array_intersect($forum_ids, array_keys($this->auth->acl_getf('m_approve', true))); if (sizeof($approve_forums)) -- cgit v1.2.1 From 0388d82504b672aa34a23baa2d0c2804c038caa2 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 29 Nov 2014 10:56:21 +0000 Subject: [ticket/13146] Adding $content_replaced to allow even more flexibility PHPBB3-13146 --- phpBB/phpbb/content_visibility.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'phpBB') diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index cab3d2952d..66cd7a8c86 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -158,6 +158,7 @@ class content_visibility { $where_sql = '('; + $content_replaced = false; /** * Allow changing the result of calling get_forums_visibility_sql * @@ -166,6 +167,7 @@ class content_visibility * @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 bool content_replaced Forces the function to return where_sql after executing the event * @since 3.1.3-RC1 */ $vars = array( @@ -177,6 +179,11 @@ class content_visibility ); extract($phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_forums_visibility_before', compact($vars))); + if ($contentReplaced) + { + return $content_replaced; + } + $approve_forums = array_intersect($forum_ids, array_keys($this->auth->acl_getf('m_approve', true))); if (sizeof($approve_forums)) -- cgit v1.2.1 From e596d0b6cef2a59aedaf9f20cdbf3d5f1ab46a9b Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 29 Nov 2014 11:27:57 +0000 Subject: [ticket/13147] Adding $approve_forums to the list of the event's variables PHPBB3-13147 --- phpBB/phpbb/content_visibility.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index 66cd7a8c86..dcf32f8f58 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -158,6 +158,8 @@ class content_visibility { $where_sql = '('; + $approve_forums = array_intersect($forum_ids, array_keys($this->auth->acl_getf('m_approve', true))); + $content_replaced = false; /** * Allow changing the result of calling get_forums_visibility_sql @@ -167,6 +169,7 @@ class content_visibility * @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 bool content_replaced Forces the function to return where_sql after executing the event * @since 3.1.3-RC1 */ @@ -175,6 +178,7 @@ class content_visibility 'mode', 'forum_ids', 'table_alias', + 'approve_forums', 'content_replaced', ); extract($phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_forums_visibility_before', compact($vars))); @@ -184,8 +188,6 @@ class content_visibility return $content_replaced; } - $approve_forums = array_intersect($forum_ids, array_keys($this->auth->acl_getf('m_approve', true))); - if (sizeof($approve_forums)) { // Remove moderator forums from the rest -- cgit v1.2.1 From e279a779fc5533ab13ef214b9c65674f9c99f865 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 29 Nov 2014 14:10:06 +0000 Subject: [ticket/13146] Typo on the returning variable PHPBB3-13146 --- phpBB/phpbb/content_visibility.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index dcf32f8f58..f1e470a8d1 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -185,7 +185,7 @@ class content_visibility if ($contentReplaced) { - return $content_replaced; + return $where_sql; } if (sizeof($approve_forums)) -- cgit v1.2.1 From e9cb9baedb4bf73f25e476ab692614a52a9ae625 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 29 Nov 2014 14:10:41 +0000 Subject: [ticket/13146] $phpbb_dispatcher was missing Added $phpbb_dispatcher to the globals list for this function. PHPBB3-13146 --- phpBB/phpbb/content_visibility.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB') diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index f1e470a8d1..f1f350a260 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -156,6 +156,8 @@ class content_visibility */ public function get_forums_visibility_sql($mode, $forum_ids = array(), $table_alias = '') { + global $phpbb_dispatcher; + $where_sql = '('; $approve_forums = array_intersect($forum_ids, array_keys($this->auth->acl_getf('m_approve', true))); -- cgit v1.2.1 From df3447b7256f4d462dcd18107c0a503289cfce53 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 29 Nov 2014 14:11:42 +0000 Subject: [ticket/13146] Extra line for clarity Added an extra line after the "if ($contentReplaced)" to help reading the code PHPBB3-13146 --- phpBB/phpbb/content_visibility.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB') diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index f1f350a260..02a5f0f766 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -190,6 +190,7 @@ class content_visibility return $where_sql; } + if (sizeof($approve_forums)) { // Remove moderator forums from the rest -- cgit v1.2.1 From 614f975e68dc21536d11cb79a4596bd4f9ee8602 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 29 Nov 2014 14:12:19 +0000 Subject: [ticket/13146] $contentReplaced -> $content_replaced PHPBB3-13146 --- phpBB/phpbb/content_visibility.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index 02a5f0f766..677c70ad5b 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -185,7 +185,7 @@ class content_visibility ); extract($phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_forums_visibility_before', compact($vars))); - if ($contentReplaced) + if ($content_replaced) { return $where_sql; } -- cgit v1.2.1 From 80a7f6930cff09d771d0146fbf2eae901def004e Mon Sep 17 00:00:00 2001 From: brunoais Date: Wed, 3 Dec 2014 13:48:46 +0000 Subject: [ticket/13146] Adding eventDispatcher to the list PHPBB3-13146 --- phpBB/config/content.yml | 1 + phpBB/phpbb/content_visibility.php | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/config/content.yml b/phpBB/config/content.yml index f0985f0292..c62b8e26fb 100644 --- a/phpBB/config/content.yml +++ b/phpBB/config/content.yml @@ -3,6 +3,7 @@ services: class: phpbb\content_visibility arguments: - @auth + - @phpbb_dispatcher - @config - @dbal.conn - @user diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index 677c70ad5b..59d239deeb 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -43,6 +43,12 @@ class content_visibility */ protected $config; + /** + * Event dispatcher object + * @var \phpbb\event\dispatcher + */ + protected $phpbb_dispatcher; + /** * phpBB root path * @var string @@ -60,6 +66,7 @@ class content_visibility * * @param \phpbb\auth\auth $auth Auth object * @param \phpbb\config\config $config Config object + * @param \phpbb\event\dispatcher $phpbb_dispatcher Event dispatcher object * @param \phpbb\db\driver\driver_interface $db Database object * @param \phpbb\user $user User object * @param string $phpbb_root_path Root path @@ -69,10 +76,11 @@ class content_visibility * @param string $topics_table Topics table name * @param string $users_table Users table name */ - public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $php_ext, $forums_table, $posts_table, $topics_table, $users_table) + public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\event\dispatcher $phpbb_dispatcher, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $php_ext, $forums_table, $posts_table, $topics_table, $users_table) { $this->auth = $auth; $this->config = $config; + $this->phpbb_dispatcher = $phpbb_dispatcher; $this->db = $db; $this->user = $user; $this->phpbb_root_path = $phpbb_root_path; -- cgit v1.2.1 From ac8a4b05b459a131d7fb6caacb23f190bdfbaf1f Mon Sep 17 00:00:00 2001 From: brunoais Date: Wed, 3 Dec 2014 13:53:23 +0000 Subject: [ticket/13146] Fixing what merging broke Merging added content I didn't expect it to add. This fixes back to what it is supposed to be. PHPBB3-13146 --- phpBB/phpbb/content_visibility.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index 59d239deeb..655e76a4a8 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -164,8 +164,6 @@ class content_visibility */ public function get_forums_visibility_sql($mode, $forum_ids = array(), $table_alias = '') { - global $phpbb_dispatcher; - $where_sql = '('; $approve_forums = array_intersect($forum_ids, array_keys($this->auth->acl_getf('m_approve', true))); @@ -191,11 +189,11 @@ class content_visibility 'approve_forums', 'content_replaced', ); - extract($phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_forums_visibility_before', compact($vars))); + extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_forums_visibility_before', compact($vars))); if ($content_replaced) { - return $where_sql; + return $content_replaced; } -- cgit v1.2.1 From 4159bb1340cc0e6998196372af56deb7226b93d6 Mon Sep 17 00:00:00 2001 From: brunoais Date: Wed, 3 Dec 2014 13:56:50 +0000 Subject: [ticket/13146] Wrong usage of tabs in .yml PHPBB3-13146 --- phpBB/config/content.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/config/content.yml b/phpBB/config/content.yml index c62b8e26fb..caeb1a4161 100644 --- a/phpBB/config/content.yml +++ b/phpBB/config/content.yml @@ -3,7 +3,7 @@ services: class: phpbb\content_visibility arguments: - @auth - - @phpbb_dispatcher + - @phpbb_dispatcher - @config - @dbal.conn - @user -- cgit v1.2.1 From 10a4f791358deb5e4365a74ca56982b36771b603 Mon Sep 17 00:00:00 2001 From: brunoais Date: Wed, 3 Dec 2014 14:00:00 +0000 Subject: [ticket/13146] Fixed variable name for the override PHPBB3-13146 --- phpBB/phpbb/content_visibility.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index 655e76a4a8..2121bd8305 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -168,7 +168,7 @@ class content_visibility $approve_forums = array_intersect($forum_ids, array_keys($this->auth->acl_getf('m_approve', true))); - $content_replaced = false; + $get_forums_visibility_sql_overwrite = false; /** * Allow changing the result of calling get_forums_visibility_sql * @@ -178,7 +178,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 bool content_replaced Forces the function to return where_sql after executing the event + * @var bool get_forums_visibility_sql_overwrite Forces the function to return where_sql after executing the event * @since 3.1.3-RC1 */ $vars = array( @@ -187,13 +187,13 @@ class content_visibility 'forum_ids', 'table_alias', 'approve_forums', - 'content_replaced', + 'get_forums_visibility_sql_overwrite', ); extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_forums_visibility_before', compact($vars))); - if ($content_replaced) + if ($get_forums_visibility_sql_overwrite) { - return $content_replaced; + return $get_forums_visibility_sql_overwrite; } -- cgit v1.2.1 From f045744606a945a190728c5ad17350776374a6a9 Mon Sep 17 00:00:00 2001 From: brunoais Date: Wed, 3 Dec 2014 14:26:25 +0000 Subject: [ticket/13146] FIxed wrong order in config/content.yml PHPBB3-13146 --- phpBB/config/content.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/config/content.yml b/phpBB/config/content.yml index caeb1a4161..4212a1ab2e 100644 --- a/phpBB/config/content.yml +++ b/phpBB/config/content.yml @@ -3,8 +3,8 @@ services: class: phpbb\content_visibility arguments: - @auth - - @phpbb_dispatcher - @config + - @phpbb_dispatcher - @dbal.conn - @user - %core.root_path% -- cgit v1.2.1 From 59ab09273ff39fd89f1f5995356acf8c8ef44650 Mon Sep 17 00:00:00 2001 From: brunoais Date: Mon, 29 Dec 2014 08:40:23 +0000 Subject: [ticket/13146] Improved $get_forums_visibility_sql_overwrite's clarity PHPBB3-13146 --- phpBB/phpbb/content_visibility.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index 2121bd8305..5df5c65037 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -178,7 +178,9 @@ 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 bool get_forums_visibility_sql_overwrite Forces the function to return where_sql after executing the event + * @var mixed get_forums_visibility_sql_overwrite If a string, forces the function to return get_forums_visibility_sql_overwrite after executing the event + * If false, get_forums_visibility_sql continues normally + * It must be either boolean or string * @since 3.1.3-RC1 */ $vars = array( @@ -191,7 +193,7 @@ class content_visibility ); extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_forums_visibility_before', compact($vars))); - if ($get_forums_visibility_sql_overwrite) + if ($get_forums_visibility_sql_overwrite !== false) { return $get_forums_visibility_sql_overwrite; } -- cgit v1.2.1 From abc5dbcd7152f57ad1d02bfa012b4fd67691b964 Mon Sep 17 00:00:00 2001 From: brunoais Date: Mon, 29 Dec 2014 08:42:13 +0000 Subject: [ticket/13146] Realign variables and descriptions in event PHPBB3-13146 --- phpBB/phpbb/content_visibility.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index 5df5c65037..31bf31ed47 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -173,11 +173,11 @@ class content_visibility * Allow changing the result of calling get_forums_visibility_sql * * @event core.phpbb_content_visibility_get_forums_visibility_before - * @var string where_sql 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 where_sql 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 mixed get_forums_visibility_sql_overwrite If a string, forces the function to return get_forums_visibility_sql_overwrite after executing the event * If false, get_forums_visibility_sql continues normally * It must be either boolean or string -- cgit v1.2.1 From b64d8c59b0becb03c9bc71dd801c1ad87dcb3bb3 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 10 Jan 2015 09:18:03 +0000 Subject: [ticket/13146] dispatcher, not phpbb_dispatcher PHPBB3-13146 --- phpBB/config/content.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/config/content.yml b/phpBB/config/content.yml index 4212a1ab2e..4d9ee31335 100644 --- a/phpBB/config/content.yml +++ b/phpBB/config/content.yml @@ -4,7 +4,7 @@ services: arguments: - @auth - @config - - @phpbb_dispatcher + - @dispatcher - @dbal.conn - @user - %core.root_path% -- cgit v1.2.1 From cea35c486c7b5307bb683c0f2ce8f426357d6ff2 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 10 Jan 2015 09:55:43 +0000 Subject: [ticket/13146] Removed stray empty line PHPBB3-13146 --- phpBB/phpbb/content_visibility.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index 31bf31ed47..de0e389dd1 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -198,7 +198,6 @@ class content_visibility return $get_forums_visibility_sql_overwrite; } - if (sizeof($approve_forums)) { // Remove moderator forums from the rest -- cgit v1.2.1