Skip to content

Commit

Permalink
MDL-38851 Admin: Fixed setType notice for webservice
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajesh Taneja committed Apr 24, 2013
1 parent 962b1ba commit ac31413
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 57 deletions.
12 changes: 11 additions & 1 deletion admin/webservice/forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ function definition() {
$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'));

Expand All @@ -65,14 +67,17 @@ function definition() {
$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;
Expand Down Expand Up @@ -100,6 +105,7 @@ function definition() {
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;
Expand Down Expand Up @@ -209,9 +215,11 @@ function definition() {
$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');
}
Expand All @@ -231,12 +239,14 @@ function definition() {
}
$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);
Expand Down
6 changes: 3 additions & 3 deletions admin/webservice/testclient.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
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);
Expand Down
Loading

0 comments on commit ac31413

Please sign in to comment.