diff options
Diffstat (limited to 'Zotlabs/Widget')
-rw-r--r-- | Zotlabs/Widget/Collections.php | 8 | ||||
-rw-r--r-- | Zotlabs/Widget/Conversations.php | 163 | ||||
-rw-r--r-- | Zotlabs/Widget/Mailmenu.php | 38 | ||||
-rw-r--r-- | Zotlabs/Widget/Messages.php | 2 | ||||
-rw-r--r-- | Zotlabs/Widget/Permcats.php | 96 | ||||
-rw-r--r-- | Zotlabs/Widget/Privacygroups.php | 55 | ||||
-rw-r--r-- | Zotlabs/Widget/Profile.php | 10 | ||||
-rw-r--r-- | Zotlabs/Widget/Settings_menu.php | 5 | ||||
-rw-r--r-- | Zotlabs/Widget/Tokens.php | 51 |
9 files changed, 219 insertions, 209 deletions
diff --git a/Zotlabs/Widget/Collections.php b/Zotlabs/Widget/Collections.php index bc9c812c6..ad1a10f4b 100644 --- a/Zotlabs/Widget/Collections.php +++ b/Zotlabs/Widget/Collections.php @@ -1,15 +1,15 @@ <?php namespace Zotlabs\Widget; - -require_once('include/group.php'); + +use Zotlabs\Lib\AccessList; class Collections { function widget($args) { if(argc() < 2) - return; + // return; $mode = ((array_key_exists('mode',$args)) ? $args['mode'] : 'conversation'); switch($mode) { @@ -49,6 +49,6 @@ class Collections { break; } - return group_side($every, $each, $edit, $current, $abook_id, $wmode); + return AccessList::widget($every, $each, $edit, $current, $abook_id, $wmode); } } diff --git a/Zotlabs/Widget/Conversations.php b/Zotlabs/Widget/Conversations.php deleted file mode 100644 index 3dc260b50..000000000 --- a/Zotlabs/Widget/Conversations.php +++ /dev/null @@ -1,163 +0,0 @@ -<?php - -namespace Zotlabs\Widget; - -class Conversations { - - function widget($arr) { - - if (! local_channel()) - return; - - switch(argv(1)) { - case 'inbox': - $mailbox = 'inbox'; - $header = t('Received Messages'); - break; - case 'outbox': - $mailbox = 'outbox'; - $header = t('Sent Messages'); - break; - default: - $mailbox = 'combined'; - $header = t('Conversations'); - break; - } - - $o = ''; - - // private_messages_list() can do other more complicated stuff, for now keep it simple - $r = self::private_messages_list(local_channel(), $mailbox, \App::$pager['start'], \App::$pager['itemspage']); - - if(! $r) { - info( t('No messages.') . EOL); - return $o; - } - - $messages = []; - - foreach($r as $rr) { - - $selected = ((argc() == 3) ? intval(argv(2)) == intval($rr['id']) : $r[0]['id'] == $rr['id']); - - $messages[] = [ - 'mailbox' => $mailbox, - 'id' => $rr['id'], - 'from_name' => $rr['from']['xchan_name'], - 'from_url' => chanlink_hash($rr['from_xchan']), - 'from_photo' => $rr['from']['xchan_photo_s'], - 'to_name' => $rr['to']['xchan_name'], - 'to_url' => chanlink_hash($rr['to_xchan']), - 'to_photo' => $rr['to']['xchan_photo_s'], - 'subject' => (($rr['seen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>'), - 'delete' => t('Delete conversation'), - 'body' => $rr['body'], - 'date' => datetime_convert('UTC',date_default_timezone_get(),$rr['created'], 'c'), - 'seen' => $rr['seen'], - 'selected' => ((argv(1) != 'new') ? $selected : '') - ]; - } - - $tpl = get_markup_template('mail_head.tpl'); - $o .= replace_macros($tpl, [ - '$header' => $header, - '$messages' => $messages - ]); - - return $o; - } - - function private_messages_list($uid, $mailbox = '', $start = 0, $numitems = 0) { - - $where = ''; - $limit = ''; - - $t0 = dba_timer(); - - if($numitems) - $limit = " LIMIT " . intval($numitems) . " OFFSET " . intval($start); - - if($mailbox !== '') { - $x = q("select channel_hash from channel where channel_id = %d limit 1", - intval($uid) - ); - - if(! $x) - return array(); - - $channel_hash = dbesc($x[0]['channel_hash']); - $local_channel = intval(local_channel()); - - switch($mailbox) { - - case 'inbox': - $sql = "SELECT * FROM mail WHERE channel_id = $local_channel AND from_xchan != '$channel_hash' ORDER BY created DESC $limit"; - break; - - case 'outbox': - $sql = "SELECT * FROM mail WHERE channel_id = $local_channel AND from_xchan = '$channel_hash' ORDER BY created DESC $limit"; - break; - - case 'combined': - default: - $parents = q("SELECT mail.parent_mid FROM mail LEFT JOIN conv ON mail.conv_guid = conv.guid WHERE mail.mid = mail.parent_mid AND mail.channel_id = %d ORDER BY conv.updated DESC $limit", - intval($local_channel) - ); - break; - } - - } - - $r = null; - - if($parents) { - foreach($parents as $parent) { - $all = q("SELECT * FROM mail WHERE parent_mid = '%s' AND channel_id = %d ORDER BY created DESC limit 1", - dbesc($parent['parent_mid']), - intval($local_channel) - ); - - if($all) { - foreach($all as $single) { - $r[] = $single; - } - } - } - } - elseif($sql) { - $r = q($sql); - } - - if(! $r) { - return array(); - } - - $chans = array(); - foreach($r as $rr) { - $s = "'" . dbesc(trim($rr['from_xchan'])) . "'"; - if(! in_array($s,$chans)) - $chans[] = $s; - $s = "'" . dbesc(trim($rr['to_xchan'])) . "'"; - if(! in_array($s,$chans)) - $chans[] = $s; - } - - $c = q("select * from xchan where xchan_hash in (" . protect_sprintf(implode(',',$chans)) . ")"); - - foreach($r as $k => $rr) { - $r[$k]['from'] = find_xchan_in_array($rr['from_xchan'],$c); - $r[$k]['to'] = find_xchan_in_array($rr['to_xchan'],$c); - $r[$k]['seen'] = intval($rr['mail_seen']); - if(intval($r[$k]['mail_obscured'])) { - if($r[$k]['title']) - $r[$k]['title'] = base64url_decode(str_rot47($r[$k]['title'])); - if($r[$k]['body']) - $r[$k]['body'] = base64url_decode(str_rot47($r[$k]['body'])); - } - } - - return $r; - } - -} - diff --git a/Zotlabs/Widget/Mailmenu.php b/Zotlabs/Widget/Mailmenu.php deleted file mode 100644 index ca022c807..000000000 --- a/Zotlabs/Widget/Mailmenu.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php - -namespace Zotlabs\Widget; - -class Mailmenu { - - function widget($arr) { - - if (! local_channel()) - return; - - return replace_macros(get_markup_template('message_side.tpl'), array( - '$title' => t('Private Mail Menu'), - '$combined' => array( - 'label' => t('Combined View'), - 'url' => z_root() . '/mail/combined', - 'sel' => (argv(1) == 'combined' || argc() == 1), - ), - '$inbox' => array( - 'label' => t('Inbox'), - 'url' => z_root() . '/mail/inbox', - 'sel' => (argv(1) == 'inbox'), - ), - '$outbox' => array( - 'label' => t('Outbox'), - 'url' => z_root() . '/mail/outbox', - 'sel' => (argv(1) == 'outbox'), - ), -/* - '$new' => array( - 'label' => t('New Message'), - 'url' => z_root() . '/mail/new', - 'sel'=> (argv(1) == 'new'), - ) -*/ - )); - } -} diff --git a/Zotlabs/Widget/Messages.php b/Zotlabs/Widget/Messages.php index c0fef9f75..71f4bd310 100644 --- a/Zotlabs/Widget/Messages.php +++ b/Zotlabs/Widget/Messages.php @@ -219,7 +219,7 @@ class Messages { $entries[$i]['info'] = ''; $entries[$i]['created'] = datetime_convert('UTC', date_default_timezone_get(), $notice['created']); $entries[$i]['summary'] = $summary; - $entries[$i]['b64mid'] = basename($notice['link']); + $entries[$i]['b64mid'] = (($notice['ntype'] & NOTIFY_INTRO) ? '' : basename($notice['link'])); $entries[$i]['href'] = (($notice['ntype'] & NOTIFY_INTRO) ? $notice['link'] : z_root() . '/hq/' . basename($notice['link'])); $entries[$i]['icon'] = (($notice['ntype'] & NOTIFY_INTRO) ? '<i class="fa fa-user-plus"></i>' : ''); diff --git a/Zotlabs/Widget/Permcats.php b/Zotlabs/Widget/Permcats.php new file mode 100644 index 000000000..a908f6220 --- /dev/null +++ b/Zotlabs/Widget/Permcats.php @@ -0,0 +1,96 @@ +<?php + +namespace Zotlabs\Widget; + +use Zotlabs\Lib\Permcat; +use Zotlabs\Access\PermissionLimits; + +class Permcats { + + function widget($arr) { + $pcat = new Permcat(local_channel()); + $pcatlist = $pcat->listing(); + + if (!$pcatlist) { + return; + } + + $roles = []; + $active_role = ''; + + 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($active_role) { + + $roles[] = [ + 'name' => '<i class="fa fa-plus"></i> ' . t('Add new role'), + 'url' => z_root() . '/permcats', + 'active' => '' + ]; + +/* get role members based on permissions + $test = $pcatlist[$active]['perms']; + + $role_sql = ''; + $count = 0; + foreach ($test as $t) { + $checkinherited = PermissionLimits::Get(local_channel(),$t['name']); + + if($checkinherited & PERMS_SPECIFIC) { + $role_sql .= "( abconfig.k = '" . dbesc($t['name']) . "' AND abconfig.v = '" . intval($t['value']) . "' ) OR "; + $count++; + } + } + + $role_sql = rtrim($role_sql, ' OR '); + + $r = q("SELECT abconfig.xchan, xchan.xchan_name, abook.abook_id FROM abconfig LEFT JOIN xchan on abconfig.xchan = xchan.xchan_hash LEFT JOIN abook ON abconfig.xchan = abook.abook_xchan WHERE xchan.xchan_deleted = 0 and abconfig.chan = %d AND abconfig.cat = 'my_perms' AND ( $role_sql ) GROUP BY abconfig.xchan HAVING count(abconfig.xchan) = %d ORDER BY xchan.xchan_name", + intval(local_channel()), + intval($count) + ); +*/ + + // get role members based on abook_role + + $r = q("SELECT abook.abook_id, abook.abook_role, xchan.xchan_name, xchan.xchan_addr, xchan.xchan_url, xchan.xchan_photo_s FROM abook + LEFT JOIN xchan on abook.abook_xchan = xchan.xchan_hash + WHERE abook.abook_channel = %d AND abook.abook_role = '%s' AND abook_self = 0 AND xchan_deleted = 0 + ORDER BY xchan.xchan_name", + intval(local_channel()), + dbesc($active_role) + ); + + $members = []; + + foreach ($r as $rr) { + $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'] + ]; + } + } + + $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; + + } +} diff --git a/Zotlabs/Widget/Privacygroups.php b/Zotlabs/Widget/Privacygroups.php new file mode 100644 index 000000000..a6b16c552 --- /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 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/Profile.php b/Zotlabs/Widget/Profile.php index 8bd624c0f..0e5444a56 100644 --- a/Zotlabs/Widget/Profile.php +++ b/Zotlabs/Widget/Profile.php @@ -2,12 +2,16 @@ namespace Zotlabs\Widget; +use App; class Profile { - function widget($args) { + if(!App::$profile['profile_uid']) { + return; + } + $block = observer_prohibited(); - return profile_sidebar(\App::$profile, $block, true, false); - } + return profile_sidebar(App::$profile, $block, true, false); + } } diff --git a/Zotlabs/Widget/Settings_menu.php b/Zotlabs/Widget/Settings_menu.php index 25b80a4b4..4d0f1d2dd 100644 --- a/Zotlabs/Widget/Settings_menu.php +++ b/Zotlabs/Widget/Settings_menu.php @@ -40,6 +40,11 @@ class Settings_menu { 'selected' => ((argv(1) === 'channel') ? 'active' : ''), ), + array( + 'label' => t('Privacy settings'), + 'url' => z_root().'/settings/privacy', + 'selected' => ((argv(1) === 'privacy') ? 'active' : '') + ) ); $tabs[] = array( 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; + + } +} |