<?
if ($_SESSION['username'] == "admin") {


if ($_POST['spaceQuota'] == "limited") {
	$spaceQuota = $_POST['spaceQuotaSize']*1024*1024;
} else {
	$spaceQuota = "";
}

if ($_POST['trafficQuota'] == "limited") {
	$trafficQuota = $_POST['trafficQuotaSize']*1024*1024;
} else {
	$trafficQuota = "";
}


$data['name'] = $str->fromHTML($_POST['name']);

$data['path'] = ($settings->config['demomode'])?$settings->config['demorestrictedfolder']:cleanPath(rawurldecode($_POST['userpath']));
$data['lastlogin'] = "0";
$data['readonly'] = ($_POST['notReadOnly'])?"0":"1";
$data['upload'] = ($_POST['upload'])?"1":"0";
$data['download'] = ($_POST['download'])?"1":"0";
$data['sendbyemail'] = ($_POST['sendbyemail'])?"1":"0";
$data['uploadnotice'] = ($_POST['uploadNotice'])?"1":"0";
$data['downloadnotice'] = ($_POST['downloadNotice'])?"1":"0";
$data['sharing'] = ($_POST['sharing'])?"1":"0";
$data['spacequota'] = $spaceQuota;
$data['traffic'] = "0";
$data['trafficquota'] = $trafficQuota;
$data['shareaccess'] = ($_POST['shareaccess'])?"1":"0";
$data['suspended'] = "0";
$data['ui_type'] = ($_POST['ui_type'])?($_POST['ui_type']):"AFIAN_STANDARD";
$data['ui_has_tree'] = "1";

//debug($data);

	if ($_POST['view_others'] == "specific") {
		$data['view_others'] = $str->fromHTML($_POST['view_others_specific']);
	} else {
		$data['view_others'] = $str->fromHTML($_POST['view_others']);
	}


if (strlen($data['name']) < 1) {
	$msg = $lang->get("Please enter a name for the group.");
	$statusBarMessage[] = array($msg, 1);
} else {

	
	
	
	if (isCleanPath($data['path'])) {
		$auth->createGroup($data);
		//debug($auth);
		if (!$auth->error) {
			$log->act("0", "group creation", $data['name']);
			$msg = $lang->get("Group \"".$data['name']."\" added.");
			$groupAdded = true;
			$statusBarMessage[] = array($msg, 0);
		} else {
			$log->act("1", "group creation", $data['name']);
			$msg = "<span class=\"nowrap\">".$lang->get("Failed to add group \"".$data['name']."\"")."</span><br><span class=\"nowrap\">".$auth->error."</span>";
			$statusBarMessage[] = array($msg, 1);
		}
	
	} else {
		$msg = "<span class=\"nowrap\">".$lang->get("Please enter a clean path (full path).")."</span>";
		$statusBarMessage[] = array($msg, 1);
	}

}

}
?>