2 require_once("include/datetime.php");
5 function ping_init(&$a) {
16 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
17 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
18 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
19 FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
20 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
21 `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0",
31 case ACTIVITY_DISLIKE:
35 $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
36 $obj = parse_xml_string($xmlhead.$it['object']);
37 $it['fname'] = $obj->title;
41 if ($it['parent']!=$it['id']) $comments[] = $it;
46 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
47 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
48 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
49 FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
50 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
51 `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 1",
60 case ACTIVITY_DISLIKE:
64 $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
65 $obj = parse_xml_string($xmlhead.$it['object']);
66 $it['fname'] = $obj->title;
70 if ($it['parent']!=$it['id']) $comments[] = $it;
75 $intros1 = q("SELECT COUNT(`intro`.`id`) AS `total`, `intro`.`id`, `intro`.`datetime`,
76 `fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo`
77 FROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`
78 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`fid`!=0",
81 $intros2 = q("SELECT COUNT(`intro`.`id`) AS `total`, `intro`.`id`, `intro`.`datetime`,
82 `contact`.`name`, `contact`.`url`, `contact`.`photo`
83 FROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id`
84 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`contact-id`!=0",
88 $intro = $intros1[0]['total'] + $intros2[0]['total'];
89 if ($intros1[0]['total']==0) $intros1=Array();
90 if ($intros2[0]['total']==0) $intros2=Array();
91 $intros = $intros1+$intros2;
95 $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ;
96 $mails = q("SELECT *, COUNT(*) AS `total` FROM `mail`
97 WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ",
101 $mail = $mails[0]['total'];
103 if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()){
104 $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");
105 $register = $regs[0]['total'];
111 function xmlize($href, $name, $url, $photo, $date, $message){
112 $notsxml = '<note href="%s" name="%s" url="%s" photo="%s" date="%s">%s</note>';
113 return sprintf ( $notsxml,
114 $href, $name, $url, $photo, $date, $message
118 header("Content-type: text/xml");
119 echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
121 <intro>$intro</intro>
125 if ($register!=0) echo "<register>$register</register>";
127 $tot = $mail+$intro+$register+count($comments)+count($likes)+count($dislikes)+count($friends);
129 echo ' <notif count="'.$tot.'">';
131 foreach ($intros as $i) {
132 echo xmlize( $a->get_baseurl().'/notifications/'.$i['id'], $i['name'], $i['url'], $i['photo'], relative_date($i['datetime']), t("{0} wants to be your friend") );
136 foreach ($mails as $i) {
137 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") );
141 foreach ($regs as $i) {
142 echo xmlize( $a->get_baseurl().'/admin/users/', $i['name'], $i['url'], $i['micro'], relative_date($i['created']), t("{0} requested registration") );
146 if (count($comments)){
147 foreach ($comments as $i) {
148 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'] ) );
152 foreach ($likes as $i) {
153 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} like %s's post"), $i['pname'] ) );
156 if (count($dislikes)){
157 foreach ($dislikes as $i) {
158 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} dislike %s's post"), $i['pname'] ) );
161 if (count($friends)){
162 foreach ($friends 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} is now friend with %s"), $i['fname'] ) );
171 if(x($_SESSION,'sysmsg')){
172 foreach ($_SESSION['sysmsg'] as $m){
173 echo "<notice>".($m)."</notice>";
175 $_SESSION['sysmsg']=array();
176 unset($_SESSION['sysmsg']);
178 if(x($_SESSION,'sysmsg_info')){
179 foreach ($_SESSION['sysmsg_info'] as $m){
180 echo "<info>".($m)."</info>";
182 $_SESSION['sysmsg_info']=array();
183 unset($_SESSION['sysmsg_info']);