From 0bb5833beb77e845c7a16b72006276b5f5e7d84b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 28 Mar 2013 11:04:15 +0400 Subject: [PATCH] api: add getFeedTree --- api/index.php | 2 ++ classes/api.php | 14 ++++++++++++++ classes/pref/feeds.php | 7 +++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/api/index.php b/api/index.php index a1143a1d..50703175 100644 --- a/api/index.php +++ b/api/index.php @@ -49,6 +49,8 @@ if ($_REQUEST["sid"]) { session_id($_REQUEST["sid"]); @session_start(); + } else if (defined('_API_DEBUG_HTTP_ENABLED')) { + @session_start(); } if (!init_connection($link)) return; diff --git a/classes/api.php b/classes/api.php index 2b9c3a14..1efa3865 100644 --- a/classes/api.php +++ b/classes/api.php @@ -704,6 +704,20 @@ class API extends Handler { } } + function getFeedTree() { + $pf = new Pref_Feeds($this->link, $_REQUEST); + + $_REQUEST['mode'] = 2; + + if ($pf){ + $data = $pf->makefeedtree(); + print $this->wrap(self::STATUS_OK, array("categories" => $data)); + } else { + print $this->wrap(self::STATUS_ERR, array("error" => + 'UNABLE_TO_INSTANTIATE_OBJECT')); + } + + } } ?> diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index d2e69c50..cd208335 100644 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -87,6 +87,10 @@ class Pref_Feeds extends Handler_Protected { } function getfeedtree() { + print json_encode($this->makefeedtree()); + } + + function makefeedtree() { if ($_REQUEST['mode'] != 2) $search = $_SESSION["prefs_feed_search"]; @@ -284,8 +288,7 @@ class Pref_Feeds extends Handler_Protected { $fl['items'] =& $root['items']; } - print json_encode($fl); - return; + return $fl; } function catsortreset() { -- 2.39.2