List <StandardActionType> GetAllowedActionsForRepository(PermissionEP permission, long idItem, int idUser, int IdCommunity) { List <StandardActionType> actions = new List <StandardActionType>(); lm.Comol.Core.FileRepository.Domain.ModuleRepository moduleRepository = GetCoreModuleRepository(idUser, IdCommunity); lm.Comol.Core.FileRepository.Domain.liteRepositoryItem item = Manager.Get <lm.Comol.Core.FileRepository.Domain.liteRepositoryItem>(idItem); if (item != null) { Boolean isPlayFile = (item.Type == Core.FileRepository.Domain.ItemType.ScormPackage || item.Type == Core.FileRepository.Domain.ItemType.Multimedia || item.Type == Core.FileRepository.Domain.ItemType.VideoStreaming); if (!isPlayFile) { if (typeof(CommunityFile) == item.GetType()) { if ((moduleRepository.DownloadOrPlay && item.IsDownloadable) || moduleRepository.Administration || moduleRepository.ManageItems || moduleRepository.EditOthersFiles || (moduleRepository.UploadFile && (item.IdOwner == idUser))) { actions.Add(StandardActionType.DownloadItem); } if (moduleRepository.Administration || moduleRepository.EditOthersFiles || moduleRepository.ManageItems || (moduleRepository.UploadFile && item.IdOwner == idUser)) { actions.Add(StandardActionType.EditPermission); } } else { if (item.IsDownloadable) { actions.Add(StandardActionType.DownloadItem); } } } else { if (typeof(CommunityFile) == item.GetType()) { if ((moduleRepository.DownloadOrPlay && item.IsDownloadable) || moduleRepository.Administration || moduleRepository.ManageItems || moduleRepository.EditOthersFiles || (moduleRepository.UploadFile && (item.IdOwner == idUser))) { actions.Add(StandardActionType.EditMetadata); } actions.Add(StandardActionType.DownloadItem); if (permission.ViewUserStat) { actions.Remove(StandardActionType.ViewAdvancedStatistics); actions.Remove(StandardActionType.ViewUserStatistics); } if (permission.ViewOwnStat) { actions.Add(StandardActionType.ViewUserStatistics); } } else if (moduleRepository.DownloadOrPlay && item.IsDownloadable) { if (permission.Read) { actions.Add(StandardActionType.DownloadItem); } if (permission.ViewOwnStat) { actions.Add(StandardActionType.ViewPersonalStatistics); } } else { if (permission.Create || permission.Update) { actions.Add(StandardActionType.EditMetadata); } if (item.IsDownloadable) { actions.Add(StandardActionType.DownloadItem); } if (permission.ViewUserStat) { actions.Add(StandardActionType.ViewAdvancedStatistics); actions.Add(StandardActionType.ViewUserStatistics); } if (permission.ViewOwnStat) { actions.Remove(StandardActionType.ViewUserStatistics); } } } } return(actions.Distinct().ToList()); }
public List <StandardActionType> GetAllowedStandardAction(ModuleObject source, ModuleObject destination, int idUser, int idRole, int idCommunity, Dictionary <string, long> moduleUserLong = null, Dictionary <string, string> moduleUserString = null) { List <StandardActionType> actions = new List <StandardActionType>(); if (source.ServiceCode == "SRVEDUP") { PermissionEP permission = new PermissionEP(RoleEP.None); switch (source.ObjectTypeID) { case (int)ItemType.Path: permission = GetUserPermission_ByPath(source.ObjectLongID, idUser, idRole); break; case (int)ItemType.Unit: permission = GetUserPermission_ByUnit(source.ObjectLongID, idUser, idRole); break; case (int)ItemType.Activity: permission = GetUserPermission_ByActivity(source.ObjectLongID, idUser, idRole); break; case (int)ItemType.SubActivity: SubActivity sub = GetSubActivity(source.ObjectLongID); if (sub != null) { permission = GetUserPermission_ByActivity(sub.ParentActivity.Id, idUser, idRole); } break; } if (permission.ViewOwnStat) { actions.Add(StandardActionType.ViewPersonalStatistics); } if (permission.ViewUserStat) { actions.Add(StandardActionType.ViewUserStatistics); } if (permission.ViewUserStat || permission.Create || permission.Update) { actions.Add(StandardActionType.ViewAdvancedStatistics); } if (permission.Create) { actions.Add(StandardActionType.Create); } if (permission.Create || permission.Update) { actions.Add(StandardActionType.Edit); } switch (destination.ServiceCode) { case CoreModuleRepository.UniqueID: actions = GetAllowedStandardActionForRepository(permission, actions, destination.ObjectLongID, idUser, idCommunity); break; } } // Boolean isMultimedia = (eventItemFile.File.RepositoryItemType != RepositoryItemType.FileStandard && eventItemFile.File.RepositoryItemType != RepositoryItemType.Folder && eventItemFile.File.RepositoryItemType != RepositoryItemType.None); //รจ multimediale e posso actions.Add(StandardActionType.EditMetadata) //actions.Add(StandardActionType.EditMetadata) // actions.Add(StandardActionType.Play); // actions.Add(StandardActionType.ViewPersonalStatistics); // actions.Add(StandardActionType.ViewAdvancedStatistics); return(actions); }