hook() now checks user permissions BEFORE the hook is included

This commit is contained in:
jengo 2001-03-14 12:10:01 +00:00
parent f8304f1b3f
commit af81ed5a8a

View File

@ -715,38 +715,59 @@
return $e_password; return $e_password;
} }
function hook($location = '', $order = ''){ function hook($location = '', $order = '')
global $phpgw, $phpgw_info; {
if ($order == ''){$order[] = $phpgw_info['flags']['currentapp'];} global $phpgw, $phpgw_info;
/* First include the ordered apps hook file */ if ($order == '')
reset ($order); {
while (list (, $appname) = each ($order)){ $order[] = $phpgw_info['flags']['currentapp'];
$f = PHPGW_SERVER_ROOT . '/' . $appname . '/inc/hook_'.$phpgw_info['flags']['currentapp']; }
if ($location != '') {
$f .= '_'.$location.'.inc.php'; /* First include the ordered apps hook file */
} else { reset ($order);
$f .= '.inc.php'; while (list (, $appname) = each ($order))
} {
if (file_exists($f)) {include($f);} $f = PHPGW_SERVER_ROOT . '/' . $appname . '/inc/hook_'.$phpgw_info['flags']['currentapp'];
$completed_hooks[$appname] = True; if ($location != '')
} {
/* Then add the rest */ $f .= '_'.$location.'.inc.php';
reset ($phpgw_info['user']['apps']); }
while ($permission = each($phpgw_info['user']['apps'])) { else
if ($completed_hooks[$permission[0]] != True){ {
$appname = $permission[0]; $f .= '.inc.php';
$f = PHPGW_SERVER_ROOT . '/' . $permission[0] . '/inc/hook_'.$phpgw_info['flags']['currentapp']; }
if ($location != '') {
$f .= '_'.$location.'.inc.php'; if (file_exists($f) && $phpgw_info['user']['apps'][$appname])
} else { {
$f .= '.inc.php'; include($f);
} }
if (file_exists($f)) { $completed_hooks[$appname] = True;
include($f); }
}
} /* Then add the rest */
} reset ($phpgw_info['user']['apps']);
} while ($permission = each($phpgw_info['user']['apps']))
{
if ($completed_hooks[$permission[0]] != True)
{
$appname = $permission[0];
$f = PHPGW_SERVER_ROOT . '/' . $permission[0] . '/inc/hook_'.$phpgw_info['flags']['currentapp'];
if ($location != '')
{
$f .= '_'.$location.'.inc.php';
}
else
{
$f .= '.inc.php';
}
if (file_exists($f) && $phpgw_info['user']['apps'][$appname])
{
include($f);
}
}
}
}
function hook_single($location = '', $appname = '') function hook_single($location = '', $appname = '')
{ {