diff options
Diffstat (limited to 'admin/ajax/removeuser.php')
-rw-r--r-- | admin/ajax/removeuser.php | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/admin/ajax/removeuser.php b/admin/ajax/removeuser.php index 12a27fff58d..9cf52c128b0 100644 --- a/admin/ajax/removeuser.php +++ b/admin/ajax/removeuser.php @@ -12,14 +12,30 @@ if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' exit(); } -$name = $_POST["username"]; +$groups = array(); +$username = $_POST["username"]; +$password = $_POST["password"]; +$groups = $_POST["groups"]; + +$success = true; +if( $password ){ + $success = $success && OC_USER::setPassword( $username, $password ); +} + +// update groups (delete old ones, add new ones) +foreach( OC_GROUP::getUserGroups( $username ) as $i ){ + OC_GROUP::removeFromGroup( $username, $i ); +} +foreach( $groups as $i ){ + OC_GROUP::addToGroup( $username, $i ); +} // Return Success story -if( OC_USER::deleteUser( $name )){ - echo json_encode( array( "status" => "success", "data" => array( "username" => $name ))); +if( $success ){ + echo json_encode( array( "status" => "success", "data" => array( "username" => $username, "groups" => implode( ", ", $groups )))); } else{ - echo json_encode( array( "status" => "error", "data" => array( "message" => "Unable to delete user" ))); + echo json_encode( array( "status" => "error", "data" => array( "message" => "Edit user" ))); } ?> |