Class SloodleRequest

Description

Handles incoming HTTP requests, typically from LSL if dealing with Second Life.

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: SloodleResponse - Outputs error messages in appropriate format if an error occurs.

Located in /lib/io.php (line 768)


	
			
Variable Summary
Method Summary
 SloodleRequest SloodleRequest ( &$_session, SloodleUser $_session)
 string|null get_avatar_name ([bool $required = true])
 string|null get_avatar_uuid ([bool $required = true])
 int|null get_controller_id ([bool $required = true])
 int|null get_course_id ([bool $required = true])
 object A get_course_module_instance ([string $type = ''], [bool $require = true])
 object A get_course_record ([bool $require = true])
 int|null get_module_id ([bool $required = true])
 string|mixed get_param (string $parname, bool $required, [mixed $default = null])
 string|null get_password ([bool $required = true])
 string|null get_request_descriptor ([bool $required = true])
 string|null get_server_access_level ([bool $required = true])
 string|mixed optional_param (string $parname, [mixed $default = null])
 bool process_request_data ([bool $require_auth = true], [bool $require_user = true])
 string required_param (string $parname)
Variables
bool $request_data_processed = false (line 788)

Indicates whether or not the basic request data has already been processed.

This is used to ensure data is processed.

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

Reference to the containing SloodleSession object.

If null, then this module is being used outwith the framework. Always check the status of the variable before using it! Note: if not provided, then this object will not render any response information.

  • access: protected
Methods
Constructor SloodleRequest (line 902)

Constructor

If the session parameter is null, then this object simply does not render response information.

SloodleRequest SloodleRequest ( &$_session, SloodleUser $_session)
get_avatar_name (line 857)

Fetches the avatar name request parameter.

  • return: The avatar name provided in the request parameters, or null if there wasn't one
string|null get_avatar_name ([bool $required = true])
  • bool $required: If true (default) then the function will terminate the script with an error message if the HTTP request parameter was not specified.
get_avatar_uuid (line 847)

Fetches the avatar UUID request parameter.

  • return: The avatar UUID provided in the request parameters, or null if there wasn't one
string|null get_avatar_uuid ([bool $required = true])
  • bool $required: If true (default) then the function will terminate the script with an error message if the HTTP request parameter was not specified.
get_controller_id (line 827)

Fetches the controller ID request parameter.

  • return: The controller ID provided in the request parameters, or null if there wasn't one
int|null get_controller_id ([bool $required = true])
  • bool $required: If true (default) then the function will terminate the script with an error message if the HTTP request parameter was not specified.
get_course_id (line 817)

Fetches the course ID request parameter.

  • return: The course ID provided in the request parameters, or null if there wasn't one
int|null get_course_id ([bool $required = true])
  • bool $required: If true (default) then the function will terminate the script with an error message if the HTTP request parameter was not specified.
get_course_module_instance (line 1023)

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 967)

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_module_id (line 837)

Fetches the module ID request parameter.

  • return: The module ID provided in the request parameters, or null if there wasn't one
int|null get_module_id ([bool $required = true])
  • bool $required: If true (default) then the function will terminate the script with an error message if the HTTP request parameter was not specified.
get_param (line 1131)

Obtains a named HTTP request parameter, optionally requiring it or not

  • return: The raw value of the HTTP parameter if found, or the value of parameter $default if it was not found and parameter $require was false
string|mixed get_param (string $parname, bool $required, [mixed $default = null])
  • string $parname: The name of the parameter to get
  • bool $required: Indicates whether or not to 'require' the parameter (if it is required, but cannot be found, then the script is terminated with an error message)
  • mixed $default: If the $require parameter is false, and the HTTP parameter cannot be found, then this value will be returned instead
get_password (line 807)

Fetches the password request parameter.

  • return: The password provided in the request parameters, or null if there wasn't one
string|null get_password ([bool $required = true])
  • bool $required: If true (default) then the function will terminate the script with an error message if the HTTP request parameter was not specified.
get_request_descriptor (line 867)

Fetches the request descriptor request parameter.

  • return: The request descriptor provided in the request parameters, or null if there wasn't one
string|null get_request_descriptor ([bool $required = true])
  • bool $required: If true (default) then the function will terminate the script with an error message if the HTTP request parameter was not specified.
get_server_access_level (line 888)

Fetches the server access level parameter, if specified.

  • return: The server access level provided in the request parameters, or null if there wasn't one
string|null get_server_access_level ([bool $required = true])
  • bool $required: If true (default) then the function will terminate the script with an error message if the HTTP request parameter was not specified.
is_object_request (line 876)

Checks the parameters to determine if the request relates to an object rather than a user

  • return: True if the request seems to have come from an object, or false otherwise.
bool is_object_request ()
is_request_data_processed (line 797)

Checks whether or not the request data has already been processed.

bool is_request_data_processed ()
optional_param (line 1092)

Obtains a named HTTP request parameter, or NULL if it has not been provided.

Return values are always strings.

  • return: The raw parameter value (will be a string if the parameter was found, or the value of parameter $default otherwise)
string|mixed optional_param (string $parname, [mixed $default = null])
  • string $parname: The name of the parameter to fetch
  • mixed $default: The value to return if the parameter cannot be found
process_request_data (line 916)

Process all of the standard data provided by the HTTP request, and write it into our SloodleSession object.

Requires that a SloodleSession object was provided at construction, and is stored in the $_session member. NOTE: this does not load the module part of the session. That must be done separately, using the SloodleSession::load_module() member function.

  • return: True if successful, or false otherwise.
bool process_request_data ([bool $require_auth = true], [bool $require_user = true])
  • bool $require_auth: If true, then the function will terminate the script with an error message if it cannot authenticate the request through a course, controller and password
  • bool $require_user: If true, then the function will terminate the script with an error message if a legitimate user was not identified or could not be auto-registered
required_param (line 1107)

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

Note: for linker scripts, this should *always* be used instead of the standard Moodle function, as this will render appropriately formatted error messages, which scripts can understand. Also note that this function always returned values in the string type. They must be cast.

  • return: The raw parameter value
string required_param (string $parname)
  • string $parname: The name of the HTTP request parameter to get.

Documentation generated on Mon, 07 Jul 2008 12:32:31 +0100 by phpDocumentor 1.4.0