Commit 83365056 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1787507: Moving mobile apps / badgr apps to third menu



So now the 'Apps' menu item in Account settings goes to a page with an
arrow menu to the different apps available

behatnotneeded

Change-Id: Ibe59bdc3d01629c85ba8f4bb483d5f73346fc5a6
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 574be74f
<?php
/**
*
* @package mahara
* @subpackage core
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
define('INTERNAL', 1);
define('MENUITEM', 'settings/apps');
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'account');
define('SECTION_PAGE', 'apps');
define('APPS', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
define('TITLE', get_string('myapplications'));
$hasapps = apps_get_menu_tabs();
$smarty = smarty();
$smarty->assign('hasapps', !empty($hasapps));
$smarty->display('account/apps.tpl');
......@@ -78,13 +78,13 @@ class PluginBlocktypeOpenbadgedisplayer extends SystemBlocktype {
return array('openbadgedisplayer' => array('media'));
}
public static function right_nav_menu_items() {
public static function app_tabs() {
return array(
'settings/badgr' => array(
'badgr' => array(
'path' => 'settings/badgr',
'url' => 'blocktype/openbadgedisplayer/badgrtoken.php',
'title' => get_string('badgrtokentitle', 'blocktype.openbadgedisplayer'),
'weight' => 60,
'weight' => 20,
'iconclass' => 'flag'
),
);
......
......@@ -884,6 +884,11 @@ $string['profileimagetexttemplate'] = "User's profile picture will go here";
$string['profileimagetextanonymous'] = "anonymous profile picture";
$string['primaryemailinvalid'] = 'Your primary email address is invalid.';
$string['addemail'] = 'Add email address';
$string['myapps'] = 'Apps';
$string['myapplications'] = 'My applications';
$string['acccountappsdescription'] = 'Here you can administer any applications that require token access.';
$string['acccountaddappsdescription'] = 'Currently there are no plugins active that allow token administration.';
$string['acccountchooseappsdescription'] = 'To administer your application tokens please select the application from the "My applications" bar.';
// Search
$string['search'] = 'Search';
......
......@@ -791,6 +791,12 @@ EOF;
}
}
if (defined('APPS')) {
if (!defined('NOAPPSMENU')) {
$smarty->assign('SUBPAGENAV', apps_get_menu_tabs());
}
}
// ---------- sideblock stuff ----------
$sidebars = !isset($extraconfig['sidebars']) || $extraconfig['sidebars'] !== false;
if ($sidebars && !defined('INSTALLER') && (!defined('MENUITEM') || substr(MENUITEM, 0, 5) != 'admin')) {
......@@ -3154,6 +3160,12 @@ function right_nav() {
'title' => get_string('legal', 'admin'),
'weight' => 30
),
'settings/apps' => array(
'path' => 'settings/apps',
'url' => 'account/apps.php',
'title' => get_string('myapps'),
'weight' => 50
),
'settings/notifications' => array(
'path' => 'settings/notifications',
'url' => 'account/activity/preferences/index.php',
......@@ -3277,6 +3289,33 @@ function footer_menu($all=false) {
return $menu;
}
function apps_get_menu_tabs() {
$menu = array();
foreach (plugin_types_installed() as $plugin_type_installed) {
foreach (plugins_installed($plugin_type_installed) as $plugin) {
safe_require($plugin_type_installed, $plugin->name);
if (method_exists(generate_class_name($plugin_type_installed, $plugin->name), 'app_tabs')) {
$plugin_menu = call_static_method(
generate_class_name($plugin_type_installed, $plugin->name),
'app_tabs'
);
$menu = array_merge($menu, $plugin_menu);
}
}
}
if (defined('MENUITEM')) {
$key = substr(MENUITEM, strlen('settings/'));
if ($key && isset($menu[$key])) {
$menu[$key]['selected'] = true;
}
}
// Sort the menu items by weight
uasort($menu, "sort_menu_by_weight");
return $menu;
}
/**
* Given a menu structure and a path, returns a data structure representing all
......
......@@ -20,11 +20,12 @@ define('MENUITEM', 'settings/webservice');
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'account');
define('SECTION_PAGE', 'webservice');
define('APPS', 1);
require('./../../init.php');
require_once($CFG->docroot . 'webservice/lib.php');
safe_require('module', 'mobileapi');
define('TITLE', get_string('mytokenspagetitle', 'module.mobileapi'));
define('TITLE', get_string('mytokenspagetitle1', 'module.mobileapi'));
// Users shouldn't be able to access this page if webservices are not enabled.
if (!PluginModuleMobileapi::is_service_ready()) {
......
......@@ -28,8 +28,8 @@ $string['servicenotallowed'] = 'The credentials you have provided are not author
$string['webserviceproviderenabled'] = 'Incoming web service requests allowed';
// User management of webservice access tokens
$string['mytokensmenutitle'] = 'Apps';
$string['mytokenspagetitle'] = 'Applications';
$string['mytokensmenutitle1'] = 'Mahara mobile';
$string['mytokenspagetitle1'] = 'Mahara mobile tokens';
$string['mytokenspagedesc'] = 'These applications can access your account.';
$string['nopersonaltokens'] = 'You have not granted access to any applications.';
$string['clientinfo'] = 'App';
......
......@@ -143,14 +143,14 @@ class PluginModuleMobileapi extends PluginModule {
return true;
}
public static function right_nav_menu_items() {
public static function app_tabs() {
if (PluginModuleMobileapi::is_service_ready()) {
return array(
'settings/webservice' => array(
'webservice' => array(
'path' => 'settings/webservice',
'url' => 'module/mobileapi/apps.php',
'title' => get_string('mytokensmenutitle', 'module.mobileapi'),
'weight' => 50,
'title' => get_string('mytokensmenutitle1', 'module.mobileapi'),
'weight' => 10,
'iconclass' => 'flag'
),
);
......
{include file="header.tpl"}
<p class="lead">{str tag="acccountappsdescription"}</p>
{if $hasapps}
<p>{str tag="acccountchooseappsdescription"}</p>
{else}
<p>{str tag="acccountaddappsdescription"}</p>
{/if}
{include file="footer.tpl"}
......@@ -189,4 +189,5 @@ Scenario: Checking menu items are available as Institution Administrator (Bug 14
Then I should see "Preferences"
And I should see "Legal"
And I should see "Notifications"
And I should see "Apps"
And I should see "Logout"
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