Index: trunk/globals.php =================================================================== diff -u -r4596 -r4698 --- trunk/globals.php (.../globals.php) (revision 4596) +++ trunk/globals.php (.../globals.php) (revision 4698) @@ -2053,5 +2053,29 @@ } return GetVar($field_name); } + + function checkActionPermission($action_mapping, $action) + { + $application =& kApplication::Instance(); + + if (!isset($action_mapping[$action])) { + // if no permission mapping defined, then action is allowed in any case + return true; + } + + $perm_status = false; + $action_mapping = explode('|', $action_mapping[$action]); + foreach ($action_mapping as $perm_name) { + $perm_status = $application->CheckPermission($perm_name, 1); + if ($perm_status) { + break; + } + } + + if (!$perm_status) { + $application->Redirect($application->IsAdmin() ? 'no_permission' : $application->ConfigValue('NoPermissionTemplate'), null, '', 'index.php'); + } + return true; + } ?>