Added no permission checking for special calls to hooks (mainly for admin and preferences)

This commit is contained in:
jengo 2001-09-03 23:02:36 +00:00
parent 3c633fcbc1
commit c1ebab8a82

View File

@ -945,7 +945,8 @@
@abstract hooking function which allows applications to 'hook' into each other @abstract hooking function which allows applications to 'hook' into each other
@discussion Someone flesh this out please @discussion Someone flesh this out please
*/ */
function hook($location, $order = '') // Note: $no_permission_check should *ONLY* be used when it *HAS* to be. (jengo)
function hook($location, $order = '', $no_permission_check = False)
{ {
global $phpgw, $phpgw_info; global $phpgw, $phpgw_info;
if ($order == '') if ($order == '')
@ -960,15 +961,34 @@
{ {
$f = PHPGW_SERVER_ROOT . '/' . $appname . '/inc/hook_' . $location . '.inc.php'; $f = PHPGW_SERVER_ROOT . '/' . $appname . '/inc/hook_' . $location . '.inc.php';
if (file_exists($f) && if (file_exists($f) &&
( $GLOBALS['phpgw_info']['user']['apps'][$appname] || ( ($location == 'preferences') && $appname) ) ) ( $GLOBALS['phpgw_info']['user']['apps'][$appname] || (($no_permission_check || $appname == 'preferences') && $appname)) )
{ {
//echo '<br>including: ' . $f;
include($f); include($f);
} }
$completed_hooks[$appname] = True; $completed_hooks[$appname] = True;
} }
/* Then add the rest */ /* Then add the rest */
if ($no_permission_check)
{
reset($GLOBALS['phpgw_info']['apps']);
while (list(,$p) = each($GLOBALS['phpgw_info']['apps']))
{
$appname = $p['name'];
if (! isset($completed_hooks[$appname]) || $completed_hooks[$appname] != True)
{
$f = PHPGW_SERVER_ROOT . '/' . $appname . '/inc/hook_' . $location . '.inc.php';
if (file_exists($f))
{
include($f);
}
} // if
} // while
} // if
else
{
reset ($GLOBALS['phpgw_info']['user']['apps']); reset ($GLOBALS['phpgw_info']['user']['apps']);
while (list(,$p) = each($GLOBALS['phpgw_info']['user']['apps'])) while (list(,$p) = each($GLOBALS['phpgw_info']['user']['apps']))
{ {
@ -980,9 +1000,10 @@
{ {
include($f); include($f);
} }
} } // if
} } // while
} } // if $no_permission_check
} // function
/*! /*!
@function hook_single @function hook_single
@ -990,7 +1011,8 @@
@param $location hook location - required @param $location hook location - required
@param $appname application name - optional @param $appname application name - optional
*/ */
function hook_single($location, $appname = '') // Note: $no_permission_check should *ONLY* be used when it *HAS* to be. (jengo)
function hook_single($location, $appname = '', $no_permission_check = False)
{ {
global $phpgw, $phpgw_info, $PHP_VERSION; global $phpgw, $phpgw_info, $PHP_VERSION;
if (! $appname) if (! $appname)
@ -1002,7 +1024,7 @@
/* First include the ordered apps hook file */ /* First include the ordered apps hook file */
$f = PHPGW_SERVER_ROOT . $SEP . $appname . $SEP . 'inc' . $SEP . 'hook_' . $location . '.inc.php'; $f = PHPGW_SERVER_ROOT . $SEP . $appname . $SEP . 'inc' . $SEP . 'hook_' . $location . '.inc.php';
if (file_exists($f) && if (file_exists($f) &&
( $GLOBALS['phpgw_info']['user']['apps'][$appname] || ( ($location == 'config') && $appname) ) ) ( $GLOBALS['phpgw_info']['user']['apps'][$appname] || (($no_permission_check || $location == 'config' || $appname == 'phpgwapi') && $appname)) )
{ {
include($f); include($f);
return True; return True;