Commit 46f75143 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Tidying up the webservices menu structure (Bug #1396435)

Before, the webservices admin pages were appearing under various
different menus.

I've taken them and put them as a third tier under
the Extensions -> Webservices menu

Change-Id: I8866da25ec54ba1a98392bfde628fe5182602270
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 0999b8e9
......@@ -2485,6 +2485,19 @@ class PluginAuth extends Plugin {
return true;
}
/**
* This function returns an array of menu items
* to be displayed
*
* See the function find_menu_children() in lib/web.php
* for a description of the expected array structure.
*
* @return array
*/
public static function menu_items() {
return array();
}
public static function update_active_flag($event, $user) {
if (!isset($user['id'])) {
log_warn("update_active_flag called without a user id");
......
......@@ -14,7 +14,8 @@ defined('INTERNAL') || die();
$string['webservice'] = 'Webservice';
$string['title'] = 'Webservice';
$string['description'] = 'Webservice only users Authenticated against Mahara\'s database';
$string['webservicesconfig'] = 'Configuration';
$string['webservicesconfigdesc'] = 'Here you can set up the varying webservice rules and enable/disable the services.';
$string['completeregistration'] = 'Complete Registration';
$string['emailalreadytaken'] = 'This e-mail address has already registered here';
$string['iagreetothetermsandconditions'] = 'I agree to the Terms and Conditions';
......
......@@ -18,30 +18,6 @@ set_include_path($path . PATH_SEPARATOR . get_include_path());
require_once(get_config('docroot') . '/webservice/lib.php');
require_once(get_config('docroot') . 'api/xmlrpc/lib.php');
/**
* if the local_right_nav_update doesn't exist, then when can
* inject the app token itme in the menu
*/
if (!function_exists('local_right_nav_update')) {
function local_right_nav_update(&$menu) {
$menu = ($menu ? $menu : array());
foreach ($menu as $item) {
if ($item['path'] == 'settings/apps') {
return;
}
}
$menu[]=
array(
'path' => 'settings/apps',
'url' => 'webservice/apptokens.php',
'title' => get_string('apptokens', 'auth.webservice'),
'weight' => 40,
'selected' => false,
'submenu' => array(),
);
}
}
/**
* The webservice authentication method, which authenticates users against the
* Mahara database, but ensures that these users can only be used for webservices
......@@ -111,70 +87,44 @@ class PluginAuthWebservice extends PluginAuth {
return array();
}
public static function menu_items($smarty=null, $selected=null) {
global $SELECTEDSUBNAV, $USER;
$items = array(
'webservice' => array(
'path' => 'webservice',
'url' => 'webservice/admin/index.php',
'title' => get_string('webservices', 'auth.webservice'),
'weight' => 10,
'selected' => false,
'submenu' => array(),
),
'webservice/oauthconfig' => array(
'path' => 'webservice/oauthconfig',
'url' => 'webservice/admin/oauthv1sregister.php',
'title' => get_string('oauth', 'auth.webservice'),
'weight' => 10,
'selected' => false,
'submenu' => array(),
),
'webservice/logs' => array(
'path' => 'webservice/logs',
'url' => 'webservice/admin/webservicelogs.php',
'title' => get_string('webservicelogs', 'auth.webservice'),
'weight' => 20,
'selected' => false,
'submenu' => array(),
),
'webservice/testclient' => array(
'path' => 'webservice/testclient',
'url' => 'webservice/testclient.php',
'title' => get_string('testclient', 'auth.webservice'),
'weight' => 30,
'selected' => false,
'submenu' => array(),
),
);
if ($USER->is_logged_in() && $smarty) {
$SELECTEDSUBNAV = ($SELECTEDSUBNAV ? $SELECTEDSUBNAV : array());
$items = array_merge($SELECTEDSUBNAV, $items);
$apps = false;
$SELECTEDSUBNAV = array();
foreach ($items as $sub) {
$sub['selected'] = ($selected == $sub['path'] ? true : false);
$SELECTEDSUBNAV[]= $sub;
if ($sub['path'] == 'settings/apps') {
$apps = true;
}
}
if (!$apps) {
$SELECTEDSUBNAV[]=
array(
'path' => 'settings/apps',
'url' => 'webservice/apptokens.php',
'title' => get_string('apptokens', 'auth.webservice'),
'weight' => 40,
'selected' => ($selected == 'settings/apps' ? true : false),
'submenu' => array(),
);
}
$smarty->assign('SELECTEDSUBNAV', $SELECTEDSUBNAV);
public static function menu_items() {
global $USER;
if ($USER->is_logged_in()) {
return array(
'configextensions/webservices/webservice' => array(
'path' => 'configextensions/webservices/webservice',
'parent' => 'configextensions/webservices',
'url' => 'webservice/admin/index.php',
'title' => get_string('webservicesconfig', 'auth.webservice'),
'weight' => 5,
),
'configextensions/webservices/oauthconfig' => array(
'path' => 'configextensions/webservices/oauthconfig',
'url' => 'webservice/admin/oauthv1sregister.php',
'title' => get_string('oauth', 'auth.webservice'),
'weight' => 10,
),
'configextensions/webservices/logs' => array(
'path' => 'configextensions/webservices/logs',
'url' => 'webservice/admin/webservicelogs.php',
'title' => get_string('webservicelogs', 'auth.webservice'),
'weight' => 20,
),
'configextensions/webservices/testclient' => array(
'path' => 'configextensions/webservices/testclient',
'url' => 'webservice/testclient.php',
'title' => get_string('testclient', 'auth.webservice'),
'weight' => 30,
),
'configextensions/webservices/apps' => array(
'path' => 'configextensions/webservices/apps',
'url' => 'webservice/apptokens.php',
'title' => get_string('apptokens', 'auth.webservice'),
'weight' => 40,
),
);
}
return $items;
}
/*
......
......@@ -2262,6 +2262,12 @@ function admin_nav() {
'title' => get_string('cleanurls', 'admin'),
'weight' => 40,
),
'configextensions/webservices' => array(
'path' => 'configextensions/webservices',
'url' => 'webservice/admin/index.php',
'title' => get_string('webservices', 'auth.webservice'),
'weight' => 50,
),
);
// Add the menu items for skins, if that feature is enabled
......@@ -2669,7 +2675,7 @@ function main_nav() {
$menu = array_filter($menu, create_function('$a', 'return empty($a["ignore"]);'));
// enable plugins to augment the menu structure
foreach (array('artefact', 'interaction', 'module') as $plugintype) {
foreach (array('artefact', 'interaction', 'module', 'auth') as $plugintype) {
if ($plugins = plugins_installed($plugintype)) {
foreach ($plugins as &$plugin) {
if (safe_require_plugin($plugintype, $plugin->name)) {
......
{include file="header.tpl"}
<p class="intro">{$pagedescription}</p>
{foreach from=$form.elements item=element}
<div class="pseudofieldset collapsible collapsed">
<span class="pseudolegend"><h4 id="{$element.name}_pseudofieldset"><a href="">{$element.legend}</a></h4></span>
......@@ -31,3 +34,5 @@ jQuery(function() {
});
</script>
{include file="footer.tpl"}
......@@ -12,7 +12,7 @@
define('INTERNAL', 1);
define('ADMIN', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
define('MENUITEM', 'configextensions/pluginadminwebservices');
define('MENUITEM', 'configextensions/webservices');
$path = get_config('docroot') . 'lib/zend';
set_include_path($path . PATH_SEPARATOR . get_include_path());
......@@ -21,22 +21,18 @@ require_once(get_config('docroot') . 'api/xmlrpc/lib.php');
define('TITLE', get_string('webservices_title', 'auth.webservice'));
require_once('pieforms/pieform.php');
safe_require('auth', 'webservice');
$heading = get_string('webservices_title', 'auth.webservice');
$webservice_menu = PluginAuthWebservice::menu_items(MENUITEM);
$form = get_config_options_extended();
$smarty = smarty_core();
$smarty = smarty(array(), array('<link rel="stylesheet" type="text/css" href="' . $THEME->get_url('style/webservice.css', false, 'auth/webservice') . '">'));
$smarty->assign('form', $form);
$smarty->assign('opened', param_alphanumext('open', ''));
$mainform = $smarty->fetch('auth:webservice:configform.tpl');
unset($smarty);
$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('form', $mainform);
$heading = get_string('webservices_title', 'auth.webservice');
$smarty->assign('TERTIARYMENU', $webservice_menu);
$smarty->assign('PAGEHEADING', $heading);
$smarty->display('form.tpl');
$smarty->assign('pagedescription', get_string('webservicesconfigdesc', 'auth.webservice'));
$smarty->display('auth:webservice:configform.tpl');
/* pieforms callback for activate_webservices for
*/
......
......@@ -11,7 +11,7 @@
define('INTERNAL', 1);
define('ADMIN', 1);
define('MENUITEM', 'adminhome/pluginadminwebservices');
define('MENUITEM', 'configextensions/webservices/oauthconfig');
define('SECTION_PAGE', 'oauth');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
define('TITLE', get_string('oauthv1sregister', 'auth.webservice'));
......
......@@ -11,7 +11,7 @@
define('INTERNAL', 1);
define('ADMIN', 1);
define('MENUITEM', 'adminhome/pluginadminwebservices');
define('MENUITEM', 'configextensions/webservices/logs');
define('SECTION_PAGE', 'webservicelogs');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once('webservicessearchlib.php');
......@@ -47,7 +47,7 @@ else {
$smarty = smarty(array(get_config('wwwroot') . 'webservice/admin/js/usersearch.js'), 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/logs');
$smarty->assign('search', $search);
$smarty->assign('alphabet', explode(',', get_string('alphabet')));
$smarty->assign('cancel', get_string('cancel'));
......
......@@ -21,7 +21,8 @@
*/
define('INTERNAL', 1);
define('MENUITEM', 'settings/applications');
define('MENUITEM', 'configextensions/webservices/apps');
define('INADMINMENU', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
require_once(dirname(__FILE__) . '/lib.php');
......@@ -422,7 +423,7 @@ $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');
PluginAuthWebservice::menu_items($smarty, 'settings/apps');
$smarty->assign('form', $form);
$smarty->assign('PAGEHEADING', TITLE);
$smarty->display('form.tpl');
......@@ -11,10 +11,7 @@
define('INTERNAL', 1);
define('ADMIN', 1);
// define('MENUITEM', 'webservice/testclient');
define('MENUITEM', 'adminhome/pluginadminwebservices');
// define('SECTION_PLUGINTYPE', 'core');
// define('SECTION_PLUGINNAME', 'admin');
define('MENUITEM', 'configextensions/webservices/testclient');
define('SECTION_PAGE', 'wstestclient');
require(dirname(dirname(__FILE__)) . '/init.php');
......@@ -173,7 +170,7 @@ $form = pieform(array(
$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/testclient');
$smarty->assign('form', $form);
$heading = get_string('testclient', 'auth.webservice');
$smarty->assign('PAGEHEADING', $heading);
......
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