Index: pro-violet-viettel/www/deploy/api/platform/modules/space/actions/actions.class.php
===================================================================
--- pro-violet-viettel/www/deploy/api/platform/modules/space/actions/actions.class.php	(revision 860)
+++ pro-violet-viettel/www/deploy/api/platform/modules/space/actions/actions.class.php	(revision 861)
@@ -82,6 +82,6 @@
     
     private function CopySpaceDir($sourceObj, $destination, $userId, &$aryNewTree) {
-        $dirId = $sourceObj->id;
-        
+    	error_log(date('YmdHis').' - Source Obj: '.var_export($sourceObj, TRUE), 3, '/srv/www/sgb/log/file.log');
+    	$dirId = $sourceObj->id;        
         $c = new Criteria();
         $c->add(TblspacecategoryPeer::CAT_ID, $dirId);
@@ -98,57 +98,21 @@
         $aryNewTree['DIRECTORIES'][] = $newDir;
         
+        error_log(date('YmdHis').' - $aryNewTree: '.var_export($aryNewTree, TRUE), 3, '/srv/www/sgb/log/file.log');
+        
         if (isset($sourceObj->childDirs)) {
-        	$aryChidlDirs = $sourceObj->childDirs;
-        	foreach ($aryChidlDirs as $key => $dir) {
-
-        			
-        		
-					/*$c = new Criteria();
-        			$c->add(TblspacecategoryPeer::CAT_ID, $dir->id);
-        			$c->add(TblspacecategoryPeer::CAT_USER, $userId);
-        			$currentDir = TblspacecategoryPeer::doSelectOne($c);
-        			$newChildDirID = $this->CreateSpaceDir($currentDir->getCatName(), $newDirID, $userId);
-        			
-        			$newDir = new stdClass();
-        			$newDir->id = $newChildDirID;
-        			$newDir->name = $dir->name;
-        			$newDir->parentID = $newDirID;
-        			
-        			$aryNewTree['DIRECTORIES'][] = $newDir; */
-        		
-        		//$this->CopySpaceDir($dir, $newDirID, $userId, $aryNewTree);
+        	foreach ($sourceObj->childDirs as $key => $dir) {
+        			$this->CopySpaceDir($dir, $newDir->id, $userId , $aryNewTree);
         	}
         }
         
-        
-        /* $c = new Criteria();
-        $c->add(TblspacecategoryPeer::CAT_ID, $newDirID);
-        $c->add(TblspacecategoryPeer::CAT_USER, $userId);
-        $newCat = TblspacecategoryPeer::doSelectOne($c);
-
-        $newDir = new stdClass();
-        $newDir->id = $newDirID;
-        $newDir->name = $newCat->getCatName();
-        $newDir->parentID = $newCat->getCatParent(); */
-
-        //$aryNewTree['DIRECTORIES'][] = $newDir;
-
-        /* if (isset($sourceObj->files)) {
-            $aryChidlFiles = $sourceObj->files;
-            foreach ($aryChidlFiles as $key => $file) {
-                $aryNewTree['FILES'][] = $this->CopySpaceFile($file->id, $newDirID, $userId);
-            }
-        }
-
-        if (isset($sourceObj->childs)) {
-            $aryChidlDirs = $sourceObj->childs;
-            foreach ($aryChidlDirs as $key => $dir) {
-                $this->CopySpaceDir($dir, $newDirID, $userId, $aryNewTree);
-            }
-        } */
+        if (isset($sourceObj->childFiles)) {
+        	foreach ($sourceObj->childFiles as $key => $file) {
+        		$aryNewTree['FILES'][] = $this->CopySpaceFile($file->id, $newDirID, $userId);
+        	}
+        }
+        
     }
 
     private function CopySpaceFile($fileId, $destination, $userId) {
-        $newFile = new stdClass();
         $c = new Criteria();
         $c->add(TblspacefilePeer::FILE_ID, $fileId);
@@ -165,8 +129,20 @@
         $tblfile->setFileDate(date('Y-m-d H:i:s'));
         $tblfile->save();
+        
+        $c = new Criteria();
+        $c->add(TblspaceresourcePeer::RES_ID, $currentFile->getFileResource());
+        $res = TblspaceresourcePeer::doSelectOne($c);
+   
+        $thumbnailUrl = file_exists("previews/$userId/".$tblfile->getFileId()."/0.png") ? "http://sbgapi.violet.vn/previews/$userId/".$tblfile->getFileId()."/0.png" : '';
+        
+        $newFile = new stdClass();        
         $newFile->id = $tblfile->getFileId();
         $newFile->name = $fileName;
         $newFile->parentID = $destination;
         $newFile->minetype = $currentFile->getFileType();
+        $newFile->fileurl = str_replace('/srv/www/violet/web', 'http://sbgapi.violet.vn', $res->getFullFilename());
+        $newFile->thumbnail = $thumbnailUrl;
+        $newFile->size = $res->getResFilesize();
+        
         return $newFile;
     }
@@ -366,24 +342,20 @@
         $act = $this->getRequestParameter('act');
         $data = $this->getRequestParameter('data');
-        $aryNewTree = array('DIRECTORIES' => array(), 'FILES' => array(),);
+        $aryNewTree = array('DIRECTORIES' => array(), 'FILES' => array());
         $aryTreeObj = json_decode($data);
         if (is_array($aryTreeObj)) {
-            foreach ($aryTreeObj as $key => $treeObj) {
-                if ($act == 'copy') {
-                    if ($treeObj->type == 'directory') {
-                        $this->CopySpaceDir($treeObj, $destination, $userId, $aryNewTree);
-                    } else {
-                        $aryNewTree['FILES'] = $this->CopySpaceFile($treeObj->id, $destination, $userId);
-                    }
-                } else if ($act == 'move') {
-                    $this->changeParentDir($treeObj, $destination);
-                    if ($treeObj->type == 'directory')
-                        $aryNewTree['DIRECTORIES'][] = $treeObj;
-                    if ($treeObj->type == 'file')
-                        $aryNewTree['FILES'][] = $treeObj;
-                }
-            }
-        }
-
+            foreach ($aryTreeObj as $key => $treeObj) {           	
+            	if ($act == 'copy') {
+            		if ($treeObj->type == 'directory'){
+            			$this->CopySpaceDir($treeObj, $destination, $userId, $aryNewTree);
+            		}
+            		else {
+            			$newFile = $this->CopySpaceFile($treeObj->id, $destination, $userId);
+            			$aryNewTree['FILES'][] = $newFile;
+            		}
+            	}
+            }
+        }
+        
         $this->errMsg = '';
         $this->errCode = '';
