This is just a quick post to introduce a pair of functions I wrote today while working on some of the Elgg 1.0 access control code.
call_gatekeeper($function, $file = "") and
callpath_gatekeeper($path, $include_subdirs = true), both of which return a boolean value.
This function tests to see whether it has the given method/function (optionally also test that it is defined in a specified file) exists on the call stack.
The function will return
true if the called by the named function (or its parent was called by the named function).
Here is an example of its usage:
... do secure stuff ...
// will work
// Will not work
To specify a method instead of a function, pass an array to
$function containing the classname and method name.
This function is similar to
call_gatekeeper() but returns
true if it is being called by a method or function which has been defined on a given path or by a specified file.
The function accepts two parameters:
$path, which is either the full path of the desired file or a partial path. If a partial path is given and
true, then the function will return
true if called by any function in or below the specified path.