diff options
-rw-r--r-- | Zotlabs/Module/Ping.php | 96 | ||||
-rw-r--r-- | Zotlabs/Module/Settings/Channel.php | 3 | ||||
-rw-r--r-- | Zotlabs/Widget/Activity_filter.php | 48 | ||||
-rw-r--r-- | Zotlabs/Widget/Notifications.php | 8 | ||||
-rwxr-xr-x | boot.php | 1 | ||||
-rw-r--r-- | include/features.php | 13 | ||||
-rw-r--r-- | include/nav.php | 6 | ||||
-rw-r--r-- | include/text.php | 54 | ||||
-rw-r--r-- | view/js/main.js | 22 | ||||
-rw-r--r-- | view/pdl/mod_network.pdl | 3 | ||||
-rw-r--r-- | view/theme/redbasic/css/style.css | 8 | ||||
-rwxr-xr-x | view/tpl/common_pills.tpl | 3 | ||||
-rw-r--r-- | view/tpl/notifications_widget.tpl | 14 | ||||
-rwxr-xr-x | view/tpl/settings.tpl | 1 |
14 files changed, 191 insertions, 89 deletions
diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index a43d9863e..3f2015d6d 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -35,11 +35,12 @@ class Ping extends \Zotlabs\Web\Controller { $result['birthdays_today'] = 0; $result['all_events'] = 0; $result['all_events_today'] = 0; - $result['notice'] = array(); - $result['info'] = array(); + $result['notice'] = []; + $result['info'] = []; $result['pubs'] = 0; $result['files'] = 0; $result['forums'] = 0; + $result['forums_sub'] = []; if(! $_SESSION['static_loadtime']) $_SESSION['static_loadtime'] = datetime_convert(); @@ -625,62 +626,51 @@ class Ping extends \Zotlabs\Web\Controller { -#### unseen forum + if($vnotify & VNOTIFY_FORUMS) { + $forums = get_forum_channels(local_channel()); - $perms_sql = item_permissions_sql(local_channel()) . item_normal(); - - $xf = false; - - $x1 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'send_stream' and v = '0'", - intval(local_channel()) - ); - if($x1) { - $xc = ids_to_querystr($x1,'xchan',true); - - $x2 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'tag_deliver' and v = '1' and xchan in (" . $xc . ") ", - intval(local_channel()) - ); - - if($x2) { - $xf = ids_to_querystr($x2,'xchan',true); - - // private forums - $x3 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'post_wall' and v = '1' and xchan in (" . $xc . ") and not xchan in (" . $xf . ") ", - intval(local_channel()) - ); - if($x3) { - $xf = ids_to_querystr(array_merge($x2,$x3),'xchan',true); - } + if(! $forums) { + $result['forums'] = 0; } - } - - $sql_extra = (($xf) ? " and ( xchan_hash in (" . $xf . ") or xchan_pubforum = 1 ) " : " and xchan_pubforum = 1 "); - - $r1 = q("select abook_id, xchan_hash, xchan_name, xchan_url, xchan_photo_s from abook left join xchan on abook_xchan = xchan_hash where xchan_deleted = 0 and abook_channel = %d and abook_pending = 0 and abook_ignored = 0 and abook_blocked = 0 $sql_extra order by xchan_name", - intval(local_channel()) - ); + else { + $fcount = count($forums); + $forums['total'] = 0; + for($x = 0; $x < $fcount; $x ++) { + $r = q("select sum(item_unseen) as unseen from item + where uid = %d and owner_xchan = '%s' and item_unseen = 1 $perms_sql ", + intval(local_channel()), + dbesc($forums[$x]['xchan_hash']) + ); + if($r[0]['unseen']) { + $forums[$x]['notify_link'] = (($forums[$x]['private_forum']) ? $forums[$x]['xchan_url'] :z_root() . '/network/?f=&cid=' . $forums[$x]['abook_id']); + $forums[$x]['name'] = $forums[$x]['xchan_name']; + $forums[$x]['url'] = $forums[$x]['xchan_url']; + $forums[$x]['photo'] = $forums[$x]['xchan_photo_s']; + $forums[$x]['unseen'] = $r[0]['unseen']; + $forums[$x]['private_forum'] = (($forums[$x]['private_forum']) ? 'lock' : ''); + $forums[$x]['message'] = (($forums[$x]['private_forum']) ? t('Private forum') : t('Public forum')); + + $forums['total'] = $forums['total'] + $r[0]['unseen']; + + unset($forums[$x]['abook_id']); + unset($forums[$x]['xchan_hash']); + unset($forums[$x]['xchan_name']); + unset($forums[$x]['xchan_url']); + unset($forums[$x]['xchan_photo_s']); + + //if($forums[$x]['private_forum']) + // unset($forums[$x]['private_forum']); - if(! $r1) { - $result['forums'] = 0; - } - else { - $fcount = count($r1); - $r1['total'] = 0; - for($x = 0; $x < $fcount; $x ++) { - $r = q("select sum(item_unseen) as unseen from item - where uid = %d and owner_xchan = '%s' and item_unseen = 1 $perms_sql ", - intval(local_channel()), - dbesc($r1[$x]['xchan_hash']) - ); - if($r[0]['unseen']) { - $r1[$x]['unseen'] = $r[0]['unseen']; - $r1['total'] = $r1['total'] + $r[0]['unseen']; - } - else { - unset($r1[$x]); + } + else { + unset($forums[$x]); + } } + $result['forums'] = $forums['total']; + unset($forums['total']); + + $result['forums_sub'] = $forums; } - $result['forums'] = $r1['total']; } $x = json_encode($result); diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php index beb62a3a3..3a6e03588 100644 --- a/Zotlabs/Module/Settings/Channel.php +++ b/Zotlabs/Module/Settings/Channel.php @@ -215,6 +215,8 @@ class Channel { $vnotify += intval($_POST['vnotify13']); if(x($_POST,'vnotify14')) $vnotify += intval($_POST['vnotify14']); + if(x($_POST,'vnotify15')) + $vnotify += intval($_POST['vnotify15']); $always_show_in_notices = x($_POST,'always_show_in_notices') ? 1 : 0; @@ -599,6 +601,7 @@ class Channel { '$vnotify12' => array('vnotify12', t('Unseen shared files'), ($vnotify & VNOTIFY_FILES), VNOTIFY_FILES, '', $yes_no), '$vnotify13' => (($disable_discover_tab && !$site_firehose) ? array() : array('vnotify13', t('Unseen public activity'), ($vnotify & VNOTIFY_PUBS), VNOTIFY_PUBS, '', $yes_no)), '$vnotify14' => array('vnotify14', t('Unseen likes and dislikes'), ($vnotify & VNOTIFY_LIKE), VNOTIFY_LIKE, '', $yes_no), + '$vnotify15' => array('vnotify15', t('Unseen forum posts'), ($vnotify & VNOTIFY_FORUMS), VNOTIFY_FORUMS, '', $yes_no), '$mailhost' => [ 'mailhost', t('Email notification hub (hostname)'), get_pconfig(local_channel(),'system','email_notify_host',\App::get_hostname()), sprintf( t('If your channel is mirrored to multiple hubs, set this to your preferred location. This will prevent duplicate email notifications. Example: %s'),\App::get_hostname()) ], '$always_show_in_notices' => array('always_show_in_notices', t('Show new wall posts, private messages and connections under Notices'), $always_show_in_notices, 1, '', $yes_no), diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index a123b739a..f9993759c 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -25,7 +25,7 @@ class Activity_filter { 'icon' => 'user-circle', 'url' => z_root() . '/' . $cmd . '/?f=&conv=1', 'sel' => $conv_active, - 'title' => t('Show posts that mention or involve me'), + 'title' => t('Show posts that mention or involve me') ]; } @@ -40,7 +40,7 @@ class Activity_filter { 'icon' => 'star', 'url'=>z_root() . '/' . $cmd . '/?f=&star=1', 'sel'=>$starred_active, - 'title' => t('Show posts that i have starred'), + 'title' => t('Show posts that i have starred') ]; } @@ -60,7 +60,7 @@ class Activity_filter { 'icon' => '', 'url' => z_root() . '/' . $cmd . '/?f=&gid=' . $g['id'], 'sel' => $group_active, - 'title' => sprintf(t('Show posts related to the %s privacy group'), $g['gname']), + 'title' => sprintf(t('Show posts related to the %s privacy group'), $g['gname']) ]; } $tabs[] = [ @@ -93,7 +93,7 @@ class Activity_filter { 'icon' => '', 'url' => z_root() . '/' . $cmd . '/?f=&file=' . $t['term'], 'sel' => $file_active, - 'title' => '', + 'title' => '' ]; } @@ -109,6 +109,38 @@ class Activity_filter { } } + if(feature_enabled(local_channel(),'forums_tab')) { + $forums = get_forum_channels(local_channel()); + + if($forums) { + foreach($forums as $f) { + if(x($_GET,'cid')) { + $forum_active = (($_GET['cid'] == $f['abook_id']) ? 'active' : ''); + $filter_active = 'forums'; + } + $fsub[] = [ + 'label' => $f['xchan_name'], + 'img' => $f['xchan_photo_s'], + 'url' => (($f['private_forum']) ? $f['xchan_url'] : z_root() . '/' . $cmd . '/?f=&cid=' . $f['abook_id']), + 'sel' => $forum_active, + 'title' => t('Private forum'), + 'lock' => (($f['private_forum']) ? 'lock' : '') + ]; + } + + $tabs[] = [ + 'label' => t('Forums'), + 'icon' => 'comments-o', + 'url' => '#', + 'sel' => (($filter_active == 'forums') ? true : false), + 'title' => t('Show this forums posts'), + 'sub' => $fsub + + ]; + } + } + + if(x($_GET,'search')) { $filter_active = 'search'; $tabs[] = [ @@ -116,7 +148,7 @@ class Activity_filter { 'icon' => 'search', 'url' => z_root() . '/' . $cmd . '/?f=&search=' . $_GET['search'], 'sel' => 'active disabled', - 'title' => t('Panel search'), + 'title' => t('Panel search') ]; } @@ -127,7 +159,7 @@ class Activity_filter { 'icon' => 'remove', 'url'=> z_root() . '/' . $cmd, 'sel'=> '', - 'title' => t('Remove active filter'), + 'title' => t('Remove active filter') ]; } @@ -139,13 +171,13 @@ class Activity_filter { if($arr['tabs']) { $content = replace_macros(get_markup_template('common_pills.tpl'), [ - '$pills' => $arr['tabs'], + '$pills' => $arr['tabs'] ]); $o .= replace_macros(get_markup_template('activity_filter_widget.tpl'), [ '$title' => t('Activity Filters'), '$reset' => $reset, - '$content' => $content, + '$content' => $content ]); } diff --git a/Zotlabs/Widget/Notifications.php b/Zotlabs/Widget/Notifications.php index 1be467ba6..a4cf4e706 100644 --- a/Zotlabs/Widget/Notifications.php +++ b/Zotlabs/Widget/Notifications.php @@ -118,12 +118,8 @@ class Notifications { 'severity' => 'secondary', 'label' => t('Forums'), 'title' => t('Forums'), - 'viewall' => [ - //'url' => 'notifications/system', - //'label' => t('View all notices') - ], - 'markall' => [ - //'label' => t('Mark all notices seen') + 'filter' => [ + 'name_label' => t('Filter by name') ] ]; } @@ -405,6 +405,7 @@ define ( 'VNOTIFY_REGISTER', 0x0400 ); define ( 'VNOTIFY_FILES', 0x0800 ); define ( 'VNOTIFY_PUBS', 0x1000 ); define ( 'VNOTIFY_LIKE', 0x2000 ); +define ( 'VNOTIFY_FORUMS', 0x4000 ); diff --git a/include/features.php b/include/features.php index 3d3e41a05..bcdea73e0 100644 --- a/include/features.php +++ b/include/features.php @@ -395,9 +395,18 @@ function get_features($filtered = true, $level = (-1)) { ], [ + 'forums_tab', + t('Forum Filter'), + t('Ability to display only posts of a specific forum'), + false, + get_config('feature_lock','forums_tab'), + feature_level('forums_tab',1), + ], + + [ 'personal_tab', - t('Network Personal Tab'), - t('Enable tab to display only Network posts that you\'ve interacted on'), + t('Personal Posts Filter'), + t('Ability to display only Network posts that you\'ve interacted on'), false, get_config('feature_lock','personal_tab'), feature_level('personal_tab',1), diff --git a/include/nav.php b/include/nav.php index d83337481..5642f438f 100644 --- a/include/nav.php +++ b/include/nav.php @@ -91,10 +91,10 @@ function nav($template = 'default') { if(local_channel()) { if(! $_SESSION['delegate']) { - $nav['manage'] = array('manage', t('Manage Channels'), "", t('Manage your channels'),'manage_nav_btn'); + $nav['manage'] = array('manage', t('Channel Manager'), "", t('Manage your channels'),'manage_nav_btn'); } - - $nav['group'] = array('group', t('Manage Privacy Groups'),"", t('Add and edit privacy groups'),'group_nav_btn'); + if(feature_enabled(local_channel(),'groups')) + $nav['group'] = array('group', t('Privacy Groups'),"", t('Manage your privacy groups'),'group_nav_btn'); $nav['settings'] = array('settings', t('Settings'),"", t('Account/Channel Settings'),'settings_nav_btn'); diff --git a/include/text.php b/include/text.php index 319de67a8..7c519eb64 100644 --- a/include/text.php +++ b/include/text.php @@ -3335,22 +3335,54 @@ function unique_multidim_array($array, $key) { return $temp_array; } -function network_qstring($req) { +function get_forum_channels($uid) { - $ret = '?f='; + if(! $uid) + return; + + $perms_sql = item_permissions_sql($uid) . item_normal(); - if(x($req, 'cid')) - $ret .= '&cid=' . $req['cid']; + $xf = false; - if(x($req, 'gid')) - $ret .= '&gid=' . $req['gid']; + $x1 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'send_stream' and v = '0'", + intval($uid) + ); + if($x1) { + $xc = ids_to_querystr($x1,'xchan',true); - if(x($req, 'star')) - $ret .= '&star=' . $req['star']; + $x2 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'tag_deliver' and v = '1' and xchan in (" . $xc . ") ", + intval($uid) + ); - if(x($req, 'conv')) - $ret .= '&conv=' . $req['conv']; + if($x2) { + $xf = ids_to_querystr($x2,'xchan',true); - return $ret; + // private forums + $x3 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'post_wall' and v = '1' and xchan in (" . $xc . ") and not xchan in (" . $xf . ") ", + intval(local_channel()) + ); + if($x3) { + $xf = ids_to_querystr(array_merge($x2,$x3),'xchan',true); + } + } + } + + $sql_extra = (($xf) ? " and ( xchan_hash in (" . $xf . ") or xchan_pubforum = 1 ) " : " and xchan_pubforum = 1 "); + + $r = q("select abook_id, xchan_hash, xchan_name, xchan_url, xchan_photo_s from abook left join xchan on abook_xchan = xchan_hash where xchan_deleted = 0 and abook_channel = %d and abook_pending = 0 and abook_ignored = 0 and abook_blocked = 0 $sql_extra order by xchan_name", + intval($uid) + ); + + for($x = 0; $x < count($r); $x ++) { + if($x3) { + foreach($x3 as $xx) { + if($r[$x]['xchan_hash'] == $xx['xchan']) { + $r[$x]['private_forum'] = 1; + } + } + } + } + + return $r; } diff --git a/view/js/main.js b/view/js/main.js index 63ab938f0..45c412296 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -420,6 +420,14 @@ function notificationsUpdate(cached_data) { // Put the object into storage sessionStorage.setItem('notifications_cache', JSON.stringify(data)); + var fnotifs = []; + if(data.forums) { + $.each(data.forums_sub, function() { + fnotifs.push(this); + }); + handleNotificationsItems('forums', fnotifs); + } + if(data.invalid == 1) { window.location.href=window.location.href; } @@ -495,13 +503,13 @@ function handleNotifications(data) { } function handleNotificationsItems(notifyType, data) { - var notifications_tpl= unescape($("#nav-notifications-template[rel=template]").html()); + var notifications_tpl = ((notifyType == 'forums') ? unescape($("#nav-notifications-forums-template[rel=template]").html()) : unescape($("#nav-notifications-template[rel=template]").html())); var notify_menu = $("#nav-" + notifyType + "-menu"); notify_menu.html(''); $(data).each(function() { - html = notifications_tpl.format(this.notify_link,this.photo,this.name,this.message,this.when,this.hclass,this.b64mid,this.notify_id,this.thread_top); + html = notifications_tpl.format(this.notify_link,this.photo,this.name,this.message,this.when,this.hclass,this.b64mid,this.notify_id,this.thread_top,this.unseen,this.private_forum); notify_menu.append(html); }); @@ -812,6 +820,15 @@ function updateInit() { if (initialLoad && (sessionStorage.getItem('notifications_cache') !== null)) { var cached_data = JSON.parse(sessionStorage.getItem('notifications_cache')); notificationsUpdate(cached_data); + + var fnotifs = []; + if(cached_data.forums) { + $.each(cached_data.forums_sub, function() { + fnotifs.push(this); + }); + handleNotificationsItems('forums', fnotifs); + } + } if(! src) { @@ -1022,6 +1039,7 @@ function loadNotificationItems(notifyType) { } console.log('updating ' + notifyType + ' notifications...'); + $.get(pingExCmd, function(data) { if(data.invalid == 1) { window.location.href=window.location.href; diff --git a/view/pdl/mod_network.pdl b/view/pdl/mod_network.pdl index d26422093..a4bdf0a9f 100644 --- a/view/pdl/mod_network.pdl +++ b/view/pdl/mod_network.pdl @@ -1,9 +1,8 @@ [region=aside] [widget=activity_order][/widget] [widget=activity_filter][/widget] -[widget=forums][/widget] -[widget=suggestions][/widget] [widget=savedsearch][/widget] +[widget=suggestions][/widget] [widget=notes][/widget] [/region] diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index 002fa700a..87c97f1f5 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -593,7 +593,8 @@ footer { background-color: $comment_item_colour; } -#nav-notifications-template { +#nav-notifications-template, +#nav-notifications-forums-template { display: none; } @@ -837,6 +838,11 @@ div.jGrowl div.jGrowl-notification { white-space: nowrap; } +.notification.notification-forum { + font-size: 0.9rem; + color: $font_colour; +} + #acl-search::-webkit-input-placeholder { /* non-fontawesome fonts set a fallback for text parts of the placeholder*/ font-family: ForkAwesome, sans-serif, arial, freesans; diff --git a/view/tpl/common_pills.tpl b/view/tpl/common_pills.tpl index 8f4381f3d..e2b018d26 100755 --- a/view/tpl/common_pills.tpl +++ b/view/tpl/common_pills.tpl @@ -3,6 +3,7 @@ <li class="nav-item hover-fx-show"{{if $p.id}} id="{{$p.id}}"{{/if}}> <a class="nav-link{{if $p.sel}} {{$p.sel}}{{/if}}" href="{{$p.url}}"{{if $p.title}} title="{{$p.title}}"{{/if}}{{if $p.sub}} onclick="{{if $p.sel}}closeOpen('{{$p.id}}_sub');{{else}}openClose('{{$p.id}}_sub');{{/if}} return false;"{{/if}}> {{if $p.icon}}<i class="fa fa-fw fa-{{$p.icon}}"></i>{{/if}} + {{if $p.img}}<img class="menu-img-1" src="{{$p.img}}">{{/if}} {{$p.label}} {{if $p.sub}}<i class="fa fa-fw fa-caret-down hover-fx-hide"></i>{{/if}} </a> @@ -12,7 +13,9 @@ <li class="nav-item"{{if $ps.id}} id="{{$ps.id}}"{{/if}}> <a class="nav-link{{if $ps.sel}} {{$ps.sel}}{{/if}}" href="{{$ps.url}}"{{if $ps.title}} title="{{$ps.title}}"{{/if}}> {{if $ps.icon}}<i class="fa fa-fw fa-{{$ps.icon}}"></i>{{/if}} + {{if $ps.img}}<img class="menu-img-1" src="{{$ps.img}}">{{/if}} {{$ps.label}} + {{if $ps.lock}}<i class="fa fa-{{$ps.lock}} text-muted"></i>{{/if}} </a> </li> {{/foreach}} diff --git a/view/tpl/notifications_widget.tpl b/view/tpl/notifications_widget.tpl index 215fddd08..068441997 100644 --- a/view/tpl/notifications_widget.tpl +++ b/view/tpl/notifications_widget.tpl @@ -127,12 +127,20 @@ {{$no_notifications}}<span class="jumping-dots"><span class="dot-1">.</span><span class="dot-2">.</span><span class="dot-3">.</span></span> </div> <div id="nav-notifications-template" rel="template"> - <a class="list-group-item clearfix notification {5}" href="{0}" title="{2} {3}" data-b64mid="{6}" data-notify_id="{7}" data-thread_top="{8}" data-contact_name="{2}"> + <a class="list-group-item clearfix notification {5}" href="{0}" title="{2}" data-b64mid="{6}" data-notify_id="{7}" data-thread_top="{8}" data-contact_name="{2}"> <img class="menu-img-3" data-src="{1}"> <span class="contactname">{2}</span> <span class="dropdown-sub-text">{3}<br>{4}</span> </a> </div> + <div id="nav-notifications-forums-template" rel="template"> + <a class="list-group-item clearfix notification notification-forum" href="{0}" title="{3}" data-b64mid="{6}" data-notify_id="{7}" data-thread_top="{8}" data-contact_name="{2}"> + <span class="float-right badge badge-{{$notification.severity}}">{9}</span> + <img class="menu-img-1" src="{1}"> + <span class="">{2}</span> + <i class="fa fa-{10} text-muted"></i> + </a> + </div> <div id="notifications" class="navbar-nav"> {{foreach $notifications as $notification}} <div class="collapse {{$notification.type}}-button"> @@ -152,15 +160,19 @@ </div> {{/if}} {{if $notification.filter}} + {{if $notification.filter.posts_label}} <div class="list-group-item cursor-pointer" id="tt-{{$notification.type}}-only"> <i class="fa fa-fw fa-filter"></i> {{$notification.filter.posts_label}} </div> + {{/if}} + {{if $notification.filter.name_label}} <div class="list-group-item clearfix notifications-textinput" id="cn-{{$notification.type}}-only"> <div class="text-muted notifications-textinput-filter"><i class="fa fa-fw fa-filter"></i></div> <input id="cn-{{$notification.type}}-input" type="text" class="form-control form-control-sm" placeholder="{{$notification.filter.name_label}}"> <div id="cn-{{$notification.type}}-input-clear" class="text-muted notifications-textinput-clear d-none"><i class="fa fa-times"></i></div> </div> {{/if}} + {{/if}} <div id="nav-{{$notification.type}}-menu" class=""> {{$loading}}<span class="jumping-dots"><span class="dot-1">.</span><span class="dot-2">.</span><span class="dot-3">.</span></span> </div> diff --git a/view/tpl/settings.tpl b/view/tpl/settings.tpl index b5e871c36..3a05ea828 100755 --- a/view/tpl/settings.tpl +++ b/view/tpl/settings.tpl @@ -147,6 +147,7 @@ {{include file="field_intcheckbox.tpl" field=$vnotify13}} {{/if}} {{include file="field_intcheckbox.tpl" field=$vnotify14}} + {{include file="field_intcheckbox.tpl" field=$vnotify15}} {{include file="field_intcheckbox.tpl" field=$always_show_in_notices}} {{include file="field_input.tpl" field=$evdays}} </div> |