Skip to content

Commit

Permalink
MDL-20353 adding missing data types of hidden form fields
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Sep 26, 2009
1 parent 98d5bad commit d18e0fe
Show file tree
Hide file tree
Showing 50 changed files with 142 additions and 4 deletions.
1 change: 1 addition & 0 deletions admin/generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 3 additions & 0 deletions course/delete_category_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)));

//--------------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions course/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand All @@ -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));
Expand Down
1 change: 1 addition & 0 deletions course/moodleform_mod.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
2 changes: 2 additions & 0 deletions course/recent_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ function definition() {
}
} else {
$mform->addElement('hidden','group');
$mform->setType('group', PARAM_INT);
$mform->setConstants(array('group'=>0));
}

Expand All @@ -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'));
Expand Down
1 change: 1 addition & 0 deletions course/request_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down
1 change: 1 addition & 0 deletions course/reset_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
5 changes: 5 additions & 0 deletions enrol/authorize/enrol_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions grade/edit/outcome/import_outcomes_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down
2 changes: 2 additions & 0 deletions grade/edit/tree/grade_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions grade/export/grade_export_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

}
Expand Down
1 change: 1 addition & 0 deletions grade/import/xml/grade_import_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', '');

Expand Down
5 changes: 5 additions & 0 deletions lib/formslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
/**
Expand Down
8 changes: 8 additions & 0 deletions lib/portfolio/forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -57,6 +59,7 @@ public function definition() {
} else {
$f = array_shift($this->_customdata['formats']);
$mform->addElement('hidden', 'format', $f);
$mform->setType('format', PARAM_RAW);
}
}

Expand All @@ -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'])) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions mod/assignment/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 2 additions & 0 deletions mod/feedback/choose_group_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions mod/feedback/delete_completed_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions mod/feedback/delete_item_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions mod/feedback/delete_template_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions mod/feedback/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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'));
Expand Down
6 changes: 6 additions & 0 deletions mod/feedback/edit_item.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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'));
}
Expand Down
1 change: 1 addition & 0 deletions mod/feedback/item/info/info_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"'));
Expand Down
1 change: 1 addition & 0 deletions mod/feedback/item/label/label_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
1 change: 1 addition & 0 deletions mod/feedback/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
4 changes: 4 additions & 0 deletions mod/feedback/use_templ_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions mod/forum/post_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand All @@ -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'));
}

Expand Down
Loading

0 comments on commit d18e0fe

Please sign in to comment.