コード例 #1
0
        public ActionResult Create()
        {
            if (!Services.Authorizer.Authorize(Permissions.ManageOwnMedia, T("Couldn't create media folder")))
            {
                return(new HttpUnauthorizedResult());
            }

            var viewModel = new MediaManagerFolderCreateViewModel();

            UpdateModel(viewModel);

            if (!_mediaLibraryService.CanManageMediaFolder(viewModel.FolderPath))
            {
                return(new HttpUnauthorizedResult());
            }

            try {
                _mediaLibraryService.CreateFolder(viewModel.FolderPath, viewModel.Name);
                Services.Notifier.Information(T("Media folder created"));
            }
            catch (ArgumentException argumentException) {
                Services.Notifier.Error(T("Creating Folder failed: {0}", argumentException.Message));
                Services.TransactionManager.Cancel();
                return(View(viewModel));
            }

            return(RedirectToAction("Index", "Admin", new { area = "Tomelt.MediaLibrary" }));
        }
コード例 #2
0
        public ActionResult Create(string folderPath)
        {
            if (!Services.Authorizer.Authorize(Permissions.ManageMediaContent, T("Couldn't create media folder")))
            {
                return(new HttpUnauthorizedResult());
            }

            var viewModel = new MediaManagerFolderCreateViewModel {
                Hierarchy  = _mediaLibraryService.GetMediaFolders(folderPath, Services.WorkContext.CurrentUser),
                FolderPath = folderPath
            };

            return(View(viewModel));
        }
コード例 #3
0
        public ActionResult Create(string folderPath)
        {
            if (!Services.Authorizer.Authorize(Permissions.ManageOwnMedia, T("Couldn't create media folder")))
            {
                return(new HttpUnauthorizedResult());
            }

            // If the user is trying to access a folder above his boundaries, redirect him to his home folder
            var rootMediaFolder = _mediaLibraryService.GetRootMediaFolder();

            if (!Services.Authorizer.Authorize(Permissions.ManageMediaContent) && !_mediaLibraryService.CanManageMediaFolder(folderPath))
            {
                return(RedirectToAction("Create", new { folderPath = rootMediaFolder.MediaPath }));
            }

            var viewModel = new MediaManagerFolderCreateViewModel {
                Hierarchy  = _mediaLibraryService.GetMediaFolders(folderPath),
                FolderPath = folderPath
            };

            return(View(viewModel));
        }
コード例 #4
0
        public ActionResult Create(string folderPath)
        {
            if (!(_mediaLibraryService.CheckMediaFolderPermission(Permissions.ImportMediaContent, folderPath) || _mediaLibraryService.CheckMediaFolderPermission(Permissions.EditMediaContent, folderPath)))
            {
                Services.Notifier.Error(T("Couldn't create media folder"));
                return(RedirectToAction("Index", "Admin", new { area = "Orchard.MediaLibrary", folderPath = folderPath }));
            }

            // If the user is trying to access a folder above his boundaries, redirect him to his home folder
            var rootMediaFolder = _mediaLibraryService.GetRootMediaFolder();

            if (!_mediaLibraryService.CanManageMediaFolder(folderPath))
            {
                return(RedirectToAction("Create", new { folderPath = rootMediaFolder.MediaPath }));
            }

            var viewModel = new MediaManagerFolderCreateViewModel {
                Hierarchy  = _mediaLibraryService.GetMediaFolders(folderPath),
                FolderPath = folderPath
            };

            return(View(viewModel));
        }
コード例 #5
0
        public ActionResult Create()
        {
            if (!Services.Authorizer.Authorize(Permissions.ManageOwnMedia))
            {
                Services.Notifier.Error(T("Couldn't create media folder"));
                return(new HttpUnauthorizedResult());
            }

            var viewModel = new MediaManagerFolderCreateViewModel();

            UpdateModel(viewModel);

            if (!(_mediaLibraryService.CheckMediaFolderPermission(Permissions.ImportMediaContent, viewModel.FolderPath) ||
                  _mediaLibraryService.CheckMediaFolderPermission(Permissions.EditMediaContent, viewModel.FolderPath)))
            {
                return(new HttpUnauthorizedResult());
            }

            try {
                bool valid = String.IsNullOrWhiteSpace(viewModel.Name) || Regex.IsMatch(viewModel.Name, @"^[^:?#\[\]@!$&'()*+,.;=\s\""\<\>\\\|%]+$");
                if (!valid)
                {
                    throw new ArgumentException(T("Folder contains invalid characters").ToString());
                }
                else
                {
                    _mediaLibraryService.CreateFolder(viewModel.FolderPath, viewModel.Name);
                    Services.Notifier.Information(T("Media folder created"));
                }
            }
            catch (ArgumentException argumentException) {
                Services.Notifier.Error(T("Creating Folder failed: {0}", argumentException.Message));
                Services.TransactionManager.Cancel();
                return(View(viewModel));
            }
            return(RedirectToAction("Index", "Admin", new { area = "Orchard.MediaLibrary" }));
        }