diff options
author | Jakob Sack <kde@jakobsack.de> | 2011-04-17 01:04:23 +0200 |
---|---|---|
committer | Jakob Sack <kde@jakobsack.de> | 2011-04-17 01:04:23 +0200 |
commit | c4287162c4fb16e5b85a103aabbbbe7a7eebe4c7 (patch) | |
tree | 40ce06b0efc339956b7f5c117e87827cd094ce10 /admin/ajax | |
parent | b129079bed8ebd1b5051dabe15eccdc17bf4b403 (diff) | |
download | nextcloud-server-c4287162c4fb16e5b85a103aabbbbe7a7eebe4c7.tar.gz nextcloud-server-c4287162c4fb16e5b85a103aabbbbe7a7eebe4c7.zip |
Some work on the fancy user management
Diffstat (limited to 'admin/ajax')
-rw-r--r-- | admin/ajax/creategroup.php | 17 | ||||
-rw-r--r-- | admin/ajax/createuser.php | 7 | ||||
-rw-r--r-- | admin/ajax/removegroup.php | 25 | ||||
-rw-r--r-- | admin/ajax/removeuser.php | 25 |
4 files changed, 57 insertions, 17 deletions
diff --git a/admin/ajax/creategroup.php b/admin/ajax/creategroup.php index ab99d2a5bee..bfa4099b889 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 ab99d2a5bee..4aa082a25e6 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 00000000000..c7991ba5819 --- /dev/null +++ b/admin/ajax/removegroup.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["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 00000000000..12a27fff58d --- /dev/null +++ b/admin/ajax/removeuser.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" ))); +} + +?> |