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); } }
public HttpResponseMessage GetFolderDetails(int folderId) { var folder = FolderManager.Instance.GetFolder(folderId); if (!FolderPermissionController.CanManageFolder((FolderInfo)folder)) { return(this.Request.CreateResponse( HttpStatusCode.InternalServerError, new { message = LocalizationHelper.GetString("UserHasNoPermissionToManageFolder.Error") })); } var createdBy = folder.CreatedByUser(this.PortalSettings.PortalId); var lastModifiedBy = folder.LastModifiedByUser(this.PortalSettings.PortalId); return(this.Request.CreateResponse(HttpStatusCode.OK, new { folderId = folder.FolderID, folderName = folder.FolderName, createdOnDate = folder.CreatedOnDate.ToShortDateString(), createdBy = createdBy != null ? createdBy.Username : string.Empty, lastModifiedOnDate = folder.LastModifiedOnDate.ToShortDateString(), lastModifiedBy = lastModifiedBy != null ? lastModifiedBy.Username : string.Empty, type = FolderMappingController.Instance.GetFolderMapping(folder.FolderMappingID).MappingName, isVersioned = folder.IsVersioned, permissions = new FolderPermissions(true, folder.FolderPermissions), })); }
/// <inheritdoc/> public bool HasManagePermission(int moduleMode, int folderId) { if (!this.HasGroupFolderOwnerPermission(folderId)) { return(false); } if (moduleMode == (int)Constants.ModuleModes.User && !this.IsUserFolder(folderId)) { return(false); } var folder = this.folderManager.GetFolder(folderId); return(FolderPermissionController.CanManageFolder((FolderInfo)folder)); }
public HttpResponseMessage SaveFolderDetails(FolderDetailsRequest folderDetails) { var folder = FolderManager.Instance.GetFolder(folderDetails.FolderId); if (folder == null) { return(this.Request.CreateResponse(HttpStatusCode.NotFound, new { message = "Folder doesn't exist." })); } if (!FolderPermissionController.CanManageFolder((FolderInfo)folder)) { return(this.Request.CreateResponse( HttpStatusCode.InternalServerError, new { message = LocalizationHelper.GetString("UserHasNoPermissionToManageFolder.Error") })); } ItemsManager.Instance.SaveFolderDetails(folder, folderDetails); return(this.Request.CreateResponse(HttpStatusCode.OK, new { Status = 0 })); }
/// <summary> /// Get children folders of the specified parent. /// </summary> /// <param name="parent">Parent folder</param> /// <param name="isRoot">True if it's the root folder</param> /// <returns>List of folder</returns> private IEnumerable <FolderDTO> GetChildrenFolder(IFolderInfo parent, bool isRoot) { List <FolderDTO> children = null; if (parent.HasChildren) { children = new List <FolderDTO>(); IEnumerable <IFolderInfo> folders = FolderManager.Instance.GetFolders(parent); foreach (IFolderInfo folder in folders) { FolderInfo current = folder as FolderInfo; if (FolderPermissionController.CanBrowseFolder(current)) { if (current.IsProtected || current.FolderPath == "Cache/") { continue; } if (current.FolderPath == "Users/" && !IsAdmin) { continue; } FolderDTO child = new FolderDTO { Label = current.FolderName, Data = new FolderDataDTO { Path = current.FolderPath, CanManage = FolderPermissionController.CanManageFolder(current) }, Leaf = !current.HasChildren, Children = current.HasChildren ? new List <FolderDTO>() : null }; children.Add(child); } } if (isRoot) { // Add personal folder at the end for not admin users if (!IsAdmin) { DocumentSettings settings = new DocumentSettings(ActiveModule); if (settings.UserFolder) { FolderInfo userFolder = FolderManager.Instance.GetUserFolder(UserInfo) as FolderInfo; FolderDTO userChild = new FolderDTO { Label = LocalizeString("UserFolder"), Data = new FolderDataDTO { Path = userFolder.FolderPath, CanManage = FolderPermissionController.CanManageFolder(userFolder) }, Leaf = !userFolder.HasChildren, Children = userFolder.HasChildren ? new List <FolderDTO>() : null }; children.Add(userChild); } } List <FolderDTO> rootFolders = new List <FolderDTO>(); FolderDTO root = new FolderDTO { Label = LocalizeString("RootFolder"), Data = new FolderDataDTO { Path = "", CanManage = FolderPermissionController.CanManageFolder(parent as FolderInfo) }, Leaf = children.Count == 0, Expanded = true, Children = children }; rootFolders.Add(root); return(rootFolders); } } return(children); }