Class SloodleUser

Description

A class to represent a single user, including Moodle and Sloodle data.

  • usedby: SloodleRequest - Stores and processes user data incoming from an HTTP request

Located in /lib/user.php (line 33)


	
			
Variable Summary
 object $avatar_data
 obejct $user_data
 object $_session
Method Summary
 SloodleUser SloodleUser (object &$_session)
 bool add_linked_avatar (mixed $userid, string $uuid, string $avname)
 object|bool add_pending_avatar (string $uuid, string $avname, [int $timestamp = null])
 int|bool add_user_object (string $avuuid, string $objuuid, string $objname, string $password)
 bool authorise_user_object (int $authid)
 string|bool autoregister_avatar_user ()
 bool delete_avatar ()
 void delete_user_object (string $uuid)
 void enrol ([object $sloodle_course = null], bool 1)
 mixed get_avatar_id ()
 string get_avatar_name ()
 string get_avatar_uuid ()
 array get_enrolled_courses ([mixed $category = null])
 array get_staff_courses ([mixed $category = null])
 string get_username ()
 string|null get_user_email ()
 string get_user_firstname ()
 mixed get_user_id ()
 string get_user_lastname ()
 array get_user_objects ()
 void is_enrolled ( $courseid, mixed $course, bool 1)
 void is_staff ( $courseid, mixed $course, bool 1)
 bool is_user_loaded ()
 bool link_avatar ()
 bool load_avatar (string $uuid, string $avname)
 bool load_avatar_by_id (mixed $id)
 bool,string load_linked_avatar ()
 bool load_user (mixed $id)
 bool login ()
 string|bool reset_password ([bool $require = true])
 void set_avatar_last_active ([int $timestamp = null])
 void set_avatar_name (string $avname)
 void set_avatar_uuid (string $uuid)
 bool write_avatar ()
Variables
object $avatar_data = null (line 51)

Internal only - avatar data.

In Moodle, corresponds to a record from the 'sloodle_users' table.

  • access: private
obejct $user_data = null (line 59)

Internal only - user data. (i.e. VLE user) In Moodle, corresponds to a record from the 'user' table.

  • access: private
object $_session = null (line 43)

Internal only - reference to the containing SloodleSession object.

Note: always check that it is not null before use!

  • access: protected
Methods
Constructor SloodleUser (line 69)

Class constructor.

  • access: public
SloodleUser SloodleUser (object &$_session)
  • object &$_session: Reference to the containing SloodleSession object, if available.
add_linked_avatar (line 361)

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.

  • return: True if successful, or false if not.
  • access: public
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
add_pending_avatar (line 391)

Adds a new unlinked avatar to the database (the entry is pending linking)

  • return: Returns the database object if successul, or false if not.
  • access: public
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.
add_user_object (line 820)

Adds or udpates the given user object as unauthorised.

(This function can be called statically).

  • return: Integer ID of the authorisation entry, or false otherwise
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
authorise_user_object (line 795)

Authorises the given object for the current avatar.

Note: the object must already exist in the database.

  • return: True if successful, or false otherwise
bool authorise_user_object (int $authid)
  • int $authid: The ID of the authorisation entry
autoregister_avatar_user (line 421)

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!

  • return: The new password (plaintext) if successful, or false if not
  • access: public
string|bool autoregister_avatar_user ()
delete_avatar (line 258)

Deletes the current avatar from the database.

  • return: True if successful, or false on failure
  • access: public
bool delete_avatar ()
delete_user_object (line 891)

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
enrol (line 673)

Enrols the current user in the specified course

NOTE: a side effect of this is that it logs-in the user

  • access: public
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
get_avatar_id (line 82)

Gets the unique ID of the avatar.

  • return: Type depends on VLE. (Integer on Moodle). Returns null if there is no avatar.
  • access: public
mixed get_avatar_id ()
get_avatar_last_active (line 187)

Gets the timestamp of whenever the avatar was last active

int get_avatar_last_active ()
get_avatar_name (line 141)

Gets the name of the avatar

