summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorTom Needham <tom@owncloud.com>2012-07-30 15:25:53 +0000
committerTom Needham <tom@owncloud.com>2012-07-30 15:25:53 +0000
commitcaa9182eed93b07d6f47bc1bc629f811172b0a02 (patch)
tree6471796d272e46f9b2f79db38526ef276b4006af /apps
parent8161b04c336763297738b348b0695cecd0bc0c78 (diff)
downloadnextcloud-server-caa9182eed93b07d6f47bc1bc629f811172b0a02.tar.gz
nextcloud-server-caa9182eed93b07d6f47bc1bc629f811172b0a02.zip
Updated group methods for provisioning api
Diffstat (limited to 'apps')
-rw-r--r--apps/provisioning_api/lib/groups.php53
1 files changed, 52 insertions, 1 deletions
diff --git a/apps/provisioning_api/lib/groups.php b/apps/provisioning_api/lib/groups.php
index 7e27eeafb08..6a18e6b37fc 100644
--- a/apps/provisioning_api/lib/groups.php
+++ b/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;
+ }
+ }
+ }
+
} \ No newline at end of file