}
require_once('edit_form.php');
-$blogpostform = new blog_post_form(null, compact('existing', 'sitecontext'));
+$blogeditform = new blog_edit_form(null, compact('existing', 'sitecontext'));
-if ($blogpostform->is_cancelled()){
+if ($blogeditform->is_cancelled()){
redirect($returnurl);
-} elseif ($blogpostform->no_submit_button_pressed()) {
- no_submit_button_actions($blogpostform, $sitecontext);
+} elseif ($blogeditform->no_submit_button_pressed()) {
+ no_submit_button_actions($blogeditform, $sitecontext);
-} elseif ($fromform = $blogpostform->data_submitted()){
+} elseif ($fromform = $blogeditform->data_submitted()){
//save stuff in db
switch ($action) {
case 'add':
print_header("$SITE->shortname: $strblogs", $SITE->fullname,
'<a href="'.$CFG->wwwroot.'/user/view.php?id='.$userid.'">'.fullname($user).'</a> ->
<a href="'.$CFG->wwwroot.'/blog/index.php?userid='.$userid.'">'.$strblogs.'</a> -> '.$strformheading,'','',true);
-$blogpostform->set_defaults($post);
-$blogpostform->display();
+$blogeditform->set_defaults($post);
+$blogeditform->display();
print_footer();
die;
/***************************** edit.php functions ***************************/
-function no_submit_button_actions(&$blogpostform, $sitecontext){
- $mform =& $blogpostform->_form;
+function no_submit_button_actions(&$blogeditform, $sitecontext){
+ $mform =& $blogeditform->_form;
$data = $mform->exportValues();
//sesskey has been checked already no need to check that
//check for official tags to add
if (!empty($data['deleteotags']) && !empty($data['otags'])){ // adding official tag
delete_otags($data['otags'], $sitecontext);
}
- $blogpostform->otags_select_setup();
+ $blogeditform->otags_select_setup();
}
function delete_otags($tagids, $sitecontext){
foreach ($tagids as $tagid) {
require_once($CFG->libdir.'/formslib.php');
-class activities_import_form_1 extends moodleform {
+class course_import_activities_form_1 extends moodleform {
function definition() {
$mform->addElement('header', 'general', '');//fill in the data depending on page params
//later using set_defaults
$mform->addElement('select', 'fromcourse', $text, $options);
-
+
// buttons
$submit_string = get_string('usethiscourse');
$this->add_action_buttons(false, true, $submit_string);
-
+
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->setConstants(array('id'=> $courseid));
}
-class activities_import_form_2 extends moodleform {
+class course_import_activities_form_2 extends moodleform {
function definition() {
global $CFG;
$mform =& $this->_form;
- $courseid = $this->_customdata['courseid'];
+ $courseid = $this->_customdata['courseid'];
$mform->addElement('header', 'general', '');//fill in the data depending on page params
//later using set_defaults
$mform->addElement('text', 'fromcoursesearch', get_string('searchcourses'));
-
+
// buttons
$this->add_action_buttons(false, true, get_string('searchcourses'));
-
+
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->setConstants(array('id'=> $courseid));
require_once($CFG->dirroot.'/course/lib.php');
require_once($CFG->dirroot.'/backup/restorelib.php');
-
+
$syscontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
// if we're not a course creator , we can only import from our own courses.
}
$strimport = get_string("importdata");
-
+
$tcourseids = '';
-
+
if ($teachers = get_user_capability_course('moodle/course:update')) {
foreach ($teachers as $teacher) {
if ($teacher->id != $course->id && $teacher->id != SITEID){
notify(get_string('courseimportnotaught'));
return; // yay , this will pass control back to the file that included or required us.
}
-
+
// quick forms
include_once('import_form.php');
-
- $mform_post = new activities_import_form_1($CFG->wwwroot.'/course/import/activities/index.php', array('options'=>$options, 'courseid' => $course->id, 'text'=> get_string('coursestaught')));
+
+ $mform_post = new course_import_activities_form_1($CFG->wwwroot.'/course/import/activities/index.php', array('options'=>$options, 'courseid' => $course->id, 'text'=> get_string('coursestaught')));
$mform_post ->display();
-
- unset($options);
+
+ unset($options);
$options = array();
-
+
foreach ($cat_courses as $ccourse) {
if ($ccourse->id != $course->id && $ccourse->id != SITEID) {
$options[$ccourse->id] = $ccourse->fullname;
}
}
$cat = get_record("course_categories","id",$course->category);
-
+
if (count($options) > 0) {
- $mform_post = new activities_import_form_1($CFG->wwwroot.'/course/import/activities/index.php', array('options'=>$options, 'courseid' => $course->id, 'text' => get_string('coursescategory')));
+ $mform_post = new course_import_activities_form_1($CFG->wwwroot.'/course/import/activities/index.php', array('options'=>$options, 'courseid' => $course->id, 'text' => get_string('coursescategory')));
$mform_post ->display();
}
if (!empty($creator)) {
- $mform_post = new activities_import_form_2($CFG->wwwroot.'/course/import/activities/index.php', array('courseid' => $course->id));
- $mform_post ->display();
+ $mform_post = new course_import_activities_form_2($CFG->wwwroot.'/course/import/activities/index.php', array('courseid' => $course->id));
+ $mform_post ->display();
}
if (!empty($fromcoursesearch) && !empty($creator)) {
require_once($CFG->libdir.'/formslib.php');
-class group_import_form extends moodleform {
+class course_import_groups_form extends moodleform {
function definition() {
$mform =& $this->_form;
$maxuploadsize = $this->_customdata['maxuploadsize'];
$strimportgroups = get_string("importgroups");
-
+
$this->_upload_manager = new upload_manager('userfile', true, false, '', false, $maxuploadsize, true, true);
$this->set_max_file_size('', $maxuploadsize);
-
+
$mform->addElement('header', 'general', '');//fill in the data depending on page params
- //later using set_defaults
+ //later using set_defaults
// buttons
-
+
$mform->addElement('hidden', 'sesskey');
$mform->setType('sesskey', PARAM_ALPHA);
$mform->setConstants(array('sesskey'=> $USER->sesskey));
-
+
$mform->addElement('file', 'userfile', '');
- $mform->setHelpButton('userfile', array('attachment', get_string('attachment', 'forum'), 'forum'));
-
-
+ $mform->setHelpButton('userfile', array('attachment', get_string('attachment', 'forum'), 'forum'));
+
+
$this->add_action_buttons(false, true, $strimportgroups);
}
$maxuploadsize = get_max_upload_file_size();
echo '<p align="center">';
print_simple_box_start('center','80%');
-
+
// use formslib
include_once('import_form.php');
- $mform_post = new group_import_form($CFG->wwwroot.'/course/import/groups/index.php?id='.$id, array('maxuploadsize'=>$maxuploadsize));
+ $mform_post = new course_import_groups_form($CFG->wwwroot.'/course/import/groups/index.php?id='.$id, array('maxuploadsize'=>$maxuploadsize));
$mform_post ->display();
-
+
print_simple_box_end();
-
+
echo '</p>';
-
+
?>
error("This module is missing important code! ($modlib)");
}
- $mformclassname=$module->name.'_mod_form';
+ $mformclassname = 'mod_'.$module->name.'_mod_form';
$cousesection=isset($cw->section)?$cw->section:$section;
$mform=& new $mformclassname($form->instance, $cousesection, ((isset($cm))?$cm:null));
$mform->set_defaults($form);
error(get_string('courserequestdisabled'));
}
- $requestform = new course_request_form('request.php');
+ $requestform = new course_request_form();
$strtitle = get_string('courserequest');
print_header($strtitle, $strtitle, $strtitle, $requestform->focus());
}
else {
require_once($CFG->dirroot.'/enrol/authorize/enrol_form.php');
- $frmenrol = new authorize_enrol_form('enrol.php');
+ $frmenrol = new enrol_authorize_form();
if ($frmenrol->data_submitted()) {
$authorizeerror = '';
switch ($form->paymentmethod) {
require_once($CFG->libdir.'/formslib.php');
-class enrol_authorize_enrol_form extends moodleform
+class enrol_authorize_form extends moodleform
{
function definition()
{
return $repeats;
}
/**
- * Use this method to add the standard buttons to the end of your form. Pass a param of false
+ * Use this method to a cancel and submit button to the end of your form. Pass a param of false
* if you don't want a cancel button in your form. If you have a cancel button make sure you
* check for it being pressed using is_cancelled() and redirecting if it is true before trying to
* get data with data_submitted().
* @param boolean $revert whether to show revert button, default true
* @param string $submitlabel label for submit button, defaults to get_string('savechanges')
*/
- function add_action_buttons($cancel = true, $revert = true, $submitlabel=null){
+ function add_action_buttons($cancel = true, $submitlabel=null){
if (is_null($submitlabel)){
$submitlabel = get_string('savechanges');
}
$mform =& $this->_form;
- if ($revert || $cancel){
- //when two or more elements we need a group
+ if ($cancel){
+ //when two elements we need a group
$buttonarray=array();
$buttonarray[] = &$mform->createElement('submit', 'submitbutton', $submitlabel);
- if ($revert){
- $buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert'));
- }
- if ($cancel){
- $buttonarray[] = &$mform->createElement('cancel');
- }
+ $buttonarray[] = &$mform->createElement('cancel');
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$mform->closeHeaderBefore('buttonar');
} else {
function getLockOptionEndScript(){
$js = '<script type="text/javascript" language="javascript">'."\n";
$js .= '//<![CDATA['."\n";
- $js .= "var ".$this->getAttribute('id')."items= {";
+ $js .= "var ".$this->_formName."items= {";
foreach ($this->_dependencies as $dependentOn => $elements){
$js .= "'$dependentOn'".' : {dependents :[';
foreach ($elements as $element){
error('Can not use this script when "Logged in as"!');
}
- $mform = new change_password_form('change_password.php');
+ $mform = new login_change_password_form();
$mform->set_defaults(array('id'=>$course->id, 'username'=>$USER->username));
if ($mform->is_cancelled()) {
-<?php
+<?php
// $Id$
// forgot password routine.
// find the user and call the appropriate routine for their authentication
set_config('auth_'.$auth.'_changepasswordurl', $CFG->changepassword);
}
set_config('changepassword', '');
-}
+}
-$mform = new forgot_password_form('forgot_password.php');
+$mform = new login_forgot_password_form();
if ($mform->is_cancelled()) {
redirect($CFG->httpswwwroot.'/login/index.php');
$user = $mailuser;
}
}
-
+
// if user located (and no errors) take the appropriate action
if (empty($errors) and !empty($user)) {
// check this user isn't 'unconfirmed'
$authmethod = $user->auth;
if (is_internal_auth($authmethod) or !empty($CFG->{'auth_'.$authmethod.'_stdchangepassword'})) {
// handle internal authentication
-
+
// set 'secret' string
$user->secret = random_string(15);
if (!set_field('user', 'secret', $user->secret, 'id', $user->id)) {
reset_login_count();
$page = 'emailsent';
-
+
$changepasswordurl = "{$CFG->httpswwwroot}/login/change_password.php";
$a = new object();
$a->email = $user->email;
error("Sorry, you may not use this page.");
}
- $mform_signup = new login_signup_form('signup.php');
+ $mform_signup = new login_signup_form_1();
if ($mform_signup->is_cancelled()) {
redirect($CFG->httpswwwroot.'/login/index.php');
require_once($CFG->libdir.'/formslib.php');
-class login_signup_form extends moodleform {
+class login_signup_form_1 extends moodleform {
function definition() {
global $USER, $CFG;
}
/// prepare form and process submitted data
- $mform = new assignment_online_edit_form('view.php');
+ $mform = new mod_assignment_online_edit_form();
$defaults = new object();
$defaults->id = $this->cm->id;
$returnurl = 'view.php?id='.$this->cm->id;
- $mform = new assignment_upload_notes_form('upload.php');
+ $mform = new mod_assignment_upload_notes_form();
$defaults = new object();
$defaults->id = $this->cm->id;
}
- $mform = new data_comment_form('comment.php');
+ $mform = new mod_data_comment_form();
$mform->set_defaults(array('mode'=>$mode, 'page'=>$page, 'rid'=>$record->id, 'commentid'=>$commentid));
if ($comment) {
$format = $comment->format;
if ($template == 'singletemplate') { //prints ratings options
data_print_ratings($data, $record);
}
-
+
/**********************************
* Printing Ratings Form *
*********************************/
if (($template == 'singletemplate') && ($data->comments)) { //prints ratings options
-
+
data_print_comments($data, $record, $page);
}
}
} else {
if (!$mform) {
require_once('comment_form.php');
- $mform = new data_comment_form('comment.php');
+ $mform = new mod_data_comment_form('comment.php');
$mform->set_defaults(array('mode'=>'add', 'page'=>$page, 'rid'=>$record->id));
}
echo '<div class="newcomment" align="center">';
}
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
- $mform_post = new forum_post_form('post.php', array('course'=>$course, 'coursecontext'=>$coursecontext, 'modcontext'=>$modcontext, 'forum'=>$forum, 'post'=>$post));
+ $mform_post = new mod_forum_post_form('post.php', array('course'=>$course, 'coursecontext'=>$coursecontext, 'modcontext'=>$modcontext, 'forum'=>$forum, 'post'=>$post));
if ($fromform = $mform_post->data_submitted()) {
error('You can\'t add comments to this glossary!');
}
- $mform = new glossary_comment_form('comment.php');
+ $mform = new mod_glossary_comment_form();
$mform->set_defaults(array('eid'=>$eid, 'action'=>'add'));
if ($mform->is_cancelled()) {
error('You can\'t edit this. Time expired!');
}
- $mform = new glossary_comment_form('comment.php');
+ $mform = new mod_glossary_comment_form();
trusttext_prepare_edit($comment->entrycomment, $comment->format, can_use_html_editor(), $context);
$mform->set_defaults(array('cid'=>$cid, 'action'=>'edit', 'entrycomment'=>$comment->entrycomment, 'format'=>$comment->format));
require_capability('mod/glossary:write', $context);
}
-$mform =& new glossary_entry_form(null, compact('cm', 'glossary', 'hook', 'mode', 'e', 'context'));
+$mform =& new mod_glossary_entry_form(null, compact('cm', 'glossary', 'hook', 'mode', 'e', 'context'));
if ($mform->is_cancelled()){
if ($e){
redirect("view.php?id=$cm->id&mode=entry&hook=$e");
if (!$lastform->name or !$lastform->template) {
error(get_string("filloutallfields"), $_SERVER["HTTP_REFERER"]);
}
- $mform = new survey_details_form($CFG->wwwroot.'/course/mod.php',array('lastform'=>stripslashes_safe($lastform)));
+ $mform = new mod_survey_details_form($CFG->wwwroot.'/course/mod.php', array('lastform'=>stripslashes_safe($lastform)));
$mform->display();
print_footer($course);
* class that inherits from this one, and implements the definition_inner()
* method.
*/
-class edit_question_form extends moodleform {
+class question_edit_form extends moodleform {
/**
* Build the form definition.
- *
- * This adds all the form files that the default question type supports.
+ *
+ * This adds all the form files that the default question type supports.
* If your question type does not support all these fields, then you can
* override this method and remove the ones you don't want with $mform->removeElement().
*/
function definition() {
global $COURSE;
-
+
$qtype = $this->qtype();
$langfile = "qtype_$qtype";
-
+
$mform =& $this->_form;
$renderer =& $mform->defaultRenderer();
// Standard fields at the start of the form.
$mform->addElement('header', 'formheader', get_string("editing$qtype", $langfile));
$mform->setHelpButton('formheader', array($qtype, get_string($qtype, $qtype), $qtype));
-
+
$mform->addElement('questioncategory', 'category', get_string('category', 'quiz'),
array('courseid' => $COURSE->id, 'published' => true, 'only_editable' => true));
-
+
$mform->addElement('text', 'name', get_string('questionname', 'quiz'),
array('size' => 50));
$mform->setType('name', PARAM_MULTILANG);
$mform->addRule('name', null, 'required', null, 'client');
-
+
$mform->addElement('htmleditor', 'questiontext', get_string('questiontext', 'quiz'),
array('rows' => 15, 'course' => $COURSE->id));
$mform->setType('questiontext', PARAM_RAW);
$mform->addElement('select', 'image', get_string('imagedisplay', 'quiz'), $images);
$mform->setType('image', PARAM_FILE);
}
-
+
$mform->addElement('text', 'defaultgrade', get_string('defaultgrade', 'quiz'),
array('size' => 3));
$mform->setType('defaultgrade', PARAM_INT);
array('rows' => 10, 'course' => $COURSE->id));
$mform->setType('generalfeedback', PARAM_RAW);
$mform->setHelpButton('generalfeedback', array('generalfeedback', get_string('generalfeedback', 'quiz'), 'quiz'));
-
+
// Any questiontype specific fields.
$this->definition_inner($mform);
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$renderer->addStopFieldsetElements('buttonar');
}
-
+
/**
* Add any question-type specific form fields.
- *
- * @param object $mform the form being built.
+ *
+ * @param object $mform the form being built.
*/
function definition_inner(&$mform) {
// By default, do nothing.
}
-
+
function set_defaults($question) {
global $QTYPES;
$QTYPES[$question->qtype]->set_default_options($question);
parent::set_defaults($question);
}
-
+
/**
* Override this in the subclass to question type name.
* @return the question type name, should be the same as the name() method in the question type class.