diff options
author | Thomas Bruederli <thomas@roundcube.net> | 2014-08-27 14:37:39 +0200 |
---|---|---|
committer | Thomas Bruederli <thomas@roundcube.net> | 2014-08-27 14:37:52 +0200 |
commit | 64d49edd789047a4791230a24b512d170d946327 (patch) | |
tree | 697a901ddbbd49b3d32115318cfbd2e197e9278e /program/lib/Roundcube/rcube_plugin_api.php | |
parent | a873d934f56c3173fae671440094f71ee8eaf91d (diff) |
Maintain a stack of currently running plugin hooks
Diffstat (limited to 'program/lib/Roundcube/rcube_plugin_api.php')
-rw-r--r-- | program/lib/Roundcube/rcube_plugin_api.php | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/program/lib/Roundcube/rcube_plugin_api.php b/program/lib/Roundcube/rcube_plugin_api.php index dae3a936d..defccc94f 100644 --- a/program/lib/Roundcube/rcube_plugin_api.php +++ b/program/lib/Roundcube/rcube_plugin_api.php @@ -46,7 +46,7 @@ class rcube_plugin_api protected $actionmap = array(); protected $objectsmap = array(); protected $template_contents = array(); - protected $active_hook = false; + protected $exec_stack = array(); // Deprecated names of hooks, will be removed after 0.5-stable release protected $deprecated_hooks = array( @@ -423,8 +423,10 @@ class rcube_plugin_api $args = array('arg' => $args); } + // TODO: avoid recusion by checking in_array($hook, $this->exec_stack) ? + $args += array('abort' => false); - $this->active_hook = $hook; + array_push($this->exec_stack, $hook); foreach ((array)$this->handlers[$hook] as $callback) { $ret = call_user_func($callback, $args); @@ -437,7 +439,7 @@ class rcube_plugin_api } } - $this->active_hook = false; + array_pop($this->exec_stack); return $args; } @@ -573,7 +575,7 @@ class rcube_plugin_api */ public function is_processing($hook = null) { - return $this->active_hook && (!$hook || $this->active_hook == $hook); + return count($this->exec_stack) > 0 && (!$hook || in_array($hook, $this->exec_stack)); } /** |