Updated group methods for provisioning api

remotes/origin/stable5
Tom Needham 13 years ago
parent 8161b04c33
commit caa9182eed
  1. 53
      apps/provisioning_api/lib/groups.php

@ -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…
Cancel
Save