From d18e0fe64653329c711d248b83083085acc114de Mon Sep 17 00:00:00 2001 From: skodak Date: Sat, 26 Sep 2009 17:07:08 +0000 Subject: [PATCH] MDL-20353 adding missing data types of hidden form fields --- admin/generator.php | 1 + course/delete_category_form.php | 3 +++ course/edit_form.php | 3 +++ course/moodleform_mod.php | 1 + course/recent_form.php | 2 ++ course/request_form.php | 1 + course/reset_form.php | 1 + enrol/authorize/enrol_form.php | 5 +++++ grade/edit/outcome/import_outcomes_form.php | 2 ++ grade/edit/tree/grade_form.php | 2 ++ grade/export/grade_export_form.php | 1 + grade/import/xml/grade_import_form.php | 1 + lib/formslib.php | 5 +++++ lib/portfolio/forms.php | 8 ++++++++ mod/assignment/mod_form.php | 2 ++ mod/feedback/choose_group_form.php | 2 ++ mod/feedback/delete_completed_form.php | 4 ++++ mod/feedback/delete_item_form.php | 3 +++ mod/feedback/delete_template_form.php | 3 +++ mod/feedback/edit_form.php | 6 ++++++ mod/feedback/edit_item.php | 6 ++++++ mod/feedback/item/info/info_form.php | 1 + mod/feedback/item/label/label_form.php | 1 + mod/feedback/mod_form.php | 1 + mod/feedback/use_templ_form.php | 4 ++++ mod/forum/post_form.php | 2 ++ mod/glossary/edit_form.php | 5 +++++ mod/glossary/mod_form.php | 1 + mod/hotpot/mod_form.php | 3 +++ mod/page/mod_form.php | 1 + mod/quiz/mod_form.php | 1 + mod/resource/mod_form.php | 4 +++- mod/scorm/mod_form.php | 5 +++++ mod/url/mod_form.php | 1 + question/move_form.php | 1 + question/type/calculated/datasetitems_form.php | 7 +++++++ .../type/calculated/edit_calculated_form.php | 16 +++++++++++++--- .../edit_calculatedsimple_form.php | 2 ++ question/type/calculatedsimple/questiontype.php | 1 + .../type/description/edit_description_form.php | 1 + question/type/essay/edit_essay_form.php | 2 ++ .../randomsamatch/edit_randomsamatch_form.php | 1 + repository/lib.php | 8 ++++++++ tag/edit_form.php | 1 + user/edit_form.php | 2 ++ user/editadvanced_form.php | 2 ++ user/filters/user_filter_forms.php | 2 ++ user/profile/index_category_form.php | 2 ++ user/profile/index_field_form.php | 3 +++ webservice/lib.php | 3 +++ 50 files changed, 142 insertions(+), 4 deletions(-) diff --git a/admin/generator.php b/admin/generator.php index b48b76015b7bd..333848b6999f6 100755 --- a/admin/generator.php +++ b/admin/generator.php @@ -1283,6 +1283,7 @@ function definition() { $mform =& $this->_form; $mform->addElement('hidden', 'do_generation', 1); + $mform->setType('do_generation', PARAM_INT); foreach ($generator->settings as $setting) { $type = 'advcheckbox'; diff --git a/course/delete_category_form.php b/course/delete_category_form.php index 372773beeba17..9c3fb34a8af8d 100644 --- a/course/delete_category_form.php +++ b/course/delete_category_form.php @@ -110,11 +110,14 @@ function definition() { } } else { $mform->addElement('hidden', 'fulldelete', 1); + $mform->setType('fulldelete', PARAM_INT); $mform->addElement('static', 'emptymessage', '', get_string('deletecategoryempty')); } $mform->addElement('hidden', 'delete'); + $mform->setType('delete', PARAM_ALPHANUM); $mform->addElement('hidden', 'sure'); + $mform->setType('sure', PARAM_ALPHANUM); $mform->setDefault('sure', md5(serialize($category))); //-------------------------------------------------------------------------------- diff --git a/course/edit_form.php b/course/edit_form.php index abcd88c6bb71f..d5ff0e6823203 100644 --- a/course/edit_form.php +++ b/course/edit_form.php @@ -65,6 +65,7 @@ function definition() { $mform->addElement('select', 'category', get_string('category'), $displaylist); } else { $mform->addElement('hidden', 'category', null); + $mform->setType('category', PARAM_INT); } $mform->setHelpButton('category', array('coursecategory', get_string('category'))); $mform->setDefault('category', $category->id); @@ -369,6 +370,7 @@ function definition() { $mform->setDefault('enablecompletion', $courseconfig->enablecompletion); } else { $mform->addElement('hidden', 'enablecompletion'); + $mform->setType('enablecompletion', PARAM_INT); $mform->setDefault('enablecompletion',0); } @@ -389,6 +391,7 @@ function definition() { $mform->disabledIf('allowedmods', 'restrictmodules', 'eq', 0); } else { $mform->addElement('hidden', 'restrictmodules', null); + $mform->setType('restrictmodules', PARAM_INT); } if ($CFG->restrictmodulesfor == 'all') { $mform->setDefault('allowedmods', explode(',',$CFG->defaultallowedmodules)); diff --git a/course/moodleform_mod.php b/course/moodleform_mod.php index fc476a8f3df8e..a2dae5d15610b 100644 --- a/course/moodleform_mod.php +++ b/course/moodleform_mod.php @@ -475,6 +475,7 @@ function standard_coursemodule_elements(){ $mform->addElement('submit', 'unlockcompletion', get_string('unlockcompletion', 'completion')); $mform->registerNoSubmitButton('unlockcompletion'); $mform->addElement('hidden', 'completionunlocked', 0); + $mform->setType('completionunlocked', PARAM_INT); $mform->addElement('select', 'completion', get_string('completion', 'completion'), array(COMPLETION_TRACKING_NONE=>get_string('completion_none', 'completion'), diff --git a/course/recent_form.php b/course/recent_form.php index c3cf6f42911c4..12723ebca7d1d 100644 --- a/course/recent_form.php +++ b/course/recent_form.php @@ -122,6 +122,7 @@ function definition() { } } else { $mform->addElement('hidden','group'); + $mform->setType('group', PARAM_INT); $mform->setConstants(array('group'=>0)); } @@ -134,6 +135,7 @@ function definition() { $mform->addElement('date_time_selector', 'date', get_string('since'), array('optional'=>true)); $mform->addElement('hidden','id'); + $mform->setType('id', PARAM_INT); $mform->setType('courseid', PARAM_INT); $this->add_action_buttons(false, get_string('showrecent')); diff --git a/course/request_form.php b/course/request_form.php index d0de92b6c055d..d084fffd02c4e 100644 --- a/course/request_form.php +++ b/course/request_form.php @@ -130,6 +130,7 @@ function definition() { $mform =& $this->_form; $mform->addElement('hidden', 'reject', 0); + $mform->setType('reject', PARAM_INT); $mform->addElement('header','coursedetails', get_string('coursereasonforrejecting')); diff --git a/course/reset_form.php b/course/reset_form.php index 8acebf9f93dd0..10da1c9890f51 100644 --- a/course/reset_form.php +++ b/course/reset_form.php @@ -80,6 +80,7 @@ function definition (){ } $mform->addElement('hidden', 'id', $COURSE->id); + $mform->setType('id', PARAM_INT); $buttonarray = array(); $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('resetcourse')); diff --git a/enrol/authorize/enrol_form.php b/enrol/authorize/enrol_form.php index 9aca6ba574aeb..e60d5bc4249c1 100755 --- a/enrol/authorize/enrol_form.php +++ b/enrol/authorize/enrol_form.php @@ -131,9 +131,14 @@ function definition() } else { $mform->addElement('hidden', 'ccstate', ''); + $mform->setType('ccstate', PARAM_ALPHANUM); $mform->addElement('hidden', 'ccaddress', $USER->address); + $mform->setType('ccaddress', PARAM_ALPHANUM); $mform->addElement('hidden', 'cccity', $USER->city); + $mform->setType('cccity', PARAM_ALPHANUM); $mform->addElement('hidden', 'cccountry', $USER->country); + $mform->setType('ccountry', PARAM_ALPHA); + $mform->setDefault('cccountry', $USER->country); } } elseif (AN_METHOD_ECHECK == $paymentmethod) diff --git a/grade/edit/outcome/import_outcomes_form.php b/grade/edit/outcome/import_outcomes_form.php index d22c5266a547a..92a3766855897 100644 --- a/grade/edit/outcome/import_outcomes_form.php +++ b/grade/edit/outcome/import_outcomes_form.php @@ -26,7 +26,9 @@ public function definition() { //$this->set_upload_manager(new upload_manager('importfile', false, false, null, false, 0, true, true, false)); $mform->addElement('hidden', 'action', 'upload'); + $mform->setType('action', PARAM_ACTION); $mform->addElement('hidden', 'id', $COURSE->id); + $mform->setType('id', PARAM_INT); $scope = array(); if (($COURSE->id > 1) && has_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM))) { diff --git a/grade/edit/tree/grade_form.php b/grade/edit/tree/grade_form.php index ef8c1c690dd32..59c803b51470a 100755 --- a/grade/edit/tree/grade_form.php +++ b/grade/edit/tree/grade_form.php @@ -106,7 +106,9 @@ function definition() { // hidden params $mform->addElement('hidden', 'oldgrade'); + $mform->setType('oldgrade', PARAM_RAW); $mform->addElement('hidden', 'oldfeedback'); + $mform->setType('oldfeedback', PARAM_RAW); $mform->addElement('hidden', 'id', 0); $mform->setType('id', PARAM_INT); diff --git a/grade/export/grade_export_form.php b/grade/export/grade_export_form.php index f12fca056ca4f..7ea178d777b46 100755 --- a/grade/export/grade_export_form.php +++ b/grade/export/grade_export_form.php @@ -128,6 +128,7 @@ function definition() { } $mform->addElement('hidden', 'id', $COURSE->id); + $mform->setType('id', PARAM_INT); $this->add_action_buttons(false, get_string('submit')); } diff --git a/grade/import/xml/grade_import_form.php b/grade/import/xml/grade_import_form.php index 26a44a7062d3d..52b2e3dd8ff47 100644 --- a/grade/import/xml/grade_import_form.php +++ b/grade/import/xml/grade_import_form.php @@ -28,6 +28,7 @@ function definition () { // course id needs to be passed for auth purposes $mform->addElement('hidden', 'id', optional_param('id', 0, PARAM_INT)); $mform->setType('id', PARAM_INT); + $mform->addElement('header', 'general', get_string('importfile', 'grades')); $mform->disabledIf('url', 'userfile', 'noteq', ''); diff --git a/lib/formslib.php b/lib/formslib.php index 907cb7c1ed303..42aa86ca58874 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -149,8 +149,10 @@ function moodleform($action=null, $customdata=null, $method='post', $target='', $this->definition(); $this->_form->addElement('hidden', 'sesskey', null); // automatic sesskey protection + $this->_form->setType('sesskey', PARAM_RAW); $this->_form->setDefault('sesskey', sesskey()); $this->_form->addElement('hidden', '_qf__'.$this->_formname, null); // form submission marker + $this->_form->setType('_qf__'.$this->_formname, PARAM_RAW); $this->_form->setDefault('_qf__'.$this->_formname, 1); $this->_form->_setDefaultRuleMessages(); @@ -814,6 +816,7 @@ function repeat_elements($elementobjs, $repeats, $options, $repeathiddenname, $mform =& $this->_form; $mform->registerNoSubmitButton($addfieldsname); $mform->addElement('hidden', $repeathiddenname, $repeats); + $mform->setType($repeathiddenname, PARAM_INT); //value not to be overridden by submitted value $mform->setConstants(array($repeathiddenname=>$repeats)); $namecloned = array(); @@ -912,6 +915,7 @@ function add_checkbox_controller($groupid, $buttontext, $attributes, $originalVa } $mform->addElement('hidden', "checkbox_controller$groupid"); + $mform->setType("checkbox_controller$groupid", PARAM_INT); $mform->setConstants(array("checkbox_controller$groupid" => $new_select_value)); // Locate all checkboxes for this group and set their value, IF the optional param was given @@ -1113,6 +1117,7 @@ function setAdvanced($elementName, $advanced=true){ $this->registerNoSubmitButton('mform_showadvanced'); $this->addElement('hidden', 'mform_showadvanced_last'); + $this->setType('mform_showadvanced_last', PARAM_INT); } } /** diff --git a/lib/portfolio/forms.php b/lib/portfolio/forms.php index ab963297a7775..0892d2cab6a76 100644 --- a/lib/portfolio/forms.php +++ b/lib/portfolio/forms.php @@ -45,7 +45,9 @@ public function definition() { $mform =& $this->_form; $mform->addElement('hidden', 'stage', PORTFOLIO_STAGE_CONFIG); + $mform->setType('stage', PARAM_INT); $mform->addElement('hidden', 'instance', $this->_customdata['instance']->get('id')); + $mform->setType('instance', PARAM_INT); if (array_key_exists('formats', $this->_customdata) && is_array($this->_customdata['formats'])) { if (count($this->_customdata['formats']) > 1) { @@ -57,6 +59,7 @@ public function definition() { } else { $f = array_shift($this->_customdata['formats']); $mform->addElement('hidden', 'format', $f); + $mform->setType('format', PARAM_RAW); } } @@ -75,6 +78,7 @@ public function definition() { } else { $mform->addElement('hidden', 'wait', 0); } + $mform->setType('wait', PARAM_INT); } if (array_key_exists('plugin', $this->_customdata) && is_object($this->_customdata['plugin'])) { @@ -131,8 +135,11 @@ public function definition() { $strrequired = get_string('required'); $mform->addElement('hidden', 'edit', ($this->instance) ? $this->instance->get('id') : 0); + $mform->setType('edit', PARAM_INT); $mform->addElement('hidden', 'new', $this->plugin); + $mform->setType('new', PARAM_INT); $mform->addElement('hidden', 'plugin', $this->plugin); + $mform->setType('plugin', PARAM_SAFEDIR); if (!$this->instance) { $insane = portfolio_instance_sanity_check($this->instance); @@ -213,6 +220,7 @@ public function definition() { $this->userid = $this->_customdata['userid']; $this->_form->addElement('hidden', 'config', $this->instance->get('id')); + $mform->setType('config', PARAM_INT); $this->instance->user_config_form($this->_form, $this->userid); diff --git a/mod/assignment/mod_form.php b/mod/assignment/mod_form.php index 8ed8b2db43c9f..6aca75cdba5e6 100644 --- a/mod/assignment/mod_form.php +++ b/mod/assignment/mod_form.php @@ -18,8 +18,10 @@ function definition() { $type = required_param('type', PARAM_ALPHA); } $mform->addElement('hidden', 'assignmenttype', $type); + $mform->setType('assignmenttype', PARAM_ALPHA); $mform->setDefault('assignmenttype', $type); $mform->addElement('hidden', 'type', $type); + $mform->setType('type', PARAM_ALPHA); $mform->setDefault('type', $type); require($CFG->dirroot.'/mod/assignment/type/'.$type.'/assignment.class.php'); diff --git a/mod/feedback/choose_group_form.php b/mod/feedback/choose_group_form.php index c4a64823569ee..1d2c082ba686e 100644 --- a/mod/feedback/choose_group_form.php +++ b/mod/feedback/choose_group_form.php @@ -41,7 +41,9 @@ function set_form_elements(){ // $mform->addElement('header', 'general', get_string('choose_group', 'feedback')); // hidden elements $mform->addElement('hidden', 'id'); + $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'do_show'); + $mform->setType('do-show', PARAM_INT); // visible elements $groups_options = array(); diff --git a/mod/feedback/delete_completed_form.php b/mod/feedback/delete_completed_form.php index c79397e425331..38bf5277fd469 100644 --- a/mod/feedback/delete_completed_form.php +++ b/mod/feedback/delete_completed_form.php @@ -19,9 +19,13 @@ function definition() { // hidden elements $mform->addElement('hidden', 'id'); + $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'completedid'); + $mform->setType('completeid', PARAM_INT); $mform->addElement('hidden', 'do_show'); + $mform->setType('do_show', PARAM_INT); $mform->addElement('hidden', 'confirmdelete'); + $mform->setType('confirmdelete', PARAM_INT); //------------------------------------------------------------------------------- // buttons diff --git a/mod/feedback/delete_item_form.php b/mod/feedback/delete_item_form.php index b4eaab5f092e0..7d48508fb751f 100644 --- a/mod/feedback/delete_item_form.php +++ b/mod/feedback/delete_item_form.php @@ -19,8 +19,11 @@ function definition() { // hidden elements $mform->addElement('hidden', 'id'); + $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'deleteitem'); + $mform->setType('deleteitem', PARAM_INT); $mform->addElement('hidden', 'confirmdelete'); + $mform->setType('confirmdelete', PARAM_INT); //------------------------------------------------------------------------------- // buttons diff --git a/mod/feedback/delete_template_form.php b/mod/feedback/delete_template_form.php index f37fe84e56f0e..75e85a181eaea 100644 --- a/mod/feedback/delete_template_form.php +++ b/mod/feedback/delete_template_form.php @@ -19,8 +19,11 @@ function definition() { // hidden elements $mform->addElement('hidden', 'id'); + $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'deletetempl'); + $mform->setType('deletetempl', PARAM_INT); $mform->addElement('hidden', 'confirmdelete'); + $mform->setType('confirmdelete', PARAM_INT); //------------------------------------------------------------------------------- // buttons diff --git a/mod/feedback/edit_form.php b/mod/feedback/edit_form.php index 1521534bb71fe..8f740d5d8206b 100644 --- a/mod/feedback/edit_form.php +++ b/mod/feedback/edit_form.php @@ -30,7 +30,9 @@ function definition() { // hidden elements $mform->addElement('hidden', 'id'); + $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'position'); + $mform->setType('position', PARAM_INT); //------------------------------------------------------------------------------- // buttons $mform->addElement('submit', 'add_item', get_string('add_item', 'feedback')); @@ -68,6 +70,7 @@ function set_form_elements(){ $mform->addElement('header', '', get_string('using_templates', 'feedback')); // hidden elements $mform->addElement('hidden', 'id'); + $mform->setType('id', PARAM_INT); // visible elements $templates_options = array(); @@ -113,8 +116,11 @@ function set_form_elements(){ // hidden elements $mform->addElement('hidden', 'id'); + $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'do_show'); + $mform->setType('do_show', PARAM_INT); $mform->addElement('hidden', 'savetemplate', 1); + $mform->setType('savetemplate', PARAM_INT); //headline $mform->addElement('header', '', get_string('creating_templates', 'feedback')); diff --git a/mod/feedback/edit_item.php b/mod/feedback/edit_item.php index 243ea48b24b77..a4e8a43bb1599 100644 --- a/mod/feedback/edit_item.php +++ b/mod/feedback/edit_item.php @@ -157,9 +157,13 @@ $i_form = &$item_form->get_item_form(); // $i_form->addElement('header', 'general', 'Titel'); $i_form->addElement('hidden', 'id', $id); +$mform->setType('id', PARAM_INT); $i_form->addElement('hidden', 'itemid', isset($item->id)?$item->id:''); +$mform->setType('itemid', PARAM_INT); $i_form->addElement('hidden', 'typ', $typ); +$mform->setType('typ', PARAM_ALPHA); $i_form->addElement('hidden', 'feedbackid', $feedback->id); +$mform->setType('feedbackid', PARAM_INT); $lastposition = $DB->count_records('feedback_item', array('feedback'=>$feedback->id)); @@ -179,10 +183,12 @@ $buttonarray = array(); if(!empty($item->id)){ $i_form->addElement('hidden', 'updateitem', '1'); + $mform->setType('updateitem', PARAM_INT); // $i_form->addElement('submit', 'update_item', get_string('update_item', 'feedback')); $buttonarray[] = &$i_form->createElement('submit', 'update_item', get_string('update_item', 'feedback')); }else{ $i_form->addElement('hidden', 'saveitem', '1'); + $mform->setType('saveitem', PARAM_INT); // $i_form->addElement('submit', 'save_item', get_string('save_item', 'feedback')); $buttonarray[] = &$i_form->createElement('submit', 'save_item', get_string('save_item', 'feedback')); } diff --git a/mod/feedback/item/info/info_form.php b/mod/feedback/item/info/info_form.php index d792d4fdda17f..a7ead8cf2f1dd 100644 --- a/mod/feedback/item/info/info_form.php +++ b/mod/feedback/item/info/info_form.php @@ -14,6 +14,7 @@ function definition() { $mform->addElement('header', 'general', get_string($this->type, 'feedback')); $this->requiredcheck = &$mform->addElement('hidden', 'required'); + $mform->setType('required', PARAM_INT); $this->itemname = &$mform->addElement('text', 'itemname', get_string('item_name', 'feedback'), array('size="'.FEEDBACK_ITEM_NAME_TEXTBOX_SIZE.'"','maxlength="255"')); $this->itemlabel = $mform->addElement('text', 'itemlabel', get_string('item_label', 'feedback'), array('size="'.FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE.'"','maxlength="255"')); diff --git a/mod/feedback/item/label/label_form.php b/mod/feedback/item/label/label_form.php index b79d5d78406a8..0719c98aa78ec 100644 --- a/mod/feedback/item/label/label_form.php +++ b/mod/feedback/item/label/label_form.php @@ -12,6 +12,7 @@ function definition() { $mform->addElement('header', 'general', get_string($this->type, 'feedback')); $mform->addElement('hidden', 'itemname', $this->type); + $mform->setType('itemname', PARAM_INT); $this->area = $mform->addElement('htmleditor', 'presentation', '', array('rows'=>20)); } } diff --git a/mod/feedback/mod_form.php b/mod/feedback/mod_form.php index d40e082cac135..1eedc587e3d94 100644 --- a/mod/feedback/mod_form.php +++ b/mod/feedback/mod_form.php @@ -66,6 +66,7 @@ function definition() { $multiple_submit_value = $feedback->multiple_submit ? get_string('yes') : get_string('no'); $mform->addElement('text', 'multiple_submit_static', get_string('multiple_submit', 'feedback'), array('size'=>'4','disabled'=>'disabled', 'value'=>$multiple_submit_value)); $mform->addElement('hidden', 'multiple_submit', ''); + $mform->setType('', PARAM_INT); $mform->setHelpButton('multiple_submit_static', array('multiplesubmit', get_string('multiple_submit', 'feedback'), 'feedback')); }else { $mform->addElement('selectyesno', 'multiple_submit', get_string('multiple_submit', 'feedback')); diff --git a/mod/feedback/use_templ_form.php b/mod/feedback/use_templ_form.php index 81a83a449c2b5..dca0b9ca87661 100644 --- a/mod/feedback/use_templ_form.php +++ b/mod/feedback/use_templ_form.php @@ -24,9 +24,13 @@ function definition() { // hidden elements $mform->addElement('hidden', 'id'); + $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'templateid'); + $mform->setType('templateid', PARAM_INT); $mform->addElement('hidden', 'do_show'); + $mform->setType('do_show', PARAM_INT); $mform->addElement('hidden', 'confirmadd'); + $mform->setType('confirmadd', PARAM_INT); //------------------------------------------------------------------------------- // buttons diff --git a/mod/forum/post_form.php b/mod/forum/post_form.php index 227b820501554..e77b14333a841 100644 --- a/mod/forum/post_form.php +++ b/mod/forum/post_form.php @@ -34,6 +34,7 @@ function definition() { $mform->addElement('static', 'subscribemessage', get_string('subscription', 'forum'), get_string('everyoneissubscribed', 'forum')); $mform->addElement('hidden', 'subscribe'); + $mform->setType('subscribe', PARAM_INT); $mform->setHelpButton('subscribemessage', array('subscription', get_string('subscription', 'forum'), 'forum')); } else if (isset($forum->forcesubscribe)&& $forum->forcesubscribe != FORUM_DISALLOWSUBSCRIBE || @@ -48,6 +49,7 @@ function definition() { } else if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE) { $mform->addElement('static', 'subscribemessage', get_string('subscription', 'forum'), get_string('disallowsubscribe', 'forum')); $mform->addElement('hidden', 'subscribe'); + $mform->setType('subscribe', PARAM_INT); $mform->setHelpButton('subscribemessage', array('subscription', get_string('subscription', 'forum'), 'forum')); } diff --git a/mod/glossary/edit_form.php b/mod/glossary/edit_form.php index d0767f7d28ae4..f301c8cc2280d 100644 --- a/mod/glossary/edit_form.php +++ b/mod/glossary/edit_form.php @@ -41,8 +41,11 @@ function definition() { if (!$glossary->usedynalink) { $mform->addElement('hidden', 'usedynalink', $CFG->glossary_linkentries); + $mform->setType('usedynalink', PARAM_INT); $mform->addElement('hidden', 'casesensitive', $CFG->glossary_casesensitive); + $mform->setType('casesensitive', PARAM_INT); $mform->addElement('hidden', 'fullmatch', $CFG->glossary_fullmatch); + $mform->setType('fullmatch', PARAM_INT); } else { //------------------------------------------------------------------------------- @@ -64,7 +67,9 @@ function definition() { } $mform->addElement('hidden', 'id'); + $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'cmid'); + $mform->setType('cmid', PARAM_INT); //------------------------------------------------------------------------------- $this->add_action_buttons(); diff --git a/mod/glossary/mod_form.php b/mod/glossary/mod_form.php index da243a6eb1741..ee265f2542577 100644 --- a/mod/glossary/mod_form.php +++ b/mod/glossary/mod_form.php @@ -32,6 +32,7 @@ function definition() { }else{ $mform->addElement('hidden', 'globalglossary'); + $mform->setType('globalglossary', PARAM_INT); } $options = array(1=>get_string('mainglossary', 'glossary'), 0=>get_string('secondaryglossary', 'glossary')); diff --git a/mod/hotpot/mod_form.php b/mod/hotpot/mod_form.php index de15a8061ca20..ce62d010c7bf7 100644 --- a/mod/hotpot/mod_form.php +++ b/mod/hotpot/mod_form.php @@ -55,6 +55,7 @@ function definition() { } else { // existing HotPot $mform->addElement('hidden', 'namesource', HOTPOT_TEXTSOURCE_SPECIFIC); + $mform->setType('namesource', PARAM_RAW); $mform->addElement('text', 'name', get_string('name'), array('size' => '40')); } $mform->setType('namesource', PARAM_INT); @@ -81,6 +82,7 @@ function definition() { } if (array_key_exists($location, $HOTPOT_LOCATION)) { $mform->addElement('hidden', 'location', $location); + $mform->setType('location', PARAM_RAW); } else { // admin can select from "site" or "course" files $mform->addElement('select', 'location', get_string('location', 'hotpot'), $HOTPOT_LOCATION); } @@ -120,6 +122,7 @@ function definition() { } else { // existing HotPot $mform->addElement('hidden', 'summarysource', HOTPOT_TEXTSOURCE_SPECIFIC); + $mform->setType('summarysource', PARAM_RAW); $mform->addElement('htmleditor', 'summary', get_string('summary')); $mform->setType('summary', PARAM_RAW); $mform->setHelpButton('summary', array('writing', 'questions', 'richtext2'), false, 'editorhelpbutton'); diff --git a/mod/page/mod_form.php b/mod/page/mod_form.php index b7dd2b359ac2b..1e816e77b1126 100644 --- a/mod/page/mod_form.php +++ b/mod/page/mod_form.php @@ -60,6 +60,7 @@ function definition() { } if (count($options) == 1) { $mform->addElement('hidden', 'display'); + $mform->setType('display', PARAM_INT); reset($options); $mform->setDefault('display', key($options)); } else { diff --git a/mod/quiz/mod_form.php b/mod/quiz/mod_form.php index 99206340f4794..8468b05aa54a8 100644 --- a/mod/quiz/mod_form.php +++ b/mod/quiz/mod_form.php @@ -271,6 +271,7 @@ function definition() { $mform->setHelpButton('overallfeedbackhdr', array('overallfeedback', get_string('overallfeedback', 'quiz'), 'quiz')); $mform->addElement('hidden', 'grade', $quizconfig->maximumgrade); + $mform->setType('grade', PARAM_RAW); if (empty($this->_cm)) { $needwarning = $quizconfig->maximumgrade == 0; } else { diff --git a/mod/resource/mod_form.php b/mod/resource/mod_form.php index 4976370d34ee4..0589df50b5c17 100644 --- a/mod/resource/mod_form.php +++ b/mod/resource/mod_form.php @@ -60,7 +60,8 @@ function definition() { $options = array('mainfile'=>$mainfile, 'subdirs'=>0, 'maxbytes'=>0, 'maxfiles'=>-1, 'filetypes'=>'*', 'returnvalue'=>'ref_id'); - $mform->addElement('hidden', $mainfile, '', array('id'=>$mainfile.'-id')); + $mform->addElement('hidden', $mainfile, '', array('id'=>$mainfile.'-id')); // TODO: what is this? + $mform->setType('mainfile', PARAM_PATH); $mform->addElement('filemanager', 'files', get_string('selectfiles'), null, $options); $mform->addElement('static', '', get_string('selectedfile'), '
'); @@ -75,6 +76,7 @@ function definition() { if (count($options) == 1) { $mform->addElement('hidden', 'display'); + $mform->setType('display', PARAM_INT); reset($options); $mform->setDefault('display', key($options)); } else { diff --git a/mod/scorm/mod_form.php b/mod/scorm/mod_form.php index 243c532eb7756..108a78c2484a8 100644 --- a/mod/scorm/mod_form.php +++ b/mod/scorm/mod_form.php @@ -221,10 +221,15 @@ function definition() { //------------------------------------------------------------------------------- // Hidden Settings $mform->addElement('hidden', 'datadir', null); + $mform->setType('datadir', PARAM_RAW); $mform->addElement('hidden', 'pkgtype', null); + $mform->setType('pkgtype', PARAM_RAW); $mform->addElement('hidden', 'launch', null); + $mform->setType('launch', PARAM_RAW); $mform->addElement('hidden', 'redirect', null); + $mform->setType('redirect', PARAM_RAW); $mform->addElement('hidden', 'redirecturl', null); + $mform->setType('redirecturl', PARAM_RAW); //------------------------------------------------------------------------------- diff --git a/mod/url/mod_form.php b/mod/url/mod_form.php index b5fe33275dbaf..489a3852b6dff 100644 --- a/mod/url/mod_form.php +++ b/mod/url/mod_form.php @@ -59,6 +59,7 @@ function definition() { } if (count($options) == 1) { $mform->addElement('hidden', 'display'); + $mform->setType('display', PARAM_INT); reset($options); $mform->setDefault('display', key($options)); } else { diff --git a/question/move_form.php b/question/move_form.php index 72fdc3e916517..f779342234d6a 100644 --- a/question/move_form.php +++ b/question/move_form.php @@ -18,6 +18,7 @@ function definition() { $this->add_action_buttons(true, get_string('categorymoveto', 'quiz')); //-------------------------------------------------------------------------------- $mform->addElement('hidden', 'delete', $currentcat); + $mform->setType('delete', PARAM_INT); } } ?> diff --git a/question/type/calculated/datasetitems_form.php b/question/type/calculated/datasetitems_form.php index 47a0a6b80bba5..575650f77d643 100644 --- a/question/type/calculated/datasetitems_form.php +++ b/question/type/calculated/datasetitems_form.php @@ -86,8 +86,11 @@ function definition() { $this->qtypeobj->custom_generator_tools_part($mform, $idx, $j); $idx++; $mform->addElement('hidden', "definition[$j]"); + $mform->setType("definition[$j]", PARAM_RAW); $mform->addElement('hidden', "itemid[$j]"); + $mform->setType("itemid[$j]", PARAM_RAW); $mform->addElement('static', "divider[$j]", '', '
'); + $mform->setType("divider[$j]", PARAM_RAW); $j++; } $mform->addElement('header', 'updateanswershdr', get_string('answerstoleranceparam', 'qtype_datasetdependent')); @@ -102,12 +105,16 @@ function definition() { }else if ('*' === $answer->answer){ $mform->addElement('static', 'answercomment['.($this->noofitems+$key1).']', $answer->answer); $mform->addElement('hidden', 'tolerance['.$key.']', ''); + $mform->setType('tolerance['.$key.']', PARAM_RAW); $mform->setAdvanced('tolerance['.$key.']',true); $mform->addElement('hidden', 'tolerancetype['.$key.']', ''); + $mform->setType('tolerancetype['.$key.']', PARAM_RAW); $mform->setAdvanced('tolerancetype['.$key.']',true); $mform->addElement('hidden', 'correctanswerlength['.$key.']', ''); + $mform->setType('correctanswerlength['.$key.']', PARAM_RAW); $mform->setAdvanced('correctanswerlength['.$key.']',true); $mform->addElement('hidden', 'correctanswerformat['.$key.']', ''); + $mform->setType('correctanswerformat['.$key.']', PARAM_RAW); $mform->setAdvanced('correctanswerformat['.$key.']',true); }else { $mform->addElement('static', 'answercomment['.($this->noofitems+$key1).']', $answer->answer); diff --git a/question/type/calculated/edit_calculated_form.php b/question/type/calculated/edit_calculated_form.php index 09e6b0ec5c962..8286f4130d4dc 100644 --- a/question/type/calculated/edit_calculated_form.php +++ b/question/type/calculated/edit_calculated_form.php @@ -95,6 +95,7 @@ function definition_inner(&$mform) { // echo "

question ".optional_param('multichoice', '', PARAM_RAW)." optional

";print_r($this->question);echo "

"; $label = get_string("sharedwildcards", "qtype_datasetdependent"); $mform->addElement('hidden', 'initialcategory', 1); + $mform->setType('initialcategory', PARAM_INT); $html2 = $this->qtypeobj->print_dataset_definitions_category($this->question); $mform->insertElementBefore($mform->createElement('static','listcategory',$label,$html2),'name'); $addfieldsname='updatecategory'; @@ -139,6 +140,7 @@ function definition_inner(&$mform) { $mform->addGroup($addgrp1, 'addgrp1', '', ' ', false); }else { $mform->addElement('hidden', 'multichoice',$this->editasmultichoice); + $mform->setType('multichoice', PARAM_INT); } if ($this->editasmultichoice == 1){ @@ -161,8 +163,12 @@ function definition_inner(&$mform) { }else { //editing as regular $mform->addElement('header', 'choicehdr', get_string('regularcalculatedquestion', 'qtype_calculated')); $mform->addElement('hidden','single', '1'); + $mform->setType('single', PARAM_INT); + $mform->addElement('hidden','shuffleanswers', '1'); - $mform->addElement('hidden','answernumbering', 'abc'); + $mform->setType('shuffleanswers', PARAM_INT); + $mform->addElement('hidden','answernumbering', 'abc'); + $mform->setType('answernumbering', PARAM_SAFEDIR); } $creategrades = get_grade_options(); @@ -179,10 +185,13 @@ function definition_inner(&$mform) { if ($this->editasmultichoice == 1){ $nounits = optional_param('nounits', 1, PARAM_INT); $mform->addElement('hidden', 'nounits', $nounits); + $mform->setType('nounits', PARAM_INT); $mform->setConstants(array('nounits'=>$nounits)); for ($i=0; $i< $nounits; $i++) { - $mform->addElement('hidden','unit'."[$i]", optional_param('unit'."[$i]", '', PARAM_NOTAGS)); - $mform->addElement('hidden', 'multiplier'."[$i]", optional_param('multiplier'."[$i]", '', PARAM_NUMBER)); + $mform->addElement('hidden','unit'."[$i]", optional_param('unit'."[$i]", '', PARAM_NOTAGS)); + $mform->setType('unit'."[$i]", PARAM_NOTAGS); + $mform->addElement('hidden', 'multiplier'."[$i]", optional_param('multiplier'."[$i]", '', PARAM_NUMBER)); + $mform->setType('multiplier'."[$i]", PARAM_NUMBER); } }else { @@ -230,6 +239,7 @@ function definition_inner(&$mform) { } //hidden elements $mform->addElement('hidden', 'synchronize', ''); + $mform->setType('synchronize', PARAM_INT); if (isset($this->question->options)&& isset($this->question->options->synchronize) ){ $mform->setDefault("synchronize", $this->question->options->synchronize); } else { diff --git a/question/type/calculatedsimple/edit_calculatedsimple_form.php b/question/type/calculatedsimple/edit_calculatedsimple_form.php index 33e75d73550c4..2ce33499e798f 100644 --- a/question/type/calculatedsimple/edit_calculatedsimple_form.php +++ b/question/type/calculatedsimple/edit_calculatedsimple_form.php @@ -284,7 +284,9 @@ function definition_inner(&$mform) { $strquestionlabel = $this->qtypeobj->comment_header($this->nonemptyanswer); $label = get_string("sharedwildcards", "qtype_datasetdependent"); $mform->addElement('hidden', 'initialcategory', 1); + $mform->setType('initialcategory', PARAM_INT); $mform->addElement('hidden', 'reload', 1); + $mform->setType('reload', PARAM_INT); $addfieldsname='updatequestion value'; $addstring=get_string("updatecategory", "qtype_calculated"); $mform->registerNoSubmitButton($addfieldsname); diff --git a/question/type/calculatedsimple/questiontype.php b/question/type/calculatedsimple/questiontype.php index ae001db7d97c8..787dba5fdc12c 100644 --- a/question/type/calculatedsimple/questiontype.php +++ b/question/type/calculatedsimple/questiontype.php @@ -237,6 +237,7 @@ function custom_generator_tools_part(&$mform, $idx, $j){ $distriboptions = array('uniform' => get_string('uniform', 'qtype_datasetdependent'), 'loguniform' => get_string('loguniform', 'qtype_datasetdependent')); $mform->addElement('hidden', "calcdistribution[$idx]", 'uniform'); + $mform->setType("calcdistribution[$idx]", PARAM_INT); } diff --git a/question/type/description/edit_description_form.php b/question/type/description/edit_description_form.php index 6771eb5a9648b..184ff5cb287fe 100644 --- a/question/type/description/edit_description_form.php +++ b/question/type/description/edit_description_form.php @@ -24,6 +24,7 @@ function definition_inner(&$mform) { $mform->removeElement('penalty'); $mform->addElement('hidden', 'defaultgrade', 0); + $mform->setType('defaultgrade', PARAM_RAW); } function qtype() { diff --git a/question/type/essay/edit_essay_form.php b/question/type/essay/edit_essay_form.php index b207c2e100781..9efd100cc325d 100644 --- a/question/type/essay/edit_essay_form.php +++ b/question/type/essay/edit_essay_form.php @@ -24,10 +24,12 @@ function definition_inner(&$mform) { $mform->setType('feedback', PARAM_RAW); $mform->addElement('hidden', 'fraction', 0); + $mform->setType('fraction', PARAM_RAW); //don't need this default element. $mform->removeElement('penalty'); $mform->addElement('hidden', 'penalty', 0); + $mform->setType('penalty', PARAM_RAW); } function set_data($question) { diff --git a/question/type/randomsamatch/edit_randomsamatch_form.php b/question/type/randomsamatch/edit_randomsamatch_form.php index 7e6ee472208f0..f6adcd72ddbcb 100644 --- a/question/type/randomsamatch/edit_randomsamatch_form.php +++ b/question/type/randomsamatch/edit_randomsamatch_form.php @@ -30,6 +30,7 @@ function definition_inner(&$mform) { $mform->setType('feedback', PARAM_RAW); $mform->addElement('hidden', 'fraction', 0); + $mform->setType('fraction', PARAM_RAW); } function set_data($question) { diff --git a/repository/lib.php b/repository/lib.php index 083bb40f54778..89b823a568e66 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -1592,10 +1592,15 @@ public function definition() { $strrequired = get_string('required'); $mform->addElement('hidden', 'edit', ($this->instance) ? $this->instance->id : 0); + $mform->setType('edit', PARAM_INT); $mform->addElement('hidden', 'new', $this->plugin); + $mform->setType('new', PARAM_FORMAT); $mform->addElement('hidden', 'plugin', $this->plugin); + $mform->setType('plugin', PARAM_SAFEDIR); $mform->addElement('hidden', 'typeid', $this->typeid); + $mform->setType('typeid', PARAM_INT); $mform->addElement('hidden', 'contextid', $this->contextid); + $mform->setType('contextid', PARAM_INT); $mform->addElement('text', 'name', get_string('name'), 'maxlength="100" size="30"'); $mform->addRule('name', $strrequired, 'required', null, 'client'); @@ -1668,8 +1673,11 @@ public function definition() { $strrequired = get_string('required'); $mform->addElement('hidden', 'edit', ($this->instance) ? $this->instance->get_typename() : 0); + $mform->setType('edit', PARAM_INT); $mform->addElement('hidden', 'new', $this->plugin); + $mform->setType('new', PARAM_FORMAT); $mform->addElement('hidden', 'plugin', $this->plugin); + $mform->setType('plugin', PARAM_SAFEDIR); // let the plugin add its specific fields if (!$this->instance) { diff --git a/tag/edit_form.php b/tag/edit_form.php index fbfdf067b895c..5aaec36198e7d 100644 --- a/tag/edit_form.php +++ b/tag/edit_form.php @@ -11,6 +11,7 @@ function definition () { $mform->addElement('header', 'tag', get_string('description','tag')); $mform->addElement('hidden', 'id'); + $mform->setType('id', PARAM_INT); $systemcontext = get_context_instance(CONTEXT_SYSTEM); diff --git a/user/edit_form.php b/user/edit_form.php index 4326c3065b59b..5e9d9c370ddc4 100644 --- a/user/edit_form.php +++ b/user/edit_form.php @@ -15,7 +15,9 @@ function definition () { /// Add some extra hidden fields $mform->addElement('hidden', 'id'); + $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'course', $COURSE->id); + $mform->setType('course', PARAM_INT); /// Print the required moodle fields first $mform->addElement('header', 'moodle', $strgeneral); diff --git a/user/editadvanced_form.php b/user/editadvanced_form.php index 0a82c749485a0..69e39549ffb7a 100644 --- a/user/editadvanced_form.php +++ b/user/editadvanced_form.php @@ -15,7 +15,9 @@ function definition() { /// Add some extra hidden fields $mform->addElement('hidden', 'id'); + $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'course', $COURSE->id); + $mform->setType('course', PARAM_INT); /// Print the required moodle fields first $mform->addElement('header', 'moodle', $strgeneral); diff --git a/user/filters/user_filter_forms.php b/user/filters/user_filter_forms.php index d1bbccdc17fa2..9cd507970e81f 100644 --- a/user/filters/user_filter_forms.php +++ b/user/filters/user_filter_forms.php @@ -19,6 +19,7 @@ function definition() { if ($extraparams) { foreach ($extraparams as $key=>$value) { $mform->addElement('hidden', $key, $value); + $mform->setType($key, PARAM_RAW); } } @@ -57,6 +58,7 @@ function definition() { if ($extraparams) { foreach ($extraparams as $key=>$value) { $mform->addElement('hidden', $key, $value); + $mform->setType($key, PARAM_RAW); } } diff --git a/user/profile/index_category_form.php b/user/profile/index_category_form.php index 44af21cad6f7c..4424892b44b92 100644 --- a/user/profile/index_category_form.php +++ b/user/profile/index_category_form.php @@ -14,7 +14,9 @@ function definition () { /// Add some extra hidden fields $mform->addElement('hidden', 'id'); + $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'action', 'editcategory'); + $mform->setType('iction', PARAM_ACTION); $mform->addElement('text', 'name', get_string('profilecategoryname', 'admin'), 'maxlength="255" size="30"'); $mform->setType('name', PARAM_MULTILANG); diff --git a/user/profile/index_field_form.php b/user/profile/index_field_form.php index 781c7afaa452b..e61848a09e622 100644 --- a/user/profile/index_field_form.php +++ b/user/profile/index_field_form.php @@ -22,8 +22,11 @@ function definition () { /// Add some extra hidden fields $mform->addElement('hidden', 'id'); + $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'action', 'editfield'); + $mform->setType('action', PARAM_ACTION); $mform->addElement('hidden', 'datatype', $datatype); + $mform->setType('datatype', PARAM_ALPHA); $this->field->define_form($mform); diff --git a/webservice/lib.php b/webservice/lib.php index b5ed7301277cd..0c40069928c34 100644 --- a/webservice/lib.php +++ b/webservice/lib.php @@ -415,6 +415,7 @@ public function definition() { $mform =& $this->_form; $mform->addElement('hidden', 'username', $this->username); + $mform->setType('username', PARAM_RAW); $param = new stdClass(); $param->username = $this->username; $wsuser = $DB->get_record("user", array("username" => $this->username)); @@ -441,6 +442,7 @@ public function definition() { $mform =& $this->_form; $mform->addElement('hidden', 'settings', $settings); + $mform->setType('settings', PARAM_RAW); $param = new stdClass(); require_once($CFG->dirroot . '/webservice/'. $settings . '/lib.php'); @@ -476,6 +478,7 @@ public function definition() { $mform =& $this->_form; $mform->addElement('hidden', 'serviceid', $serviceid); + $mform->setType('serviceid', PARAM_INT); $param = new stdClass(); // require_once($CFG->dirroot . '/webservice/'. $settings . '/lib.php');