aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2017-10-06 16:46:27 +0200
committerMario Vavti <mario@mariovavti.com>2017-10-06 16:46:27 +0200
commitf427b4a325e3db897afc33a09fb04d9af765a53f (patch)
tree69db5904f152e960e676cc5e025111a9c8a842d6
parenta6835f4e714b0648717672767aa32625b72dfc47 (diff)
downloadvolse-hubzilla-f427b4a325e3db897afc33a09fb04d9af765a53f.tar.gz
volse-hubzilla-f427b4a325e3db897afc33a09fb04d9af765a53f.tar.bz2
volse-hubzilla-f427b4a325e3db897afc33a09fb04d9af765a53f.zip
introduce public stream notifications
-rw-r--r--Zotlabs/Module/Ping.php38
-rw-r--r--include/nav.php4
-rwxr-xr-xview/tpl/nav.tpl10
3 files changed, 46 insertions, 6 deletions
diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php
index 3cda6a277..0acd720d6 100644
--- a/Zotlabs/Module/Ping.php
+++ b/Zotlabs/Module/Ping.php
@@ -19,6 +19,7 @@ class Ping extends \Zotlabs\Web\Controller {
* @result JSON
*/
function init() {
+
$result = array();
$notifs = array();
@@ -139,8 +140,8 @@ class Ping extends \Zotlabs\Web\Controller {
db_utcnow(), db_quoteinterval('3 MINUTE')
);
- $disable_discover_tab = get_config('system','disable_discover_tab') || get_config('system','disable_discover_tab') === false;
- $notify_pubs = ((local_channel()) ? ($vnotify & VNOTIFY_PUBS) && !$disable_discover_tab : !$disable_discover_tab);
+ $discover_tab_on = ((get_config('system','disable_discover_tab') != 1) ? true : false);
+ $notify_pubs = ((local_channel()) ? ($vnotify & VNOTIFY_PUBS) && $discover_tab_on : $discover_tab_on);
if($notify_pubs) {
$sys = get_sys_channel();
@@ -161,6 +162,36 @@ class Ping extends \Zotlabs\Web\Controller {
$result['pubs'] = intval($pubs[0]['total']);
}
+ if((argc() > 1) && (argv(1) === 'pubs') && ($notify_pubs)) {
+ $sys = get_sys_channel();
+ $result = array();
+
+ $r = q("SELECT * FROM item
+ WHERE uid = %d
+ AND author_xchan != '%s'
+ AND obj_type != '%s'
+ AND item_unseen = 1
+ AND created > '" . datetime_convert('UTC','UTC',$_SESSION['static_loadtime']) . "'
+ $item_normal
+ ORDER BY created DESC
+ LIMIT 300",
+ intval($sys['channel_id']),
+ dbesc(get_observer_hash()),
+ dbesc(ACTIVITY_OBJ_FILE)
+ );
+
+ if($r) {
+ xchan_query($r);
+ foreach($r as $rr) {
+ $result[] = \Zotlabs\Lib\Enotify::format($rr);
+ }
+ }
+
+// logger('ping (network||home): ' . print_r($result, true), LOGGER_DATA);
+ echo json_encode(array('notify' => $result));
+ killme();
+ }
+
$t1 = dba_timer();
if((! local_channel()) || ($result['invalid'])) {
@@ -206,6 +237,9 @@ class Ping extends \Zotlabs\Web\Controller {
intval(local_channel())
);
break;
+ case 'pubs':
+ unset($_SESSION['static_loadtime']);
+ break;
default:
break;
}
diff --git a/include/nav.php b/include/nav.php
index b51a03c4f..441a198fa 100644
--- a/include/nav.php
+++ b/include/nav.php
@@ -211,7 +211,9 @@ EOT;
}
if(! get_config('system', 'disable_discover_tab')) {
- $nav['pubs'] = array('pubstream', t('Public stream'), "", t('Public stream activities'),'pubs_nav_btn');
+ $nav['pubs'] = array('pubstream', t('Public stream'), "", t('Public stream activity'),'pubs_nav_btn');
+ $nav['pubs']['all'] = [ 'pubstream', t('View your public stream'), '','' ];
+ $nav['pubs']['mark'] = array('', t('Mark all public stream items seen'), '','');
}
/**
diff --git a/view/tpl/nav.tpl b/view/tpl/nav.tpl
index 9f4525c17..234b3682c 100755
--- a/view/tpl/nav.tpl
+++ b/view/tpl/nav.tpl
@@ -188,13 +188,17 @@
<a class="nav-link" href="{{$nav.alogout.0}}" title="{{$nav.alogout.3}}" id="{{$nav.alogout.4}}">{{$nav.alogout.1}}</a>
</li>
{{/if}}
-
{{if $nav.pubs}}
<li class="nav-item dropdown pubs-button" style="display: none;">
- <a class="nav-link" href="{{$nav.pubs.0}}" title="{{$nav.pubs.3}}" id="{{$nav.pubs.4}}" rel="#nav-pubs-menu">
+ <a class="nav-link" href="#" title="{{$nav.pubs.3}}" id="{{$nav.pubs.4}}" data-toggle="dropdown" rel="#nav-pubs-menu">
<i class="fa fa-fw fa-globe"></i>
- <span class="badge badge-pill badge-primary pubs-update"></span>
+ <span class="badge badge-pill badge-secondary pubs-update"></span>
</a>
+ <div id="nav-pubs-menu" class="dropdown-menu" rel="pubs">
+ <a class="dropdown-item" id="nav-pubs-see-all" href="{{$nav.pubs.all.0}}">{{$nav.pubs.all.1}}</a>
+ <a class="dropdown-item" id="nav-pubs-mark-all" href="#" onclick="markRead('pubs'); return false;">{{$nav.pubs.mark.1}}</a>
+ {{$emptynotifications}}
+ </div>
</li>
{{/if}}
</ul>