echo $OUTPUT->paging_bar($totalcount, $page, $perpage, "$url&perpage=$perpage");
$table = new html_table();
- $table->classes = array('logtable','generalbox');
+ $table->classes = array('logtable','generaltable');
$table->align = array('right', 'left', 'left');
$table->head = array(
get_string('time'),
// NOTE: this is legacy stuff, module subtypes are very strongly discouraged!!
$gettypesfunc = $modname.'_get_types';
if (function_exists($gettypesfunc)) {
- if ($types = $gettypesfunc()) {
+ $types = $gettypesfunc();
+ if (is_array($types) && count($types) > 0) {
$group = new stdClass();
$group->name = $modname;
$group->icon = $OUTPUT->pix_icon('icon', '', $modname, array('class' => 'icon'));
$module->archetype = plugin_supports('mod', $modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
$modlist[$course->id][$modname] = $module;
}
- $return[$modname] = $modlist[$course->id][$modname];
+ if (isset($modlist[$course->id][$modname])) {
+ $return[$modname] = $modlist[$course->id][$modname];
+ } else {
+ debugging("Invalid module metadata configuration for {$modname}");
+ }
}
return $return;
return has_any_capability(array('moodle/category:manage', 'moodle/course:create'), $context);
}
-/**
- * Prints the turn editing on/off button on course/index.php or course/category.php.
- *
- * @param integer $categoryid The id of the category we are showing, or 0 for system context.
- * @return string HTML of the editing button, or empty string, if this user is not allowed
- * to see it.
- */
-function update_category_button($categoryid = 0) {
- global $CFG, $PAGE, $OUTPUT;
-
- // Check permissions.
- if (!can_edit_in_category($categoryid)) {
- return '';
- }
-
- // Work out the appropriate action.
- if ($PAGE->user_is_editing()) {
- $label = get_string('turneditingoff');
- $edit = 'off';
- } else {
- $label = get_string('turneditingon');
- $edit = 'on';
- }
-
- // Generate the button HTML.
- $options = array('categoryedit' => $edit, 'sesskey' => sesskey());
- if ($categoryid) {
- $options['id'] = $categoryid;
- $page = 'category.php';
- } else {
- $page = 'index.php';
- }
- return $OUTPUT->single_button(new moodle_url('/course/' . $page, $options), $label, 'get');
-}
-
/**
* Print courses in category. If category is 0 then all courses are printed.
* @param int|stdClass $category category object or id.
if (file_exists($modlib)) {
require_once($modlib);
} else {
- throw new moodle_exception("This module is missing mod/$modulename/lib.php", '', '',
- null, 'failedtodeletemodulemissinglibfile');
+ throw new moodle_exception('cannotdeletemodulemissinglib', '', '', null,
+ "Cannot delete this module as the file mod/$modulename/lib.php is missing.");
}
- $deleteinstancefunction = $modulename . "_delete_instance";
+ $deleteinstancefunction = $modulename . '_delete_instance';
+ // Ensure the delete_instance function exists for this module.
+ if (!function_exists($deleteinstancefunction)) {
+ throw new moodle_exception('cannotdeletemodulemissingfunc', '', '', null,
+ "Cannot delete this module as the function {$modulename}_delete_instance is missing in mod/$modulename/lib.php.");
+ }
+
+ // Call the delete_instance function, if it returns false throw an exception.
if (!$deleteinstancefunction($cm->instance)) {
- throw new moodle_exception("Could not delete the $modulename (instance)", '', '',
- null, 'failedtodeletemoduleinstance');
+ throw new moodle_exception('cannotdeletemoduleinstance', '', '', null,
+ "Cannot delete the module $modulename (instance).");
}
// Remove all module files in case modules forget to do that.
// Delete module from that section.
if (!delete_mod_from_section($cm->id, $cm->section)) {
- throw new moodle_exception("Could not delete the $modulename from section", '', '',
- null, 'failedtodeletemodulefromsection');
+ throw new moodle_exception('cannotdeletemodulefromsection', '', '', null,
+ "Cannot delete the module $modulename (instance) from section.");
}
// Trigger a mod_deleted event with information about this module.
)), null, true);
}
- // Include blocks dragdrop
- $params = array(
- 'courseid' => $course->id,
- 'pagetype' => $PAGE->pagetype,
- 'pagelayout' => $PAGE->pagelayout,
- 'subpage' => $PAGE->subpage,
- 'regions' => $PAGE->blocks->get_regions(),
- );
- $PAGE->requires->yui_module('moodle-core-blocks', 'M.core_blocks.init_dragdrop', array($params), null, true);
-
// Require various strings for the command toolbox
$PAGE->requires->strings_for_js(array(
'moveleft',