Ignore:
Timestamp:
Sep 19, 2014 4:18:09 PM (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

    r137 r138  
    133133    $tblfile->setFileType($currentFile->getFileType());
    134134    $tblfile->setFileDate(date('Y-m-d H:i:s'));
    135     $tblfile->save();   
     135    $tblfile->save();
    136136    $newFile->id = $tblfile->getFileId();
    137137    $newFile->name = $fileName;
     
    139139    $newFile->minetype = $currentFile->getFileType();
    140140    return $newFile;
     141  }
     142 
     143  private function changeParentDir ($item, $destination) {
     144        if ($item->type == 'directory') {
     145                $tblfile = TblspacefilePeer::retrieveByPk($item->id);
     146                $tblfile->setFileCategory($destination);
     147                $tblfile->save();
     148        }
     149        else if ($item->type == 'file') {
     150                $tblCategory = TblspacecategoryPeer::retrieveByPk($item->id);
     151                $tblCategory->setCatParent($destination);
     152                $tblCategory->save();
     153        }
     154       
     155        $item->parentID = $destination;
     156        return $item;
    141157  }
    142158
     
    282298  public function executeCopy () {
    283299    $userId = $this->getRequestParameter('userid');
    284     $destination = $this->getRequestParameter('destination');
     300    $destination = $this->getRequestParameter('destination');
     301    $act = $this->getRequestParameter('act');
    285302    $data = $this->getRequestParameter('data');
    286303        $aryNewTree = array('DIRECTORIES' => array(),'FILES' => array(), );
     
    289306    if (is_array($aryTreeObj)) {
    290307        foreach ($aryTreeObj as $key => $treeObj){;
    291                 if ($treeObj->type == 'directory') {
    292                         $this->CopySpaceDir($treeObj, $destination, $userId, $aryNewTree);
     308                if ($act == 'copy') {
     309                        if ($treeObj->type == 'directory') {
     310                                $this->CopySpaceDir($treeObj, $destination, $userId, $aryNewTree);
     311                        }
     312                        else {
     313                                $aryNewTree['FILES'] = $this->CopySpaceFile($treeObj->id, $destination, $userId);
     314                        }
    293315                }
    294                 else {
    295                         $aryNewTree['FILES'] = $this->CopySpaceFile($treeObj->id, $destination, $userId);
     316                else if ($act == 'move') {
     317                        $this->changeParentDir($treeObj, $destination);
     318                        if ($treeObj->type == 'directory') $aryNewTree['DIRECTORIES'][];
     319                        if ($treeObj->type == 'file') $aryNewTree['FILES'][];
    296320                }
    297321        }
Note: See TracChangeset for help on using the changeset viewer.