diff options
author | Mario <mario@mariovavti.com> | 2021-12-17 14:59:25 +0100 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2021-12-17 14:59:25 +0100 |
commit | 220ed35f5855f22344d7a815da9bb1f6c96f1002 (patch) | |
tree | d8603dbf6eb8fef03d0df3c6bbf4aabdb27097e8 /Zotlabs/Widget | |
parent | b1cf5d4e441c6e86525dd0c955bd617e7e492309 (diff) | |
download | volse-hubzilla-220ed35f5855f22344d7a815da9bb1f6c96f1002.tar.gz volse-hubzilla-220ed35f5855f22344d7a815da9bb1f6c96f1002.tar.bz2 volse-hubzilla-220ed35f5855f22344d7a815da9bb1f6c96f1002.zip |
implement contact role deletion
Diffstat (limited to 'Zotlabs/Widget')
-rw-r--r-- | Zotlabs/Widget/Permcats.php | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/Zotlabs/Widget/Permcats.php b/Zotlabs/Widget/Permcats.php index 72c80ca0c..97ae6cba2 100644 --- a/Zotlabs/Widget/Permcats.php +++ b/Zotlabs/Widget/Permcats.php @@ -11,26 +11,25 @@ class Permcats { $pcat = new Permcat(local_channel()); $pcatlist = $pcat->listing(); - $list = '<b>Roles:</b><br>'; - $active = ''; - $active_role = ''; + if (!$pcatlist) { + return; + } - if($pcatlist) { - $i = 0; - foreach($pcatlist as $pc) { - if(argc() > 1) { - if($pc['name'] == hex2bin(argv(1))) { - $active = $i; - $active_role = $pc['name']; - } - } + $roles = []; + $active_role = ''; - $list .= '<a href="permcats/' . bin2hex($pc['name']) . '">' . $pc['localname'] . '</a><br>'; - $i++; + foreach($pcatlist as $pc) { + if (!$active_role) { + $active_role = ((argc() > 1 && $pc['name'] === hex2bin(argv(1))) ? $pc['name'] : ''); } + $roles[] = [ + 'name' => $pc['localname'], + 'url' => z_root() . '/permcats/' . bin2hex($pc['name']), + 'active' => (argc() > 1 && $pc['name'] === hex2bin(argv(1))) + ]; } - if(argc() > 1) { + if($active_role) { /* get role members based on permissions $test = $pcatlist[$active]['perms']; @@ -64,16 +63,28 @@ class Permcats { dbesc($active_role) ); - $members = '<b>Role members:</b><br>'; - $members .= '<div class="border rounded" style="height: 20rem; overflow: auto;">'; + $members = []; foreach ($r as $rr) { - $addr = (($rr['xchan_addr']) ? $rr['xchan_addr'] : $rr['xchan_url']); - $members .= '<a href="connections#' . $rr['abook_id'] . '" class="lh-sm border-bottom p-2 d-block text-truncate"><img src="' . $rr['xchan_photo_s'] . '" class="float-start rounded me-2" style="height: 2.2rem; width: 2.2rem;" loading="lazy">' . $rr['xchan_name'] . '<br><span class="text-muted small">' . $addr . '</span></a>'; + $members[] = [ + 'name' => $rr['xchan_name'], + 'addr' => (($rr['xchan_addr']) ? $rr['xchan_addr'] : $rr['xchan_url']), + 'url' => z_root() . '/connections#' . $rr['abook_id'], + 'photo' => $rr['xchan_photo_s'] + ]; } - $members .= '</div>'; } - return $list . '<br>' . $members. '<br>' . $others; + + $tpl = get_markup_template("permcats_widget.tpl"); + $o .= replace_macros($tpl, [ + '$roles_label' => t('Contact roles'), + '$members_label' => t('Role members'), + '$roles' => $roles, + '$members' => $members + + ]); + + return $o; } } |