Register a callback for getting the current system user's id, or name.
- This is useful for logging errors etc..
- self::current_user() will return 0, unless you define a handler.
@param string | array handler callable with call_user_func
@return bool
19902
static function set_current_user_getter( $handler ){
		if( ! is_callable($handler) ){
			trigger_error( 'current user getter is not callable ('.var_export($handler,1).')', E_USER_WARNING );
			return false;
		}
		self::$current_user_func = $handler;
		return true;	
	}
949769
protected function getUserId()
    {
        if (property_exists($this, 'userKey'))
        {
            $userKey = $this->userKey;

            return $this->$userKey;
        }

        if ( ! is_null($this->user_id))
        {
            return $this->user_id;
        }

        return null;
    }
144036
public function getCurrentUser()
    {
        if ($this->currentuser === null) {
            $hash = $this->getCurrentSessionHash();
            if ($hash === false) {
                return false;
            }

            $uid = $this->getSessionUID($hash);
            if ($uid === false) {
                return false;
            }

            $this->currentuser = $this->getUser($uid);
        }
        return $this->currentuser;
    }
689771
public function getCurrentUser()
    {
        if (Towel::isCli()) {
          return false; //Cli is not logged.
        }

        $userRecord = $this->session()->get('user', false);
        if (!$userRecord) {
            return false;
        }

        $userModel = $this->getInstance('user_model');
        $userModel->setRecord($userRecord);

        return $userModel;
    }
712414
protected function getCurrentUser()
    {
        if ($this->tokenStorage && ($token = $this->tokenStorage->getToken())) {
            $user = $token->getUser();

            if ($user instanceof UserInterface) {
                return $user;
            }
        }

        return;
    }
232611
public function register($name, $handler)
    {
        Assert::string($name, 'The handler name must be a string. Got: %s');
        Assert::notEmpty($name, 'The handler name must not be empty.');

        if (!is_object($handler)) {
            Assert::isCallable($handler, 'The handler must be a callable or an object. Got: %s');
        }

        $this->handlers[$name] = $handler;

        if (!$this->selectedHandler) {
            $this->selectedHandler = $name;
        }
    }
730791
public function user()
    {
        if ($this->loggedOut) {
            return;
        }

        // If we have already retrieved the user for the current request we can just
        // return it back immediately. We do not want to pull the user data every
        // request into the method because that would tremendously slow an app.
        if (! is_null($this->user)) {
            return $this->user;
        }

        $id = $this->session->get($this->getName());

        // First we will try to load the user using the identifier in the session if
        // one exists. Otherwise we will check for a "remember me" cookie in this
        // request, and if one exists, attempt to retrieve the user using that.
        $user = null;

        if (! is_null($id)) {
            $user = $this->provider->retrieveByID($id);
        }

        // If the user is null, but we decrypt a "recaller" cookie we can attempt to
        // pull the user data on that cookie which serves as a remember cookie on
        // the application. Once we have a user we can return it to the caller.
        $recaller = $this->getRecaller();

        if (is_null($user) && ! is_null($recaller)) {
            $user = $this->getUserByRecaller($recaller);
        }

        return $this->user = $user;
    }
107364
public static function GetCurrentUser($guid = "CURRENT_USER")
	{
		if (self::$user == null)
		{
			self::Init();
			
			if (isset($_SESSION[$guid]))
			{
				self::$user = unserialize($_SESSION[$guid]);
			}		
		}
		return self::$user;
	}
