]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-8166 rename in/out methods in formslib - HQ consensus
authorskodak <skodak>
Fri, 12 Jan 2007 18:52:09 +0000 (18:52 +0000)
committerskodak <skodak>
Fri, 12 Jan 2007 18:52:09 +0000 (18:52 +0000)
20 files changed:
blog/edit.php
course/edit.php
course/modedit.php
course/request.php
enrol/authorize/enrol.php
lib/formslib.php
login/change_password.php
login/forgot_password.php
login/signup.php
mod/assignment/type/online/assignment.class.php
mod/assignment/type/upload/assignment.class.php
mod/data/comment.php
mod/data/lib.php
mod/forum/post.php
mod/glossary/comment.php
mod/glossary/edit.php
question/question2.php
user/edit.php
user/profile/index.php
user/profile/index_field_form.php

index 38bb661779e0a98f2c4da4447198fbc526ede348..b14f3f38462c868668ccabee328a31e116e1df61 100755 (executable)
@@ -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,
                 '<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);
-$blogeditform->set_defaults($post);
+$blogeditform->set_data($post);
 $blogeditform->display();
 
 
index 61e785d13f83c49a057e68a3e27a5015a9a35515..e2bf1d4504e47b607692c59bd5d192260d01c2a6 100644 (file)
@@ -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
index 387b65605a9ad93c00341a15cf343451484160b1..914b0b2f176340ba6f49189bbec6518548a83476 100644 (file)
     $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)){
         } 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");
index 79a4b21c24c24b0f35b5d3576766f11ca096cbd7..a81803c6e18ee80a3c122d488e51a8fe9ce3c066 100644 (file)
@@ -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)) {
index 6cda255639716bf4c086e0d6d731582e6c8ee3ab..cc0afe5659e7b571eeef3e4bff6ca6d852b0a2bc 100755 (executable)
@@ -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:
index 8ce6952aa61f2066f2025ea6098c49fe3de5b0eb..d159b08972dca45b5542b09b3b8b149409712d44 100644 (file)
@@ -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
index dc280e929db1153aacdb6fd5d8b26743ef5f0e4d..21340181d2272e161053bb9518ddaef3ead4d47c 100644 (file)
     }
 
     $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.'&amp;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
index 85b3116bddbe7bd6021898da013f33774135e338..f029c730369fd3e10ce579d5181311c8ac844baa 100644 (file)
@@ -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();
 }
index 1ebba8ebc3ecf85710bab4f93de0c5cf1d8bba55..c4c86591599f0e8deecbc3ef353b4a6a11e29789 100644 (file)
@@ -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);
index fecda894648dc4e1a405c1d2edcadc1c2f0c718b..b6396350e8aae1fe4274ecd229f20f9071cebfee 100644 (file)
@@ -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();
index bc2925a105fb30dde0f8c2138023aac1ec9cbce7..2ef367f080e4b1ac7ffc5fbbeb7652cf1e748bc4 100644 (file)
@@ -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;
index 0735a2d02db5f14d0e1afea93e0d4483271a7f3e..f9c696de26c638e470b70945b229f2240861745a 100755 (executable)
@@ -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
             }
 
index e8916054323d00c2ef2a9b64d49bc8dc3dc8c91a..bbb35b40ab201112a866581bc8b5cfd8a5fcd3de 100755 (executable)
@@ -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 '<div class="newcomment" style="text-align:center">';
         $mform->display();
index cebc944908695cd1f4b79e9f33bfcdb72891bec6..88c959fae5498a1787490f2434e29cb60ce99d75 100644 (file)
 
     $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
                     (!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,
index 0a0cc181ad1dc99570d15ca852a6e04ee2e1d982..f416fc9907ddf499e81e539739ad0c3131958c78 100644 (file)
@@ -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&amp;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();
index 54cd0dc317e49c10b5adfc7d08197edb818655f6..28bfb4c5422450602cf9f919c661d0d05ddea79d 100644 (file)
@@ -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);
     }
 }
 
index 9406650c62970b783ef94a7ef46f771d477960aa..4c4e0ed88548999a07565a659e82f72e9c68c2cf 100644 (file)
@@ -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
index 8471c37ea609bb2dbf5a11f13eeb78d75a537128..dfe2eddf7b617338730d1f1ae1b9edc6ab38be60 100644 (file)
 
     $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
index 3251a393002043c422f89ea34a1410b39293d437..c56ef5b35d5442d7e6c96034da6b4da014bf65bf 100644 (file)
@@ -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);
index 28f2f4fa745503eccd3499d47ea36b2155d40ba1..979348bb94a3fa1ab410529dfa85df2cf772ead3 100644 (file)
@@ -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);