]> git.wh0rd.org Git - tt-rss.git/commitdiff
add feed editor button to reset pubsub subscription state
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sat, 2 Apr 2011 10:39:46 +0000 (14:39 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sat, 2 Apr 2011 10:39:46 +0000 (14:39 +0400)
functions.js
modules/pref-feeds.php

index 9352984be6da65257d0eda8916fef51196cfdc16..b4c085a092dc098503ed7bccc4ba34cf1f5fc33e 100644 (file)
@@ -1015,6 +1015,27 @@ function quickAddFilter() {
        }
 }
 
+function resetPubSub(feed_id, title) {
+
+       var msg = __("Reset subscription? Tiny Tiny RSS will try to subscribe to the notification hub again on next feed update.").replace("%s", title);
+
+       if (title == undefined || confirm(msg)) {
+               notify_progress("Loading, please wait...");
+
+               var query = "?op=pref-feeds&quiet=1&subop=resetPubSub&ids=" + feed_id;
+
+               new Ajax.Request("backend.php", {
+                       parameters: query,
+                       onComplete: function(transport) {
+                               dijit.byId("pubsubReset_Btn").attr('disabled', true);
+                               notify_info("Subscription reset.");
+                       } });
+       }
+
+       return false;
+}
+
+
 function unsubscribeFeed(feed_id, title) {
 
        var msg = __("Unsubscribe from %s?").replace("%s", title);
index e202c2ca400dfa5f457ba40039c112872066524d..48ad88e53cc81c806aeeb43c7a10be8b4a32bdec 100644 (file)
                        print "<div class='dlgButtons'>
                                <div style=\"float : left\">
                                <button dojoType=\"dijit.form.Button\" onclick='return unsubscribeFeed($feed_id, \"$title\")'>".
-                                       __('Unsubscribe')."</button>
-                               </div>
-                               <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedEditDlg').execute()\">".__('Save')."</button>
+                                       __('Unsubscribe')."</button>";
+
+                       $pubsub_state = db_fetch_result($result, 0, "pubsub_state");
+
+                       $pubsub_btn_disabled = ($pubsub_state == 2) ? "" : "disabled=\"1\"";
+
+                       print "<button dojoType=\"dijit.form.Button\" id=\"pubsubReset_Btn\" $pubsub_btn_disabled
+                                       onclick='return resetPubSub($feed_id, \"$title\")'>".__('Resubscribe to push updates').
+                                       "</button>";
+
+                       print "</div>";
+
+                       print "<div dojoType=\"dijit.Tooltip\" connectId=\"pubsubReset_Btn\" position=\"below\">".
+                               __('Resets PubSubHubbub subscription status for push-enabled feeds.')."</div>";
+
+                       print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedEditDlg').execute()\">".__('Save')."</button>
                                <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedEditDlg').hide()\">".__('Cancel')."</button>
                        </div>";
 
                        return;
                }
 
+               if ($subop == "resetPubSub") {
+
+                       $ids = db_escape_string($_REQUEST["ids"]);
+
+                       db_query($link, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ($ids)
+                               AND owner_uid = " . $_SESSION["uid"]);
+
+                       return;
+               }
+
                if ($subop == "remove") {
 
                        $ids = split(",", db_escape_string($_REQUEST["ids"]));