start on network/home notification refactor

This commit is contained in:
friendica
2012-10-27 04:43:39 -07:00
parent 4d97432214
commit 96c8e74438
3 changed files with 94 additions and 8 deletions

View File

@@ -2,6 +2,7 @@
require_once('include/bbcode.php');
require_once('include/notify.php');
function ping_init(&$a) {
@@ -88,7 +89,33 @@ function ping_init(&$a) {
killme();
}
if(argc() > 1 && (argv(1) === 'network' || argv(1) === 'home')) {
$result = array();
$r = q("SELECT id, item_restrict, item_flags FROM item
WHERE item_restrict = %d and item_flags & %d and `item`.`uid` = %d",
intval(ITEM_VISIBLE),
intval(ITEM_UNSEEN),
intval(local_user())
);
if($r) {
foreach($r as $item) {
if((argv(1) === 'home') && (! ($item['item_flags'] & ITEM_HOME)))
continue;
$result[] = format_notification($item);
}
}
echo json_encode(array( argv(1) => $result));
killme();
}
// Normal ping - just the counts
$t = q("select count(*) as total from notify where uid = %d and seen = 0",
intval(local_user())