Merge branch 'patch-20190113c' into 'dev'

Hooks to allow addons to add "extras" to privacy group settings edit page.

See merge request hubzilla/core!1469
This commit is contained in:
Mario 2019-01-14 10:29:48 +01:00
commit a8a5d2fc4e
6 changed files with 57 additions and 1 deletions

View File

@ -75,6 +75,10 @@ class Group extends Controller {
);
if($r)
info( t('Privacy group updated.') . EOL );
$hookinfo = [ 'pgrp_extras' => '', 'group'=>$group['id'] ];
call_hooks ('privacygroup_extras_post',$hookinfo);
build_sync_packet(local_channel(),null,true);
}
@ -127,6 +131,10 @@ class Group extends Controller {
$i++;
}
$hookinfo = [ 'pgrp_extras' => '', 'group'=>argv(1) ];
call_hooks ('privacygroup_extras',$hookinfo);
$pgrp_extras = $hookinfo['pgrp_extras'];
$tpl = get_markup_template('privacy_groups.tpl');
$o = replace_macros($tpl, [
'$title' => t('Privacy Groups'),
@ -136,6 +144,7 @@ class Group extends Controller {
// new group form
'$gname' => array('groupname',t('Privacy group name')),
'$public' => array('public',t('Members are visible to other channels'), false),
'$pgrp_extras' => $pgrp_extras,
'$form_security_token' => get_form_security_token("group_edit"),
'$submit' => t('Submit'),
@ -166,8 +175,11 @@ class Group extends Controller {
);
if($r)
$result = group_rmv(local_channel(),$r[0]['gname']);
if($result)
if($result) {
$hookinfo = [ 'pgrp_extras' => '', 'group'=>$argv(2) ];
call_hooks ('privacygroup_extras_drop',$hookinfo);
info( t('Privacy group removed.') . EOL);
}
else
notice( t('Unable to remove privacy group.') . EOL);
}

View File

@ -0,0 +1,12 @@
[h2]privacygroup_extras[/h2]
Add items to the Privacy Group edit form
[code]
$hookinfo = [ 'pgrp_extras' => '', 'group'=>$argv(1) ];
call_hooks ('privacygroup_extras',$hookinfo);
$pgrp_extras = $hookinfo['pgrp_extras'];
[/code]
see: Zotlabs/Module/Group.php
see: view/tpl/privacy_groups.tpl

View File

@ -0,0 +1,11 @@
[h2]privacygroup_extras_drop[/h2]
Called after privacy group is dropped
[code]
$hookinfo = [ 'pgrp_extras' => '', 'group'=>$argv(2) ];
call_hooks ('privacygroup_extras_drop',$hookinfo);
[/code]
see: Zotlabs/Module/Group.php
see: view/tpl/privacy_groups.tpl

View File

@ -0,0 +1,11 @@
[h2]privacygroup_extras_post[/h2]
Called as privacy group edit form is edited.
[code]
$hookinfo = [ 'pgrp_extras' => '', 'group'=>$group['id'] ];
call_hooks ('privacygroup_extras_post',$hookinfo);
[/code]
see: Zotlabs/Module/Group.php
see: view/tpl/privacy_groups.tpl

View File

@ -559,6 +559,15 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/prepare_body_init]prepare_body_init[/zrl]
Called before generating the HTML for a displayed conversation item
[zrl=[baseurl]/help/hook/privacygroup_extras]privacygroup_extras[/zrl]
Called before generating the HTML for the Privacy Group edit options
[zrl=[baseurl]/help/hook/privacygroup_extras_delete]privacygroup_extras_delete[/zrl]
Called after privacy group is dropped.
[zrl=[baseurl]/help/hook/privacygroup_extras_post]privacygroup_extras_post[/zrl]
Called when privacy group edit form is submitted.
[zrl=[baseurl]/help/hook/proc_run]proc_run[/zrl]
Called when invoking PHP sub processes

View File

@ -8,6 +8,7 @@
<input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
{{include file="field_input.tpl" field=$gname}}
{{include file="field_checkbox.tpl" field=$public}}
{{$pgrp_extras}}
<button type="submit" name="submit" class="btn btn-sm btn-primary float-right">{{$submit}}</button>
</form>
</div>