Tsugi

User
in package
uses JsonTrait

This is a class to provide access to user data from the LTI launch.

This data comes from the LTI launch from the LMS. A user represents a person who has launched the tool. Each user has properties like display name, email, and role. Users are associated with contexts (courses/classes) through memberships.

Table of Contents

Constants

SESSION_CREATE_COURSES  : mixed = 'create_courses'
Session key for {@see rememberCreateCourses()} (user-level, not a context role).

Properties

$admin  : mixed
Is the user an administrator?
$displayname  : mixed
The user's display name
$email  : mixed
The user's email
$firstname  : mixed
The user's first name
$guid  : mixed
Stable guid for this user, as 32 lowercase hex characters.
$id  : mixed
The integer primary key for this user in the 'lti_user' table.
$image  : mixed
The User's Image / Avatar
$instructor  : mixed
Is the user an instructor?
$key  : mixed
The logical key for this user in the 'lti_user' table.
$lastname  : mixed
The user's last name
$launch  : mixed
$locale  : mixed
The User's Locale
$ENTITY_NAME  : mixed
$PRIMARY_KEY  : mixed
$TABLE_NAME  : mixed

Methods

__construct()  : mixed
A guid already on the row is kept with no query. A null guid becomes the value read back after the conditional update, not the candidate that this request generated.
canCreateCourses()  : mixed
True when the current user may mint a new site-login course.
displayNameHtml()  : mixed
HTML display name, with a supporter marker when premium tier was active at post time.
getDisplay()  : string|false
Construct the user's name / email combination
getFirstName()  : string|null
Get the user's first name, falling back to email
getJson()  : string
Load the json field for this entity
getJsonKey()  : mixed
Get a JSON key for this entity
getJsonKeyLegacy()  : mixed
Get a JSON key for this entity (legacy array style)
getNameAndEmail()  : string|false
Construct the user's name / email combination
loadUserInfoBypass()  : array<string|int, mixed>|false
Load a user's info from the user_id
loadUserInfoBypassBySubject()  : array<string|int, mixed>|null
Load a user's info from the user's subject
rememberCreateCourses()  : bool
Load lti_user.create_courses into the session. Call at login, never on course switch.
setJson()  : mixed
Set the JSON entry for this entity
setJsonKey()  : mixed
Set/update a JSON key for this entity
setJsonKeys()  : mixed
Set/update an array of JSON keys for this entity

Constants

SESSION_CREATE_COURSES

Session key for {@see rememberCreateCourses()} (user-level, not a context role).

public mixed SESSION_CREATE_COURSES = 'create_courses'

Properties

$admin

Is the user an administrator?

public mixed $admin = false

$displayname

The user's display name

public mixed $displayname = null

$email

The user's email

public mixed $email = null

$firstname

The user's first name

public mixed $firstname = null

$guid

Stable guid for this user, as 32 lowercase hex characters.

public mixed $guid = null

$id

The integer primary key for this user in the 'lti_user' table.

public mixed $id

$image

The User's Image / Avatar

public mixed $image = null

$instructor

Is the user an instructor?

public mixed $instructor = null

$key

The logical key for this user in the 'lti_user' table.

public mixed $key

$lastname

The user's last name

public mixed $lastname = null

$launch

public mixed $launch = false

$locale

The User's Locale

public mixed $locale = null

$ENTITY_NAME

protected mixed $ENTITY_NAME = "user"

$PRIMARY_KEY

protected mixed $PRIMARY_KEY = "user_id"

$TABLE_NAME

protected mixed $TABLE_NAME = "lti_user"

Methods

__construct()

A guid already on the row is kept with no query. A null guid becomes the value read back after the conditional update, not the candidate that this request generated.

public __construct([array<string, mixed>|null $row = null ]) : mixed
Parameters
$row : array<string, mixed>|null = null

Launch or lti_user row. Null leaves guid unset.

canCreateCourses()

True when the current user may mint a new site-login course.

public static canCreateCourses() : mixed

Site admins always pass. Everyone else needs lti_user.create_courses. Independent of instructor role in the current (or last) context.

displayNameHtml()

HTML display name, with a supporter marker when premium tier was active at post time.

public static displayNameHtml(string|null $displayname[, int $premium = 0 ]) : mixed
Parameters
$displayname : string|null
$premium : int = 0

Premium tier at post time (0 = none)

getDisplay()

Construct the user's name / email combination

public static getDisplay(int $user_id, string|null $displayname, string|null $email) : string|false
Parameters
$user_id : int

The user ID

$displayname : string|null

The user's display name

$email : string|null

The user's email address

Return values
string|false —

Formatted string with name and email, or false if no data available

getFirstName()

Get the user's first name, falling back to email

public getFirstName([string|null $displayname = null ]) : string|null
Parameters
$displayname : string|null = null

Optional display name to parse. If null, uses getNameAndEmail()

Return values
string|null —

The first name, or null if not available

getJson()

Load the json field for this entity

public getJson() : string
Return values
string —

This returns the json string - it is not parsed - if there is nothing to return - this returns "false"

getJsonKey()

Get a JSON key for this entity

public getJsonKey(mixed $key[, mixed $default = false ]) : mixed
Parameters
$key : mixed

The key to be retrieved from the JSON

$default : mixed = false

The default value (optional)

getJsonKeyLegacy()

Get a JSON key for this entity (legacy array style)

public getJsonKeyLegacy(mixed $key[, mixed $default = false ]) : mixed
Parameters
$key : mixed

The key to be retrieved from the JSON

$default : mixed = false

The default value (optional)

getNameAndEmail()

Construct the user's name / email combination

public getNameAndEmail() : string|false
Return values
string|false —

Formatted string with name and email, or false if no data available

loadUserInfoBypass()

Load a user's info from the user_id

public static loadUserInfoBypass(int $user_id) : array<string|int, mixed>|false

We make sure that the user is a member of the current context so as not to slide across silos.

Parameters
$user_id : int

The user ID to load

Return values
array<string|int, mixed>|false —

Associative array with displayname, email, user_key, or false if not found

loadUserInfoBypassBySubject()

Load a user's info from the user's subject

public loadUserInfoBypassBySubject(string $user_subject) : array<string|int, mixed>|null

We make sure that the user is a member of the current context and key so as not to slide across silos.

Parameters
$user_subject : string

The user's subject identifier from LTI launch

Return values
array<string|int, mixed>|null —

Associative array with user_id, displayname, email, user_key, or null if not found

rememberCreateCourses()

Load lti_user.create_courses into the session. Call at login, never on course switch.

public static rememberCreateCourses(mixed $user_id) : bool
Parameters
$user_id : mixed
Return values
bool —

True when the flag is set

setJson()

Set the JSON entry for this entity

public setJson(mixed $json) : mixed
Parameters
$json : mixed

This is a string - no validation is done

setJsonKey()

Set/update a JSON key for this entity

public setJsonKey(mixed $key, mixed $value) : mixed
Parameters
$key : mixed

The key to be inserted/updated in the JSON

$value : mixed

The value to be inserted/updated in the JSON

setJsonKeys()

Set/update an array of JSON keys for this entity

public setJsonKeys(mixed $values) : mixed
Parameters
$values : mixed

An array of key/value pairs to be inserted/updated in the JSON


        
On this page

Search results