From eae7522bc99cc3af0074c189560a66181d2b70a0 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 28 Jul 2012 17:39:26 -0700 Subject: also notify count of events today --- mod/ping.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'mod/ping.php') diff --git a/mod/ping.php b/mod/ping.php index 99ff48aa7..d37824645 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -15,6 +15,7 @@ function ping_init(&$a) { $result['mail'] = 0; $result['register'] = 0; $result['events'] = 0; + $result['events_today'] = 0; $result['notice'] = array(); $result['info'] = array(); @@ -154,18 +155,26 @@ function ping_init(&$a) { $t5 = dba_timer(); - - $events = q("SELECT count(`event`.`id`) as total FROM `event` + $events = q("SELECT count(`event`.`id`) as total, start, convert FROM `event` WHERE `event`.`uid` = %d AND `start` < '%s' AND `finish` > '%s' ORDER BY `start` ASC ", intval(local_user()), - dbesc(datetime_convert('UTC','UTC','now + 1 days')), + dbesc(datetime_convert('UTC','UTC','now + 7 days')), dbesc(datetime_convert('UTC','UTC','now')) ); - if($events) + if($events && count($events)) { $result['events'] = intval($events[0]['total']); + if($result['events']) { + $str_now = datetime_convert('UTC',$a->timezone,'now','Y-m-d'); + foreach($events as $x) { + if(datetime_convert('UTC',((intval($x['convert'])) ? $a->timezone : 'UTC'), $x['start'],'Y-m-d') === $str_now) + $result['events_today'] ++; + } + } + } + $x = json_encode($result); $t6 = dba_timer(); -- cgit v1.2.3