Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 402] [Versions 310 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).

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

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.

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

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

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

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

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

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

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