}
}
- /**
- * 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();
return true;
}
+
}
class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless {
var $_types = array();
- var $_formats = array();
/**
$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;
}
}
}
}
+ 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);
+
+ }
+
+ }
}
/**
$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;
+ }
+ }
}
(!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),
array('discussion'=>$discussion->id):
array()));
- $mform_post->trusttext_prepare_edit('message', 'format', $modcontext);
$mform_post->display();