Skip to content

Commit

Permalink
MDL-8166 rename in/out methods in formslib - HQ consensus
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Jan 12, 2007
1 parent 0b0f7c0 commit beac471
Show file tree
Hide file tree
Showing 20 changed files with 42 additions and 42 deletions.
4 changes: 2 additions & 2 deletions blog/edit.php
Expand Up @@ -77,7 +77,7 @@
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':
Expand Down Expand Up @@ -152,7 +152,7 @@
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();


Expand Down
4 changes: 2 additions & 2 deletions course/edit.php
Expand Up @@ -62,7 +62,7 @@
$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)) {
Expand All @@ -71,7 +71,7 @@
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
Expand Down
4 changes: 2 additions & 2 deletions course/modedit.php
Expand Up @@ -125,15 +125,15 @@
$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)){
redirect("$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id");
} 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");
Expand Down
2 changes: 1 addition & 1 deletion course/request.php
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion enrol/authorize/enrol.php
Expand Up @@ -75,7 +75,7 @@ function print_entry($course) {
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:
Expand Down
10 changes: 5 additions & 5 deletions lib/formslib.php
Expand Up @@ -232,7 +232,7 @@ function _validate_files() {
* @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;
}
Expand Down Expand Up @@ -348,7 +348,7 @@ function is_cancelled(){
* @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()) {
Expand Down Expand Up @@ -406,7 +406,7 @@ function definition() {

/**
* 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(){
Expand Down Expand Up @@ -529,7 +529,7 @@ function repeat_elements($elementobjs, $repeats, $options, $repeathiddenname, $a
* 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
Expand Down Expand Up @@ -829,7 +829,7 @@ function getAdvancedHTML(){

/**
* 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
Expand Down
4 changes: 2 additions & 2 deletions login/change_password.php
Expand Up @@ -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.'&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
Expand Down
4 changes: 2 additions & 2 deletions login/forgot_password.php
Expand Up @@ -56,7 +56,7 @@
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
///=====================
Expand Down Expand Up @@ -265,7 +265,7 @@

}

if(!$mform->data_submitted()) {
if(!$mform->get_data()) {
echo $strforgotteninstruct;
$mform->display();
}
Expand Down
2 changes: 1 addition & 1 deletion login/signup.php
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions mod/assignment/type/online/assignment.class.php
Expand Up @@ -56,13 +56,13 @@ function view() {
$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();
Expand Down
4 changes: 2 additions & 2 deletions mod/assignment/type/upload/assignment.class.php
Expand Up @@ -449,7 +449,7 @@ function upload_notes() {
$defaults->text = '';
}

$mform->set_defaults($defaults);
$mform->set_data($defaults);

if ($mform->is_cancelled()) {
redirect('view.php?id='.$this->cm->id);
Expand All @@ -463,7 +463,7 @@ function upload_notes() {
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;
Expand Down
8 changes: 4 additions & 4 deletions mod/data/comment.php
Expand Up @@ -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;
Expand All @@ -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));
}


Expand All @@ -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
}

Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion mod/data/lib.php
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions mod/forum/post.php
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions mod/glossary/comment.php
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions mod/glossary/edit.php
Expand Up @@ -47,7 +47,7 @@
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) ) {
Expand Down Expand Up @@ -176,7 +176,7 @@
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);
}
}

Expand Down
4 changes: 2 additions & 2 deletions question/question2.php
Expand Up @@ -76,11 +76,11 @@
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
Expand Down
4 changes: 2 additions & 2 deletions user/edit.php
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions user/profile/index.php
Expand Up @@ -115,7 +115,7 @@
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;
Expand Down Expand Up @@ -158,7 +158,7 @@
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);
Expand Down
2 changes: 1 addition & 1 deletion user/profile/index_field_form.php
Expand Up @@ -30,7 +30,7 @@ function definition () {
$formfield->edit_field($mform);

/// override the defaults with the user settings
$this->set_defaults($field);
$this->set_data($field);

$this->add_action_buttons(true);

Expand Down

0 comments on commit beac471

Please sign in to comment.