]> git.wh0rd.org Git - tt-rss.git/commitdiff
daemon: properly pass owner_uid to catchup_feed when catching up a newly subscribed...
authorAndrew Dolgov <fox@bah.org.ru>
Fri, 6 Mar 2009 15:21:54 +0000 (18:21 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Fri, 6 Mar 2009 15:21:54 +0000 (18:21 +0300)
functions.php

index d59d5aa125d9c68adc2c1e4413354d6e8e75ec4c..92387c856233dfde9b304395d6f4ce01ca37a7b7 100644 (file)
                                if (defined('DAEMON_EXTENDED_DEBUG') || $_GET['xdebug']) {
                                        _debug("update_rss_feed: new feed, catching it up...");
                                }
-                               catchup_feed($link, $feed, false);
+                               catchup_feed($link, $feed, false, $owner_uid);
                        }
 
                        if (!$hidden) {
                }
        }
 
-       function catchup_feed($link, $feed, $cat_view) {
+       function catchup_feed($link, $feed, $cat_view, $owner_uid) {
+
+                       if (!$owner_uid) $owner_uid = $_SESSION['uid'];
 
                        if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) {
                        
                                                }
                                        
                                                $tmp_result = db_query($link, "SELECT id 
-                                                       FROM ttrss_feeds WHERE $cat_qpart AND owner_uid = " . 
-                                                       $_SESSION["uid"]);
+                                                       FROM ttrss_feeds WHERE $cat_qpart AND owner_uid = $owner_uid");
 
                                                while ($tmp_line = db_fetch_assoc($tmp_result)) {
 
 
                                                        db_query($link, "UPDATE ttrss_user_entries 
                                                                SET unread = false,last_read = NOW() 
-                                                               WHERE feed_id = '$tmp_feed' AND owner_uid = " . $_SESSION["uid"]);
+                                                               WHERE feed_id = '$tmp_feed' AND owner_uid = $owner_uid");
                                                }
                                        } else if ($feed == -2) {
 
                                                db_query($link, "UPDATE ttrss_user_entries 
                                                        SET unread = false,last_read = NOW() WHERE (SELECT COUNT(*) 
                                                                FROM ttrss_user_labels2 WHERE article_id = ref_id) > 0 
-                                                       AND unread = true AND owner_uid = " . $_SESSION["uid"]);
+                                                       AND unread = true AND owner_uid = $owner_uid");
                                        }
 
                                } else if ($feed > 0) {
                                                db_query($link, "UPDATE ttrss_user_entries 
                                                        SET unread = false,last_read = NOW() 
                                                        WHERE (feed_id = '$feed' OR $children_qpart) 
-                                                       AND owner_uid = " . $_SESSION["uid"]);
+                                                       AND owner_uid = $owner_uid");
 
                                        } else {                                                
                                                db_query($link, "UPDATE ttrss_user_entries 
                                                        SET unread = false,last_read = NOW() 
-                                                       WHERE feed_id = '$feed' AND owner_uid = " . $_SESSION["uid"]);
+                                                       WHERE feed_id = '$feed' AND owner_uid = $owner_uid");
                                        }
                                                
                                } else if ($feed < 0 && $feed > -10) { // special, like starred
                                        if ($feed == -1) {
                                                db_query($link, "UPDATE ttrss_user_entries 
                                                        SET unread = false,last_read = NOW()
-                                                       WHERE marked = true AND owner_uid = ".$_SESSION["uid"]);
+                                                       WHERE marked = true AND owner_uid = $owner_uid");
                                        }
 
                                        if ($feed == -2) {
                                                db_query($link, "UPDATE ttrss_user_entries 
                                                        SET unread = false,last_read = NOW()
-                                                       WHERE published = true AND owner_uid = ".$_SESSION["uid"]);
+                                                       WHERE published = true AND owner_uid = $owner_uid");
                                        }
 
                                        if ($feed == -3) {
                                                        ttrss_user_entries WHERE $match_part AND
                                                        unread = true AND
                                                        ttrss_user_entries.ref_id = ttrss_entries.id AND        
-                                                       owner_uid = ".$_SESSION["uid"]);
+                                                       owner_uid = $owner_uid");
 
                                                $affected_ids = array();
 
                                        if ($feed == -4) {
                                                db_query($link, "UPDATE ttrss_user_entries 
                                                        SET unread = false,last_read = NOW()
-                                                       WHERE owner_uid = ".$_SESSION["uid"]);
+                                                       WHERE owner_uid = $owner_uid");
                                        }
 
                                } else if ($feed < -10) { // label
                                        db_query($link, "UPDATE ttrss_user_entries, ttrss_user_labels2 
                                                SET unread = false, last_read = NOW() 
                                                        WHERE label_id = '$label_id' AND unread = true
-                                                       AND owner_uid = '".$_SESSION["uid"]."' AND ref_id = article_id");
+                                                       AND owner_uid = '$owner_uid' AND ref_id = article_id");
 
                                }
 
                                $tag_name = db_escape_string($feed);
 
                                $result = db_query($link, "SELECT post_int_id FROM ttrss_tags
-                                       WHERE tag_name = '$tag_name' AND owner_uid = " . $_SESSION["uid"]);
+                                       WHERE tag_name = '$tag_name' AND owner_uid = $owner_uid");
 
                                while ($line = db_fetch_assoc($result)) {
                                        db_query($link, "UPDATE ttrss_user_entries SET