From 63b0256797ba5469626b1d4a8b589b0583b5e7af Mon Sep 17 00:00:00 2001 From: skodak Date: Mon, 20 Apr 2009 18:51:37 +0000 Subject: [PATCH] MDL-18910 normalised module intro and introformat --- mod/assignment/db/upgrade.php | 2 +- mod/choice/db/upgrade.php | 2 +- mod/data/db/install.xml | 9 +++++---- mod/data/db/upgrade.php | 13 +++++++++++++ mod/data/index.php | 4 ++-- mod/data/version.php | 4 ++-- mod/data/view.php | 2 +- mod/feedback/backuplib.php | 2 +- mod/feedback/db/install.xml | 14 +++++++++----- mod/feedback/db/upgrade.php | 28 +++++++++++++++++++++++++++- mod/feedback/lib.php | 4 ++-- mod/feedback/mod_form.php | 6 +++--- mod/feedback/restorelib.php | 6 +++--- mod/feedback/version.php | 4 ++-- mod/feedback/view.php | 3 ++- 15 files changed, 74 insertions(+), 29 deletions(-) diff --git a/mod/assignment/db/upgrade.php b/mod/assignment/db/upgrade.php index 6d01ab6ac0..a1c145a42f 100644 --- a/mod/assignment/db/upgrade.php +++ b/mod/assignment/db/upgrade.php @@ -149,7 +149,7 @@ function xmldb_assignment_upgrade($oldversion) { /// Rename field format on table assignment to introformat $table = new xmldb_table('assignment'); - $field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'description'); + $field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro'); /// Launch rename field format $dbman->rename_field($table, $field, 'introformat'); diff --git a/mod/choice/db/upgrade.php b/mod/choice/db/upgrade.php index de45eccfcc..2c7eb5f1ab 100644 --- a/mod/choice/db/upgrade.php +++ b/mod/choice/db/upgrade.php @@ -45,7 +45,7 @@ function xmldb_choice_upgrade($oldversion) { /// Rename field format on table choice to NEWNAMEGOESHERE $table = new xmldb_table('choice'); - $field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'text'); + $field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro'); /// Launch rename field format $dbman->rename_field($table, $field, 'introformat'); diff --git a/mod/data/db/install.xml b/mod/data/db/install.xml index 079518a9ce..7920a2f469 100644 --- a/mod/data/db/install.xml +++ b/mod/data/db/install.xml @@ -1,5 +1,5 @@ - @@ -9,8 +9,9 @@ - - + + + @@ -130,4 +131,4 @@ - + \ No newline at end of file diff --git a/mod/data/db/upgrade.php b/mod/data/db/upgrade.php index eccbde4de7..0847570abf 100644 --- a/mod/data/db/upgrade.php +++ b/mod/data/db/upgrade.php @@ -167,6 +167,19 @@ function xmldb_data_upgrade($oldversion) { upgrade_mod_savepoint($result, 2008112700, 'data'); } + if ($result && $oldversion < 2009042000) { + + /// Define field introformat to be added to data + $table = new xmldb_table('data'); + $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro'); + + /// Launch add field introformat + $dbman->add_field($table, $field); + + /// data savepoint reached + upgrade_mod_savepoint($result, 2009042000, 'data'); + } + return $result; } diff --git a/mod/data/index.php b/mod/data/index.php index f4e325bc3a..93e9c2a145 100755 --- a/mod/data/index.php +++ b/mod/data/index.php @@ -123,10 +123,10 @@ } $currentsection = $data->section; } - $row = array ($printsection, $link, format_text($data->intro, FORMAT_MOODLE, $options), $numrecords, $numunapprovedrecords); + $row = array ($printsection, $link, format_text($data->intro, $data->introformat, $options), $numrecords, $numunapprovedrecords); } else { - $row = array ($link, format_text($data->intro, FORMAT_MOODLE, $options), $numrecords, $numunapprovedrecords); + $row = array ($link, format_text($data->intro, $data->introformat, $options), $numrecords, $numunapprovedrecords); } if ($rss) { diff --git a/mod/data/version.php b/mod/data/version.php index 7c61de22e8..b40155e72f 100644 --- a/mod/data/version.php +++ b/mod/data/version.php @@ -5,8 +5,8 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2008112700; -$module->requires = 2008080701; // Requires this Moodle version +$module->version = 2009042000; +$module->requires = 2009041700; // Requires this Moodle version $module->cron = 60; ?> diff --git a/mod/data/view.php b/mod/data/view.php index 93b11b506d..9a6792730a 100755 --- a/mod/data/view.php +++ b/mod/data/view.php @@ -316,7 +316,7 @@ if ($data->intro and empty($page) and empty($record) and $mode != 'single') { $options = new object(); $options->noclean = true; - print_box(format_text($data->intro, FORMAT_MOODLE, $options), 'generalbox', 'intro'); + print_box(format_text($data->intro, $data->introformat, $options), 'generalbox', 'intro'); } /// Delete any requested records diff --git a/mod/feedback/backuplib.php b/mod/feedback/backuplib.php index 2b56b9ec99..caa1ef1b27 100644 --- a/mod/feedback/backuplib.php +++ b/mod/feedback/backuplib.php @@ -58,7 +58,7 @@ fwrite ($bf,full_tag("MODTYPE",4,false,"feedback")); fwrite ($bf,full_tag("VERSION",4,false,1)); //version 1 steht fuer die neue Version fwrite ($bf,full_tag("NAME",4,false,$feedback->name)); - fwrite ($bf,full_tag("SUMMARY",4,false,$feedback->summary)); + fwrite ($bf,full_tag("SUMMARY",4,false,$feedback->intro)); fwrite ($bf,full_tag("ANONYMOUS",4,false,$feedback->anonymous)); fwrite ($bf,full_tag("EMAILNOTIFICATION",4,false,$feedback->email_notification)); fwrite ($bf,full_tag("MULTIPLESUBMIT",4,false,$feedback->multiple_submit)); diff --git a/mod/feedback/db/install.xml b/mod/feedback/db/install.xml index 89e276eb01..ae6a4e5b7e 100644 --- a/mod/feedback/db/install.xml +++ b/mod/feedback/db/install.xml @@ -1,13 +1,17 @@ - + - - - + + + + @@ -159,4 +163,4 @@
-
+
\ No newline at end of file diff --git a/mod/feedback/db/upgrade.php b/mod/feedback/db/upgrade.php index 3aa24f3048..ba7e0e84de 100644 --- a/mod/feedback/db/upgrade.php +++ b/mod/feedback/db/upgrade.php @@ -250,7 +250,33 @@ function xmldb_feedback_upgrade($oldversion) { upgrade_mod_savepoint($result, 2009031301, 'feedback'); } - + + if ($result && $oldversion < 2009042000) { + + /// Rename field summary on table feedback to intro + $table = new xmldb_table('feedback'); + $field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null, 'name'); + + /// Launch rename field summary + $dbman->rename_field($table, $field, 'intro'); + + /// feedback savepoint reached + upgrade_mod_savepoint($result, 2009042000, 'feedback'); + } + + if ($result && $oldversion < 2009042001) { + + /// Define field introformat to be added to feedback + $table = new xmldb_table('feedback'); + $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro'); + + /// Launch add field introformat + $dbman->add_field($table, $field); + + /// feedback savepoint reached + upgrade_mod_savepoint($result, 2009042001, 'feedback'); + } + return $result; } diff --git a/mod/feedback/lib.php b/mod/feedback/lib.php index ce42b1149a..871585429b 100644 --- a/mod/feedback/lib.php +++ b/mod/feedback/lib.php @@ -454,7 +454,7 @@ function feedback_set_events($feedback) { if($feedback->timeopen > 0) { $event = NULL; $event->name = get_string('start', 'feedback').' '.$feedback->name; - $event->description = $feedback->summary; + $event->description = $feedback->intro; $event->courseid = $feedback->course; $event->groupid = 0; $event->userid = 0; @@ -476,7 +476,7 @@ function feedback_set_events($feedback) { if($feedback->timeclose > 0) { $event = NULL; $event->name = get_string('stop', 'feedback').' '.$feedback->name; - $event->description = $feedback->summary; + $event->description = $feedback->intro; $event->courseid = $feedback->course; $event->groupid = 0; $event->userid = 0; diff --git a/mod/feedback/mod_form.php b/mod/feedback/mod_form.php index a96dc11d65..1365def081 100644 --- a/mod/feedback/mod_form.php +++ b/mod/feedback/mod_form.php @@ -24,9 +24,9 @@ class mod_feedback_mod_form extends moodleform_mod { $mform->setType('name', PARAM_TEXT); $mform->addRule('name', null, 'required', null, 'client'); - $mform->addElement('htmleditor', 'summary', get_string("description", "feedback"), array('rows' => 20)); - $mform->setType('summary', PARAM_RAW); - $mform->addRule('summary', null, 'required', null, 'client'); + $mform->addElement('htmleditor', 'intro', get_string("description", "feedback"), array('rows' => 20)); + $mform->setType('intro', PARAM_RAW); + $mform->addRule('intro', null, 'required', null, 'client'); //------------------------------------------------------------------------------- $mform->addElement('header', 'timinghdr', get_string('timing', 'form')); diff --git a/mod/feedback/restorelib.php b/mod/feedback/restorelib.php index 279aa1dee4..7a6f8853c5 100644 --- a/mod/feedback/restorelib.php +++ b/mod/feedback/restorelib.php @@ -49,7 +49,7 @@ //Now, build the feedback record structure $feedback->course = $restore->course_id; $feedback->name = backup_todb($info['MOD']['#']['NAME']['0']['#']); - $feedback->summary = backup_todb($info['MOD']['#']['SUMMARY']['0']['#']); + $feedback->intro = backup_todb($info['MOD']['#']['SUMMARY']['0']['#']); $feedback->anonymous = backup_todb($info['MOD']['#']['ANONYMOUS']['0']['#']); $feedback->email_notification = backup_todb($info['MOD']['#']['EMAILNOTIFICATION']['0']['#']); $feedback->multiple_submit = backup_todb($info['MOD']['#']['MULTIPLESUBMIT']['0']['#']); @@ -69,7 +69,7 @@ if($feedback->timeopen > 0) { $event = NULL; $event->name = get_string('start', 'feedback').' '.$feedback->name; - $event->description = $feedback->summary; + $event->description = $feedback->intro; $event->courseid = $feedback->course; $event->groupid = 0; $event->userid = 0; @@ -91,7 +91,7 @@ if($feedback->timeclose > 0) { $event = NULL; $event->name = get_string('stop', 'feedback').' '.$feedback->name; - $event->description = $feedback->summary; + $event->description = $feedback->intro; $event->courseid = $feedback->course; $event->groupid = 0; $event->userid = 0; diff --git a/mod/feedback/version.php b/mod/feedback/version.php index 1320f8aee7..b1bb96e8ee 100644 --- a/mod/feedback/version.php +++ b/mod/feedback/version.php @@ -10,8 +10,8 @@ */ - $module->version = 2009031301; // The current module version (Date: YYYYMMDDXX) - $module->requires = 2008072401; // Requires this Moodle version + $module->version = 2009042001; // The current module version (Date: YYYYMMDDXX) + $module->requires = 2009041700; // Requires this Moodle version $feedback_version_intern = 1; //this version is used for restore older backups $module->cron = 0; // Period for cron to check this module (secs) diff --git a/mod/feedback/view.php b/mod/feedback/view.php index abb656f199..c34a184972 100644 --- a/mod/feedback/view.php +++ b/mod/feedback/view.php @@ -116,7 +116,8 @@ // print_simple_box_start('center', '80%'); print_box_start('generalbox boxaligncenter boxwidthwide'); - echo format_text($feedback->summary); + $options = (object)array('noclean'=>true); + echo format_text($feedback->intro, $feedback->introformat, $options); // print_simple_box_end(); print_box_end(); -- 2.39.5