diff options
Diffstat (limited to 'classes')
-rw-r--r-- | classes/dlg.php | 49 | ||||
-rw-r--r-- | classes/pref_feeds.php | 2 | ||||
-rw-r--r-- | classes/rpc.php | 49 |
3 files changed, 100 insertions, 0 deletions
diff --git a/classes/dlg.php b/classes/dlg.php index cd098d396..d39f691cb 100644 --- a/classes/dlg.php +++ b/classes/dlg.php @@ -978,5 +978,54 @@ class Dlg extends Protected_Handler { } + function batchSubscribe() { + print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">"; + print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"batchaddfeeds\">"; + + print "<table width='100%'><tr><td> + ".__("Add one valid RSS feed per line (no feed detection is done)")." + </td><td align='right'>"; + if (get_pref($this->link, 'ENABLE_FEED_CATS')) { + print __('Place in category:') . " "; + print_feed_cat_select($this->link, "cat", false, 'dojoType="dijit.form.Select"'); + } + print "</td></tr><tr><td colspan='2'>"; + print "<textarea + style='font-size : 12px; width : 100%; height: 200px;' + placeHolder=\"".__("Feeds to subscribe, One per line")."\" + dojoType=\"dijit.form.SimpleTextarea\" required=\"1\" name=\"feeds\"></textarea>"; + + print "</td></tr><tr><td colspan='2'>"; + + print "<div id='feedDlg_loginContainer' style='display : none'> + " . + " <input dojoType=\"dijit.form.TextBox\" name='login'\" + placeHolder=\"".__("Login")."\" + style=\"width : 10em;\"> ". + " <input + placeHolder=\"".__("Password")."\" + dojoType=\"dijit.form.TextBox\" type='password' + style=\"width : 10em;\" name='pass'\">". + " <p class='insensitive'>".__("OAuth will be used automatically for Twitter feeds.")."</p> + </div>"; + + print "</td></tr><tr><td colspan='2'>"; + + print "<div style=\"clear : both\"> + <input type=\"checkbox\" name=\"need_auth\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\" + onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'> + <label for=\"feedDlg_loginCheck\">". + __('Feeds require authentication.')."</div>"; + + print "</form>"; + + print "</td></tr></table>"; + + print "<div class=\"dlgButtons\"> + <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('batchSubDlg').execute()\">".__('Subscribe')."</button> + <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('batchSubDlg').hide()\">".__('Cancel')."</button> + </div>"; + } + } ?> diff --git a/classes/pref_feeds.php b/classes/pref_feeds.php index 978a848e9..0e77b6e5f 100644 --- a/classes/pref_feeds.php +++ b/classes/pref_feeds.php @@ -1317,6 +1317,8 @@ class Pref_Feeds extends Protected_Handler { dojoType=\"dijit.MenuItem\">".__('Edit selected feeds')."</div>"; print "<div onclick=\"resetFeedOrder()\" dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>"; + print "<div onclick=\"batchSubscribe()\" + dojoType=\"dijit.MenuItem\">".__('Batch subscribe')."</div>"; print "</div></div>"; if (get_pref($this->link, 'ENABLE_FEED_CATS')) { diff --git a/classes/rpc.php b/classes/rpc.php index 58e25a456..ef89a2141 100644 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -788,5 +788,54 @@ class RPC extends Protected_Handler { print json_encode(array("hash" => $hash)); } + + function batchAddFeeds() { + $cat_id = db_escape_string($_REQUEST['cat']); + $feeds = explode("\n", db_escape_string($_REQUEST['feeds'])); + $login = db_escape_string($_REQUEST['login']); + $pass = db_escape_string($_REQUEST['pass']); + $need_auth = db_escape_string($_REQUEST['need_auth']) != ""; + + $result = db_query($this->link, "SELECT twitter_oauth FROM ttrss_users +WHERE id = ".$_SESSION['uid']); + $has_oauth = db_fetch_result($result, 0, 'twitter_oauth') != ""; + + foreach ($feeds as $feed) { + $feed = trim($feed); + + if (validate_feed_url($feed)) { + + db_query($this->link, "BEGIN"); + + if (!$need_auth || !$has_oauth || strpos($url, '://api.twitter.com') + === false) { + $update_method = 0; + } else { + $update_method = 3; + } + + if ($cat_id == "0" || !$cat_id) { + $cat_qpart = "NULL"; + } else { + $cat_qpart = "'$cat_id'"; + } + + $result = db_query($this->link, + "SELECT id FROM ttrss_feeds + WHERE feed_url = '$feed' AND owner_uid = ".$_SESSION["uid"]); + + if (db_num_rows($result) == 0) { + $result = db_query($this->link, + "INSERT INTO ttrss_feeds + (owner_uid,feed_url,title,cat_id,auth_login,auth_pass,update_method) + VALUES ('".$_SESSION["uid"]."', '$feed', + '[Unknown]', $cat_qpart, '$login', '$pass', '$update_method')"); + } + + db_query($this->link, "COMMIT"); + } + } + } + } ?> |