aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/hook/permit_hook.bb0
-rw-r--r--doc/hooklist.bb3
-rwxr-xr-xinclude/plugin.php19
3 files changed, 22 insertions, 0 deletions
diff --git a/doc/hook/permit_hook.bb b/doc/hook/permit_hook.bb
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/doc/hook/permit_hook.bb
diff --git a/doc/hooklist.bb b/doc/hooklist.bb
index 591c3cab0..1b48df6e6 100644
--- a/doc/hooklist.bb
+++ b/doc/hooklist.bb
@@ -469,6 +469,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/permissions_update]permissions_update[/zrl]
Called when a permissions refresh is transmitted
+[zrl=[baseurl]/help/hook/permit_hook]permit_hook[/zrl]
+ Called before a registered hook is actually executed to determine if it should be allowed or blocked
+
[zrl=[baseurl]/help/hook/personal_xrd]personal_xrd[/zrl]
Called when generating the personal XRD for "old webfinger" (Diaspora)
diff --git a/include/plugin.php b/include/plugin.php
index 9757be356..fdc62b3a7 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -458,6 +458,25 @@ function call_hooks($name, &$data = null) {
if (isset(App::$hooks[$name])) {
foreach(App::$hooks[$name] as $hook) {
+
+ if ($name != 'permit_hook') { // avoid looping
+ $checkhook = [
+ 'name'=>$name,
+ 'hook'=>$hook,
+ 'data'=>$data,
+ // Note: Since PHP uses COPY-ON-WRITE
+ // for variables, there is no cost to
+ // passing the $data structure (unless
+ // the permit_hook processors change the
+ // information it contains.
+ 'permit'=>true
+ ];
+ call_hooks('permit_hook',$checkhook);
+ if (!$checkhook['permit']) {
+ continue;
+ }
+ $data = $checkhook['data'];
+ }
$origfn = $hook[1];
if($hook[0])
@include_once($hook[0]);