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' ?".">";
23 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
24 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
25 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
26 FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
27 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
28 `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0
29 ORDER BY `item`.`created` DESC",
37 $obj = parse_xml_string($xmlhead.$it['object']);
38 $it['tname'] = $obj->content;
44 case ACTIVITY_DISLIKE:
48 $obj = parse_xml_string($xmlhead.$it['object']);
49 $it['fname'] = $obj->title;
53 if ($it['parent']!=$it['id']) {
61 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
62 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
63 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
64 FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
65 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
66 `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 1",
73 $obj = parse_xml_string($xmlhead.$it['object']);
74 $it['tname'] = $obj->content;
80 case ACTIVITY_DISLIKE:
84 $obj = parse_xml_string($xmlhead.$it['object']);
85 $it['fname'] = $obj->title;
89 if ($it['parent']!=$it['id']) $comments[] = $it;
94 $intros1 = q("SELECT `intro`.`id`, `intro`.`datetime`,
95 `fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo`
96 FROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`
97 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`fid`!=0",
100 $intros2 = q("SELECT `intro`.`id`, `intro`.`datetime`,
101 `contact`.`name`, `contact`.`url`, `contact`.`photo`
102 FROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id`
103 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`contact-id`!=0",
107 $intro = count($intros1) + count($intros2);
108 $intros = $intros1+$intros2;
112 $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ;
113 $mails = q("SELECT *, COUNT(*) AS `total` FROM `mail`
114 WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ",
115 intval(local_user()),
118 $mail = $mails[0]['total'];
120 if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()){
121 $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");
122 $register = $regs[0]['total'];
128 function xmlize($href, $name, $url, $photo, $date, $message){
129 $notsxml = '<note href="%s" name="%s" url="%s" photo="%s" date="%s">%s</note>';
130 return sprintf ( $notsxml,
131 xmlify($href), xmlify($name), xmlify($url), xmlify($photo), xmlify($date), xmlify($message)
136 echo "<intro>$intro</intro>
140 if ($register!=0) echo "<register>$register</register>";
142 $tot = $mail+$intro+$register+count($comments)+count($likes)+count($dislikes)+count($friends)+count($posts)+count($tags);
144 echo ' <notif count="'.$tot.'">';
146 foreach ($intros as $i) {
147 echo xmlize( $a->get_baseurl().'/notifications/intros/'.$i['id'], $i['name'], $i['url'], $i['photo'], relative_date($i['datetime']), t("{0} wants to be your friend") );
151 foreach ($mails as $i) {
152 echo xmlize( $a->get_baseurl().'/message/'.$i['id'], $i['from-name'], $i['from-url'], $i['from-photo'], relative_date($i['created']), t("{0} sent you a message") );
156 foreach ($regs as $i) {
157 echo xmlize( $a->get_baseurl().'/admin/users/', $i['name'], $i['url'], $i['micro'], relative_date($i['created']), t("{0} requested registration") );
161 if (count($comments)){
162 foreach ($comments as $i) {
163 echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), sprintf( t("{0} commented %s's post"), $i['pname'] ) );
167 foreach ($likes as $i) {
168 echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), sprintf( t("{0} liked %s's post"), $i['pname'] ) );
171 if (count($dislikes)){
172 foreach ($dislikes as $i) {
173 echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), sprintf( t("{0} disliked %s's post"), $i['pname'] ) );
176 if (count($friends)){
177 foreach ($friends as $i) {
178 echo xmlize($a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'],$i['author-name'],$i['author-link'], $i['author-avatar'], relative_date($i['created']), sprintf( t("{0} is now friends with %s"), $i['fname'] ) );
182 foreach ($posts as $i) {
183 echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), sprintf( t("{0} posted") ) );
187 foreach ($tags as $i) {
188 echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), sprintf( t("{0} tagged %s's post with #%s"), $i['pname'], $i['tname'] ) );
193 foreach ($cit as $i) {
194 echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), t("{0} mentioned you in a post") );
202 if(x($_SESSION,'sysmsg')){
203 foreach ($_SESSION['sysmsg'] as $m){
204 echo "<notice>".xmlify($m)."</notice>";
206 unset($_SESSION['sysmsg']);
208 if(x($_SESSION,'sysmsg_info')){
209 foreach ($_SESSION['sysmsg_info'] as $m){
210 echo "<info>".xmlify($m)."</info>";
212 unset($_SESSION['sysmsg_info']);