]> git.wh0rd.org - tt-rss.git/blobdiff - backend.php
misc interface cleanups, only allow daemon to start when ENABLE_UPDATE_DAEMON is...
[tt-rss.git] / backend.php
index 8c988ae955ba9970e587c5798c11163888a2de3b..d1ff69142ee71fecc1f332a0a14f14cb3625ed8b 100644 (file)
@@ -28,7 +28,7 @@
                exit;
        }
 
-       define('SCHEMA_VERSION', 4);
+       define('SCHEMA_VERSION', 5);
 
        require_once "sanity_check.php";
        require_once "config.php";
@@ -61,6 +61,7 @@
                }  
 
                setcookie('ttrss_vf_refresh', FEEDS_FRAME_REFRESH);
+               setcookie('ttrss_vf_daemon', ENABLE_UPDATE_DAEMON);
        }
 
        $fetch = $_GET["fetch"];
 
                if ($subop == "forceUpdateAllFeeds" || $subop == "updateAllFeeds") {
        
-                       if (ENABLE_UPDATE_SCHEDULER) {
+                       if (ENABLE_UPDATE_DAEMON) {
 
-                               $result = db_query($link, "SELECT count(id) AS cid FROM
-                                       ttrss_scheduled_updates WHERE feed_id IS NULL AND
-                                               owner_uid = " . $_SESSION["uid"]);
-
-                               $cid = db_fetch_result($result, 0, "cid");
-
-                               print "<rpc-reply>";
-
-                               if ($cid == 0) {
+                               if ($subop == "forceUpdateAllFeeds") {                          
 
-                                       db_query($link, "INSERT INTO ttrss_scheduled_updates
-                                               (owner_uid, feed_id, entered) VALUES
-                                               (".$_SESSION["uid"].", NULL, NOW())");
+                                       $result = db_query($link, "SELECT count(id) AS cid FROM
+                                               ttrss_scheduled_updates WHERE feed_id IS NULL AND
+                                                       owner_uid = " . $_SESSION["uid"]);
+       
+                                       $cid = db_fetch_result($result, 0, "cid");
+       
+#                                      print "<rpc-reply>";
+       
+                                       if ($cid == 0) {
+       
+                                               db_query($link, "INSERT INTO ttrss_scheduled_updates
+                                                       (owner_uid, feed_id, entered) VALUES
+                                                       (".$_SESSION["uid"].", NULL, NOW())");
+                                                       
+//                                             print "<!-- ScheduledOK -->";
                                                
-                                       print "<message>ScheduledOK</message>";
-                                       
-                               } else {
-                                       print "<message>RequestAlreadyInQueue</message>";
+                                       } else {
+//                                             print "<!-- RequestAlreadyInQueue -->";
+                                       }
+       
+#                                      print "</rpc-reply>";
                                }
-
-                               print "</rpc-reply>";
                                
                        } else {        
                                update_all_feeds($link, $subop == "forceUpdateAllFeeds");
                        }
 
-                       if (!(ENABLE_UPDATE_SCHEDULER && $subop == "forceUpdateAllFeeds")) {
-
-                               $omode = $_GET["omode"];
+                       $omode = $_GET["omode"];
 
-                               if (!$omode) $omode = "tfl";
+                       if (!$omode) $omode = "tfl";
 
-                               print "<rpc-reply>";
-                               if (strchr($omode, "l")) getLabelCounters($link);
-                               if (strchr($omode, "f")) getFeedCounters($link);
-                               if (strchr($omode, "t")) getTagCounters($link);
-                               if (get_pref($link, 'ENABLE_FEED_CATS')) {
-                                       getCategoryCounters($link);
-                               }
-                               getGlobalCounters($link);
-                               print "</rpc-reply>";
+                       print "<rpc-reply>";
+                       if (strchr($omode, "l")) getLabelCounters($link);
+                       if (strchr($omode, "f")) getFeedCounters($link);
+                       if (strchr($omode, "t")) getTagCounters($link);
+                       if (get_pref($link, 'ENABLE_FEED_CATS')) {
+                               getCategoryCounters($link);
                        }
+                       getGlobalCounters($link);
+                       print "</rpc-reply>";
+
                }
        
                /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */
 
                if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) {
 
-                       if (ENABLE_UPDATE_SCHEDULER) {
+/*                     if (ENABLE_UPDATE_DAEMON) {
 
                                if ($cid == 0) {
 
                                                (".$_SESSION["uid"].", '$feed', NOW())");
                                }
 
-                       } else {
-                               $tmp_result = db_query($link, "SELECT feed_url FROM ttrss_feeds
-                                       WHERE id = '$feed'");
-                               $feed_url = db_fetch_result($tmp_result, 0, "feed_url");
-                               update_rss_feed($link, $feed_url, $feed);
-                       }
+                       } else { 
+                               // fixme update_rss_feed...
+                       } */
+
+                       $tmp_result = db_query($link, "SELECT feed_url FROM ttrss_feeds
+                               WHERE id = '$feed'");
+                       $feed_url = db_fetch_result($tmp_result, 0, "feed_url");                                
+                       update_rss_feed($link, $feed_url, $feed, ENABLE_UPDATE_DAEMON);
                }
 
                if ($subop == "MarkAllRead")  {