aboutsummaryrefslogtreecommitdiffstats
path: root/mod/ping.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/ping.php')
-rw-r--r--mod/ping.php47
1 files changed, 20 insertions, 27 deletions
diff --git a/mod/ping.php b/mod/ping.php
index b676726fe..394dbf089 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -43,6 +43,8 @@ function ping_init(&$a) {
$vnotify = false;
+ $item_normal = item_normal();
+
if(local_channel()) {
$vnotify = get_pconfig(local_channel(),'system','vnotify');
$evdays = intval(get_pconfig(local_channel(),'system','evdays'));
@@ -156,16 +158,13 @@ function ping_init(&$a) {
);
break;
case 'home':
- $r = q("update item set item_unseen = 0 where item_unseen = 1 and (item_flags & %d) > 0 and uid = %d",
- intval(ITEM_WALL),
+ $r = q("update item set item_unseen = 0 where item_unseen = 1 and item_wall = 1 and uid = %d",
intval(local_channel())
);
break;
case 'messages':
- $r = q("update mail set mail_flags = ( mail_flags | %d ) where channel_id = %d and not (mail_flags & %d) > 0",
- intval(MAIL_SEEN),
- intval(local_channel()),
- intval(MAIL_SEEN)
+ $r = q("update mail set mail_seen = 1 where mail_seen = 0 and channel_id = %d ",
+ intval(local_channel())
);
break;
case 'all_events':
@@ -243,11 +242,9 @@ function ping_init(&$a) {
if(argc() > 1 && argv(1) === 'messages') {
$channel = $a->get_channel();
$t = q("select mail.*, xchan.* from mail left join xchan on xchan_hash = from_xchan
- where channel_id = %d and not ( mail_flags & %d ) > 0 and not (mail_flags & %d ) > 0
+ where channel_id = %d and mail_seen = 0 and mail_deleted = 0
and from_xchan != '%s' order by created desc limit 50",
intval(local_channel()),
- intval(MAIL_SEEN),
- intval(MAIL_DELETED),
dbesc($channel['channel_hash'])
);
@@ -259,7 +256,7 @@ function ping_init(&$a) {
'url' => $zz['xchan_url'],
'photo' => $zz['xchan_photo_s'],
'when' => relative_date($zz['created']),
- 'hclass' => (($zz['mail_flags'] & MAIL_SEEN) ? 'notify-seen' : 'notify-unseen'),
+ 'hclass' => (intval($zz['mail_seen']) ? 'notify-seen' : 'notify-unseen'),
'message' => t('sent you a private message'),
);
}
@@ -273,7 +270,7 @@ function ping_init(&$a) {
$result = array();
$r = q("SELECT * FROM item
- WHERE item_restrict = 0 and item_unseen = 1 and uid = %d
+ WHERE item_unseen = 1 and uid = %d $item_normal
and author_xchan != '%s' ORDER BY created DESC limit 300",
intval(local_channel()),
dbesc($ob_hash)
@@ -282,7 +279,7 @@ function ping_init(&$a) {
if($r) {
xchan_query($r);
foreach($r as $item) {
- if((argv(1) === 'home') && (! ($item['item_flags'] & ITEM_WALL)))
+ if((argv(1) === 'home') && (! intval($item['item_wall'])))
continue;
$result[] = format_notification($item);
}
@@ -295,11 +292,8 @@ function ping_init(&$a) {
if(argc() > 1 && (argv(1) === 'intros')) {
$result = array();
- $r = q("SELECT * FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) > 0 and not ((abook_flags & %d) > 0 or (xchan_flags & %d) > 0) ORDER BY abook_created DESC LIMIT 50",
- intval(local_channel()),
- intval(ABOOK_FLAG_PENDING),
- intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED),
- intval(XCHAN_FLAGS_DELETED|XCHAN_FLAGS_ORPHAN)
+ $r = q("SELECT * FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and abook_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ORDER BY abook_created DESC LIMIT 50",
+ intval(local_channel())
);
if($r) {
@@ -327,6 +321,7 @@ function ping_init(&$a) {
$r = q("SELECT * FROM event left join xchan on event_xchan = xchan_hash
WHERE `event`.`uid` = %d AND start < '%s' AND start > '%s' and `ignore` = 0
+ and type in ( 'event', 'birthday' )
ORDER BY `start` DESC LIMIT 1000",
intval(local_channel()),
dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval($evdays) . ' days')),
@@ -378,8 +373,9 @@ function ping_init(&$a) {
$t1 = dba_timer();
if($vnotify & (VNOTIFY_NETWORK|VNOTIFY_CHANNEL)) {
- $r = q("SELECT id, item_restrict, item_flags FROM item
- WHERE item_restrict = 0 and item_unseen = 1 and uid = %d
+ $r = q("SELECT id, item_wall FROM item
+ WHERE item_unseen = 1 and uid = %d
+ $item_normal
and author_xchan != '%s'",
intval(local_channel()),
dbesc($ob_hash)
@@ -390,7 +386,7 @@ function ping_init(&$a) {
call_hooks('network_ping', $arr);
foreach ($r as $it) {
- if($it['item_flags'] & ITEM_WALL)
+ if(intval($it['item_wall']))
$result['home'] ++;
else
$result['network'] ++;
@@ -406,11 +402,8 @@ function ping_init(&$a) {
$t2 = dba_timer();
if($vnotify & VNOTIFY_INTRO) {
- $intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) > 0 and not ((abook_flags & %d) > 0 or (xchan_flags & %d) > 0)",
- intval(local_channel()),
- intval(ABOOK_FLAG_PENDING),
- intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED),
- intval(XCHAN_FLAGS_DELETED|XCHAN_FLAGS_ORPHAN)
+ $intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and abook_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ",
+ intval(local_channel())
);
$t3 = dba_timer();
@@ -424,9 +417,8 @@ function ping_init(&$a) {
if($vnotify & VNOTIFY_MAIL) {
$mails = q("SELECT count(id) as total from mail
- WHERE channel_id = %d AND not (mail_flags & %d) > 0 and from_xchan != '%s' ",
+ WHERE channel_id = %d AND mail_seen = 0 and from_xchan != '%s' ",
intval(local_channel()),
- intval(MAIL_SEEN),
dbesc($channel['channel_hash'])
);
if($mails)
@@ -448,6 +440,7 @@ function ping_init(&$a) {
if($vnotify & (VNOTIFY_EVENT|VNOTIFY_EVENTTODAY|VNOTIFY_BIRTHDAY)) {
$events = q("SELECT type, start, adjust FROM `event`
WHERE `event`.`uid` = %d AND start < '%s' AND start > '%s' and `ignore` = 0
+ and type in ( 'event', 'birthday' )
ORDER BY `start` ASC ",
intval(local_channel()),
dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval($evdays) . ' days')),