diff options
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" ))); +} + +?> |