]> git.wh0rd.org Git - tt-rss.git/commitdiff
more published feeds work
authorAndrew Dolgov <fox@bah.spb.su>
Thu, 9 Aug 2007 13:09:34 +0000 (14:09 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Thu, 9 Aug 2007 13:09:34 +0000 (14:09 +0100)
backend.php
functions.php
modules/backend-rpc.php
modules/pref-feeds.php
prefs.js

index d5272ddae51736407245be79c3c16b69beaf66c8..9454702fba02f1b690af63a052f2fcb68e7c4cdc 100644 (file)
@@ -56,7 +56,7 @@
        $print_exec_time = false;
 
        if ((!$op || $op == "rpc" || $op == "rss" || $op == "view" || 
-                       $op == "digestSend" || $op == "viewfeed" ||
+                       $op == "digestSend" || $op == "viewfeed" || $op == "publish" ||
                        $op == "globalUpdateFeeds") && !$_REQUEST["noxml"]) {
                header("Content-Type: application/xml; charset=utf-8");
        } else {
@@ -69,7 +69,7 @@
        }
        
        if (!($_SESSION["uid"] && validate_session($link)) && $op != "globalUpdateFeeds" 
-                       && $op != "rss" && $op != "getUnread") {
+                       && $op != "rss" && $op != "getUnread" && $op != "publish") {
 
                if ($op == "rpc" || $op == "viewfeed" || $op == "view") {
                        print_error_xml(6); die;
                module_pref_feed_browser($link);
        }
 
+       if ($op == "publish") {
+               $key = db_escape_string($_GET["key"]);
+
+               $result = db_query($link, "SELECT login, owner_uid 
+                       FROM ttrss_user_prefs, ttrss_users WHERE
+                       pref_name = '_PREFS_PUBLISH_KEY' AND 
+                       value = '$key' AND 
+                       ttrss_users.id = owner_uid");
+
+               if (db_num_rows($result) == 1) {
+                       $owner = db_fetch_result($result, 0, "owner_uid");
+                       $login = db_fetch_result($result, 0, "login");
+
+                       $_SESSION["uid"] = $owner;
+       
+                       generate_syndicated_feed($link, -2, false);
+
+                       session_destroy();
+               } else {
+
+                       $_SESSION["uid"] = 0;
+                       generate_syndicated_feed($link, -2, false);
+                       session_destroy();
+               }
+
+       }
+
        if ($op == "rss") {
                $feed = db_escape_string($_GET["id"]);
                $user = db_escape_string($_GET["user"]);
                                generate_syndicated_feed($link, $feed, $is_cat, 
                                        $search, $search_mode, $match_on);
                }
+
+               session_destroy();
        }
 
        if ($op == "labelFromSearch") {
index a77d2f85c0cc7ef0c10d8c0c60d2b91e88bf302f..8157d12d2cf3f76179377d774c4e7109f7053afb 100644 (file)
        function getFeedTitle($link, $id) {
                if ($id == -1) {
                        return __("Starred articles");
+               } else if ($id == -2) {
+                       return __("Published articles");
                } else if ($id < -10) {
                        $label_id = -10 - $id;
                        $result = db_query($link, "SELECT description FROM ttrss_labels WHERE id = '$label_id'");
index 1e757ca72526ad801f81eec335478481cc158bc4..ddf33a0df1842f4940cd25b143af3240545caaf0 100644 (file)
 
                }
 
+               if ($subop == "regenPubKey") {
+
+                       print "<rpc-reply>";
+
+                       set_pref($link, "_PREFS_PUBLISH_KEY", generate_publish_key());
+               
+                       $url_path = 'http://' . $_SERVER["HTTP_HOST"] . \
+                               parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
+
+                       $new_link = $url_path . "?op=publish&key=" . get_pref($link, "_PREFS_PUBLISH_KEY");
+
+                       print "<link><![CDATA[$new_link]]></link>";
+
+                       print "</rpc-reply>";
+
+               }
+
                if ($subop == "logout") {
                        logout_user();
                        print_error_xml(6);
index b5070c7e926ad6b1db9295c5b34e2c29dafd43ed..17324424531e7defd11a5789428e795a72a4e736 100644 (file)
 
                $url_path .= "?op=publish&key=" . get_pref($link, "_PREFS_PUBLISH_KEY");
 
-               print "<p><a id=\"pubGenAddress\" target=\"_new\" href=\"$url_path\">$url_path</a></p>";
+               print "<p class=\"small\"><a id=\"pubGenAddress\" target=\"_new\" href=\"$url_path\">$url_path</a></p>";
 
                print "<p><input type=\"submit\" onclick=\"return pubRegenKey()\" 
                        value=\"".__('Generate another address')."\"></p>";
index a662aeef7711896c53a366fd8155e9f13f64e845..0fec3620669d1c50121daacae7260eb6765c070d 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -16,7 +16,6 @@ var caller_subop = false;
 
 var sanity_check_done = false;
 
-/*
 function replace_pubkey_callback() {
        if (xmlhttp.readyState == 4) {
                try {   
@@ -24,15 +23,25 @@ function replace_pubkey_callback() {
 
                        if (xmlhttp.responseXML) {
 
+                               var new_link = xmlhttp.responseXML.getElementsByTagName("link")[0];
+
+                               if (new_link) {
+                                       link.href = new_link.firstChild.nodeValue;
+                                       link.innerHTML = new_link.firstChild.nodeValue;
+
+                                       notify_info("Address changed");
+                               } else {
+                                       notify_error("Could not change address");
+                               }
 
                        } else {
-                               notify_error("Error while changing adress");
+                               notify_error("Could not change address");
                        }
                } catch (e) {
                        exception_error("replace_pubkey_callback", e);
                }
        }
-} */
+}
 
 function expand_feed_callback() {
        if (xmlhttp.readyState == 4) {
@@ -1748,7 +1757,6 @@ function feedlistToggleSLAT() {
        updateFeedList()
 }
 
-/*
 function pubRegenKey() {
 
        if (!xmlhttp_ready(xmlhttp)) {
@@ -1762,10 +1770,10 @@ function pubRegenKey() {
 
                notify_progress("Trying to change address...");
 
-               xmlhttp.open("GET", "backend.php?op=backend-rpc&subop=regen-pub-key");
+               xmlhttp.open("GET", "backend.php?op=rpc&subop=regenPubKey");
                xmlhttp.onreadystatechange=replace_pubkey_callback;
                xmlhttp.send(null);
        }
 
        return false;
-} */
+}