MDL-18910 full support for module intro editor with embedded images
authorskodak <skodak>
Tue, 21 Apr 2009 21:33:08 +0000 (21:33 +0000)
committerskodak <skodak>
Tue, 21 Apr 2009 21:33:08 +0000 (21:33 +0000)
mod/assignment/lib.php
mod/chat/lib.php
mod/chat/mod_form.php
mod/chat/view.php
mod/choice/mod_form.php
mod/choice/view.php

index 548794be7023cffaf168f844441ec0cfd40ad8a2..ac34749d7be183deef3b8ecaf552744f2de516c5 100644 (file)
@@ -2428,7 +2428,7 @@ function assignment_refresh_events($courseid = 0) {
 
     foreach ($assignments as $assignment) {
         $cm = get_coursemodule_from_id('assignment', $assignment->id);
-        $event = NULL;
+        $event = new object();
         $event->name        = $assignment->name;
         $event->description = format_module_intro('assignment', $assignment, $cm->id);
         $event->timestart   = $assignment->timedue;
index 7476b683de8d2b48d76b346507629f776273815f..40d88732fa45f015226c9dc4c981a96a48227204 100644 (file)
@@ -79,7 +79,7 @@ function chat_add_instance($chat) {
 
         $event = NULL;
         $event->name        = $chat->name;
-        $event->description = $chat->intro;
+        $event->description = format_module_intro('chat', $chat, $chat->coursemodule);
         $event->courseid    = $chat->course;
         $event->groupid     = 0;
         $event->userid      = 0;
@@ -113,7 +113,7 @@ function chat_update_instance($chat) {
         if ($event->id = $DB->get_field('event', 'id', array('modulename'=>'chat', 'instance'=>$chat->id))) {
 
             $event->name        = $chat->name;
-            $event->description = $chat->intro;
+            $event->description = format_module_intro('chat', $chat, $chat->coursemodule);
             $event->timestart   = $chat->chattime;
 
             update_event($event);
@@ -399,9 +399,10 @@ function chat_refresh_events($courseid = 0) {
     $moduleid = $DB->get_field('modules', 'id', array('name'=>'chat'));
 
     foreach ($chats as $chat) {
-        $event = NULL;
+        $cm = get_coursemodule_from_id('chat', $chat->id);
+        $event = new object();
         $event->name        = $chat->name;
-        $event->description = $chat->intro;
+        $event->description = format_module_intro('chat', $chat, $cm->id);
         $event->timestart   = $chat->chattime;
 
         if ($event->id = $DB->get_field('event', 'id', array('modulename'=>'chat', 'instance'=>$chat->id))) {
@@ -600,8 +601,6 @@ function chat_update_chat_times($chatid=0) {
     }
 
     foreach ($chats as $chat) {
-        unset($chat->name);
-        unset($chat->intro);
         switch ($chat->schedule) {
             case 1: // Single event - turn off schedule and disable
                     $chat->chattime = 0;
index add670f8d7ad09b4f9f0f2dc7201898a0c97a431..ca9477f61046a95d7ba84f19db98fa295196fd7d 100644 (file)
@@ -4,8 +4,7 @@ require_once ($CFG->dirroot.'/course/moodleform_mod.php');
 class mod_chat_mod_form extends moodleform_mod {
 
     function definition() {
-        global $CFG, $DB;
-        $mform    =& $this->_form;
+        $mform = $this->_form;
 
 //-------------------------------------------------------------------------------
         $mform->addElement('header', 'general', get_string('general', 'form'));
@@ -18,10 +17,7 @@ class mod_chat_mod_form extends moodleform_mod {
         }
         $mform->addRule('name', null, 'required', null, 'client');
 
-        $mform->addElement('htmleditor', 'intro', get_string('chatintro', 'chat'));
-        $mform->setType('intro', PARAM_RAW);
-        $mform->setHelpButton('intro', array('writing', 'questions', 'richtext2'), false, 'editorhelpbutton');
-        $mform->addRule('intro', get_string('required'), 'required', null, 'client');
+        $this->add_intro_editor(true, get_string('chatintro', 'chat'));
 
         $mform->addElement('date_time_selector', 'chattime', get_string('chattime', 'chat'));
 
@@ -55,4 +51,3 @@ class mod_chat_mod_form extends moodleform_mod {
         $this->add_action_buttons();
     }
 }
-?>
index d1f14474564d0d6dbaaa09292f4c9e625ef4b6e1..f94cf15d07cff3d1871b3c24127b5c425129ff99 100644 (file)
                 }
 
                 if ($chat->intro) {
-                    $options = (object)array('noclean'=>true);
-                    print_box(format_text($chat->intro, $chat->introformat, $options), 'generalbox', 'intro');
+                    print_box(format_module_intro('chat', $chat, $cm->id), 'generalbox', 'intro');
                 }
 
                 chat_delete_old_users();
index 19d455027ba638a2adaa2ec9bb79ee7b7694c76d..b093c9be47172595d2c35277243ec97a192b49f1 100644 (file)
@@ -19,21 +19,16 @@ class mod_choice_mod_form extends moodleform_mod {
         }
         $mform->addRule('name', null, 'required', null, 'client');
 
-        $mform->addElement('htmleditor', 'intro', get_string('choicetext', 'choice'));
-        $mform->setType('intro', PARAM_RAW);
-        $mform->addRule('intro', null, 'required', null, 'client');
-        $mform->setHelpButton('intro', array('writing', 'questions', 'richtext2'), false, 'editorhelpbutton');
-
-        $mform->addElement('format', 'introformat', get_string('format'));
+        $this->add_intro_editor(true, get_string('chatintro', 'chat'));
 
 //-------------------------------------------------------------------------------
-        $repeatarray=array();
+        $repeatarray = array();
         $repeatarray[] = &MoodleQuickForm::createElement('header', '', get_string('option','choice').' {no}');
         $repeatarray[] = &MoodleQuickForm::createElement('text', 'option', get_string('option','choice'));
         $repeatarray[] = &MoodleQuickForm::createElement('text', 'limit', get_string('limit','choice'));
         $repeatarray[] = &MoodleQuickForm::createElement('hidden', 'optionid', 0);
 
-        $menuoptions=array();
+        $menuoptions = array();
         $menuoptions[0] = get_string('disable');
         $menuoptions[1] = get_string('enable');
         $mform->addElement('header', 'timerestricthdr', get_string('limit', 'choice'));
index e93feb7b5b282ea7664f46d9e76aa178a1c92225..cfa4cc3dad52949b3f8185548ffade88250b7187 100644 (file)
@@ -79,8 +79,7 @@
     echo '<div class="clearer"></div>';
 
     if ($choice->intro) {
-        $options = (object)array('noclean'=>true);
-        print_box(format_text($choice->intro, $choice->introformat, $options), 'generalbox', 'intro');
+        print_box(format_module_intro('choice', $choice, $cm->id), 'generalbox', 'intro');
     }
 
     $current = false;  // Initialise for later