diff options
author | Alessandro Cosentino <cosenal@gmail.com> | 2012-07-27 10:23:01 -0400 |
---|---|---|
committer | Alessandro Cosentino <cosenal@gmail.com> | 2012-07-27 10:23:01 -0400 |
commit | 96a44ed8e8cf7c5610a07de4e450eea7ad1f8949 (patch) | |
tree | daf91c6c8dedc9929cf58dd4286cd18c7e7ecb6a /ajax | |
parent | f80555a94cc1d2fb21233b538ef8a4dd140486ea (diff) |
update counters with js when update feeds
Diffstat (limited to 'ajax')
-rw-r--r-- | ajax/updatefeed.php | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/ajax/updatefeed.php b/ajax/updatefeed.php index bc74324e3..f503d9e91 100644 --- a/ajax/updatefeed.php +++ b/ajax/updatefeed.php @@ -33,7 +33,16 @@ if(!$newfeedid) { OCP\Util::writeLog('news','ajax/updatefeed.php: Error updating feed: '.$_POST['feedid'], OCP\Util::ERROR); exit(); } - -//TODO: replace the following with a real success case. see contact/ajax/createaddressbook.php for inspirations -OCP\JSON::success(array('data' => array('message' => $l->t('Feed updated!')))); - +else { + //TODO: maybe make this more efficient by coding it into OC_News_FeedMapper->save() + $itemmapper = new OC_News_ItemMapper(); + $items = $itemmapper->findAll($newfeedid); + $unreadcounter = 0; + foreach($items as $item) { + if(!$item->isRead()) + ++$unreadcounter; + } + + OCP\JSON::success(array('data' => array('message' => $l->t('Feed updated!'), 'unreadcount' => $unreadcounter))); + exit(); +} |