Merge pull request #24 from duthied/master

fixes to the notifications drop-down
This commit is contained in:
duthied 2011-10-08 21:27:20 -07:00
commit 0e401b5ad8

View file

@ -15,13 +15,14 @@ function ping_init(&$a) {
$likes = array(); $likes = array();
$dislikes = array(); $dislikes = array();
$friends = array(); $friends = array();
$posts = array();
$r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
`item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`, `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
`pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink` `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent` FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
`item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0", `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ORDER BY `item`.`created` DESC",
intval(local_user()) intval(local_user())
); );
@ -34,6 +35,9 @@ function ping_init(&$a) {
case ACTIVITY_DISLIKE: case ACTIVITY_DISLIKE:
$dislikes[] = $it; $dislikes[] = $it;
break; break;
case ACTIVITY_POST;
$posts[] = $it;
break;
case ACTIVITY_FRIEND: case ACTIVITY_FRIEND:
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">"; $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
$obj = parse_xml_string($xmlhead.$it['object']); $obj = parse_xml_string($xmlhead.$it['object']);
@ -114,7 +118,7 @@ function ping_init(&$a) {
function xmlize($href, $name, $url, $photo, $date, $message){ function xmlize($href, $name, $url, $photo, $date, $message){
$notsxml = '<note href="%s" name="%s" url="%s" photo="%s" date="%s">%s</note>'; $notsxml = '<note href="%s" name="%s" url="%s" photo="%s" date="%s">%s</note>';
return sprintf ( $notsxml, return sprintf ( $notsxml,
xmlify($href), xmlify($name), xmlify($url), xmlify($photo), xmlify($date), xmlify($message) $href, $name, $url, $photo, $date, $message
); );
} }
@ -151,20 +155,24 @@ function ping_init(&$a) {
} }
if (count($likes)){ if (count($likes)){
foreach ($likes as $i) { foreach ($likes as $i) {
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'] ) ); 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'] ) );
}; };
} }
if (count($dislikes)){ if (count($dislikes)){
foreach ($dislikes as $i) { foreach ($dislikes as $i) {
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'] ) ); 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'] ) );
}; };
} }
if (count($friends)){ if (count($friends)){
foreach ($friends as $i) { foreach ($friends as $i) {
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'] ) ); 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'] ) );
};
}
if (count($posts)){
foreach ($posts as $i) {
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") ) );
}; };
} }
echo " </notif>"; echo " </notif>";
} }