From d9acb9ed876d9814e468081d799f06ffd631580f Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Wed, 14 May 2014 18:08:52 +0200 Subject: add serverside possibility to order by oldest first --- controller/itemcontroller.php | 7 +++++-- controller/pagecontroller.php | 42 ++++++++++++++++++++++-------------------- 2 files changed, 27 insertions(+), 22 deletions(-) (limited to 'controller') diff --git a/controller/itemcontroller.php b/controller/itemcontroller.php index dfc059505..0f590950e 100644 --- a/controller/itemcontroller.php +++ b/controller/itemcontroller.php @@ -57,6 +57,8 @@ class ItemController extends Controller { public function index($type, $id, $limit, $offset=0) { $showAll = $this->settings->getUserValue($this->userId, $this->appName, 'showAll') === '1'; + $oldestFirst = $this->settings->getUserValue($this->userId, $this->appName, + 'oldestFirst') === '1'; $this->settings->setUserValue($this->userId, $this->appName, 'lastViewedFeedId', $id); @@ -77,8 +79,9 @@ class ItemController extends Controller { $params['starred'] = $this->itemBusinessLayer->starredCount($this->userId); } - $params['items'] = $this->itemBusinessLayer->findAll($id, $type, $limit, - $offset, $showAll, $this->userId); + $params['items'] = $this->itemBusinessLayer->findAll( + $id, $type, $limit, $offset, $showAll, $this->userId, $oldestFirst + ); // this gets thrown if there are no items // in that case just return an empty array diff --git a/controller/pagecontroller.php b/controller/pagecontroller.php index 88154803f..db0fa48bf 100644 --- a/controller/pagecontroller.php +++ b/controller/pagecontroller.php @@ -51,17 +51,17 @@ class PageController extends Controller { * @NoAdminRequired */ public function settings() { - $showAll = $this->settings->getUserValue($this->userId, $this->appName, - 'showAll'); - $compact = $this->settings->getUserValue($this->userId, $this->appName, - 'compact'); - $language = $this->l10n->getLanguageCode(); - - return [ - 'showAll' => $showAll === '1', - 'compact' => $compact === '1', - 'language' => $language - ]; + $settings = ['showAll', 'compact', 'readOnScroll', 'oldestFirst']; + + $result = ['language' => $this->l10n->getLanguageCode()]; + + foreach ($settings as $setting) { + $result[$setting] = $this->settings->getUserValue( + $this->userId, $this->appName, $setting + ) === '1'; + } + + return $result; } @@ -70,17 +70,19 @@ class PageController extends Controller { * * @param bool $showAll * @param bool $compact + * @param bool $readOnScroll + * @param bool $oldestFirst */ - public function updateSettings($showAll, $compact) { - if($showAll !== null) { - $this->settings->setUserValue($this->userId, $this->appName, - 'showAll', $showAll); - } - - if($compact !== null) { - $this->settings->setUserValue($this->userId, $this->appName, - 'compact', $compact); + public function updateSettings($showAll, $compact, $readOnScroll, $oldestFirst) { + $settings = ['showAll', 'compact', 'readOnScroll', 'oldestFirst']; + + foreach ($settings as $setting) { + if(${$setting} !== null) { + $this->settings->setUserValue($this->userId, $this->appName, + $setting, ${$setting}); + } } } + } \ No newline at end of file -- cgit v1.2.3