2 require_once("include/datetime.php");
5 function ping_init(&$a) {
7 header("Content-type: text/xml");
9 echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
12 $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
15 $firehose = intval(get_pconfig(local_user(),'system','notify_full'));
17 $t = q("select count(*) as total from notify where uid = %d and seen = 0",
20 if($t && intval($t[0]['total']) > 49) {
21 $z = q("select * from notify where uid = %d
22 and seen = 0 order by date desc limit 0, 50",
25 $sysnotify = $t[0]['total'];
28 $z1 = q("select * from notify where uid = %d
29 and seen = 0 order by date desc limit 0, 50",
33 $z2 = q("select * from notify where uid = %d
34 and seen = 1 order by date desc limit 0, %d",
36 intval(50 - intval($t[0]['total']))
38 $z = array_merge($z1,$z2);
39 $sysnotify = 0; // we will update this in a moment
53 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`wall`, `item`.`author-name`,
54 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
55 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
56 FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
57 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
58 `item`.`deleted` = 0 AND `item`.`uid` = %d
59 ORDER BY `item`.`created` DESC",
74 $obj = parse_xml_string($xmlhead.$it['object']);
75 $it['tname'] = $obj->content;
81 case ACTIVITY_DISLIKE:
85 $obj = parse_xml_string($xmlhead.$it['object']);
86 $it['fname'] = $obj->title;
90 if ($it['parent']!=$it['id']) {
100 $intros1 = q("SELECT `intro`.`id`, `intro`.`datetime`,
101 `fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo`
102 FROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`
103 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`fid`!=0",
106 $intros2 = q("SELECT `intro`.`id`, `intro`.`datetime`,
107 `contact`.`name`, `contact`.`url`, `contact`.`photo`
108 FROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id`
109 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`contact-id`!=0",
113 $intro = count($intros1) + count($intros2);
114 $intros = $intros1+$intros2;
118 $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ;
119 $mails = q("SELECT *, COUNT(*) AS `total` FROM `mail`
120 WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ",
121 intval(local_user()),
125 $mail = $mails[0]['total'];
127 if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()){
128 $regs = q("SELECT `contact`.`name`, `contact`.`url`, `contact`.`micro`, `register`.`created`, COUNT(*) as `total` FROM `contact` RIGHT JOIN `register` ON `register`.`uid`=`contact`.`uid` WHERE `contact`.`self`=1");
130 $register = $regs[0]['total'];
136 function xmlize($href, $name, $url, $photo, $date, $seen, $message){
137 $notsxml = '<note href="%s" name="%s" url="%s" photo="%s" date="%s" seen="%s" >%s</note>';
138 return sprintf ( $notsxml,
139 xmlify($href), xmlify($name), xmlify($url), xmlify($photo), xmlify($date), xmlify($seen), xmlify($message)
143 echo "<intro>$intro</intro>
147 if ($register!=0) echo "<register>$register</register>";
149 $tot = $mail+$intro+$register+count($comments)+count($likes)+count($dislikes)+count($friends)+count($posts)+count($tags);
151 require_once('include/bbcode.php');
154 echo ' <notif count="'.$tot.'">';
157 if(count($z) && (! $sysnotify)) {
164 echo ' <notif count="'. $sysnotify .'">';
167 echo xmlize($a->get_baseurl() . '/notify/view/' . $zz['id'], $zz['name'],$zz['url'],$zz['photo'],relative_date($zz['date']), ($zz['seen'] ? 'notify-seen' : 'notify-unseen'), ($zz['seen'] ? '' : '→ ') .strip_tags(bbcode($zz['msg'])));
174 foreach ($intros as $i) {
175 echo xmlize( $a->get_baseurl().'/notifications/intros/'.$i['id'], $i['name'], $i['url'], $i['photo'], relative_date($i['datetime']), 'notify-unseen',t("{0} wants to be your friend") );
179 foreach ($mails as $i) {
180 echo xmlize( $a->get_baseurl().'/message/'.$i['id'], $i['from-name'], $i['from-url'], $i['from-photo'], relative_date($i['created']), 'notify-unseen',t("{0} sent you a message") );
184 foreach ($regs as $i) {
185 echo xmlize( $a->get_baseurl().'/admin/users/', $i['name'], $i['url'], $i['micro'], relative_date($i['created']), 'notify-unseen',t("{0} requested registration") );
189 if (count($comments)){
190 foreach ($comments as $i) {
191 echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), 'notify-unseen',sprintf( t("{0} commented %s's post"), $i['pname'] ) );
195 foreach ($likes as $i) {
196 echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), 'notify-unseen',sprintf( t("{0} liked %s's post"), $i['pname'] ) );
199 if (count($dislikes)){
200 foreach ($dislikes as $i) {
201 echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), 'notify-unseen',sprintf( t("{0} disliked %s's post"), $i['pname'] ) );
204 if (count($friends)){
205 foreach ($friends as $i) {
206 echo xmlize($a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'],$i['author-name'],$i['author-link'], $i['author-avatar'], relative_date($i['created']), 'notify-unseen',sprintf( t("{0} is now friends with %s"), $i['fname'] ) );
210 foreach ($posts as $i) {
211 echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), 'notify-unseen',sprintf( t("{0} posted") ) );
215 foreach ($tags as $i) {
216 echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), 'notify-unseen',sprintf( t("{0} tagged %s's post with #%s"), $i['pname'], $i['tname'] ) );
221 foreach ($cit as $i) {
222 echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), 'notify-unseen',t("{0} mentioned you in a post") );
231 if(x($_SESSION,'sysmsg')){
232 foreach ($_SESSION['sysmsg'] as $m){
233 echo "<notice>".xmlify($m)."</notice>";
235 unset($_SESSION['sysmsg']);
237 if(x($_SESSION,'sysmsg_info')){
238 foreach ($_SESSION['sysmsg_info'] as $m){
239 echo "<info>".xmlify($m)."</info>";
241 unset($_SESSION['sysmsg_info']);