diff options
-rw-r--r-- | 0001-finished-folder-businesslayer.patch | 98 | ||||
-rw-r--r-- | 0002-welcome-in-the-age-of-newness.patch | 666 | ||||
-rw-r--r-- | 0003-no-kde-for-you-jan.patch | 24 | ||||
-rw-r--r-- | 0004-findAll-All-All.patch | 230 | ||||
-rw-r--r-- | appinfo/routes.php | 150 | ||||
-rw-r--r-- | dependencyinjection/dicontainer.php | 32 | ||||
-rw-r--r-- | js/app/services/persistence.coffee | 38 | ||||
-rw-r--r-- | js/public/app.js | 38 | ||||
-rw-r--r-- | js/tests/services/persistenceSpec.coffee | 40 |
9 files changed, 1255 insertions, 61 deletions
diff --git a/0001-finished-folder-businesslayer.patch b/0001-finished-folder-businesslayer.patch new file mode 100644 index 000000000..e90ddcbe2 --- /dev/null +++ b/0001-finished-folder-businesslayer.patch @@ -0,0 +1,98 @@ +From a1fb325f85af12e2eea90edb70fedcaf8d9d62ca Mon Sep 17 00:00:00 2001 +From: Bernhard Posselt <nukeawhale@gmail.com> +Date: Wed, 20 Mar 2013 23:00:39 +0100 +Subject: [PATCH 1/4] finished folder businesslayer + +--- + bl/folderbl.php | 22 +++++++--------------- + tests/bl/FeedBlTest.php | 23 +++++++++++++++++++++-- + 2 files changed, 28 insertions(+), 17 deletions(-) + +diff --git a/bl/folderbl.php b/bl/folderbl.php +index 9f9c09d..fa12380 100644 +--- a/bl/folderbl.php ++++ b/bl/folderbl.php +@@ -35,7 +35,7 @@ class FolderBl extends Bl { + } + + +- public function getAll($userId) { ++ public function findAll($userId) { + return $this->mapper->findAllFromUser($userId); + } + +@@ -55,19 +55,11 @@ class FolderBl extends Bl { + } + + +-/* +- public function modify($folderid, $name = null, $parent = null, $opened = null) { +- $folder = $this->folderMapper->find($folderid); +- if(!$folder) +- return false; +- +- if($name) +- $folder->setName($name); +- if($parent) +- $folder->setParentId($parent); +- if($opened) +- $folder->setOpened($opened); +- return $this->folderMapper->update($folder); ++ public function rename($folderId, $folderName, $userId){ ++ $folder = $this->find($folderId, $userId); ++ $folder->setName($folderName); ++ $this->mapper->update($folder); + } +-*/ ++ ++ + } +diff --git a/tests/bl/FeedBlTest.php b/tests/bl/FeedBlTest.php +index 01301b9..dca99c6 100644 +--- a/tests/bl/FeedBlTest.php ++++ b/tests/bl/FeedBlTest.php +@@ -47,7 +47,7 @@ class FolderBlTest extends \OCA\AppFramework\Utility\TestUtility { + } + + +- function testGetAll(){ ++ function testFindAll(){ + $userId = 'jack'; + $return = 'hi'; + $this->folderMapper->expects($this->once()) +@@ -55,7 +55,7 @@ class FolderBlTest extends \OCA\AppFramework\Utility\TestUtility { + ->with($this->equalTo($userId)) + ->will($this->returnValue($return)); + +- $result = $this->folderBl->getAll($userId); ++ $result = $this->folderBl->findAll($userId); + + $this->assertEquals($return, $result); + } +@@ -95,4 +95,23 @@ class FolderBlTest extends \OCA\AppFramework\Utility\TestUtility { + + } + ++ ++ public function testRename(){ ++ $folder = new Folder(); ++ $folder->setName('jooohn'); ++ ++ $this->folderMapper->expects($this->once()) ++ ->method('find') ++ ->with($this->equalTo(3)) ++ ->will($this->returnValue($folder)); ++ ++ $this->folderMapper->expects($this->once()) ++ ->method('update') ++ ->with($this->equalTo($folder)); ++ ++ $this->folderBl->rename(3, 'bogus', ''); ++ ++ $this->assertEquals('bogus', $folder->getName()); ++ } ++ + } +-- +1.8.2 + diff --git a/0002-welcome-in-the-age-of-newness.patch b/0002-welcome-in-the-age-of-newness.patch new file mode 100644 index 000000000..ddffaa127 --- /dev/null +++ b/0002-welcome-in-the-age-of-newness.patch @@ -0,0 +1,666 @@ +From d72f8d55d8eeb6e16301da3d2906d8e3df22de3e Mon Sep 17 00:00:00 2001 +From: Bernhard Posselt <nukeawhale@gmail.com> +Date: Wed, 20 Mar 2013 23:33:51 +0100 +Subject: [PATCH 2/4] welcome in the age of newness + +--- + appinfo/app.php | 5 +- + appinfo/bootstrap.php | 139 --------------------- + appinfo/routes.php | 201 ++++-------------------------- + controller/foldercontroller.php | 16 ++- + dependencyinjection/dicontainer.php | 70 +++++++++++ + tests/controller/FolderControllerTest.php | 44 +++---- + 6 files changed, 129 insertions(+), 346 deletions(-) + delete mode 100644 appinfo/bootstrap.php + create mode 100644 dependencyinjection/dicontainer.php + +diff --git a/appinfo/app.php b/appinfo/app.php +index be66754..96f56f1 100644 +--- a/appinfo/app.php ++++ b/appinfo/app.php +@@ -12,7 +12,6 @@ + + namespace OCA\News; + +-require_once \OC_App::getAppPath('news') . '/appinfo/bootstrap.php'; + + + \OCP\App::addNavigationEntry( array( +@@ -22,10 +21,10 @@ require_once \OC_App::getAppPath('news') . '/appinfo/bootstrap.php'; + 'icon' => \OC_Helper::imagePath( 'news', 'news.svg' ), + 'name' => \OC_L10N::get('news')->t('News') + )); +- ++/* + \OC_Search::registerProvider('OC_Search_Provider_News'); + + \OCP\Backgroundjob::addRegularTask( 'OCA\News\Backgroundjob', 'run' ); + \OCP\Share::registerBackend('news_item', 'OCA\News\Share_Backend_News_Item'); +- ++*/ + +diff --git a/appinfo/bootstrap.php b/appinfo/bootstrap.php +deleted file mode 100644 +index ae011cc..0000000 +--- a/appinfo/bootstrap.php ++++ /dev/null +@@ -1,139 +0,0 @@ +-<?php +-/** +-* ownCloud - News app +-* +-* @author Alessandro Cosentino +-* @author Bernhard Posselt +-* @copyright 2012 Alessandro Cosentino cosenal@gmail.com +-* @copyright 2012 Bernhard Posselt nukeawhale@gmail.com +-* +-* This file is licensed under the Affero General Public License version 3 or later. +-* See the COPYING-README file +-* +-*/ +- +-namespace OCA\News; +- +-\OC::$CLASSPATH['Pimple'] = 'apps/news/3rdparty/Pimple/Pimple.php'; +- +-\OC::$CLASSPATH['OC_Search_Provider_News'] = 'apps/news/lib/search.php'; +-\OC::$CLASSPATH['OCA\News\Backgroundjob'] = 'apps/news/lib/backgroundjob.php'; +-\OC::$CLASSPATH['OCA\News\Share_Backend_News_Item'] = 'apps/news/lib/share/item.php'; +-\OC::$CLASSPATH['OCA\News\Utils'] = 'apps/news/lib/utils.php'; +-\OC::$CLASSPATH['OCA\News\Security'] = 'apps/news/lib/security.php'; +-\OC::$CLASSPATH['OCA\News\API'] = 'apps/news/lib/api.php'; +-\OC::$CLASSPATH['OCA\News\Request'] = 'apps/news/lib/request.php'; +-\OC::$CLASSPATH['OCA\News\TemplateResponse'] = 'apps/news/lib/response.php'; +-\OC::$CLASSPATH['OCA\News\JSONResponse'] = 'apps/news/lib/response.php'; +-\OC::$CLASSPATH['OCA\News\TextDownloadResponse'] = 'apps/news/lib/response.php'; +-\OC::$CLASSPATH['OCA\News\Controller'] = 'apps/news/lib/controller.php'; +- +-\OC::$CLASSPATH['OCA\News\OPMLParser'] = 'apps/news/opmlparser.php'; +-\OC::$CLASSPATH['OCA\News\OPMLExporter'] = 'apps/news/opmlexporter.php'; +-\OC::$CLASSPATH['OCA\News\OPMLImporter'] = 'apps/news/opmlimporter.php'; +- +-\OC::$CLASSPATH['OCA\News\Enclosure'] = 'apps/news/db/enclosure.php'; +-\OC::$CLASSPATH['OCA\News\FeedMapper'] = 'apps/news/db/feedmapper.php'; +-\OC::$CLASSPATH['OCA\News\ItemMapper'] = 'apps/news/db/itemmapper.php'; +-\OC::$CLASSPATH['OCA\News\FolderMapper'] = 'apps/news/db/foldermapper.php'; +-\OC::$CLASSPATH['OCA\News\Folder'] = 'apps/news/db/folder.php'; +-\OC::$CLASSPATH['OCA\News\Feed'] = 'apps/news/db/feed.php'; +-\OC::$CLASSPATH['OCA\News\Item'] = 'apps/news/db/item.php'; +-\OC::$CLASSPATH['OCA\News\Collection'] = 'apps/news/db/collection.php'; +-\OC::$CLASSPATH['OCA\News\FeedType'] = 'apps/news/db/feedtype.php'; +-\OC::$CLASSPATH['OCA\News\StatusFlag'] = 'apps/news/db/statusflag.php'; +- +-\OC::$CLASSPATH['OCA\News\NewsController'] = 'apps/news/controller/news.controller.php'; +-\OC::$CLASSPATH['OCA\News\NewsAjaxController'] = 'apps/news/controller/news.ajax.controller.php'; +- +-\OC::$CLASSPATH['OCA\News\FolderBl'] = 'apps/news/folder.bl.php'; +-\OC::$CLASSPATH['OCA\News\FeedBl'] = 'apps/news/feed.bl.php'; +- +-\OC::$CLASSPATH['OCA\News\FolderApi'] = 'apps/news/external_api/folder.php'; +-\OC::$CLASSPATH['OCA\News\FeedApi'] = 'apps/news/external_api/feed.php'; +- +- +-/** +- * @return a new DI container with prefilled values for the news app +- */ +-function createDIContainer(){ +- $newsContainer = new \Pimple(); +- +- /** +- * CONSTANTS +- */ +- $newsContainer['AppName'] = 'news'; +- +- +- /** +- * CLASSES +- */ +- $newsContainer['API'] = $newsContainer->share(function($c){ +- return new API($c['AppName']); +- }); +- +- +- $newsContainer['Request'] = $newsContainer->share(function($c){ +- return new Request($_GET, $_POST, $_FILES); +- }); +- +- +- $newsContainer['Security'] = $newsContainer->share(function($c) { +- return new Security($c['AppName']); +- }); +- +- +- /** +- * MAPPERS +- */ +- $newsContainer['ItemMapper'] = $newsContainer->share(function($c){ +- return new ItemMapper($c['API']->getUserId()); +- }); +- +- $newsContainer['FeedMapper'] = $newsContainer->share(function($c){ +- return new FeedMapper($c['API']->getUserId()); +- }); +- +- $newsContainer['FolderMapper'] = $newsContainer->share(function($c){ +- return new FolderMapper($c['API']->getUserId()); +- }); +- +- +- /** +- * CONTROLLERS +- */ +- $newsContainer['NewsController'] = function($c){ +- return new NewsController($c['Request'], $c['API'], $c['FeedMapper'], +- $c['FolderMapper']); +- }; +- +- $newsContainer['NewsAjaxController'] = function($c){ +- return new NewsAjaxController($c['Request'], $c['API'], $c['FeedMapper'], +- $c['FolderMapper'], $c['ItemMapper']); +- }; +- +- /** +- * BUSINESS LAYER OBJECTS +- */ +- $newsContainer['FolderBl'] = $newsContainer->share(function($c){ +- return new FolderBl($c['FolderMapper']); +- }); +- +- $newsContainer['FeedBl'] = $newsContainer->share(function($c){ +- return new FeedBl($c['FeedMapper']); +- }); +- +- /** +- * EXTERNAL API LAYER +- */ +- $newsContainer['FolderApi'] = $newsContainer->share(function($c){ +- return new FolderApi($c['FolderBl']); +- }); +- +- $newsContainer['FeedApi'] = $newsContainer->share(function($c){ +- return new FeedApi($c['FeedBl']); +- }); +- +- +- return $newsContainer; +-} +\ No newline at end of file +diff --git a/appinfo/routes.php b/appinfo/routes.php +index 767e59f..ab9e173 100644 +--- a/appinfo/routes.php ++++ b/appinfo/routes.php +@@ -1,206 +1,53 @@ + <?php ++ + /** +-* ownCloud - News app ++* ownCloud - News + * ++* @author Alessandro Cosentino + * @author Bernhard Posselt +-* Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com> ++* @copyright 2012 Alessandro Cosentino cosenal@gmail.com ++* @copyright 2012 Bernhard Posselt nukeawhale@gmail.com ++* ++* This library is free software; you can redistribute it and/or ++* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE ++* License as published by the Free Software Foundation; either ++* version 3 of the License, or any later version. ++* ++* This library is distributed in the hope that it will be useful, ++* but WITHOUT ANY WARRANTY; without even the implied warranty of ++* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++* GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * +-* This file is licensed under the Affero General Public License version 3 or later. +-* See the COPYING-README file ++* You should have received a copy of the GNU Affero General Public ++* License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ + + namespace OCA\News; + +-require_once \OC_App::getAppPath('news') . '/appinfo/bootstrap.php'; +- +-/** +- * Shortcut for calling a controller method and printing the result +- * @param string $controllerName: the name of the controller under which it is +- * stored in the DI container +- * @param string $methodName: the method that you want to call +- * @param array $urlParams: an array with variables extracted from the routes +- * @param bool $disableAdminCheck: disables the check for adminuser rights +- * @param bool $isAjax: if the request is an ajax request +- */ +-function callController($controllerName, $methodName, $urlParams, $disableAdminCheck=true, +- $isAjax=false){ +- $container = createDIContainer(); +- +- // run security checks +- $security = $container['Security']; +- runSecurityChecks($security, $isAjax, $disableAdminCheck); +- +- // call the controller and render the page +- $controller = $container[$controllerName]; +- $response = $controller->$methodName($urlParams); +- echo $response->render(); +-} +- ++use \OCA\AppFramework\App; + +-/** +- * Shortcut for calling an ajax controller method and printing the result +- * @param string $controllerName: the name of the controller under which it is +- * stored in the DI container +- * @param string $methodName: the method that you want to call +- * @param array $urlParams: an array with variables extracted from the routes +- * @param bool $disableAdminCheck: disables the check for adminuser rights +- */ +-function callAjaxController($controllerName, $methodName, $urlParams, $disableAdminCheck=true){ +- callController($controllerName, $methodName, $urlParams, $disableAdminCheck, true); +-} ++use \OCA\News\DependencyInjection\DIContainer; + + + /** +- * Runs the security checks and exits on error +- * @param Security $security: the security object +- * @param bool $isAjax: if true, the ajax checks will be run, otherwise the normal +- * checks +- * @param bool $disableAdminCheck: disables the check for adminuser rights +- */ +-function runSecurityChecks($security, $isAjax=false, $disableAdminCheck=true){ +- if($disableAdminCheck){ +- $security->setIsAdminCheck(false); +- } +- +- if($isAjax){ +- $security->runAJAXChecks(); +- } else { +- $security->runChecks(); +- } +-} +- +- +-/************************* +- * Define your routes here ++ * Webinterface + */ + +- +-/** +- * Normal Routes +- */ +-$this->create('news_index', '/')->action( ++$this->create('news_index', '/')->get()->action( + function($params){ +- callController('NewsController', 'index', $params, true); ++ //App::main('FolderController', 'getAll', $params, new DIContainer()); + } + ); + +-$this->create('news_index_feed', '/feed/{feedid}')->action( +- function($params){ +- callController('NewsController', 'index', $params, true); +- } +-); + +-$this->create('news_export_opml', '/export/opml')->action( ++$this->create('news_folders', '/folders')->get()->action( + function($params){ +- callController('NewsController', 'exportOPML', $params, true); ++ App::main('FolderController', 'getAll', $params, new DIContainer()); + } + ); + + +-/** +- * AJAX Routes +- */ +-$this->create('news_ajax_init', '/ajax/init')->action( +- function($params){ +- callAjaxController('NewsAjaxController', 'init', $params); +- } +-); +- +-$this->create('news_ajax_setshowall', '/ajax/setshowall')->action( +- function($params){ +- callAjaxController('NewsAjaxController', 'setShowAll', $params); +- } +-); +- +- +-/** +- * Folders +- */ +-$this->create('news_ajax_collapsefolder', '/ajax/collapsefolder')->action( +- function($params){ +- callAjaxController('NewsAjaxController', 'collapseFolder', $params); +- } +-); +- +-$this->create('news_ajax_changefoldername', '/ajax/changefoldername')->action( +- function($params){ +- callAjaxController('NewsAjaxController', 'changeFolderName', $params); +- } +-); +- +-$this->create('news_ajax_createfolder', '/ajax/createfolder')->action( +- function($params){ +- callAjaxController('NewsAjaxController', 'createFolder', $params); +- } +-); +- +-$this->create('news_ajax_deletefolder', '/ajax/deletefolder')->action( +- function($params){ +- callAjaxController('NewsAjaxController', 'deleteFolder', $params); +- } +-); +- +- +-/** +- * Feeds +- */ +-$this->create('news_ajax_loadfeed', '/ajax/loadfeed')->action( +- function($params){ +- callAjaxController('NewsAjaxController', 'loadFeed', $params); +- } +-); +- +-$this->create('news_ajax_deletefeed', '/ajax/deletefeed')->action( +- function($params){ +- callAjaxController('NewsAjaxController', 'deleteFeed', $params); +- } +-); +- +-$this->create('news_ajax_movefeedtofolder', '/ajax/movefeedtofolder')->action( +- function($params){ +- callAjaxController('NewsAjaxController', 'moveFeedToFolder', $params); +- } +-); +- +-$this->create('news_ajax_updatefeed', '/ajax/updatefeed')->action( +- function($params){ +- callAjaxController('NewsAjaxController', 'updateFeed', $params); +- } +-); +- +-$this->create('news_ajax_createfeed', '/ajax/createfeed')->action( +- function($params){ +- callAjaxController('NewsAjaxController', 'createFeed', $params); +- } +-); +- +- +-/** +- * Items +- */ +-$this->create('news_ajax_setitemstatus', '/ajax/setitemstatus')->action( +- function($params){ +- callAjaxController('NewsAjaxController', 'setItemStatus', $params); +- } +-); +- +-$this->create('news_ajax_setallitemsread', '/ajax/setallitemsread')->action( +- function($params){ +- callAjaxController('NewsAjaxController', 'setAllItemsRead', $params); +- } +-); +- +- +-/** +- * Import stuff +- */ +-$this->create('news_ajax_importOPML', '/import')->action( +- function($params){ +- callAjaxController('NewsAjaxController', 'uploadOPML', $params); +- } +-); +- + + /** + * External API +diff --git a/controller/foldercontroller.php b/controller/foldercontroller.php +index 0f3ec83..1bf7da6 100644 +--- a/controller/foldercontroller.php ++++ b/controller/foldercontroller.php +@@ -28,16 +28,17 @@ namespace OCA\News\Controller; + use \OCA\AppFramework\Controller\Controller; + use \OCA\AppFramework\Core\API; + use \OCA\AppFramework\Http\Request; +-use \OCA\AppFramework\Db\DoesNotExistException; +-use \OCA\AppFramework\Db\MultipleObjectsReturnedException; ++ ++use \OCA\News\Bl\FolderBl; + + + class FolderController extends Controller { + ++ private $folderBl; + +- public function __construct(API $api, Request $request, $folderMapper){ ++ public function __construct(API $api, Request $request, FolderBl $folderBl){ + parent::__construct($api, $request); +- $this->folderMapper = $folderMapper; ++ $this->folderBl = $folderBl; + } + + +@@ -49,8 +50,11 @@ class FolderController extends Controller { + * Returns all folders + */ + public function getAll(){ +- $folders = $this->folderMapper->getAll(); +- return $this->renderJSON($folders); ++ $folders = $this->folderBl->findAll($this->api->getUserId()); ++ $result = array( ++ 'folders' => $folders ++ ); ++ return $this->renderJSON($result); + } + + +diff --git a/dependencyinjection/dicontainer.php b/dependencyinjection/dicontainer.php +new file mode 100644 +index 0000000..874360b +--- /dev/null ++++ b/dependencyinjection/dicontainer.php +@@ -0,0 +1,70 @@ ++<?php ++ ++/** ++* ownCloud - News ++* ++* @author Alessandro Cosentino ++* @author Bernhard Posselt ++* @copyright 2012 Alessandro Cosentino cosenal@gmail.com ++* @copyright 2012 Bernhard Posselt nukeawhale@gmail.com ++* ++* This library is free software; you can redistribute it and/or ++* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE ++* License as published by the Free Software Foundation; either ++* version 3 of the License, or any later version. ++* ++* This library is distributed in the hope that it will be useful, ++* but WITHOUT ANY WARRANTY; without even the implied warranty of ++* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++* GNU AFFERO GENERAL PUBLIC LICENSE for more details. ++* ++* You should have received a copy of the GNU Affero General Public ++* License along with this library. If not, see <http://www.gnu.org/licenses/>. ++* ++*/ ++ ++namespace OCA\News\DependencyInjection; ++ ++use OCA\AppFramework\DependencyInjection\DIContainer as BaseContainer; ++ ++use OCA\News\Controller\FolderController; ++use OCA\News\Bl\FolderBl; ++use OCA\News\Db\FolderMapper; ++ ++ ++class DIContainer extends BaseContainer { ++ ++ ++ /** ++ * Define your dependencies in here ++ */ ++ public function __construct(){ ++ // tell parent container about the app name ++ parent::__construct('news'); ++ ++ ++ /** ++ * CONTROLLERS ++ */ ++ $this['FolderController'] = $this->share(function($c){ ++ return new FolderController($c['API'], $c['Request'], $c['FolderBl']); ++ }); ++ ++ /** ++ * Business ++ */ ++ $this['FolderBl'] = $this->share(function($c){ ++ return new FolderBl($c['FolderMapper']); ++ }); ++ ++ /** ++ * MAPPERS ++ */ ++ $this['FolderMapper'] = $this->share(function($c){ ++ return new FolderMapper($c['API']); ++ }); ++ ++ ++ } ++} ++ +diff --git a/tests/controller/FolderControllerTest.php b/tests/controller/FolderControllerTest.php +index 4dfe5e2..52836b0 100644 +--- a/tests/controller/FolderControllerTest.php ++++ b/tests/controller/FolderControllerTest.php +@@ -31,6 +31,8 @@ use \OCA\AppFramework\Utility\ControllerTestUtility; + use \OCA\AppFramework\Db\DoesNotExistException; + use \OCA\AppFramework\Db\MultipleObjectsReturnedException; + ++use \OCA\News\Db\Folder; ++ + + require_once(__DIR__ . "/../classloader.php"); + +@@ -38,7 +40,7 @@ require_once(__DIR__ . "/../classloader.php"); + class FolderControllerTest extends ControllerTestUtility { + + private $api; +- private $folderMapper; ++ private $folderBl; + private $request; + private $controller; + +@@ -48,20 +50,21 @@ class FolderControllerTest extends ControllerTestUtility { + */ + public function setUp(){ + $this->api = $this->getAPIMock(); +- $this->folderMapper = $this->getMock('FolderMapper', +- array('getAll', 'setCollapsed')); ++ $this->folderBl = $this->getMockBuilder('\OCA\News\Bl\FolderBl') ++ ->disableOriginalConstructor() ++ ->getMock(); + $this->request = new Request(); + $this->controller = new FolderController($this->api, $this->request, +- $this->folderMapper); +- ++ $this->folderBl); + } + ++ + /** + * getAll + */ + public function testGetAllCalled(){ +- $this->folderMapper->expects($this->once()) +- ->method('getAll') ++ $this->folderBl->expects($this->once()) ++ ->method('findAll') + ->will($this->returnValue( array() )); + + $this->controller->getAll(); +@@ -70,18 +73,21 @@ class FolderControllerTest extends ControllerTestUtility { + + public function testGetAllReturnsFolders(){ + $return = array( +- 'folder1' => 'name1', +- 'folder2' => 'name2' ++ new Folder(), ++ new Folder(), + ); +- $this->folderMapper->expects($this->once()) +- ->method('getAll') ++ $this->folderBl->expects($this->once()) ++ ->method('findAll') + ->will($this->returnValue($return)); + + $response = $this->controller->getAll(); +- $this->assertEquals($return, $response->getParams()); ++ $expected = array( ++ 'folders' => $return ++ ); ++ $this->assertEquals($expected, $response->getParams()); + } + +- ++ + public function testGetAllAnnotations(){ + $methodName = 'getAll'; + $annotations = array('IsAdminExemption', 'IsSubAdminExemption', 'Ajax'); +@@ -91,10 +97,6 @@ class FolderControllerTest extends ControllerTestUtility { + + + public function testGetAllReturnsJSON(){ +- $this->folderMapper->expects($this->once()) +- ->method('getAll') +- ->will($this->returnValue( array() )); +- + $response = $this->controller->getAll(); + + $this->assertTrue($response instanceof JSONResponse); +@@ -106,7 +108,7 @@ class FolderControllerTest extends ControllerTestUtility { + *//* + public function testCollapseCalled(){ + $urlParams = array('folderId' => 1); +- $this->folderMapper->expects($this->once()) ++ $this->folderBl->expects($this->once()) + ->method('setCollapsed') + ->with($this->equalTo($urlParams['folderId']), $this->equalTo(true)); + $this->controller->setURLParams($urlParams); +@@ -117,7 +119,7 @@ class FolderControllerTest extends ControllerTestUtility { + + public function testCollapseReturnsNoParams(){ + $urlParams = array('folderId' => 1); +- $this->folderMapper->expects($this->once()) ++ $this->folderBl->expects($this->once()) + ->method('setCollapsed') + ->with($this->equalTo($urlParams['folderId']), $this->equalTo(true)); + $this->controller->setURLParams($urlParams); +@@ -137,7 +139,7 @@ class FolderControllerTest extends ControllerTestUtility { + + public function testCollapseReturnsJSON(){ + $urlParams = array('folderId' => 1); +- $this->folderMapper->expects($this->once()) ++ $this->folderBl->expects($this->once()) + ->method('setCollapsed') + ->with($this->equalTo($urlParams['folderId']), $this->equalTo(true)); + $this->controller->setURLParams($urlParams); +@@ -150,7 +152,7 @@ class FolderControllerTest extends ControllerTestUtility { + + private function collapseException($ex){ + $urlParams = array('folderId' => 1); +- $this->folderMapper->expects($this->once()) ++ $this->folderBl->expects($this->once()) + ->method('setCollapsed') + ->with($this->equalTo($urlParams['folderId']), $this->equalTo(true)) + ->will($this->throwException($ex)); +-- +1.8.2 + diff --git a/0003-no-kde-for-you-jan.patch b/0003-no-kde-for-you-jan.patch new file mode 100644 index 000000000..c80e35a12 --- /dev/null +++ b/0003-no-kde-for-you-jan.patch @@ -0,0 +1,24 @@ +From cf75b259ba604791494544f9569183de4a6b66a1 Mon Sep 17 00:00:00 2001 +From: Bernhard Posselt <nukeawhale@gmail.com> +Date: Wed, 20 Mar 2013 23:36:11 +0100 +Subject: [PATCH 3/4] no kde for you jan + +--- + .kdev4/news.kdev4 | 5 ----- + 1 file changed, 5 deletions(-) + delete mode 100644 .kdev4/news.kdev4 + +diff --git a/.kdev4/news.kdev4 b/.kdev4/news.kdev4 +deleted file mode 100644 +index fe496cc..0000000 +--- a/.kdev4/news.kdev4 ++++ /dev/null +@@ -1,5 +0,0 @@ +-[Buildset] +-BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x08\x00n\x00e\x00w\x00s) +- +-[Project] +-VersionControlSupport=kdevgit +-- +1.8.2 + diff --git a/0004-findAll-All-All.patch b/0004-findAll-All-All.patch new file mode 100644 index 000000000..24645b60f --- /dev/null +++ b/0004-findAll-All-All.patch @@ -0,0 +1,230 @@ +From 13a5c748036dde6d31c1ed08f92d7a116732b5cd Mon Sep 17 00:00:00 2001 +From: Alessandro Cosentino <cosenal@gmail.com> +Date: Wed, 20 Mar 2013 23:41:33 +0100 +Subject: [PATCH 4/4] findAll All All + +--- + db/itemmapper.php | 61 +++++++++++++++++++++++----- + tests/db/ItemMapperTest.php | 98 +++++++++++++++++++++++++++++++++++---------- + 2 files changed, 127 insertions(+), 32 deletions(-) + +diff --git a/db/itemmapper.php b/db/itemmapper.php +index 693dbc0..bd223a7 100644 +--- a/db/itemmapper.php ++++ b/db/itemmapper.php +@@ -3,10 +3,22 @@ + * ownCloud - News app + * + * @author Alessandro Cosentino +-* Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com> ++* @author Bernhard Posselt ++* @copyright 2012 Alessandro Cosentino cosenal@gmail.com ++* @copyright 2012 Bernhard Posselt nukeawhale@gmail.com + * +-* This file is licensed under the Affero General Public License version 3 or later. +-* See the COPYING-README file ++* This library is free software; you can redistribute it and/or ++* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE ++* License as published by the Free Software Foundation; either ++* version 3 of the License, or any later version. ++* ++* This library is distributed in the hope that it will be useful, ++* but WITHOUT ANY WARRANTY; without even the implied warranty of ++* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++* GNU AFFERO GENERAL PUBLIC LICENSE for more details. ++* ++* You should have received a copy of the GNU Affero General Public ++* License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ + +@@ -36,7 +48,7 @@ class ItemMapper extends NewsMapper { + + return $items; + } +- ++ + public function findAllFromFeed($feedId, $userId){ + $sql = 'SELECT * FROM `*PREFIX*news_items` ' . + 'WHERE user_id = ? ' . +@@ -46,17 +58,46 @@ class ItemMapper extends NewsMapper { + return $this->findAllRows($sql, $params); + } + +- public function findAllFromFolder($userId, $folderId, $status){ +- $sql = 'SELECT `*dbprefix*news_items`.* FROM `*dbprefix*news_items` ' . ++ public function findAllFromFeedByStatus($feedId, $userId, $status){ ++ $sql = 'SELECT * FROM `*PREFIX*news_items` ' . ++ 'WHERE user_id = ? ' . ++ 'AND feed_id = ? ' . ++ 'AND ((`*dbprefix*news_items`.`status` & ?) > 0)'; ++ ++ $params = array($feedId, $userId, $status); ++ return $this->findAllRows($sql, $params); ++ } ++ ++ ++ public function findAllFromFolder($userId, $folderId){ ++ $sql = $this->makeFindAllFromFolderQuery(''); ++ $params = array($userId, $folderId); ++ return $this->findAllRows($sql, $params); ++ } ++ ++ public function findAllFromFolderByStatus($userId, $folderId, $status){ ++ $sql = $this->makeFindAllFromFolderQuery('AND ((`*dbprefix*news_items`.`status` & ?) > 0)'); ++ $params = array($userId, $folderId, $status); ++ return $this->findAllRows($sql, $params); ++ } ++ ++ public function findAllFromFolderByLastMofified($userId, $folderId, $lastModified){ ++ $sql = $this->makeFindAllFromFolderQuery('AND `*dbprefix*news_items`.last_modified >= ? '); ++ $params = array($userId, $folderId, $lastModified); ++ return $this->findAllRows($sql, $params); ++ } ++ ++ private function makeFindAllFromFolderQuery($custom) { ++ return 'SELECT `*dbprefix*news_items`.* FROM `*dbprefix*news_items` ' . + 'JOIN `*dbprefix*news_feeds` ' . + 'ON `*dbprefix*news_feeds`.`id` = `*dbprefix*news_items`.`feed_id` ' . + 'WHERE `*dbprefix*news_feeds`.`user_id` = ? ' . + 'AND `*dbprefix*news_feeds`.`folder_id` = ? ' . +- 'AND ((`*dbprefix*news_items`.`status` & ?) > 0)'; +- +- $params = array($userId, $folderId, $status); +- return $this->findAllRows($sql, $params); ++ $custom; + } ++ ++ ++ + /* + request: get all items of a folder of a user (unread and read) + SELECT * FROM items +diff --git a/tests/db/ItemMapperTest.php b/tests/db/ItemMapperTest.php +index eba9175..983bfc9 100644 |