/** * Gets all object types and versions available in this installation. * Creates a 2-dimensional associative array. * The top level is the object name, and the second is the object version (both as strings). * The associated value is the path to the configuration form script, or boolean false * if the object has no configuration options. * @return array|false Returns a 2d associative array if successful, or false if an error occurs */ function sloodle_get_installed_object_types() { // Fetch all sub-directories of the "mod" directory $MODPATH = SLOODLE_DIRROOT . '/mod'; $dirs = sloodle_get_subdirectories($MODPATH, true); if (!$dirs) { return false; } // Go through each object to parse names and version numbers. // Object names should have format "name-version" (e.g. "chat-1.0"). // We will skip anything that does not match this format. // We will also skip anything with a "noshow" file in the folder. $mods = array(); foreach ($dirs as $d) { if (empty($d)) { continue; } // Parse the object identifier list($name, $version) = sloodle_parse_object_identifier($d); if (empty($name) || empty($version)) { continue; } // Check if there's a noshow file if (file_exists("{$MODPATH}/{$d}/noshow")) { continue; } // Check if this object has a configuration script $cfgscript = "{$MODPATH}/{$d}/object_config.php"; if (file_exists($cfgscript)) { $mods[$name][$version] = $cfgscript; } else { $mods[$name][$version] = false; } } // Sort the array by name of the object ksort($mods); return $mods; }
// Display the page header //$navigation = "<a href=\"{$CFG->wwwroot}/mod/sloodle/index.php?id=$course->id\">$strsloodles</a> ->"; $navigation = "<a href=\"{$CFG->wwwroot}/mod/sloodle/view.php?id={$sloodlecontrollerid}\">" . format_string($sloodle->name) . "</a> ->"; print_header_simple($pagename, "", "{$navigation} " . $pagename, "", "", true, '', navmenu($course, $cm)); // We can display the Sloodle module info... log the view add_to_log($course->id, 'sloodle', 'view sloodle config', "classroom/notecard_configuration.php?sloodlecontrollerid={$sloodlecontrollerid}&sloodleobjtype={$sloodleobjtype}", $sloodleobjtype, $cm->id); // Make sure the object type is recognised $objectpath = SLOODLE_DIRROOT . "/mod/{$sloodleobjtype}"; if (!file_exists($objectpath)) { error("ERROR: object \"{$sloodleobjtype}\" is not installed."); } // Determine if we have a custom configuration page $customconfig = $objectpath . '/object_config.php'; $hascustomconfig = file_exists($customconfig); // Split up the object identifier into name and version number, then get the translated name list($objectname, $objectversion) = sloodle_parse_object_identifier($sloodleobjtype); $strobjectname = get_string("object:{$objectname}", 'sloodle'); //--------------------------------------------------------------------------------- // Display intro information print_box_start('generalbox boxwidthwide boxaligncenter'); echo '<div style="text-align:center;">'; echo "<h1>{$pagename}</h1>"; echo "<h2>{$strobjectname} {$objectversion}</h2>"; // Display our configuration form echo '<form action="' . SLOODLE_WWWROOT . '/classroom/notecard_configuration_view.php" method="POST">'; echo '<input type="hidden" name="formsubmitted" value="true">'; // Are there any custom configuration options? if ($hascustomconfig) { // We need to create some dummy data for the form // (basically pretend we have an authorised object, and hope nobody tries to use the missing data anywhere!) // (not the best idea, I know, but the notecard stuff was added late... :-\)