public void UpdateForUpload(long idItem, Boolean allowUpload, List <dtoEditAssignment> assignments, Dictionary <AssignmentType, String> tTranslations, Dictionary <PermissionsTranslation, String> translations, Dictionary <ModuleRepository.Base2Permission, String> pTranslations) { if (!SessionTimeout()) { liteRepositoryItem rItem = Service.ItemGet(idItem); Int32 idCommunity = UserContext.CurrentCommunityID; ModuleRepository.ObjectType oType = ModuleRepository.ObjectType.File; ModuleRepository.ActionType uAction = ModuleRepository.ActionType.VersionUnableToAdd; View.AllowUpload = allowUpload; if (rItem != null) { ModuleRepository module = Service.GetPermissions(rItem.Repository, UserContext.CurrentUserID); idCommunity = rItem.Repository.IdCommunity; long permissions = (long)((rItem.AllowUpload) ? ModuleRepository.Base2Permission.DownloadOrPlay | ModuleRepository.Base2Permission.Upload : ModuleRepository.Base2Permission.DownloadOrPlay); assignments.Where(a => !a.Denyed && a.Permissions == 0).ToList().ForEach(a => a.Permissions = permissions); Boolean reloadItems = Service.AssignmentsAddToItem(idItem, assignments.Where(a => !a.IsDeleted).ToList(), false); View.HasPendingChanges = !reloadItems; uAction = (reloadItems ? ModuleRepository.ActionType.PermissionsSaved : ModuleRepository.ActionType.PermissionsNotSaved); if (reloadItems) { LoadAssignments(true, idItem, tTranslations, translations, pTranslations); } View.SendUserAction(idCommunity, Service.GetIdModule(), uAction, idItem, oType); } else { View.SendUserAction(idCommunity, Service.GetIdModule(), uAction, idItem, oType); } } }
public List <dtoModuleUploadedItem> AddFiles(String istanceIdentifier, Int32 idUploaderUser, Boolean allowAnonymousUpload, Boolean alwaysLastVersion, RepositoryIdentifier identifier, long idFolder, List <dtoUploadedItem> files, Object obj, long idObject, Int32 idObjectType, String moduleCode, Int32 idModuleAjaxAction, Int32 idModuleAction = 0) { List <dtoModuleUploadedItem> items = new List <dtoModuleUploadedItem>(); if (!SessionTimeout() || allowAnonymousUpload && idUploaderUser > 0) { litePerson person = Service.GetValidPerson(idUploaderUser); liteRepositorySettings settings = Service.SettingsGetByRepositoryIdentifier(identifier); ModuleRepository module = Service.GetPermissions(identifier, idUploaderUser); ModuleRepository.ObjectType oType = ModuleRepository.ObjectType.File; ModuleRepository.ActionType uAction = ModuleRepository.ActionType.UnableToAddFile; liteRepositoryItem item = (idFolder > 0 ? Service.ItemGet(idFolder) : null); if (person == null || (item == null && idFolder > 0)) { View.DisplayError(ItemUploadError.UnableToAddFileToUnknownFolder); uAction = ModuleRepository.ActionType.UnknownItemFound; InitializeView(idFolder, identifier, module, settings, CurrentManager.GetLitePerson(idUploaderUser)); } else { Boolean allowAdd = module.Administration || module.ManageItems || module.UploadFile; dtoDisplayRepositoryItem dItem = Service.GetItemWithPermissions(idFolder, UserContext.CurrentUserID, identifier, View.GetUnknownUserName()); if (dItem != null) { oType = ModuleRepository.GetObjectType(dItem.Type); allowAdd = allowAdd || dItem.Permissions.GetActions().Contains(ItemAction.upload); } else if (idFolder == 0) { oType = ModuleRepository.ObjectType.Folder; } String folderName = (idFolder == 0 ? View.GetRootFolderName() : dItem.Name); if (!allowAdd) { View.DisplayError(ItemUploadError.MissingPermissionsToAddFile, folderName, "", ItemType.Folder); uAction = ModuleRepository.ActionType.UnavailableItem; } else { Boolean executed = false; items = Service.FileAddToRepository(settings, istanceIdentifier, identifier, person, alwaysLastVersion, module, View.GetRepositoryDiskPath(), idFolder, files, obj, idObject, idObjectType, moduleCode, idModuleAjaxAction, idModuleAction); executed = (items != null && items.Any(a => a.IsAdded)); uAction = (executed ? (items.Any(a => !a.IsAdded) ? ModuleRepository.ActionType.UnableToAddSomeFile : ModuleRepository.ActionType.AddFile) : ModuleRepository.ActionType.UnableToAddFile); if (executed) { View.NotifyAddedItems(Service.GetIdModule(), idFolder, folderName, RootObject.RepositoryItems(identifier.Type, identifier.IdCommunity, -1, (dItem == null ? 0 : dItem.Id)), items.Where(a => a.ItemAdded != null).Select(f => f.ItemAdded).ToList()); } else { View.DisplayError(ItemUploadError.UnableToAddFile, folderName, (items == null) ? null : items.Where(a => !a.IsAdded).Select(a => a.UploadedFile).ToList()); } } } View.SendUserAction(identifier.IdCommunity, Service.GetIdModule(), uAction, idFolder, oType); } return(items); }
public void TryToSave(long idItem, List <dtoEditAssignment> assignments, Dictionary <AssignmentType, String> tTranslations, Dictionary <PermissionsTranslation, String> translations, Dictionary <ModuleRepository.Base2Permission, String> pTranslations) { if (!SessionTimeout()) { liteRepositoryItem rItem = Service.ItemGet(idItem); Int32 idCommunity = UserContext.CurrentCommunityID; ModuleRepository.ObjectType oType = ModuleRepository.ObjectType.File; ModuleRepository.ActionType uAction = ModuleRepository.ActionType.VersionUnableToAdd; if (rItem != null) { ModuleRepository module = Service.GetPermissions(rItem.Repository, UserContext.CurrentUserID); idCommunity = rItem.Repository.IdCommunity; dtoDisplayRepositoryItem dItem = Service.GetItemWithPermissions(idItem, UserContext.CurrentUserID, rItem.Repository, View.GetUnknownUserName()); if (dItem == null) { View.DisplayUserMessage(UserMessageType.detailsNoPermissionToSave); oType = ModuleRepository.GetObjectType(rItem.Type); uAction = ModuleRepository.ActionType.UnknownItemFound; } else if (rItem.Type == ItemType.Folder) { View.AskUserForApply(rItem.DisplayName); } else { SaveAssignments(idItem, assignments, false, tTranslations, translations, pTranslations); } } else { View.SendUserAction(idCommunity, Service.GetIdModule(), uAction, idItem, oType); } } }
public void Save(long idItem, long idVersion, long idSettings, EvaluationType evaluation, List <dtoScormItemEvaluationSettings> items) { if (!SessionTimeout()) { ModuleRepository.ActionType uAction = ModuleRepository.ActionType.ScormSettingsUnableToSave; Int32 idCommunity = View.RepositoryIdCommunity; liteRepositoryItemVersion version = Service.ItemGetVersion(idItem, idVersion); if (version == null) { uAction = ModuleRepository.ActionType.ScormSettingsLoaded; View.DisplayUnknownItem(); View.AllowSave = false; } else { ScormPackageSettings settings = Service.ScormPackageSettingsSave(idItem, idVersion, idSettings, evaluation, items); if (settings == null) { uAction = ModuleRepository.ActionType.ScormSettingsUnableToSave; View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.scormSettingsUnableToSave, version.Availability); } else { View.IdSettings = settings.Id; View.LoadSettings(version.UniqueIdVersion.ToString(), version.DisplayName, dtoScormPackageSettings.CreateFrom(settings, version), false, false); uAction = ModuleRepository.ActionType.ScormSettingsSaved; View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.scormSettingsSaved, version.Availability); } } View.SendUserAction(idCommunity, Service.GetIdModule(), uAction); } }
public Boolean SaveItem(long idItem, String description, String name, String url, DisplayMode?mode, Boolean isVisible, Boolean allowUpload, List <String> tags) { Boolean executed = false; if (SessionTimeout()) { View.DisplaySessionTimeout(); } else { ModuleRepository.ObjectType oType = ModuleRepository.ObjectType.File; ModuleRepository.ActionType uAction = ModuleRepository.ActionType.GenericError; Int32 idCommunity = UserContext.CurrentCommunityID; liteRepositoryItem item = Service.ItemGet(idItem); if (item == null) { View.DisplayUnknownItem(ItemAction.edit); uAction = ModuleRepository.ActionType.UnknownItemFound; } else { idCommunity = item.Repository.IdCommunity; Int32 idCurrentUser = UserContext.CurrentUserID; oType = ModuleRepository.GetObjectType(item.Type); ItemSaving saving = Service.ItemSetBaseSettings(idItem, description, name, url, mode, isVisible, allowUpload, tags); if (saving == ItemSaving.None) { View.DisplayUnavailableItem(ItemAction.edit); uAction = ModuleRepository.ActionType.UnavailableItem; } else { executed = (saving == ItemSaving.Saved); View.DisplayUpdateMessage(saving); switch (saving) { case ItemSaving.Saved: uAction = ModuleRepository.ActionType.ItemSavedDetails; View.UpdateDefaultTags(ServiceTags.GetAvailableTags(idCurrentUser, idCommunity, Service.GetIdModule(), ModuleRepository.UniqueCode)); break; case ItemSaving.None: uAction = ModuleRepository.ActionType.ItemTryToSaveDetails; break; default: uAction = ModuleRepository.ActionType.ItemSavedSomeDetails; break; } } } View.SendUserAction(idCommunity, Service.GetIdModule(), uAction, idItem, oType); } return(executed); }
public void SaveAssignments(long idItem, List <dtoEditAssignment> assignments, Boolean applyToContent, Dictionary <AssignmentType, String> tTranslations, Dictionary <PermissionsTranslation, String> translations, Dictionary <ModuleRepository.Base2Permission, String> pTranslations) { if (!SessionTimeout()) { liteRepositoryItem rItem = Service.ItemGet(idItem); Int32 idCommunity = UserContext.CurrentCommunityID; ModuleRepository.ObjectType oType = ModuleRepository.ObjectType.File; ModuleRepository.ActionType uAction = ModuleRepository.ActionType.VersionUnableToAdd; if (rItem != null) { oType = ModuleRepository.GetObjectType(rItem.Type); ModuleRepository module = Service.GetPermissions(rItem.Repository, UserContext.CurrentUserID); Boolean reloadItems = false; idCommunity = rItem.Repository.IdCommunity; dtoDisplayRepositoryItem dItem = Service.GetItemWithPermissions(idItem, UserContext.CurrentUserID, rItem.Repository, View.GetUnknownUserName()); if (dItem == null) { View.DisplayUserMessage(UserMessageType.detailsNoPermissionToSave); uAction = ModuleRepository.ActionType.UnknownItemFound; } else { oType = ModuleRepository.GetObjectType(dItem.Type); applyToContent = applyToContent && dItem.Type == ItemType.Folder; if (!dItem.Permissions.EditPermission) { View.DisplayUserMessage(UserMessageType.permissionsNoPermissionToSave); uAction = ModuleRepository.ActionType.UnavailableItem; } else if (!assignments.Any(a => !a.Denyed)) { View.DisplayUserMessage(UserMessageType.permissionsNoItemToSave); uAction = ModuleRepository.ActionType.PermissionsNothingToSave; } else { long permissions = (long)((rItem.AllowUpload) ? ModuleRepository.Base2Permission.DownloadOrPlay | ModuleRepository.Base2Permission.Upload : ModuleRepository.Base2Permission.DownloadOrPlay); assignments.Where(a => !a.Denyed && a.Permissions == 0).ToList().ForEach(a => a.Permissions = permissions); reloadItems = Service.AssignmentsAddToItem(idItem, assignments.Where(a => !a.IsDeleted).ToList(), applyToContent); View.HasPendingChanges = !reloadItems; uAction = (reloadItems ? ModuleRepository.ActionType.PermissionsSaved : ModuleRepository.ActionType.PermissionsNotSaved); View.DisplayUserMessage((reloadItems? UserMessageType.permissionsSaved : UserMessageType.permissionsUnableToSave)); } } if (reloadItems) { InitializeSelectors(dItem); LoadAssignments(true, dItem.Id, tTranslations, translations, pTranslations); } } View.SendUserAction(idCommunity, Service.GetIdModule(), uAction, idItem, oType); } }
public void ExecuteAction(long idItem, long idVersion, ItemAction action, String unknownUser, String repositoryPath, String thumnailPath) { if (!SessionTimeout()) { Boolean reloadItems = false; Int32 idCommunity = UserContext.CurrentCommunityID; ModuleRepository.ActionType uAction = ModuleRepository.ActionType.GenericError; liteRepositoryItemVersion version = Service.VersionGet(idVersion); if (version == null) { View.DisplayUserMessage(UserMessageType.versionItemNotFound); uAction = ModuleRepository.ActionType.UnknownItemFound; } else { liteRepositoryItem item = Service.ItemGet(version.IdItem); if (item != null) { String path = repositoryPath; switch (item.Repository.Type) { case RepositoryType.Portal: path += "\\0"; break; case RepositoryType.Community: path += "\\" + item.Repository.IdCommunity.ToString(); break; } Boolean executed = false; switch (action) { case ItemAction.addVersion: RepositoryItemVersion vr = Service.VersionSetActive(idVersion); reloadItems = (vr != null && vr.IsActive); if (reloadItems) { View.CurrentVersionUpdated(); } View.DisplayUserMessage((reloadItems ? UserMessageType.versionPromoted : UserMessageType.versionNotPromoted)); uAction = (reloadItems) ? ModuleRepository.ActionType.VersionSetAsActive : ModuleRepository.ActionType.VersionUnableToSetAsActive; break; } if (reloadItems) { LoadVersions(item, unknownUser, repositoryPath); } } } View.SendUserAction(idCommunity, Service.GetIdModule(), uAction, idVersion, ModuleRepository.ObjectType.VersionItem); } }
public void SetDefaultDocument(long idItem, long idVersion, long idDocument) { if (!SessionTimeout()) { ModuleRepository.ActionType uAction = ModuleRepository.ActionType.MultimedaSettingsUnableToSetDefaultDocument; Int32 idCommunity = View.RepositoryIdCommunity; liteRepositoryItemVersion version = Service.ItemGetVersion(idItem, idVersion); if (version == null) { View.DisplayUnknownItem(); View.AllowSave = false; } else { dtoMultimediaFileObject obj = Service.MultimediaGetItem(idDocument); if (obj == null) { View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.multimediaSettingsDocumentNotFound); } else { MultimediaFileObject file = Service.MultimediaSetDefaultItem(idItem, idVersion, idDocument); if (file == null || !file.IsDefaultDocument) { uAction = ModuleRepository.ActionType.MultimedaSettingsUnableToSetDefaultDocument; View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.multimediaSettingsUnableToSave, version.Availability, obj.Fullname); } else { List <dtoMultimediaFileObject> items = Service.MultimediaGetItems(idItem, idVersion); View.AllowSave = (items != null); View.LoadItems(version.UniqueIdVersion.ToString(), version.DisplayName, items, (items == null ? null : items.Where(i => i.IsDefaultDocument).FirstOrDefault())); uAction = ModuleRepository.ActionType.MultimedaSettingsSetDefaultDocument; View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.multimediaSettingsSaved, version.Availability, obj.Fullname); } } } View.SendUserAction(idCommunity, Service.GetIdModule(), uAction); } }
public void InitView(long idLink, long idItem, long idVersion, long idFolder, String path, Boolean setBackUrl, String backUrl) { RepositoryIdentifier rIdentifier = Service.ItemGetRepositoryIdentifier(idItem); Int32 idCommunity = UserContext.CurrentCommunityID; View.IdItem = idItem; View.IdVersion = idVersion; View.IdLink = idLink; View.IdCurrentFolder = idFolder; View.CurrentFolderIdentifierPath = path; if (setBackUrl && String.IsNullOrEmpty(backUrl)) { backUrl = View.GetPreviousRelativeUrl(); if (!IsValidPreviousUrl(backUrl)) { backUrl = ""; setBackUrl = false; } if (backUrl.StartsWith(RootObject.BaseRepositoryUrl(), StringComparison.InvariantCultureIgnoreCase) && rIdentifier != null) { cookieRepository cookie = View.GetRepositoryCookie(rIdentifier); if (cookie != null) { backUrl = RootObject.RepositoryItems(rIdentifier.Type, rIdentifier.IdCommunity, 0, cookie.IdFolder, cookie.Type, cookie.ItemsOrderBy, cookie.Ascending, cookie.IdentifierPath); } } SetLogoutUrl(View.GetCurrentUrl(), setBackUrl, backUrl); } else { View.DefaultLogoutUrl = View.GetCurrentUrl(); } View.BackUrl = (setBackUrl ? backUrl : ""); View.SetPageBackUrl(backUrl); View.PageIdentifier = Guid.NewGuid(); if (SessionTimeout()) { return; } View.IsInitialized = true; ModuleRepository.ActionType uAction = ModuleRepository.ActionType.None; if (rIdentifier == null) { uAction = ModuleRepository.ActionType.MultimedaSettingsTryToLoad; View.DisplayUnknownItem(); } else { Int32 idCurrentUser = UserContext.CurrentUserID; liteRepositoryItem item = Service.ItemGet(idItem); liteRepositoryItemVersion version = Service.ItemGetVersion(idItem, idVersion); if (version == null) { uAction = ModuleRepository.ActionType.MultimedaSettingsTryToLoad; View.DisplayUnknownItem(); } else if (version.Type != ItemType.Multimedia) { idCommunity = version.IdCommunity; View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.multimediaSettingsInvalidType); uAction = ModuleRepository.ActionType.MultimedaSettingsInvalidType; } else { idVersion = version.Id; View.IdVersion = idVersion; idCommunity = version.IdCommunity; if (version.Availability == ItemAvailability.available || version.Availability == ItemAvailability.waitingsettings) { ItemPermission permissions = null; if (idLink == 0) { dtoDisplayRepositoryItem dto = Service.GetItemWithPermissions(idItem, idCurrentUser, item.Repository, View.GetUnknownUserName()); if (dto != null) { permissions = dto.Permissions; } } else { liteModuleLink link = CurrentManager.Get <liteModuleLink>(idLink); if (link == null) { View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.multimediaSettingsNoPermission); } else { permissions = View.GetLinkPermissions(link, idCurrentUser); idCommunity = link.SourceItem.CommunityID; } } if (permissions != null) { if (permissions.EditSettings) { if (version.Availability == ItemAvailability.waitingsettings) { View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.multimediaSettingsNoDefaultDocument); } List <dtoMultimediaFileObject> items = Service.MultimediaGetItems(idItem, idVersion); View.AllowSave = (items != null && items.Any()); View.LoadItems(item.UniqueIdVersion.ToString(), item.DisplayName, items, (items == null ? null : items.Where(i => i.IsDefaultDocument).FirstOrDefault())); } else { uAction = ModuleRepository.ActionType.MultimedaSettingsNoPermissions; View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.multimediaSettingsNoPermission); } } else { uAction = ModuleRepository.ActionType.MultimedaSettingsStatusError; View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.multimediaSettingsInvalidStatus, version.Availability); } } else { uAction = ModuleRepository.ActionType.MultimedaSettingsStatusError; View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.multimediaSettingsInvalidStatus, version.Availability); } } View.RepositoryIdentifier = CacheKeys.RepositoryIdentifierKey(rIdentifier.Type, rIdentifier.IdCommunity); View.RepositoryIdCommunity = rIdentifier.IdCommunity; View.RepositoryType = rIdentifier.Type; View.IsInitialized = true; } View.SendUserAction(idCommunity, Service.GetIdModule(), uAction); }
public void InitView(Boolean isEditPage, long idItem, long idFolder, String path, Boolean setBackUrl, String backUrl) { RepositoryIdentifier rIdentifier = Service.ItemGetRepositoryIdentifier(idItem); Int32 idCommunity = UserContext.CurrentCommunityID; View.IdItem = idItem; View.IdCurrentFolder = idFolder; View.CurrentFolderIdentifierPath = path; if (setBackUrl && String.IsNullOrEmpty(backUrl)) { backUrl = View.GetPreviousRelativeUrl(); if (!IsValidPreviousUrl(backUrl)) { backUrl = ""; setBackUrl = false; } if (backUrl.StartsWith(RootObject.BaseRepositoryUrl(), StringComparison.InvariantCultureIgnoreCase) && rIdentifier != null) { cookieRepository cookie = View.GetRepositoryCookie(rIdentifier); if (cookie != null) { backUrl = RootObject.RepositoryItems(rIdentifier.Type, rIdentifier.IdCommunity, 0, cookie.IdFolder, cookie.Type, cookie.ItemsOrderBy, cookie.Ascending, cookie.IdentifierPath); } } SetLogoutUrl(isEditPage, View.GetCurrentUrl(), setBackUrl, backUrl); } else { View.DefaultLogoutUrl = View.GetCurrentUrl(); } View.BackUrl = (setBackUrl ? backUrl : ""); View.SetPageBackUrl(backUrl); View.PageIdentifier = Guid.NewGuid(); if (SessionTimeout()) { return; } View.IsInitialized = true; ModuleRepository.ActionType uAction = ModuleRepository.ActionType.None; if (rIdentifier == null) { View.InitializeHeader(); uAction = (isEditPage) ? ModuleRepository.ActionType.EditDetailsTryToLoad : ModuleRepository.ActionType.ViewDetailsTryToLoad; View.DisplayUnknownItem(); } else { Int32 idCurrentUser = UserContext.CurrentUserID; liteRepositorySettings settings = Service.SettingsGetByRepositoryIdentifier(rIdentifier); ModuleRepository module = Service.GetPermissions(rIdentifier, idCurrentUser); View.RepositoryIdentifier = CacheKeys.RepositoryIdentifierKey(rIdentifier.Type, rIdentifier.IdCommunity); View.RepositoryIdCommunity = rIdentifier.IdCommunity; idCommunity = rIdentifier.IdCommunity; View.RepositoryType = rIdentifier.Type; View.SetTitle(Service.ItemGetType(idItem)); View.IsInitialized = true; if (settings != null) { Boolean admin = module.ManageItems || module.Administration; dtoDisplayRepositoryItem dto = Service.GetItemWithPermissionsAndStatistics(idItem, Service.GetAvailableRepositoryItems(settings, UserContext.CurrentUserID, rIdentifier.Type, rIdentifier.IdCommunity, View.GetUnknownUserName(), View.GetFolderTypeTranslation(), View.GetTypesTranslations(), module, admin, admin), UserContext.CurrentUserID); if (dto != null) { if (!isEditPage && dto.Permissions.Edit) { View.SetUrlForEdit(RootObject.EditItem(idItem, idFolder, path, ItemAction.edit, (!String.IsNullOrWhiteSpace(backUrl)), backUrl)); } else if (isEditPage) { View.SetUrlForView(RootObject.Details(idItem, idFolder, path, ItemAction.edit, (!String.IsNullOrWhiteSpace(backUrl)), backUrl)); } if (!isEditPage || (isEditPage && dto.Permissions.Edit)) { View.AllowSave = dto.Permissions.Edit && isEditPage; View.AllowHideItem = dto.Permissions.Hide && isEditPage; View.AllowShowItem = dto.Permissions.Show && isEditPage; View.DisplayItemDetails(isEditPage, dto, settings.AutoThumbnailWidth, settings.AutoThumbnailHeight, settings.AutoThumbnailForExtension); if (dto.Permissions.ViewPermission || dto.Permissions.EditPermission) { View.DisplayItemPermissions(isEditPage, dto); } if (isEditPage) { View.InitializeDefaultTags(ServiceTags.GetAvailableTags(rIdentifier.IdPerson, idCommunity, CurrentIdModule, ModuleRepository.UniqueCode)); } else { View.InitializeHeader(); } uAction = (isEditPage) ? ModuleRepository.ActionType.EditDetailsLoaded : ModuleRepository.ActionType.ViewDetailsLoaded; } else if (isEditPage) { View.SendUserAction(idCommunity, Service.GetIdModule(), ModuleRepository.ActionType.EditDetailsTryToLoad); View.GoToUrl(RootObject.Details(idItem, idFolder, path, ItemAction.details, setBackUrl, backUrl)); } } else { if (isEditPage) { View.SetUrlForView(RootObject.Details(idItem, idFolder, path, ItemAction.edit, (!String.IsNullOrWhiteSpace(backUrl)), backUrl)); } View.InitializeHeader(); View.DisplayNoPermission(idCommunity, Service.GetIdModule()); uAction = (isEditPage) ? ModuleRepository.ActionType.EditDetailsNoPermissions : ModuleRepository.ActionType.ViewDetailsNoPermissions; } } else { View.InitializeHeader(); uAction = (isEditPage) ? ModuleRepository.ActionType.EditDetailsTryToLoad : ModuleRepository.ActionType.ViewDetailsTryToLoad; View.DisplayUnknownItem(); } } View.SendUserAction(idCommunity, Service.GetIdModule(), uAction); }
public Boolean ExecuteAction(long idItem, ItemAction action) { Boolean executed = false; Int32 idCommunity = UserContext.CurrentCommunityID; Boolean reloadItems = true; ModuleRepository.ObjectType oType = ModuleRepository.ObjectType.File; ModuleRepository.ActionType uAction = ModuleRepository.ActionType.GenericError; if (SessionTimeout()) { return(executed); } liteRepositoryItem item = Service.ItemGet(idItem); if (item == null) { View.DisplayUnknownItem(action); uAction = ModuleRepository.ActionType.UnknownItemFound; } else { idCommunity = item.Repository.IdCommunity; oType = ModuleRepository.GetObjectType(item.Type); switch (action) { case ItemAction.hide: case ItemAction.show: liteRepositoryItem rItem = Service.ItemSetVisibility(idItem, (action == ItemAction.show), item.Repository.Type, item.Repository.IdCommunity); if (rItem == null) { View.DisplayUnavailableItem(action); uAction = ModuleRepository.ActionType.UnavailableItem; } else { executed = (rItem.IsVisible == (action == ItemAction.show)); View.DisplayUpdateMessage(action, executed, rItem.DisplayName, rItem.Extension, rItem.Type); String folderName = (rItem.IdFolder == 0 ? View.GetRootFolderFullname() : Service.FolderGetName(rItem.IdFolder)); View.NotifyVisibilityChanged(Service.GetIdModule(), rItem.IdFolder, folderName, RootObject.RepositoryItems(rItem.Repository.Type, rItem.Repository.IdCommunity, rItem.Id, rItem.IdFolder), rItem); if (executed) { switch (item.Type) { case ItemType.Folder: if (action == ItemAction.show) { uAction = ModuleRepository.ActionType.ShowFolder; } else { uAction = ModuleRepository.ActionType.HideFolder; } break; default: if (action == ItemAction.show) { uAction = ModuleRepository.ActionType.ShowItem; } else { uAction = ModuleRepository.ActionType.HideItem; } break; } reloadItems = executed; } else { if (action == ItemAction.show) { uAction = ModuleRepository.ActionType.UnableToShow; } else { uAction = ModuleRepository.ActionType.UnableToHide; } } } break; } } View.SendUserAction(idCommunity, Service.GetIdModule(), uAction, idItem, oType); return(executed); }
public void AddVersionToFile(String istanceIdentifier, long idItem, dtoUploadedItem version, String unknownUser, String repositoryPath) { if (!SessionTimeout()) { liteRepositoryItem rItem = Service.ItemGet(idItem); Int32 idCommunity = UserContext.CurrentCommunityID; ModuleRepository.ObjectType oType = ModuleRepository.ObjectType.File; ModuleRepository.ActionType uAction = ModuleRepository.ActionType.VersionUnableToAdd; if (rItem != null) { ModuleRepository module = Service.GetPermissions(rItem.Repository, UserContext.CurrentUserID); Boolean reloadItems = false; idCommunity = rItem.Repository.IdCommunity; dtoDisplayRepositoryItem dItem = Service.GetItemWithPermissions(idItem, UserContext.CurrentUserID, rItem.Repository, View.GetUnknownUserName()); if (dItem == null) { View.DisplayUserMessage(UserMessageType.versionItemNoPermission); uAction = ModuleRepository.ActionType.UnknownItemFound; } else { Boolean allowAdd = dItem.Permissions.GetActions().Contains(ItemAction.addVersion); oType = ModuleRepository.GetObjectType(dItem.Type); if (!allowAdd) { View.DisplayUserMessage(UserMessageType.versionItemNoPermission); uAction = ModuleRepository.ActionType.UnavailableItem; } else { liteRepositorySettings settings = Service.SettingsGetByRepositoryIdentifier(rItem.Repository); Service.ThumbnailsCreate(settings, dItem.UniqueId, version); dtoCreatedItem addedVersion = Service.FileAddVersion(settings, module, repositoryPath, istanceIdentifier, idItem, version); reloadItems = (addedVersion != null && addedVersion.IsAdded); uAction = (reloadItems ? ModuleRepository.ActionType.VersionAddedToFile : ModuleRepository.ActionType.VersionUnableToAdd); if (reloadItems) { View.DisplayUserMessage(UserMessageType.versionAdded); dItem.IdVersion = addedVersion.Added.Id; dItem.UniqueIdVersion = addedVersion.Added.UniqueIdVersion; dItem.Thumbnail = addedVersion.Added.Thumbnail; dItem.AutoThumbnail = addedVersion.Added.AutoThumbnail; View.CurrentVersionUpdated(dItem, settings.AutoThumbnailWidth, settings.AutoThumbnailHeight, settings.AutoThumbnailForExtension); String folderName = (dItem.IdFolder == 0 ? View.GetRootFolderFullname() : Service.FolderGetName(dItem.IdFolder)); View.NotifyAddedVersion(Service.GetIdModule(), dItem.IdFolder, folderName, RootObject.RepositoryItems(dItem.Repository.Type, dItem.Repository.IdCommunity, dItem.Id, dItem.IdFolder), addedVersion); } else { View.DisplayUserMessage(UserMessageType.versionNotAdded); } } } if (reloadItems) { LoadVersions(true, dItem, unknownUser, repositoryPath); } } View.SendUserAction(idCommunity, Service.GetIdModule(), uAction, idItem, oType); } }
public void InitView(long idSettings, long idLink, long idItem, long idVersion) { RepositoryIdentifier rIdentifier = Service.ItemGetRepositoryIdentifier(idItem); Int32 idCommunity = UserContext.CurrentCommunityID; View.IdItem = idItem; View.IdVersion = idVersion; View.IdLink = idLink; View.PageIdentifier = Guid.NewGuid(); if (SessionTimeout()) { return; } View.IsInitialized = true; ModuleRepository.ActionType uAction = ModuleRepository.ActionType.None; if (rIdentifier == null) { uAction = ModuleRepository.ActionType.ScormSettingsTryToLoad; View.DisplayUnknownItem(); } else { Int32 idCurrentUser = UserContext.CurrentUserID; liteRepositoryItem item = Service.ItemGet(idItem); liteRepositoryItemVersion version = Service.ItemGetVersion(idItem, idVersion); if (version == null) { uAction = ModuleRepository.ActionType.ScormSettingsTryToLoad; View.DisplayUnknownItem(); } else if (version.Type != ItemType.ScormPackage) { idCommunity = version.IdCommunity; View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.scormSettingsInvalidType); uAction = ModuleRepository.ActionType.ScormSettingsInvalidType; } else { idVersion = version.Id; View.IdVersion = idVersion; idCommunity = version.IdCommunity; if (version.Availability == ItemAvailability.available || version.Availability == ItemAvailability.waitingsettings) { ItemPermission permissions = null; if (idLink == 0) { dtoDisplayRepositoryItem dto = Service.GetItemWithPermissions(idItem, idCurrentUser, item.Repository, View.GetUnknownUserName()); if (dto != null) { permissions = dto.Permissions; } } else { liteModuleLink link = CurrentManager.Get <liteModuleLink>(idLink); if (link == null) { View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.scormSettingsNoPermission); } else { permissions = View.GetLinkPermissions(link, idCurrentUser); idCommunity = link.SourceItem.CommunityID; } } if (permissions != null && (permissions.Edit || permissions.EditSettings || permissions.ViewMyStatistics || permissions.ViewOtherStatistics)) { uAction = ModuleRepository.ActionType.ScormSettingsView; if (version.Availability == ItemAvailability.waitingsettings) { View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.scormSettingsWaitingToSet); } dtoScormPackageSettings settings = Service.ScormPackageGetDtoCompletionSettings(idItem, idVersion, idSettings); if (settings == null) { View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.scormSettingsNotFound); } else { View.IdSettings = settings.Id; View.LoadSettings(item.UniqueIdVersion.ToString(), item.DisplayName, settings, true, true); } } else { uAction = ModuleRepository.ActionType.ScormSettingsNoPermissions; View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.scormSettingsNoPermission); } } else { uAction = ModuleRepository.ActionType.ScormSettingsStatusError; View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.scormSettingsInvalidStatus, version.Availability); } } View.RepositoryIdentifier = CacheKeys.RepositoryIdentifierKey(rIdentifier.Type, rIdentifier.IdCommunity); View.RepositoryIdCommunity = rIdentifier.IdCommunity; View.RepositoryType = rIdentifier.Type; View.IsInitialized = true; } View.SendUserAction(idCommunity, Service.GetIdModule(), uAction); }