diff options
Diffstat (limited to 'external')
-rw-r--r-- | external/feedapi.php | 226 | ||||
-rw-r--r-- | external/folderapi.php | 178 | ||||
-rw-r--r-- | external/itemapi.php | 297 | ||||
-rw-r--r-- | external/newsapi.php | 111 |
4 files changed, 0 insertions, 812 deletions
diff --git a/external/feedapi.php b/external/feedapi.php deleted file mode 100644 index be228d490..000000000 --- a/external/feedapi.php +++ /dev/null @@ -1,226 +0,0 @@ -<?php - -/** -* ownCloud - News -* -* @author Alessandro Cosentino -* @author Bernhard Posselt -* @copyright 2012 Alessandro Cosentino cosenal@gmail.com -* @copyright 2012 Bernhard Posselt dev@bernhard-posselt.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\External; - -use \OCA\AppFramework\Core\API; -use \OCA\AppFramework\Controller\Controller; -use \OCA\AppFramework\Http\Request; -use \OCA\AppFramework\Http\JSONResponse; -use \OCA\AppFramework\Http\Http; - -use \OCA\News\BusinessLayer\FeedBusinessLayer; -use \OCA\News\BusinessLayer\FolderBusinessLayer; -use \OCA\News\BusinessLayer\ItemBusinessLayer; -use \OCA\News\BusinessLayer\BusinessLayerException; -use \OCA\News\BusinessLayer\BusinessLayerConflictException; - - -class FeedAPI extends Controller { - - private $itemBusinessLayer; - private $feedBusinessLayer; - private $folderBusinessLayer; - - public function __construct(API $api, - Request $request, - FolderBusinessLayer $folderBusinessLayer, - FeedBusinessLayer $feedBusinessLayer, - ItemBusinessLayer $itemBusinessLayer){ - parent::__construct($api, $request); - $this->folderBusinessLayer = $folderBusinessLayer; - $this->feedBusinessLayer = $feedBusinessLayer; - $this->itemBusinessLayer = $itemBusinessLayer; - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @Ajax - * @API - */ - public function getAll() { - $userId = $this->api->getUserId(); - - $result = array( - 'feeds' => array(), - 'starredCount' => $this->itemBusinessLayer->starredCount($userId) - ); - - foreach ($this->feedBusinessLayer->findAll($userId) as $feed) { - array_push($result['feeds'], $feed->toAPI()); - } - - // check case when there are no items - try { - $result['newestItemId'] = - $this->itemBusinessLayer->getNewestItemId($userId); - } catch(BusinessLayerException $ex) {} - - return new JSONResponse($result); - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @Ajax - * @API - */ - public function create() { - $userId = $this->api->getUserId(); - $feedUrl = $this->params('url'); - $folderId = (int) $this->params('folderId', 0); - - try { - $this->feedBusinessLayer->purgeDeleted($userId, false); - - $feed = $this->feedBusinessLayer->create($feedUrl, $folderId, $userId); - $result = array( - 'feeds' => array($feed->toAPI()) - ); - - try { - $result['newestItemId'] = - $this->itemBusinessLayer->getNewestItemId($userId); - } catch(BusinessLayerException $ex) {} - - return new JSONResponse($result); - - } catch(BusinessLayerConflictException $ex) { - return new JSONResponse(array('message' => $ex->getMessage()), - Http::STATUS_CONFLICT); - } catch(BusinessLayerException $ex) { - return new JSONResponse(array('message' => $ex->getMessage()), - Http::STATUS_NOT_FOUND); - } - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @Ajax - * @API - */ - public function delete() { - $userId = $this->api->getUserId(); - $feedId = (int) $this->params('feedId'); - - try { - $this->feedBusinessLayer->delete($feedId, $userId); - return new JSONResponse(); - } catch(BusinessLayerException $ex) { - return new JSONResponse(array('message' => $ex->getMessage()), - Http::STATUS_NOT_FOUND); - } - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @Ajax - * @API - */ - public function read() { - $userId = $this->api->getUserId(); - $feedId = (int) $this->params('feedId'); - $newestItemId = (int) $this->params('newestItemId'); - - $this->itemBusinessLayer->readFeed($feedId, $newestItemId, $userId); - return new JSONResponse(); - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @Ajax - * @API - */ - public function move() { - $userId = $this->api->getUserId(); - $feedId = (int) $this->params('feedId'); - $folderId = (int) $this->params('folderId'); - - try { - $this->feedBusinessLayer->move($feedId, $folderId, $userId); - return new JSONResponse(); - } catch(BusinessLayerException $ex) { - return new JSONResponse(array('message' => $ex->getMessage()), - Http::STATUS_NOT_FOUND); - } - } - - - /** - * @CSRFExemption - * @Ajax - * @API - */ - public function getAllFromAllUsers() { - $feeds = $this->feedBusinessLayer->findAllFromAllUsers(); - $result = array('feeds' => array()); - - foreach ($feeds as $feed) { - array_push($result['feeds'], array( - 'id' => $feed->getId(), - 'userId' => $feed->getUserId() - )); - } - - return new JSONResponse($result); - } - - - /** - * @CSRFExemption - * @Ajax - * @API - */ - public function update() { - $userId = $this->params('userId'); - $feedId = (int) $this->params('feedId'); - - try { - $this->feedBusinessLayer->update($feedId, $userId); - // ignore update failure (feed could not be reachable etc, we dont care) - } catch(\Exception $ex) { - $this->api->log('Could not update feed ' . $ex->getMessage(), - 'debug'); - } - return new JSONResponse(); - - } - - -} diff --git a/external/folderapi.php b/external/folderapi.php deleted file mode 100644 index 5d2555e10..000000000 --- a/external/folderapi.php +++ /dev/null @@ -1,178 +0,0 @@ -<?php - -/** -* ownCloud - News -* -* @author Alessandro Cosentino -* @author Bernhard Posselt -* @copyright 2012 Alessandro Cosentino cosenal@gmail.com -* @copyright 2012 Bernhard Posselt dev@bernhard-posselt.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\External; - -use \OCA\AppFramework\Core\API; -use \OCA\AppFramework\Controller\Controller; -use \OCA\AppFramework\Http\Request; -use \OCA\AppFramework\Http\JSONResponse; -use \OCA\AppFramework\Http\Http; - -use \OCA\News\BusinessLayer\FolderBusinessLayer; -use \OCA\News\BusinessLayer\ItemBusinessLayer; -use \OCA\News\BusinessLayer\BusinessLayerException; -use \OCA\News\BusinessLayer\BusinessLayerConflictException; -use \OCA\News\BusinessLayer\BusinessLayerValidationException; - - -class FolderAPI extends Controller { - - private $folderBusinessLayer; - private $itemBusinessLayer; - - public function __construct(API $api, - Request $request, - FolderBusinessLayer $folderBusinessLayer, - ItemBusinessLayer $itemBusinessLayer){ - parent::__construct($api, $request); - $this->folderBusinessLayer = $folderBusinessLayer; - $this->itemBusinessLayer = $itemBusinessLayer; - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @Ajax - * @API - */ - public function getAll() { - $userId = $this->api->getUserId(); - $result = array( - 'folders' => array() - ); - - foreach ($this->folderBusinessLayer->findAll($userId) as $folder) { - array_push($result['folders'], $folder->toAPI()); - } - - return new JSONResponse($result); - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @Ajax - * @API - */ - public function create() { - $userId = $this->api->getUserId(); - $folderName = $this->params('name'); - $result = array( - 'folders' => array() - ); - - try { - $this->folderBusinessLayer->purgeDeleted($userId, false); - $folder = $this->folderBusinessLayer->create($folderName, $userId); - array_push($result['folders'], $folder->toAPI()); - - return new JSONResponse($result); - - } catch(BusinessLayerValidationException $ex) { - return new JSONResponse(array('message' => $ex->getMessage()), - Http::STATUS_UNPROCESSABLE_ENTITY); - - } catch(BusinessLayerConflictException $ex) { - return new JSONResponse(array('message' => $ex->getMessage()), - Http::STATUS_CONFLICT); - } - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @API - * @Ajax - */ - public function delete() { - $userId = $this->api->getUserId(); - $folderId = (int) $this->params('folderId'); - - try { - $this->folderBusinessLayer->delete($folderId, $userId); - return new JSONResponse(); - } catch(BusinessLayerException $ex) { - return new JSONResponse(array('message' => $ex->getMessage()), - Http::STATUS_NOT_FOUND); - } - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @Ajax - * @API - */ - public function update() { - $userId = $this->api->getUserId(); - $folderId = (int) $this->params('folderId'); - $folderName = $this->params('name'); - - try { - $this->folderBusinessLayer->rename($folderId, $folderName, $userId); - return new JSONResponse(); - - } catch(BusinessLayerValidationException $ex) { - return new JSONResponse(array('message' => $ex->getMessage()), - Http::STATUS_UNPROCESSABLE_ENTITY); - - } catch(BusinessLayerConflictException $ex) { - return new JSONResponse(array('message' => $ex->getMessage()), - Http::STATUS_CONFLICT); - - } catch(BusinessLayerException $ex) { - return new JSONResponse(array('message' => $ex->getMessage()), - Http::STATUS_NOT_FOUND); - } - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @Ajax - * @API - */ - public function read() { - $userId = $this->api->getUserId(); - $folderId = (int) $this->params('folderId'); - $newestItemId = (int) $this->params('newestItemId'); - - $this->itemBusinessLayer->readFolder($folderId, $newestItemId, $userId); - return new JSONResponse(); - } - - -} diff --git a/external/itemapi.php b/external/itemapi.php deleted file mode 100644 index 8fd4b3767..000000000 --- a/external/itemapi.php +++ /dev/null @@ -1,297 +0,0 @@ -<?php - -/** -* ownCloud - News -* -* @author Alessandro Cosentino -* @author Bernhard Posselt -* @copyright 2012 Alessandro Cosentino cosenal@gmail.com -* @copyright 2012 Bernhard Posselt dev@bernhard-posselt.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\External; - -use \OCA\AppFramework\Core\API; -use \OCA\AppFramework\Controller\Controller; -use \OCA\AppFramework\Http\Request; -use \OCA\AppFramework\Http\JSONResponse; -use \OCA\AppFramework\Http\Http; - -use \OCA\News\BusinessLayer\ItemBusinessLayer; -use \OCA\News\BusinessLayer\BusinessLayerException; - - -class ItemAPI extends Controller { - - private $itemBusinessLayer; - - public function __construct(API $api, - Request $request, - ItemBusinessLayer $itemBusinessLayer){ - parent::__construct($api, $request); - $this->itemBusinessLayer = $itemBusinessLayer; - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @Ajax - * @API - */ - public function getAll() { - $result = array( - 'items' => array() - ); - - $userId = $this->api->getUserId(); - $batchSize = (int) $this->params('batchSize', 20); - $offset = (int) $this->params('offset', 0); - $type = (int) $this->params('type'); - $id = (int) $this->params('id'); - $showAll = $this->params('getRead'); - - if($showAll === 'true' || $showAll === true) { - $showAll = true; - } else { - $showAll = false; - } - - $items = $this->itemBusinessLayer->findAll( - $id, - $type, - $batchSize, - $offset, - $showAll, - $userId - ); - - foreach ($items as $item) { - array_push($result['items'], $item->toAPI()); - } - - return new JSONResponse($result); - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @Ajax - * @API - */ - public function getUpdated() { - $result = array( - 'items' => array() - ); - - $userId = $this->api->getUserId(); - $lastModified = (int) $this->params('lastModified', 0); - $type = (int) $this->params('type'); - $id = (int) $this->params('id'); - - $items = $this->itemBusinessLayer->findAllNew( - $id, - $type, - $lastModified, - true, - $userId - ); - - foreach ($items as $item) { - array_push($result['items'], $item->toAPI()); - } - - return new JSONResponse($result); - } - - - private function setRead($isRead) { - $userId = $this->api->getUserId(); - $itemId = (int) $this->params('itemId'); - try { - $this->itemBusinessLayer->read($itemId, $isRead, $userId); - return new JSONResponse(); - } catch(BusinessLayerException $ex){ - return new JSONResponse(array('message' => $ex->getMessage()), - Http::STATUS_NOT_FOUND); - } - } - - - private function setStarred($isStarred) { - $userId = $this->api->getUserId(); - $feedId = (int) $this->params('feedId'); - $guidHash = $this->params('guidHash'); - try { - $this->itemBusinessLayer->star($feedId, $guidHash, $isStarred, $userId); - return new JSONResponse(); - } catch(BusinessLayerException $ex){ - return new JSONResponse(array('message' => $ex->getMessage()), - Http::STATUS_NOT_FOUND); - } - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @Ajax - * @API - */ - public function read() { - return $this->setRead(true); - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @Ajax - * @API - */ - public function unread() { - return $this->setRead(false); - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @Ajax - * @API - */ - public function star() { - return $this->setStarred(true); - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @Ajax - * @API - */ - public function unstar() { - return $this->setStarred(false); - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @Ajax - * @API - */ - public function readAll() { - $userId = $this->api->getUserId(); - $newestItemId = (int) $this->params('newestItemId'); - - $this->itemBusinessLayer->readAll($newestItemId, $userId); - return new JSONResponse(); - } - - - private function setMultipleRead($isRead) { - $userId = $this->api->getUserId(); - $items = $this->params('items'); - - foreach($items as $id) { - try { - $this->itemBusinessLayer->read($id, $isRead, $userId); - } catch(BusinessLayerException $ex) { - continue; - } - } - - return new JSONResponse(); - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @Ajax - * @API - */ - public function readMultiple() { - return $this->setMultipleRead(true); - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @Ajax - * @API - */ - public function unreadMultiple() { - return $this->setMultipleRead(false); - } - - - private function setMultipleStarred($isStarred) { - $userId = $this->api->getUserId(); - $items = $this->params('items'); - - foreach($items as $item) { - try { - $this->itemBusinessLayer->star($item['feedId'], - $item['guidHash'], $isStarred, $userId); - } catch(BusinessLayerException $ex) { - continue; - } - } - - return new JSONResponse(); - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @Ajax - * @API - */ - public function starMultiple() { - return $this->setMultipleStarred(true); - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @Ajax - * @API - */ - public function unstarMultiple() { - return $this->setMultipleStarred(false); - } - - -} diff --git a/external/newsapi.php b/external/newsapi.php deleted file mode 100644 index 51a2d9cf2..000000000 --- a/external/newsapi.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php - -/** -* ownCloud - News -* -* @author Alessandro Cosentino -* @author Bernhard Posselt -* @copyright 2012 Alessandro Cosentino cosenal@gmail.com -* @copyright 2012 Bernhard Posselt dev@bernhard-posselt.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\External; - -use \OCA\AppFramework\Core\API; -use \OCA\AppFramework\Controller\Controller; -use \OCA\AppFramework\Http\Request; -use \OCA\AppFramework\Http\JSONResponse; -use \OCA\AppFramework\Http\Response; -use \OCA\AppFramework\Http\Http; - -use \OCA\News\Utility\Updater; - - -class NewsAPI extends Controller { - - private $updater; - - public function __construct(API $api, Request $request, Updater $updater){ - parent::__construct($api, $request); - $this->updater = $updater; - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @Ajax - * @API - */ - public function version() { - $version = $this->api->getAppValue('installed_version'); - $response = new JSONResponse(array('version' => $version)); - return $response; - } - - - /** - * @CSRFExemption - * @Ajax - * @API - */ - public function beforeUpdate() { - $this->updater->beforeUpdate(); - return new JSONResponse(); - } - - - /** - * @CSRFExemption - * @Ajax - * @API - */ - public function afterUpdate() { - $this->updater->afterUpdate(); - return new JSONResponse(); - } - - - /** - * @IsAdminExemption - * @IsSubAdminExemption - * @CSRFExemption - * @IsLoggedInExemption - * @Ajax - */ - public function cors() { - // needed for webapps access due to cross origin request policy - if(isset($this->request->server['HTTP_ORIGIN'])) { - $origin = $this->request->server['HTTP_ORIGIN']; - } else { - $origin = '*'; - } - - $response = new Response(); - $response->addHeader('Access-Control-Allow-Origin', $origin); - $response->addHeader('Access-Control-Allow-Methods', - 'PUT, POST, GET, DELETE'); - $response->addHeader('Access-Control-Allow-Credentials', 'true'); - $response->addHeader('Access-Control-Max-Age', '1728000'); - $response->addHeader('Access-Control-Allow-Headers', - 'Authorization, Content-Type'); - return $response; - } - - -} |