Skip to content

Commit

Permalink
feature added: pwg.images.add can perform an update on an existing ph…
Browse files Browse the repository at this point in the history
…oto.

git-svn-id: http://piwigo.org/svn/trunk@13090 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
plegall committed Feb 10, 2012
1 parent 8afb39b commit 2bfedae
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
20 changes: 19 additions & 1 deletion include/ws_functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,24 @@ function ws_images_add($params, &$service)
);
}

$params['image_id'] = (int)$params['image_id'];
if ($params['image_id'] > 0)
{
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');

$query='
SELECT *
FROM '.IMAGES_TABLE.'
WHERE id = '.$params['image_id'].'
;';

$image_row = pwg_db_fetch_assoc(pwg_query($query));
if ($image_row == null)
{
return new PwgError(404, "image_id not found");
}
}

// does the image already exists ?
if ($params['check_uniqueness'])
{
Expand Down Expand Up @@ -1797,7 +1815,7 @@ function ws_images_add($params, &$service)
$params['original_filename'],
null, // categories
isset($params['level']) ? $params['level'] : null,
null, // image_id
$params['image_id'] > 0 ? $params['image_id'] : null,
$params['original_sum']
);

Expand Down
1 change: 1 addition & 0 deletions ws.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ function ws_addDefaultMethods( $arr )
'maxValue' => $conf['available_permission_levels']
),
'check_uniqueness' => array('default' => true),
'image_id' => array('default' => null),
),
'POST method only.
<br><b>categories</b> is a string list "category_id[,rank];category_id[,rank]" The rank is optional and is equivalent to "auto" if not given.'
Expand Down

0 comments on commit 2bfedae

Please sign in to comment.