public void EditUrl(long idAttachmentLink, long idAttachment, String unknownUser) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { Boolean reloadItems = true; Boolean isPersonal = View.isPersonal; Int32 idCommunity = View.ProjectIdCommunity; Boolean isPortal = View.forPortal; long idProject = View.IdProject; Person p = CurrentManager.GetPerson(UserContext.CurrentUserID); ModuleProjectManagement mPermission = (isPortal) ? ModuleProjectManagement.CreatePortalmodule((p == null) ? (Int32)UserTypeStandard.Guest : p.TypeID) : new ModuleProjectManagement(CurrentManager.GetModulePermission(UserContext.CurrentUserID, idCommunity, CurrentIdModule)); PmActivityPermission pPermissions = Service.GetProjectPermission(idProject, UserContext.CurrentUserID); Boolean allowSave = (mPermission.Administration && !isPersonal) || ((pPermissions & PmActivityPermission.ManageProject) == PmActivityPermission.ManageProject); if (allowSave) { dtoAttachment attachment = Service.AttachmentGetByIdLink(idAttachmentLink, unknownUser); if (attachment != null && attachment.Type == AttachmentType.url) { View.DisplayUrlForEditing(new dtoUrl() { Id = attachment.IdAttachment, Address = attachment.Url, Name = attachment.DisplayName }); reloadItems = false; } else { View.SendUserAction(idCommunity, CurrentIdModule, idProject, idAttachment, ModuleProjectManagement.ActionType.ProjectAttachmentsUrlUnknown); View.DisplayUrlRemoved(); } } else { View.SendUserAction(idCommunity, CurrentIdModule, idProject, idAttachment, ModuleProjectManagement.ActionType.ProjectAttachmentsNoPermissionToEditUrl); View.DisplayNoPermissionToEditUrl(); } if (reloadItems) { LoadAttachments(unknownUser, idProject, isPersonal, idCommunity, mPermission, pPermissions, allowSave, ModuleProjectManagement.ActionType.ProjectAttachmentsReload); } } }
public dtoAttachment AttachmentGetByIdLink(long idAttachmentLink, String unknownUser) { dtoAttachment attachment = null; try { ProjectAttachmentLink l = Manager.Get <ProjectAttachmentLink>(idAttachmentLink); if (l != null && l.Attachment != null) { List <Int32> idUsers = new List <int>(); idUsers.Add(l.Attachment.IdCreatedBy); idUsers.Add(l.Attachment.IdModifiedBy); attachment = new dtoAttachment(l, GetUsers(idUsers, unknownUser), unknownUser); } } catch (Exception ex) { } return(attachment); }
private dtoAttachmentPermission AttachmentGetPermissions(litePerson person, dtoAttachment attachment, PmActivity activity, PmActivityPermission rolePermissions, ModuleProjectManagement mPermission, ModuleRepository repositoryPermissions) { dtoAttachmentPermission result = new dtoAttachmentPermission(); switch (attachment.Type) { case AttachmentType.file: result.Download = (attachment.File != null && (attachment.File.IsDownloadable || attachment.File.Type == ItemType.Link)) && (HasPermission(rolePermissions, PmActivityPermission.ViewAttachments) || HasPermission(rolePermissions, PmActivityPermission.DownloadAttacchments)); result.Play = (attachment.File != null && (attachment.File.Type == ItemType.Multimedia || attachment.File.Type == ItemType.ScormPackage || attachment.File.Type == ItemType.VideoStreaming)) && (HasPermission(rolePermissions, PmActivityPermission.ViewAttachments) || HasPermission(rolePermissions, PmActivityPermission.DownloadAttacchments)); switch (attachment.File.Type) { case ItemType.ScormPackage: case ItemType.Multimedia: result.ViewMyStatistics = HasPermission(rolePermissions, PmActivityPermission.ViewAttachments); if (attachment.File.IsInternal || (repositoryPermissions.Administration || (repositoryPermissions.EditOthersFiles || (repositoryPermissions.EditMyFiles && attachment.File.IdOwner == person.Id)))) { result.ViewOtherStatistics = HasPermission(rolePermissions, PmActivityPermission.ManageAttachments) || (HasPermission(rolePermissions, PmActivityPermission.ManageActivityAttachments) && attachment.IdCreatedBy == person.Id); result.SetMetadata = result.ViewOtherStatistics; } break; case ItemType.Link: result.Play = result.Download; break; } result.Edit = false; break; case AttachmentType.url: result.Download = HasPermission(rolePermissions, PmActivityPermission.ViewAttachments) || HasPermission(rolePermissions, PmActivityPermission.DownloadAttacchments); result.Play = result.Download; result.Edit = HasPermission(rolePermissions, PmActivityPermission.ManageAttachments) || (HasPermission(rolePermissions, PmActivityPermission.ManageActivityAttachments) && attachment.IdCreatedBy == person.Id); break; } result.Delete = false; result.UnDelete = (attachment.Deleted != BaseStatusDeleted.None) && (HasPermission(rolePermissions, PmActivityPermission.VirtualUnDeleteAttachments) || (HasPermission(rolePermissions, PmActivityPermission.ManageActivityAttachments) && attachment.IdCreatedBy == person.Id)); result.Unlink = (attachment.InSharing && attachment.Deleted == BaseStatusDeleted.None) && (HasPermission(rolePermissions, PmActivityPermission.VirtualDeleteAttachments) || HasPermission(rolePermissions, PmActivityPermission.ManageAttachments) || (HasPermission(rolePermissions, PmActivityPermission.ManageActivityAttachments) && attachment.CreatedBy != null && attachment.IdCreatedBy == person.Id)); result.VirtualDelete = (attachment.Deleted == BaseStatusDeleted.None) && (HasPermission(rolePermissions, PmActivityPermission.VirtualDeleteAttachments) || HasPermission(rolePermissions, PmActivityPermission.ManageAttachments) || (HasPermission(rolePermissions, PmActivityPermission.ManageActivityAttachments) && attachment.IdCreatedBy == person.Id)); return(result); }
private dtoAttachmentPermission AttachmentGetPermissions(litePerson person, dtoAttachment attachment, CoreItemPermission permissions, lm.Comol.Core.FileRepository.Domain.ModuleRepository moduleRepository) { dtoAttachmentPermission result = new dtoAttachmentPermission(); if (attachment.File != null) { Boolean fileRepositoryOwner = (moduleRepository.Administration || (moduleRepository.EditOthersFiles || (moduleRepository.EditMyFiles && attachment.File.IdOwner == person.Id))); result.Download = (attachment.File != null && (attachment.File.IsDownloadable || attachment.File.Type == FileRepository.Domain.ItemType.Link)) && permissions.AllowViewFiles; result.Play = (attachment.File != null && (attachment.File.Type == FileRepository.Domain.ItemType.Multimedia || attachment.File.Type == FileRepository.Domain.ItemType.ScormPackage || attachment.File.Type == FileRepository.Domain.ItemType.VideoStreaming)) && permissions.AllowViewFiles; result.EditVisibility = permissions.AllowEdit; switch (attachment.File.Type) { case FileRepository.Domain.ItemType.Multimedia: case FileRepository.Domain.ItemType.ScormPackage: result.ViewMyStatistics = permissions.AllowViewStatistics; result.SetMetadata = permissions.AllowEdit && (attachment.File.IsInternal || fileRepositoryOwner); result.ViewOtherStatistics = permissions.AllowEdit && (attachment.File.IsInternal || fileRepositoryOwner); break; case FileRepository.Domain.ItemType.Link: result.Play = result.Download; break; } result.Edit = false; result.EditRepositoryVisibility = permissions.AllowEdit && fileRepositoryOwner && !attachment.File.IsInternal; result.EditRepositoryPermission = permissions.AllowEdit && fileRepositoryOwner && !attachment.File.IsInternal; result.Delete = attachment.File.IsInternal && permissions.AllowDelete && (attachment.Deleted != BaseStatusDeleted.None);; result.UnDelete = attachment.File.IsInternal && (attachment.Deleted != BaseStatusDeleted.None) && (permissions.AllowUnDelete); result.VirtualDelete = attachment.File.IsInternal && (attachment.Deleted == BaseStatusDeleted.None) && permissions.AllowUnDelete; result.Unlink = (!attachment.File.IsInternal && permissions.AllowAddFiles); result.Publish = permissions.AllowFilePublish && attachment.File.IsInternal && attachment.Deleted == BaseStatusDeleted.None; } return(result); }