942105
public final function getCurrentUser()
    {
        if (! self::$currentUser) {
            if ($this->session->__isset('__user_definition')) {
                $defName = $this->session->__get('__user_definition');

                // Check for during upgrade. Remove for version 1.6
                if (substr($defName, -10, 10) != 'Definition') {
                    $defName .= 'Definition';
                }

                self::$currentUser = $this->_loadClass('User', true, array($this->session, $this->_getClass($defName)));

            } else {
                if (\MUtil_Console::isConsole()) {
                    if (! $this->project->isConsoleAllowed()) {
                        echo "Accessing " . GEMS_PROJECT_NAME . " from the command line is not allowed.\n";
                        exit;
                    }


                    $request = \Zend_Controller_Front::getInstance()->getRequest();

                    if (($request instanceof \MUtil_Controller_Request_Cli) && $request->hasUserLogin()) {
                        $user = $this->getUser($request->getUserName(), $request->getUserOrganization());

                        $authResult = $user->authenticate($request->getUserPassword());
                        if (! $authResult->isValid()) {
                            echo "Invalid user login data.\n";
                            echo implode("\n", $authResult->getMessages());
                            exit;
                        }
                        self::$currentUser = $user;

                    } elseif ($this->project->getConsoleRole()) {
                        // \MUtil_Echo::track($this->request->getUserName(), $this->request->getUserOrganization());
                        self::$currentUser = $this->loadUser(self::USER_CONSOLE, 0, '(system)');
                    }

                }
                if (! self::$currentUser) {
                    self::$currentUser = $this->getUser(null, self::SYSTEM_NO_ORG);
                }
                self::$currentUser->setAsCurrentUser();
           }
        }

        return self::$currentUser;
    }
801891
public function user()
    {
        if ($this->loggedOut) {
            return;
        }

        // If we've already retrieved the user for the current request we can just
        // return it back immediately. We do not want to fetch the user data on
        // every call to this method because that would be tremendously slow.
        if (! is_null($this->user)) {
            return $this->user;
        }

        $id = $this->session->get($this->getName());

        // First we will try to load the user using the identifier in the session if
        // one exists. Otherwise we will check for a "remember me" cookie in this
        // request, and if one exists, attempt to retrieve the user using that.
        if (! is_null($id) && $this->user = $this->provider->retrieveById($id)) {
            $this->fireAuthenticatedEvent($this->user);
        }

        // If the user is null, but we decrypt a "recaller" cookie we can attempt to
        // pull the user data on that cookie which serves as a remember cookie on
        // the application. Once we have a user we can return it to the caller.
        if (is_null($this->user) && ! is_null($recaller = $this->recaller())) {
            $this->user = $this->userFromRecaller($recaller);

            if ($this->user) {
                $this->updateSession($this->user->getAuthIdentifier());

                $this->fireLoginEvent($this->user, true);
            }
        }

        return $this->user;
    }
1142985
public function wasByCurrentUser()
    {
        return $this->credentials->check() && $this->credentials->getUser()->id == $this->wrappedObject->user_id;
    }
244018
def User(self, Username=''):
        
        if not Username:
            Username = self.CurrentUserHandle
        o = User(self, Username)
        o.OnlineStatus # Test if such a user exists.
        return o
67097
static function currentUser()
    {
        $user = self::instance();
        if ( $user->isAnonymous() || $user->isEnabled() )
        {
            return $user;
        }
        self::logoutCurrent();
        return self::instance();
    }
1266824
public function getUserId()
  {
    if ($this->userId === null) {
      $this->userId = $this->fetchUserId();
    }

    return $this->userId;
  }
799577
protected function defaultHandler()/*# : bool */
    {
        $status = $this->result->getStatus();
        $handler = $this->result->getHandler() ?: $this->getHandler($status);

        if ($handler) {
            $param = ['result' => $this->result];
            $callable = $this->getResolver()->resolve($handler);
            if ($this->trigger(self::EVENT_BEFORE_HANDLER, $param)) {
                call_user_func($callable, $this->result);
                $this->trigger(self::EVENT_AFTER_HANDLER, $param);
            }
        }
        return false;
    }
763659
public static function getCurrent()
    {
        $class = get_called_class();
        if (Session::get('user')) {
            return $class::search()->where('user_id', Session::get('user')->user_id)->execOne();
        }
        return false;
    }
1166169
public static function getUserID()
    {
        $user = Yii::$app->getUser();

        return $user && !$user->getIsGuest() ? $user->getId() : 0;
    }