summaryrefslogtreecommitdiff
path: root/roundcubemail/program/include/rcube_plugin_api.php
diff options
context:
space:
mode:
authorthomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c>2009-07-13 18:52:15 +0000
committerthomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c>2009-07-13 18:52:15 +0000
commitb62727725c9a533cdf4e7935155d7b3d1369ce81 (patch)
tree88fb8b384dbe059c3cbd8ae658f1c0d84cb72baf /roundcubemail/program/include/rcube_plugin_api.php
parenteac66f0194d5e0566787cc815488333f2f51d500 (diff)
Prevent from endless loops in render_page hook
git-svn-id: https://svn.roundcube.net/trunk@2743 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/include/rcube_plugin_api.php')
-rw-r--r--roundcubemail/program/include/rcube_plugin_api.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/roundcubemail/program/include/rcube_plugin_api.php b/roundcubemail/program/include/rcube_plugin_api.php
index 381b36ff8..b05758a3f 100644
--- a/roundcubemail/program/include/rcube_plugin_api.php
+++ b/roundcubemail/program/include/rcube_plugin_api.php
@@ -39,7 +39,8 @@ class rcube_plugin_api
private $objectsmap = array();
private $template_contents = array();
- private $required_plugins = array('filesystem_attachments');
+ private $required_plugins = array('filesystem_attachments');
+ private $active_hook = false;
/**
* This implements the 'singleton' design pattern
@@ -179,6 +180,7 @@ class rcube_plugin_api
public function exec_hook($hook, $args = array())
{
$args += array('abort' => false);
+ $this->active_hook = $hook;
foreach ((array)$this->handlers[$hook] as $callback) {
$ret = call_user_func($callback, $args);
@@ -189,6 +191,7 @@ class rcube_plugin_api
break;
}
+ $this->active_hook = false;
return $args;
}
@@ -257,6 +260,19 @@ class rcube_plugin_api
}
}
+
+ /**
+ * Check if a plugin hook is currently processing.
+ * Mainly used to prevent loops and recursion.
+ *
+ * @param string Hook to check (optional)
+ * @return boolean True if any/the given hook is currently processed, otherwise false
+ */
+ public function is_processing($hook = null)
+ {
+ return $this->active_hook && (!$hook || $this->active_hook == $hook);
+ }
+
/**
* Include a plugin script file in the current HTML page
*/