From ac31413e9588f07e0cf1106f841b990b034c47c6 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Tue, 23 Apr 2013 15:23:00 +0800 Subject: [PATCH] MDL-38851 Admin: Fixed setType notice for webservice --- admin/webservice/forms.php | 12 +- admin/webservice/testclient.php | 6 +- admin/webservice/testclient_forms.php | 189 ++++++++++++++++++-------- 3 files changed, 150 insertions(+), 57 deletions(-) diff --git a/admin/webservice/forms.php b/admin/webservice/forms.php index 745e9e186b4..6a1cc49f5b0 100644 --- a/admin/webservice/forms.php +++ b/admin/webservice/forms.php @@ -40,10 +40,12 @@ class external_service_authorised_user_settings_form extends moodleform { $mform->addElement('text', 'iprestriction', get_string('iprestriction', 'webservice')); $mform->addHelpButton('iprestriction', 'iprestriction', 'webservice'); + $mform->setType('iprestriction', PARAM_RAW_TRIMMED); $mform->addElement('date_selector', 'validuntil', get_string('validuntil', 'webservice'), array('optional' => true)); $mform->addHelpButton('validuntil', 'validuntil', 'webservice'); + $mform->setType('validuntil', PARAM_INT); $this->add_action_buttons(true, get_string('updateusersettings', 'webservice')); @@ -65,14 +67,17 @@ class external_service_form extends moodleform { $mform->addRule('name', get_string('required'), 'required', null, 'client'); $mform->setType('name', PARAM_TEXT); $mform->addElement('advcheckbox', 'enabled', get_string('enabled', 'webservice')); + $mform->setType('enabled', PARAM_BOOL); $mform->addElement('advcheckbox', 'restrictedusers', get_string('restrictedusers', 'webservice')); $mform->addHelpButton('restrictedusers', 'restrictedusers', 'webservice'); + $mform->setType('restrictedusers', PARAM_BOOL); //can users download files $mform->addElement('advcheckbox', 'downloadfiles', get_string('downloadfiles', 'webservice')); $mform->setAdvanced('downloadfiles'); $mform->addHelpButton('downloadfiles', 'downloadfiles', 'webservice'); + $mform->setType('downloadfiles', PARAM_BOOL); /// needed to select automatically the 'No required capability" option $currentcapabilityexist = false; @@ -100,6 +105,7 @@ class external_service_form extends moodleform { get_string('requiredcapability', 'webservice'), $capabilitychoices); $mform->addHelpButton('requiredcapability', 'requiredcapability', 'webservice'); $mform->setAdvanced('requiredcapability'); + $mform->setType('requiredcapability', PARAM_RAW); /// display notification error if the current requiredcapability doesn't exist anymore if (empty($currentcapabilityexist)) { global $OUTPUT; @@ -209,9 +215,11 @@ class web_service_token_form extends moodleform { $options[$userid] = fullname($user); } $mform->addElement('searchableselector', 'user', get_string('user'), $options); + $mform->setType('user', PARAM_INT); } else { //simple text box for username or user id (if two username exists, a form error is displayed) $mform->addElement('text', 'user', get_string('usernameorid', 'webservice')); + $mform->setType('user', PARAM_RAW_TRIMMED); } $mform->addRule('user', get_string('required'), 'required', null, 'client'); } @@ -231,12 +239,14 @@ class web_service_token_form extends moodleform { } $mform->addElement('select', 'service', get_string('service', 'webservice'), $options); $mform->addRule('service', get_string('required'), 'required', null, 'client'); - + $mform->setType('service', PARAM_INT); $mform->addElement('text', 'iprestriction', get_string('iprestriction', 'webservice')); + $mform->setType('iprestriction', PARAM_RAW_TRIMMED); $mform->addElement('date_selector', 'validuntil', get_string('validuntil', 'webservice'), array('optional' => true)); + $mform->setType('validuntil', PARAM_INT); $mform->addElement('hidden', 'action'); $mform->setType('action', PARAM_ALPHANUMEXT); diff --git a/admin/webservice/testclient.php b/admin/webservice/testclient.php index 228c7b7bf21..dd9dc4806da 100644 --- a/admin/webservice/testclient.php +++ b/admin/webservice/testclient.php @@ -29,9 +29,9 @@ require_once($CFG->libdir.'/adminlib.php'); require_once("$CFG->libdir/externallib.php"); require_once($CFG->dirroot . "/" . $CFG->admin . "/webservice/testclient_forms.php"); -$function = optional_param('function', '', PARAM_SAFEDIR); -$protocol = optional_param('protocol', '', PARAM_SAFEDIR); -$authmethod = optional_param('authmethod', '', PARAM_SAFEDIR); +$function = optional_param('function', '', PARAM_PLUGIN); +$protocol = optional_param('protocol', '', PARAM_ALPHA); +$authmethod = optional_param('authmethod', '', PARAM_ALPHA); $PAGE->set_url('/' . $CFG->admin . '/webservice/testclient.php'); $PAGE->navbar->ignore_active(true); diff --git a/admin/webservice/testclient_forms.php b/admin/webservice/testclient_forms.php index 04cc360d7d5..ab88e23440f 100644 --- a/admin/webservice/testclient_forms.php +++ b/admin/webservice/testclient_forms.php @@ -14,10 +14,13 @@ class webservice_test_client_form extends moodleform { $authmethod = array('simple' => 'simple', 'token' => 'token'); $mform->addElement('select', 'authmethod', get_string('authmethod', 'webservice'), $authmethod); + $mform->setType('simple', PARAM_ALPHA); $mform->addElement('select', 'protocol', get_string('protocol', 'webservice'), $protocols); + $mform->setType('protocol', PARAM_ALPHA); $mform->addElement('select', 'function', get_string('function', 'webservice'), $functions); + $mform->setType('function', PARAM_PLUGIN); $this->add_action_buttons(false, get_string('select')); } @@ -38,9 +41,12 @@ class moodle_user_create_users_form extends moodleform { $data = $this->_customdata; if ($data['authmethod'] == 'simple') { $mform->addElement('text', 'wsusername', 'wsusername'); + $mform->setType('wsusername', PARAM_USERNAME); $mform->addElement('text', 'wspassword', 'wspassword'); - } else if ($data['authmethod'] == 'token') { + $mform->setType('wspassword', PARAM_RAW); + } else if ($data['authmethod'] == 'token') { $mform->addElement('text', 'token', 'token'); + $mform->setType('token', PARAM_RAW_TRIMMED); } $mform->addElement('hidden', 'authmethod', $data['authmethod']); @@ -48,19 +54,26 @@ class moodle_user_create_users_form extends moodleform { /// specific to the create users function $mform->addElement('text', 'username', 'username'); + $mform->setType('username', PARAM_USERNAME); $mform->addElement('text', 'password', 'password'); + $mform->setType('password', PARAM_RAW); $mform->addElement('text', 'firstname', 'firstname'); + $mform->setType('firstname', PARAM_RAW); $mform->addElement('text', 'lastname', 'lastname'); + $mform->setType('lastname', PARAM_RAW); $mform->addElement('text', 'email', 'email'); + $mform->setType('email', PARAM_EMAIL); $mform->addElement('text', 'customfieldtype', 'customfieldtype'); + $mform->setType('customfieldtype', PARAM_RAW); $mform->addElement('text', 'customfieldvalue', 'customfieldvalue'); + $mform->setType('customfieldvalue', PARAM_RAW); $mform->addElement('hidden', 'function'); - $mform->setType('function', PARAM_SAFEDIR); + $mform->setType('function', PARAM_PLUGIN); $mform->addElement('hidden', 'protocol'); - $mform->setType('protocol', PARAM_SAFEDIR); + $mform->setType('protocol', PARAM_ALPHA); @@ -112,32 +125,43 @@ class moodle_user_update_users_form extends moodleform { $data = $this->_customdata; if ($data['authmethod'] == 'simple') { $mform->addElement('text', 'wsusername', 'wsusername'); + $mform->setType('wsusername', PARAM_USERNAME); $mform->addElement('text', 'wspassword', 'wspassword'); - } else if ($data['authmethod'] == 'token') { + $mform->setType('wspassword', PARAM_RAW); + } else if ($data['authmethod'] == 'token') { $mform->addElement('text', 'token', 'token'); + $mform->setType('token', PARAM_RAW_TRIMMED); } $mform->addElement('hidden', 'authmethod', $data['authmethod']); - $mform->setType('authmethod', PARAM_SAFEDIR); + $mform->setType('authmethod', PARAM_ALPHA); /// specific to the create users function $mform->addElement('text', 'id', 'id'); $mform->addRule('id', get_string('required'), 'required', null, 'client'); + $mform->setType('id', PARAM_INT); $mform->addElement('text', 'username', 'username'); + $mform->setType('username', PARAM_USERNAME); $mform->addElement('text', 'password', 'password'); + $mform->setType('password', PARAM_RAW); $mform->addElement('text', 'firstname', 'firstname'); + $mform->setType('firstname', PARAM_RAW); $mform->addElement('text', 'lastname', 'lastname'); + $mform->setType('lastname', PARAM_RAW); $mform->addElement('text', 'email', 'email'); + $mform->setType('email', PARAM_EMAIL); $mform->addElement('text', 'customfieldtype', 'customfieldtype'); + $mform->setType('customfieldtype', PARAM_RAW); $mform->addElement('text', 'customfieldvalue', 'customfieldvalue'); + $mform->setType('customfieldvalue', PARAM_RAW); $mform->addElement('hidden', 'function'); - $mform->setType('function', PARAM_SAFEDIR); + $mform->setType('function', PARAM_PLUGIN); $mform->addElement('hidden', 'protocol'); - $mform->setType('protocol', PARAM_SAFEDIR); + $mform->setType('protocol', PARAM_ALPHA); @@ -195,28 +219,30 @@ class moodle_user_delete_users_form extends moodleform { $data = $this->_customdata; if ($data['authmethod'] == 'simple') { $mform->addElement('text', 'wsusername', 'wsusername'); + $mform->setType('wsusername', PARAM_USERNAME); $mform->addElement('text', 'wspassword', 'wspassword'); - } else if ($data['authmethod'] == 'token') { + $mform->setType('wspassword', PARAM_RAW); + } else if ($data['authmethod'] == 'token') { $mform->addElement('text', 'token', 'token'); + $mform->setType('token', PARAM_RAW_TRIMMED); } $mform->addElement('hidden', 'authmethod', $data['authmethod']); - $mform->setType('authmethod', PARAM_SAFEDIR); + $mform->setType('authmethod', PARAM_ALPHA); /// beginning of specific code to the create users function $mform->addElement('text', 'userids[0]', 'userids[0]'); $mform->addElement('text', 'userids[1]', 'userids[1]'); $mform->addElement('text', 'userids[2]', 'userids[2]'); $mform->addElement('text', 'userids[3]', 'userids[3]'); + $mform->setType('userids', PARAM_INT); /// end of specific code to the create users function $mform->addElement('hidden', 'function'); - $mform->setType('function', PARAM_SAFEDIR); + $mform->setType('function', PARAM_PLUGIN); $mform->addElement('hidden', 'protocol'); - $mform->setType('protocol', PARAM_SAFEDIR); - - + $mform->setType('protocol', PARAM_ALPHA); $mform->addElement('static', 'warning', '', get_string('executewarnign', 'webservice')); @@ -265,26 +291,30 @@ class moodle_user_get_users_by_id_form extends moodleform { $data = $this->_customdata; if ($data['authmethod'] == 'simple') { $mform->addElement('text', 'wsusername', 'wsusername'); + $mform->setType('wsusername', PARAM_USERNAME); $mform->addElement('text', 'wspassword', 'wspassword'); - } else if ($data['authmethod'] == 'token') { + $mform->setType('wspassword', PARAM_RAW); + } else if ($data['authmethod'] == 'token') { $mform->addElement('text', 'token', 'token'); + $mform->setType('token', PARAM_RAW_TRIMMED); } $mform->addElement('hidden', 'authmethod', $data['authmethod']); - $mform->setType('authmethod', PARAM_SAFEDIR); + $mform->setType('authmethod', PARAM_ALPHA); /// beginning of specific code to the create users function $mform->addElement('text', 'userids[0]', 'userids[0]'); $mform->addElement('text', 'userids[1]', 'userids[1]'); $mform->addElement('text', 'userids[2]', 'userids[2]'); $mform->addElement('text', 'userids[3]', 'userids[3]'); + $mform->setType('userids', PARAM_INT); /// end of specific code to the create users function $mform->addElement('hidden', 'function'); - $mform->setType('function', PARAM_SAFEDIR); + $mform->setType('function', PARAM_PLUGIN); $mform->addElement('hidden', 'protocol'); - $mform->setType('protocol', PARAM_SAFEDIR); + $mform->setType('protocol', PARAM_ALPHA); @@ -334,24 +364,31 @@ class moodle_group_create_groups_form extends moodleform { $data = $this->_customdata; if ($data['authmethod'] == 'simple') { $mform->addElement('text', 'wsusername', 'wsusername'); + $mform->setType('wsusername', PARAM_USERNAME); $mform->addElement('text', 'wspassword', 'wspassword'); - } else if ($data['authmethod'] == 'token') { + $mform->setType('wspassword', PARAM_RAW); + } else if ($data['authmethod'] == 'token') { $mform->addElement('text', 'token', 'token'); + $mform->setType('token', PARAM_RAW_TRIMMED); } $mform->addElement('hidden', 'authmethod', $data['authmethod']); - $mform->setType('authmethod', PARAM_SAFEDIR); + $mform->setType('authmethod', PARAM_ALPHA); $mform->addElement('text', 'courseid', 'courseid'); + $mform->setType('courseid', PARAM_INT); $mform->addElement('text', 'name', 'name'); + $mform->setType('name', PARAM_TEXT); $mform->addElement('text', 'description', 'description'); + $mform->setType('description', PARAM_TEXT); $mform->addElement('text', 'enrolmentkey', 'enrolmentkey'); + $mform->setType('enrolmentkey', PARAM_RAW); $mform->addElement('hidden', 'function'); - $mform->setType('function', PARAM_SAFEDIR); + $mform->setType('function', PARAM_PLUGIN); $mform->addElement('hidden', 'protocol'); - $mform->setType('protocol', PARAM_SAFEDIR); + $mform->setType('protocol', PARAM_ALPHA); @@ -393,23 +430,27 @@ class moodle_group_get_groups_form extends moodleform { $data = $this->_customdata; if ($data['authmethod'] == 'simple') { $mform->addElement('text', 'wsusername', 'wsusername'); + $mform->setType('wsusername', PARAM_USERNAME); $mform->addElement('text', 'wspassword', 'wspassword'); - } else if ($data['authmethod'] == 'token') { + $mform->setType('wspassword', PARAM_RAW); + } else if ($data['authmethod'] == 'token') { $mform->addElement('text', 'token', 'token'); + $mform->setType('token', PARAM_RAW_TRIMMED); } $mform->addElement('hidden', 'authmethod', $data['authmethod']); - $mform->setType('authmethod', PARAM_SAFEDIR); + $mform->setType('authmethod', PARAM_ALPHA); $mform->addElement('text', 'groupids[0]', 'groupids[0]'); $mform->addElement('text', 'groupids[1]', 'groupids[1]'); $mform->addElement('text', 'groupids[2]', 'groupids[2]'); $mform->addElement('text', 'groupids[3]', 'groupids[3]'); + $mform->setType('groupids', PARAM_INT); $mform->addElement('hidden', 'function'); - $mform->setType('function', PARAM_SAFEDIR); + $mform->setType('function', PARAM_PLUGIN); $mform->addElement('hidden', 'protocol'); - $mform->setType('protocol', PARAM_SAFEDIR); + $mform->setType('protocol', PARAM_ALPHA); $this->add_action_buttons(true, get_string('execute', 'webservice')); } @@ -452,20 +493,23 @@ class moodle_group_get_course_groups_form extends moodleform { $data = $this->_customdata; if ($data['authmethod'] == 'simple') { $mform->addElement('text', 'wsusername', 'wsusername'); + $mform->setType('wsusername', PARAM_USERNAME); $mform->addElement('text', 'wspassword', 'wspassword'); - } else if ($data['authmethod'] == 'token') { + $mform->setType('wspassword', PARAM_RAW); + } else if ($data['authmethod'] == 'token') { $mform->addElement('text', 'token', 'token'); + $mform->setType('token', PARAM_RAW_TRIMMED); } $mform->addElement('hidden', 'authmethod', $data['authmethod']); - $mform->setType('authmethod', PARAM_SAFEDIR); + $mform->setType('authmethod', PARAM_ALPHA); $mform->addElement('text', 'courseid', 'courseid'); $mform->addElement('hidden', 'function'); - $mform->setType('function', PARAM_SAFEDIR); + $mform->setType('function', PARAM_PLUGIN); $mform->addElement('hidden', 'protocol'); - $mform->setType('protocol', PARAM_SAFEDIR); + $mform->setType('protocol', PARAM_ALPHA); $this->add_action_buttons(true, get_string('execute', 'webservice')); } @@ -502,23 +546,27 @@ class moodle_group_delete_groups_form extends moodleform { $data = $this->_customdata; if ($data['authmethod'] == 'simple') { $mform->addElement('text', 'wsusername', 'wsusername'); + $mform->setType('wsusername', PARAM_USERNAME); $mform->addElement('text', 'wspassword', 'wspassword'); - } else if ($data['authmethod'] == 'token') { + $mform->setType('wspassword', PARAM_RAW); + } else if ($data['authmethod'] == 'token') { $mform->addElement('text', 'token', 'token'); + $mform->setType('token', PARAM_RAW_TRIMMED); } $mform->addElement('hidden', 'authmethod', $data['authmethod']); - $mform->setType('authmethod', PARAM_SAFEDIR); + $mform->setType('authmethod', PARAM_ALPHA); $mform->addElement('text', 'groupids[0]', 'groupids[0]'); $mform->addElement('text', 'groupids[1]', 'groupids[1]'); $mform->addElement('text', 'groupids[2]', 'groupids[2]'); $mform->addElement('text', 'groupids[3]', 'groupids[3]'); + $mform->setType('groupids', PARAM_INT); $mform->addElement('hidden', 'function'); - $mform->setType('function', PARAM_SAFEDIR); + $mform->setType('function', PARAM_PLUGIN); $mform->addElement('hidden', 'protocol'); - $mform->setType('protocol', PARAM_SAFEDIR); + $mform->setType('protocol', PARAM_ALPHA); $mform->addElement('static', 'warning', '', get_string('executewarnign', 'webservice')); @@ -563,23 +611,27 @@ class moodle_group_get_groupmembers_form extends moodleform { $data = $this->_customdata; if ($data['authmethod'] == 'simple') { $mform->addElement('text', 'wsusername', 'wsusername'); + $mform->setType('wsusername', PARAM_USERNAME); $mform->addElement('text', 'wspassword', 'wspassword'); - } else if ($data['authmethod'] == 'token') { + $mform->setType('wspassword', PARAM_RAW); + } else if ($data['authmethod'] == 'token') { $mform->addElement('text', 'token', 'token'); + $mform->setType('token', PARAM_RAW_TRIMMED); } $mform->addElement('hidden', 'authmethod', $data['authmethod']); - $mform->setType('authmethod', PARAM_SAFEDIR); + $mform->setType('authmethod', PARAM_ALPHA); $mform->addElement('text', 'groupids[0]', 'groupids[0]'); $mform->addElement('text', 'groupids[1]', 'groupids[1]'); $mform->addElement('text', 'groupids[2]', 'groupids[2]'); $mform->addElement('text', 'groupids[3]', 'groupids[3]'); + $mform->setType('groupids', PARAM_INT); $mform->addElement('hidden', 'function'); - $mform->setType('function', PARAM_SAFEDIR); + $mform->setType('function', PARAM_PLUGIN); $mform->addElement('hidden', 'protocol'); - $mform->setType('protocol', PARAM_SAFEDIR); + $mform->setType('protocol', PARAM_ALPHA); $this->add_action_buttons(true, get_string('execute', 'webservice')); } @@ -622,9 +674,12 @@ class moodle_group_add_groupmembers_form extends moodleform { $data = $this->_customdata; if ($data['authmethod'] == 'simple') { $mform->addElement('text', 'wsusername', 'wsusername'); + $mform->setType('wsusername', PARAM_USERNAME); $mform->addElement('text', 'wspassword', 'wspassword'); - } else if ($data['authmethod'] == 'token') { + $mform->setType('wspassword', PARAM_RAW); + } else if ($data['authmethod'] == 'token') { $mform->addElement('text', 'token', 'token'); + $mform->setType('token', PARAM_RAW_TRIMMED); } $mform->addElement('hidden', 'authmethod', $data['authmethod']); @@ -633,12 +688,14 @@ class moodle_group_add_groupmembers_form extends moodleform { $mform->addElement('text', 'groupid[0]', 'groupid[0]'); $mform->addElement('text', 'userid[1]', 'userid[1]'); $mform->addElement('text', 'groupid[1]', 'groupid[1]'); + $mform->setType('userid', PARAM_INT); + $mform->setType('groupids', PARAM_INT); $mform->addElement('hidden', 'function'); - $mform->setType('function', PARAM_SAFEDIR); + $mform->setType('function', PARAM_PLUGIN); $mform->addElement('hidden', 'protocol'); - $mform->setType('protocol', PARAM_SAFEDIR); + $mform->setType('protocol', PARAM_ALPHA); $this->add_action_buttons(true, get_string('execute', 'webservice')); } @@ -681,23 +738,28 @@ class moodle_group_delete_groupmembers_form extends moodleform { $data = $this->_customdata; if ($data['authmethod'] == 'simple') { $mform->addElement('text', 'wsusername', 'wsusername'); + $mform->setType('wsusername', PARAM_USERNAME); $mform->addElement('text', 'wspassword', 'wspassword'); - } else if ($data['authmethod'] == 'token') { + $mform->setType('wspassword', PARAM_RAW); + } else if ($data['authmethod'] == 'token') { $mform->addElement('text', 'token', 'token'); + $mform->setType('token', PARAM_RAW_TRIMMED); } $mform->addElement('hidden', 'authmethod', $data['authmethod']); - $mform->setType('authmethod', PARAM_SAFEDIR); + $mform->setType('authmethod', PARAM_ALPHA); $mform->addElement('text', 'userid[0]', 'userid[0]'); $mform->addElement('text', 'groupid[0]', 'groupid[0]'); $mform->addElement('text', 'userid[1]', 'userid[1]'); $mform->addElement('text', 'groupid[1]', 'groupid[1]'); + $mform->setType('userid', PARAM_INT); + $mform->setType('groupids', PARAM_INT); $mform->addElement('hidden', 'function'); - $mform->setType('function', PARAM_SAFEDIR); + $mform->setType('function', PARAM_PLUGIN); $mform->addElement('hidden', 'protocol'); - $mform->setType('protocol', PARAM_SAFEDIR); + $mform->setType('protocol', PARAM_ALPHA); $this->add_action_buttons(true, get_string('execute', 'webservice')); } @@ -750,13 +812,16 @@ class core_course_create_categories_form extends moodleform { $data = $this->_customdata; if ($data['authmethod'] == 'simple') { $mform->addElement('text', 'wsusername', 'wsusername'); + $mform->setType('wsusername', PARAM_USERNAME); $mform->addElement('text', 'wspassword', 'wspassword'); + $mform->setType('wspassword', PARAM_RAW); } else if ($data['authmethod'] == 'token') { $mform->addElement('text', 'token', 'token'); + $mform->setType('token', PARAM_RAW_TRIMMED); } $mform->addElement('hidden', 'authmethod', $data['authmethod']); - $mform->setType('authmethod', PARAM_SAFEDIR); + $mform->setType('authmethod', PARAM_ALPHA); $mform->addElement('text', 'name[0]', 'name[0]'); $mform->addElement('text', 'parent[0]', 'parent[0]'); $mform->addElement('text', 'idnumber[0]', 'idnumber[0]'); @@ -765,12 +830,16 @@ class core_course_create_categories_form extends moodleform { $mform->addElement('text', 'parent[1]', 'parent[1]'); $mform->addElement('text', 'idnumber[1]', 'idnumber[1]'); $mform->addElement('text', 'description[1]', 'description[1]'); + $mform->setType('name', PARAM_TEXT); + $mform->setType('parent', PARAM_INT); + $mform->setType('idnumber', PARAM_RAW); + $mform->setType('description', PARAM_TEXT); $mform->addElement('hidden', 'function'); - $mform->setType('function', PARAM_SAFEDIR); + $mform->setType('function', PARAM_PLUGIN); $mform->addElement('hidden', 'protocol'); - $mform->setType('protocol', PARAM_SAFEDIR); + $mform->setType('protocol', PARAM_ALPHA); $this->add_action_buttons(true, get_string('execute', 'webservice')); } @@ -827,25 +896,31 @@ class core_course_delete_categories_form extends moodleform { $data = $this->_customdata; if ($data['authmethod'] == 'simple') { $mform->addElement('text', 'wsusername', 'wsusername'); + $mform->setType('wsusername', PARAM_USERNAME); $mform->addElement('text', 'wspassword', 'wspassword'); + $mform->setType('wspassword', PARAM_RAW); } else if ($data['authmethod'] == 'token') { $mform->addElement('text', 'token', 'token'); + $mform->setType('token', PARAM_RAW_TRIMMED); } $mform->addElement('hidden', 'authmethod', $data['authmethod']); - $mform->setType('authmethod', PARAM_SAFEDIR); + $mform->setType('authmethod', PARAM_ALPHA); $mform->addElement('text', 'id[0]', 'id[0]'); $mform->addElement('text', 'newparent[0]', 'newparent[0]'); $mform->addElement('text', 'recursive[0]', 'recursive[0]'); $mform->addElement('text', 'id[1]', 'id[1]'); $mform->addElement('text', 'newparent[1]', 'newparent[1]'); $mform->addElement('text', 'recursive[1]', 'recursive[1]'); + $mform->setType('id', PARAM_INT); + $mform->setType('newparent', PARAM_INT); + $mform->setType('recursive', PARAM_BOOL); $mform->addElement('hidden', 'function'); - $mform->setType('function', PARAM_SAFEDIR); + $mform->setType('function', PARAM_PLUGIN); $mform->addElement('hidden', 'protocol'); - $mform->setType('protocol', PARAM_SAFEDIR); + $mform->setType('protocol', PARAM_ALPHA); $this->add_action_buttons(true, get_string('execute', 'webservice')); } @@ -909,13 +984,16 @@ class core_course_update_categories_form extends moodleform { $data = $this->_customdata; if ($data['authmethod'] == 'simple') { $mform->addElement('text', 'wsusername', 'wsusername'); + $mform->setType('wsusername', PARAM_USERNAME); $mform->addElement('text', 'wspassword', 'wspassword'); + $mform->setType('wspassword', PARAM_RAW); } else if ($data['authmethod'] == 'token') { $mform->addElement('text', 'token', 'token'); + $mform->setType('token', PARAM_RAW_TRIMMED); } $mform->addElement('hidden', 'authmethod', $data['authmethod']); - $mform->setType('authmethod', PARAM_SAFEDIR); + $mform->setType('authmethod', PARAM_ALPHA); $mform->addElement('text', 'id[0]', 'id[0]'); $mform->addElement('text', 'name[0]', 'name[0]'); $mform->addElement('text', 'parent[0]', 'parent[0]'); @@ -926,12 +1004,17 @@ class core_course_update_categories_form extends moodleform { $mform->addElement('text', 'parent[1]', 'parent[1]'); $mform->addElement('text', 'idnumber[1]', 'idnumber[1]'); $mform->addElement('text', 'description[1]', 'description[1]'); + $mform->setType('id', PARAM_INT); + $mform->setType('name', PARAM_TEXT); + $mform->setType('parent', PARAM_INT); + $mform->setType('idnumber', PARAM_RAW); + $mform->setType('description', PARAM_TEXT); $mform->addElement('hidden', 'function'); - $mform->setType('function', PARAM_SAFEDIR); + $mform->setType('function', PARAM_PLUGIN); $mform->addElement('hidden', 'protocol'); - $mform->setType('protocol', PARAM_SAFEDIR); + $mform->setType('protocol', PARAM_ALPHA); $this->add_action_buttons(true, get_string('execute', 'webservice')); }