From 6beee17904e7a8829fde211dba053993800ab04b Mon Sep 17 00:00:00 2001 From: plegall Date: Thu, 30 Aug 2012 12:54:29 +0000 Subject: merge r17668 from branch 2.4 to trunk bug 2733 fixed: when creating a sub-album in a private album with pwg.categories.add, it is automatically private too. git-svn-id: http://piwigo.org/svn/trunk@17669 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/ws_functions.inc.php | 49 ++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 29 deletions(-) (limited to 'include/ws_functions.inc.php') diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php index 4e9d8d3fb..4e439af88 100644 --- a/include/ws_functions.inc.php +++ b/include/ws_functions.inc.php @@ -2302,46 +2302,37 @@ function ws_categories_add($params, &$service) include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); - $creation_output = create_virtual_category( - $params['name'], - $params['parent'] - ); - - if (isset($creation_output['error'])) + $options = array(); + if (!empty($params['status']) and in_array($params['status'], array('private','public'))) { - return new PwgError(500, $creation_output['error']); + $options['status'] = $params['status']; } - $updates = array(); - if ( !empty($params['status']) and in_array($params['status'], array('private','public')) ) + if (!empty($params['visible']) and in_array($params['visible'], array('true','false'))) { - $updates['status'] = $params['status']; + $options['visible'] = get_boolean($params['visible']); } - if ( !empty($params['visible']) and in_array($params['visible'], array('true','false')) ) - { - $updates['visible'] = $params['visible']; - } - if ( !empty($params['commentable']) and in_array($params['commentable'], array('true','false')) ) - { - $updates['commentable'] = $params['commentable']; - } - if ( !empty($params['comment']) ) + + if (!empty($params['commentable']) and in_array($params['commentable'], array('true','false')) ) { - $updates['comment'] = strip_tags($params['comment']); + $options['commentable'] = get_boolean($params['commentable']); } - - if (!empty($updates)) + + if (!empty($params['comment'])) { - single_update( - CATEGORIES_TABLE, - $updates, - array('id'=>$creation_output['id']) - ); + $options['comment'] = $params['comment']; } - if ( isset($updates['status']) and 'private' == $updates['status'] ) + + $creation_output = create_virtual_category( + $params['name'], + $params['parent'], + $options + ); + + if (isset($creation_output['error'])) { - add_permission_on_category($creation_output['id'], get_admins()); + return new PwgError(500, $creation_output['error']); } invalidate_user_cache(); -- cgit v1.2.3