]> git.wh0rd.org - tt-rss.git/blobdiff - classes/rpc.php
move digest to a separate plugin
[tt-rss.git] / classes / rpc.php
index bf693d2a2049bc3d61fe68a1c14401213f88c374..4e08c3dc7f91e1953979f496dfa4a0299fca1465 100644 (file)
@@ -1,8 +1,8 @@
 <?php
-class RPC extends Protected_Handler {
+class RPC extends Handler_Protected {
 
        function csrf_ignore($method) {
-               $csrf_ignored = array("sanitycheck", "buttonplugin", "exportget");
+               $csrf_ignored = array("sanitycheck", "buttonplugin", "exportget", "completelabels");
 
                return array_search($method, $csrf_ignored) !== false;
        }
@@ -195,12 +195,6 @@ class RPC extends Protected_Handler {
                print json_encode(array("result" => $rc));
        }
 
-       function extractfeedurls() {
-               $urls = get_feeds_from_html($_REQUEST['url']);
-
-               print json_encode(array("urls" => $urls));
-       }
-
        function togglepref() {
                $key = db_escape_string($_REQUEST["key"]);
                set_pref($this->link, $key, !get_pref($this->link, $key));
@@ -276,7 +270,7 @@ class RPC extends Protected_Handler {
                }
 
                $result = db_query($this->link, "UPDATE ttrss_user_entries SET
-                       published = $pub
+                       published = $pub, last_read = NOW()
                        WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
 
                $pubsub_result = false;
@@ -432,6 +426,23 @@ class RPC extends Protected_Handler {
                print json_encode(array("link" => $new_link));
        }
 
+       function completeLabels() {
+               $search = db_escape_string($_REQUEST["search"]);
+
+               $result = db_query($this->link, "SELECT DISTINCT caption FROM
+                               ttrss_labels2
+                               WHERE owner_uid = '".$_SESSION["uid"]."' AND
+                               LOWER(caption) LIKE LOWER('$search%') ORDER BY caption
+                               LIMIT 5");
+
+               print "<ul>";
+               while ($line = db_fetch_assoc($result)) {
+                       print "<li>" . $line["caption"] . "</li>";
+               }
+               print "</ul>";
+       }
+
+
        function completeTags() {
                $search = db_escape_string($_REQUEST["search"]);
 
@@ -583,60 +594,6 @@ class RPC extends Protected_Handler {
                }
        }
 
-       function digestgetcontents() {
-               $article_id = db_escape_string($_REQUEST['article_id']);
-
-               $result = db_query($this->link, "SELECT content,title,link,marked,published
-                       FROM ttrss_entries, ttrss_user_entries
-                       WHERE id = '$article_id' AND ref_id = id AND owner_uid = ".$_SESSION['uid']);
-
-               $content = sanitize($this->link, db_fetch_result($result, 0, "content"));
-               $title = strip_tags(db_fetch_result($result, 0, "title"));
-               $article_url = htmlspecialchars(db_fetch_result($result, 0, "link"));
-               $marked = sql_bool_to_bool(db_fetch_result($result, 0, "marked"));
-               $published = sql_bool_to_bool(db_fetch_result($result, 0, "published"));
-
-               print json_encode(array("article" =>
-                       array("id" => $article_id, "url" => $article_url,
-                               "tags" => get_article_tags($this->link, $article_id),
-                               "marked" => $marked, "published" => $published,
-                               "title" => $title, "content" => $content)));
-       }
-
-       function digestupdate() {
-               $feed_id = db_escape_string($_REQUEST['feed_id']);
-               $offset = db_escape_string($_REQUEST['offset']);
-               $seq = db_escape_string($_REQUEST['seq']);
-
-               if (!$feed_id) $feed_id = -4;
-               if (!$offset) $offset = 0;
-
-               $reply = array();
-
-               $reply['seq'] = $seq;
-
-               $headlines = api_get_headlines($this->link, $feed_id, 30, $offset,
-                               '', ($feed_id == -4), true, false, "unread", "updated DESC", 0, 0);
-
-               $reply['headlines'] = array();
-               $reply['headlines']['title'] = getFeedTitle($this->link, $feed_id);
-               $reply['headlines']['content'] = $headlines;
-
-               print json_encode($reply);
-       }
-
-       function digestinit() {
-               $tmp_feeds = api_get_feeds($this->link, -4, true, false, 0);
-
-               $feeds = array();
-
-               foreach ($tmp_feeds as $f) {
-                       if ($f['id'] > 0 || $f['id'] == -4) array_push($feeds, $f);
-               }
-
-               print json_encode(array("feeds" => $feeds));
-       }
-
        function catchupFeed() {
                $feed_id = db_escape_string($_REQUEST['feed_id']);
                $is_cat = db_escape_string($_REQUEST['is_cat']) == "true";
@@ -687,7 +644,6 @@ class RPC extends Protected_Handler {
                return;
        }
 
-
        function verifyRegexp() {
                $reg_exp = $_REQUEST["reg_exp"];
 
@@ -696,77 +652,8 @@ class RPC extends Protected_Handler {
                print json_encode(array("status" => $status));
        }
 
-       // TODO: unify with digest-get-contents?
-       function cdmGetArticle() {
-               $ids = array(db_escape_string($_REQUEST["id"]));
-               $cids = explode(",", $_REQUEST["cids"]);
-
-               $ids = array_merge($ids, $cids);
-
-               $rv = array();
-
-               foreach ($ids as $id) {
-                       $id = (int)$id;
-
-                       $result = db_query($this->link, "SELECT content,
-                                       ttrss_feeds.site_url AS site_url FROM ttrss_user_entries, ttrss_feeds,
-                                       ttrss_entries
-                                       WHERE feed_id = ttrss_feeds.id AND ref_id = '$id' AND
-                                       ttrss_entries.id = ref_id AND
-                                       ttrss_user_entries.owner_uid = ".$_SESSION["uid"]);
-
-                       if (db_num_rows($result) != 0) {
-                               $line = db_fetch_assoc($result);
-
-                               $article_content = sanitize($this->link, $line["content"],
-                                       false, false, $line['site_url']);
-
-                               array_push($rv,
-                                       array("id" => $id, "content" => $article_content));
-                       }
-               }
-
-               print json_encode($rv);
-       }
-
-       function scheduleFeedUpdate() {
-               $feed_id = db_escape_string($_REQUEST["id"]);
-               $is_cat =  db_escape_string($_REQUEST['is_cat']) == 'true';
-
-               $message = __("Your request could not be completed.");
-
-               if ($feed_id >= 0) {
-                       if (!$is_cat) {
-                               $message = __("Feed update has been scheduled.");
-
-                               db_query($this->link, "UPDATE ttrss_feeds SET
-                                       last_update_started = '1970-01-01',
-                                       last_updated = '1970-01-01' WHERE id = '$feed_id' AND
-                                       owner_uid = ".$_SESSION["uid"]);
-
-                       } else {
-                               $message = __("Category update has been scheduled.");
-
-                               if ($feed_id)
-                               $cat_query = "cat_id = '$feed_id'";
-                               else
-                               $cat_query = "cat_id IS NULL";
-
-                               db_query($this->link, "UPDATE ttrss_feeds SET
-                                               last_update_started = '1970-01-01',
-                                               last_updated = '1970-01-01' WHERE $cat_query AND
-                                               owner_uid = ".$_SESSION["uid"]);
-                       }
-               } else {
-                       $message = __("Can't update this kind of feed.");
-               }
-
-               print json_encode(array("message" => $message));
-               return;
-       }
-
-       function buttonPlugin() {
-               $pclass = basename($_REQUEST['plugin']) . "_button";
+       /* function buttonPlugin() {
+               $pclass = "button_" . basename($_REQUEST['plugin']);
                $method = $_REQUEST['plugin_method'];
 
                if (class_exists($pclass)) {
@@ -775,7 +662,7 @@ class RPC extends Protected_Handler {
                                return $plugin->$method();
                        }
                }
-       }
+       } */
 
        function genHash() {
                $hash = sha1(uniqid(rand(), true));
@@ -790,10 +677,6 @@ class RPC extends Protected_Handler {
                $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);
 
@@ -801,12 +684,7 @@ WHERE id = ".$_SESSION['uid']);
 
                                db_query($this->link, "BEGIN");
 
-                               if (!$need_auth || !$has_oauth || strpos($url, '://api.twitter.com')
-                                                                                                                               === false) {
-                                       $update_method = 0;
-                               } else {
-                                       $update_method = 3;
-                               }
+                               $update_method = 0;
 
                                if ($cat_id == "0" || !$cat_id) {
                                        $cat_qpart = "NULL";
@@ -831,5 +709,16 @@ WHERE id = ".$_SESSION['uid']);
                }
        }
 
+       function setScore() {
+               $ids = db_escape_string($_REQUEST['id']);
+               $score = (int)db_escape_string($_REQUEST['score']);
+
+               db_query($this->link, "UPDATE ttrss_user_entries SET
+                       score = '$score' WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]);
+
+               print json_encode(array("id" => $id,
+                       "score_pic" => theme_image($link, get_score_pic($score))));
+       }
+
 }
 ?>