]> git.wh0rd.org Git - tt-rss.git/commitdiff
feed browser now works
authorAndrew Dolgov <fox@bah.spb.su>
Thu, 29 Dec 2005 18:25:07 +0000 (19:25 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Thu, 29 Dec 2005 18:25:07 +0000 (19:25 +0100)
backend.php
prefs.js

index 626df1d064aeb8c034d75dba85042d4e74845e50..14e911449ef4e4610465ae87970fa29fcef0920e 100644 (file)
                $subop = $_REQUEST["subop"];
                $quiet = $_REQUEST["quiet"];
 
+               if ($subop == "massSubscribe") {
+                       $ids = split(",", db_escape_string($_GET["ids"]));
+
+                       foreach ($ids as $id) {
+                               $result = db_query($link, "SELECT feed_url,title FROM ttrss_feeds
+                                       WHERE id = '$id'");
+
+                               $feed_url = db_fetch_result($result, 0, "feed_url");
+                               $title = db_fetch_result($result, 0, "title");
+
+                               $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE
+                                       feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
+
+                               if (db_num_rows($result) == 0) {                        
+                                       $result = db_query($link,
+                                               "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id) 
+                                               VALUES ('".$_SESSION["uid"]."', '$feed_url', '$title', NULL)");
+                               }
+                       }
+               }               
+
                if ($subop == "browse") {
                        
                        print "<div class=\"infoBoxContents\">";
                                        $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
                                }
 
-                               $check_box = "<input class='feedBrowseCB' type=\"checkbox\" id=\"BFCHK-" . $details["id"] . "\">";
+                               $check_box = "<input class='feedBrowseCB' type=\"checkbox\" id=\"FBCHK-" . 
+                                       $details["id"] . "\">";
 
-                               print "<li>$check_box $feed_icon" . $details["title"] . 
+                               print "<li id=\"FBROW-".$details["id"]."\">$check_box $feed_icon" . 
+                                       $details["title"] . 
                                        "&nbsp;<span class='subscribers'>($subscribers)</span></li>";
                                                                }
 
index 3f88fff1977b14f8d520fc6dfbc8fdba0a61b8f1..82196d2a937a498b1c7c704fb260e7c9f90ebe3f 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -1293,3 +1293,37 @@ function browseFeeds() {
        xmlhttp.send(null);
 
 }
+
+function feedBrowserSubscribe() {
+       try {
+               var list = document.getElementById("browseFeedList");
+
+               var selected = new Array();
+
+               for (i = 0; i < list.childNodes.length; i++) {
+                       var child = list.childNodes[i];
+                       if (child.id && child.id.match("FBROW-")) {
+                               var id = child.id.replace("FBROW-", "");
+                               
+                               var cb = document.getElementById("FBCHK-" + id);
+
+                               if (cb.checked) {
+                                       selected.push(id);
+                               }
+                       }
+               }
+
+               if (selected.length > 0) {
+                       closeInfoBox();
+                       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
+                               param_escape(selected.toString()), true);
+                       xmlhttp.onreadystatechange=feedlist_callback;
+                       xmlhttp.send(null);
+               } else {
+                       alert("No feeds are selected.");
+               }
+
+       } catch (e) {
+               exception_error("feedBrowserSubscribe", e);
+       }
+}