Fix bugs and rename <groups> to <group_posts>

This commit is contained in:
Sandro Santilli 2015-11-08 15:56:08 +01:00
parent ba158dfeb1
commit e28072f548

View file

@ -88,20 +88,17 @@ function ping_init(&$a) {
if ( $network ) if ( $network )
{ {
# Find out how unseen network posts are spread across groups # Find out how unseen network posts are spread across groups
$sql = "SELECT g.id, g.name, count(i.id) gm $sql = "SELECT g.id, g.name, count(i.id) count " .
FROM `group` g, group_member gm, item i "FROM `group` g, group_member gm, item i " .
WHERE g.uid = %d "WHERE g.uid = %d " .
AND i.uid = %d "AND i.uid = %d " .
AND i.unseen AND i.visible "AND i.unseen AND i.visible " .
AND NOT i.deleted "AND NOT i.deleted " .
AND i.`contact-id` = gm.`contact-id` "AND i.`contact-id` = gm.`contact-id` " .
AND gm.gid = g.id GROUP BY g.id"; "AND gm.gid = g.id GROUP BY g.id";
#echo '<SQL id="' . intval(local_user()) . '">' . $sql . '</SQL>'; #echo '<SQL id="' . intval(local_user()) . '">' . $sql . '</SQL>';
$r = q(sql, intval(local_user()), intval(local_user())); $network_group = q($sql, intval(local_user()), intval(local_user()));
#echo $r; #echo '<COUNT R="' . count($network_group) . '"/>';
foreach ($r as $it) {
$network_group[] = $it;
}
} }
$intros1 = q("SELECT `intro`.`id`, `intro`.`datetime`, $intros1 = q("SELECT `intro`.`id`, `intro`.`datetime`,
@ -223,11 +220,11 @@ function ping_init(&$a) {
<home>$home</home>\r\n"; <home>$home</home>\r\n";
if ($register!=0) echo "<register>$register</register>"; if ($register!=0) echo "<register>$register</register>";
if ( count($network_group) ) { if ( count($network_group) ) {
echo '<groups uid="' . intval(local_user()) . '">'; echo '<group_posts>';
foreach ($network_group as $it) { foreach ($network_group as $it) {
echo '<group id="' . $it['id'] . '">' . $it['count'] . "</group>"; echo '<group id="' . $it['id'] . '">' . $it['count'] . "</group>";
} }
echo "</groups>"; echo "</group_posts>";
} }
echo "<all-events>$all_events</all-events> echo "<all-events>$all_events</all-events>