if (empty($this->content)) {
return '';
}
- if ($this->modname === 'label') {
- // special case, label returns already formatted content, see cm_info::__construct()
- // and label_get_coursemodule_info()
- return $this->content;
- }
// Improve filter performance by preloading filter setttings for all
// activities on the course (this does nothing if called multiple
// times)
$this->showdescription = isset($mod->showdescription) ? $mod->showdescription : 0;
$this->state = self::STATE_BASIC;
- // This special case handles old label data. Labels used to use the 'name' field for
- // content
- if ($this->modname === 'label' && $this->content === '') {
- $this->content = $this->extra;
- $this->extra = '';
- }
-
// Note: These fields from $cm were not present in cm_info in Moodle
// 2.0.2 and prior. They may not be available if course cache hasn't
// been rebuilt since then.
* Class that is the return value for the _get_coursemodule_info module API function.
*
* Note: For backward compatibility, you can also return a stdclass object from that function.
- * The difference is that the stdclass object may contain an 'extra' field (deprecated because
- * it was crazy, except for label which uses it differently). The stdclass object may not contain
+ * The difference is that the stdclass object may contain an 'extra' field (deprecated,
+ * use extraclasses and onclick instead). The stdclass object may not contain
* the new fields defined here (content, extraclasses, customdata).
*/
class cached_cm_info {
// Moodle v2.4.0 release upgrade line
// Put any upgrade step following this
+ if ($oldversion < 2013021400) {
+ // find all courses that contain labels and reset their cache
+ $modid = $DB->get_field_sql("SELECT id FROM {modules} WHERE name=?",
+ array('label'));
+ if ($modid) {
+ $courses = $DB->get_fieldset_sql('SELECT DISTINCT course '.
+ 'FROM {course_modules} WHERE module=?', array($modid));
+ foreach ($courses as $courseid) {
+ $DB->execute('UPDATE {course} set modinfo = ?, sectioncache = ? '.
+ 'WHERE id = ?', array(null, null, $courseid));
+ }
+ }
+
+ // label savepoint reached
+ upgrade_mod_savepoint(true, 2013021400, 'label');
+ }
return true;
}
$label->name = "label{$label->id}";
$DB->set_field('label', 'name', $label->name, array('id'=>$label->id));
}
- $info = new stdClass();
+ $info = new cached_cm_info();
// no filtering hre because this info is cached and filtered later
- $info->extra = format_module_intro('label', $label, $coursemodule->id, false);
+ $info->content = format_module_intro('label', $label, $coursemodule->id, false);
$info->name = $label->name;
return $info;
} else {
defined('MOODLE_INTERNAL') || die();
-$module->version = 2012112900; // The current module version (Date: YYYYMMDDXX)
+$module->version = 2013021400; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2012112900; // Requires this Moodle version
$module->component = 'mod_label'; // Full name of the plugin (used for diagnostics)
$module->cron = 0;