diff options
author | plegall <plg@piwigo.org> | 2009-06-24 21:42:39 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2009-06-24 21:42:39 +0000 |
commit | 91c7200b59367be519aad81e3d1724fd3bdc1c0d (patch) | |
tree | 35a34f394b6c417d46d7647c702c5bcd83c3bfa0 /include/ws_functions.inc.php | |
parent | 90cc8dccf3140aee43c3bf1a9af77b90a6ff7cbc (diff) |
feature 1033 added: new API method pwg.categories.setInfo makes possible to
change the name and comment of a given category.
git-svn-id: http://piwigo.org/svn/branches/2.0@3453 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/ws_functions.inc.php')
-rw-r--r-- | include/ws_functions.inc.php | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php index 422cfd176..979e855ef 100644 --- a/include/ws_functions.inc.php +++ b/include/ws_functions.inc.php @@ -1733,6 +1733,59 @@ SELECT } } +function ws_categories_setInfo($params, &$service) +{ + global $conf; + if (!is_admin() || is_adviser() ) + { + return new PwgError(401, 'Access denied'); + } + + // category_id + // name + // comment + + $params['category_id'] = (int)$params['category_id']; + if ($params['category_id'] <= 0) + { + return new PwgError(WS_ERR_INVALID_PARAM, "Invalid category_id"); + } + + // database registration + $update = array( + 'id' => $params['category_id'], + ); + + $info_columns = array( + 'name', + 'comment', + ); + + $perform_update = false; + foreach ($info_columns as $key) + { + if (isset($params[$key])) + { + $perform_update = true; + $update[$key] = $params[$key]; + } + } + + if ($perform_update) + { + include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); + mass_updates( + CATEGORIES_TABLE, + array( + 'primary' => array('id'), + 'update' => array_diff(array_keys($update), array('id')) + ), + array($update) + ); + } + +} + function ws_logfile($string) { return true; |