Skip to content
Snippets Groups Projects
Select Git revision
  • 41a201bade92f39de5d58d9de8b2ffecade9e338
  • master default protected
  • Legacy_Php7
3 results

user.class.php

Blame
  • user.class.php 8.54 KiB
    <?php
    
    /**
     * user class contains username and its roles
     * This class is used in the base class
     *
     * @author hahn
     */
    class user {
        
        /**
         * login name of the current user
         * @var string
         */
        private $_sUsername=false;
        
        /**
         * list of groups of the current user
         * @var array
         */
        private $_aUserGroups=array();
        
        /**
         * list of roles based on the groups
         * @var array
         */
        private $_aUserPermmissions=array();
        
        /**
         * list of projects the current user is involved in
         * @var array
         */
        private $_aProjects=array();
        
        /**
         * name of the last checked role
         * @var string
         */
        private $_sLastCheckedPermission=false;
        
        /**
         * init user with optional given user
         * @param type $sUser
         */
        public function __construct($sUser=false){
            $this->setUser($sUser);
        }
        
        
        // ----------------------------------------------------------------------
        // private functions
        // ----------------------------------------------------------------------
        
        
        /**
         * get string with detected user from current session / basic auth / cli access
         * @return string
         */
        private function _autoDetectUser(){
            $sUser=false;
            if (isset($_SESSION) && isset($_SESSION["PHP_AUTH_USER"])){
                $sUser=$_SESSION["PHP_AUTH_USER"];
            }
            if (!$sUser && isset($_SERVER["PHP_AUTH_USER"])){
                $sUser=$_SERVER["PHP_AUTH_USER"];
            }
            if (php_sapi_name() == "cli") {
                $sUser="cliadmin";
            }
            return $sUser;