Source for file modules.php
Documentation is available at modules.php
// This file is part of the Sloodle project (www.sloodle.org)
* This file brings all of the Sloodle module classes together.
* It also provides functionality to create and load different module types.
* @copyright Copyright (c) 2008 Sloodle (various contributors)
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
* @contributor Peter R. Bloomfield
require_once(SLOODLE_LIBROOT.
'/modules/module_base.php');
// Now we will go through every file in the "lib/modules" folder which starts "module_", and include it.
foreach ($modulefiles as $mf) {
// Does this filename start with "module_" and end with ".php"?
include_once($MODULESPATH.
'/'.
$mf);
// We will store an associative array of module types to module class names
// e.g. { 'chat'=>'SloodleModuleChat', 'distributor'=>'SloodleModuleDistributor', ...}
global $SLOODLE_MODULE_CLASS;
$SLOODLE_MODULE_CLASS =
array();
// Go through each declared class
foreach ($allclasses as $c) {
// Is this class a subclass of the Sloodle Module type?
// Add it to our array with its type
$SLOODLE_MODULE_CLASS[$curtype] =
$c;
* Constructs a appropriate Sloodle module object based on the named type.
* @param string $type The type of module to construct - typically a short name, such as 'chat' or 'blog'
* @param SloodleSession &$_session The {@link SloodleSession} object to pass to the module on construction, or just null
* @param mixed $id The identifier of the module instance to load from the database (or null if there is no module data)
* @return SloodleModule|boolReturns the cosntructed module object, or false if it fails
global $SLOODLE_MODULE_CLASS;
// Abort if the type is not recognised
sloodle_debug("Module load failed - type \"$type\" not recognised.<br/>");
// Construct the object, based on the class name in our array
$module =
new $SLOODLE_MODULE_CLASS[$type]($_session);
// Load the data from the database, if necessary
if ($module->load($id)) return $module;
sloodle_debug("Failed to load module data from database with ID $id.<br/>");
Documentation generated on Mon, 07 Jul 2008 12:32:47 +0100 by phpDocumentor 1.4.0