Source for file module_distributor.php
Documentation is available at module_distributor.php
// This file is part of the Sloodle project (www.sloodle.org)
* This file defines the Sloodle Distributor module.
* @copyright Copyright (c) 2008 Sloodle (various contributors)
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
* @contributor Peter R. Bloomfield
/** The Sloodle module base. */
require_once(SLOODLE_LIBROOT.
'/modules/module_base.php');
/** General Sloodle functions. */
require_once(SLOODLE_LIBROOT.
'/general.php');
* The Sloodle Distributor module class.
* Internal for Moodle only - course module instance.
* Corresponds to one record from the Moodle 'course_modules' table.
* Internal only - Sloodle module instance database object.
* Corresponds to one record from the Moodle 'sloodle' table.
* Internal only - Sloodle Distributor instance database object.
* Corresponds to one record from the Moodle 'sloodle_distributor' table.
parent::$constructor($_session);
* Loads data from the database.
* Note: even if the function fails, it may still have overwritten some or all existing data in the object.
* @param mixed $id The site-wide unique identifier for all modules. Type depends on VLE. On Moodle, it is an integer course module identifier ('id' field of 'course_modules' table)
* @return bool True if successful, or false otherwise
// Make sure the ID is valid
if (!is_int($id) ||
$id <=
0) return false;
// Fetch the course module data
if (!($this->cm =
get_coursemodule_from_id('sloodle', $id))) return false;
// Load from the primary table: Sloodle instance
// Check that it is the correct type
// Load from the secondary table: Distributor instance
* Gets a list of all objects for this Distributor.
* @return array An array of strings, each string containing the name of an object in this Distributor.
// Get all distributor record entries for this distributor, sorted alphabetically
if (!$recs) return array();
// Convert it to an array of strings
$entries[] =
$recs->name;
* Sets the list of objects in this Distributor
* @param array $objects An array of strings, each string containing the name of an object in the Distributor.
* @return bool True if successful, or false if not
// Delete all existing records for this Distributor
// Go through each new entry
foreach ($objects as $o) {
// Construct the new record
if (!insert_record('sloodle_distributor_entry', $rec)) $result =
false;
* Sets the UUID of the XMLRPC channel used for requests.
* @param string $uuid The UUID of an XMLRPC channel
* @return bool True if successful, or false if not
* Request that the specified object be sent to the specified avatar.
* @param string $objname Name of the object to send
* @param string $uuid UUID of the avatar to send the object to
* @return bool True if successful, or false if not.
// Check that the object exists in this distributor
if (!record_exists('sloodle_distributor_entry', 'distributorid', $this->distrib_id, 'name', addslashes($objname))) return false;
// Send the XMLRPC request
* Gets the name of this module instance.
* @return string The name of this controller
* Gets the intro description of this module instance, if available.
* @return string The intro description of this controller
* Gets the identifier of the course this controller belongs to.
* @return mixed Course identifier. Type depends on VLE. (In Moodle, it will be an integer).
* Gets the time at which this instance was created, or 0 if unknown.
* Gets the time at which this instance was last modified, or 0 if unknown.
* Gets the short type name of this instance.
* Gets the full type name of this instance, according to the current language pack, if available.
* Note: should be overridden by sub-classes.
* @return string Full type name if possible, or the short name otherwise.
Documentation generated on Fri, 17 Jul 2009 11:01:59 +0100 by phpDocumentor 1.4.0