add hook: permit_hook

This commit is contained in:
M.Dent (DM42.Net) 2018-09-19 21:54:46 -04:00
parent 34fec995f7
commit 456fe71ca9
3 changed files with 22 additions and 7 deletions

0
doc/hook/permit_hook.bb Normal file
View File

View File

@ -457,6 +457,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] [zrl=[baseurl]/help/hook/permissions_update]permissions_update[/zrl]
Called when a permissions refresh is transmitted 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] [zrl=[baseurl]/help/hook/personal_xrd]personal_xrd[/zrl]
Called when generating the personal XRD for "old webfinger" (Diaspora) Called when generating the personal XRD for "old webfinger" (Diaspora)

View File

@ -458,6 +458,18 @@ function call_hooks($name, &$data = null) {
if (isset(App::$hooks[$name])) { if (isset(App::$hooks[$name])) {
foreach(App::$hooks[$name] as $hook) { foreach(App::$hooks[$name] as $hook) {
if ($name != 'permit_hook') { // avoid looping
$checkhook = [
'name'=>$name,
'hook'=>$hook,
'permit'=>true
];
call_hooks('permit_hook',$checkhook);
if (!$checkhook['permit']) {
continue;
}
}
$origfn = $hook[1]; $origfn = $hook[1];
if($hook[0]) if($hook[0])
@include_once($hook[0]); @include_once($hook[0]);