require_once 'webservicessearchlib.php'; define('TITLE', get_string('webservices_title', 'auth.webservice')); require_once 'pieforms/pieform.php'; $userquery = param_variable('userquery', null); $username = !empty($userquery) ? get_field('usr', 'username', 'id', $userquery) : ''; $functionquery = param_variable('functionquery', null); $functionname = !empty($functionquery) ? get_field('external_functions', 'name', 'id', $functionquery) : ''; $search = (object) array('userquery' => $username, 'functionquery' => $functionname, 'protocol' => trim(param_alphanumext('protocol', 'all')), 'authtype' => trim(param_alphanum('authtype', 'all')), 'onlyerrors' => 'on' == param_alphanum('onlyerrors', 'off') ? 1 : 0, 'sortby' => param_alpha('sortby', 'timelogged'), 'sortdir' => param_alpha('sortdir', 'desc'), 'offset' => param_integer('offset', 0), 'limit' => param_integer('limit', 10)); if ($USER->get('admin')) { $institutions = get_records_array('institution', '', '', 'displayname'); $search->institution = param_alphanum('institution', 'all'); } else { $institutions = get_records_select_array('institution', "name IN ('" . join("','", array_keys($USER->get('admininstitutions'))) . "')", null, 'displayname'); $search->institution_requested = param_alphanum('institution_requested', 'all'); } list($html, $columns, $searchurl, $pagination) = build_webservice_log_search_results($search); $institutionselect = ''; if (count($institutions) > 1) { $selecttype = $USER->get('admin') ? 'institution' : 'institution_requested'; $options = array('all' => get_string('All')); foreach ($institutions as $institution) { $options[$institution->name] = $institution->displayname; } $institutionfield = array($selecttype => array('type' => 'select', 'title' => get_string('Institution', 'admin'), 'defaultvalue' => !empty($search->institution) ? $search->institution : 'all', 'options' => $options)); $institutionselect = array_shift($institutionfield); } $protocoloptions = array('all' => get_string('All')); $protocols = array('REST', 'XML-RPC', 'SOAP'); foreach ($protocols as $protocol) { $protocoloptions[$protocol] = $protocol; }
* */ define('INTERNAL', 1); define('JSON', 1); define('INSTITUTIONALADMIN', 1); require dirname(dirname(dirname(__FILE__))) . '/init.php'; $action = param_variable('action'); if ($action == 'search') { require_once 'webservicessearchlib.php'; $params = new StdClass(); $params->userquery = trim(param_variable('userquery', '')); $params->functionquery = trim(param_variable('functionquery', '')); $params->institution = param_alphanum('institution', 'all'); $params->protocol = param_alphanum('protocol', 'all'); $params->authtype = param_alphanum('authtype', 'all'); $params->institution_requested = param_alphanum('institution_requested', null); $params->offset = param_integer('offset', 0); $params->limit = param_integer('limit', 10); $params->sortby = param_alpha('sortby', 'timelogged'); $params->sortdir = param_alpha('sortdir', 'desc'); json_headers(); if (param_boolean('raw', false)) { $data = get_log_search_results($params); } else { $data['data'] = build_webservice_log_search_results($params); } $data['error'] = false; $data['message'] = null; echo json_encode($data); exit; }