"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "mrbs-1.9.4/web/lib/MRBS/Auth/AuthJoomla.php" between
mrbs-1.9.4.tar.gz and mrbs-1.10.0.tar.gz

About: MRBS is a web application for booking meeting rooms or other resources (using PHP and MySQL/pgsql).

AuthJoomla.php  (mrbs-1.9.4):AuthJoomla.php  (mrbs-1.10.0)
skipping to change at line 27 skipping to change at line 27
* *
* Checks if the specified username/password pair are valid * Checks if the specified username/password pair are valid
* *
* $user - The user name * $user - The user name
* $pass - The password * $pass - The password
* *
* Returns: * Returns:
* false - The pair are invalid or do not exist * false - The pair are invalid or do not exist
* true - The user has been validated and logged in * true - The user has been validated and logged in
*/ */
public function validateUser($user, $pass) public function validateUser(?string $user, ?string $pass)
{ {
$mainframe = JFactory::getApplication('site'); $mainframe = JFactory::getApplication('site');
return $mainframe->login(array('username' => $user, return $mainframe->login(array('username' => $user,
'password' => $pass)); 'password' => $pass));
} }
public function getUser($username=null) public function getUser($username=null) : ?User
{ {
if ($username === '') if ($username === '')
{ {
return null; return null;
} }
$joomla_user = JFactory::getUser($username); $joomla_user = JFactory::getUser($username);
if ($joomla_user === false) if ($joomla_user === false)
{ {
skipping to change at line 63 skipping to change at line 63
$user = new User($joomla_user->username); $user = new User($joomla_user->username);
$user->display_name = $joomla_user->name; $user->display_name = $joomla_user->name;
$user->email = $joomla_user->email; $user->email = $joomla_user->email;
$user->level = self::getUserLevel($joomla_user); $user->level = self::getUserLevel($joomla_user);
return $user; return $user;
} }
// Return an array of MRBS users, indexed by 'username' and 'display_name' // Return an array of MRBS users, indexed by 'username' and 'display_name'
public function getUsernames() public function getUsernames() : array
{ {
$result = array(); $result = array();
// We only want MRBS users, not all the Joomla users // We only want MRBS users, not all the Joomla users
$groups = self::getMRBSGroups(); $groups = self::getMRBSGroups();
// Get the user ids associated with those groups // Get the user ids associated with those groups
$user_ids = array(); $user_ids = array();
foreach($groups as $group) foreach($groups as $group)
skipping to change at line 97 skipping to change at line 97
'display_name' => $user->name); 'display_name' => $user->name);
} }
// Need to sort the users // Need to sort the users
self::sortUsers($result); self::sortUsers($result);
return $result; return $result;
} }
// Get an array of Joomla groups that have MRBS user or admin rights // Get an array of Joomla groups that have MRBS user or admin rights
private static function getMRBSGroups() private static function getMRBSGroups() : array
{ {
global $auth; global $auth;
$result = array(); $result = array();
// Get all the Joomla access levels that have MRBS user or admin rights // Get all the Joomla access levels that have MRBS user or admin rights
$mrbs_access_levels = array_merge($auth['joomla']['admin_access_levels'], $mrbs_access_levels = array_merge($auth['joomla']['admin_access_levels'],
$auth['joomla']['user_access_levels']); $auth['joomla']['user_access_levels']);
$mrbs_access_levels = array_unique($mrbs_access_levels); $mrbs_access_levels = array_unique($mrbs_access_levels);
skipping to change at line 137 skipping to change at line 137
{ {
$result = array_merge($result, (json_decode($rules))); $result = array_merge($result, (json_decode($rules)));
} }
// Remove duplicates // Remove duplicates
$result = array_unique($result); $result = array_unique($result);
return $result; return $result;
} }
private static function getUserLevel(\MRBS\JUser $joomla_user) private static function getUserLevel(\MRBS\JUser $joomla_user) : int
{ {
global $auth; global $auth;
// User not logged in, user level '0' // User not logged in, user level '0'
if ($joomla_user->guest) if ($joomla_user->guest)
{ {
return 0; return 0;
} }
// Otherwise get the user's access levels // Otherwise get the user's access levels
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)