Ignore:
Timestamp:
Sep 11, 2014 11:28:50 AM (11 years ago)
Author:
dungnv
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pro-bachkim-filespace/sourcecode/api.violet.vn/www/apps/platform/modules/space/actions/actions.class.php

    r73 r75  
    7979  }
    8080
    81   private function CopySpaceDir ($dirObj, $destination, $userId) {
    82     $dirId = $dirObj->id;
    83     $dirName = $dirObj->name;
    84     $aryChidlDirs = $dirObj->childs;
    85     $aryChidlFiles = $dirObj->files;
    86 
     81  private function CopySpaceDir ($sourceObj, $destination, $userId, &$aryNewTree) {
     82    $dirId = $sourceObj->id;
    8783    $c = new Criteria();
    8884    $c->add(TblspacecategoryPeer::CAT_ID, $dirId);
    8985    $c->add(TblspacecategoryPeer::CAT_USER, $userId);
    90     $thisCat = TblspacecategoryPeer::doSelectOne($c);
    91     var_dump($thisCat);
     86    $currentCat = TblspacecategoryPeer::doSelectOne($c);
     87    $newDir =  $this->CreateSpaceDir($currentCat->getCatName(), $destination, $userId);
     88    $aryNewTree['DIRECTORIES'][] = $newDir;
     89
     90    if (isset($sourceObj->files)) {
     91      $aryChidlFiles = $sourceObj->files;
     92      foreach ($aryChidlFiles as $key => $file) {
     93        $aryNewTree['FILES'][] = $this->CopySpaceFile();
     94      }
     95    }
     96
     97    if (isset($sourceObj->childs)) {
     98      $aryChidlDirs = $sourceObj->childs;
     99      foreach ($aryChidlDirs as $key => $dir) {
     100        $this->CopySpaceDir($dir, $newDir, $userId, $aryNewTree);
     101      }
     102    }
     103  }
     104
     105  private function CopySpaceFile ($fileId, $destination, $userid) {
     106    $c = new Criteria();
     107    $c->add(TblspacefilePeer::FILE_ID, $dirId);
     108    $c->add(TblspacefilePeer::FILE_USER, $userId);
     109    $currentFile = TblspacefilePeer::doSelectOne($c);
     110
     111    $tblfile = new Tblspacefile();
     112    $tblfile->setFileResource($currentFile);
     113    $tblfile->setFileCategory($destination);
     114    $tblfile->setFileUser($userId);
     115    $tblfile->setFileName($currentFile->getFileName());
     116    $tblfile->setFileDate(date('Y-m-d H:i:s'));
     117    $tblfile->save();
     118    return $tblfile->getFileId();
    92119  }
    93120
     
    172199        $c->add(TblspacefilePeer::FILE_ID, $id);
    173200        $c->add(TblspacefilePeer::FILE_USER, $userId);
    174         $tblfile = TblspacefilePeer::doSelectOne($c);
     201        $tblfile = TblspacefilePeer::doSelectOne($c);
    175202        if ($tblfile) $tblfile->delete();
    176203        break;
     
    235262    $destination = $this->getRequestParameter('destination');
    236263    $data = $this->getRequestParameter('data');
    237 
    238     $treeObj = json_decode($data);
    239 
    240     $this->CopySpaceDir($treeObj[0], $destination, $userId);
    241 
     264        $aryNewTree = array();
     265    $aryTreeObj = json_decode($data);
     266
     267    if (is_array($aryTreeObj)) {
     268        foreach ($aryTreeObj as $key => $treeObj){
     269                $this->CopySpaceDir($treeObj, $destination, $userId, $aryNewTree);
     270        }
     271    }
     272   
     273    $this->aryNewTree = $aryNewTree;
     274   
    242275  }
    243276
Note: See TracChangeset for help on using the changeset viewer.