Skip to content

Commit

Permalink
merge r12725 from branch 2.3 to trunk
Browse files Browse the repository at this point in the history
feature 2533 added: ability to deactivate uniqueness check on pwg.images.add


git-svn-id: http://piwigo.org/svn/trunk@12726 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
plegall committed Dec 13, 2011
1 parent 4bc17c2 commit 5338ef8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
25 changes: 14 additions & 11 deletions include/ws_functions.inc.php
Expand Up @@ -1634,24 +1634,27 @@ function ws_images_add($params, &$service)
}

// does the image already exists ?
if ('md5sum' == $conf['uniqueness_mode'])
{
$where_clause = "md5sum = '".$params['original_sum']."'";
}
if ('filename' == $conf['uniqueness_mode'])
if ($params['check_uniqueness'])
{
$where_clause = "file = '".$params['original_filename']."'";
}
if ('md5sum' == $conf['uniqueness_mode'])
{
$where_clause = "md5sum = '".$params['original_sum']."'";
}
if ('filename' == $conf['uniqueness_mode'])
{
$where_clause = "file = '".$params['original_filename']."'";
}

$query = '
$query = '
SELECT
COUNT(*) AS counter
FROM '.IMAGES_TABLE.'
WHERE '.$where_clause.'
;';
list($counter) = pwg_db_fetch_row(pwg_query($query));
if ($counter != 0) {
return new PwgError(500, 'file already exists');
list($counter) = pwg_db_fetch_row(pwg_query($query));
if ($counter != 0) {
return new PwgError(500, 'file already exists');
}
}

if ($params['resize'])
Expand Down
1 change: 1 addition & 0 deletions ws.php
Expand Up @@ -241,6 +241,7 @@ function ws_addDefaultMethods( $arr )
'maxValue' => $conf['available_permission_levels']
),
'resize' => array('default' => false),
'check_uniqueness' => array('default' => true),
),
'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 5338ef8

Please sign in to comment.