From 9b010a102e3940921172063ff554e8f30f5bd9ac Mon Sep 17 00:00:00 2001 From: skodak Date: Tue, 21 Apr 2009 21:33:08 +0000 Subject: [PATCH] MDL-18910 full support for module intro editor with embedded images --- mod/assignment/lib.php | 2 +- mod/chat/lib.php | 11 +++++------ mod/chat/mod_form.php | 9 ++------- mod/chat/view.php | 3 +-- mod/choice/mod_form.php | 11 +++-------- mod/choice/view.php | 3 +-- 6 files changed, 13 insertions(+), 26 deletions(-) diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index 548794be70..ac34749d7b 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -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; diff --git a/mod/chat/lib.php b/mod/chat/lib.php index 7476b683de..40d88732fa 100644 --- a/mod/chat/lib.php +++ b/mod/chat/lib.php @@ -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; diff --git a/mod/chat/mod_form.php b/mod/chat/mod_form.php index add670f8d7..ca9477f610 100644 --- a/mod/chat/mod_form.php +++ b/mod/chat/mod_form.php @@ -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(); } } -?> diff --git a/mod/chat/view.php b/mod/chat/view.php index d1f1447456..f94cf15d07 100644 --- a/mod/chat/view.php +++ b/mod/chat/view.php @@ -173,8 +173,7 @@ } 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(); diff --git a/mod/choice/mod_form.php b/mod/choice/mod_form.php index 19d455027b..b093c9be47 100644 --- a/mod/choice/mod_form.php +++ b/mod/choice/mod_form.php @@ -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')); diff --git a/mod/choice/view.php b/mod/choice/view.php index e93feb7b5b..cfa4cc3dad 100644 --- a/mod/choice/view.php +++ b/mod/choice/view.php @@ -79,8 +79,7 @@ echo '
'; 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 -- 2.39.5