2011-04-17 03:04:23 +04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Init owncloud
|
|
|
|
require_once('../../lib/base.php');
|
|
|
|
|
2012-07-18 19:23:40 +04:00
|
|
|
OC_JSON::checkSubAdminUser();
|
2012-07-07 17:27:04 +04:00
|
|
|
OCP\JSON::callCheck();
|
2011-04-17 03:04:23 +04:00
|
|
|
|
2011-04-17 15:15:55 +04:00
|
|
|
$username = $_POST["username"];
|
2011-04-17 03:04:23 +04:00
|
|
|
|
2012-07-18 19:23:40 +04:00
|
|
|
if(!OC_Group::inGroup(OC_User::getUser(), 'admin') && OC_SubAdmin::isSubAdmin(OC_User::getUser())){
|
|
|
|
$accessiblegroups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
|
|
|
|
$isuseraccessible = false;
|
|
|
|
foreach($accessiblegroups as $accessiblegroup){
|
|
|
|
if(OC_Group::inGroup($username, $accessiblegroup)){
|
|
|
|
$isuseraccessible = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!$isuseraccessible){
|
|
|
|
$l = OC_L10N::get('core');
|
|
|
|
self::error(array( 'data' => array( 'message' => $l->t('Authentication error') )));
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-17 03:04:23 +04:00
|
|
|
// Return Success story
|
2011-07-29 23:36:03 +04:00
|
|
|
if( OC_User::deleteUser( $username )){
|
2011-09-24 00:22:59 +04:00
|
|
|
OC_JSON::success(array("data" => array( "username" => $username )));
|
2011-04-17 03:04:23 +04:00
|
|
|
}
|
|
|
|
else{
|
2011-09-24 00:22:59 +04:00
|
|
|
OC_JSON::error(array("data" => array( "message" => "Unable to delete user" )));
|
2011-04-17 03:04:23 +04:00
|
|
|
}
|