]> git.wh0rd.org Git - tt-rss.git/commitdiff
fix multiple issues with archived feeds
authorAndrew Dolgov <noreply@fakecake.org>
Tue, 26 Jan 2016 16:03:05 +0000 (19:03 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Tue, 26 Jan 2016 16:03:05 +0000 (19:03 +0300)
classes/feeds.php
classes/rpc.php
include/functions2.php

index df0fd440b8a1c2422832140d522a79310a333b93..61b1f738e58958bccb948b497d36d80a0559bf77 100755 (executable)
@@ -671,7 +671,7 @@ class Feeds extends Handler_Protected {
                        if ($line["orig_feed_id"]) {
 
                                $tmp_result = $this->dbh->query("SELECT * FROM ttrss_archived_feeds
-                                       WHERE id = ".$line["orig_feed_id"]);
+                                       WHERE id = ".$line["orig_feed_id"] . " AND owner_uid = " . $_SESSION["uid"]);
 
                                                if ($this->dbh->num_rows($tmp_result) != 0) {
 
index d8f2088e13d902614031c3e2e2e55191dfe08561..235db59ef21bb076dce990871e6312ffdd2f2466 100755 (executable)
@@ -165,7 +165,7 @@ class RPC extends Handler_Protected {
 
                        $result = $this->dbh->query("SELECT feed_url,site_url,title FROM ttrss_archived_feeds
                                WHERE id = (SELECT orig_feed_id FROM ttrss_user_entries WHERE ref_id = $id
-                               AND owner_uid = ".$_SESSION["uid"].")");
+                               AND owner_uid = ".$_SESSION["uid"].") AND owner_uid = " . $_SESSION["uid"]);
 
                        if ($this->dbh->num_rows($result) != 0) {
                                $feed_url = $this->dbh->escape_string(db_fetch_result($result, 0, "feed_url"));
@@ -237,17 +237,22 @@ class RPC extends Handler_Protected {
 
                        if ($feed_id) {
                                $result = $this->dbh->query("SELECT id FROM ttrss_archived_feeds
-                                       WHERE id = '$feed_id'");
+                                       WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
 
                                if ($this->dbh->num_rows($result) == 0) {
+                                       $result = db_query("SELECT MAX(id) AS id FROM ttrss_archived_feeds");
+                                       $new_feed_id = (int)db_fetch_result($result, 0, "id") + 1;
+
                                        $this->dbh->query("INSERT INTO ttrss_archived_feeds
                                                (id, owner_uid, title, feed_url, site_url)
-                                       SELECT id, owner_uid, title, feed_url, site_url from ttrss_feeds
+                                       SELECT $new_feed_id, owner_uid, title, feed_url, site_url from ttrss_feeds
                                        WHERE id = '$feed_id'");
+                               } else {
+                                       $new_feed_id = $this->dbh->fetch_result($result, 0, "id");
                                }
 
                                $this->dbh->query("UPDATE ttrss_user_entries
-                                       SET orig_feed_id = feed_id, feed_id = NULL
+                                       SET orig_feed_id = $new_feed_id, feed_id = NULL
                                        WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
                        }
                }
index fb2fff286ff610d533023b9ee5262ed58ada7537..15797a95db12ba6de78ecc79f52c48a1e86ca532 100755 (executable)
                        if ($line["orig_feed_id"]) {
 
                                $tmp_result = db_query("SELECT * FROM ttrss_archived_feeds
-                                       WHERE id = ".$line["orig_feed_id"]);
+                                       WHERE id = ".$line["orig_feed_id"] . " AND owner_uid = " . $_SESSION["uid"]);
 
                                if (db_num_rows($tmp_result) != 0) {