11 use Symfony\Component\HttpFoundation\Request;
12 use Symfony\Component\HttpFoundation\Response;
16 const NAME =
'content_move';
21 function __construct()
23 parent::__construct(self::NAME, array(
24 self::TITLE => _(
"Move upload or folder"),
25 self::MENU_LIST =>
"Organize::Folders::Move or Copy",
27 self::REQUIRES_LOGIN => TRUE
29 $this->folderDao = $this->
getObject(
'dao.folder');
34 parent::RegisterMenus();
36 menu_insert(
"Main::Organize::Uploads::Move or Copy", 0, $this->name, $this->name);
44 protected function handle(Request $request)
46 $userId = Auth::getUserId();
49 $folderContentIds = $request->get(
'foldercontent', array());
50 $parentFolderId = intval($request->get(
'toFolder'));
51 $isCopyRequest = $request->get(
'copy');
53 $vars[
'message'] = $this->
performAction($folderContentIds, $parentFolderId, $isCopyRequest);
55 $rootFolderId = $this->folderDao->getRootFolder($userId)->getId();
57 $uiFolderNav = $this->
getObject(
'ui.folder.nav');
58 $vars[
'folderTree'] = $uiFolderNav->showFolderTree($rootFolderId);
59 $vars[
'folderStructure'] = $this->folderDao->getFolderStructure($rootFolderId);
60 return $this->
render(
'admin_content_move.html.twig', $this->mergeWithDefault($vars));
70 private function performAction($folderContentIds, $parentFolderId, $isCopyRequest)
73 for ($i = 0; $i <
sizeof($folderContentIds); $i++) {
74 $folderContentId = intval($folderContentIds[$i]);
75 if ($folderContentId && $parentFolderId && $isCopyRequest) {
77 $this->folderDao->copyContent($folderContentId, $parentFolderId);
78 }
catch (Exception $ex) {
79 $message .= $ex->getMessage();
81 } elseif ($folderContentId && $parentFolderId) {
83 $this->folderDao->moveContent($folderContentId, $parentFolderId);
84 }
catch (Exception $ex) {
85 $message .= $ex->getMessage();
100 public function copyContent($uploadIds, $parentFolderId, $isCopyRequest)
102 return $this->
performAction($uploadIds, $parentFolderId, $isCopyRequest);
RegisterMenus()
Customize submenus.
copyContent($uploadIds, $parentFolderId, $isCopyRequest)
performAction($folderContentIds, $parentFolderId, $isCopyRequest)
Contains the constants and helpers for authentication of user.
render($templateName, $vars=null, $headers=null)
#define PERM_WRITE
Read-Write permission.