diff --git a/admin/ajax/creategroup.php b/admin/ajax/creategroup.php index ab99d2a5be..bfa4099b88 100644 --- a/admin/ajax/creategroup.php +++ b/admin/ajax/creategroup.php @@ -12,23 +12,14 @@ if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' exit(); } -$groups = array(); -if( isset( $_POST["groups"] )){ - $groups = $_POST["groups"]; -} -$username = $_POST["username"]; -$password = $_POST["password"]; - -foreach( $groups as $i ){ - OC_GROUP::addToGroup( $username, $i ); -} +$name = $_POST["groupname"]; // Return Success story -if( OC_USER::createUser( $username, $password )){ - echo json_encode( array( "status" => "success", "data" => array( "username" => $username, "groups" => implode( ", ", $groups )))); +if( OC_GROUP::createGroup( $name )){ + echo json_encode( array( "status" => "success", "data" => array( "groupname" => $name ))); } else{ - echo json_encode( array( "status" => "error", "data" => array( "message" => "Unable to add user" ))); + echo json_encode( array( "status" => "error", "data" => array( "message" => "Unable to add group" ))); } ?> diff --git a/admin/ajax/createuser.php b/admin/ajax/createuser.php index ab99d2a5be..4aa082a25e 100644 --- a/admin/ajax/createuser.php +++ b/admin/ajax/createuser.php @@ -19,12 +19,11 @@ if( isset( $_POST["groups"] )){ $username = $_POST["username"]; $password = $_POST["password"]; -foreach( $groups as $i ){ - OC_GROUP::addToGroup( $username, $i ); -} - // Return Success story if( OC_USER::createUser( $username, $password )){ + foreach( $groups as $i ){ + OC_GROUP::addToGroup( $username, $i ); + } echo json_encode( array( "status" => "success", "data" => array( "username" => $username, "groups" => implode( ", ", $groups )))); } else{ diff --git a/admin/ajax/removegroup.php b/admin/ajax/removegroup.php new file mode 100644 index 0000000000..c7991ba581 --- /dev/null +++ b/admin/ajax/removegroup.php @@ -0,0 +1,25 @@ + "error", "data" => array( "message" => "Authentication error" ))); + exit(); +} + +$name = $_POST["groupname"]; + +// Return Success story +if( OC_GROUP::deleteGroup( $name )){ + echo json_encode( array( "status" => "success", "data" => array( "groupname" => $name ))); +} +else{ + echo json_encode( array( "status" => "error", "data" => array( "message" => "Unable to delete group" ))); +} + +?> diff --git a/admin/ajax/removeuser.php b/admin/ajax/removeuser.php new file mode 100644 index 0000000000..12a27fff58 --- /dev/null +++ b/admin/ajax/removeuser.php @@ -0,0 +1,25 @@ + "error", "data" => array( "message" => "Authentication error" ))); + exit(); +} + +$name = $_POST["username"]; + +// Return Success story +if( OC_USER::deleteUser( $name )){ + echo json_encode( array( "status" => "success", "data" => array( "username" => $name ))); +} +else{ + echo json_encode( array( "status" => "error", "data" => array( "message" => "Unable to delete user" ))); +} + +?> diff --git a/admin/js/users.js b/admin/js/users.js index 0713cf8e5d..7cd1ed6f62 100644 --- a/admin/js/users.js +++ b/admin/js/users.js @@ -12,10 +12,15 @@ $(document).ready(function(){ "Create an account": function() { var post = $( "#createuserdata" ).serialize(); $.post( 'ajax/createuser.php', post, function(data){ - var newrow = '