Merge branch 'wip-mdl-38851' of git://github.com/rajeshtaneja/moodle

This commit is contained in:
Damyon Wiese 2013-04-24 11:39:13 +08:00
commit c65bf47276
7 changed files with 159 additions and 60 deletions

View file

@ -40,10 +40,12 @@ class external_service_authorised_user_settings_form extends moodleform {
$mform->addElement('text', 'iprestriction', $mform->addElement('text', 'iprestriction',
get_string('iprestriction', 'webservice')); get_string('iprestriction', 'webservice'));
$mform->addHelpButton('iprestriction', 'iprestriction', 'webservice'); $mform->addHelpButton('iprestriction', 'iprestriction', 'webservice');
$mform->setType('iprestriction', PARAM_RAW_TRIMMED);
$mform->addElement('date_selector', 'validuntil', $mform->addElement('date_selector', 'validuntil',
get_string('validuntil', 'webservice'), array('optional' => true)); get_string('validuntil', 'webservice'), array('optional' => true));
$mform->addHelpButton('validuntil', 'validuntil', 'webservice'); $mform->addHelpButton('validuntil', 'validuntil', 'webservice');
$mform->setType('validuntil', PARAM_INT);
$this->add_action_buttons(true, get_string('updateusersettings', 'webservice')); $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->addRule('name', get_string('required'), 'required', null, 'client');
$mform->setType('name', PARAM_TEXT); $mform->setType('name', PARAM_TEXT);
$mform->addElement('advcheckbox', 'enabled', get_string('enabled', 'webservice')); $mform->addElement('advcheckbox', 'enabled', get_string('enabled', 'webservice'));
$mform->setType('enabled', PARAM_BOOL);
$mform->addElement('advcheckbox', 'restrictedusers', $mform->addElement('advcheckbox', 'restrictedusers',
get_string('restrictedusers', 'webservice')); get_string('restrictedusers', 'webservice'));
$mform->addHelpButton('restrictedusers', 'restrictedusers', 'webservice'); $mform->addHelpButton('restrictedusers', 'restrictedusers', 'webservice');
$mform->setType('restrictedusers', PARAM_BOOL);
//can users download files //can users download files
$mform->addElement('advcheckbox', 'downloadfiles', get_string('downloadfiles', 'webservice')); $mform->addElement('advcheckbox', 'downloadfiles', get_string('downloadfiles', 'webservice'));
$mform->setAdvanced('downloadfiles'); $mform->setAdvanced('downloadfiles');
$mform->addHelpButton('downloadfiles', 'downloadfiles', 'webservice'); $mform->addHelpButton('downloadfiles', 'downloadfiles', 'webservice');
$mform->setType('downloadfiles', PARAM_BOOL);
/// needed to select automatically the 'No required capability" option /// needed to select automatically the 'No required capability" option
$currentcapabilityexist = false; $currentcapabilityexist = false;
@ -100,6 +105,7 @@ class external_service_form extends moodleform {
get_string('requiredcapability', 'webservice'), $capabilitychoices); get_string('requiredcapability', 'webservice'), $capabilitychoices);
$mform->addHelpButton('requiredcapability', 'requiredcapability', 'webservice'); $mform->addHelpButton('requiredcapability', 'requiredcapability', 'webservice');
$mform->setAdvanced('requiredcapability'); $mform->setAdvanced('requiredcapability');
$mform->setType('requiredcapability', PARAM_RAW);
/// display notification error if the current requiredcapability doesn't exist anymore /// display notification error if the current requiredcapability doesn't exist anymore
if (empty($currentcapabilityexist)) { if (empty($currentcapabilityexist)) {
global $OUTPUT; global $OUTPUT;
@ -209,9 +215,11 @@ class web_service_token_form extends moodleform {
$options[$userid] = fullname($user); $options[$userid] = fullname($user);
} }
$mform->addElement('searchableselector', 'user', get_string('user'), $options); $mform->addElement('searchableselector', 'user', get_string('user'), $options);
$mform->setType('user', PARAM_INT);
} else { } else {
//simple text box for username or user id (if two username exists, a form error is displayed) //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->addElement('text', 'user', get_string('usernameorid', 'webservice'));
$mform->setType('user', PARAM_RAW_TRIMMED);
} }
$mform->addRule('user', get_string('required'), 'required', null, 'client'); $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->addElement('select', 'service', get_string('service', 'webservice'), $options);
$mform->addRule('service', get_string('required'), 'required', null, 'client'); $mform->addRule('service', get_string('required'), 'required', null, 'client');
$mform->setType('service', PARAM_INT);
$mform->addElement('text', 'iprestriction', get_string('iprestriction', 'webservice')); $mform->addElement('text', 'iprestriction', get_string('iprestriction', 'webservice'));
$mform->setType('iprestriction', PARAM_RAW_TRIMMED);
$mform->addElement('date_selector', 'validuntil', $mform->addElement('date_selector', 'validuntil',
get_string('validuntil', 'webservice'), array('optional' => true)); get_string('validuntil', 'webservice'), array('optional' => true));
$mform->setType('validuntil', PARAM_INT);
$mform->addElement('hidden', 'action'); $mform->addElement('hidden', 'action');
$mform->setType('action', PARAM_ALPHANUMEXT); $mform->setType('action', PARAM_ALPHANUMEXT);

