From 53efd4e470f10e123209ed63b90213b20a87e011 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 1 Jun 2018 23:22:52 +0200 Subject: unread forum notifications - wip/unfinished --- Zotlabs/Module/Ping.php | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'Zotlabs/Module/Ping.php') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index bb80adc41..a43d9863e 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -39,6 +39,7 @@ class Ping extends \Zotlabs\Web\Controller { $result['info'] = array(); $result['pubs'] = 0; $result['files'] = 0; + $result['forums'] = 0; if(! $_SESSION['static_loadtime']) $_SESSION['static_loadtime'] = datetime_convert(); @@ -622,6 +623,66 @@ class Ping extends \Zotlabs\Web\Controller { if(! ($vnotify & VNOTIFY_BIRTHDAY)) $result['birthdays'] = 0; + + +#### unseen forum + + $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); + } + } + } + + $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()) + ); + + 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]); + } + } + $result['forums'] = $r1['total']; + } + $x = json_encode($result); $t8 = dba_timer(); -- cgit v1.2.3 From db0a3a753420e8722776094334759dd4ff61fc77 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 2 Jun 2018 15:39:38 +0200 Subject: some more work on forum notifications --- Zotlabs/Module/Ping.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'Zotlabs/Module/Ping.php') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index a43d9863e..941b7b286 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -673,14 +673,27 @@ class Ping extends \Zotlabs\Web\Controller { dbesc($r1[$x]['xchan_hash']) ); if($r[0]['unseen']) { + $r1[$x]['notify_link'] = z_root() . '/network/?f=&cid=' . $r1[$x]['abook_id']; + $r1[$x]['name'] = $r1[$x]['xchan_name']; + $r1[$x]['url'] = $r1[$x]['xchan_url']; + $r1[$x]['photo'] = $r1[$x]['xchan_photo_s']; $r1[$x]['unseen'] = $r[0]['unseen']; $r1['total'] = $r1['total'] + $r[0]['unseen']; + + unset($r1[$x]['abook_id']); + unset($r1[$x]['xchan_hash']); + unset($r1[$x]['xchan_name']); + unset($r1[$x]['xchan_url']); + unset($r1[$x]['xchan_photo_s']); } else { unset($r1[$x]); } } $result['forums'] = $r1['total']; + unset($r1['total']); + + $result['forums_sub'] = $r1; } $x = json_encode($result); -- cgit v1.2.3 From 8189408190333b4f6ac45f98623be0d1db8b9462 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 2 Jun 2018 22:11:11 +0200 Subject: finalize filters and forum notifications --- Zotlabs/Module/Ping.php | 109 +++++++++++++++++++----------------------------- 1 file changed, 43 insertions(+), 66 deletions(-) (limited to 'Zotlabs/Module/Ping.php') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index 941b7b286..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,75 +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]['notify_link'] = z_root() . '/network/?f=&cid=' . $r1[$x]['abook_id']; - $r1[$x]['name'] = $r1[$x]['xchan_name']; - $r1[$x]['url'] = $r1[$x]['xchan_url']; - $r1[$x]['photo'] = $r1[$x]['xchan_photo_s']; - $r1[$x]['unseen'] = $r[0]['unseen']; - $r1['total'] = $r1['total'] + $r[0]['unseen']; - - unset($r1[$x]['abook_id']); - unset($r1[$x]['xchan_hash']); - unset($r1[$x]['xchan_name']); - unset($r1[$x]['xchan_url']); - unset($r1[$x]['xchan_photo_s']); - } - else { - unset($r1[$x]); + } + else { + unset($forums[$x]); + } } - } - $result['forums'] = $r1['total']; - unset($r1['total']); + $result['forums'] = $forums['total']; + unset($forums['total']); - $result['forums_sub'] = $r1; + $result['forums_sub'] = $forums; + } } $x = json_encode($result); -- cgit v1.2.3 From a42ff1e6d40496cc93481312b47548200e8af380 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 3 Jun 2018 13:27:06 +0200 Subject: missing $perm_sql --- Zotlabs/Module/Ping.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Module/Ping.php') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index 3f2015d6d..d95df34a0 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -633,8 +633,11 @@ class Ping extends \Zotlabs\Web\Controller { $result['forums'] = 0; } else { + + $perms_sql = item_permissions_sql(local_channel()) . item_normal(); $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 ", @@ -642,7 +645,7 @@ class Ping extends \Zotlabs\Web\Controller { 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]['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']; -- cgit v1.2.3 From 5d1d6299cde7b0d699851da00a32878cdc49593e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 6 Jun 2018 18:02:25 +0200 Subject: add the pf argument to the forum notification links --- Zotlabs/Module/Ping.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module/Ping.php') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index d95df34a0..baefe62ec 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -645,7 +645,7 @@ class Ping extends \Zotlabs\Web\Controller { 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]['notify_link'] = (($forums[$x]['private_forum']) ? $forums[$x]['xchan_url'] : z_root() . '/network/?f=&pf=1&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']; -- cgit v1.2.3