summaryrefslogtreecommitdiff
path: root/inc/pluginutils.php
diff options
context:
space:
mode:
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;
+}