Joomla CMS  4.2.2
Documentation des API du CMS Joomla en version 4.2.2
Référence de la classe PlgUserToken
+ Graphe d'héritage de PlgUserToken:

Fonctions membres publiques

 onContentPrepareData (string $context, &$data)
 
 onContentPrepareForm (Form $form, $data)
 
 onUserAfterSave ($data, bool $isNew, bool $result, ?string $error)
 
 onUserAfterDelete (array $user, bool $success, string $msg)
 
- Fonctions membres publiques hérités de CMSPlugin
 __construct (&$subject, $config=array())
 
 loadLanguage ($extension='', $basePath=JPATH_ADMINISTRATOR)
 
 setApplication (CMSApplicationInterface $application)
 
- Fonctions membres publiques hérités de DispatcherAwareInterface
 setDispatcher (DispatcherInterface $dispatcher)
 
- Fonctions membres publiques hérités de PluginInterface
 registerListeners ()
 

Attributs protégés

 $autoloadLanguage = true
 
 $app
 
 $db
 
- Attributs protégés hérités de CMSPlugin
 $_name = null
 
 $_type = null
 
 $autoloadLanguage = false
 
 $allowLegacyListeners = true
 

Fonctions membres privées

 getDefaultProfileFieldValues ()
 
 getTokenSeedForUser (int $userId)
 
 getAllowedUserGroups ()
 
 isInAllowedUserGroup ($userId)
 
 getTokenForDisplay (int $userId, string $tokenSeed, string $algorithm='sha256')
 
 getAlgorithmFromFormFile ()
 
 hasTokenProfileFields (?int $userId)
 

Attributs privés

 $allowedContexts
 
 $profileKeyPrefix = 'joomlatoken'
 
 $tokenLength = 32
 

Membres hérités additionnels

- Champs de données hérités de CMSPlugin
 $params = null
 
- Fonctions membres protégées hérités de CMSPlugin
 registerLegacyListener (string $methodName)
 
 registerListener (string $methodName)
 
 getApplication ()
 

Description détaillée

An example custom terms and conditions plugin.

Depuis
3.9.0

Documentation des fonctions membres

◆ getAlgorithmFromFormFile()

getAlgorithmFromFormFile ( )
private

Get the token algorithm as defined in the form file

We use a simple RegEx match instead of loading the form for better performance.

Renvoie
string The configured algorithm, 'sha256' as a fallback if none is found.

Références __DIR__.

◆ getAllowedUserGroups()

getAllowedUserGroups ( )
private

Get the configured user groups which are allowed to have access to tokens.

Renvoie
int[]
Depuis
4.0.0

◆ getDefaultProfileFieldValues()

getDefaultProfileFieldValues ( )
private

Returns an array with the default profile field values.

This is used when saving the form data of a user (new or existing) without a token already set.

Renvoie
array
Depuis
4.0.0

Références Crypt\genRandomBytes().

◆ getTokenForDisplay()

getTokenForDisplay ( int  $userId,
string  $tokenSeed,
string  $algorithm = 'sha256' 
)
private

Returns the token formatted suitably for the user to copy.

Paramètres
integer$userIdThe user id for token
string$tokenSeedThe token seed data stored in the database
string$algorithmThe hashing algorithm to use for the token (default: sha256)
Renvoie
string
Depuis
4.0.0

Références $message, et $userId.

◆ getTokenSeedForUser()

getTokenSeedForUser ( int  $userId)
private

Retrieve the token seed string for the given user ID.

Paramètres
int$userIdThe numeric user ID to return the token seed string for.
Renvoie
string|null Null if there is no token configured or the user doesn't exist.
Depuis
4.0.0

Références $db, $query, $userId, ParameterType\INTEGER, null, et ParameterType\STRING.

◆ hasTokenProfileFields()

hasTokenProfileFields ( ?int  $userId)
private

Does the user have the Joomla Token profile fields?

Paramètres
int | null$userIdThe user we're interested in
Renvoie
bool True if the user has Joomla Token profile fields

Références $db, et $userId.

◆ isInAllowedUserGroup()

isInAllowedUserGroup (   $userId)
private

Is the user with the given ID in the allowed User Groups with access to tokens?

Paramètres
int$userIdThe user ID to check
Renvoie
boolean False when doesn't belong to allowed user groups, user not found, or guest
Depuis
4.0.0

Références $groups, $user, et $userId.

◆ onContentPrepareData()

onContentPrepareData ( string  $context,
$data 
)

Inject the Joomla token management panel's data into the User Profile.

This method is called whenever Joomla is preparing the data for an XML form for display.

Paramètres
string$contextForm context, passed by Joomla
mixed$dataForm data
Renvoie
boolean
Depuis
4.0.0

Modify the data for display in the user profile view page in the frontend.

It's important to note that we deliberately not register HTMLHelper methods to do the same (unlike e.g. the actionlogs system plugin) because the names of our fields are too generic and we run the risk of creating naming clashes. Instead, we manipulate the data directly.

Références $context, $data, et $userId.

◆ onContentPrepareForm()

onContentPrepareForm ( Form  $form,
  $data 
)

Runs whenever Joomla is preparing a form object.

Paramètres
Form$formThe form to be altered.
mixed$dataThe associated data for the form.
Renvoie
boolean
Exceptions
ExceptionWhen $form is not a valid form object
Depuis
4.0.0

Références $data, $form, $userId, __DIR__, et if.

◆ onUserAfterDelete()

onUserAfterDelete ( array  $user,
bool  $success,
string  $msg 
)

Remove the Joomla token when the user account is deleted from the database.

This event is called after the user data is deleted from the database.

Paramètres
array$userHolds the user data
boolean$successTrue if user was successfully stored in the database
string$msgMessage
Renvoie
void
Exceptions
Exception
Depuis
4.0.0

Références $db, $query, $user, $userId, ParameterType\INTEGER, et ParameterType\STRING.

◆ onUserAfterSave()

onUserAfterSave (   $data,
bool  $isNew,
bool  $result,
?string  $error 
)

Save the Joomla token in the user profile field

Paramètres
mixed$dataThe incoming form data
bool$isNewIs this a new user?
bool$resultHas Joomla successfully saved the user?
string$errorError string
Renvoie
void
Depuis
4.0.0

Is the user being saved programmatically, without passing the user profile information? In this case I do not want to accidentally try to generate a new token!

We determine that by examining whether the Joomla token field exists. If it does but it wasn't passed when saving the user I know it's a programmatic user save and I have to ignore it.

Références $data, $db, $default, $query, $result, $this, $userId, ParameterType\INTEGER, et ParameterType\STRING.

Documentation des champs

◆ $allowedContexts

$allowedContexts
private
Valeur initiale :
= [
'com_users.profile',
'com_users.user',
]

◆ $app

$app
protected

◆ $autoloadLanguage

$autoloadLanguage = true
protected

◆ $db

$db
protected

◆ $profileKeyPrefix

$profileKeyPrefix = 'joomlatoken'
private

◆ $tokenLength

$tokenLength = 32
private

La documentation de cette classe a été générée à partir du fichier suivant :