[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/plugins/user/token/ -> token.php (summary)

(no description)

Copyright: (C) 2020 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
File Size: 620 lines (19 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

PlgUserToken:: (11 methods):
  onContentPrepareData()
  onContentPrepareForm()
  onUserAfterSave()
  onUserAfterDelete()
  getDefaultProfileFieldValues()
  getTokenSeedForUser()
  getAllowedUserGroups()
  isInAllowedUserGroup()
  getTokenForDisplay()
  getAlgorithmFromFormFile()
  hasTokenProfileFields()


Class: PlgUserToken  - X-Ref

An example custom terms and conditions plugin.

onContentPrepareData(string $context, &$data)   X-Ref
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: string  $context  Form context, passed by Joomla
param: mixed   $data     Form data
return: boolean

onContentPrepareForm(Form $form, $data)   X-Ref
Runs whenever Joomla is preparing a form object.

param: Form   $form  The form to be altered.
param: mixed  $data  The associated data for the form.
return: boolean

onUserAfterSave($data, bool $isNew, bool $result, ?string $error)   X-Ref
Save the Joomla token in the user profile field

param: mixed   $data    The incoming form data
param: bool    $isNew   Is this a new user?
param: bool    $result  Has Joomla successfully saved the user?
param: string  $error   Error string
return: void

onUserAfterDelete(array $user, bool $success, string $msg)   X-Ref
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: array    $user     Holds the user data
param: boolean  $success  True if user was successfully stored in the database
param: string   $msg      Message
return: void

getDefaultProfileFieldValues()   X-Ref
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.

return: array

getTokenSeedForUser(int $userId)   X-Ref
Retrieve the token seed string for the given user ID.

param: int  $userId  The numeric user ID to return the token seed string for.
return: string|null  Null if there is no token configured or the user doesn't exist.

getAllowedUserGroups()   X-Ref
Get the configured user groups which are allowed to have access to tokens.

return: int[]

isInAllowedUserGroup($userId)   X-Ref
Is the user with the given ID in the allowed User Groups with access to tokens?

param: int  $userId  The user ID to check
return: boolean  False when doesn't belong to allowed user groups, user not found, or guest

getTokenForDisplay(int $userId,string $tokenSeed,string $algorithm = 'sha256')   X-Ref
Returns the token formatted suitably for the user to copy.

param: integer  $userId     The user id for token
param: string   $tokenSeed  The token seed data stored in the database
param: string   $algorithm  The hashing algorithm to use for the token (default: sha256)
return: string

getAlgorithmFromFormFile()   X-Ref
Get the token algorithm as defined in the form file

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

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

hasTokenProfileFields(?int $userId)   X-Ref
Does the user have the Joomla Token profile fields?

param: int|null  $userId  The user we're interested in
return: bool  True if the user has Joomla Token profile fields



Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer