aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2016-02-23 15:58:31 +0100
committerplegall <plg@piwigo.org>2016-02-23 15:58:31 +0100
commitbbe117080de593376007b89e76384bf449f1a004 (patch)
tree8889482ac7bb9095b28f84d286b9fcf76d54cb0e
parente936d291ebd2ffbffd6eabe33b8e26c979171900 (diff)
feature #321, set status with pwg.categories.setInfos
-rw-r--r--include/ws_functions/pwg.categories.php27
-rw-r--r--ws.php2
2 files changed, 29 insertions, 0 deletions
diff --git a/include/ws_functions/pwg.categories.php b/include/ws_functions/pwg.categories.php
index 9c337f7c2..502c8f18d 100644
--- a/include/ws_functions/pwg.categories.php
+++ b/include/ws_functions/pwg.categories.php
@@ -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'],
);
diff --git a/ws.php b/ws.php
index 44e34b3a6..6a2bd211d 100644
--- a/ws.php
+++ b/ws.php
@@ -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',