From ddfe6fd4de5de943cb92259b9a0a98bb9f5413b0 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Fri, 22 Mar 2013 23:23:08 +0100 Subject: check if active feed or folder exist --- controller/feedcontroller.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'controller/feedcontroller.php') 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( -- cgit v1.2.3