Index: pro-bachkim-filespace/sourcecode/application/modules/ajax/controllers/privatecontent.php
===================================================================
--- pro-bachkim-filespace/sourcecode/application/modules/ajax/controllers/privatecontent.php	(revision 23)
+++ pro-bachkim-filespace/sourcecode/application/modules/ajax/controllers/privatecontent.php	(revision 42)
@@ -7,49 +7,76 @@
  */
 
+/* private $_aryDir = array(
+ 0 => array ('id' => 1, 'name' => 'Dir 1', 'parentID' => 0),
+		1 => array ('id' => 2, 'name' => 'Dir 2', 'parentID' => 0),
+		2 => array ('id' => 3, 'name' => 'Dir 1.1', 'parentID' => 1),
+		3 => array ('id' => 4, 'name' => 'Dir 1.1.1', 'parentID' => 3),
+		4 => array ('id' => 5, 'name' => 'Dir 1.1.1.1', 'parentID' => 4),
+		5 => array ('id' => 6, 'name' => 'Dir 1.1.2', 'parentID' => 3),
+		6 => array ('id' => 7, 'name' => 'Dir 3', 'parentID' => 0),
+		7 => array ('id' => 8, 'name' => 'Dir 3.1', 'parentID' => 7)
+);
+
+private $_aryFile = array(
+		0 => array('id' => 1, 'name' => 'File 1', 'minetype' => 'text', 'size' => '1.5MB', 'parentID' => 1),
+		1 => array('id' => 2, 'name' => 'File 2', 'minetype' => 'text', 'size' => '1.6MB', 'parentID' => 1),
+		2 => array('id' => 3, 'name' => 'File 3', 'minetype' => 'text', 'size' => '1.7MB', 'parentID' => 2),
+		3 => array('id' => 4, 'name' => 'File 4', 'minetype' => 'text', 'size' => '1.8MB', 'parentID' => 2),
+		4 => array('id' => 5, 'name' => 'File 5', 'minetype' => 'text', 'size' => '1.8MB', 'parentID' => 0),
+		5 => array('id' => 6, 'name' => 'File 6', 'minetype' => 'text', 'size' => '1.8MB', 'parentID' => 3),
+		5 => array('id' => 7, 'name' => 'File 7', 'minetype' => 'text', 'size' => '1.8MB', 'parentID' => 5)
+); */
+
 class PrivateContent extends MX_Controller 
 {
-	/* private $_aryDir = array(
-				0 => array ('id' => 1, 'name' => 'Dir 1', 'parentID' => 0),
-				1 => array ('id' => 2, 'name' => 'Dir 2', 'parentID' => 0),
-				2 => array ('id' => 3, 'name' => 'Dir 1.1', 'parentID' => 1),
-				3 => array ('id' => 4, 'name' => 'Dir 1.1.1', 'parentID' => 3),
-				4 => array ('id' => 5, 'name' => 'Dir 1.1.1.1', 'parentID' => 4),
-				5 => array ('id' => 6, 'name' => 'Dir 1.1.2', 'parentID' => 3),
-				6 => array ('id' => 7, 'name' => 'Dir 3', 'parentID' => 0),
-				7 => array ('id' => 8, 'name' => 'Dir 3.1', 'parentID' => 7)
-		);
-	
-	private $_aryFile = array(
-				0 => array('id' => 1, 'name' => 'File 1', 'minetype' => 'text', 'size' => '1.5MB', 'parentID' => 1),
-				1 => array('id' => 2, 'name' => 'File 2', 'minetype' => 'text', 'size' => '1.6MB', 'parentID' => 1),
-				2 => array('id' => 3, 'name' => 'File 3', 'minetype' => 'text', 'size' => '1.7MB', 'parentID' => 2),
-				3 => array('id' => 4, 'name' => 'File 4', 'minetype' => 'text', 'size' => '1.8MB', 'parentID' => 2),
-				4 => array('id' => 5, 'name' => 'File 5', 'minetype' => 'text', 'size' => '1.8MB', 'parentID' => 0),
-				5 => array('id' => 6, 'name' => 'File 6', 'minetype' => 'text', 'size' => '1.8MB', 'parentID' => 3),
-				5 => array('id' => 7, 'name' => 'File 7', 'minetype' => 'text', 'size' => '1.8MB', 'parentID' => 5)
-		); */
-	
+
 	public function __construct() {
 		parent::__construct();
 		$this->load->model('Directory_model', 'objDirectory', TRUE);
+		$this->vservices->setApiUrl($this->config->item('api_url'));
+		$this->vservices->setConnection($this->curl);
+		$this->vservices->setUserId(33);
 	}
 	
 	public function getContent () {
-		$aryData = array('DIRECTORIES' =>  $this->objDirectory->getAllDirectory() , 'FILES' => $this->objDirectory->getAllFile(), 'ENCRYPT' => md5('abcdef'));
+		$xmlData = $this->vservices->getPrivateTree();
+		$this->xml->parse($xmlData);
+
+		$aryDirs = array();
+		$aryFiles = array();
+		
+		$aryError = array('err' => $this->xml->tree->_param['err'], 'errCode' => $this->xml->tree->_param['errCode']);
+		
+		if (is_array($this->xml->tree->folderlist->folder)) {
+			foreach($this->xml->tree->folderlist->folder as $key=>$value){
+				$aryDirs[] = array('id' => $value->_param['id'], 'name' => $value->_value, 'parentID' => $value->_param['parentid'] == -1 ? 0:$value->_param['parentid']);
+			}
+		}
+		else if (isset($this->xml->tree->folderlist->folder)) {
+			$folder = $this->xml->tree->folderlist->folder;
+			$aryDirs[] = array('id' => $folder->_param['id'], 'name' => $folder->_value,'parentID' => $folder->_param['parentid'] == -1 ? 0:$folder->_param['parentid']);
+		}
+		
+		if (is_array($this->xml->tree->filelist->file)) {
+			foreach($this->xml->tree->filelist->file as $key=>$value){
+				$aryFiles[] = array('id' => $value->_param['id'], 'name' => $value->_value, 'parentID' => $value->_param['parentid'] == -1 ? 0:$value->_param['parentid'], 'minetype' => $value->_param['filetype']);
+			}
+		}else if (isset($this->xml->tree->filelist->file)) {
+			$file = $this->xml->tree->filelist->file;
+			$aryFiles[] = array('id' => $file->_param['id'], 'name' => $file->_value,'parentID' => $file->_param['parentid'] == -1 ? 0:$file->_param['parentid'], 'minetype' => $file->_param['filetype']);
+		}
+		
+		$aryData = array('DIRECTORIES' =>  $aryDirs , 'FILES' => $aryFiles, 'ERROR' => $aryError);
 		echo json_encode($aryData);
 	}
 
 	public function createDir () {
-		$parentDir =  $this->input->post('parentID',TRUE);
-		$name =  $this->input->post('name',TRUE);
-		
-		if (!is_null($parentDir) && !is_null($name)) {
-			
-			$maxID = $this->objDirectory->getMaxID (true);
-			$aryDir = array('id' => (int)$maxID + 1, 'name' => $name, 'parentID' => $parentDir, 'maxID' => $maxID);
-			
-			$result = $this->objDirectory->createDir($aryDir);
-			echo json_encode($aryDir);
-		}
+		$parentDir =  $this->input->post('fparentid',TRUE);
+		$name =  $this->input->post('fname',TRUE);
+		$xmlData = $this->vservices->createDir($name, $parentDir);
+		$this->xml->parse($xmlData);
+		$aryError = array('err' => $this->xml->status->_param['err'], 'errCode' => $this->xml->status->_param['errCode']);
+		$aryData = array('id' => $this->xml->status->_param['id'], 'name' => $name, 'parentID' => $parentDir, 'ERROR' => $aryError);
+		echo json_encode($aryData);
 	}
 	
@@ -74,5 +101,8 @@
 		echo json_encode($aryData);
 	}
-
+	
+	public function upload() {
+		
+	}
 }
 
