]> git.wh0rd.org Git - tt-rss.git/commitdiff
rpc: move several feed-related calls to pref-feeds
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Tue, 2 Apr 2013 10:47:43 +0000 (14:47 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Tue, 2 Apr 2013 10:47:43 +0000 (14:47 +0400)
classes/pref/feeds.php
classes/rpc.php
js/functions.js
js/prefs.js

index aa018ee10d3a959a0d335edbca461b6677c6cbcd..7fb64623e57d8e48622932e052a22d192f86afff 100644 (file)
@@ -1834,5 +1834,54 @@ class Pref_Feeds extends Handler_Protected {
                }
        }
 
+       function regenOPMLKey() {
+               $this->update_feed_access_key($this->link, 'OPML:Publish',
+               false, $_SESSION["uid"]);
+
+               $new_link = Opml::opml_publish_url($this->link);
+
+               print json_encode(array("link" => $new_link));
+       }
+
+       function regenFeedKey() {
+               $feed_id = db_escape_string($this->link, $_REQUEST['id']);
+               $is_cat = db_escape_string($this->link, $_REQUEST['is_cat']) == "true";
+
+               $new_key = $this->update_feed_access_key($this->link, $feed_id, $is_cat);
+
+               print json_encode(array("link" => $new_key));
+       }
+
+
+       private function update_feed_access_key($link, $feed_id, $is_cat, $owner_uid = false) {
+               if (!$owner_uid) $owner_uid = $_SESSION["uid"];
+
+               $sql_is_cat = bool_to_sql_bool($is_cat);
+
+               $result = db_query($link, "SELECT access_key FROM ttrss_access_keys
+                       WHERE feed_id = '$feed_id'      AND is_cat = $sql_is_cat
+                       AND owner_uid = " . $owner_uid);
+
+               if (db_num_rows($result) == 1) {
+                       $key = db_escape_string($this->link, sha1(uniqid(rand(), true)));
+
+                       db_query($link, "UPDATE ttrss_access_keys SET access_key = '$key'
+                               WHERE feed_id = '$feed_id' AND is_cat = $sql_is_cat
+                               AND owner_uid = " . $owner_uid);
+
+                       return $key;
+
+               } else {
+                       return get_feed_access_key($link, $feed_id, $is_cat, $owner_uid);
+               }
+       }
+
+       // Silent
+       function clearKeys() {
+               db_query($this->link, "DELETE FROM ttrss_access_keys WHERE
+                       owner_uid = " . $_SESSION["uid"]);
+       }
+
+
 }
 ?>
index d61b2891ad3c5286d85195e12a54e3d88e4d4bae..3593bd5d8094242f7fe57fa7ea9e2f57e7216401 100644 (file)
@@ -411,15 +411,6 @@ class RPC extends Handler_Protected {
                                "content" => $tags_str, "content_full" => $tags_str_full));
        }
 
-       function regenOPMLKey() {
-               $this->update_feed_access_key($this->link, 'OPML:Publish',
-               false, $_SESSION["uid"]);
-
-               $new_link = Opml::opml_publish_url($this->link);
-
-               print json_encode(array("link" => $new_link));
-       }
-
        function completeLabels() {
                $search = db_escape_string($this->link, $_REQUEST["search"]);
 
@@ -609,21 +600,6 @@ class RPC extends Handler_Protected {
                print_feed_cat_select($this->link, "cat_id", $id);
        }
 
-       function regenFeedKey() {
-               $feed_id = db_escape_string($this->link, $_REQUEST['id']);
-               $is_cat = db_escape_string($this->link, $_REQUEST['is_cat']) == "true";
-
-               $new_key = $this->update_feed_access_key($this->link, $feed_id, $is_cat);
-
-               print json_encode(array("link" => $new_key));
-       }
-
-       // Silent
-       function clearKeys() {
-               db_query($this->link, "DELETE FROM ttrss_access_keys WHERE
-                       owner_uid = " . $_SESSION["uid"]);
-       }
-
        // Silent
        function clearArticleKeys() {
                db_query($this->link, "UPDATE ttrss_user_entries SET uuid = '' WHERE
@@ -716,29 +692,6 @@ class RPC extends Handler_Protected {
 
        }
 
-       function update_feed_access_key($link, $feed_id, $is_cat, $owner_uid = false) {
-               if (!$owner_uid) $owner_uid = $_SESSION["uid"];
-
-               $sql_is_cat = bool_to_sql_bool($is_cat);
-
-               $result = db_query($link, "SELECT access_key FROM ttrss_access_keys
-                       WHERE feed_id = '$feed_id'      AND is_cat = $sql_is_cat
-                       AND owner_uid = " . $owner_uid);
-
-               if (db_num_rows($result) == 1) {
-                       $key = db_escape_string($this->link, sha1(uniqid(rand(), true)));
-
-                       db_query($link, "UPDATE ttrss_access_keys SET access_key = '$key'
-                               WHERE feed_id = '$feed_id' AND is_cat = $sql_is_cat
-                               AND owner_uid = " . $owner_uid);
-
-                       return $key;
-
-               } else {
-                       return get_feed_access_key($link, $feed_id, $is_cat, $owner_uid);
-               }
-       }
-
        private function markArticlesById($link, $ids, $cmode) {
 
                $tmp_ids = array();
index 560742598e1bc3815d22bb890841c94667ea509a..4e4d035572ec4e06fe72cb940cc3cf8b74886a95 100644 (file)
@@ -1357,7 +1357,7 @@ function genUrlChangeKey(feed, is_cat) {
 
                        notify_progress("Trying to change address...", true);
 
-                       var query = "?op=rpc&method=regenFeedKey&id=" + param_escape(feed) +
+                       var query = "?op=pref-feeds&method=regenFeedKey&id=" + param_escape(feed) +
                                "&is_cat=" + param_escape(is_cat);
 
                        new Ajax.Request("backend.php", {
index 358625e933d86b8deddd18efcbbdb063dfc05548..b4ecd25842cda5b6ccaa0cb555f9b1a588d6c5b5 100644 (file)
@@ -1221,7 +1221,7 @@ function opmlRegenKey() {
 
                        notify_progress("Trying to change address...", true);
 
-                       var query = "?op=rpc&method=regenOPMLKey";
+                       var query = "?op=pref-feeds&method=regenOPMLKey";
 
                        new Ajax.Request("backend.php", {
                                parameters: query,
@@ -1521,7 +1521,7 @@ function clearFeedAccessKeys() {
        if (ok) {
                notify_progress("Clearing URLs...");
 
-               var query = "?op=rpc&method=clearKeys";
+               var query = "?op=pref-feeds&method=clearKeys";
 
                new Ajax.Request("backend.php", {
                        parameters: query,