View file

@ -29,9 +29,9 @@ require_once($CFG->libdir.'/adminlib.php');
require_once("$CFG->libdir/externallib.php"); require_once("$CFG->libdir/externallib.php");
require_once($CFG->dirroot . "/" . $CFG->admin . "/webservice/testclient_forms.php"); require_once($CFG->dirroot . "/" . $CFG->admin . "/webservice/testclient_forms.php");
$function = optional_param('function', '', PARAM_SAFEDIR); $function = optional_param('function', '', PARAM_PLUGIN);
$protocol = optional_param('protocol', '', PARAM_SAFEDIR); $protocol = optional_param('protocol', '', PARAM_ALPHA);
$authmethod = optional_param('authmethod', '', PARAM_SAFEDIR); $authmethod = optional_param('authmethod', '', PARAM_ALPHA);
$PAGE->set_url('/' . $CFG->admin . '/webservice/testclient.php'); $PAGE->set_url('/' . $CFG->admin . '/webservice/testclient.php');
$PAGE->navbar->ignore_active(true); $PAGE->navbar->ignore_active(true);

View file

@ -14,10 +14,13 @@ class webservice_test_client_form extends moodleform {
$authmethod = array('simple' => 'simple', 'token' => 'token'); $authmethod = array('simple' => 'simple', 'token' => 'token');
$mform->addElement('select', 'authmethod', get_string('authmethod', 'webservice'), $authmethod); $mform->addElement('select', 'authmethod', get_string('authmethod', 'webservice'), $authmethod);
$mform->setType('simple', PARAM_ALPHA);
$mform->addElement('select', 'protocol', get_string('protocol', 'webservice'), $protocols); $mform->addElement('select', 'protocol', get_string('protocol', 'webservice'), $protocols);
$mform->setType('protocol', PARAM_ALPHA);
$mform->addElement('select', 'function', get_string('function', 'webservice'), $functions); $mform->addElement('select', 'function', get_string('function', 'webservice'), $functions);
$mform->setType('function', PARAM_PLUGIN);
$this->add_action_buttons(false, get_string('select')); $this->add_action_buttons(false, get_string('select'));
} }
@ -38,9 +41,12 @@ class moodle_user_create_users_form extends moodleform {
$data = $this->_customdata; $data = $this->_customdata;
if ($data['authmethod'] == 'simple') { if ($data['authmethod'] == 'simple') {
$mform->addElement('text', 'wsusername', 'wsusername'); $mform->addElement('text', 'wsusername', 'wsusername');
$mform->setType('wsusername', PARAM_USERNAME);
$mform->addElement('text', 'wspassword', 'wspassword'); $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->addElement('text', 'token', 'token');
$mform->setType('token', PARAM_RAW_TRIMMED);
} }
$mform->addElement('hidden', 'authmethod', $data['authmethod']); $mform->addElement('hidden', 'authmethod', $data['authmethod']);
@ -48,19 +54,26 @@ class moodle_user_create_users_form extends moodleform {
/// specific to the create users function /// specific to the create users function
$mform->addElement('text', 'username', 'username'); $mform->addElement('text', 'username', 'username');
$mform->setType('username', PARAM_USERNAME);
$mform->addElement('text', 'password', 'password'); $mform->addElement('text', 'password', 'password');
$mform->setType('password', PARAM_RAW);
$mform->addElement('text', 'firstname', 'firstname'); $mform->addElement('text', 'firstname', 'firstname');
$mform->setType('firstname', PARAM_RAW);
$mform->addElement('text', 'lastname', 'lastname'); $mform->addElement('text', 'lastname', 'lastname');
$mform->setType('lastname', PARAM_RAW);
$mform->addElement('text', 'email', 'email'); $mform->addElement('text', 'email', 'email');
$mform->setType('email', PARAM_EMAIL);
$mform->addElement('text', 'customfieldtype', 'customfieldtype'); $mform->addElement('text', 'customfieldtype', 'customfieldtype');
$mform->setType('customfieldtype', PARAM_RAW);
$mform->addElement('text', 'customfieldvalue', 'customfieldvalue'); $mform->addElement('text', 'customfieldvalue', 'customfieldvalue');
$mform->setType('customfieldvalue', PARAM_RAW);
$mform->addElement('hidden', 'function'); $mform->addElement('hidden', 'function');
$mform->setType('function', PARAM_SAFEDIR); $mform->setType('function', PARAM_PLUGIN);
$mform->addElement('hidden', 'protocol'); $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; $data = $this->_customdata;
if ($data['authmethod'] == 'simple') { if ($data['authmethod'] == 'simple') {
$mform->addElement('text', 'wsusername', 'wsusername'); $mform->addElement('text', 'wsusername', 'wsusername');
$mform->setType('wsusername', PARAM_USERNAME);
$mform->addElement('text', 'wspassword', 'wspassword'); $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->addElement('text', 'token', 'token');
$mform->setType('token', PARAM_RAW_TRIMMED);
} }
$mform->addElement('hidden', 'authmethod', $data['authmethod']); $mform->addElement('hidden', 'authmethod', $data['authmethod']);
$mform->setType('authmethod', PARAM_SAFEDIR); $mform->setType('authmethod', PARAM_ALPHA);
/// specific to the create users function /// specific to the create users function
$mform->addElement('text', 'id', 'id'); $mform->addElement('text', 'id', 'id');
$mform->addRule('id', get_string('required'), 'required', null, 'client'); $mform->addRule('id', get_string('required'), 'required', null, 'client');
$mform->setType('id', PARAM_INT);
$mform->addElement('text', 'username', 'username'); $mform->addElement('text', 'username', 'username');
$mform->setType('username', PARAM_USERNAME);
$mform->addElement('text', 'password', 'password'); $mform->addElement('text', 'password', 'password');
$mform->setType('password', PARAM_RAW);
$mform->addElement('text', 'firstname', 'firstname'); $mform->addElement('text', 'firstname', 'firstname');
$mform->setType('firstname', PARAM_RAW);
$mform->addElement('text', 'lastname', 'lastname'); $mform->addElement('text', 'lastname', 'lastname');
$mform->setType('lastname', PARAM_RAW);
$mform->addElement('text', 'email', 'email'); $mform->addElement('text', 'email', 'email');
$mform->setType('email', PARAM_EMAIL);
$mform->addElement('text', 'customfieldtype', 'customfieldtype'); $mform->addElement('text', 'customfieldtype', 'customfieldtype');
$mform->setType('customfieldtype', PARAM_RAW);
$mform->addElement('text', 'customfieldvalue', 'customfieldvalue'); $mform->addElement('text', 'customfieldvalue', 'customfieldvalue');
$mform->setType('customfieldvalue', PARAM_RAW);
$mform->addElement('hidden', 'function'); $mform->addElement('hidden', 'function');
$mform->setType('function', PARAM_SAFEDIR); $mform->setType('function', PARAM_PLUGIN);
$mform->addElement('hidden', 'protocol'); $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; $data = $this->_customdata;
if ($data['authmethod'] == 'simple') { if ($data['authmethod'] == 'simple') {
$mform->addElement('text', 'wsusername', 'wsusername'); $mform->addElement('text', 'wsusername', 'wsusername');
$mform->setType('wsusername', PARAM_USERNAME);
$mform->addElement('text', 'wspassword', 'wspassword'); $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->addElement('text', 'token', 'token');
$mform->setType('token', PARAM_RAW_TRIMMED);
} }
$mform->addElement('hidden', 'authmethod', $data['authmethod']); $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 /// beginning of specific code to the create users function
$mform->addElement('text', 'userids[0]', 'userids[0]'); $mform->addElement('text', 'userids[0]', 'userids[0]');
$mform->addElement('text', 'userids[1]', 'userids[1]'); $mform->addElement('text', 'userids[1]', 'userids[1]');
$mform->addElement('text', 'userids[2]', 'userids[2]'); $mform->addElement('text', 'userids[2]', 'userids[2]');
$mform->addElement('text', 'userids[3]', 'userids[3]'); $mform->addElement('text', 'userids[3]', 'userids[3]');
$mform->setType('userids', PARAM_INT);
/// end of specific code to the create users function /// end of specific code to the create users function
$mform->addElement('hidden', 'function'); $mform->addElement('hidden', 'function');
$mform->setType('function', PARAM_SAFEDIR); $mform->setType('function', PARAM_PLUGIN);
$mform->addElement('hidden', 'protocol'); $mform->addElement('hidden', 'protocol');
$mform->setType('protocol', PARAM_SAFEDIR); $mform->setType('protocol', PARAM_ALPHA);
$mform->addElement('static', 'warning', '', get_string('executewarnign', 'webservice')); $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; $data = $this->_customdata;
if ($data['authmethod'] == 'simple') { if ($data['authmethod'] == 'simple') {
$mform->addElement('text', 'wsusername', 'wsusername'); $mform->addElement('text', 'wsusername', 'wsusername');
$mform->setType('wsusername', PARAM_USERNAME);
$mform->addElement('text', 'wspassword', 'wspassword'); $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->addElement('text', 'token', 'token');
$mform->setType('token', PARAM_RAW_TRIMMED);
} }
$mform->addElement('hidden', 'authmethod', $data['authmethod']); $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 /// beginning of specific code to the create users function
$mform->addElement('text', 'userids[0]', 'userids[0]'); $mform->addElement('text', 'userids[0]', 'userids[0]');
$mform->addElement('text', 'userids[1]', 'userids[1]'); $mform->addElement('text', 'userids[1]', 'userids[1]');
$mform->addElement('text', 'userids[2]', 'userids[2]'); $mform->addElement('text', 'userids[2]', 'userids[2]');
$mform->addElement('text', 'userids[3]', 'userids[3]'); $mform->addElement('text', 'userids[3]', 'userids[3]');
$mform->setType('userids', PARAM_INT);
/// end of specific code to the create users function /// end of specific code to the create users function
$mform->addElement('hidden', 'function'); $mform->addElement('hidden', 'function');
$mform->setType('function', PARAM_SAFEDIR); $mform->setType('function', PARAM_PLUGIN);
$mform->addElement('hidden', 'protocol'); $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; $data = $this->_customdata;
if ($data['authmethod'] == 'simple') { if ($data['authmethod'] == 'simple') {
$mform->addElement('text', 'wsusername', 'wsusername'); $mform->addElement('text', 'wsusername', 'wsusername');
$mform->setType('wsusername', PARAM_USERNAME);
$mform->addElement('text', 'wspassword', 'wspassword'); $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->addElement('text', 'token', 'token');
$mform->setType('token', PARAM_RAW_TRIMMED);
} }
$mform->addElement('hidden', 'authmethod', $data['authmethod']); $mform->addElement('hidden', 'authmethod', $data['authmethod']);
$mform->setType('authmethod', PARAM_SAFEDIR); $mform->setType('authmethod', PARAM_ALPHA);
$mform->addElement('text', 'courseid', 'courseid'); $mform->addElement('text', 'courseid', 'courseid');
$mform->setType('courseid', PARAM_INT);
$mform->addElement('text', 'name', 'name'); $mform->addElement('text', 'name', 'name');
$mform->setType('name', PARAM_TEXT);
$mform->addElement('text', 'description', 'description'); $mform->addElement('text', 'description', 'description');
$mform->setType('description', PARAM_TEXT);
$mform->addElement('text', 'enrolmentkey', 'enrolmentkey'); $mform->addElement('text', 'enrolmentkey', 'enrolmentkey');
$mform->setType('enrolmentkey', PARAM_RAW);
$mform->addElement('hidden', 'function'); $mform->addElement('hidden', 'function');
$mform->setType('function', PARAM_SAFEDIR); $mform->setType('function', PARAM_PLUGIN);
$mform->addElement('hidden', 'protocol'); $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; $data = $this->_customdata;
if ($data['authmethod'] == 'simple') { if ($data['authmethod'] == 'simple') {
$mform->addElement('text', 'wsusername', 'wsusername'); $mform->addElement('text', 'wsusername', 'wsusername');
$mform->setType('wsusername', PARAM_USERNAME);
$mform->addElement('text', 'wspassword', 'wspassword'); $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->addElement('text', 'token', 'token');
$mform->setType('token', PARAM_RAW_TRIMMED);
} }
$mform->addElement('hidden', 'authmethod', $data['authmethod']); $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[0]', 'groupids[0]');
$mform->addElement('text', 'groupids[1]', 'groupids[1]'); $mform->addElement('text', 'groupids[1]', 'groupids[1]');
$mform->addElement('text', 'groupids[2]', 'groupids[2]'); $mform->addElement('text', 'groupids[2]', 'groupids[2]');
$mform->addElement('text', 'groupids[3]', 'groupids[3]'); $mform->addElement('text', 'groupids[3]', 'groupids[3]');
$mform->setType('groupids', PARAM_INT);
$mform->addElement('hidden', 'function'); $mform->addElement('hidden', 'function');
$mform->setType('function', PARAM_SAFEDIR); $mform->setType('function', PARAM_PLUGIN);
$mform->addElement('hidden', 'protocol'); $mform->addElement('hidden', 'protocol');
$mform->setType('protocol', PARAM_SAFEDIR); $mform->setType('protocol', PARAM_ALPHA);
$this->add_action_buttons(true, get_string('execute', 'webservice')); $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; $data = $this->_customdata;
if ($data['authmethod'] == 'simple') { if ($data['authmethod'] == 'simple') {
$mform->addElement('text', 'wsusername', 'wsusername'); $mform->addElement('text', 'wsusername', 'wsusername');
$mform->setType('wsusername', PARAM_USERNAME);
$mform->addElement('text', 'wspassword', 'wspassword'); $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->addElement('text', 'token', 'token');
$mform->setType('token', PARAM_RAW_TRIMMED);
} }
$mform->addElement('hidden', 'authmethod', $data['authmethod']); $mform->addElement('hidden', 'authmethod', $data['authmethod']);
$mform->setType('authmethod', PARAM_SAFEDIR); $mform->setType('authmethod', PARAM_ALPHA);
$mform->addElement('text', 'courseid', 'courseid'); $mform->addElement('text', 'courseid', 'courseid');
$mform->addElement('hidden', 'function'); $mform->addElement('hidden', 'function');
$mform->setType('function', PARAM_SAFEDIR); $mform->setType('function', PARAM_PLUGIN);
$mform->addElement('hidden', 'protocol'); $mform->addElement('hidden', 'protocol');
$mform->setType('protocol', PARAM_SAFEDIR); $mform->setType('protocol', PARAM_ALPHA);
$this->add_action_buttons(true, get_string('execute', 'webservice')); $this->add_action_buttons(true, get_string('execute', 'webservice'));
} }
@ -502,23 +546,27 @@ class moodle_group_delete_groups_form extends moodleform {
$data = $this->_customdata; $data = $this->_customdata;
if ($data['authmethod'] == 'simple') { if ($data['authmethod'] == 'simple') {
$mform->addElement('text', 'wsusername', 'wsusername'); $mform->addElement('text', 'wsusername', 'wsusername');
$mform->setType('wsusername', PARAM_USERNAME);
$mform->addElement('text', 'wspassword', 'wspassword'); $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->addElement('text', 'token', 'token');
$mform->setType('token', PARAM_RAW_TRIMMED);
} }
$mform->addElement('hidden', 'authmethod', $data['authmethod']); $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[0]', 'groupids[0]');
$mform->addElement('text', 'groupids[1]', 'groupids[1]'); $mform->addElement('text', 'groupids[1]', 'groupids[1]');
$mform->addElement('text', 'groupids[2]', 'groupids[2]'); $mform->addElement('text', 'groupids[2]', 'groupids[2]');
$mform->addElement('text', 'groupids[3]', 'groupids[3]'); $mform->addElement('text', 'groupids[3]', 'groupids[3]');
$mform->setType('groupids', PARAM_INT);
$mform->addElement('hidden', 'function'); $mform->addElement('hidden', 'function');
$mform->setType('function', PARAM_SAFEDIR); $mform->setType('function', PARAM_PLUGIN);
$mform->addElement('hidden', 'protocol'); $mform->addElement('hidden', 'protocol');
$mform->setType('protocol', PARAM_SAFEDIR); $mform->setType('protocol', PARAM_ALPHA);
$mform->addElement('static', 'warning', '', get_string('executewarnign', 'webservice')); $mform->addElement('static', 'warning', '', get_string('executewarnign', 'webservice'));
@ -563,23 +611,27 @@ class moodle_group_get_groupmembers_form extends moodleform {
$data = $this->_customdata; $data = $this->_customdata;
if ($data['authmethod'] == 'simple') { if ($data['authmethod'] == 'simple') {
$mform->addElement('text', 'wsusername', 'wsusername'); $mform->addElement('text', 'wsusername', 'wsusername');
$mform->setType('wsusername', PARAM_USERNAME);
$mform->addElement('text', 'wspassword', 'wspassword'); $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->addElement('text', 'token', 'token');
$mform->setType('token', PARAM_RAW_TRIMMED);
} }
$mform->addElement('hidden', 'authmethod', $data['authmethod']); $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[0]', 'groupids[0]');
$mform->addElement('text', 'groupids[1]', 'groupids[1]'); $mform->addElement('text', 'groupids[1]', 'groupids[1]');
$mform->addElement('text', 'groupids[2]', 'groupids[2]'); $mform->addElement('text', 'groupids[2]', 'groupids[2]');
$mform->addElement('text', 'groupids[3]', 'groupids[3]'); $mform->addElement('text', 'groupids[3]', 'groupids[3]');
$mform->setType('groupids', PARAM_INT);
$mform->addElement('hidden', 'function'); $mform->addElement('hidden', 'function');
$mform->setType('function', PARAM_SAFEDIR); $mform->setType('function', PARAM_PLUGIN);
$mform->addElement('hidden', 'protocol'); $mform->addElement('hidden', 'protocol');
$mform->setType('protocol', PARAM_SAFEDIR); $mform->setType('protocol', PARAM_ALPHA);
$this->add_action_buttons(true, get_string('execute', 'webservice')); $this->add_action_buttons(true, get_string('execute', 'webservice'));
} }
@ -622,9 +674,12 @@ class moodle_group_add_groupmembers_form extends moodleform {
$data = $this->_customdata; $data = $this->_customdata;
if ($data['authmethod'] == 'simple') { if ($data['authmethod'] == 'simple') {
$mform->addElement('text', 'wsusername', 'wsusername'); $mform->addElement('text', 'wsusername', 'wsusername');
$mform->setType('wsusername', PARAM_USERNAME);
$mform->addElement('text', 'wspassword', 'wspassword'); $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->addElement('text', 'token', 'token');
$mform->setType('token', PARAM_RAW_TRIMMED);
} }
$mform->addElement('hidden', 'authmethod', $data['authmethod']); $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', 'groupid[0]', 'groupid[0]');
$mform->addElement('text', 'userid[1]', 'userid[1]'); $mform->addElement('text', 'userid[1]', 'userid[1]');
$mform->addElement('text', 'groupid[1]', 'groupid[1]'); $mform->addElement('text', 'groupid[1]', 'groupid[1]');
$mform->setType('userid', PARAM_INT);
$mform->setType('groupids', PARAM_INT);
$mform->addElement('hidden', 'function'); $mform->addElement('hidden', 'function');
$mform->setType('function', PARAM_SAFEDIR); $mform->setType('function', PARAM_PLUGIN);
$mform->addElement('hidden', 'protocol'); $mform->addElement('hidden', 'protocol');
$mform->setType('protocol', PARAM_SAFEDIR); $mform->setType('protocol', PARAM_ALPHA);
$this->add_action_buttons(true, get_string('execute', 'webservice')); $this->add_action_buttons(true, get_string('execute', 'webservice'));
} }
@ -681,23 +738,28 @@ class moodle_group_delete_groupmembers_form extends moodleform {
$data = $this->_customdata; $data = $this->_customdata;
if ($data['authmethod'] == 'simple') { if ($data['authmethod'] == 'simple') {
$mform->addElement('text', 'wsusername', 'wsusername'); $mform->addElement('text', 'wsusername', 'wsusername');
$mform->setType('wsusername', PARAM_USERNAME);
$mform->addElement('text', 'wspassword', 'wspassword'); $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->addElement('text', 'token', 'token');
$mform->setType('token', PARAM_RAW_TRIMMED);
} }
$mform->addElement('hidden', 'authmethod', $data['authmethod']); $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', 'userid[0]', 'userid[0]');
$mform->addElement('text', 'groupid[0]', 'groupid[0]'); $mform->addElement('text', 'groupid[0]', 'groupid[0]');
$mform->addElement('text', 'userid[1]', 'userid[1]'); $mform->addElement('text', 'userid[1]', 'userid[1]');
$mform->addElement('text', 'groupid[1]', 'groupid[1]'); $mform->addElement('text', 'groupid[1]', 'groupid[1]');
$mform->setType('userid', PARAM_INT);
$mform->setType('groupids', PARAM_INT);
$mform->addElement('hidden', 'function'); $mform->addElement('hidden', 'function');
$mform->setType('function', PARAM_SAFEDIR); $mform->setType('function', PARAM_PLUGIN);
$mform->addElement('hidden', 'protocol'); $mform->addElement('hidden', 'protocol');
$mform->setType('protocol', PARAM_SAFEDIR); $mform->setType('protocol', PARAM_ALPHA);
$this->add_action_buttons(true, get_string('execute', 'webservice')); $this->add_action_buttons(true, get_string('execute', 'webservice'));
} }
@ -750,13 +812,16 @@ class core_course_create_categories_form extends moodleform {
$data = $this->_customdata; $data = $this->_customdata;
if ($data['authmethod'] == 'simple') { if ($data['authmethod'] == 'simple') {
$mform->addElement('text', 'wsusername', 'wsusername'); $mform->addElement('text', 'wsusername', 'wsusername');
$mform->setType('wsusername', PARAM_USERNAME);
$mform->addElement('text', 'wspassword', 'wspassword'); $mform->addElement('text', 'wspassword', 'wspassword');
$mform->setType('wspassword', PARAM_RAW);
} else if ($data['authmethod'] == 'token') { } else if ($data['authmethod'] == 'token') {
$mform->addElement('text', 'token', 'token'); $mform->addElement('text', 'token', 'token');
$mform->setType('token', PARAM_RAW_TRIMMED);
} }
$mform->addElement('hidden', 'authmethod', $data['authmethod']); $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', 'name[0]', 'name[0]');
$mform->addElement('text', 'parent[0]', 'parent[0]'); $mform->addElement('text', 'parent[0]', 'parent[0]');
$mform->addElement('text', 'idnumber[0]', 'idnumber[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', 'parent[1]', 'parent[1]');
$mform->addElement('text', 'idnumber[1]', 'idnumber[1]'); $mform->addElement('text', 'idnumber[1]', 'idnumber[1]');
$mform->addElement('text', 'description[1]', 'description[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->addElement('hidden', 'function');
$mform->setType('function', PARAM_SAFEDIR); $mform->setType('function', PARAM_PLUGIN);
$mform->addElement('hidden', 'protocol'); $mform->addElement('hidden', 'protocol');
$mform->setType('protocol', PARAM_SAFEDIR); $mform->setType('protocol', PARAM_ALPHA);
$this->add_action_buttons(true, get_string('execute', 'webservice')); $this->add_action_buttons(true, get_string('execute', 'webservice'));
} }
@ -827,25 +896,31 @@ class core_course_delete_categories_form extends moodleform {
$data = $this->_customdata; $data = $this->_customdata;
if ($data['authmethod'] == 'simple') { if ($data['authmethod'] == 'simple') {
$mform->addElement('text', 'wsusername', 'wsusername'); $mform->addElement('text', 'wsusername', 'wsusername');
$mform->setType('wsusername', PARAM_USERNAME);
$mform->addElement('text', 'wspassword', 'wspassword'); $mform->addElement('text', 'wspassword', 'wspassword');
$mform->setType('wspassword', PARAM_RAW);
} else if ($data['authmethod'] == 'token') { } else if ($data['authmethod'] == 'token') {
$mform->addElement('text', 'token', 'token'); $mform->addElement('text', 'token', 'token');
$mform->setType('token', PARAM_RAW_TRIMMED);
} }
$mform->addElement('hidden', 'authmethod', $data['authmethod']); $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', 'id[0]', 'id[0]');
$mform->addElement('text', 'newparent[0]', 'newparent[0]'); $mform->addElement('text', 'newparent[0]', 'newparent[0]');
$mform->addElement('text', 'recursive[0]', 'recursive[0]'); $mform->addElement('text', 'recursive[0]', 'recursive[0]');
$mform->addElement('text', 'id[1]', 'id[1]'); $mform->addElement('text', 'id[1]', 'id[1]');
$mform->addElement('text', 'newparent[1]', 'newparent[1]'); $mform->addElement('text', 'newparent[1]', 'newparent[1]');
$mform->addElement('text', 'recursive[1]', 'recursive[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->addElement('hidden', 'function');
$mform->setType('function', PARAM_SAFEDIR); $mform->setType('function', PARAM_PLUGIN);
$mform->addElement('hidden', 'protocol'); $mform->addElement('hidden', 'protocol');
$mform->setType('protocol', PARAM_SAFEDIR); $mform->setType('protocol', PARAM_ALPHA);
$this->add_action_buttons(true, get_string('execute', 'webservice')); $this->add_action_buttons(true, get_string('execute', 'webservice'));
} }
@ -909,13 +984,16 @@ class core_course_update_categories_form extends moodleform {
$data = $this->_customdata; $data = $this->_customdata;
if ($data['authmethod'] == 'simple') { if ($data['authmethod'] == 'simple') {
$mform->addElement('text', 'wsusername', 'wsusername'); $mform->addElement('text', 'wsusername', 'wsusername');
$mform->setType('wsusername', PARAM_USERNAME);
$mform->addElement('text', 'wspassword', 'wspassword'); $mform->addElement('text', 'wspassword', 'wspassword');
$mform->setType('wspassword', PARAM_RAW);
} else if ($data['authmethod'] == 'token') { } else if ($data['authmethod'] == 'token') {
$mform->addElement('text', 'token', 'token'); $mform->addElement('text', 'token', 'token');
$mform->setType('token', PARAM_RAW_TRIMMED);
} }
$mform->addElement('hidden', 'authmethod', $data['authmethod']); $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', 'id[0]', 'id[0]');
$mform->addElement('text', 'name[0]', 'name[0]'); $mform->addElement('text', 'name[0]', 'name[0]');
$mform->addElement('text', 'parent[0]', 'parent[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', 'parent[1]', 'parent[1]');
$mform->addElement('text', 'idnumber[1]', 'idnumber[1]'); $mform->addElement('text', 'idnumber[1]', 'idnumber[1]');
$mform->addElement('text', 'description[1]', 'description[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->addElement('hidden', 'function');
$mform->setType('function', PARAM_SAFEDIR); $mform->setType('function', PARAM_PLUGIN);
$mform->addElement('hidden', 'protocol'); $mform->addElement('hidden', 'protocol');
$mform->setType('protocol', PARAM_SAFEDIR); $mform->setType('protocol', PARAM_ALPHA);
$this->add_action_buttons(true, get_string('execute', 'webservice')); $this->add_action_buttons(true, get_string('execute', 'webservice'));
} }

