unread forum notifications - wip/unfinished
This commit is contained in:
parent
22a9e4c9a9
commit
53efd4e470
@ -39,6 +39,7 @@ class Ping extends \Zotlabs\Web\Controller {
|
|||||||
$result['info'] = array();
|
$result['info'] = array();
|
||||||
$result['pubs'] = 0;
|
$result['pubs'] = 0;
|
||||||
$result['files'] = 0;
|
$result['files'] = 0;
|
||||||
|
$result['forums'] = 0;
|
||||||
|
|
||||||
if(! $_SESSION['static_loadtime'])
|
if(! $_SESSION['static_loadtime'])
|
||||||
$_SESSION['static_loadtime'] = datetime_convert();
|
$_SESSION['static_loadtime'] = datetime_convert();
|
||||||
@ -622,6 +623,66 @@ class Ping extends \Zotlabs\Web\Controller {
|
|||||||
if(! ($vnotify & VNOTIFY_BIRTHDAY))
|
if(! ($vnotify & VNOTIFY_BIRTHDAY))
|
||||||
$result['birthdays'] = 0;
|
$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);
|
$x = json_encode($result);
|
||||||
|
|
||||||
$t8 = dba_timer();
|
$t8 = dba_timer();
|
||||||
|
@ -27,8 +27,6 @@ class Forums {
|
|||||||
$x1 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'send_stream' and v = '0'",
|
$x1 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'send_stream' and v = '0'",
|
||||||
intval(local_channel())
|
intval(local_channel())
|
||||||
);
|
);
|
||||||
//print_r($x1);killme();
|
|
||||||
|
|
||||||
if($x1) {
|
if($x1) {
|
||||||
$xc = ids_to_querystr($x1,'xchan',true);
|
$xc = ids_to_querystr($x1,'xchan',true);
|
||||||
|
|
||||||
|
@ -111,6 +111,21 @@ class Notifications {
|
|||||||
'label' => t('Mark all notices seen')
|
'label' => t('Mark all notices seen')
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$notifications[] = [
|
||||||
|
'type' => 'forums',
|
||||||
|
'icon' => 'comments-o',
|
||||||
|
'severity' => 'secondary',
|
||||||
|
'label' => t('Forums'),
|
||||||
|
'title' => t('Forums'),
|
||||||
|
'viewall' => [
|
||||||
|
//'url' => 'notifications/system',
|
||||||
|
//'label' => t('View all notices')
|
||||||
|
],
|
||||||
|
'markall' => [
|
||||||
|
//'label' => t('Mark all notices seen')
|
||||||
|
]
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(local_channel() && is_site_admin()) {
|
if(local_channel() && is_site_admin()) {
|
||||||
|
@ -451,7 +451,7 @@ function notificationsUpdate(cached_data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleNotifications(data) {
|
function handleNotifications(data) {
|
||||||
if(data.network || data.home || data.intros || data.register || data.mail || data.all_events || data.notify || data.files || data.pubs) {
|
if(data.network || data.home || data.intros || data.register || data.mail || data.all_events || data.notify || data.files || data.pubs || data.forums) {
|
||||||
$('.notifications-btn').css('opacity', 1);
|
$('.notifications-btn').css('opacity', 1);
|
||||||
$('#no_notifications').hide();
|
$('#no_notifications').hide();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user