aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2016-09-24 17:36:33 +0200
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2016-09-24 17:36:33 +0200
commit44f22ab8b4c46befab98440f69a05725928bed75 (patch)
tree71a9c76629514af82bf5706a1c64c850e7d305c2 /app
parentd9bf9b2c6f0b2cc9dec3b638841b7e3040dcf46f (diff)
API move feed to another category
https://github.com/jangernert/FeedReader/issues/59 https://github.com/FreshRSS/FreshRSS/issues/443
Diffstat (limited to 'app')
-rwxr-xr-xapp/Controllers/feedController.php14
-rw-r--r--app/Models/FeedDAO.php13
2 files changed, 14 insertions, 13 deletions
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index 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.php
index 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);