allow hooks to send redirects via Exception\Redirect, thought only first redirect will be executed, if there are multiple hooks

This commit is contained in:
Ralf Becker 2017-04-19 10:42:38 +02:00
parent 254ca19c2d
commit a468c57284

View File

@ -114,7 +114,7 @@ class Hooks
return false;
}
$ret = array();
$ret = $redirects = array();
foreach((array)self::$locations[$location][$appname] as $hook)
{
try {
@ -143,11 +143,24 @@ class Hooks
$ret[] = ExecMethod2($hook, $args);
}
}
catch (Exception\Redirect $e)
{
$redirects[] = $e;
}
catch (\Exception $e) {
_egw_log_exception($e);
}
}
if ($redirects)
{
if (count($redirects) > 1)
{
error_log("Multiple redirects for location '$location', only first one gets executed!");
}
throw $redirects[0];
}
// hooks only existing in filesystem used by setup
if (!$ret && $try_unregistered && file_exists(EGW_SERVER_ROOT.($hook='/'.$appname.'/inc/hook_'.$location.'.inc.php')))
{