Skip to content

Commit

Permalink
Further fix for authentication against Joomla Version 5. See GitHub I…
Browse files Browse the repository at this point in the history
…ssue #3547.
  • Loading branch information
campbell-m committed Oct 30, 2023
1 parent 6937eb1 commit bd356f3
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions web/lib/MRBS/Auth/AuthJoomla.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,14 @@ public function getUsernames() : array
foreach($groups as $group)
{
// Include child groups by doing it recursively
$user_ids = array_merge($user_ids, \JAccess::getUsersByGroup($group, $recursive=true));
if (version_compare(JVERSION, '5.0', '<'))
{
$user_ids = array_merge($user_ids, \JAccess::getUsersByGroup($group, $recursive = true));
}
else
{
$user_ids = array_merge($user_ids, \Joomla\CMS\Access\Access::getUsersByGroup($group, $recursive = true));
}
}

$user_ids = array_unique($user_ids);
Expand All @@ -112,7 +119,14 @@ public function getUsernames() : array
// be using the Joomla API abstraction.
foreach ($user_ids as $user_id)
{
$user = JFactory::getUser((int) $user_id);
if (version_compare(JVERSION, '5.0', '<'))
{
$user = JFactory::getUser((int)$user_id);
}
else
{
$user = Factory::getUser((int)$user_id);
}
$result[] = array('username' => $user->username,
'display_name' => $user->name);
}
Expand Down Expand Up @@ -141,7 +155,15 @@ private static function getMRBSGroups() : array
// it with direct access to the database.

// Get a db connection.
$db = JFactory::getDbo();
if (version_compare(JVERSION, '5.0', '<'))
{
$db = JFactory::getDbo();
}
else
{
$db = Factory::getDbo();
}


// Create a new query object.
$query = $db->getQuery(true);
Expand Down

0 comments on commit bd356f3

Please sign in to comment.