diff options
Diffstat (limited to 'include/ws_functions/pwg.images.php')
-rw-r--r-- | include/ws_functions/pwg.images.php | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/include/ws_functions/pwg.images.php b/include/ws_functions/pwg.images.php index 319bce1f1..1d9d0cbd4 100644 --- a/include/ws_functions/pwg.images.php +++ b/include/ws_functions/pwg.images.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 Piwigo Team http://piwigo.org | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | // +-----------------------------------------------------------------------+ @@ -740,7 +740,40 @@ UPDATE '. IMAGES_TABLE .' * @option int rank */ function ws_images_setRank($params, $service) -{ +{ + if (count($params['image_id']) > 1) + { + include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); + + save_images_order( + $params['category_id'], + $params['image_id'] + ); + + $query = ' +SELECT + image_id + FROM '.IMAGE_CATEGORY_TABLE.' + WHERE category_id = '.$params['category_id'].' + ORDER BY rank ASC +;'; + $image_ids = query2array($query, null, 'image_id'); + + // return data for client + return array( + 'image_id' => $image_ids, + 'category_id' => $params['category_id'], + ); + } + + // turns image_id into a simple int instead of array + $params['image_id'] = array_shift($params['image_id']); + + if (empty($params['rank'])) + { + return new PwgError(WS_ERR_MISSING_PARAM, 'rank is missing'); + } + // does the image really exist? $query = ' SELECT COUNT(*) |