27 const NAME =
'content_move';
32 function __construct()
34 parent::__construct(self::NAME, array(
35 self::TITLE => _(
"Move upload or folder"),
36 self::MENU_LIST =>
"Organize::Folders::Move or Copy",
38 self::REQUIRES_LOGIN => TRUE
40 $this->folderDao = $this->
getObject(
'dao.folder');
43 protected function RegisterMenus()
45 parent::RegisterMenus();
47 menu_insert(
"Main::Organize::Uploads::Move or Copy", 0, $this->name, $this->name);
55 protected function handle(Request $request)
57 $userId = Auth::getUserId();
60 $folderContentIds = $request->get(
'foldercontent', array());
61 $parentFolderId = intval($request->get(
'toFolder'));
62 $isCopyRequest = $request->get(
'copy');
64 $vars[
'message'] = $this->
performAction($folderContentIds, $parentFolderId, $isCopyRequest);
66 $rootFolderId = $this->folderDao->getRootFolder($userId)->getId();
68 $uiFolderNav = $this->
getObject(
'ui.folder.nav');
69 $vars[
'folderTree'] = $uiFolderNav->showFolderTree($rootFolderId);
70 $vars[
'folderStructure'] = $this->folderDao->getFolderStructure($rootFolderId);
71 return $this->
render(
'admin_content_move.html.twig', $this->mergeWithDefault($vars));
81 private function performAction($folderContentIds, $parentFolderId, $isCopyRequest)
84 for ($i = 0; $i <
sizeof($folderContentIds); $i++) {
85 $folderContentId = intval($folderContentIds[$i]);
86 if ($folderContentId && $parentFolderId && $isCopyRequest) {
88 $this->folderDao->copyContent($folderContentId, $parentFolderId);
89 }
catch (Exception $ex) {
90 $message .= $ex->getMessage();
92 } elseif ($folderContentId && $parentFolderId) {
94 $this->folderDao->moveContent($folderContentId, $parentFolderId);
95 }
catch (Exception $ex) {
96 $message .= $ex->getMessage();
111 public function copyContent($uploadIds, $parentFolderId, $isCopyRequest)
113 return $this->
performAction($uploadIds, $parentFolderId, $isCopyRequest);
performAction($folderContentIds, $parentFolderId, $isCopyRequest)
render($templateName, $vars=null, $headers=null)
copyContent($uploadIds, $parentFolderId, $isCopyRequest)
#define PERM_WRITE
Read-Write permission.