]> git.mxchange.org Git - friendica.git/blobdiff - include/api.php
Added statuses/show parameter ?conversation=true
[friendica.git] / include / api.php
index a58dd20dfaba67cf3fd13e200b46cac5329e0187..124096bf0ffc324959562d8c517463e0cd52f50c 100644 (file)
                logger('API: api_statuses_show: '.$id);
 
                //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false);
+               //$sql_extra = "";
+               if ($_GET["conversation"] == "true") $sql_extra .= " AND `item`.`parent` = %d"; else $sql_extra .= " AND `item`.`id` = %d";
 
                $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
                        `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
                        AND `contact`.`id` = `item`.`contact-id`
                        AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
                        $sql_extra
-                       AND `item`.`id`=%d",
+                       ",
                        intval($id)
                );
-
+//var_dump($r);
                $ret = api_format_items($r,$user_info);
-
-               $data = array('$status' => $ret[0]);
-               /*switch($type){
-                       case "atom":
-                       case "rss":
-                               $data = api_rss_extra($a, $data, $user_info);
-               }*/
-               return  api_apply_template("status", $type, $data);
+//var_dump($ret);
+               if ($_GET["conversation"] == "true") {
+                       $data = array('$statuses' => $ret);
+                       return  api_apply_template("timeline", $type, $data);
+               } else {
+                       $data = array('$status' => $ret[0]);
+                       /*switch($type){
+                               case "atom":
+                               case "rss":
+                                       $data = api_rss_extra($a, $data, $user_info);
+                       }*/
+                       return  api_apply_template("status", $type, $data);
+               }
        }
        api_register_func('api/statuses/show','api_statuses_show', true);
 
                $page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
                if ($page<0) $page=0;
                $since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
+               $exclude_replies = (x($_REQUEST,'exclude_replies')?1:0);
                //$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
                
                $start = $page*$count;
 
-               if ($user_info['self']==1) $sql_extra = "AND `item`.`wall` = 1 ";
+               $sql_extra = '';
+               if ($user_info['self']==1) $sql_extra .= " AND `item`.`wall` = 1 ";
+               if ($exclude_replies > 0)  $sql_extra .= ' AND `item`.`parent` = `item`.`id`';
 
                $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, 
                        `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,