]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-18910 normalised module intro and introformat
authorskodak <skodak>
Mon, 20 Apr 2009 19:10:05 +0000 (19:10 +0000)
committerskodak <skodak>
Mon, 20 Apr 2009 19:10:05 +0000 (19:10 +0000)
mod/forum/db/install.xml
mod/forum/db/upgrade.php
mod/forum/index.php
mod/forum/mod_form.php
mod/forum/post.php
mod/forum/version.php
mod/forum/view.php
mod/glossary/db/install.xml
mod/glossary/db/upgrade.php
mod/glossary/version.php
mod/glossary/view.php

index 201df61d2d1b202b465a18ea6b1baa084b4114d8..d874ed514bfe0eaf6f29c377dcd5805ea19e7609 100644 (file)
@@ -10,8 +10,9 @@
         <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="type"/>
         <FIELD NAME="type" TYPE="char" LENGTH="20" NOTNULL="true" DEFAULT="general" SEQUENCE="false" ENUM="true" ENUMVALUES="'single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'" PREVIOUS="course" NEXT="name"/>
         <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="type" NEXT="intro"/>
-        <FIELD NAME="intro" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="assessed"/>
-        <FIELD NAME="assessed" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="intro" NEXT="assesstimestart"/>
+        <FIELD NAME="intro" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="introformat"/>
+        <FIELD NAME="introformat" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="text format of intro field" PREVIOUS="intro" NEXT="assessed"/>
+        <FIELD NAME="assessed" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="introformat" NEXT="assesstimestart"/>
         <FIELD NAME="assesstimestart" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="assessed" NEXT="assesstimefinish"/>
         <FIELD NAME="assesstimefinish" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="assesstimestart" NEXT="scale"/>
         <FIELD NAME="scale" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="assesstimefinish" NEXT="maxbytes"/>
index 7892b8e6a81b62ada9c7f42d129a7782202a121d..d95bc90a1ea601994b3c337fc9a50cea7afa7dbe 100644 (file)
@@ -220,6 +220,18 @@ function xmldb_forum_upgrade($oldversion) {
         upgrade_mod_savepoint($result, 2009042002, 'forum');
     }
 
+    if ($result && $oldversion < 2009042003) {
+
+    /// Define field introformat to be added to forum
+        $table = new xmldb_table('forum');
+        $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);
+
+    /// forum savepoint reached
+        upgrade_mod_savepoint($result, 2009042003, 'forum');
+    }
 
     return $result;
 }
index 0ccc9670492c52ddf66ee5c3a2a7324072020a86..7be7884d1e242a444bece516cff3f250866b93d2 100644 (file)
                 }
             }
 
-            $forum->intro = shorten_text(trim(format_text($forum->intro, FORMAT_HTML, $introoptions)), $CFG->forum_shortpost);
+            $forum->intro = shorten_text(trim(format_text($forum->intro, $forum->introformat, $introoptions)), $CFG->forum_shortpost);
             $forumname = format_string($forum->name, true);;
 
             if ($cm->visible) {
                 }
 
                 $introoptions->para=false;
