mirror of
https://github.com/nextcloud/server.git
synced 2026-04-23 07:08:34 -04:00
Updated group methods for provisioning api
This commit is contained in:
parent
8161b04c33
commit
caa9182eed
1 changed files with 52 additions and 1 deletions
|
|
@ -23,7 +23,58 @@
|
|||
|
||||
class OC_Provisioning_API_Groups{
|
||||
|
||||
/**
|
||||
* returns a list of groups
|
||||
*/
|
||||
public static function getGroups($parameters){
|
||||
|
||||
$groups = OC_Group::getGroups();
|
||||
return empty($groups) ? 404 : $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns an array of users in the group specified
|
||||
*/
|
||||
public static function getGroup($parameters){
|
||||
// Check the group exists
|
||||
if(!OC_Group::groupExists($parameters['groupid'])){
|
||||
return 404;
|
||||
}
|
||||
return OC_Group::usersInGroup($parameters['groupid']);
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new group
|
||||
*/
|
||||
public static function addGroup($parameters){
|
||||
// Validate name
|
||||
if( preg_match( '/[^a-zA-Z0-9 _\.@\-]/', $parameters['groupid'] ) || empty($parameters['groupid'])){
|
||||
return 401;
|
||||
}
|
||||
// Check if it exists
|
||||
if(OC_Group::groupExists($parameters['groupid'])){
|
||||
return 409;
|
||||
}
|
||||
if(OC_Group::createGroup($parameters['groupid'])){
|
||||
return 200;
|
||||
} else {
|
||||
return 500;
|
||||
}
|
||||
}
|
||||
|
||||
public static function deleteGroup($parameters){
|
||||
// Check it exists
|
||||
if(!OC_Group::groupExists($parameters['groupid'])){
|
||||
return 404;
|
||||
} else if($parameters['groupid'] == 'admin'){
|
||||
// Cannot delete admin group
|
||||
return 403;
|
||||
} else {
|
||||
if(OC_Group::deleteGroup($parameters['groupid'])){
|
||||
return 200;
|
||||
} else {
|
||||
return 500;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue