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`,
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",
28 case 'http://activitystrea.ms/schema/1.0/like':
31 case 'http://activitystrea.ms/schema/1.0/dislike':
34 case 'http://activitystrea.ms/schema/1.0/make-friend':
38 if ($it['parent']!=$it['id']) $comments[] = $it;
43 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
44 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`,
45 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
46 FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
47 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
48 `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 1",
54 case 'http://activitystrea.ms/schema/1.0/like':
57 case 'http://activitystrea.ms/schema/1.0/dislike':
60 case 'http://activitystrea.ms/schema/1.0/make-friend':
64 if ($it['parent']!=$it['id']) $comments[] = $it;
69 $intros1 = q("SELECT COUNT(`intro`.`id`) AS `total`, `intro`.`id`, `intro`.`datetime`,
70 `fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo`
71 FROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`
72 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`fid`!=0",
75 $intros2 = q("SELECT COUNT(`intro`.`id`) AS `total`, `intro`.`id`, `intro`.`datetime`,
76 `contact`.`name`, `contact`.`url`, `contact`.`photo`
77 FROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id`
78 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`contact-id`!=0",
82 $intro = $intros1[0]['total'] + $intros2[0]['total'];
83 if ($intros1[0]['total']==0) $intros1=Array();
84 if ($intros2[0]['total']==0) $intros2=Array();
85 $intros = $intros1+$intros2;
89 $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ;
90 $mails = q("SELECT *, COUNT(*) AS `total` FROM `mail`
91 WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ",
95 $mail = $mails[0]['total'];
97 if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()){
98 $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");
99 $register = $regs[0]['total'];
105 function xmlize($href, $name, $url, $photo, $date, $message){
106 $notsxml = '<note href="%s" name="%s" url="%s" photo="%s" date="%s">%s</note>';
107 return sprintf ( $notsxml,
108 $href, $name, $url, $photo, $date, $message
112 header("Content-type: text/xml");
113 echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
115 <intro>$intro</intro>
119 if ($register!=0) echo "<register>$register</register>";
121 $tot = $mail+$intro+$register+count($comments)+count($likes)+count($dislikes)+count($friends);
123 echo ' <notif count="'.$tot.'">';
125 foreach ($intros as $i) {
126 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") );
130 foreach ($mails as $i) {
131 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") );
135 foreach ($regs as $i) {
136 echo xmlize( $a->get_baseurl().'/admin/users/', $i['name'], $i['url'], $i['micro'], relative_date($i['created']), t("{0} requested registration") );
140 if (count($comments)){
141 foreach ($comments as $i) {
142 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'] ) );
146 foreach ($likes as $i) {
147 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'] ) );
150 if (count($dislikes)){
151 foreach ($dislikes as $i) {
152 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'] ) );
155 if (count($friends)){
156 foreach ($friends as $i) {
157 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['pname'] ) );
165 if(x($_SESSION,'sysmsg')){
166 foreach ($_SESSION['sysmsg'] as $m){
167 echo "<notice>".($m)."</notice>";
169 $_SESSION['sysmsg']=array();
170 unset($_SESSION['sysmsg']);
172 if(x($_SESSION,'sysmsg_info')){
173 foreach ($_SESSION['sysmsg_info'] as $m){
174 echo "<info>".($m)."</info>";
176 $_SESSION['sysmsg_info']=array();
177 unset($_SESSION['sysmsg_info']);