diff options
-rw-r--r-- | Zotlabs/Widget/Privacygroups.php | 55 | ||||
-rw-r--r-- | Zotlabs/Widget/Tokens.php | 51 | ||||
-rw-r--r-- | view/tpl/widget_menu_count.tpl | 13 |
3 files changed, 119 insertions, 0 deletions
diff --git a/Zotlabs/Widget/Privacygroups.php b/Zotlabs/Widget/Privacygroups.php new file mode 100644 index 000000000..74ce02ccd --- /dev/null +++ b/Zotlabs/Widget/Privacygroups.php @@ -0,0 +1,55 @@ +<?php + +namespace Zotlabs\Widget; + +use Zotlabs\Lib\AccessList; + +class Privacygroups { + + function widget($arr) { + + $o = ''; + + $groups = q("SELECT id, gname FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", + intval(local_channel()) + ); + + if (!$groups) { + return $o; + } + + $menu_items = []; + $z_root = z_root(); + $active = argv(1) ?? ''; + + foreach($groups as $group) { + $menu_items[] = [ + 'href' => $z_root . '/group/' . $group['id'], + 'label' => $group['gname'], + 'title' => '', + 'active' => ($active === $group['id']), + 'count' => count(AccessList::members(local_channel(), $group['id'])) + ]; + } + + if ($active) { + $menu_items[] = [ + 'href' => $z_root . '/group', + 'label' => '<i class="fa fa-plus"></i> ' . t('Add new privacy group'), + 'title' => '', + 'active' => '', + 'count' => '' + ]; + } + + $tpl = get_markup_template("widget_menu_count.tpl"); + $o .= replace_macros($tpl, [ + '$title' => t('Privacy groups'), + '$menu_items' => $menu_items, + + ]); + + return $o; + + } +} diff --git a/Zotlabs/Widget/Tokens.php b/Zotlabs/Widget/Tokens.php new file mode 100644 index 000000000..8c31003fc --- /dev/null +++ b/Zotlabs/Widget/Tokens.php @@ -0,0 +1,51 @@ +<?php + +namespace Zotlabs\Widget; + +class Tokens { + + function widget($arr) { + + $o = ''; + + $tokens = q("SELECT atoken_id, atoken_name FROM atoken WHERE atoken_uid = %d", + intval(local_channel()) + ); + + if (!$tokens) { + return $o; + } + + $menu_items = []; + $z_root = z_root(); + $active = argv(1) ?? ''; + + foreach($tokens as $token) { + $menu_items[] = [ + 'href' => $z_root . '/tokens/' . $token['atoken_id'], + 'label' => $token['atoken_name'], + 'title' => '', + 'active' => ($active === $token['atoken_id']) + ]; + } + + if ($active) { + $menu_items[] = [ + 'href' => $z_root . '/tokens', + 'label' => '<i class="fa fa-plus"></i> ' . t('Add new guest'), + 'title' => '', + 'active' => '' + ]; + } + + $tpl = get_markup_template("widget_menu.tpl"); + $o .= replace_macros($tpl, [ + '$title' => t('Guest access'), + '$menu_items' => $menu_items, + + ]); + + return $o; + + } +} diff --git a/view/tpl/widget_menu_count.tpl b/view/tpl/widget_menu_count.tpl new file mode 100644 index 000000000..ed70d3295 --- /dev/null +++ b/view/tpl/widget_menu_count.tpl @@ -0,0 +1,13 @@ +<div class="widget"> + <h3>{{$title}}</h3> + <ul class="nav nav-pills flex-column"> + {{foreach $menu_items as $menu_item}} + <li class="nav-item"> + <a class="nav-link {{if $menu_item.active}} active{{/if}}" href="{{$menu_item.href}}" title="{{$menu_item.title}}"> + {{$menu_item.label}} + <span class="badge bg-secondary float-end">{{$menu_item.count}}</span> + </a> + <li> + {{/foreach}} + </ul> +</div> |