Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 402] [Versions 400 and 403]

(no description)

File Size: 473 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

User:: (20 methods):
  __construct()
  initialize()
  initialise()
  save()
  delete()
  getResourceLink()
  getRecordId()
  setRecordId()
  setResourceLinkId()
  getDataConnector()
  getId()
  setNames()
  setEmail()
  isAdmin()
  isStaff()
  isLearner()
  fromRecordId()
  fromResourceLink()
  hasRole()
  load()


Class: User  - X-Ref

Class to represent a tool consumer user

__construct()   X-Ref
Class constructor.


initialize()   X-Ref
Initialise the user.


initialise()   X-Ref
Initialise the user.

Pseudonym for initialize().

save()   X-Ref
Save the user to the database.

return: boolean True if the user object was successfully saved

delete()   X-Ref
Delete the user from the database.

return: boolean True if the user object was successfully deleted

getResourceLink()   X-Ref
Get resource link.

return: ResourceLink Resource link object

getRecordId()   X-Ref
Get record ID of user.

return: int Record ID of user

setRecordId($id)   X-Ref
Set record ID of user.

param: int $id  Record ID of user

setResourceLinkId($resourceLinkId)   X-Ref
Set resource link ID of user.

param: int $resourceLinkId  Resource link ID of user

getDataConnector()   X-Ref
Get the data connector.

return: mixed Data connector object or string

getId($idScope = null)   X-Ref
Get the user ID (which may be a compound of the tool consumer and resource link IDs).

return: string User ID value
param: int $idScope Scope to use for user ID (optional, default is null for consumer default setting)

setNames($firstname, $lastname, $fullname)   X-Ref
Set the user's name.

param: string $firstname User's first name.
param: string $lastname User's last name.
param: string $fullname User's full name.

setEmail($email, $defaultEmail = null)   X-Ref
Set the user's email address.

param: string $email        Email address value
param: string $defaultEmail Value to use if no email is provided (optional, default is none)

isAdmin()   X-Ref
Check if the user is an administrator (at any of the system, institution or context levels).

return: boolean True if the user has a role of administrator

isStaff()   X-Ref
Check if the user is staff.

return: boolean True if the user has a role of instructor, contentdeveloper or teachingassistant

isLearner()   X-Ref
Check if the user is a learner.

return: boolean True if the user has a role of learner

fromRecordId($id, $dataConnector)   X-Ref
Load the user from the database.

return: User  User object
param: int $id     Record ID of user
param: DataConnector   $dataConnector    Database connection object

fromResourceLink($resourceLink, $ltiUserId)   X-Ref
Class constructor from resource link.

return: User
param: ResourceLink $resourceLink Resource_Link object
param: string $ltiUserId User ID value

hasRole($role)   X-Ref
Check whether the user has a specified role name.

return: boolean True if the user has the specified role
param: string $role Name of role

load($id = null)   X-Ref
Load the user from the database.

return: boolean True if the user object was successfully loaded
param: int $id     Record ID of user (optional, default is null)