7
cache/forms.php vendored
View file

@ -57,19 +57,20 @@ class cachestore_addinstance_form extends moodleform {
$form->addElement('text', 'name', get_string('storename', 'cache')); $form->addElement('text', 'name', get_string('storename', 'cache'));
$form->addHelpButton('name', 'storename', 'cache'); $form->addHelpButton('name', 'storename', 'cache');
$form->addRule('name', get_string('required'), 'required'); $form->addRule('name', get_string('required'), 'required');
$form->setType('name', PARAM_TEXT); $form->setType('name', PARAM_NOTAGS);
} else { } else {
$form->addElement('hidden', 'name', $store); $form->addElement('hidden', 'name', $store);
$form->addElement('static', 'name-value', get_string('storename', 'cache'), $store); $form->addElement('static', 'name-value', get_string('storename', 'cache'), $store);
$form->setType('name', PARAM_TEXT); $form->setType('name', PARAM_NOTAGS);
} }
if (is_array($locks)) { if (is_array($locks)) {
$form->addElement('select', 'lock', get_string('lockmethod', 'cache'), $locks); $form->addElement('select', 'lock', get_string('lockmethod', 'cache'), $locks);
$form->addHelpButton('lock', 'lockmethod', 'cache'); $form->addHelpButton('lock', 'lockmethod', 'cache');
$form->setType('lock', PARAM_TEXT); $form->setType('lock', PARAM_PLUGIN);
} else { } else {
$form->addElement('hidden', 'lock', ''); $form->addElement('hidden', 'lock', '');
$form->setType('lock', PARAM_PLUGIN);
$form->addElement('static', 'lock-value', get_string('lockmethod', 'cache'), $form->addElement('static', 'lock-value', get_string('lockmethod', 'cache'),
'<em>'.get_string('nativelocking', 'cache').'</em>'); '<em>'.get_string('nativelocking', 'cache').'</em>');
} }

