]> git.wh0rd.org - tt-rss.git/commitdiff
allow subscribing to twitter feeds without oauth (if require auth checkbox is unset)
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 26 Jan 2012 09:48:14 +0000 (13:48 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 26 Jan 2012 09:48:14 +0000 (13:48 +0400)
classes/dlg.php
classes/rpc.php
include/functions.php

index 55eb5e37e0a2223fba2f7e2eb8eb3fb870036ee1..cd098d3968fa3d08f17a19f5a0cf738b57355b64 100644 (file)
@@ -284,12 +284,13 @@ class Dlg extends Protected_Handler {
                                " <input
                                        placeHolder=\"".__("Password")."\"
                                        dojoType=\"dijit.form.TextBox\" type='password'
-                                       style=\"width : 10em;\" name='pass'\">
+                                       style=\"width : 10em;\" name='pass'\">".
+                               " <p class='insensitive'>".__("OAuth will be used automatically for Twitter feeds.")."</p>
                        </div></div>";
 
 
                print "<div style=\"clear : both\">
-                       <input type=\"checkbox\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"
+                       <input type=\"checkbox\" name=\"need_auth\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"
                                        onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'>
                                <label for=\"feedDlg_loginCheck\">".
                                __('This feed requires authentication.')."</div>";
index 1da3a14ec7b277144d2c60393968841f6347e5c8..58e25a4562abeac5f33ab42e537bf1736f6d0971 100644 (file)
@@ -188,8 +188,9 @@ class RPC extends Protected_Handler {
                $cat = db_escape_string($_REQUEST['cat']);
                $login = db_escape_string($_REQUEST['login']);
                $pass = db_escape_string($_REQUEST['pass']);
+               $need_auth = db_escape_string($_REQUEST['need_auth']) != "";
 
-               $rc = subscribe_to_feed($this->link, $feed, $cat, $login, $pass);
+               $rc = subscribe_to_feed($this->link, $feed, $cat, $login, $pass, $need_auth);
 
                print json_encode(array("result" => $rc));
        }
index 415047458e9997382b28b91877bf7ba5a54b00a0..3ace20f86edd6955e439dac9a6831b82bc404082 100644 (file)
        }
 
        /**
-        * Subscribes the user to the given feed
-        *
-        * @param resource $link       Database connection
-        * @param string   $url        Feed URL to subscribe to
-        * @param integer  $cat_id     Category ID the feed shall be added to
-        * @param string   $auth_login (optional) Feed username
-        * @param string   $auth_pass  (optional) Feed password
-        *
         * @return integer Status code:
         *                 0 - OK, Feed already exists
         *                 1 - OK, Feed added
         *                 5 - Couldn't download the URL content.
         */
        function subscribe_to_feed($link, $url, $cat_id = 0,
-                       $auth_login = '', $auth_pass = '') {
+                       $auth_login = '', $auth_pass = '', $need_auth = false) {
 
                require_once "include/rssfuncs.php";
 
 
                $has_oauth = db_fetch_result($result, 0, 'twitter_oauth');
 
-               if (!$has_oauth || strpos($url, '://api.twitter.com') === false) {
+               if (!$need_auth || !$has_oauth || strpos($url, '://api.twitter.com') === false) {
                        if (!fetch_file_contents($url, false, $auth_login, $auth_pass)) return 5;
 
                        if (url_is_html($url, $auth_login, $auth_pass)) {