예제 #1
0
        protected override void OnLoad(EventArgs e)
        {
            try
            {
                if (!this.Page.IsPostBack)
                {
                    this.SetupPermissionGrid();
                    this.PrepareFolderProperties();
                    this.SetPropertiesAvailability(FolderPermissionController.CanManageFolder((FolderInfo)this.Folder));
                }

                if (!FolderPermissionController.CanViewFolder((FolderInfo)this.Folder))
                {
                    this.SaveButton.Visible = false;
                    this.SetPropertiesVisibility(false);
                    UI.Skins.Skin.AddModuleMessage(this, this.LocalizeString("UserCannotReadFolderError"), ModuleMessage.ModuleMessageType.RedError);
                }
                else
                {
                    this.SaveButton.Visible = FolderPermissionController.CanViewFolder((FolderInfo)this.Folder) && FolderPermissionController.CanManageFolder((FolderInfo)this.Folder);
                }
            }
            catch (DotNetNukeException dnnex)
            {
                UI.Skins.Skin.AddModuleMessage(this, dnnex.Message, ModuleMessage.ModuleMessageType.RedError);
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
        bool CanView(string url)
        {
            switch (Globals.GetURLType(url))
            {
            case TabType.File:
                if (url.IndexOf("fileid=", StringComparison.InvariantCultureIgnoreCase) >= 0)
                {
                    var file = FileManager.Instance.GetFile(int.Parse(url.Split('=') [1]));
                    if (file != null)
                    {
                        var folder = FolderManager.Instance.GetFolder(file.FolderId);
                        if (folder != null && FolderPermissionController.CanViewFolder((FolderInfo)folder))
                        {
                            return(true);
                        }
                    }
                }
                break;

            case TabType.Tab:
                var tab = TabController.Instance.GetTab(int.Parse(url), PortalId);
                if (tab != null && TabPermissionController.CanViewPage(tab))
                {
                    return(true);
                }
                break;

            default:
                return(true);
            }

            return(false);
        }
예제 #3
0
        public HttpResponseMessage GetFileDetails(int fileId)
        {
            var file = FileManager.Instance.GetFile(fileId);

            if (file == null)
            {
                return(this.Request.CreateResponse(HttpStatusCode.NotFound, new { }));
            }

            var folder = FolderManager.Instance.GetFolder(file.FolderId);

            if (!FolderPermissionController.CanViewFolder((FolderInfo)folder))
            {
                return(this.Request.CreateResponse(
                           HttpStatusCode.InternalServerError,
                           new { message = LocalizationHelper.GetString("UserHasNoPermissionToReadFileProperties.Error") }));
            }

            var createdBy      = file.CreatedByUser(this.PortalSettings.PortalId);
            var lastModifiedBy = file.LastModifiedByUser(this.PortalSettings.PortalId);

            return(this.Request.CreateResponse(HttpStatusCode.OK, new
            {
                fileId = file.FileId,
                fileName = file.FileName,
                title = file.Title,
                description = file.Description ?? string.Empty,
                size = string.Format(new FileSizeFormatProvider(), "{0:fs}", file.Size),
                createdOnDate = file.CreatedOnDate.ToShortDateString(),
                createdBy = createdBy != null ? createdBy.Username : string.Empty,
                lastModifiedOnDate = file.LastModifiedOnDate.ToShortDateString(),
                lastModifiedBy = lastModifiedBy != null ? lastModifiedBy.Username : string.Empty,
                url = FileManager.Instance.GetUrl(file),
            }));
        }
예제 #4
0
        private bool CanUserViewFile(IFileInfo file)
        {
            if (file == null)
            {
                return(false);
            }
            var folder = (FolderInfo)FolderManager.Instance.GetFolder(file.FolderId);

            return(FolderPermissionController.CanViewFolder(folder));
        }
예제 #5
0
        private IEnumerable <IFolderInfo> GetChildFolders(int folderID)
        {
            var parentFolder = FolderManager.Instance.GetFolder(folderID);
            var folders      = FolderManager.Instance.GetFolders(parentFolder);

            var viewableFolders = new List <FolderInfo>();

            foreach (FolderInfo folder in folders)
            {
                if (FolderPermissionController.CanViewFolder(folder) == true)
                {
                    viewableFolders.Add(folder);
                }
            }
            return(viewableFolders);
        }
        public virtual bool CanViewFilesInFolder(FolderInfo dnnFolder)
        {
            if ((dnnFolder == null))
            {
                return(false);
            }

            if (!(CanViewFolder(dnnFolder)))
            {
                return(false);
            }

            if (!(FolderPermissionController.CanViewFolder(dnnFolder)))
            {
                return(false);
            }

            return(true);
        }
        public static PathPermissions TelerikPermissions(IFolderInfo folder)
        {
            var folderPermissions = PathPermissions.Read;

            if (FolderPermissionController.CanViewFolder((FolderInfo)folder))
            {
                if (FolderPermissionController.CanAddFolder((FolderInfo)folder))
                {
                    folderPermissions = folderPermissions | PathPermissions.Upload;
                }

                if (FolderPermissionController.CanDeleteFolder((FolderInfo)folder))
                {
                    folderPermissions = folderPermissions | PathPermissions.Delete;
                }
            }

            return(folderPermissions);
        }
예제 #8
0
        public object GetFileByPath(string relativePath)
        {
            var dnnDynamicCode = new DnnDynamicCode().Init(GetBlock(), Log);
            var portal         = dnnDynamicCode.Dnn.Portal;

            relativePath = relativePath.Replace(portal.HomeDirectory, "");
            var file = FileManager.Instance.GetFile(portal.PortalId, relativePath);

            if (file == null)
            {
                return(null);
            }
            var folder = (FolderInfo)FolderManager.Instance.GetFolder(file.FolderId);

            return(FolderPermissionController.CanViewFolder(folder)
                ? new
            {
                file.FileId
            }
                : null);
        }
예제 #9
0
        protected override void OnInit(EventArgs e)
        {
            try
            {
                base.OnInit(e);

                JavaScript.RequestRegistration(CommonJs.DnnPlugins);

                var fileId = Convert.ToInt32(Request.Params["FileId"]);
                file     = FileManager.Instance.GetFile(fileId, true);
                fileItem = controller.GetFile(fileId);
                folder   = FolderManager.Instance.GetFolder(file.FolderId);

                SaveButton.Click   += OnSaveClick;
                CancelButton.Click += OnCancelClick;

                if (FolderPermissionController.CanViewFolder((FolderInfo)folder))
                {
                    var mef = new ExtensionPointManager();
                    var preViewPanelExtension = mef.GetUserControlExtensionPointFirstByPriority("DigitalAssets", "PreviewInfoPanelExtensionPoint");
                    previewPanelControl = Page.LoadControl(preViewPanelExtension.UserControlSrc);
                    PreviewPanelContainer.Controls.Add(previewPanelControl);

                    var fileFieldsExtension = mef.GetUserControlExtensionPointFirstByPriority("DigitalAssets", "FileFieldsControlExtensionPoint");
                    fileFieldsControl    = Page.LoadControl(fileFieldsExtension.UserControlSrc);
                    fileFieldsControl.ID = fileFieldsControl.GetType().BaseType.Name;
                    FileFieldsContainer.Controls.Add(fileFieldsControl);

                    PrepareFilePreviewInfoControl();
                    PrepareFileFieldsControl();

                    // Tab Extension Point
                    var tabContentControlsInstances = new List <PropertiesTabContentControl>();
                    foreach (var extension in mef.GetEditPageTabExtensionPoints("DigitalAssets", "FilePropertiesTab"))
                    {
                        if (FolderPermissionController.HasFolderPermission(folder.FolderPermissions, extension.Permission))
                        {
                            var liElement = new HtmlGenericControl("li")
                            {
                                InnerHtml = "<a href=\"#" + extension.EditPageTabId + "\">" + extension.Text + "</a>",
                            };
                            liElement.Attributes.Add("class", extension.CssClass);
                            liElement.Attributes.Add("id", extension.EditPageTabId + "_tab");
                            Tabs.Controls.Add(liElement);

                            var container = new PanelTabExtensionControl {
                                PanelId = extension.EditPageTabId
                            };
                            var control = (PortalModuleBase)Page.LoadControl(extension.UserControlSrc);
                            control.ID = Path.GetFileNameWithoutExtension(extension.UserControlSrc);
                            control.ModuleConfiguration = ModuleConfiguration;
                            var contentControl = control as PropertiesTabContentControl;
                            if (contentControl != null)
                            {
                                contentControl.OnItemUpdated += OnItemUpdated;
                                tabContentControlsInstances.Add(contentControl);
                            }
                            container.Controls.Add(control);
                            TabsPanel.Controls.Add(container);
                        }
                    }
                    tabContentControls = tabContentControlsInstances.ToList();
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
 public bool CanViewFolder(IFolderInfo folder)
 {
     return(FolderPermissionController.CanViewFolder((FolderInfo)folder));
 }