foreach ($functions as $function) { $dbfunction = get_record('external_functions', 'name', $function->functionname); $function_list[] = '<a href="' . get_config('wwwroot') . 'webservice/wsdoc.php?id=' . $dbfunction->id . '">' . $function->functionname . '</a>'; } } $token_details['elements']['functions'] = array('title' => get_string('functions', 'auth.webservice'), 'value' => implode(', ', $function_list), 'type' => 'html'); $token_details['elements']['wssigenc'] = array('defaultvalue' => $dbtoken->wssigenc == 1 ? 'checked' : '', 'type' => 'checkbox', 'disabled' => false, 'title' => get_string('wssigenc', 'auth.webservice')); $token_details['elements']['publickey'] = array('type' => 'textarea', 'title' => get_string('publickey', 'admin'), 'defaultvalue' => $dbtoken->publickey, 'rows' => 15, 'cols' => 90); $token_details['elements']['publickeyexpires'] = array('type' => 'html', 'title' => get_string('publickeyexpires', 'admin'), 'value' => $dbtoken->publickeyexpires ? format_date($dbtoken->publickeyexpires, 'strftimedatetime', 'formatdate', 'auth.webservice') : format_date(time(), 'strftimedatetime', 'formatdate', 'auth.webservice')); $token_details['elements']['submit'] = array('type' => 'submitcancel', 'value' => array(get_string('save'), get_string('back')), 'goto' => get_config('wwwroot') . 'webservice/admin/index.php?open=webservices_token'); $elements = array('token_details' => array('type' => 'fieldset', 'legend' => get_string('tokenid', 'auth.webservice', $dbtoken->token), 'elements' => array('sflist' => array('type' => 'html', 'value' => pieform($token_details))), 'collapsible' => false)); $form = array('renderer' => 'table', 'type' => 'div', 'id' => 'maintable', 'name' => 'tokenconfig', 'jsform' => true, 'successcallback' => 'allocate_webservice_tokens_submit', 'validatecallback' => 'allocate_webservice_tokens_validate', 'elements' => $elements); $form = pieform($form); $smarty = smarty(array(), array('<link rel="stylesheet" type="text/css" href="' . $THEME->get_url('style/webservice.css', false, 'auth/webservice') . '">')); safe_require('auth', 'webservice'); $webservice_menu = PluginAuthWebservice::menu_items(MENUITEM); $smarty->assign('TERTIARYMENU', $webservice_menu); $smarty->assign('token', $dbtoken->token); $smarty->assign('form', $form); $heading = get_string('tokens', 'auth.webservice'); $smarty->assign('PAGEHEADING', $heading); $smarty->display('form.tpl'); function allocate_webservice_tokens_submit(Pieform $form, $values) { global $SESSION; $dbtoken = get_record('external_tokens', 'id', $values['tokenid']); if (empty($dbtoken)) { $SESSION->add_error_msg(get_string('invalidtoken', 'auth.webservice')); redirect('/webservice/admin/index.php?open=webservices_token'); return; }
$c = (object) $store->getConsumer($key, $USER->get('id'), true); if (empty($c)) { $SESSION->add_error_msg(get_string('errorregister', 'auth.webservice')); redirect('/webservice/admin/oauthv1sregister.php'); } else { redirect('/webservice/admin/oauthv1sregister.php?edit=' . $c->id); } } $SESSION->add_error_msg(get_string('errorupdate', 'auth.webservice')); redirect('/webservice/admin/oauthv1sregister.php'); } $pieform = new Pieform($form); $form = $pieform->build(false); $smarty = smarty(array(), array('<link rel="stylesheet" type="text/css" href="' . $THEME->get_url('style/webservice.css', false, 'auth/webservice') . '">')); safe_require('auth', 'webservice'); PluginAuthWebservice::menu_items($smarty, 'webservice/oauthconfig'); $smarty->assign('form', $form); $smarty->assign('PAGEHEADING', TITLE); $smarty->display('form.tpl'); function webservice_main_submit(Pieform $form, $values) { } function webservice_server_edit_form($dbserver, $sopts, $iopts) { $server_details = array('name' => 'webservice_oauth_server', 'successcallback' => 'webservice_oauth_server_submit', 'jsform' => false, 'renderer' => 'table', 'elements' => array('id' => array('type' => 'hidden', 'value' => $dbserver->id), 'userid' => array('type' => 'hidden', 'value' => $dbserver->userid), 'consumer_key' => array('type' => 'hidden', 'value' => $dbserver->consumer_key))); $server_details['elements']['consumer_secret'] = array('title' => get_string('consumer_secret', 'auth.webservice'), 'value' => $dbserver->consumer_secret, 'type' => 'html'); $server_details['elements']['application_title'] = array('title' => get_string('application_title', 'auth.webservice'), 'defaultvalue' => $dbserver->application_title, 'type' => 'text'); $server_details['elements']['user'] = array('title' => get_string('serviceuser', 'auth.webservice'), 'value' => get_field('usr', 'username', 'id', $dbserver->userid), 'type' => 'html'); $server_details['elements']['application_uri'] = array('title' => get_string('application_uri', 'auth.webservice'), 'defaultvalue' => $dbserver->application_uri, 'type' => 'text'); $server_details['elements']['callback_uri'] = array('title' => get_string('callback', 'auth.webservice'), 'defaultvalue' => $dbserver->callback_uri, 'type' => 'text'); $server_details['elements']['institution'] = array('type' => 'select', 'title' => get_string('institution'), 'options' => $iopts, 'defaultvalue' => trim($dbserver->institution));
foreach ($functions as $function) { $dbfunction = get_record('external_functions', 'name', $function->functionname); $function_list[] = '<a href="' . get_config('wwwroot') . 'webservice/wsdoc.php?id=' . $dbfunction->id . '">' . $function->functionname . '</a>'; } } $token_details['elements']['functions'] = array('title' => get_string('functions', 'auth.webservice'), 'value' => implode(', ', $function_list), 'type' => 'html'); $token_details['elements']['wssigenc'] = array('defaultvalue' => $dbtoken->wssigenc == 1 ? 'checked' : '', 'type' => 'checkbox', 'disabled' => false, 'title' => get_string('wssigenc', 'auth.webservice')); $token_details['elements']['publickey'] = array('type' => 'textarea', 'title' => get_string('publickey', 'admin'), 'defaultvalue' => $dbtoken->publickey, 'rows' => 15, 'cols' => 90); $token_details['elements']['publickeyexpires'] = array('type' => 'html', 'title' => get_string('publickeyexpires', 'admin'), 'value' => $dbtoken->publickeyexpires ? format_date($dbtoken->publickeyexpires, 'strftimedatetime', 'formatdate', 'auth.webservice') : format_date(time(), 'strftimedatetime', 'formatdate', 'auth.webservice')); $token_details['elements']['submit'] = array('type' => 'submitcancel', 'class' => 'btn-primary', 'value' => array(get_string('save'), get_string('back')), 'goto' => get_config('wwwroot') . 'webservice/admin/index.php?open=webservices_token'); $elements = array('token_details' => array('type' => 'fieldset', 'legend' => get_string('tokenid', 'auth.webservice', $dbtoken->token), 'elements' => array('sflist' => array('type' => 'html', 'value' => pieform($token_details))))); $form = array('renderer' => 'div', 'id' => 'maintable', 'class' => 'form-group-nested', 'name' => 'tokenconfig', 'jsform' => true, 'successcallback' => 'allocate_webservice_tokens_submit', 'validatecallback' => 'allocate_webservice_tokens_validate', 'elements' => $elements); $form = pieform($form); $smarty = smarty(array(), array('<link rel="stylesheet" type="text/css" href="' . $THEME->get_url('style/webservice.css', false, 'auth/webservice') . '">')); safe_require('auth', 'webservice'); $webservice_menu = PluginAuthWebservice::admin_menu_items(); $smarty->assign('SUBPAGENAV', $webservice_menu); $smarty->assign('token', $dbtoken->token); $smarty->assign('form', $form); $heading = get_string('tokens', 'auth.webservice'); $smarty->assign('PAGEHEADING', $heading); $smarty->display('form.tpl'); function allocate_webservice_tokens_submit(Pieform $form, $values) { global $SESSION; $dbtoken = get_record('external_tokens', 'id', $values['tokenid']); if (empty($dbtoken)) { $SESSION->add_error_msg(get_string('invalidtoken', 'auth.webservice')); redirect('/webservice/admin/index.php?open=webservices_token'); return; }
define('SECTION_PAGE', 'webservice'); require dirname(dirname(__FILE__)) . '/init.php'; define('TITLE', get_string('pluginadmin', 'admin')); require_once 'pieforms/pieform.php'; require_once get_config('docroot') . 'webservice/lib.php'; $function = param_integer('id', 0); $dialog = param_integer('dialog', 0); $dbfunction = get_record('external_functions', 'id', $function); if (empty($dbfunction)) { $SESSION->add_error_msg(get_string('invalidfunction', 'auth.webservice')); redirect('/webservice/admin/index.php'); } $fdesc = webservice_function_info($dbfunction->name); $smarty = smarty(array(), array('<link rel="stylesheet" type="text/css" href="' . $THEME->get_url('style/webservice.css', false, 'auth/webservice') . '">')); safe_require('auth', 'webservice'); PluginAuthWebservice::menu_items($smarty, 'webservice'); $smarty->assign('function', $dbfunction); $smarty->assign('functiondescription', $fdesc->description); $smarty->assign('fdesc', $fdesc); $smarty->assign('xmlrpcactive', webservice_protocol_is_enabled('xmlrpc')); $smarty->assign('restactive', webservice_protocol_is_enabled('rest')); $smarty->assign('soapactive', webservice_protocol_is_enabled('soap')); $heading = get_string('wsdoc', 'auth.webservice'); $smarty->assign('PAGEHEADING', $heading); $smarty->assign('dialog', $dialog); $smarty->display('auth:webservice:wsdoc.tpl'); die; /** * Return documentation for a ws description object * ws description object can be 'external_multiple_structure', 'external_single_structure' * or 'external_value'