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",
27 $z1 = q("select * from notify where uid = %d
28 and seen = 0 order by date desc limit 0, 50",
32 $z2 = q("select * from notify where uid = %d
33 and seen = 1 order by date desc limit 0, %d",
35 intval(50 - intval($t[0]['total']))
37 $z = array_merge($z1,$z2);
51 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`wall`, `item`.`author-name`,
52 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
53 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
54 FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
55 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
56 `item`.`deleted` = 0 AND `item`.`uid` = %d
57 ORDER BY `item`.`created` DESC",
72 $obj = parse_xml_string($xmlhead.$it['object']);
73 $it['tname'] = $obj->content;
79 case ACTIVITY_DISLIKE:
83 $obj = parse_xml_string($xmlhead.$it['object']);
84 $it['fname'] = $obj->title;
88 if ($it['parent']!=$it['id']) {
98 $intros1 = q("SELECT `intro`.`id`, `intro`.`datetime`,
99 `fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo`
100 FROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`
101 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`fid`!=0",
104 $intros2 = q("SELECT `intro`.`id`, `intro`.`datetime`,
105 `contact`.`name`, `contact`.`url`, `contact`.`photo`
106 FROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id`
107 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`contact-id`!=0",
111 $intro = count($intros1) + count($intros2);
112 $intros = $intros1+$intros2;
116 $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ;
117 $mails = q("SELECT *, COUNT(*) AS `total` FROM `mail`
118 WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ",
119 intval(local_user()),
123 $mail = $mails[0]['total'];
125 if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()){
126 $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");
128 $register = $regs[0]['total'];
134 function xmlize($href, $name, $url, $photo, $date, $seen, $message){
135 $notsxml = '<note href="%s" name="%s" url="%s" photo="%s" date="%s" seen="%s" >%s</note>';
136 return sprintf ( $notsxml,
137 xmlify($href), xmlify($name), xmlify($url), xmlify($photo), xmlify($date), xmlify($seen), xmlify($message)
141 echo "<intro>$intro</intro>
145 if ($register!=0) echo "<register>$register</register>";
147 $tot = $mail+$intro+$register+count($comments)+count($likes)+count($dislikes)+count($friends)+count($posts)+count($tags);
149 require_once('include/bbcode.php');
153 echo ' <notif count="'.$tot.'">';
163 echo ' <notif count="'. $sysnotify .'">';
166 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'])));
173 foreach ($intros as $i) {
174 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") );
178 foreach ($mails as $i) {
179 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") );
183 foreach ($regs as $i) {
184 echo xmlize( $a->get_baseurl().'/admin/users/', $i['name'], $i['url'], $i['micro'], relative_date($i['created']), 'notify-unseen',t("{0} requested registration") );
188 if (count($comments)){
189 foreach ($comments as $i) {
190 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'] ) );
194 foreach ($likes as $i) {
195 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'] ) );
198 if (count($dislikes)){
199 foreach ($dislikes as $i) {
200 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'] ) );
203 if (count($friends)){
204 foreach ($friends as $i) {
205 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'] ) );
209 foreach ($posts as $i) {
210 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") ) );
214 foreach ($tags as $i) {
215 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'] ) );
220 foreach ($cit as $i) {
221 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") );
230 if(x($_SESSION,'sysmsg')){
231 foreach ($_SESSION['sysmsg'] as $m){
232 echo "<notice>".xmlify($m)."</notice>";
234 unset($_SESSION['sysmsg']);
236 if(x($_SESSION,'sysmsg_info')){
237 foreach ($_SESSION['sysmsg_info'] as $m){
238 echo "<info>".xmlify($m)."</info>";
240 unset($_SESSION['sysmsg_info']);