diff options
author | Mario Vavti <mario@mariovavti.com> | 2018-06-02 22:11:11 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2018-06-02 22:11:11 +0200 |
commit | 8189408190333b4f6ac45f98623be0d1db8b9462 (patch) | |
tree | eb10d322eb63456bc7685c33db3ca627abf1cecf /Zotlabs/Module | |
parent | db0a3a753420e8722776094334759dd4ff61fc77 (diff) | |
download | volse-hubzilla-8189408190333b4f6ac45f98623be0d1db8b9462.tar.gz volse-hubzilla-8189408190333b4f6ac45f98623be0d1db8b9462.tar.bz2 volse-hubzilla-8189408190333b4f6ac45f98623be0d1db8b9462.zip |
finalize filters and forum notifications
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r-- | Zotlabs/Module/Ping.php | 109 | ||||
-rw-r--r-- | Zotlabs/Module/Settings/Channel.php | 3 |
2 files changed, 46 insertions, 66 deletions
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); 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), |