// The followign parameter is optional:
//
//   sloodleblogvisibility = the visibility of the post: public, site, private (or draft)
//
//
// Returns status code 1 if successful in simply checking authorisation and blogging ability.
// Returns status code 103 is successful in adding blog entry.
// Can also return various blog-specific error codes.
/** Lets Sloodle know we are in a linker script. */
define('SLOODLE_LINKER_SCRIPT', true);
/** Grab the Sloodle/Moodle configuration. */
require_once '../sl_config.php';
/** Include the Sloodle PHP API. */
require_once SLOODLE_LIBROOT . '/sloodle_session.php';
// Authenticate the request as user-specific, and load a blog module
$sloodle = new SloodleSession();
$sloodle->authenticate_user_request();
$sloodle->load_module('blog', false);
// No database data required
// Attempt to validate the avatar
$sloodle->validate_avatar();
$sloodle->user->login();
// Is blogging enabled?
if (!$sloodle->module->is_enabled()) {
    $sloodle->response->quick_output(-10401, 'BLOG', 'Blogging is disabled on this site.', false);
    exit;
}
// Check if the user has permission to create blog entries
if (!$sloodle->module->user_can_write()) {
    $sloodle->response->quick_output(-10402, 'BLOG', 'User lacks permission to write blog entries.', false);
    exit;
Example #2
0
//  sloodlemoduleid = ID of a presenter
//
// Status code 1 will be returned on success.
// Each data line specifies one entry in the presetnation, as follows:
//  type|url|name
// The type may be "image", "video" or "web".
// In future, scaling values may be applied.
//
/** Lets Sloodle know we are in a linker script. */
define('SLOODLE_LINKER_SCRIPT', true);
/** Grab the Sloodle/Moodle configuration. */
require_once '../../sl_config.php';
/** Include the Sloodle PHP API. */
require_once SLOODLE_LIBROOT . '/sloodle_session.php';
// Authenticate the request, and load a slideshow module
$sloodle = new SloodleSession();
$sloodle->authenticate_request();
$sloodle->load_module(SLOODLE_TYPE_PRESENTER, true);
// Load the necessary Presenter plugins
if (!$sloodle->plugins->load_plugins('presenter')) {
    $sloodle->response->quick_output(-131, 'PLUGIN', 'Failed to load any SLOODLE Presenter plugins. Please check your "sloodle/plugin" folder.', false);
    exit;
}
// Start preparing the response
$sloodle->response->set_status_code(1);
$sloodle->response->set_status_descriptor('OK');
// Output each URL and entry type
$slides = $sloodle->module->get_slides();
if (is_array($slides)) {
    foreach ($slides as $slide) {
        // This will store the source URL for the slide
Example #3
0
//  sloodleuuid = UUID of the avatar
//  sloodleavname = name of the avatar
//  message = the body of the message.
//
// The following parameters are optional:
//  firstmessageid = if specified, only messages whose ID number is greater than or equal to this value will be returned in the chat history
//  sloodledebug = if 'true', then Sloodle debugging mode is activated
//
/** Lets Sloodle know we are in a linker script. */
define('SLOODLE_LINKER_SCRIPT', true);
/** Grab the Sloodle/Moodle configuration. */
require_once '../../sl_config.php';
/** Include the Sloodle PHP API. */
require_once SLOODLE_LIBROOT . '/sloodle_session.php';
// Authenticate the request, and load a chat module
$sloodle = new SloodleSession();
$sloodle->authenticate_request();
$sloodle->load_module('chat', true);
// Attempt to validate the user
// (this will auto-register/enrol users where necessary and allowed)
// If server access level is public, then validation is not essential... otherwise, it is
$sloodleserveraccesslevel = $sloodle->request->get_server_access_level(false);
if ($sloodleserveraccesslevel == 0) {
    $sloodle->validate_user(false);
} else {
    $sloodle->validate_user(true);
}
// Has an incoming message been provided?
$message = sloodle_clean_for_db($sloodle->request->optional_param('message', null));
if ($message != null) {
    // Add it to the chatroom.
//
// If everything is OK, the script will return status code, with the following information on the data lines:
//  coursename_short|coursename_full
//  autoreg_enabled|autoenrol_enabled
//
// The information will relate to whatever course the accessed controller belongs to.
// (This is for security, to ensure course data cannot be retrieved unauthorised).
// The autoreg and autoenrol values will be 0 or 1, indicate whether each feature is disabled or enabled on the course.
/** Lets Sloodle know we are in a linker script. */
define('SLOODLE_LINKER_SCRIPT', true);
/** Grab the Sloodle/Moodle configuration. */
require_once '../sl_config.php';
/** Include the Sloodle PHP API. */
require_once SLOODLE_LIBROOT . '/sloodle_session.php';
// Authenticate the request
$sloodle = new SloodleSession();
$sloodle->authenticate_request();
// Make sure Sloodle is actually installed
$moduleinfo = get_record('modules', 'name', 'sloodle');
if (!$moduleinfo) {
    sloodle_debug('ERROR: Sloodle not installed<br/>');
    $sloodle->response->quick_output(-106, 'SYSTEM', 'The Sloodle module is not installed on this Moodle site.', false);
    exit;
}
// Check out autoreg and autoenrol settings
$autoreg = '0';
$autoenrol = '0';
if ($sloodle->course->check_autoreg()) {
    $autoreg = '1';
}
if ($sloodle->course->check_autoenrol()) {
 *  sloodleobjuuid = UUID of the object
 *  sloodleobjname = name of the object
 *  sloodleobjpwd = password for the object
 *  sloodleuuid = UUID of the avatar
 *  sloodleavname = name of the avatar
 *
 * If successful, the status code returned will be 1 and the data line will contain a URL to forward the user to.
 */
/** Lets Sloodle know we are in a linker script. */
define('SLOODLE_LINKER_SCRIPT', true);
/** Grab the Sloodle/Moodle configuration. */
require_once '../sl_config.php';
/** Include the Sloodle PHP API. */
require_once SLOODLE_LIBROOT . '/sloodle_session.php';
// Process the request (but we can't authenticate it)
$sloodle = new SloodleSession();
// Make sure we have the required parameters
$objuuid = $sloodle->request->required_param('sloodleobjuuid');
$objname = $sloodle->request->required_param('sloodleobjname');
$objpwd = $sloodle->request->required_param('sloodleobjpwd');
$avuuid = $sloodle->request->get_avatar_uuid();
$avname = $sloodle->request->get_avatar_name();
// Attempt to validate the user (but suppress autoreg/enrol)
$avatar_validated = $sloodle->validate_avatar(false);
// If user validation failed, then setup a pending avatar entry
$lst = null;
if (!$avatar_validated) {
    $pa = $sloodle->user->add_pending_avatar($avuuid, $avname);
    if (!$pa) {
        $sloodle->response->quick_output(-322, 'MISC_REGISTER', 'Failed to add pending avatar details.', false);
        exit;
Example #6
0
//  sloodleprimdropuuid = UUID of the PrimDrop object being submitted to
//  sloodleregion = region in which the PrimDrop is located
//  sloodlepos = position of the PrimDrop (vector <x,y,z>)
//
// If the submission was successful, the status code will be 1.
// Otherwise, the codes above may be returned (although -10204 will only appear as a side effect).
// Status code -103 will appear if some assignment submission to the database fails.
//
/** Lets Sloodle know we are in a linker script. */
define('SLOODLE_LINKER_SCRIPT', true);
/** Grab the Sloodle/Moodle configuration. */
require_once '../../sl_config.php';
/** Include the Sloodle PHP API. */
require_once SLOODLE_LIBROOT . '/sloodle_session.php';
// Authenticate the request, load the Sloodle Object assignment module, and validate the user
$sloodle = new SloodleSession();
$sloodle->authenticate_request();
$sloodle->load_module('sloodleobject', true);
// Has user data been omitted?
$uuid = $sloodle->request->get_avatar_uuid(false);
$avname = $sloodle->request->get_avatar_name(false);
if ($uuid == null && $avname == null) {
    // Just query the assignment details
    $sloodle->response->set_status_code(1);
    $sloodle->response->set_status_descriptor('OK');
    $sloodle->response->add_data_line($sloodle->module->get_name());
    $sloodle->response->add_data_line(strip_tags($sloodle->module->get_intro()));
    $sloodle->response->render_to_output();
    exit;
}
// Some user data has been provided, so make sure we can validate the user
Example #7
0
//   page = ?
//   questionids = ?
//   finishattempt = ?
//   timeup = true if submission was by timer
//    forcenew = teacher has requested a new preview
//    action = ??
/** Lets Sloodle know we are in a linker script. */
define('SLOODLE_LINKER_SCRIPT', true);
/** Grab the Sloodle/Moodle configuration. */
require_once '../../sl_config.php';
/** Include the Sloodle PHP API. */
require_once SLOODLE_LIBROOT . '/sloodle_session.php';
/** Include the Moodle quiz code.  */
require_once $CFG->dirroot . '/mod/quiz/locallib.php';
// Authenticate the request and login the user
$sloodle = new SloodleSession();
$sloodle->authenticate_request();
$sloodle->validate_user();
$sloodle->user->login();
// Grab our additional parameters
$id = $sloodle->request->get_module_id();
$limittoquestion = optional_param('ltq', 0, PARAM_INT);
$output = array();
$courseid = optional_param('courseid', 0, PARAM_INT);
// Course Module ID
//$id = optional_param('id', 0, PARAM_INT);               // Course Module ID
$q = optional_param('q', 0, PARAM_INT);
// or quiz ID
$page = optional_param('page', 0, PARAM_INT);
$questionids = optional_param('questionids', '');
$finishattempt = optional_param('finishattempt', 0, PARAM_BOOL);
//
// With this information, a new entry is made which is not linked to a particular user account.
// As such, the entry is deemed 'unauthorised' and cannot be used until authorised.
// If successful, status code 1 is returned, and the ID of the active object entry is returned on the data line.
// The object should use this to build a URL to send the user to Sloodle for manual object authorisation.
// Unauthorised entries will expire within 5 minutes and be deleted.
/** Lets Sloodle know we are in a linker script. */
define('SLOODLE_LINKER_SCRIPT', true);
/** Grab the Sloodle/Moodle configuration. */
require_once '../sl_config.php';
/** Include the Sloodle PHP API. */
require_once SLOODLE_LIBROOT . '/sloodle_session.php';
// Attempt to authenticate the request
// (only require authentication if controller ID and/or password is set)
$authrequired = isset($_REQUEST['sloodlecontrollerid']) || isset($_REQUEST['sloodlepwd']);
$sloodle = new SloodleSession();
$request_auth = $sloodle->authenticate_request($authrequired);
// Get the extra parameters
$sloodleobjuuid = $sloodle->request->required_param('sloodleobjuuid');
$sloodleobjname = $sloodle->request->required_param('sloodleobjname');
$sloodleobjpwd = $sloodle->request->required_param('sloodleobjpwd');
$sloodleobjtype = $sloodle->request->optional_param('sloodleobjtype', '');
$sloodlecloneconfig = $sloodle->request->optional_param('sloodlecloneconfig', '');
// uuid of an object whose config we want to clone. combined with a layout id of 0. used for rezzing a mothership from a set
// When the set rezzes an item from a layout, it can pass this parameter saying what layout entry the object represented.
// We'll use that to auto-configure the object based on the layout entry configurations.
$sloodlelayoutentryid = $sloodle->request->optional_param('sloodlelayoutentryid', -1, PARAM_INT);
// If the request was authenticated, then the object is being fully authorised.
// Otherwise, it is simply a 'pending' authorisation.
if ($request_auth) {
    // If the request is coming from an authorised object, then use that user as the authoriser for this one
//  sloodleobjuuid = the UUID of the object which is active
//
//
// If the check is successful, the status code will be 1.
// If the object was not found, status code -103 is returned.
//
// NOTE: using the "sloodleobjuuid" parameter allows an object to ping on behalf of another.
// However, the object must be authorised on the controller identified by "sloodlecontrollerid".
//
/** Lets Sloodle know we are in a linker script. */
define('SLOODLE_LINKER_SCRIPT', true);
/** Grab the Sloodle/Moodle configuration. */
require_once '../sl_config.php';
/** Include the Sloodle PHP API. */
require_once SLOODLE_LIBROOT . '/sloodle_session.php';
// Authenticate the request
$sloodle = new SloodleSession();
$sloodle->authenticate_request();
// Get our additional parameter
$sloodleobjuuid = $sloodle->request->get_param('sloodleobjuuid', true);
// Attempt to ping the object
if ($sloodle->course->controller->ping_object($sloodleobjuuid)) {
    $sloodle->set_status_code(1);
    $sloodle->set_status_descriptor('OK');
} else {
    $sloodle->set_status_code(-103);
    $sloodle->set_status_descriptor('SYSTEM');
    $sloodle->add_data_line('Failed to ping active object.');
}
// Output the response
$sloodle->response->render_to_output();
Example #10
0
//  sloodlecontrollerid = ID of a Sloodle Controller through which to access Moodle
//  sloodlepwd = the prim password or object-specific session key to authenticate the request
//  sloodlemoduleid = ID of a chatroom
//  sloodleinventory = a pipe-separated list of names of items in the obect's inventory
//  sloodlechannel = the UUID of an XMLRPC channel which can be used to request object distribution
//
// The following parameter is optional:
//  sloodledebug = if 'true', then Sloodle debugging mode is activated
/** Lets Sloodle know we are in a linker script. */
define('SLOODLE_LINKER_SCRIPT', true);
/** Grab the Sloodle/Moodle configuration. */
require_once '../../sl_config.php';
/** Include the Sloodle PHP API. */
require_once SLOODLE_LIBROOT . '/sloodle_session.php';
// Authenticate the request, and load a chat module
$sloodle = new SloodleSession();
$sloodle->authenticate_request();
$sloodle->load_module('distributor', true);
// Fetch the required additional parameters
$sloodleinventory = $sloodle->request->required_param('sloodleinventory');
$sloodlechannel = $sloodle->request->required_param('sloodlechannel');
// Attempt to update the inventory
$objects = explode('|', $sloodleinventory);
if (!$sloodle->module->set_objects($objects)) {
    // Update failed
    $sloodle->response->quick_output(-101, 'SYSTEM', 'Failed to update list of objects', false);
    exit;
}
// Attempt to update the channel
if (!$sloodle->module->set_channel($sloodlechannel)) {
    // Update failed
 *  sloodleuuid = UUID of the avatar
 *  sloodleavname = name of the avatar
 *
 * If successful, the status code returned will be 1 and the data line will contain a URL to forward the user to.
 * If nothing needs done because the user is already registered, then status code 301 is returned.
 * If nothing needs done because the user is already enrolled, then status code 401 is returned.
 * If the user cannot be enrolled because they are not yet registered, then status code -321.
 */
/** Lets Sloodle know we are in a linker script. */
define('SLOODLE_LINKER_SCRIPT', true);
/** Grab the Sloodle/Moodle configuration. */
require_once '../sl_config.php';
/** Include the Sloodle PHP API. */
require_once SLOODLE_LIBROOT . '/sloodle_session.php';
// Authenticate the request
$sloodle = new SloodleSession();
$sloodle->authenticate_request();
// Attempt to authenticate the user, but do not allow auto-registration/enrolment
$sloodle->validate_user(false, true, true);
$is_registered = $sloodle->user->is_user_loaded();
$is_enrolled = false;
if ($is_registered) {
    $is_enrolled = $sloodle->user->is_enrolled($sloodle->course->get_course_id());
}
// Make sure UUID and avatar name were specified
$sloodleuuid = $sloodle->request->get_avatar_uuid(TRUE);
$sloodleavname = $sloodle->request->get_avatar_name(TRUE);
// Get the mode value
$sloodlemode = $sloodle->request->required_param('sloodlemode');
// If the mode is 'regenrol', but the user is already registered,
//  then just do enrolment
Example #12
0
//  sloodlesearchdefinitions = if 'true' or '1' then searches will search by definitions too (defaults to false)
//
//  sloodleserveraccesslevel = defines the access level to the resource (ignored if unspecified)
//
// The following parameter is optional:
//  sloodledebug = if 'true', then Sloodle debugging mode is activated
// If successful, status code 1 will be returned.
// Each data line will contain a concept and definition separated by a pipe: <concept>|<definition>
/** Lets Sloodle know we are in a linker script. */
define('SLOODLE_LINKER_SCRIPT', true);
/** Grab the Sloodle/Moodle configuration. */
require_once '../../sl_config.php';
/** Include the Sloodle PHP API. */
require_once SLOODLE_LIBROOT . '/sloodle_session.php';
// Authenticate the request, and load a glossary module
$sloodle = new SloodleSession();
$sloodle->authenticate_request();
$sloodle->load_module('glossary', true);
// Has a search term been specified?
$sloodleterm = $sloodle->request->optional_param('sloodleterm', null);
if (empty($sloodleterm)) {
    // Just fetch the name of the glossary
    $sloodle->response->set_status_code(1);
    $sloodle->response->set_status_descriptor('OK');
    $sloodle->response->add_data_line($sloodle->module->get_name());
    $sloodle->response->add_data_line(strip_tags($sloodle->module->get_intro()));
    $sloodle->response->render_to_output();
    exit;
}
// If the server access level has been specified, then validate the user
$serveraccesslevel = $sloodle->request->get_server_access_level(false);
Example #13
0
            foreach ($rawresponses as $response) {
                if (isset($allresponses[0][$response->userid])) {
                    // This person is enrolled and in correct group
                    $allresponses[0][$response->userid]->timemodified = $response->timemodified;
                    $allresponses[$response->optionid][$response->userid] = clone $allresponses[0][$response->userid];
                    unset($allresponses[0][$response->userid]);
                    // Remove from unanswered column
                }
            }
        }
        return $allresponses;
    }
}
///// END HORRIBLE HACK! /////
// Authenticate the request, and load a choice module
$sloodle = new SloodleSession();
$sloodle->authenticate_request();
$sloodle->load_module('choice', true);
// Has an option been specified?
$sloodleoptionid = $sloodle->request->optional_param('sloodleoptionid');
if ($sloodleoptionid === null) {
    // No - we are simply querying for choice data
    $sloodle->response->set_status_code(10001);
    $sloodle->response->set_status_descriptor('CHOICE_QUERY');
    // Check availability and results
    $isavailable = '0';
    if ($sloodle->module->is_open()) {
        $isavailable = '1';
    }
    $canshowresults = $sloodle->module->can_show_results();
    // Fetch the intro (question) text, but cut everything after the first line