diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/ws_functions.inc.php | 49 |
1 files changed, 20 insertions, 29 deletions
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(); |