Get the currently logged in user name.

@return string
768566
public static function currentUserName()
    {
        if (function_exists('\get_user_name')) {
            $username = \get_user_name();
        }
        if (empty($username)) {
            $username   = \get_current_user();
        }
        if (empty($username)) {
            $username   = Request::header('php-auth-user');
        }
        if (empty($username)) {
            $username   = 'system';
        }

        return $username;
    }
736358
protected function getUser()
    {
        if ($this->_user === null) {
            $this->_user = User::findByUsername($this->username);
        }

        return $this->_user;
    }
921780
public function getUsername()
    {
        $info = $this->getUserInfo();
        $username = strstr($info, ':', true);

        return rawurldecode($username === false ? $info : $username);
    }
1308492
protected function getUserId()
    {
        if (Credentials::check()) {
            return Credentials::getUser()->id;
        } elseif (isset($this['user_id']) && $this['user_id']) {
            return $this['user_id'];
        }
    }
444428
private function getCurrentUserId()
    {
        if ($this->authorizationChecker->isGranted('IS_AUTHENTICATED_FULLY') // user has just logged in
            || $this->authorizationChecker->isGranted('IS_AUTHENTICATED_REMEMBERED') // user has logged in using remember_me cookie
        ) {
            $authenticationToken = $this->tokenStorage->getToken();
            $user = $authenticationToken->getUser();

            if (is_string($user)) {
                return $user;
            } elseif (method_exists($user, 'getAPIUser')) {
                return $user->getAPIUser()->id;
            }

            return $authenticationToken->getUsername();
        }

        if (!$this->session->isStarted()) {
            $this->session->start();
        }

        $request = $this->requestStack->getMasterRequest();

        if (!$request->cookies->has('yc-session-id')) {
            $request->cookies->set('yc-session-id', $this->session->getId());
        }

        return $request->cookies->get('yc-session-id');
    }
295350
public function getAuthorName()
    {
        if ($this->fvAuthorUID) {
            $app = Application::getFacadeApplication();
            $ui = $app->make(UserInfoRepository::class)->getByID($this->fvAuthorUID);
        } else {
            $ui = null;
        }

        return $ui === null ? t('(Unknown)') : $ui->getUserDisplayName();
    }
948892
protected function getCurrentUserIdentity()
    {
        /** @var AccountManagerInterface $manager */
        /** @var PassportAccountInterface $account */
        $manager = $this->getContainer()->get(AccountManagerInterface::class);
        $account = $manager->getAccount();
        $userId  = $account->getUserIdentity();

        return $userId;
    }
1346250
public function getUserId()
    {
        if (! is_null($this->userId)) {
            return $this->userId;
        }

        $rooms = $this->room->getRooms($this->getSender());

        foreach ($rooms as $room) {
            if (count($explode = explode(static::USER_PREFIX, $room)) === 2) {
                $this->userId = $explode[1];
            }
        }

        return $this->userId;
    }
858415
public function getFullName()
    {
        if (! $this->_getVar('user_name')) {
            $name = ltrim($this->_getVar('user_first_name') . ' ') .
                    ltrim($this->_getVar('user_surname_prefix') . ' ') .
                    $this->_getVar('user_last_name');

            if (! $name) {
                // Use obfuscated login name
                $name = $this->getLoginName();
                $name = substr($name, 0, 3) . str_repeat('*', max(5, strlen($name) - 2));
            }

            $this->_setVar('user_name', $name);

            // \MUtil_Echo::track($name);
        }

        return $this->_getVar('user_name');
    }
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;
    }
1328909
public function getUserSession() {
		if (isset($_SESSION['user_'.$this->usernameKey])) {
			$arrUser = array();
			foreach ($_SESSION as $strKey => $strValue)
				if (substr($strKey, 0, 4) == 'user_')
					$arrUser[substr($strKey, 4)] = $strValue;
			return $arrUser;
		}

		return false;
	}
928707
public function getName()
    {
        if (!array_key_exists(self::NAME, $this->passwd)) {
            throw new \Exception('Could not get user name from passwd.');
        }
        return $this->passwd[self::NAME];
    }
161002
public function getAuthorsEnglish()
    {
        $array = $this->getAuthors();
        // sanity check
        if (!$array || !count($array)) {
            return '';
        }
        // change array into linked usernames
        foreach ($array as $key => $user) {
            $full_array[$key] = '<a href="'.$user->getURL().'">'.$user->getName().'</a>';
        }
        // get last element
        $last = array_pop($full_array);
        // if it was the only element - return it
        if (!count($full_array)) {
            return $last;
        }
        return implode(', ', $full_array).' and '.$last;
    }
1324746
public function getName()
    {
        if (!$this->name) {
            if ($this->config['name']) {
                return $this->name = $this->config['name'];
            }

            $ref = new \ReflectionClass(static::class);

            $name = substr($ref->getShortName(), 0, -10);

            return $this->name = strtolower($name);
        }

        return $this->name;
    }
1016664
public function getLoggedUser() {
		$session = BUsersSession::getInstanceAndStart();
		if (empty($session)) {
			return NULL;
		}
		return $this->itemGet($session->userid);
	}
713635
protected function getUsername()
    {

        // initialize the name
        $name = null;

        // query whether or not we've an principal
        if ($identity = $this->getIdentity()) {
            $name = $identity->getName();
        }

        // return the name
        return $name;
    }
243993
public function getUser()
    {
        if ($user = $this->provider->getUser()) {
            return ($field = $this->field) ? (string) $user->{$field} : $user->getLogin();
        }
    }