A free, self-hostable news aggregator…
API move feed to another category
Alexandre Alapetite44f22ab8b4c4
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.phpindex ffda1450d..c64b67a80 100755--- a/app/Controllers/feedController.php+++ b/app/Controllers/feedController.php@@ -511,21 +511,9 @@ class FreshRSS_feed_Controller extends Minz_ActionController {$feed_id = Minz_Request::param('f_id');$cat_id = Minz_Request::param('c_id');-- if ($cat_id === false) {- // If category was not given get the default one.- $catDAO = new FreshRSS_CategoryDAO();- $catDAO->checkDefault();- $def_cat = $catDAO->getDefault();- $cat_id = $def_cat->id();- }-$feedDAO = FreshRSS_Factory::createFeedDao();- $values = array('category' => $cat_id);- $feed = $feedDAO->searchById($feed_id);- if ($feed && ($feed->category() == $cat_id ||- $feedDAO->updateFeed($feed_id, $values))) {+ if ($feedDAO->moveFeed($feed_id, $cat_id)) {// TODO: return something useful} else {Minz_Log::warning('Cannot move feed `' . $feed_id . '` ' .diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.phpindex 475d39286..2fd2c6194 100644--- a/app/Models/FeedDAO.php+++ b/app/Models/FeedDAO.php@@ -136,6 +136,19 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {}}+ public function moveFeed($feed_id, $cat_id) {+ if ($cat_id <= 0) {+ // If category was not given get the default one.+ $catDAO = new FreshRSS_CategoryDAO();+ $catDAO->checkDefault();+ $def_cat = $catDAO->getDefault();+ $cat_id = $def_cat->id();+ }+ $feed = $this->searchById($feed_id);+ return $feed && ($feed->category() == $cat_id ||+ $this->updateFeed($feed_id, array('category' => $cat_id)));+ }+public function deleteFeed($id) {$sql = 'DELETE FROM `' . $this->prefix . 'feed` WHERE id=?';$stm = $this->bd->prepare($sql);diff --git a/p/api/greader.php b/p/api/greader.phpindex 3da1156c2..426f3fe44 100644--- a/p/api/greader.php+++ b/p/api/greader.php@@ -337,14 +337,17 @@ function subscriptionEdit($streamNames, $titles, $action, $add = '', $remove = 'break;case 'edit':if ($feedId > 0) {- //TODO+ if ($feedDAO->moveFeed($feed_id, $cat_id)) {+ exit('OK');+ } else {+ badRequest();+ }}break;}}}notImplemented();- exit('OK');}function unreadCount() { //http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/#unread-count