Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-33774 mod_label stores the content where it is supposed to

removed hardcoded checking for 'label' module type

changed label update script
  • Loading branch information...
commit 3008f86c3f94ef0f2c4b5e290818e73b26592b81 1 parent 1dd6835
@marinaglancy marinaglancy authored
View
16 lib/modinfolib.php
@@ -785,11 +785,6 @@ public function get_formatted_content($options = array()) {
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)
@@ -1094,13 +1089,6 @@ public function __construct(course_modinfo $modinfo, $course, $mod, $info) {
$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.
@@ -1491,8 +1479,8 @@ function rebuild_course_cache($courseid=0, $clearonly=false) {
* 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 {
View
16 mod/label/db/upgrade.php
@@ -62,6 +62,22 @@ function xmldb_label_upgrade($oldversion) {
// 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;
}
View
4 mod/label/lib.php
@@ -129,9 +129,9 @@ function label_get_coursemodule_info($coursemodule) {
$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 {
View
2  mod/label/version.php
@@ -25,7 +25,7 @@
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;
Please sign in to comment.
Something went wrong with that request. Please try again.