Class SloodleLSLRequest

Description

Handles incoming HTTP requests, typically from LSL scripts.

This class will perform much of the complex and repetitive processing required for handling HTTP requests.

  • uses: SloodleUser - Stores and processes user data incoming from an HTTP request
  • uses: SloodleLSLResponse - Outputs error messages in appropriate format if an error occurs.

Located in /lib/sl_iolib.php (line 708)


	
			
Variable Summary
Method Summary
 SloodleLSLRequest SloodleLSLRequest ( &$response,  &$user, SloodleLSLResponse $response, SloodleUser $user)
 bool authenticate_request ([bool $require = TRUE])
 string|null get_avatar_name ()
 string|null get_avatar_uuid ()
 integer|null get_course_id ()
 object A get_course_module_instance ([string $type = ''], [bool $require = TRUE])
 object A get_course_record ([bool $require = TRUE])
 string|null get_login_security_token ()
 integer|null get_module_id ()
 string|null get_password ()
 &SloodleLSLResponse get_response ()
 &SloodleUser get_user ()
 bool is_auth_failed ()
 void process_request_data ([bool $force = FALSE])
 mixed required_param (string $parname, [int $type = PARAM_RAW])
 void set_response ( &$response, SloodleLSLResponse $response)
 void set_user ( &$user, SloodleUser $user)
Variables
int $auth_status = SLOODLE_AUTH_UNKNOWN (line 737)

Indicates the status of request authentication.

mixed $avatar_name = NULL (line 767)

String name of the SL agent specified in the request (or NULL if not specified).

  • access: private
mixed $avatar_uuid = NULL (line 761)

String UUID of the SL user agent specified in the request (or NULL if not specified).

  • access: private
mixed $course_id = NULL (line 749)

Integer ID of the course specified in the request (or NULL if not specified).

  • access: private
mixed $login_security_token = NULL (line 773)

String containing the login security token specified in the request (or NULL if not specified).

  • access: private
mixed $login_zone_pos = NULL (line 743)

A 3-element array containing the LoginZone position vector specified in HTTP request parameters (or NULL if not specified).

  • access: private
mixed $module_id = NULL (line 755)

Integer ID of the course module instance specified in the request (or NULL if not specified).

  • access: private
mixed $password = NULL (line 726)

Contains the password specified in HTTP request parameters (or NULL if not specified).

bool $request_data_processed = FALSE (line 719)

Indicates whether or not the request data has been processed by the process_request_data() function.

SloodleLSLResponse $response = NULL (line 787)

The object used to output response data.

The object reference may be provided externally in the parameters of the constructor (SloodleLSLRequest()) or via the (set_response()) accessor. Otherwise, it will have been instantiated by this object itself.

SloodleUser $user = NULL (line 798)

The object used to store and process incoming user data.

The object reference may be provided externally in the parameters of the constructor (SloodleLSLRequest()) or via the (set_user()) accessor. Otherwise, it will have been instantiated by this object itself.

Methods
Constructor SloodleLSLRequest (line 973)

Constructor

  • initialises the user and response objects.

If the parameters provide references to appropriate objects, then the constructor will store them. However, if the parameters are NULL, then the constructor will create its own instances.

SloodleLSLRequest SloodleLSLRequest ( &$response,  &$user, SloodleLSLResponse $response, SloodleUser $user)
  • SloodleLSLResponse $response: Reference to the response object which this object should use, or NULL
  • SloodleUser $user: Refernce to the user object which this object should use, or NULL
  • &$response
  • &$user
authenticate_request (line 1057)

Authenticates the request against the site using the password parameter.

This function can use both site-wide or object-specific prim passwords (the latter of which uses the 'sloodle_active_object' table in the database). It will also set the content of member {$link $auth_status} as appropriate.

  • return: TRUE if successful in authenticating the request, or FALSE if not.
bool authenticate_request ([bool $require = TRUE])
  • bool $require: If TRUE, the function will NOT return on authentication failure. Rather, it will terminate the script with an error message.
get_auth_status (line 818)

Returns member variable $auth_status.

int get_auth_status ()
get_avatar_name (line 919)

Returns member value $avatar_name.

Note: this function will ensure that process_request_data() has already been called prior to execution.

  • return: The avatar name provided in the request parameters, or NULL if there wasn't one
