summaryrefslogtreecommitdiffstats
path: root/controller
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-03-22 23:23:08 +0100
committerBernhard Posselt <nukeawhale@gmail.com>2013-03-22 23:23:08 +0100
commitddfe6fd4de5de943cb92259b9a0a98bb9f5413b0 (patch)
tree60885b7157ce164b9e2ac4029f5c817a685456f6 /controller
parent0b530f2cf5b58669f8dccfd19097618459c1bcdc (diff)
check if active feed or folder exist
Diffstat (limited to 'controller')
-rw-r--r--controller/feedcontroller.php24
1 files changed, 21 insertions, 3 deletions
diff --git a/controller/feedcontroller.php b/controller/feedcontroller.php
index 62af79197..27ab07408 100644
--- a/controller/feedcontroller.php
+++ b/controller/feedcontroller.php
@@ -32,16 +32,21 @@ use \OCA\AppFramework\Db\DoesNotExistException;
use \OCA\AppFramework\Db\MultipleObjectsReturnedException;
use \OCA\News\Bl\FeedBl;
+use \OCA\News\Bl\FolderBl;
use \OCA\News\Bl\BLException;
+use \OCA\News\Db\FeedType;
class FeedController extends Controller {
private $feedBl;
+ private $folderBl;
- public function __construct(API $api, Request $request, FeedBl $feedBl){
+ public function __construct(API $api, Request $request, FeedBl $feedBl,
+ FolderBl $folderBl){
parent::__construct($api, $request);
$this->feedBl = $feedBl;
+ $this->folderBl = $folderBl;
}
@@ -68,8 +73,21 @@ class FeedController extends Controller {
* @Ajax
*/
public function active(){
- $feedId = $this->api->getUserValue('lastViewedFeedId');
- $feedType = $this->api->getUserValue('lastViewedFeedType');
+ $userId = $this->api->getUserId();
+ $feedId = $this->api->getUserValue($userId, 'lastViewedFeedId');
+ $feedType = $this->api->getUserValue($userId, 'lastViewedFeedType');
+
+ // check if feed or folder exist
+ try {
+ if($feedType === FeedType::FOLDER){
+ $this->folderBl->find($feedId, $userId);
+ } elseif ($feedType === FeedType::FEED){
+ $this->feedBl->find($feedId, $userId);
+ }
+ } catch (BLException $ex){
+ $feedId = 0;
+ $feedType = FeedType::SUBSCRIPTIONS;
+ }
$params = array(
'activeFeed' => array(