require_once($_SERVER['DOCUMENT_ROOT'].'/members/a/bo/FTPFileGroup.php5');

header("Content-type: text/plain");
session_start();

//
// REMOVE THIS LINE WHEN OUT OF DEV
//
if (!isset($_SESSION['ccuserid'])) { $_SESSION['ccuserid'] = 7; }

if (!$_SESSION['ccuserid']) {
	echo getJSONError(array(1, "Not logged in"));
}
else {
	
	$rsPaths = FTPFileGroupDB::retrieveForUserId($_SESSION['ccuserid']);
	$arPaths = array();
	for ($i = 0; $i < sizeof($rsPaths); $i++) {
		array_push($arPaths, $rsPaths[$i]->toHashMap());
	}
	
	echo getJSONResult(array("groupList" => $arPaths));
}

function getJSONResult($result) {
	return json_encode(array("result" => $result));
}

function getJSONError($errors) {
	return json_encode(array("errors" => $errors));
}
Example #2
0
}
else {
	$groupId = $_POST["group_id"];
	unset($_POST["group_id"]);
	
	// If no groupId was provided, look one up for the current user,
	// if none no groups exist, we'll create a default one and use that;
	// otherwise, if one exists with a name of "Default Group", we'll use that;
	// otherwise, an error is thrown back since a group must be specified.
	if (!($groupId)) {
		$ar = FTPFileGroupDB::retrieveForUserId($_SESSION["ccuserid"]);
		if ($ar == null) {
			$ftpFileGroup = new FTPFileGroup();
			$ftpFileGroup->setUserId($_SESSION["ccuserid"]);
			$ftpFileGroup->setName("Default Group");
			FTPFileGroupDB::save($ftpFileGroup);
			$groupId = $ftpFileGroup->getGroupId();
		}
		else if (sizeof($ar) == 1) {
			if ($ar[0]->getName() == "Default Group") {
				$groupId = $ar[0]->getGroupId();
			}
		}
	}
	
	// same test as above, if we still don't have one, then don't proceed
	if (($groupId)) {
		$successful = false;
		$arFtpSiteIds = array();
		
		if (sizeof($_POST) == 0) {
Example #3
0
require_once($_SERVER['DOCUMENT_ROOT'].'/members/a/bo/FTPPath.php5');
require_once($_SERVER['DOCUMENT_ROOT'].'/members/a/bo/FTPFileGroup.php5');

header("Content-type: text/plain");
session_start();

//
// REMOVE THIS LINE WHEN OUT OF DEV
//
if (!isset($_SESSION['ccuserid'])) { $_SESSION['ccuserid'] = 7; }

if (!$_SESSION['ccuserid']) {
	echo getJSONError(array(1, "Not logged in"));
}
else {
	$arGroups = FTPFileGroupDB::retrieveForUserId($_SESSION["ccuserid"]);
	if ($arGroups != null) {
		$groupId = $arGroups[0]->getGroupId();
	}
	
	if (!groupId) {
		echo getJSONError(array(3, "Group Id required"));
	}
	else {
		$arPathRecords = FTPPathDB::retrieveForGroupId($groupId);
		$arOut = array();
		
		if ($arPathRecords != null) {
			foreach ($arPathRecords as $pathRecord) {
				$paths = explode(chr(13), $pathRecord->getPath());
				foreach ($paths as $path) {