string|null get_avatar_name ()
get_avatar_uuid (line 907)

Returns member value $avatar_uuid.

Note: this function will ensure that process_request_data() has already been called prior to execution.

  • return: The avatar UUID provided in the request parameters, or NULL if there wasn't one
string|null get_avatar_uuid ()
get_course_id (line 883)

Returns member value $course_id.

Note: this function will ensure that process_request_data() has already been called prior to execution.

  • return: The course ID provided in the request parameters, or NULL if there wasn't one
integer|null get_course_id ()
get_course_module_instance (line 1182)

Get a course module instance for the module specified in the request Uses the ID specified in $module_id.

  • return: database record if successful, or FALSE if not (e.g. if instance is not found, is not visible, or is not of the correct type)
object A get_course_module_instance ([string $type = ''], [bool $require = TRUE])
  • string $type: specifies the name of the module type (e.g. 'forum', 'choice' etc.) - ignored if blank (default).
  • bool $require: If TRUE, the function will NOT return failure. Rather, it will terminate the script with an error message.
get_course_record (line 1126)

Gets a database record for the course identified in the request.

(Note: this function does not check whether or not the user is enrolled in the course)

  • return: record directly from the database, or NULL if the course is not found.
object A get_course_record ([bool $require = TRUE])
  • bool $require: If TRUE, the function will NOT return failure. Rather, it will terminate the script with an error message.
get_login_security_token (line 931)

Returns member value $login_security_token.

Note: this function will ensure that process_request_data() has already been called prior to execution.

  • return: The login security token provided in the request parameters, or NULL if there wasn't one
string|null get_login_security_token ()
get_module_id (line 895)

Returns member value $module_id.

Note: this function will ensure that process_request_data() has already been called prior to execution.

  • return: The course module instance ID provided in the request parameters, or NULL if there wasn't one
integer|null get_module_id ()
get_password (line 871)

Returns member value $password.

Note: this function will ensure that process_request_data() has already been called prior to execution.

  • return: The password provided in the request parameters, or NULL if there wasn't one
string|null get_password ()
get_response (line 943)

Returns member value $response.

Note: this function will ensure that process_request_data() has already been called prior to execution.

  • return: A reference to the response object used by this object
&SloodleLSLResponse get_response ()
get_user (line 955)

Returns member value $user.

Note: this function will ensure that process_request_data() has already been called prior to execution.

  • return: A reference to the user object used by this object
&SloodleUser get_user ()
is_authenticated (line 829)

Indicates whether or not request authentication has succeeded.

bool is_authenticated ()
is_auth_failed (line 840)

Indicates whether or not request authentication has failed.

bool is_auth_failed ()
is_request_data_processed (line 808)

Returns member variable $request_data_processed.

bool is_request_data_processed ()
process_request_data (line 1005)

Process all of the standard data provided by the HTTP request.

This function should normally be called very shortly after the start of a script, as it will check all the expected HTTP request parameters, perform basic processing, and store the data. It will also send data to the appropriate SloodleLSLResposne and SloodleUser objects. When called, it will check the $request_data_processed member to see if it has already been called. If so, it will not execute again, unless the $force parameter is TRUE. Note: most functions in this class will automatically call this function if needed to ensure data is available.

void process_request_data ([bool $force = FALSE])
  • bool $force: If TRUE, then the function is forced to execute again, even if it has already been executed. (Default: FALSE).
required_param (line 1253)

Obtains a named HTTP request parameter, and terminate with an error message if it has not been provided.

Note: for LSL linker scripts, this should *always* be used instead of the Moodle function, as this will render appropraitely formatted error messages, which LSL scripts can understand.

  • return: The converted and cleaned parameter if it is found
mixed required_param (string $parname, [int $type = PARAM_RAW])
  • string $parname: The name of the HTTP request parameter to get.
  • int $type: Specifies the expected type of parameter, as according to the Moodle documentation.
set_response (line 849)

Sets the SloodleLSLRequest::$response member.

void set_response ( &$response, SloodleLSLResponse $response)
set_user (line 858)

Sets the SloodleLSLRequest::$user member.

void set_user ( &$user, SloodleUser $user)

Documentation generated on Tue, 04 Mar 2008 15:08:45 +0000 by phpDocumentor 1.4.0