Browse Source

api: add getFeedTree

Andrew Dolgov 7 years ago
parent
commit
0bb5833beb
3 changed files with 21 additions and 2 deletions
  1. 2 0
      api/index.php
  2. 14 0
      classes/api.php
  3. 5 2
      classes/pref/feeds.php

+ 2 - 0
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;

+ 14 - 0
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'));
+		}
+
+	}
 }
 
 ?>

+ 5 - 2
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() {