]> git.wh0rd.org - tt-rss.git/blobdiff - modules/backend-rpc.php
more digest page improvements
[tt-rss.git] / modules / backend-rpc.php
index adefbd5a5f21e8ae673c6dc9220c2567b113483c..70b6901112c3bcf5d4e5fc4629bff6692e1edf20 100644 (file)
 
                }
 
-               if ($subop == "setpref") {
-                       if (WEB_DEMO_MODE) {
-                               return;
-                       }
+               if ($subop == "togglepref") {
+                       print "<rpc-reply>";
+
+                       $key = db_escape_string($_REQUEST["key"]);
+
+                       set_pref($link, $key, !get_pref($link, $key));
 
+                       $value = get_pref($link, $key);
+
+                       print "<param-set key=\"$key\" value=\"$value\"/>";
+
+                       print "</rpc-reply>";
+
+                       return;
+               }
+
+               if ($subop == "setpref") {
                        print "<rpc-reply>";
 
                        $key = db_escape_string($_REQUEST["key"]);
                if ($subop == "updateFeed") {
                        $feed_id = db_escape_string($_REQUEST["feed"]);
 
-                       $result = db_query($link, 
-                               "SELECT feed_url FROM ttrss_feeds WHERE id = '$feed_id'
-                                       AND owner_uid = " . $_SESSION["uid"]);
-
-                       if (db_num_rows($result) > 0) {                 
-                               $feed_url = db_fetch_result($result, 0, "feed_url");
-                               update_rss_feed($link, $feed_url, $feed_id);
-                       }
+                       update_rss_feed($link, $feed_id);
 
                        print "<rpc-reply>";    
                        print "<counters>";
 
                if ($subop == "setArticleTags") {
 
+                       global $memcache;
+
                        $id = db_escape_string($_REQUEST["id"]);
 
                        $tags_str = db_escape_string($_REQUEST["tags_str"]);
 
                        db_query($link, "COMMIT");
 
+                       if ($memcache) {
+                               $obj_id = md5("TAGS:".$_SESSION["uid"].":$id");
+                               $memcache->delete($obj_id);
+                       }
+
                        $tags_str = format_tags_string(get_article_tags($link, $id), $id);
 
                        print "<rpc-reply>
                        return;
                }
 
+               if ($subop == "regenOPMLKey") {
+
+                       print "<rpc-reply>";
+                       set_pref($link, " _PREFS_OPML_PUBLISH_KEY", generate_publish_key(), $_SESSION["uid"]);
+                       $new_link = opml_publish_url($link);            
+                       print "<link><![CDATA[$new_link]]></link>";
+                       print "</rpc-reply>";
+                       return;
+               }
+
                if ($subop == "logout") {
                        logout_user();
                        print_error_xml(6);
                        return;
                }
 
+               if ($subop == "digest-update") {
+                       $feed_id = db_escape_string($_REQUEST['feed_id']);
+                       $offset = db_escape_string($_REQUEST['offset']);
+               
+                       if (!$feed_id) $feed_id = -4;
+                       if (!$offset) $offset = 0;
+
+
+                       print "<rpc-reply>";
+
+                       $headlines = api_get_headlines($link, $feed_id, 10, $offset,
+                               '', ($feed_id == -4), true, true, "unread", "updated DESC");
+
+                       //function api_get_headlines($link, $feed_id, $limit, $offset,
+                       //              $filter, $is_cat, $show_excerpt, $show_content, $view_mode) {
+
+                       print "<headlines><![CDATA[" . json_encode($headlines) . "]]></headlines>";
+
+                       print "</rpc-reply>";
+                       return;
+               }
+
+               if ($subop == "digest-init") {
+                       print "<rpc-reply>";
+
+                       $tmp_feeds = api_get_feeds($link, false, true, false, 0);
+                       $feeds = array();
+
+                       foreach ($tmp_feeds as $f) {
+                               if ($f['id'] > 0 || $f['id'] == -4) array_push($feeds, $f);
+                       }
+
+                       function feeds_sort_by_unread_rev($a, $b) {
+                               $a = $a['unread'];
+                               $b = $b['unread'];
+
+                               if ($a == $b) {
+                                       return 0;
+                               }
+                               return ($a < $b) ? 1 : -1;
+                       }
+
+                       //uasort($feeds, 'feeds_sort_by_unread_rev');
+                       //$feeds = array_slice($feeds, 0, 10);
+
+                       print "<feeds><![CDATA[" . json_encode($feeds) . "]]></feeds>";
+
+                       print "</rpc-reply>";
+                       return;
+               }
+
                print "<rpc-reply><error>Unknown method: $subop</error></rpc-reply>";
        }
 ?>