+
+ $ev = q("SELECT count(`event`.`id`) as total, type, start, adjust FROM `event`
+ WHERE `event`.`uid` = %d AND `start` < '%s' AND `finish` > '%s' and `ignore` = 0
+ ORDER BY `start` ASC ",
+ intval(local_user()),
+ dbesc(datetime_convert('UTC','UTC','now + 7 days')),
+ dbesc(datetime_convert('UTC','UTC','now'))
+ );
+
+ if($ev && count($ev)) {
+ $all_events = intval($ev[0]['total']);
+
+ if($all_events) {
+ $str_now = datetime_convert('UTC',$a->timezone,'now','Y-m-d');
+ foreach($ev as $x) {
+ $bd = false;
+ if($x['type'] === 'birthday') {
+ $birthdays ++;
+ $bd = true;
+ }
+ else {
+ $events ++;
+ }
+ if(datetime_convert('UTC',((intval($x['adjust'])) ? $a->timezone : 'UTC'), $x['start'],'Y-m-d') === $str_now) {
+ $all_events_today ++;
+ if($bd)
+ $birthdays_today ++;
+ else
+ $events_today ++;
+ }
+ }
+ }
+ }
+
+
+ /**
+ * return xml from notification array
+ *
+ * @param array $n Notification array:
+ * 'href' => notification link
+ * 'name' => subject name
+ * 'url' => subject url
+ * 'photo' => subject photo
+ * 'date' => notification date
+ * 'seen' => bool true/false
+ * 'message' => notification message. "{0}" will be replaced by subject name
+ **/
+ function xmlize($n){
+ $n['photo'] = proxy_url($n['photo'], false, PROXY_SIZE_MICRO);
+
+ $n['message'] = html_entity_decode($n['message'], ENT_COMPAT | ENT_HTML401, "UTF-8");
+ $n['name'] = html_entity_decode($n['name'], ENT_COMPAT | ENT_HTML401, "UTF-8");
+
+ // Are the nofications calles from the regular process or via the friendica app?
+ $regularnotifications = (intval($_GET['uid']) AND intval($_GET['_']));
+
+ $a = get_app();
+
+ if ($a->is_friendica_app() OR !$regularnotifications)
+ $n['message'] = str_replace("{0}", $n['name'], $n['message']);
+
+ $local_time = datetime_convert('UTC',date_default_timezone_get(),$n['date']);
+
+ call_hooks('ping_xmlize', $n);
+ $notsxml = '<note href="%s" name="%s" url="%s" photo="%s" date="%s" seen="%s" timestamp="%s" >%s</note>'."\n";