92 $this->firstname =
'';
97 $this->roles = array();
98 $this->groups = array();
120 $names = array(0 =>
'', 1 =>
'');
123 $names = preg_split(
"/[\s]+/", $this->fullname, 2);
128 } elseif (!empty($names[0])) {
129 $this->firstname = $names[0];
130 } elseif (!static::$allowEmptyName) {
131 $this->firstname =
'User';
133 $this->firstname =
'';
138 } elseif (!empty($names[1])) {
139 $this->lastname = $names[1];
140 } elseif (!static::$allowEmptyName) {
143 $this->lastname =
'';
145 if (empty($this->fullname) && (!empty($this->firstname) || !empty($this->lastname))) {
146 $this->fullname = trim(
"{$this->firstname} {$this->lastname}");
160 } elseif (!empty($defaultEmail)) {
161 $this->email = $defaultEmail;
162 if (substr($this->email, 0, 1) ===
'@') {
177 return $this->hasRole(
'Administrator') || $this->hasRole(
'urn:lti:sysrole:ims/lis/SysAdmin') ||
178 $this->hasRole(
'urn:lti:sysrole:ims/lis/Administrator') || $this->hasRole(
'urn:lti:instrole:ims/lis/Administrator');
188 return ($this->hasRole(
'Instructor') || $this->hasRole(
'ContentDeveloper') || $this->hasRole(
'TeachingAssistant'));
198 return $this->hasRole(
'Learner');
212 private function hasRole($role)
215 if ((substr($role, 0, 4) !==
'urn:') && (substr($role, 0, 7) !==
'http://') && (substr($role, 0, 8) !==
'https://')) {
216 $role2 =
'http://purl.imsglobal.org/vocab/lis/v2/membership#' . $role;
217 $role =
'urn:lti:role:ims/lis/' . $role;
219 $ok = in_array($role, $this->roles);
220 if (!$ok && !empty($role2)) {
221 $ok = in_array($role2, $this->roles);
isStaff()
Check if the user is staff.
isLearner()
Check if the user is a learner.
$firstname
UserResult's first name.
$ltiUserId
user ID as supplied in the last connection request.
initialize()
Initialise the user.
$lastname
UserResult's last name (surname or family name).
$fullname
UserResult's fullname.
__construct()
Class constructor.
$email
UserResult's email address.
setNames($firstname, $lastname, $fullname)
Set the user's name.
initialise()
Initialise the user.
setEmail($email, $defaultEmail=null)
Set the user's email address.
$image
UserResult's image URI.
Class to represent a tool consumer user.
static $allowEmptyName
Allow user name field to be empty?
isAdmin()
Check if the user is an administrator (at any of the system, institution or context levels).