‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Context\UserAspect Class Reference
Inheritance diagram for TYPO3\CMS\Core\Context\UserAspect:
TYPO3\CMS\Core\Context\AspectInterface

Public Member Functions

 __construct (AbstractUserAuthentication $user=null, array $alternativeGroups=null)
 
int bool string array get (string $name)
 
 isLoggedIn ()
 
 isAdmin ()
 
 getGroupIds ()
 
 getGroupNames ()
 
bool isUserOrGroupSet ()
 

Protected Attributes

AbstractUserAuthentication stdClass $user
 
int[] null $groups
 

Private Member Functions

 createPseudoUser ()
 

Detailed Description

The aspect contains information about a user. Can be used for frontend and backend users.

Allowed properties:

  • ‪id
  • ‪username
  • ‪isLoggedIn
  • ‪groupIds (Array of Ids)
  • ‪groupNames

Definition at line 36 of file UserAspect.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Context\UserAspect::__construct ( AbstractUserAuthentication  $user = null,
array  $alternativeGroups = null 
)
Parameters
AbstractUserAuthentication | null$user
array | null$alternativeGroups

Definition at line 52 of file UserAspect.php.

References TYPO3\CMS\Core\Context\UserAspect\$user, and TYPO3\CMS\Core\Context\UserAspect\createPseudoUser().

Member Function Documentation

◆ createPseudoUser()

TYPO3\CMS\Core\Context\UserAspect::createPseudoUser ( )
private

◆ get()

int bool string array TYPO3\CMS\Core\Context\UserAspect::get ( string  $name)

Fetch common information about the user

Returns
‪int|bool|string|array
Exceptions
AspectPropertyNotFoundException

Implements TYPO3\CMS\Core\Context\AspectInterface.

Definition at line 71 of file UserAspect.php.

References TYPO3\CMS\Core\Context\UserAspect\getGroupIds(), TYPO3\CMS\Core\Context\UserAspect\getGroupNames(), TYPO3\CMS\Core\Context\UserAspect\isAdmin(), and TYPO3\CMS\Core\Context\UserAspect\isLoggedIn().

◆ getGroupIds()

TYPO3\CMS\Core\Context\UserAspect::getGroupIds ( )

Return the groups the user is a member of

For Frontend Users there are two special groups: "-1" = hide at login "-2" = show at any login

Definition at line 121 of file UserAspect.php.

References TYPO3\CMS\Core\Context\UserAspect\$groups, and TYPO3\CMS\Core\Context\UserAspect\isLoggedIn().

Referenced by TYPO3\CMS\Core\Context\UserAspect\get(), and TYPO3\CMS\Core\Context\UserAspect\isUserOrGroupSet().

◆ getGroupNames()

TYPO3\CMS\Core\Context\UserAspect::getGroupNames ( )

Get the name of all groups, used in Fluid's IfHasRole ViewHelper

Definition at line 148 of file UserAspect.php.

Referenced by TYPO3\CMS\Core\Context\UserAspect\get().

◆ isAdmin()

TYPO3\CMS\Core\Context\UserAspect::isAdmin ( )

Check if admin is set

Definition at line 105 of file UserAspect.php.

Referenced by TYPO3\CMS\Core\Context\UserAspect\get().

◆ isLoggedIn()

TYPO3\CMS\Core\Context\UserAspect::isLoggedIn ( )

A user is logged in if the user has a UID, but does not care about groups.

For frontend purposes, it is possible to e.g. simulate groups, but this would still be defined as "not logged in".

For backend, only the check on the user ID is used.

Definition at line 97 of file UserAspect.php.

Referenced by TYPO3\CMS\Core\Context\UserAspect\get(), TYPO3\CMS\Core\Context\UserAspect\getGroupIds(), and TYPO3\CMS\Core\Context\UserAspect\isUserOrGroupSet().

◆ isUserOrGroupSet()

bool TYPO3\CMS\Core\Context\UserAspect::isUserOrGroupSet ( )

Checking if a user is logged in or a group constellation different from "0,-1"

Returns
‪bool TRUE if either a login user is found OR if the group list is set to something else than '0,-1' (could be done even without a user being logged in!)

Definition at line 164 of file UserAspect.php.

References TYPO3\CMS\Core\Context\UserAspect\$groups, TYPO3\CMS\Core\Context\UserAspect\getGroupIds(), and TYPO3\CMS\Core\Context\UserAspect\isLoggedIn().

Member Data Documentation

◆ $groups

int [] null TYPO3\CMS\Core\Context\UserAspect::$groups
protected

Alternative list of groups, usually useful for frontend logins with "magic" groups like "-1" and "-2"

Definition at line 46 of file UserAspect.php.

Referenced by TYPO3\CMS\Core\Context\UserAspect\getGroupIds(), and TYPO3\CMS\Core\Context\UserAspect\isUserOrGroupSet().

◆ $user

AbstractUserAuthentication stdClass TYPO3\CMS\Core\Context\UserAspect::$user
protected