From beac4717de97f0c55c48bdf334a0e2ab921d34d7 Mon Sep 17 00:00:00 2001 From: skodak Date: Fri, 12 Jan 2007 18:52:09 +0000 Subject: [PATCH] MDL-8166 rename in/out methods in formslib - HQ consensus --- blog/edit.php | 4 ++-- course/edit.php | 4 ++-- course/modedit.php | 4 ++-- course/request.php | 2 +- enrol/authorize/enrol.php | 2 +- lib/formslib.php | 10 +++++----- login/change_password.php | 4 ++-- login/forgot_password.php | 4 ++-- login/signup.php | 2 +- mod/assignment/type/online/assignment.class.php | 4 ++-- mod/assignment/type/upload/assignment.class.php | 4 ++-- mod/data/comment.php | 8 ++++---- mod/data/lib.php | 2 +- mod/forum/post.php | 4 ++-- mod/glossary/comment.php | 8 ++++---- mod/glossary/edit.php | 4 ++-- question/question2.php | 4 ++-- user/edit.php | 4 ++-- user/profile/index.php | 4 ++-- user/profile/index_field_form.php | 2 +- 20 files changed, 42 insertions(+), 42 deletions(-) diff --git a/blog/edit.php b/blog/edit.php index 38bb661779..b14f3f3846 100755 --- a/blog/edit.php +++ b/blog/edit.php @@ -77,7 +77,7 @@ if ($blogeditform->is_cancelled()){ no_submit_button_actions($blogeditform, $sitecontext); -} else if ($fromform = $blogeditform->data_submitted()){ +} else if ($fromform = $blogeditform->get_data()){ //save stuff in db switch ($action) { case 'add': @@ -152,7 +152,7 @@ if (!$user = get_record('user', 'id', $userid)) { print_header("$SITE->shortname: $strblogs", $SITE->fullname, ''.fullname($user).' -> '.$strblogs.' -> '.$strformheading,'','',true); -$blogeditform->set_defaults($post); +$blogeditform->set_data($post); $blogeditform->display(); diff --git a/course/edit.php b/course/edit.php index 61e785d13f..e2bf1d4504 100644 --- a/course/edit.php +++ b/course/edit.php @@ -62,7 +62,7 @@ if (!empty($course)) { $editform = new course_edit_form('edit.php', compact('course', 'category')); // now override defaults if course already exists if (!empty($course)) { - $editform->set_defaults($course); + $editform->set_data($course); } if ($editform->is_cancelled()){ if (empty($course)) { @@ -71,7 +71,7 @@ if (!empty($course)) { redirect($CFG->wwwroot.'/course/view.php?id='.$course->id); } - } elseif ($data = $editform->data_submitted()) { + } elseif ($data = $editform->get_data()) { /// process data if submitted //preprocess data diff --git a/course/modedit.php b/course/modedit.php index 387b65605a..914b0b2f17 100644 --- a/course/modedit.php +++ b/course/modedit.php @@ -125,7 +125,7 @@ $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); + $mform->set_data($form); if ($mform->is_cancelled()) { if ($return && isset($cm)){ @@ -133,7 +133,7 @@ } else { redirect("view.php?id=$course->id#section-".$cousesection); } - } elseif ($fromform=$mform->data_submitted()){ + } elseif ($fromform=$mform->get_data()){ if (empty($fromform->coursemodule)) { //add if (! $course = get_record("course", "id", $fromform->course)) { error("This course doesn't exist"); diff --git a/course/request.php b/course/request.php index 79a4b21c24..a81803c6e1 100644 --- a/course/request.php +++ b/course/request.php @@ -29,7 +29,7 @@ redirect($CFG->wwwroot); - }elseif ($data = $requestform->data_submitted()) { + }elseif ($data = $requestform->get_data()) { $data->requester = $USER->id; if (insert_record('course_request', $data)) { diff --git a/enrol/authorize/enrol.php b/enrol/authorize/enrol.php index 6cda255639..cc0afe5659 100755 --- a/enrol/authorize/enrol.php +++ b/enrol/authorize/enrol.php @@ -75,7 +75,7 @@ class enrolment_plugin_authorize else { require_once($CFG->dirroot.'/enrol/authorize/enrol_form.php'); $frmenrol = new enrol_authorize_form(); - if ($frmenrol->data_submitted()) { + if ($frmenrol->get_data()) { $authorizeerror = ''; switch ($form->paymentmethod) { case AN_METHOD_CC: diff --git a/lib/formslib.php b/lib/formslib.php index 8ce6952aa6..d159b08972 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -232,7 +232,7 @@ class moodleform { * @param mixed $default_values object or array of default values * @param bool $slased true if magic quotes applied to data values */ - function set_defaults($default_values, $slashed=false) { + function set_data($default_values, $slashed=false) { if (is_object($default_values)) { $default_values = (array)$default_values; } @@ -348,7 +348,7 @@ class moodleform { * @param bool $slashed true means return data with addslashes applied * @return object submitted data; NULL if not valid or not submitted */ - function data_submitted($slashed=true) { + function get_data($slashed=true) { $mform =& $this->_form; if ($this->is_submitted() and $this->is_validated()) { @@ -406,7 +406,7 @@ class moodleform { /** * Dummy stub method - override if you need to setup the form depending on current - * values. This method is called after definition(), data submission and set_defaults(). + * values. This method is called after definition(), data submission and set_data(). * All form setup that is dependent on form values should go in here. */ function definition_after_data(){ @@ -529,7 +529,7 @@ class moodleform { * 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(). + * get data with get_data(). * * @param boolean $cancel whether to show cancel button, default true * @param boolean $revert whether to show revert button, default true @@ -829,7 +829,7 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless { /** * Initializes a default form value. Used to specify the default for a new entry where - * no data is loaded in using moodleform::set_defaults() + * no data is loaded in using moodleform::set_data() * * @param string $elementname element name * @param mixed $values values for that element name diff --git a/login/change_password.php b/login/change_password.php index dc280e929d..21340181d2 100644 --- a/login/change_password.php +++ b/login/change_password.php @@ -37,11 +37,11 @@ } $mform = new login_change_password_form(); - $mform->set_defaults(array('id'=>$course->id, 'username'=>$USER->username)); + $mform->set_data(array('id'=>$course->id, 'username'=>$USER->username)); if ($mform->is_cancelled()) { redirect($CFG->wwwroot.'/user/view.php?id='.$USER->id.'&course='.$course->id); - } else if ($data = $mform->data_submitted()) { + } else if ($data = $mform->get_data()) { if (!has_capability('moodle/user:update', $sitecontext)) { //ignore submitted username - the same is done in form validation diff --git a/login/forgot_password.php b/login/forgot_password.php index 85b3116bdd..f029c73036 100644 --- a/login/forgot_password.php +++ b/login/forgot_password.php @@ -56,7 +56,7 @@ if ($mform->is_cancelled()) { redirect($CFG->httpswwwroot.'/login/index.php'); } -if ($action == 'find' and $param = $mform->data_submitted()) { +if ($action == 'find' and $param = $mform->get_data()) { ///===================== /// find the user in the database and mail info ///===================== @@ -265,7 +265,7 @@ if ($page == 'emailconfirm') { } -if(!$mform->data_submitted()) { +if(!$mform->get_data()) { echo $strforgotteninstruct; $mform->display(); } diff --git a/login/signup.php b/login/signup.php index 1ebba8ebc3..c4c8659159 100644 --- a/login/signup.php +++ b/login/signup.php @@ -16,7 +16,7 @@ if ($mform_signup->is_cancelled()) { redirect($CFG->httpswwwroot.'/login/index.php'); - } else if ($user = $mform_signup->data_submitted()) { + } else if ($user = $mform_signup->get_data()) { $plainpass = $user->password; $user->password = hash_internal_user_password($plainpass); diff --git a/mod/assignment/type/online/assignment.class.php b/mod/assignment/type/online/assignment.class.php index fecda89464..b6396350e8 100644 --- a/mod/assignment/type/online/assignment.class.php +++ b/mod/assignment/type/online/assignment.class.php @@ -56,13 +56,13 @@ class assignment_online extends assignment_base { $defaults->format = $submission->data2; } } - $mform->set_defaults($defaults); + $mform->set_data($defaults); if ($mform->is_cancelled()) { redirect('view.php?id='.$this->cm->id); } - if ($data = $mform->data_submitted()) { // No incoming data? + if ($data = $mform->get_data()) { // No incoming data? if ($editable && $this->update_submission($data)) { //TODO fix log actions - needs db upgrade $submission = $this->get_submission(); diff --git a/mod/assignment/type/upload/assignment.class.php b/mod/assignment/type/upload/assignment.class.php index bc2925a105..2ef367f080 100644 --- a/mod/assignment/type/upload/assignment.class.php +++ b/mod/assignment/type/upload/assignment.class.php @@ -449,7 +449,7 @@ class assignment_upload extends assignment_base { $defaults->text = ''; } - $mform->set_defaults($defaults); + $mform->set_data($defaults); if ($mform->is_cancelled()) { redirect('view.php?id='.$this->cm->id); @@ -463,7 +463,7 @@ class assignment_upload extends assignment_base { die; } - if ($data = $mform->data_submitted() and $action == 'savenotes') { + if ($data = $mform->get_data() and $action == 'savenotes') { $submission = $this->get_submission($USER->id, true); // get or create submission $updated = new object(); $updated->id = $submission->id; diff --git a/mod/data/comment.php b/mod/data/comment.php index 0735a2d02d..f9c696de26 100755 --- a/mod/data/comment.php +++ b/mod/data/comment.php @@ -47,7 +47,7 @@ $mform = new mod_data_comment_form(); - $mform->set_defaults(array('mode'=>$mode, 'page'=>$page, 'rid'=>$record->id, 'commentid'=>$commentid)); + $mform->set_data(array('mode'=>$mode, 'page'=>$page, 'rid'=>$record->id, 'commentid'=>$commentid)); if ($comment) { $format = $comment->format; $content = $comment->content; @@ -58,7 +58,7 @@ $content = format_text($content, $format, $options); $format = FORMAT_HTML; } - $mform->set_defaults(array('content'=>$content, 'format'=>$format)); + $mform->set_data(array('content'=>$content, 'format'=>$format)); } @@ -68,7 +68,7 @@ switch ($mode) { case 'add': - if (!$formadata = $mform->data_submitted()) { + if (!$formadata = $mform->get_data()) { break; // something is wrong here, try again } @@ -87,7 +87,7 @@ break; case 'edit': //print edit form - if (!$formadata = $mform->data_submitted()) { + if (!$formadata = $mform->get_data()) { break; // something is wrong here, try again } diff --git a/mod/data/lib.php b/mod/data/lib.php index e891605432..bbb35b40ab 100755 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -1117,7 +1117,7 @@ function data_print_comments($data, $record, $page=0, $mform=false) { if (!$mform) { require_once('comment_form.php'); $mform = new mod_data_comment_form('comment.php'); - $mform->set_defaults(array('mode'=>'add', 'page'=>$page, 'rid'=>$record->id)); + $mform->set_data(array('mode'=>'add', 'page'=>$page, 'rid'=>$record->id)); } echo '
'; $mform->display(); diff --git a/mod/forum/post.php b/mod/forum/post.php index cebc944908..88c959fae5 100644 --- a/mod/forum/post.php +++ b/mod/forum/post.php @@ -436,7 +436,7 @@ $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()) { + if ($fromform = $mform_post->get_data()) { if (!empty($course->lang)) { // Override current language @@ -726,7 +726,7 @@ (!empty($USER->autosubscribe)); - $mform_post->set_defaults(array( 'general'=>$heading, + $mform_post->set_data(array( 'general'=>$heading, 'subject'=>$post->subject, 'message'=>$post->message, 'subscribe'=>$subscribe?1:0, diff --git a/mod/glossary/comment.php b/mod/glossary/comment.php index 0a0cc181ad..f416fc9907 100644 --- a/mod/glossary/comment.php +++ b/mod/glossary/comment.php @@ -52,13 +52,13 @@ function glossary_comment_add() { } $mform = new mod_glossary_comment_form(); - $mform->set_defaults(array('eid'=>$eid, 'action'=>'add')); + $mform->set_data(array('eid'=>$eid, 'action'=>'add')); if ($mform->is_cancelled()) { redirect("comments.php?id=$cm->id&eid=$entry->id"); } - if ($data = $mform->data_submitted()) { + if ($data = $mform->get_data()) { trusttext_after_edit($data->entrycomment, $context); $newcomment = new object(); @@ -176,9 +176,9 @@ function glossary_comment_edit() { $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)); + $mform->set_data(array('cid'=>$cid, 'action'=>'edit', 'entrycomment'=>$comment->entrycomment, 'format'=>$comment->format)); - if ($data = $mform->data_submitted()) { + if ($data = $mform->get_data()) { trusttext_after_edit($data->entrycomment, $context); $updatedcomment = new object(); diff --git a/mod/glossary/edit.php b/mod/glossary/edit.php index 54cd0dc317..28bfb4c542 100644 --- a/mod/glossary/edit.php +++ b/mod/glossary/edit.php @@ -47,7 +47,7 @@ if ($mform->is_cancelled()){ redirect("view.php?id=$cm->id"); } -} elseif ($fromform = $mform->data_submitted()) { +} elseif ($fromform = $mform->get_data()) { trusttext_after_edit($fromform->definition, $context); if ( !isset($fromform->usedynalink) ) { @@ -176,7 +176,7 @@ if ($mform->is_cancelled()){ if ( $aliases = get_records_menu("glossary_alias", "entryid", $e, '', 'id, alias') ) { $toform->aliases = implode("\n", $aliases) . "\n"; } - $mform->set_defaults($toform); + $mform->set_data($toform); } } diff --git a/question/question2.php b/question/question2.php index 9406650c62..4c4e0ed885 100644 --- a/question/question2.php +++ b/question/question2.php @@ -76,11 +76,11 @@ if ($wizard!==''){ if ($mform === null) { print_error('missingimportantcode', 'question', $returnurl, 'question editing form definition'); } -$mform->set_defaults($question); +$mform->set_data($question); if ($mform->is_cancelled()){ redirect($returnurl); -} else if ($data = $mform->data_submitted()){ +} else if ($data = $mform->get_data()){ if (!empty($data->makecopy)) { $question->id = 0; // causes a new question to be created. $question->hidden = 0; // Copies should not be hidden diff --git a/user/edit.php b/user/edit.php index 8471c37ea6..dfe2eddf7b 100644 --- a/user/edit.php +++ b/user/edit.php @@ -80,10 +80,10 @@ $userform = new user_edit_form(null, compact('user','course','authplugin')); $userform->set_upload_manager(new upload_manager('imagefile',false,false,null,false,0,true,true)); - $userform->set_defaults($user); + $userform->set_data($user); /// If data submitted, then process and store. - if ($usernew = $userform->data_submitted()) { + if ($usernew = $userform->get_data()) { $context = get_context_instance(CONTEXT_SYSTEM, SITEID); // if userid = x and name = changeme then we are adding 1 diff --git a/user/profile/index.php b/user/profile/index.php index 3251a39300..c56ef5b35d 100644 --- a/user/profile/index.php +++ b/user/profile/index.php @@ -115,7 +115,7 @@ if ( ($action == 'editcategory' )) { redirect($redirect); exit; } else { - if ($data = $categoryform->data_submitted()) { + if ($data = $categoryform->get_data()) { if ($data->id == 0) { unset($data->id); $data->sortorder = count_records_select('user_info_category', '1') + 1; @@ -158,7 +158,7 @@ if ( ($action == 'editcategory' )) { redirect($redirect); exit; } else { - if ($data = $fieldform->data_submitted()) { + if ($data = $fieldform->get_data()) { require_once($CFG->dirroot.'/user/profile/field/'.$field->datatype.'/field.class.php'); $newfield = 'profile_field_'.$field->datatype; $formfield = new $newfield($field->id); diff --git a/user/profile/index_field_form.php b/user/profile/index_field_form.php index 28f2f4fa74..979348bb94 100644 --- a/user/profile/index_field_form.php +++ b/user/profile/index_field_form.php @@ -30,7 +30,7 @@ class field_form extends moodleform { $formfield->edit_field($mform); /// override the defaults with the user settings - $this->set_defaults($field); + $this->set_data($field); $this->add_action_buttons(true); -- 2.39.5