Class constructor.
SloodleUser
SloodleUser
(object &$_session)
-
object
&$_session: Reference to the containing SloodleSession object, if available.
Adds a new avatar to the database, and link it to the specified user.
If successful, it deletes any matching avatar details from pending users list.
bool
add_linked_avatar
(mixed $userid, string $uuid, string $avname)
-
mixed
$userid: Site-wide unique ID of a user (type depends on VLE; integer for Moodle)
-
string
$uuid: UUID of the avatar
-
string
$avname: Name of the avatar
Adds a new unlinked avatar to the database (the entry is pending linking)
object|bool
add_pending_avatar
(string $uuid, string $avname, [int $timestamp = null])
-
string
$uuid: UUID of the avatar
-
string
$avname: Name of the avatar
-
int
$timestamp: The timestamp at which to mark the update (or null to use the current timestamp). Entries expire after a certain period.
Adds or udpates the given user object as unauthorised.
(This function can be called statically).
int|bool
add_user_object
(string $avuuid, string $objuuid, string $objname, string $password)
-
string
$avuuid: UUID of the avatar the object will be authorised for
-
string
$objuuid: UUID of the object
-
string
$objname: Name of the object
-
string
$password: Password to store for the object
Authorises the given object for the current avatar.
Note: the object must already exist in the database.
bool
authorise_user_object
(int $authid)
-
int
$authid: The ID of the authorisation entry
Auto-register a new user account for the current avatar.
NOTE: this does NOT respect ANYTHING but the most basic Moodle accounts. Use at your own risk!
string|bool
autoregister_avatar_user
()
Deletes the current avatar from the database.
bool
delete_avatar
()
Deletes a user-centric object by UUID.
Note: the object must have been authorised for the current avatar.
void
delete_user_object
(string $uuid)
-
string
$uuid: The UUID of the object to delete
Enrols the current user in the specified course
NOTE: a side effect of this is that it logs-in the user
void
enrol
([object $sloodle_course = null], bool 1)
-
object
$sloodle_course: A SloodleCourse object setup for the necessary course. If null, then the $_session member is queried instead.
-
bool
1: True if successful (or the user was already enrolled), or false otherwise
Gets the unique ID of the avatar.
mixed
get_avatar_id
()
Gets the timestamp of whenever the avatar was last active
int
get_avatar_last_active
()
Gets the name of the avatar
string
get_avatar_name
()
Gets the UUID of the avatar
string
get_avatar_uuid
()
Gets a numeric array of SloodleCourse objects for courses the user is enrolled in.
WARNING: this function is not very efficient, and will likely be very slow on large sites.
array
get_enrolled_courses
([mixed $category = null])
-
mixed
$category: Unique identifier of a category to limit the query to. Ignored if null. (Type depends on VLE; integer for Moodle)
Gets a numeric array of SloodleCourse objects for courses the user is Sloodle staff.
This relates to the "mod/sloodle:staff" capability. WARNING: this function is not very efficient, and will likely be very slow on large sites.
array
get_staff_courses
([mixed $category = null])
-
mixed
$category: Unique identifier of a category to limit the query to. Ignored if null. (Type depends on VLE; integer for Moodle)
Gets the user's username
string
get_username
()
Gets the user's email address.
string|null
get_user_email
()
Gets the first name of the user
string
get_user_firstname
()
Gets the unique ID of the VLE user.
mixed
get_user_id
()
Gets the last name of the user
string
get_user_lastname
()
Gets a list of all user-centric objects authorised for the current avatar.
array
get_user_objects
()
Determines whether or not the current user and avatar are linked.
bool
is_avatar_linked
()
Determines whether or not an avatar is loaded.
bool
is_avatar_loaded
()
Is the current user enrolled in the specified course?
NOTE: a side effect of this is that it logs-in the user
void
is_enrolled
( $courseid, mixed $course, bool 1)
-
mixed
$course: Unique identifier of the course -- type depends on VLE (integer for Moodle)
-
bool
1: True if the user is enrolled, or false if not.
-
$courseid
Is the current user Sloodle staff in the specified course?
NOTE: a side effect of this is that it logs-in the user
void
is_staff
( $courseid, mixed $course, bool 1)
-
mixed
$course: Unique identifier of the course -- type depends on VLE (integer for Moodle)
-
bool
1: True if the user is staff, or false if not.
-
$courseid
Determines whether or not a VLE user is loaded.
bool
is_user_loaded
()
Links the current avatar to the current user.
NOTE: does not remove any other avatar links to the VLE user.
bool
link_avatar
()
Finds an avatar with the given UUID and/or name, and loads its data.
The UUID is searched for first. If that is not found, then the name is used.
bool
load_avatar
(string $uuid, string $avname)
-
string
$uuid: The UUID of the avatar, or blank to search only by name.
-
string
$avname: The name of the avatar, or blank to search only by UUID.
Loads the specified avatar from the database.
bool
load_avatar_by_id
(mixed $id)
-
mixed
$id: The ID of the avatar (type depends on VLE; integer for Moodle)
Load the avatar linked to the current user.
bool,string
load_linked_avatar
()
Find the VLE user linked to the current avatar.
bool
load_linked_user
()
Load the specified user from the database
bool
load_user
(mixed $id)
-
mixed
$id: The unique identifier for the VLE user. (Type depends on VLE; integer for Moodle)
Internally 'log-in' the current user.
In Moodle, this just stores all the user data in the global $USER variable. This function will not perform automatic registration.
bool
login
()
If the system is waiting to send a password notification to this user, then remove it
void
purge_password_notifications
()
Resets the user's password
string|bool
reset_password
([bool $require = true])
-
bool
$require: If true, then the script will be terminated if the operation fails
Sets the timestamp of when the user was last active
void
set_avatar_last_active
([int $timestamp = null])
-
int
$timestamp: A UNIX timestamp, or null to use the current time
Sets the name of the avatar
void
set_avatar_name
(string $avname)
-
string
$avname: The new avatar name
Sets the UUID of the avatar
void
set_avatar_uuid
(string $uuid)
-
string
$uuid: The new UUID
Uses the current avatar data to update the database.
bool
write_avatar
()