Commit 4376ab2b authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1633808: Webservices logs form display institution field



Was not quite working before.

Things also fixed (or partially fixed)
1) The webservice logs page searching for function name to filter by
- before the ajax was wanting to paginate by 5 and select2 expected 10
results so the more search results was not working

2) The error returned on the testclient page when there was an error
with a field didn't display which field it was.

3) Display on testclient page a file upload filed if type is PARAM_FILE
- The actual testing of file upload is not working yet but it wasn't
working before either but this is a step in the right direction

4) The wsdocs page was displaying 'REQUIRED' for the VALUE_DEFAULT
fields rather than the VALUE_REQUIRED fields.

behatnotneeded

Change-Id: Ia00beeb6d48fa3019984f2e0f7605fbb097edffd
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 17ef60df
......@@ -52,7 +52,7 @@ else {
list($html, $columns, $searchurl, $pagination) = build_webservice_log_search_results($search);
$institutionselect = '';
$institutionselect = false;
if (count($institutions) > 1) {
$selecttype = $USER->get('admin') ? 'institution' : 'institution_requested';
$options = array('all' => get_string('All'));
......@@ -80,66 +80,68 @@ $authtypeoptions = array('all' => get_string('All'));
foreach ($authtypes as $authtype) {
$authtypeoptions[$authtype] = $authtype;
}
$elements = array();
$elements['userquery'] = array(
'type' => 'autocomplete',
'title' => get_string('userauth', 'auth.webservice'),
'defaultvalue' => !empty($userquery) ? $userquery : null,
'ajaxurl' => get_config('wwwroot') . 'webservice/admin/users.json.php',
'initfunction' => 'translate_ids_to_names',
'multiple' => true,
'ajaxextraparams' => array(),
'extraparams' => array(
'maximumSelectionLength' => 1
),
'width' => '280px',
);
if ($institutionselect) {
$elements[$selecttype] = $institutionselect;
}
$elements['protocol'] = array(
'type' => 'select',
'title' => get_string('protocol', 'auth.webservice'),
'defaultvalue' => !empty($search->protocol) ? $search->protocol : 'all',
'options' => $protocoloptions,
);
$elements['authtype'] = array(
'type' => 'select',
'title' => get_string('sauthtype', 'auth.webservice'),
'defaultvalue' => !empty($search->authtype) ? $search->authtype : 'all',
'options' => $authtypeoptions,
);
$elements['functionquery'] = array(
'type' => 'autocomplete',
'title' => get_string('function', 'auth.webservice'),
'defaultvalue' => !empty($functionquery) ? $functionquery : '',
'ajaxurl' => get_config('wwwroot') . 'webservice/admin/functions.json.php',
'initfunction' => 'translate_ids_to_functions',
'multiple' => true,
'ajaxextraparams' => array(),
'extraparams' => array(
'maximumSelectionLength' => 1
),
'width' => '280px',
);
$elements['onlyerrors'] = array(
'type' => 'switchbox',
'class' => 'last',
'title' => get_string('errors', 'auth.webservice'),
'defaultvalue' => $search->onlyerrors,
);
$elements['submit'] = array(
'type' => 'submit',
'class' => 'btn-primary',
'value' => get_string('go'),
);
$form = array(
'name' => 'logsearchform',
'method' => 'post',
'successcallback' => 'logsearchform_submit',
'renderer' => 'div',
'elements' => array(
'userquery' => array(
'type' => 'autocomplete',
'title' => get_string('userauth', 'auth.webservice'),
'defaultvalue' => !empty($userquery) ? $userquery : null,
'ajaxurl' => get_config('wwwroot') . 'webservice/admin/users.json.php',
'initfunction' => 'translate_ids_to_names',
'multiple' => true,
'ajaxextraparams' => array(),
'extraparams' => array(
'maximumSelectionLength' => 1
),
'width' => '280px',
),
$institutionselect,
'protocol' => array(
'type' => 'select',
'title' => get_string('protocol', 'auth.webservice'),
'defaultvalue' => !empty($search->protocol) ? $search->protocol : 'all',
'options' => $protocoloptions,
),
'authtype' => array(
'type' => 'select',
'title' => get_string('sauthtype', 'auth.webservice'),
'defaultvalue' => !empty($search->authtype) ? $search->authtype : 'all',
'options' => $authtypeoptions,
),
'functionquery' => array(
'type' => 'autocomplete',
'title' => get_string('function', 'auth.webservice'),
'defaultvalue' => !empty($functionquery) ? $functionquery : '',
'ajaxurl' => get_config('wwwroot') . 'webservice/admin/functions.json.php',
'initfunction' => 'translate_ids_to_functions',
'multiple' => true,
'ajaxextraparams' => array(),
'extraparams' => array(
'maximumSelectionLength' => 1
),
'width' => '280px',
),
'onlyerrors' => array(
'type' => 'switchbox',
'class' => 'last',
'title' => get_string('errors', 'auth.webservice'),
'defaultvalue' => $search->onlyerrors,
),
'submit' => array(
'type' => 'submit',
'class' => 'btn-primary',
'value' => get_string('go'),
),
),
'elements' => $elements,
);
unset($form['elements'][0]);
$form = pieform($form);
$smarty = smarty(array('paginator'));
setpageicon($smarty, 'icon-puzzle-piece');
......
......@@ -588,7 +588,7 @@ class external_api {
$result[$key] = self::validate_parameters($subdesc, $params[$key]);
} catch (WebserviceInvalidParameterException $e) {
//it's ok to display debug info as here the information is useful for ws client/dev
throw new WebserviceParameterException('invalidextparam',"key: $key - ".$e->getMessage().(isset($e->debuginfo) ? " (debuginfo: " . $e->debuginfo.") " : ""));
throw new WebserviceParameterException(get_string('invalidextparam', 'auth.webservice', "key: $key - " . $e->getMessage() . (isset($e->debuginfo) ? " (debuginfo: " . $e->debuginfo . ") " : "")));
}
}
unset($params[$key]);
......
......@@ -142,6 +142,7 @@ if (!empty($authtype)) {
$title = preg_replace('/^(.*?)_NUM_/', '', $var['name']);
$title = preg_replace('/_NUM_/', ' / ', $title);
$type = (trim($var['type']) == 'bool') ? 'switchbox' : 'text';
$type = (trim($var['type']) == 'file') ? 'file' : $type;
if ($title == 'institution') {
// Let see if we can fetch the exact allowed values
$elements[$name] = get_institution_selector();
......@@ -326,9 +327,13 @@ function testclient_parameters($paramdescription, $paramstring) {
case PARAM_FLOAT:
$type = 'double';
break;
case PARAM_FILE:
$type = 'file';
break;
default:
$type = 'string';
}
return $paramstring . " " . $type . $brakeline;
}
}
......
......@@ -107,8 +107,7 @@ function wsdoc_detailed_description_html($params, $indentlevel = 0) {
else if (!is_scalar($params->default)) {
$params->default = '&lt;' . gettype($params->default) . '&gt;';
}
$required = '<span class="wsrequired">' . get_string('required', 'auth.webservice') . '</span> ' .
'<span class="wsoptional">' . get_string('default', 'auth.webservice', $params->default) . '</span> ';
$required = '<span class="wsoptional">' . get_string('default', 'auth.webservice', $params->default) . '</span> ';
break;
case VALUE_OPTIONAL:
......@@ -117,8 +116,10 @@ function wsdoc_detailed_description_html($params, $indentlevel = 0) {
. '</span> ';
break;
// Don't need to print anything for a required param
case VALUE_REQUIRED:
$required = '<span class="wsrequired">' . get_string('required', 'auth.webservice') . '</span> ';
break;
default:
$required = '';
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment