‪TYPO3CMS  11.5
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)
 
bool isLoggedIn ()
 
bool isAdmin ()
 
array getGroupIds ()
 
array getGroupNames ()
 
bool isUserOrGroupSet ()
 

Protected Attributes

AbstractUserAuthentication stdClass $user
 
int[] null $groups
 

Private Member Functions

stdClass 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()

stdClass TYPO3\CMS\Core\Context\UserAspect::createPseudoUser ( )
private
Returns
‪\stdClass

Definition at line 61 of file UserAspect.php.

References TYPO3\CMS\Core\Context\UserAspect\$user.

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

◆ get()

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

Fetch common information about the user

Parameters
string$name
Returns
‪int|bool|string|array
Exceptions
AspectPropertyNotFoundException

Implements TYPO3\CMS\Core\Context\AspectInterface.

Definition at line 75 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()

array 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

Returns
‪array

Definition at line 133 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()

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

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

Returns
‪array

Definition at line 162 of file UserAspect.php.

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

◆ isAdmin()

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

Check if admin is set

Returns
‪bool

Definition at line 115 of file UserAspect.php.

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

◆ isLoggedIn()

bool 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". This is also possible in frontend where there are cases that a user can be marked as NOT logged IN, but be logged in but the groups are explicitly NOT defined (see pages.fe_login_mode)

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

Returns
‪bool

Definition at line 105 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 178 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