summaryrefslogtreecommitdiff
path: root/inc/pluginutils.php
diff options
context:
space:
mode:
authorChristopher Smith <chris@jalakai.co.uk>2015-05-16 19:07:23 +0200
committerChristopher Smith <chris@jalakai.co.uk>2015-05-16 19:07:23 +0200
commita61966c55d9d0ac4b800d65cfc6ee1aea44899b5 (patch)
treeac4dc0bb88c5efe6e0fdcb834f3a185eb6741fe7 /inc/pluginutils.php
parentc248bda1dcbef2068071904057b8410aa1eb0200 (diff)
downloadrpg-a61966c55d9d0ac4b800d65cfc6ee1aea44899b5.tar.gz
rpg-a61966c55d9d0ac4b800d65cfc6ee1aea44899b5.tar.bz2
Provide a function to return admin plugin for the page request.
This was previously carried out in three separate places. Refactor that code to use the new function. Update tpl_pageTitle test to use a manager level admin plugin.
Diffstat (limited to 'inc/pluginutils.php')
-rw-r--r--inc/pluginutils.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/inc/pluginutils.php b/inc/pluginutils.php
index 4d591869d..60f79869f 100644
--- a/inc/pluginutils.php
+++ b/inc/pluginutils.php
@@ -103,3 +103,34 @@ function plugin_getcascade() {
global $plugin_controller;
return $plugin_controller->getCascade();
}
+
+
+/**
+ * Return the currently operating admin plugin or null
+ * if not on an admin plugin page
+ *
+ * @return Doku_Plugin_Admin
+ */
+function plugin_getRequestAdminPlugin(){
+ static $admin_plugin = false;
+ global $ACT,$INPUT,$INFO;
+
+ if ($admin_plugin === false) {
+ if (($ACT == 'admin') && ($page = $INPUT->str('page', '', true)) != '') {
+ $pluginlist = plugin_list('admin');
+ if (in_array($page, $pluginlist)) {
+ // attempt to load the plugin
+ /** @var $admin_plugin DokuWiki_Admin_Plugin */
+ $admin_plugin = plugin_load('admin', $page);
+ // verify
+ if ($admin_plugin && $admin_plugin->forAdminOnly() && !$INFO['isadmin']) {
+ $admin_plugin = null;
+ $INPUT->remove('page');
+ msg('For admins only',-1);
+ }
+ }
+ }
+ }
+
+ return $admin_plugin;
+}