-                $forum->intro = shorten_text(trim(format_text($forum->intro, FORMAT_HTML, $introoptions)), $CFG->forum_shortpost);
+                $forum->intro = shorten_text(trim(format_text($forum->intro, $forum->introformat, $introoptions)), $CFG->forum_shortpost);
 
                 if ($cm->sectionnum != $currentsection) {
                     $printsection = $cm->sectionnum;
index cb8f21c9515dae084f8184873ee965ffdbb46167..3e16366f6aae25d10c8368c66c8ca065e03b88af 100644 (file)
@@ -32,7 +32,7 @@ class mod_forum_mod_form extends moodleform_mod {
         $mform->addRule('intro', get_string('required'), 'required', null, 'client');
         $mform->setHelpButton('intro', array('writing', 'questions', 'richtext2'), false, 'editorhelpbutton');
 
-        $mform->addElement('format', 'format', get_string('format'));
+        $mform->addElement('format', 'introformat', get_string('format'));
 
         $options = array();
         $options[0] = get_string('no');
index cea697d9aa8e952053cbfaffae7d85bac0012e0e..486a620a37f102bf76206e3d1dde3c75fdaf11eb 100644 (file)
     } else {
         $forum->intro = trim($forum->intro);
         if (!empty($forum->intro)) {
-            print_box(format_text($forum->intro), 'generalbox', 'intro');
+            $options = (object)array('noclean'=>true);
+            print_box(format_text($forum->intro, $forum->introformat, $options), 'generalbox', 'intro');
         }
     }
 
index 9f661283ec71d5db364ca39384bb367bd5fe5b4a..4207a9427076f8a5c1db1e87bd7b6eb54bce20cb 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2009042002;
+$module->version  = 2009042003;
 $module->requires = 2009041700;  // Requires this Moodle version
 $module->cron     = 60;
 
index 0d5d42bcc309d516d7c1e33cc5b5c3357444c5cb..04ab3bf30704b9ff716e6ffa11c33f8abd1876b4 100644 (file)
             if (!empty($forum->intro)) {
                 $options = new stdclass;
                 $options->para = false;
-                print_box(format_text($forum->intro, FORMAT_MOODLE, $options), 'generalbox', 'intro');
+                $options->noclean = true;
+                print_box(format_text($forum->intro, $forum->introformat, $options), 'generalbox', 'intro');
             }
             echo '<p class="mdl-align">';
             if (forum_user_can_post_discussion($forum, null, -1, $cm)) {
             if (!empty($forum->intro)) {
                 $options = new stdclass;
                 $options->para = false;
-                print_box(format_text($forum->intro, FORMAT_MOODLE, $options), 'generalbox', 'intro');
+                $options->noclean = true;
+                print_box(format_text($forum->intro, $forum->introformat, $options), 'generalbox', 'intro');
             }
             echo '<br />';
             if (!empty($showall)) {
index 5989bf58cc9bd10653553a6f7f09e2672580d899..ee25a196ba79150c8fd61d51f5a7e01c7e465c3e 100644 (file)
@@ -9,8 +9,9 @@
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="course"/>
         <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="name"/>
         <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="intro"/>
-        <FIELD NAME="intro" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="allowduplicatedentries"/>
-        <FIELD NAME="allowduplicatedentries" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="intro" NEXT="displayformat"/>
+        <FIELD NAME="intro" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="introformat"/>
+        <FIELD NAME="introformat" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="intro" NEXT="allowduplicatedentries"/>
+        <FIELD NAME="allowduplicatedentries" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="introformat" NEXT="displayformat"/>
         <FIELD NAME="displayformat" TYPE="char" LENGTH="50" NOTNULL="true" DEFAULT="dictionary" SEQUENCE="false" ENUM="false" PREVIOUS="allowduplicatedentries" NEXT="mainglossary"/>
         <FIELD NAME="mainglossary" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="displayformat" NEXT="showspecial"/>
         <FIELD NAME="showspecial" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="mainglossary" NEXT="showalphabet"/>
index 40a905690976856a28cb74acc370542a0c9d8892..9f241233896724f87a47bf0c7fcffe0f7134ef62 100644 (file)
@@ -190,6 +190,21 @@ function xmldb_glossary_upgrade($oldversion) {
         upgrade_mod_savepoint($result, 2009042005, 'glossary');
     }
 
+    if ($result && $oldversion < 2009042006) {
+
+    /// Define field introformat to be added to glossary
+        $table = new xmldb_table('glossary');
+        $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
+
+    /// Conditionally launch add field introformat
+        if (!$dbman->field_exists($table, $field)) {
+            $dbman->add_field($table, $field);
+        }
+
+    /// glossary savepoint reached
+        upgrade_mod_savepoint($result, 2009042006, 'glossary');
+    }
+
     return $result;
 }
 
index 90f4c0d8bf73960a18d2b95047cb6b92b0ac8489..4a051799720ab9cd08c464ff0cb195646903e98b 100644 (file)
@@ -5,7 +5,7 @@
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2009042005;
+$module->version  = 2009042006;
 $module->requires = 2009041700;  // Requires this Moodle version
 $module->cron     = 0;           // Period for cron to check this module (secs)
 
index 72861cb790aebc8a8499661f040ce6a8b192e7c0..58367404ed3e4043724701ee085653bf6cd71532 100644 (file)
     if ( $glossary->intro && $showcommonelements ) {
         $options = new stdclass;
         $options->para = false;
-        print_box(format_text($glossary->intro, FORMAT_MOODLE, $options), 'generalbox', 'intro');
+        $options->noclean = true;
+        print_box(format_text($glossary->intro, $glossary->introformat, $options), 'generalbox', 'intro');
     }
 
 /// Search box