X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fapi.php;h=124096bf0ffc324959562d8c517463e0cd52f50c;hb=0f5a6bfcdbde8f53283826251056a4670bdf9f7a;hp=f58a91a72f48224616e09ee047014a304d63de7c;hpb=f2e648d62fe7cafb9a55c7505687ea4d1c294778;p=friendica.git diff --git a/include/api.php b/include/api.php index f58a91a72f..124096bf0f 100644 --- a/include/api.php +++ b/include/api.php @@ -245,7 +245,7 @@ } - logger('api_user: ' . $extra_query . ' ' , $user); + logger('api_user: ' . $extra_query . ', user: ' . $user); // user info $uinfo = q("SELECT *, `contact`.`id` as `cid` FROM `contact` WHERE 1 @@ -719,14 +719,18 @@ if ($page<0) $page=0; $since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0); $max_id = (x($_REQUEST,'max_id')?$_REQUEST['max_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; //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); + $sql_extra = ''; if ($max_id > 0) - $sql_extra = 'AND `item`.`id` <= '.intval($max_id); + $sql_extra .= ' AND `item`.`id` <= '.intval($max_id); + 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`, @@ -860,6 +864,8 @@ 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`, @@ -870,19 +876,24 @@ 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); @@ -898,7 +909,7 @@ // params $id = intval($a->argv[3]); - logger('API: api_statuses_repeat: '.$id); + logger('API: api_statuses_repeat: '.$id); //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); @@ -915,13 +926,15 @@ intval($id) ); - $_REQUEST['body'] = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8')."[url=".$r[0]['reply_url']."]".$r[0]['reply_author']."[/url] \n".$r[0]['body']; - $_REQUEST['profile_uid'] = local_user(); - $_REQUEST['type'] = 'wall'; - $_REQUEST['api_source'] = true; + if ($r[0]['body'] != "") { + $_REQUEST['body'] = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8')."[url=".$r[0]['reply_url']."]".$r[0]['reply_author']."[/url] \n".$r[0]['body']; + $_REQUEST['profile_uid'] = local_user(); + $_REQUEST['type'] = 'wall'; + $_REQUEST['api_source'] = true; - require_once('mod/item.php'); - item_post($a); + require_once('mod/item.php'); + item_post($a); + } if ($type == 'xml') $ok = "true"; @@ -943,7 +956,7 @@ // params $id = intval($a->argv[3]); - logger('API: api_statuses_destroy: '.$id); + logger('API: api_statuses_destroy: '.$id); require_once('include/items.php'); drop_item($id, false); @@ -976,7 +989,7 @@ $since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0); $max_id = (x($_REQUEST,'max_id')?$_REQUEST['max_id']:0); //$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0); - + $start = $page*$count; //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); @@ -985,11 +998,19 @@ $myurl = substr($myurl,strpos($myurl,'://')+3); $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl); $diasp_url = str_replace('/profile/','/u/',$myurl); - $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` regexp '%s' or `tag` regexp '%s' or tag regexp '%s' )) ", - dbesc($myurl . '$'), - dbesc($myurl . '\\]'), - dbesc($diasp_url . '\\]') - ); + + if (get_config('system','use_fulltext_engine')) + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (MATCH(`author-link`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ", + dbesc(protect_sprintf($myurl)), + dbesc(protect_sprintf($myurl)), + dbesc(protect_sprintf($diasp_url)) + ); + else + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ", + dbesc(protect_sprintf('%' . $myurl)), + dbesc(protect_sprintf('%' . $myurl . ']%')), + dbesc(protect_sprintf('%' . $diasp_url . ']%')) + ); if ($max_id > 0) $sql_extra .= ' AND `item`.`id` <= '.intval($max_id); @@ -1051,11 +1072,14 @@ $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`, @@ -1644,7 +1668,6 @@ account/update_profile_background_image account/update_profile_image blocks/create blocks/destroy -oauth/authorize Not implemented in status.net: statuses/retweeted_to_me