blob: 08fe676807b110aea2a1054122bc658edf3c80b5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
<?php
/**
* * Name: Tokens
* * Description: Display a menu with links to existing guest access tokens
* * Requires: tokens
*/
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="bi bi-plus-lg"></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;
}
}
|