Skip to content
Snippets Groups Projects
Commit caa9182e authored by Tom Needham's avatar Tom Needham
Browse files

Updated group methods for provisioning api

parent 8161b04c
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment