]> git.wh0rd.org - tt-rss.git/blobdiff - classes/rpc.php
fix multiple issues with archived feeds
[tt-rss.git] / classes / rpc.php
old mode 100644 (file)
new mode 100755 (executable)
index a84883b..235db59
@@ -123,7 +123,7 @@ class RPC extends Handler_Protected {
                $key = $_REQUEST['key'];
                $value = str_replace("\n", "<br/>", $_REQUEST['value']);
 
-               set_pref($key, $value, $_SESSION['uid'], $key != 'USER_STYLESHEET');
+               set_pref($key, $value, false, $key != 'USER_STYLESHEET');
 
                print json_encode(array("param" =>$key, "value" => $value));
        }
@@ -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"]);
                        }
                }
@@ -550,7 +555,7 @@ class RPC extends Handler_Protected {
 
                // Purge orphans and cleanup tags
                purge_orphans();
-               cleanup_tags(14, 50000);
+               //cleanup_tags(14, 50000);
 
                if ($num_updated > 0) {
                        print json_encode(array("message" => "UPDATE_COUNTERS",