feature #321, set status with pwg.categories.setInfos

This commit is contained in:
plegall 2016-02-23 15:58:31 +01:00
parent e936d291eb
commit bbe117080d
2 changed files with 29 additions and 0 deletions

View file

@ -591,6 +591,33 @@ function ws_categories_add($params, &$service)
*/
function ws_categories_setInfo($params, &$service)
{
// does the category really exist?
$query = '
SELECT *
FROM '.CATEGORIES_TABLE.'
WHERE id = '.$params['category_id'].'
;';
$categories = query2array($query);
if (count($categories) == 0)
{
return new PwgError(404, 'category_id not found');
}
$category = $categories[0];
if (!empty($params['status']))
{
if (!in_array($params['status'], array('private','public')))
{
return new PwgError(WS_ERR_INVALID_PARAM, "Invalid status, only public/private");
}
if ($params['status'] != $category['status'])
{
set_cat_status(array($params['category_id']), $params['status']);
}
}
$update = array(
'id' => $params['category_id'],
);

2
ws.php
View file

@ -692,6 +692,8 @@ function ws_addDefaultMethods( $arr )
'category_id' => array('type'=>WS_TYPE_ID),
'name' => array('default'=>null),
'comment' => array('default'=>null),
'status' => array('default'=>null,
'info'=>'public, private'),
),
'Changes properties of an album.',
$ws_functions_root . 'pwg.categories.php',