Source for file auth_check_linker.php

Documentation is available at auth_check_linker.php

  1. <?php
  2.     /**
  3.     * Sloodle object authorization check linker.
  4.     * Allows authorised objects in SL to check whether or not a specified user can authorize objects.
  5.     *
  6.     * @package sloodleclassroom
  7.     * @copyright Copyright (c) 2008 Sloodle (various contributors)
  8.     * @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
  9.     *
  10.     * @contributor Peter R. Bloomfield
  11.     *
  12.     */
  13.     
  14.     // The following parameters are required:
  15.     //
  16.     //  sloodlecontrollerid = the ID of the controller through which the current object may access Sloodle
  17.     //  sloodlepwd = the prim password or object-specific session key to authenticate access
  18.     //  sloodleuuid = the UUID of the agent requesting object authorisation
  19.     //  sloodleavname = the name of the avatar requesting object authorisation
  20.     //
  21.     //
  22.     // If the check is successful, the status code will be 1.
  23.     // The data line will contain a 1 to indicate if the user can authorise objects on this course, or 0 otherwise.
  24.     //
  25.     
  26.     
  27.     /** Lets Sloodle know we are in a linker script. */
  28.     define('SLOODLE_LINKER_SCRIPT'true);
  29.     
  30.     /** Grab the Sloodle/Moodle configuration. */
  31.     require_once('../sl_config.php');
  32.     /** Include the Sloodle PHP API. */
  33.     require_once(SLOODLE_LIBROOT.'/sloodle_session.php');
  34.     
  35.     // Authenticate the request and the user, but do not allow autoreg/autoenrol
  36.     $sloodle new SloodleSession();
  37.     $sloodle->authenticate_request();
  38.     $sloodle->validate_user(truetruetrue);
  39.     $sloodle->user->login();
  40.     
  41.     $can_authorize false;
  42.     
  43. // MOODLE-SPECIFIC //
  44.     // Check that the user has the Sloodle capability on this course
  45.     $course_context get_context_instance(CONTEXT_COURSE$sloodle->course->get_course_id());
  46.     $can_authorize has_capability('mod/sloodle:objectauth' $course_context);
  47.     
  48. // END MOODLE-SPECIFIC //
  49.     
  50.     // Render the output
  51.     $sloodle->response->set_status_code(1);
  52.     $sloodle->response->set_status_descriptor('OK');
  53.     if ($can_authorize$sloodle->response->add_data_line('1');
  54.     else $sloodle->response->add_data_line('0');
  55.     $sloodle->response->render_to_output();
  56. ?>

Documentation generated on Fri, 17 Jul 2009 11:00:59 +0100 by phpDocumentor 1.4.0