Esempio n. 1
0
 /**
  * @param Request $request
  * @return Response
  */
 protected function handle(Request $request)
 {
     $userId = Auth::getUserId();
     $vars = array();
     $folderContentId = intval($request->get('foldercontent'));
     $parentFolderId = intval($request->get('toFolder'));
     if ($folderContentId && $parentFolderId && $request->get('copy')) {
         try {
             $this->folderDao->copyContent($folderContentId, $parentFolderId);
         } catch (Exception $ex) {
             $vars['message'] = $ex->getMessage();
         }
     } elseif ($folderContentId && $parentFolderId) {
         try {
             $this->folderDao->moveContent($folderContentId, $parentFolderId);
         } catch (Exception $ex) {
             $vars['message'] = $ex->getMessage();
         }
     }
     $rootFolderId = $this->folderDao->getRootFolder($userId)->getId();
     /* @var $uiFolderNav FolderNav */
     $uiFolderNav = $this->getObject('ui.folder.nav');
     $vars['folderTree'] = $uiFolderNav->showFolderTree($rootFolderId);
     $vars['folderStructure'] = $this->folderDao->getFolderStructure($rootFolderId);
     return $this->render('admin_content_move.html.twig', $this->mergeWithDefault($vars));
 }
Esempio n. 2
0
 public function testCopyContent()
 {
     $this->folderDao->ensureTopLevelFolder();
     $folderA = $this->folderDao->insertFolder($folderName = 'A', '/A', FolderDao::TOP_LEVEL);
     $folderB = $this->folderDao->insertFolder($folderName = 'B', '/A/B', $folderA);
     $this->folderDao->insertFolder($folderName = 'C', '/C', FolderDao::TOP_LEVEL);
     $fc = $this->dbManager->getSingleRow('SELECT foldercontents_pk FROM foldercontents WHERE child_id=$1', array($folderB), __METHOD__ . '.needs.the.foldercontent_pk');
     $this->folderDao->copyContent($fc['foldercontents_pk'], FolderDao::TOP_LEVEL);
     assertThat($this->folderDao->getFolderChildFolders($folderA), is(arrayWithSize(1)));
     assertThat($this->folderDao->getFolderChildFolders(FolderDao::TOP_LEVEL), is(arrayWithSize(3)));
 }