From bb40325e1bf6796c6f5870dae5d529dd7124df32 Mon Sep 17 00:00:00 2001 From: jamiesensei Date: Wed, 8 Nov 2006 06:22:58 +0000 Subject: [PATCH] removed trusttext method from formslib which was unnecessary and revised trusttext use in mod/form/post.php --- lib/form/format.php | 1 - lib/formslib.php | 62 ++++++++++++++++++++++++++++++++------------- mod/forum/post.php | 7 ++--- 3 files changed, 48 insertions(+), 22 deletions(-) diff --git a/lib/form/format.php b/lib/form/format.php index cdf6d9d21d..6f955860de 100644 --- a/lib/form/format.php +++ b/lib/form/format.php @@ -77,7 +77,6 @@ class MoodleQuickForm_format extends MoodleQuickForm_select{ }else{ $format=FORMAT_MOODLE; } - $caller->setFormat($this->getName(), $format, $this->_useHtmlEditor); if ($this->_useHtmlEditor){ $this->setValue(array(FORMAT_HTML)); }else{ diff --git a/lib/formslib.php b/lib/formslib.php index 0dcfea0cc4..d2e24d3890 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -131,20 +131,6 @@ class moodleform { } } - /** - * Called after setting up defaults for form and before displaying it. - * - * @param string $elementname - * @param string $formatname - * @param object $context - */ - function trusttext_prepare_edit($elementname, $formatname, $context) { - $defaultvalue=$this->_form->_defaultValues[$elementname]; - extract($this->_form->_formats[$formatname]);// format and usehtml - trusttext_prepare_edit($defaultvalue, $format, - $usehtml, $context); - $this->_form->setDefault($elementname, $defaultvalue); - } function display() { $this->_form->display(); @@ -171,11 +157,11 @@ class moodleform { return true; } + } class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless { var $_types = array(); - var $_formats = array(); /** @@ -211,9 +197,7 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless { $this->_helpImageURL.'" />'); $this->setRequiredNote(get_string('denotesreq', 'form', $this->getReqHTML())); } - function setFormat($elementname, $format, $usehtml) { - $this->_formats[$elementname]=compact('format', 'usehtml'); - } + function setType($elementname, $paramtype) { $this->_types[$elementname] = $paramtype; } @@ -481,7 +465,39 @@ function validate_' . $this->_attributes['id'] . '(frm) { } } } + function getLockOptionStartScript(){ + + return ''; + } + function getLockOptionEndScript(){ + + return ''; + } + + function addGroupmodeSetting($course) { + if (! $course = get_record('course', 'id', $course)) { + error("This course doesn't exist"); + } + + if ($form->coursemodule) { + if (! $cm = get_record('course_modules', 'id', $form->coursemodule)) { + error("This course module doesn't exist"); + } + } else { + $cm = null; + } + $groupmode = groupmode($course, $cm); + if ($course->groupmode or (!$course->groupmodeforce)) { + unset($choices); + $choices[NOGROUPS] = get_string('groupsnone'); + $choices[SEPARATEGROUPS] = get_string('groupsseparate'); + $choices[VISIBLEGROUPS] = get_string('groupsvisible'); + choose_from_menu($choices, 'groupmode', $groupmode, '', '', 0, false, $course->groupmodeforce); + + } + + } } /** @@ -605,6 +621,16 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{ $element->updateAttributes(array('id'=>'id_'.$id)); parent::renderElement($element, $required, $error); } + function finishForm(&$form){ + parent::finishForm($form); + // add a validation script + if ('' != ($script = $form->getLockOptionStartScript())) { + $this->_html = $script . "\n" . $this->_html; + } + if ('' != ($script = $form->getLockOptionEndScript())) { + $this->_html = $this->_html . "\n" . $script; + } + } } diff --git a/mod/forum/post.php b/mod/forum/post.php index 94aac962bc..40e0940568 100644 --- a/mod/forum/post.php +++ b/mod/forum/post.php @@ -732,8 +732,10 @@ (!empty($USER->autosubscribe)); - $mform_post->set_defaults(array('general'=>$heading, - 'subject'=>$post->subject, + trusttext_prepare_edit($post->message, $post->format, can_use_html_editor(), $modcontext); + + $mform_post->set_defaults(array( 'general'=>$heading, + 'subject'=>$post->subject, 'message'=>$post->message, 'subscribe'=>$subscribe?1:0, 'mailnow'=>!empty($post->mailnow), @@ -772,7 +774,6 @@ array('discussion'=>$discussion->id): array())); - $mform_post->trusttext_prepare_edit('message', 'format', $modcontext); $mform_post->display(); -- 2.39.5