From ca5b1fd8be75eebdd3eed33aec87e45942daa9e5 Mon Sep 17 00:00:00 2001 From: Tazzios <23451105+Tazzios@users.noreply.github.com> Date: Thu, 19 Sep 2019 08:44:36 +0200 Subject: [PATCH 1/5] Update ContentFinder.php article behavior 'Show Unauthorised Links' #2542 Removed the autorisation check on category level Added check on show_noauth. --- .../classes/Gantry/Joomla/Content/ContentFinder.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/platforms/joomla/classes/Gantry/Joomla/Content/ContentFinder.php b/src/platforms/joomla/classes/Gantry/Joomla/Content/ContentFinder.php index f5a64da75..fa9977be7 100644 --- a/src/platforms/joomla/classes/Gantry/Joomla/Content/ContentFinder.php +++ b/src/platforms/joomla/classes/Gantry/Joomla/Content/ContentFinder.php @@ -111,20 +111,21 @@ public function authorised($authorised = true) $nullDate = $this->db->quote($this->db->getNullDate()); $nowDate = $this->db->quote(\JFactory::getDate()->toSql()); + $groups = $user->getAuthorisedViewLevels(); + $comma_separated_groups = implode(",", $groups); + // Filter by start and end dates. if (!$user->authorise('core.edit.state', 'com_content') && !$user->authorise('core.edit', 'com_content')) { $this->query ->where("(a.publish_up = {$nullDate} OR a.publish_up <= {$nowDate})") ->where("(a.publish_down = {$nullDate} OR a.publish_down >= {$nowDate})") ->where("a.state >= 1") + ->where("(a.access IN ({$comma_separated_groups}) OR JSON_EXTRACT(a.attribs, '$.show_noauth') =1)") ; } - $groups = $user->getAuthorisedViewLevels(); - - $this->query->join('INNER', '#__categories AS c ON c.id = a.catid'); - - return $this->where('a.access', 'IN', $groups)->where('c.access', 'IN', $groups); + $this->query->join('INNER', '#__categories AS c ON c.id = a.catid'); + return $this; } protected function addToGroup($key, $ids, $include = true) From dac8131051aa45442c2ec7eb938111f228861213 Mon Sep 17 00:00:00 2001 From: Tazzios <23451105+Tazzios@users.noreply.github.com> Date: Thu, 19 Sep 2019 08:47:25 +0200 Subject: [PATCH 2/5] Update CategoryFinder.php article behavior 'Show Unauthorised Links' #2542 Removed the autorisation check on category level so that the check will be only on category level. --- .../joomla/classes/Gantry/Joomla/Category/CategoryFinder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/joomla/classes/Gantry/Joomla/Category/CategoryFinder.php b/src/platforms/joomla/classes/Gantry/Joomla/Category/CategoryFinder.php index d2d2b32b5..8e4d8a8c4 100644 --- a/src/platforms/joomla/classes/Gantry/Joomla/Category/CategoryFinder.php +++ b/src/platforms/joomla/classes/Gantry/Joomla/Category/CategoryFinder.php @@ -106,7 +106,7 @@ public function authorised($authorised = true) $user = \JFactory::getUser(); $groups = $user->getAuthorisedViewLevels(); - return $this->where('a.access', 'IN', $groups); + return $this; } public function extension($extension) From 2abce378be28d8c1336c8ce747f2b6290b0207b2 Mon Sep 17 00:00:00 2001 From: Tazzios <23451105+Tazzios@users.noreply.github.com> Date: Thu, 19 Sep 2019 14:47:45 +0200 Subject: [PATCH 3/5] Update ContentFinder.php #1 --- .../joomla/classes/Gantry/Joomla/Content/ContentFinder.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/platforms/joomla/classes/Gantry/Joomla/Content/ContentFinder.php b/src/platforms/joomla/classes/Gantry/Joomla/Content/ContentFinder.php index fa9977be7..8524af9d0 100644 --- a/src/platforms/joomla/classes/Gantry/Joomla/Content/ContentFinder.php +++ b/src/platforms/joomla/classes/Gantry/Joomla/Content/ContentFinder.php @@ -120,7 +120,9 @@ public function authorised($authorised = true) ->where("(a.publish_up = {$nullDate} OR a.publish_up <= {$nowDate})") ->where("(a.publish_down = {$nullDate} OR a.publish_down >= {$nowDate})") ->where("a.state >= 1") - ->where("(a.access IN ({$comma_separated_groups}) OR JSON_EXTRACT(a.attribs, '$.show_noauth') =1)") + ->where("(a.access IN ({$comma_separated_groups}) OR + (CASE WHEN JSON_EXTRACT(attribs, '$.show_noauth') IS NULL THEN (select JSON_EXTRACT(params, '$.show_noauth') FROM #__extensions where element='com_content') + ELSE JSON_EXTRACT(attribs, '$.show_noauth') END) =1)") ; } From 7145da6e621546698740937cde6239e3ffe436b3 Mon Sep 17 00:00:00 2001 From: Tazzios <23451105+Tazzios@users.noreply.github.com> Date: Fri, 20 Sep 2019 10:03:08 +0200 Subject: [PATCH 4/5] Update ContentFinder.php #1 added is null or empty and JSON_UNQUOTE --- .../joomla/classes/Gantry/Joomla/Content/ContentFinder.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/platforms/joomla/classes/Gantry/Joomla/Content/ContentFinder.php b/src/platforms/joomla/classes/Gantry/Joomla/Content/ContentFinder.php index 8524af9d0..8e9918c54 100644 --- a/src/platforms/joomla/classes/Gantry/Joomla/Content/ContentFinder.php +++ b/src/platforms/joomla/classes/Gantry/Joomla/Content/ContentFinder.php @@ -120,9 +120,10 @@ public function authorised($authorised = true) ->where("(a.publish_up = {$nullDate} OR a.publish_up <= {$nowDate})") ->where("(a.publish_down = {$nullDate} OR a.publish_down >= {$nowDate})") ->where("a.state >= 1") - ->where("(a.access IN ({$comma_separated_groups}) OR - (CASE WHEN JSON_EXTRACT(attribs, '$.show_noauth') IS NULL THEN (select JSON_EXTRACT(params, '$.show_noauth') FROM #__extensions where element='com_content') - ELSE JSON_EXTRACT(attribs, '$.show_noauth') END) =1)") + ->where("(a.access IN ({$comma_separated_groups}) OR + ( CASE WHEN JSON_UNQUOTE(JSON_EXTRACT(attribs, '$.show_noauth' )) IS NULL OR JSON_UNQUOTE(JSON_EXTRACT(attribs, '$.show_noauth' )) ='' THEN + JSON_UNQUOTE((select JSON_EXTRACT(params, '$.show_noauth') FROM josvz_extensions where element='com_content')) + ELSE JSON_UNQUOTE(JSON_EXTRACT(attribs, '$.show_noauth')) END) =1)") ; } From 55e21e1529efe023b7e2bc80ada3171536145ecd Mon Sep 17 00:00:00 2001 From: Tazzios <23451105+Tazzios@users.noreply.github.com> Date: Fri, 20 Sep 2019 19:25:05 +0200 Subject: [PATCH 5/5] Update ContentFinder.php Forgot a table prefix --- .../joomla/classes/Gantry/Joomla/Content/ContentFinder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/joomla/classes/Gantry/Joomla/Content/ContentFinder.php b/src/platforms/joomla/classes/Gantry/Joomla/Content/ContentFinder.php index 8e9918c54..45a051a5f 100644 --- a/src/platforms/joomla/classes/Gantry/Joomla/Content/ContentFinder.php +++ b/src/platforms/joomla/classes/Gantry/Joomla/Content/ContentFinder.php @@ -122,7 +122,7 @@ public function authorised($authorised = true) ->where("a.state >= 1") ->where("(a.access IN ({$comma_separated_groups}) OR ( CASE WHEN JSON_UNQUOTE(JSON_EXTRACT(attribs, '$.show_noauth' )) IS NULL OR JSON_UNQUOTE(JSON_EXTRACT(attribs, '$.show_noauth' )) ='' THEN - JSON_UNQUOTE((select JSON_EXTRACT(params, '$.show_noauth') FROM josvz_extensions where element='com_content')) + JSON_UNQUOTE((select JSON_EXTRACT(params, '$.show_noauth') FROM #__extensions where element='com_content')) ELSE JSON_UNQUOTE(JSON_EXTRACT(attribs, '$.show_noauth')) END) =1)") ; }