]> git.wh0rd.org - tt-rss.git/blobdiff - functions.php
Merge branch 'digest-experimental'
[tt-rss.git] / functions.php
index 232ee7c1fadd8c2221c1393a80a9a0081cba2914..d628ec743e7a575fdc36512222b41457af8d20f0 100644 (file)
        } // function purge_feed
 
        /**
-        * Purge old posts from old feeds.
+        * Purge old posts from old feeds. Not used anymore, purging is done after feed update.
         * 
         * @param mixed $link A database connection
         * @param boolean $do_output Set to true to enable printed output, false by default.
         * @access public
         * @return void
         */
-       function global_purge_old_posts($link, $do_output = false, $limit = false) {
+       /* function global_purge_old_posts($link, $do_output = false, $limit = false) {
 
                $random_qpart = sql_random_function();
 
                        }
                }       
 
-               // purge orphaned posts in main content table
-               $result = db_query($link, "DELETE FROM ttrss_entries WHERE 
-                       (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0");
-
-               if ($do_output) {
-                       $rows = db_affected_rows($link, $result);
-                       _debug("Purged $rows orphaned posts.");
-               }
+               purge_orphans($link, $do_output);
 
-       } // function global_purge_old_posts
+       } // function global_purge_old_posts */
 
        function feed_purge_interval($link, $feed_id) {
 
                purge_orphans($link);
        }
 
-       function purge_orphans($link) {
+       function purge_orphans($link, $do_output = false) {
+
                // purge orphaned posts in main content table
-               db_query($link, "DELETE FROM ttrss_entries WHERE 
+               $result = db_query($link, "DELETE FROM ttrss_entries WHERE 
                        (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0");
+
+               if ($do_output) {
+                       $rows = db_affected_rows($link, $result);
+                       _debug("Purged $rows orphaned posts.");
+               }
        }
 
        function get_feed_update_interval($link, $feed_id) {
        
                                $_SESSION["ip_address"] = $_SERVER["REMOTE_ADDR"];
                                $_SESSION["pwd_hash"] = db_fetch_result($result, 0, "pwd_hash");
+
+                               $_SESSION["last_version_check"] = time();
        
                                initialize_user_prefs($link, $_SESSION["uid"]);
        
                print "<param key=\"cdm_auto_catchup\" value=\"" . 
                        (int) get_pref($link, "CDM_AUTO_CATCHUP") . "\"/>";
 
+               print "<param key=\"fresh_article_max_age\" value=\"" . 
+                       (int) get_pref($link, "FRESH_ARTICLE_MAX_AGE") . "\"/>";
+
                print "<param key=\"icons_url\" value=\"" . ICONS_URL . "\"/>";
 
                print "<param key=\"cookie_lifetime\" value=\"" . SESSION_COOKIE_LIFETIME . "\"/>";
                }
 
                error_reporting(0);
-               if (DEFAULT_UPDATE_INTERVAL == "1") {
+               if (DEFAULT_UPDATE_METHOD == "1") {
                        $rss = new SimplePie();
                        $rss->set_useragent(SIMPLEPIE_USERAGENT . MAGPIE_USER_AGENT_EXT);
 //                     $rss->set_timeout(MAGPIE_FETCH_TIME_OUT);
                                }
 
                                $tmp_result = db_query($link, "SELECT always_display_enclosures FROM
-                                       ttrss_feeds WHERE id = ".$line['feed_id']." AND owner_uid = ".$_SESSION["uid"]);
+                                       ttrss_feeds WHERE id = ".
+                                               (($line['feed_id'] == null) ? $line['orig_feed_id'] : 
+                                                               $line['feed_id'])." AND owner_uid = ".$_SESSION["uid"]);
 
                                $always_display_enclosures = db_fetch_result($tmp_result, 0, "always_display_enclosures");