Select Git revision
user.class.php
user.class.php 9.23 KiB
<?php
/**
* user class contains username and its roles
* This class is used in the base class
*
* @author hahn
*
* Axel <axel.hahn@unibe.ch>
* 2024-08-29 Axel php8 only; added variable types; use short array syntax
*/
class user
{
/**
* login name of the current user
* @var string
*/
private string $_sUsername = '';
/**
* list of groups of the current user
* @var array
*/
private array $_aUserGroups = [];
/**
* list of roles based on the groups
* @var array
*/
private array $_aUserPermmissions = [];
/**
* list of projects the current user is involved in
* @var array
*/
private $_aProjects = [];
/**
* name of the last checked role
* @var string
*/
private $_sLastCheckedPermission = false;
/**
* Constructor
* init user with optional given user
*
* @param string $sUser username to set
*/
public function __construct(string $sUser = '')
{
$this->setUser($sUser);
}
// ----------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------
/**
* Get string with detected user from current session / basic auth / cli access
*
* @return string
*/
private function _autoDetectUser(): string
{
$sUser = '';
if (isset($_SESSION) && isset($_SESSION["PHP_AUTH_USER"])) {