From: Roland Häder Date: Wed, 19 Apr 2017 21:06:01 +0000 (+0200) Subject: Merge branch 'develop' into rewrites/coding-convention-split2-1-2 X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b9d8587f413d198b854ccb213521e47327088566;p=friendica.git Merge branch 'develop' into rewrites/coding-convention-split2-1-2 --- b9d8587f413d198b854ccb213521e47327088566 diff --cc include/api.php index 1705374bbb,0918690264..97c09c20a9 --- a/include/api.php +++ b/include/api.php @@@ -3272,14 -3064,11 +3276,14 @@@ $called_api = null api_register_func('api/oauth/request_token', 'api_oauth_request_token', false); api_register_func('api/oauth/access_token', 'api_oauth_access_token', false); - function api_fr_photos_list($type) { - if (api_user()===false) throw new ForbiddenException(); - $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`, album, filename, type", + if (api_user() === false) { + throw new ForbiddenException(); + } + + $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( @@@ -3309,19 -3098,19 +3313,22 @@@ } function api_fr_photo_detail($type) { - if (api_user()===false) throw new ForbiddenException(); - if(!x($_REQUEST,'photo_id')) throw new BadRequestException("No photo id."); + if (api_user() === false) { + throw new ForbiddenException(); + } elseif (!x($_REQUEST, 'photo_id')) { + throw new BadRequestException("No photo id."); + } $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,"); ++ $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`, ++ $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", ++ FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' %s", $data_sql, intval(local_user()), dbesc($_REQUEST['photo_id']),