string get_avatar_name ()
get_avatar_uuid (line 122)

Gets the UUID of the avatar

string get_avatar_uuid ()
get_enrolled_courses (line 553)

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.

  • return: A numeric array of SloodleCourse objects
  • access: public
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)
get_staff_courses (line 590)

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.

  • return: A numeric array of SloodleCourse objects
  • access: public
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)
get_username (line 160)

Gets the user's username

string get_username ()
get_user_email (line 207)

Gets the user's email address.

  • return: The user's email address, or null if none is specified of if email is disabled.
string|null get_user_email ()
get_user_firstname (line 169)

Gets the first name of the user

string get_user_firstname ()
get_user_id (line 93)

Gets the unique ID of the VLE user.

  • return: Type depends on VLE. (Integer on Moodle). Returns null if there is no user
  • access: public
mixed get_user_id ()
get_user_lastname (line 178)

Gets the last name of the user

string get_user_lastname ()
get_user_objects (line 859)

Gets a list of all user-centric objects authorised for the current avatar.

array get_user_objects ()
is_avatar_linked (line 221)

Determines whether or not the current user and avatar are linked.

  • return: True if they are linked, or false if not.
bool is_avatar_linked ()
is_avatar_loaded (line 103)

Determines whether or not an avatar is loaded.

bool is_avatar_loaded ()
is_enrolled (line 623)

Is the current user enrolled in the specified course?

NOTE: a side effect of this is that it logs-in the user

  • todo: Update to match parameter format and handling of enrol() function.
  • access: public
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_staff (line 649)

Is the current user Sloodle staff in the specified course?

NOTE: a side effect of this is that it logs-in the user

  • todo: Update to match parameter format and handling of enrol() function.
  • access: public
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
is_user_loaded (line 112)

Determines whether or not a VLE user is loaded.

bool is_user_loaded ()
link_avatar (line 236)

Links the current avatar to the current user.

NOTE: does not remove any other avatar links to the VLE user.

  • return: True if successful or false otherwise.
  • access: public
bool link_avatar ()
load_avatar (line 294)

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.

  • return: True if successful, or false otherwise
  • access: public
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.
load_avatar_by_id (line 273)

Loads the specified avatar from the database.

  • return: True if successful, or false otherwise.
  • access: public
bool load_avatar_by_id (mixed $id)
  • mixed $id: The ID of the avatar (type depends on VLE; integer for Moodle)
load_linked_avatar (line 491)

Load the avatar linked to the current user.

  • return: True if a link was loaded, false if there was no link, or string 'multi' if multiple avatars are linked
  • access: public
bool,string load_linked_avatar ()
load_linked_user (line 513)

Find the VLE user linked to the current avatar.

  • return: True if successful, or false if no link was found
  • access: public
bool load_linked_user ()
load_user (line 322)

Load the specified user from the database

  • return: True if successful, or false on failure
  • access: public
bool load_user (mixed $id)
  • mixed $id: The unique identifier for the VLE user. (Type depends on VLE; integer for Moodle)
login (line 534)

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.

  • return: True if successful, or false otherwise.
  • access: public
bool login ()
purge_password_notifications (line 778)

If the system is waiting to send a password notification to this user, then remove it

void purge_password_notifications ()
reset_password (line 741)

Resets the user's password

  • return: The new password if successful, or false otherwise (if $require was false).
string|bool reset_password ([bool $require = true])
  • bool $require: If true, then the script will be terminated if the operation fails
set_avatar_last_active (line 197)

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
set_avatar_name (line 151)

Sets the name of the avatar

void set_avatar_name (string $avname)
  • string $avname: The new avatar name
set_avatar_uuid (line 132)

Sets the UUID of the avatar

void set_avatar_uuid (string $uuid)
  • string $uuid: The new UUID
write_avatar (line 344)

Uses the current avatar data to update the database.

  • return: True if successful, or false if the update fails
  • access: public
bool write_avatar ()

Documentation generated on Fri, 17 Jul 2009 11:02:37 +0100 by phpDocumentor 1.4.0