allow subscribing to twitter feeds without oauth (if require auth checkbox is unset)
This commit is contained in:
parent
ec418193a8
commit
aa60999b97
3 changed files with 7 additions and 13 deletions
|
@ -284,12 +284,13 @@ class Dlg extends Protected_Handler {
|
||||||
" <input
|
" <input
|
||||||
placeHolder=\"".__("Password")."\"
|
placeHolder=\"".__("Password")."\"
|
||||||
dojoType=\"dijit.form.TextBox\" type='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>";
|
</div></div>";
|
||||||
|
|
||||||
|
|
||||||
print "<div style=\"clear : both\">
|
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\")'>
|
onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'>
|
||||||
<label for=\"feedDlg_loginCheck\">".
|
<label for=\"feedDlg_loginCheck\">".
|
||||||
__('This feed requires authentication.')."</div>";
|
__('This feed requires authentication.')."</div>";
|
||||||
|
|
|
@ -188,8 +188,9 @@ class RPC extends Protected_Handler {
|
||||||
$cat = db_escape_string($_REQUEST['cat']);
|
$cat = db_escape_string($_REQUEST['cat']);
|
||||||
$login = db_escape_string($_REQUEST['login']);
|
$login = db_escape_string($_REQUEST['login']);
|
||||||
$pass = db_escape_string($_REQUEST['pass']);
|
$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));
|
print json_encode(array("result" => $rc));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1843,14 +1843,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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:
|
* @return integer Status code:
|
||||||
* 0 - OK, Feed already exists
|
* 0 - OK, Feed already exists
|
||||||
* 1 - OK, Feed added
|
* 1 - OK, Feed added
|
||||||
|
@ -1862,7 +1854,7 @@
|
||||||
* 5 - Couldn't download the URL content.
|
* 5 - Couldn't download the URL content.
|
||||||
*/
|
*/
|
||||||
function subscribe_to_feed($link, $url, $cat_id = 0,
|
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";
|
require_once "include/rssfuncs.php";
|
||||||
|
|
||||||
|
@ -1877,7 +1869,7 @@
|
||||||
|
|
||||||
$has_oauth = db_fetch_result($result, 0, 'twitter_oauth');
|
$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 (!fetch_file_contents($url, false, $auth_login, $auth_pass)) return 5;
|
||||||
|
|
||||||
if (url_is_html($url, $auth_login, $auth_pass)) {
|
if (url_is_html($url, $auth_login, $auth_pass)) {
|
||||||
|
|
Loading…
Reference in a new issue