]> git.wh0rd.org Git - tt-rss.git/commitdiff
add auth support to subscribe-to-feed dialog
authorAndrew Dolgov <fox@bah.spb.su>
Wed, 25 Apr 2007 15:00:08 +0000 (16:00 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Wed, 25 Apr 2007 15:00:08 +0000 (16:00 +0100)
functions.js
functions.php
modules/popup-dialog.php
modules/pref-feeds.php
tt-rss.css

index 7fe79c9a821f6ce4ea2825b848ff4082fa4fc465..b26f75fd8a1ebd7d719d6ce952a4592d6c2e1705 100644 (file)
@@ -1252,11 +1252,18 @@ function getRelativeFeedId(list, id, direction, unread_only) {
        }
 }
 
-function showBlockElement(id) {
+function showBlockElement(id, h_id) {
        var elem = document.getElementById(id);
 
        if (elem) {
                elem.style.display = "block";
+
+               if (h_id) {
+                       elem = document.getElementById(h_id);
+                       if (elem) {
+                               elem.style.display = "none";
+                       }
+               }
        } else {
                alert("[showBlockElement] can't find element with id " + id);
        } 
@@ -1437,6 +1444,8 @@ function qaddFeed() {
        
        var query = Form.serialize("feed_add_form");
        
+       debug("subscribe q: " + query);
+
 /*     xmlhttp.open("GET", "backend.php?" + query, true);
        xmlhttp.onreadystatechange=dlg_frefresh_callback;
        xmlhttp.send(null); */
index 4044639a5c222a885e668832b777ca8b74de37a8..dee0d08c324c45e66a6d21b8c45d1597992c91c2 100644 (file)
                print "</rpc-reply>";
        }
 
-       function subscribe_to_feed($link, $feed_link, $cat_id = 0) {
+       function subscribe_to_feed($link, $feed_link, $cat_id = 0, 
+                       $auth_login = '', $auth_pass = '') {
 
                # check for feed:http://url
                $feed_link = trim(preg_replace("/^feed:/", "", $feed_link));
                if (db_num_rows($result) == 0) {
                        
                        $result = db_query($link,
-                               "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id) 
+                               "INSERT INTO ttrss_feeds 
+                                       (owner_uid,feed_url,title,cat_id, auth_login,auth_pass) 
                                VALUES ('".$_SESSION["uid"]."', '$feed_link', 
-                               '[Unknown]', $cat_qpart)");
+                               '[Unknown]', $cat_qpart, '$auth_login', '$auth_pass')");
        
                        $result = db_query($link,
                                "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link' 
-                               AND owner_uid = " . $_SESSION["uid"]);
+                                       AND owner_uid = " . $_SESSION["uid"]);
        
                        $feed_id = db_fetch_result($result, 0, "id");
        
index b69d36e2f57a4039405dc6bfebdf76ed41c0751e..7eab1bae7d654d742919883faa58fba284fd310f 100644 (file)
                        print "</div></td></tr>"; */
 
                        print "</table>";
+
+                       print "<div id='fadd_login_prompt'><br/>
+                               <a href='javascript:showBlockElement(\"fadd_login_container\", 
+                                       \"fadd_login_prompt\")'>Click here if this feed requires authentication.</a></div>";
+
+                       print "<div id='fadd_login_container'>
+                               <table width='100%'>
+                                       <tr><td>Login:</td><td><input name='auth_login' class='iedit'></td></tr>
+                                       <tr><td>Password:</td><td><input type='password'
+                                               name='auth_pass' class='iedit'></td></tr>
+                               </table>
+                               </div>";
+
                        print "</form>";
 
                        print "<div align='right'>
index 61fc2167c335a098d3cf7f4af530f79c6789328f..c11ce2aa30687052045783fc52f4af5273a643b2 100644 (file)
                
                        if (!WEB_DEMO_MODE) {
 
-                               $feed_url = db_escape_string(trim($_POST["feed_url"]));
-                               $cat_id = db_escape_string($_POST["cat_id"]);
-                               $p_from = db_escape_string($_POST["from"]);
+                               $feed_url = db_escape_string(trim($_REQUEST["feed_url"]));
+                               $cat_id = db_escape_string($_REQUEST["cat_id"]);
+                               $p_from = db_escape_string($_REQUEST["from"]);
+
+                               /* only read authentication information from POST */
+
+                               $auth_login = db_escape_string(trim($_POST["auth_login"]));
+                               $auth_pass = db_escape_string(trim($_POST["auth_pass"]));
 
                                if ($p_from != 'tt-rss') {
                                        print "<html>
                                                <div class=\"content\">";
                                }
 
-                               if (subscribe_to_feed($link, $feed_url, $cat_id)) {
+                               if (subscribe_to_feed($link, $feed_url, $cat_id, $auth_login, $auth_pass)) {
                                        print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
                                } else {
                                        print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
index 94a99b304e59c3f354055c26c12a973546d9bc24..0162638ba50ede078df6784ce06ff84c9b658be2 100644 (file)
@@ -1502,3 +1502,7 @@ a.helpLinkPic {
 a.helpLinkPic img {
        border-width : 0px;
 }
+
+#fadd_login_container {
+       display : none;
+}