Ejemplo n.º 1
0
        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);
                }
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
                }
            }
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        public VersionErrors AddVersionToFile(String istanceIdentifier, long idItem, dtoUploadedItem version, String unknownUser, String repositoryPath, RepositoryIdentifier identifier, Boolean allowManage, Boolean allowView, Boolean updateLinks)
        {
            VersionErrors      error = VersionErrors.unabletoadd;
            liteRepositoryItem rItem = ItemGet(idItem);

            ModuleRepository.ObjectType oType = ModuleRepository.ObjectType.File;
            dtoDisplayRepositoryItem    dItem = null;

            if (rItem != null)
            {
                ModuleRepository module      = GetPermissions(rItem.Repository, UC.CurrentUserID);
                Boolean          allowCreate = false;
                Int32            idCommunity = rItem.Repository.IdCommunity;
                if (rItem.IsInternal)
                {
                    allowCreate = true;
                }
                else
                {
                    dItem = GetItemWithPermissions(idItem, UC.CurrentUserID, rItem.Repository, unknownUser, allowManage, allowView);
                    if (dItem == null)
                    {
                        error = VersionErrors.unavailableItem;
                    }
                    else
                    {
                        Boolean allowAdd = dItem.Permissions.GetActions().Contains(ItemAction.addVersion);
                        oType = ModuleRepository.GetObjectType(dItem.Type);
                        if (!allowAdd)
                        {
                            error = VersionErrors.nopermission;
                        }
                        else
                        {
                            allowCreate = true;
                        }
                    }
                }
                if (allowCreate)
                {
                    liteRepositorySettings settings = SettingsGetByRepositoryIdentifier(rItem.Repository);
                    ThumbnailsCreate(settings, rItem.UniqueId, version);
                    dtoCreatedItem addedVersion = FileAddVersion(settings, module, repositoryPath, istanceIdentifier, idItem, version);

                    if (addedVersion != null && addedVersion.IsAdded)
                    {
                        if (dItem != null)
                        {
                            dItem.IdVersion       = addedVersion.Added.IdVersion;
                            dItem.UniqueIdVersion = addedVersion.Added.UniqueIdVersion;
                        }
                        if (updateLinks)
                        {
                            List <liteModuleLink> links = (from l in GetQuery <liteModuleLink>()
                                                           where
                                                           l.DestinationItem.ServiceCode == ModuleRepository.UniqueCode &&
                                                           l.DestinationItem.ObjectLongID == idItem &&
                                                           l.DestinationItem.ObjectIdVersion > 0
                                                           select l).ToList();
                            if (links.Any())
                            {
                                links.ForEach(l => l.DestinationItem.ObjectIdVersion = addedVersion.Added.IdVersion);
                                Manager.SaveOrUpdateList(links);
                            }
                        }
                        error = VersionErrors.none;
                    }
                    else
                    {
                        error = VersionErrors.unabletoadd;
                    }
                }
            }
            return(error);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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);
            }
        }