summaryrefslogtreecommitdiff
path: root/classes/rpc.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2016-01-26 19:03:05 +0300
committerAndrew Dolgov <[email protected]>2016-01-26 19:03:05 +0300
commit71b75bb7faabf9e662d76a292c8260634160afee (patch)
tree2c35433f67ec2d0aa0b14f299061e0ac793a1e19 /classes/rpc.php
parent41245888f1c538f15d7ffa3a0ddc9310b60c98d7 (diff)
fix multiple issues with archived feeds
Diffstat (limited to 'classes/rpc.php')
-rwxr-xr-xclasses/rpc.php13
1 files changed, 9 insertions, 4 deletions
diff --git a/classes/rpc.php b/classes/rpc.php
index d8f2088e1..235db59ef 100755
--- a/classes/rpc.php
+++ b/classes/rpc.php
@@ -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"]);
}
}