Source for file linker.php

Documentation is available at linker.php

  1. <?php
  2.     /**
  3.     * Sloodle password reset linker.
  4.     * Allows users in-world to request a password reset.
  5.     * This is only intended for auto-registered users.
  6.     *
  7.     * @package sloodlepwreset
  8.     * @copyright Copyright (c) 2008 Sloodle (various contributors)
  9.     * @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
  10.     *
  11.     * @contributor Peter R. Bloomfield
  12.     *
  13.     */
  14.     
  15.     // This script should be called with the following parameters:
  16.     //  sloodlecontrollerid = ID of a Sloodle Controller through which to access Moodle
  17.     //  sloodlepwd = the prim password or object-specific session key to authenticate the request
  18.     //  sloodleuuid = the UUID of a user agent
  19.     //  sloodleavname = the name of an avatar
  20.     //
  21.     // The following parameter is optional:
  22.     //  sloodleserveraccesslevel = indicates what access level to enforce: 0 = public, 1 = course, 2 = site, 3 = staff
  23.     //
  24.     //
  25.     // If successful, the script will reset the user's password, returning status code 1.
  26.     // The data line will contain: username|password
  27.     //
  28.     // If the user has an active email account associated with their Moodle account, then
  29.     //  status code -341 is returned, and the password is unchanged.
  30.     
  31.  
  32.     /** Lets Sloodle know we are in a linker script. */
  33.     define('SLOODLE_LINKER_SCRIPT'true);
  34.     
  35.     /** Grab the Sloodle/Moodle configuration. */
  36.     require_once('../../sl_config.php');
  37.     /** Include the Sloodle PHP API. */
  38.     require_once(SLOODLE_LIBROOT.'/sloodle_session.php');
  39.     
  40.     // Authenticate the request, and validate the user, but do not allow auto-registration/enrolment
  41.     $sloodle new SloodleSession();
  42.     $sloodle->authenticate_request();
  43.     $sloodle->validate_user(truetruetrue);
  44.     
  45.     // Request a password reset.
  46.     $password $sloodle->user->reset_password();
  47.     
  48.     // Prepare the response
  49.     $sloodle->response->set_status_code(1);
  50.     $sloodle->response->set_status_descriptor('OK');
  51.     $sloodle->response->add_data_line(array($sloodle->user->get_username()$password));
  52.     
  53.     // If there are any pending password notifications for this user, then delete them
  54.     $sloodle->user->purge_password_notifications();
  55.     
  56.     // Output the response data
  57.     sloodle_debug('<pre>');
  58.     $sloodle->response->render_to_output();
  59.     sloodle_debug('</pre>');
  60.     
  61. ?>

Documentation generated on Mon, 16 Jun 2008 15:56:34 +0100 by phpDocumentor 1.4.0