summaryrefslogtreecommitdiffstats
path: root/settings/ajax/creategroup.php
blob: be376bea9dc18655bcc9c37a5a824e3257c3d48d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php

OCP\JSON::callCheck();
OC_JSON::checkAdminUser();

$groupname = $_POST["groupname"];
$l = \OC::$server->getL10N('settings');

// Does the group exist?
if( in_array( $groupname, OC_Group::getGroups())) {
	OC_JSON::error(array("data" => array( "message" => $l->t("Group already exists") )));
	exit();
}

// Return Success story
if( OC_Group::createGroup( $groupname )) {
	OC_JSON::success(array("data" => array( "groupname" => $groupname )));
}
else{
	OC_JSON::error(array("data" => array( "message" => $l->t("Unable to add group") )));
}