View file

@ -112,6 +112,7 @@ class portfolio_plugin_boxnet extends portfolio_plugin_push_base {
$mform->addElement('text', 'apikey', get_string('apikey', 'portfolio_boxnet')); $mform->addElement('text', 'apikey', get_string('apikey', 'portfolio_boxnet'));
$mform->addRule('apikey', get_string('required'), 'required', null, 'client'); $mform->addRule('apikey', get_string('required'), 'required', null, 'client');
$mform->setType('apikey', PARAM_RAW_TRIMMED);
$a = new stdClass(); $a = new stdClass();
$a->servicesurl = 'http://www.box.net/developers/services'; $a->servicesurl = 'http://www.box.net/developers/services';
$a->callbackurl = $CFG->wwwroot . '/portfolio/add.php?postcontrol=1&type=boxnet'; $a->callbackurl = $CFG->wwwroot . '/portfolio/add.php?postcontrol=1&type=boxnet';

View file

@ -102,8 +102,10 @@ class portfolio_plugin_flickr extends portfolio_plugin_push_base {
$strrequired = get_string('required'); $strrequired = get_string('required');
$mform->addElement('text', 'apikey', get_string('apikey', 'portfolio_flickr'), array('size' => 30)); $mform->addElement('text', 'apikey', get_string('apikey', 'portfolio_flickr'), array('size' => 30));
$mform->addRule('apikey', $strrequired, 'required', null, 'client'); $mform->addRule('apikey', $strrequired, 'required', null, 'client');
$mform->setType('apikey', PARAM_RAW_TRIMMED);
$mform->addElement('text', 'sharedsecret', get_string('sharedsecret', 'portfolio_flickr')); $mform->addElement('text', 'sharedsecret', get_string('sharedsecret', 'portfolio_flickr'));
$mform->addRule('sharedsecret', $strrequired, 'required', null, 'client'); $mform->addRule('sharedsecret', $strrequired, 'required', null, 'client');
$mform->setType('sharedsecret', PARAM_RAW_TRIMMED);
$a = new stdClass(); $a = new stdClass();
$a->applyurl = 'http://www.flickr.com/services/api/keys/apply/'; $a->applyurl = 'http://www.flickr.com/services/api/keys/apply/';
$a->keysurl = 'http://www.flickr.com/services/api/keys/'; $a->keysurl = 'http://www.flickr.com/services/api/keys/';

View file

@ -92,7 +92,9 @@ class portfolio_plugin_mahara extends portfolio_plugin_pull_base {
} }
$mform->addElement('select', 'mnethostid', get_string('mnethost', 'portfolio_mahara'), $hosts); $mform->addElement('select', 'mnethostid', get_string('mnethost', 'portfolio_mahara'), $hosts);
$mform->addRule('mnethostid', $strrequired, 'required', null, 'client'); $mform->addRule('mnethostid', $strrequired, 'required', null, 'client');
$mform->setType('mnethostid', PARAM_INT);
$mform->addElement('selectyesno', 'enableleap2a', get_string('enableleap2a', 'portfolio_mahara')); $mform->addElement('selectyesno', 'enableleap2a', get_string('enableleap2a', 'portfolio_mahara'));
$mform->setType('enableleap2a', PARAM_BOOL);
} }
public function instance_sanity_check() { public function instance_sanity_check() {