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(
}
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']),