Commit 0aa571a2 authored by Aaron Wells's avatar Aaron Wells Committed by Gerrit Code Review
Browse files

Merge "Allow plugins to register admin menu items (Bug #1431540)"

parents 50cdb600 14f82418
......@@ -169,6 +169,45 @@ abstract class PluginArtefact extends Plugin implements IPluginArtefact {
public static function right_nav_menu_items() {
return array();
}
/**
* This function returns an array of admin 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 admin_menu_items() {
return array();
}
/**
* This function returns an array of institution 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 institution_menu_items() {
return array();
}
/**
* This function returns an array of institution staff 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 institution_staff_menu_items() {
return array();
}
}
/**
......
......@@ -2536,6 +2536,45 @@ class PluginAuth extends Plugin {
return array();
}
/**
* This function returns an array of admin 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 admin_menu_items() {
return array();
}
/**
* This function returns an array of institution 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 institution_menu_items() {
return array();
}
/**
* This function returns an array of institution staff 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 institution_staff_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");
......
......@@ -111,6 +111,45 @@ abstract class PluginInteraction extends Plugin implements IPluginInteraction {
public static function right_nav_menu_items() {
return array();
}
/**
* This function returns an array of admin 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 admin_menu_items() {
return array();
}
/**
* This function returns an array of institution 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 institution_menu_items() {
return array();
}
/**
* This function returns an array of institution staff 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 institution_staff_menu_items() {
return array();
}
}
/**
......
......@@ -2372,6 +2372,19 @@ function admin_nav() {
'weight' => 76,
);
}
// enable plugins to augment the admin menu structure
foreach (array('artefact', 'interaction', 'module', 'auth') as $plugintype) {
if ($plugins = plugins_installed($plugintype)) {
foreach ($plugins as &$plugin) {
if (safe_require_plugin($plugintype, $plugin->name)) {
$plugin_menu = call_static_method(generate_class_name($plugintype,$plugin->name), 'admin_menu_items');
$menu = array_merge($menu, $plugin_menu);
}
}
}
}
return $menu;
}
......@@ -2546,8 +2559,19 @@ function institutional_admin_nav() {
);
};
return $ret;
// enable plugins to augment the institution admin menu structure
foreach (array('artefact', 'interaction', 'module', 'auth') as $plugintype) {
if ($plugins = plugins_installed($plugintype)) {
foreach ($plugins as &$plugin) {
if (safe_require_plugin($plugintype, $plugin->name)) {
$plugin_menu = call_static_method(generate_class_name($plugintype,$plugin->name), 'institution_menu_items');
$ret = array_merge($ret, $plugin_menu);
}
}
}
}
return $ret;
}
/**
......@@ -2559,7 +2583,7 @@ function institutional_admin_nav() {
* @return a data structure containing the staff navigation
*/
function staff_nav() {
return array(
$menu = array(
'usersearch' => array(
'path' => 'usersearch',
'url' => 'admin/users/search.php',
......@@ -2582,6 +2606,20 @@ function staff_nav() {
'accesskey' => 'i',
),
);
// enable plugins to augment the institution staff menu structure
foreach (array('artefact', 'interaction', 'module', 'auth') as $plugintype) {
if ($plugins = plugins_installed($plugintype)) {
foreach ($plugins as &$plugin) {
if (safe_require_plugin($plugintype, $plugin->name)) {
$plugin_menu = call_static_method(generate_class_name($plugintype,$plugin->name), 'institution_staff_menu_items');
$menu = array_merge($menu, $plugin_menu);
}
}
}
}
return $menu;
}
/**
......
......@@ -50,4 +50,43 @@ abstract class PluginModule extends Plugin {
public static function right_nav_menu_items() {
return array();
}
/**
* This function returns an array of admin 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 admin_menu_items() {
return array();
}
/**
* This function returns an array of institution 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 institution_menu_items() {
return array();
}
/**
* This function returns an array of institution staff 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 institution_staff_menu_items() {
return array();
}
}
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