* @todo Automatically detect if incoming data is HTML or BBCode
*/
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\Core\Config;
require_once 'include/HTTPExceptions.php';
require_once 'include/bbcode.php';
header ("Content-Type: application/json");
foreach ($r as $rr)
$json = json_encode($rr);
- if ($_GET['callback']) {
+ if (x($_GET, 'callback')) {
$json = $_GET['callback'] . "(" . $json . ")";
}
return $json;
}
}
+ if (is_null($user) && x($_GET, 'profileurl')) {
+ $user = dbesc(normalise_link($_GET['profileurl']));
+ $nick = $user;
+ $extra_query = "AND `contact`.`nurl` = '%s' ";
+ if (api_user() !== false) {
+ $extra_query .= "AND `contact`.`uid`=".intval(api_user());
+ }
+ }
+
if (is_null($user) AND ($a->argc > (count($called_api) - 1)) AND (count($called_api) > 0)) {
$argid = count($called_api);
list($user, $null) = explode(".", $a->argv[$argid]);
($item["deny_gid"] != "") OR
$item["private"]);
- $owner_user = api_get_user($a, $item["owner-link"]);
+ if ($item['thr-parent'] == $item['uri']) {
+ $owner_user = api_get_user($a, $item["owner-link"]);
+ } else {
+ $owner_user = $status_user;
+ }
return (array($status_user, $owner_user));
}
/// @TODO move to top of file or somewhere better
api_register_func('api/users/show','api_users_show');
+ api_register_func('api/externalprofile/show','api_users_show');
function api_users_search($type) {
} else {
$ret['text'] = $item['title'] . "\n" . html2plain(bbcode(api_clean_plain_items($item['body']), false, false, 2, true), 0);
}
- if (x($_GET, 'getUserObjects']) && $_GET['getUserObjects'] == 'false') {
+ if (x($_GET, 'getUserObjects') && $_GET['getUserObjects'] == 'false') {
unset($ret['sender']);
unset($ret['recipient']);
}
foreach ($r as $item) {
localize_item($item);
- list($status_user, $owner_user) = api_item_get_user($a,$item);
+ list($status_user, $owner_user) = api_item_get_user($a, $item);
// Look if the posts are matching if they should be filtered by user id
if ($filter_user AND ($status_user["id"] != $user_info["id"])) {
if ($retweeted_item !== false) {
$retweeted_status = $status;
try {
- $retweeted_status["user"] = api_get_user($a,$retweeted_item["author-link"]);
+ $retweeted_status["user"] = api_get_user($a, $retweeted_item["author-link"]);
} catch( BadRequestException $e ) {
// user not found. should be found?
/// @todo check if the user should be always found
}
$ids = array();
- foreach ($r as $rr)
- if ($stringify_ids)
+ foreach ($r as $rr) {
+ if ($stringify_ids) {
$ids[] = $rr['id'];
} else {
$ids[] = intval($rr['id']);
}
+ }
return api_format_data("ids", $type, array('id' => $ids));
}
$r = q("SELECT `resource-id`, MAX(`scale`) AS `scale`, `album`, `filename`, `type`
FROM `photo`
- WHERE `uid` = %d AND `album` != 'Contact Photos' GROUP BY `resource-id`",
+ WHERE `uid` = %d AND `album` != 'Contact Photos' GROUP BY `resource-id`, `album`, `filename`, `type`",
intval(local_user())
);
$typetoext = array(
}
$scale = (x($_REQUEST, 'scale') ? intval($_REQUEST['scale']) : false);
- $scale_sql = ($scale === false ? "" : sprintf("and scale=%d", intval($scale)));
- $data_sql = ($scale === false ? "" : "data, ");
-
- $r = q("SELECT %s `resource-id`, `created`, `edited`, `title`, `desc`, `album`, `filename`,
- `type`, `height`, `width`, `datasize`, `profile`, MIN(`scale`) AS `minscale`, MAX(`scale`) AS `maxscale`
- FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' %s GROUP BY `resource-id`",
+ $scale_sql = ($scale === false ? "" : sprintf("AND `scale`=%d",intval($scale)));
+ $data_sql = ($scale === false ? "" : "ANY_VALUE(`data`) AS data`,");
+
+ $r = q("SELECT %s ANY_VALUE(`resource-id`) AS `resource-id`, ANY_VALUE(`created`) AS `created`,
+ ANY_VALUE(`edited`) AS `edited`, ANY_VALUE(`title`) AS `title`, ANY_VALUE(`desc`) AS `desc`,
+ ANY_VALUE(`album`) AS `album`, ANY_VALUE(`filename`) AS `filename`, ANY_VALUE(`type`) AS `type`,
+ ANY_VALUE(`height`) AS `height`, ANY_VALUE(`width`) AS `width`, ANY_VALUE(`datasize`) AS `datasize`,
+ ANY_VALUE(`profile`) AS `profile`, min(`scale`) as minscale, max(`scale`) as maxscale
+ FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' %s",
$data_sql,
intval(local_user()),
dbesc($_REQUEST['photo_id']),