From 9e085e11123dcb183bd3194bb98edf42552652ea Mon Sep 17 00:00:00 2001 From: Tazzios <23451105+Tazzios@users.noreply.github.com> Date: Tue, 23 Jul 2024 14:44:31 +0200 Subject: [PATCH] J5 compatible Did not test it yet with compatible plugin off because Gantry template does not support it . --- cblisthelper.php | 3 ++- helper.php | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cblisthelper.php b/cblisthelper.php index ace4970..7342e7b 100644 --- a/cblisthelper.php +++ b/cblisthelper.php @@ -2,6 +2,7 @@ defined('_JEXEC') or die; +use Joomla\CMS\Factory; /* this file will build the query to get the profiles in the same way as the cblist. * By seperating it it can be easier used in other applications. * @copyright 2022 @@ -23,7 +24,7 @@ function createcblistquerymod($cblistid,$cblistname) { // Obtain a database connection - $db = JFactory::getDbo(); + $db = Factory::getDbo(); // Retrieve the selected list $query = $db->getQuery(true) ->select('params') diff --git a/helper.php b/helper.php index a458ef7..b0317e9 100644 --- a/helper.php +++ b/helper.php @@ -9,6 +9,8 @@ // No direct access defined('_JEXEC') or die; +use Joomla\CMS\Factory; + require_once( dirname(__FILE__) . '/cblisthelper.php' ); @@ -54,7 +56,7 @@ public static function getData( $params ) // get all the fields that could possibly be part of template to be replaced to get us something to loop through. Also add id and user_id as fields. - $db = JFactory::getDbo(); + $db = Factory::getDbo(); $query = "SELECT fields.name, fields.type FROM #__comprofiler_fields as fields WHERE (fields.table = '#__users' OR fields.table = '#__comprofiler') and name not in ('password','params') and fields.tablecolumns <> '' UNION SELECT 'id' AS name, 'id' as type @@ -155,7 +157,7 @@ public static function getData( $params ) function db_field_replace($before_str, $user_id,$rules,$fields) { //Get data from current user - $db = JFactory::getDbo(); + $db = Factory::getDbo(); $query = "select * from #__users inner join #__comprofiler on #__users.id = #__comprofiler.user_id WHERE #__users.id =".$user_id; // echo $query; $db->setQuery($query); @@ -216,7 +218,7 @@ function db_field_replace($before_str, $user_id,$rules,$fields) { foreach ($values as $value) { //Get label from value - $dblabel = JFactory::getDbo(); + $dblabel = Factory::getDbo(); $query = "select fieldlabel from #__comprofiler_field_values WHERE fieldtitle ='". addslashes($value) . "'"; $dblabel->setQuery($query); $labels = (array) $dblabel->loadAssoc(); @@ -241,7 +243,8 @@ function db_field_replace($before_str, $user_id,$rules,$fields) { if ( $rule_id !== false) { // get usergroups from loggedin user - $user_accesslevels = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id'), $recursive = true); + $user = Factory::getUser(); + $user_accesslevels = $user->getAuthorisedViewLevels(); $autorised = false; if ( empty($rules[$rule_id]['accesslevel']) or array_sum(array_count_values(array_intersect($user_accesslevels, $rules[$rule_id]['accesslevel'])))>0 ) { // if not set show the data