]> git.wh0rd.org - tt-rss.git/blobdiff - modules/backend-rpc.php
tweak article notes
[tt-rss.git] / modules / backend-rpc.php
index b8877da20eca1197d9bb7ea317fa9503cf7a0039..239ff60f6b8eb9f4e75f12df3fdb802e02cba57f 100644 (file)
                        return;
                }
 
-               // XML method
                if ($subop == "publ") {
+                       header("Content-Type: text/plain");
+
                        $pub = $_REQUEST["pub"];
                        $id = db_escape_string($_REQUEST["id"]);
                        $note = trim(strip_tags(db_escape_string($_REQUEST["note"])));
                                $pub = "false";
                        }
 
-                       if ($note != 'undefined') {
-                               $note_qpart = "note = '$note',";
-                       }
-
-                       // FIXME this needs collision testing
-
                        $result = db_query($link, "UPDATE ttrss_user_entries SET 
-                               $note_qpart
                                published = $pub
                                WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
 
-
-                       print "<rpc-reply>";
-                       
-                       if ($note != 'undefined') {
-                               $note_size = strlen($note);
-                               print "<note id=\"$id\" size=\"$note_size\">";
-                               print "<![CDATA[" . format_article_note($id, $note) . "]]>";
-                               print "</note>";
-                       }
-
-                       print "<message>UPDATE_COUNTERS</message>";
-
-                       print "</rpc-reply>";
-
+                       print json_encode(array("message" => "UPDATE_COUNTERS"));
                        return;
                }
 
                        return;
                }
 
+               if ($subop == "setNote") {
+                       header("Content-Type: text/plain");
+
+                       $id = db_escape_string($_REQUEST["id"]);
+                       $note = strip_tags(db_escape_string($_REQUEST["note"]));
+
+                       db_query($link, "UPDATE ttrss_user_entries SET note = '$note'
+                               WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+
+                       $formatted_note = format_article_note($id, $note);
+
+                       print json_encode(array("note" => $formatted_note));
+                       return;
+               }
+
                print "<rpc-reply><error>Unknown method: $subop</error></rpc-reply>";
        }
 ?>