summaryrefslogtreecommitdiff
path: root/xml-rpc.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2006-06-19 09:00:46 +0100
committerAndrew Dolgov <[email protected]>2006-06-19 09:00:46 +0100
commitbd907fe295d0de547b1ea2b42938a435be7b693d (patch)
treeef620bdf91f594f190445d64df472df729cc301d /xml-rpc.php
parent5516095502dc143a3a43c3be449aac752e5577c6 (diff)
add xml-rpc method rss.getCategories
Diffstat (limited to 'xml-rpc.php')
-rw-r--r--xml-rpc.php59
1 files changed, 58 insertions, 1 deletions
diff --git a/xml-rpc.php b/xml-rpc.php
index 4e3043111..92d862cd4 100644
--- a/xml-rpc.php
+++ b/xml-rpc.php
@@ -23,6 +23,57 @@
pg_query("set client_encoding = 'utf-8'");
}
+ function getCategories($msg) {
+ global $link;
+
+ $login_o = $msg->getParam(0);
+ $pass_o = $msg->getParam(1);
+
+ $login = $login_o->scalarval();
+ $pass = $pass_o->scalarval();
+
+ $user_id = authenticate_user($link, $login, $pass);
+
+ $error_code = 0;
+
+ if (authenticate_user($link, $login, $pass)) {
+
+ $result = db_query($link, "SELECT
+ id, title FROM ttrss_feed_categories
+ WHERE owner_uid = " .
+ $_SESSION["uid"]);
+
+ $feeds = array();
+
+ while ($line = db_fetch_assoc($result)) {
+
+ $unread = getFeedUnread($link, $line["id"]);
+
+ $line_struct = new xmlrpcval(
+ array(
+ "title" => new xmlrpcval($line["title"]),
+ "id" => new xmlrpcval($line["id"], "int")
+ ),
+ "struct");
+
+ array_push($feeds, $line_struct);
+ }
+
+ $reply = new xmlrpcval($feeds, "array");
+
+ } else {
+ $reply = "Login failed.";
+ $error_code = 1;
+ }
+
+ if ($error_code != 0) {
+ return new xmlrpcresp(0, $error_code, $reply_msg);
+ } else {
+ return new xmlrpcresp($reply);
+ }
+
+ }
+
function getTotalUnread($msg) {
global $link;
@@ -72,7 +123,7 @@
if (authenticate_user($link, $login, $pass)) {
$result = db_query($link, "SELECT
- id, feed_url, title, SUBSTRING(last_updated,1,19) AS last_updated
+ id, feed_url, cat_id, title, SUBSTRING(last_updated,1,19) AS last_updated
FROM ttrss_feeds WHERE owner_uid = " .
$_SESSION["uid"]);
@@ -88,6 +139,7 @@
"title" => new xmlrpcval($line["title"]),
"id" => new xmlrpcval($line["id"], "int"),
"unread" => new xmlrpcval($unread, "int"),
+ "category_id" => new xmlrpcval($line["cat_id"], "int"),
"last_updated" => new xmlrpcval(strtotime($line["last_updated"]), "int")
),
"struct");
@@ -398,8 +450,13 @@
$getTotalUnread_sig = array(array($xmlrpcInt, $xmlrpcString,
$xmlrpcString));
+ $getCategories_sig = array(array($xmlrpcString,
+ $xmlrpcString, $xmlrpcString));
+
$s = new xmlrpc_server(
array(
+ "rss.getCategories" => array("function" => "getCategories",
+ "signature" => $getCategories_sig),
"rss.getTotalUnread" => array("function" => "getTotalUnread",
"signature" => $getTotalUnread_sig),
"rss.getVersion" => array("function" => "getVersion",