mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-26 19:29:58 +03:00
issue #164 add new API method pwg.images.uploadCompleted
+ trigger ws_images_uploadCompleted when this API method is called + trigger empty_lounge (can be called at another moment with different effect)
This commit is contained in:
parent
0ee8772b9e
commit
fb84527e3b
5 changed files with 87 additions and 5 deletions
|
@ -1961,7 +1961,6 @@ INSERT IGNORE
|
|||
return;
|
||||
}
|
||||
$logger->debug(__FUNCTION__.', exec='.$exec_id.' wins the race and gets the token!');
|
||||
sleep(5);
|
||||
|
||||
$max_image_id = 0;
|
||||
|
||||
|
@ -2008,7 +2007,10 @@ DELETE
|
|||
conf_delete_param('empty_lounge_running');
|
||||
|
||||
$logger->debug(__FUNCTION__.', exec='.$exec_id.', ends');
|
||||
return count($rows);
|
||||
|
||||
trigger_notify('empty_lounge', $rows);
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -223,10 +223,12 @@ jQuery(document).ready(function(){
|
|||
Piecon.reset();
|
||||
|
||||
jQuery.ajax({
|
||||
url: "ws.php?format=json&method=pwg.images.emptyLounge",
|
||||
url: "ws.php?format=json&method=pwg.images.uploadCompleted",
|
||||
type:"POST",
|
||||
data: {
|
||||
pwg_token: pwg_token
|
||||
pwg_token: pwg_token,
|
||||
image_id: uploadedPhotos.join(","),
|
||||
category_id: uploadCategory.id,
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -2106,11 +2106,62 @@ function ws_images_emptyLounge($params, $service)
|
|||
{
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||
|
||||
$ret = array('count' => empty_lounge());
|
||||
$ret = array('rows' => empty_lounge());
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* API method
|
||||
* Empties the lounge, where photos may wait before taking off.
|
||||
* @since 12
|
||||
* @param mixed[] $params
|
||||
*/
|
||||
function ws_images_uploadCompleted($params, $service)
|
||||
{
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||
|
||||
if (get_pwg_token() != $params['pwg_token'])
|
||||
{
|
||||
return new PwgError(403, 'Invalid security token');
|
||||
}
|
||||
|
||||
if (!is_array($params['image_id']))
|
||||
{
|
||||
$params['image_id'] = preg_split(
|
||||
'/[\s,;\|]/',
|
||||
$params['image_id'],
|
||||
-1,
|
||||
PREG_SPLIT_NO_EMPTY
|
||||
);
|
||||
}
|
||||
$params['image_id'] = array_map('intval', $params['image_id']);
|
||||
|
||||
$image_ids = array();
|
||||
foreach ($params['image_id'] as $image_id)
|
||||
{
|
||||
if ($image_id > 0)
|
||||
{
|
||||
$image_ids[] = $image_id;
|
||||
}
|
||||
}
|
||||
|
||||
// the list of images moved from the lounge might not be the same than
|
||||
// $image_ids (canbe a subset or more image_ids from another upload too)
|
||||
$moved_from_lounge = empty_lounge();
|
||||
|
||||
trigger_notify(
|
||||
'ws_images_uploadCompleted',
|
||||
array(
|
||||
'image_ids' => $image_ids,
|
||||
'category_id' => $params['category_id'],
|
||||
'moved_from_lounge' => $moved_from_lounge,
|
||||
)
|
||||
);
|
||||
|
||||
return array('moved_from_lounge' => $moved_from_lounge);
|
||||
}
|
||||
|
||||
/**
|
||||
* API method
|
||||
* add md5sum at photos, by block. Returns how md5sum were added and how many are remaining.
|
||||
|
|
|
@ -468,6 +468,20 @@ array(
|
|||
'files' => array('admin\include\functions_upload.inc.php (add_uploaded_file)'),
|
||||
'infos' => 'New in 2.11',
|
||||
),
|
||||
array(
|
||||
'name' => 'empty_lounge',
|
||||
'type' => 'trigger_notify',
|
||||
'vars' => array('array', 'rows'),
|
||||
'files' => array('admin\include\functions.php (empty_lounge)'),
|
||||
'infos' => 'New in 12',
|
||||
),
|
||||
array(
|
||||
'name' => 'ws_images_uploadCompleted',
|
||||
'type' => 'trigger_notify',
|
||||
'vars' => array('array', 'upload_data'),
|
||||
'files' => array('include\ws_functions\pwg.images.php (ws_images_uploadCompleted)'),
|
||||
'infos' => 'New in 12',
|
||||
),
|
||||
array(
|
||||
'name' => 'loc_end_password',
|
||||
'type' => 'trigger_notify',
|
||||
|
|
13
ws.php
13
ws.php
|
@ -817,6 +817,19 @@ function ws_addDefaultMethods( $arr )
|
|||
array('admin_only'=>true)
|
||||
);
|
||||
|
||||
$service->addMethod(
|
||||
'pwg.images.uploadCompleted',
|
||||
'ws_images_uploadCompleted',
|
||||
array(
|
||||
'image_id' => array('default'=>null, 'flags'=>WS_PARAM_ACCEPT_ARRAY),
|
||||
'pwg_token' => array(),
|
||||
'category_id' => array('default'=>null, 'type'=>WS_TYPE_ID),
|
||||
),
|
||||
'Notifiy Piwigo you have finished to upload a set of photos. It will empty the lounge, if any.',
|
||||
$ws_functions_root . 'pwg.images.php',
|
||||
array('admin_only'=>true)
|
||||
);
|
||||
|
||||
$service->addMethod(
|
||||
'pwg.images.setInfo',
|
||||
'ws_images_setInfo',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue