diff options
author | Jakob Sack <kde@jakobsack.de> | 2011-04-17 13:15:55 +0200 |
---|---|---|
committer | Jakob Sack <kde@jakobsack.de> | 2011-04-17 13:15:55 +0200 |
commit | afa2c4a2c31c6cb293981cdb25f264fe96fb3b98 (patch) | |
tree | 44318f8539e1d9ab43870effee60826528d0a410 /admin/ajax | |
parent | 58cb46c4e85ff4af41d91522e8fcba89e01fed81 (diff) | |
download | nextcloud-server-afa2c4a2c31c6cb293981cdb25f264fe96fb3b98.tar.gz nextcloud-server-afa2c4a2c31c6cb293981cdb25f264fe96fb3b98.zip |
User manager still not perfect but the aim is reachable!
Diffstat (limited to 'admin/ajax')
-rw-r--r-- | admin/ajax/changepassword.php | 25 | ||||
-rw-r--r-- | admin/ajax/removeuser.php | 24 | ||||
-rw-r--r-- | admin/ajax/togglegroups.php | 25 |
3 files changed, 70 insertions, 4 deletions
diff --git a/admin/ajax/changepassword.php b/admin/ajax/changepassword.php new file mode 100644 index 00000000000..12a27fff58d --- /dev/null +++ b/admin/ajax/changepassword.php @@ -0,0 +1,25 @@ +<?php + +// Init owncloud +require_once('../../lib/base.php'); + +// We send json data +header( "Content-Type: application/jsonrequest" ); + +// Check if we are a user +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ + echo json_encode( array( "status" => "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/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" ))); } ?> diff --git a/admin/ajax/togglegroups.php b/admin/ajax/togglegroups.php new file mode 100644 index 00000000000..12a27fff58d --- /dev/null +++ b/admin/ajax/togglegroups.php @@ -0,0 +1,25 @@ +<?php + +// Init owncloud +require_once('../../lib/base.php'); + +// We send json data +header( "Content-Type: application/jsonrequest" ); + +// Check if we are a user +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ + echo json_encode( array( "status" => "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" ))); +} + +?> |