Files: added archive folder
This commit is contained in:
parent
597baeb510
commit
858d93366d
@ -167,9 +167,5 @@
|
||||
<DependentUpon>FilesUCResource.resx</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="ApiModels\RequestDto\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -422,6 +422,8 @@ public class FileStorageService<T> //: IFileStorageService
|
||||
var parent = await folderDao.GetFolderAsync(parentId);
|
||||
ErrorIf(parent == null, FilesCommonResource.ErrorMassage_FolderNotFound);
|
||||
ErrorIf(!await _fileSecurity.CanCreateAsync(parent), FilesCommonResource.ErrorMassage_SecurityException_Create);
|
||||
ErrorIf(parent.RootFolderType == FolderType.Archive, FilesCommonResource.ErrorMessage_UpdateArchivedRoom);
|
||||
ErrorIf(parent.FolderType == FolderType.Archive, FilesCommonResource.ErrorMassage_SecurityException);
|
||||
|
||||
try
|
||||
{
|
||||
@ -449,17 +451,18 @@ public class FileStorageService<T> //: IFileStorageService
|
||||
var folder = await folderDao.GetFolderAsync(folderId);
|
||||
ErrorIf(folder == null, FilesCommonResource.ErrorMassage_FolderNotFound);
|
||||
|
||||
var canRename = (folder.FolderType == FolderType.FillingFormsRoom || folder.FolderType == FolderType.EditingRoom
|
||||
var canEdit = (folder.FolderType == FolderType.FillingFormsRoom || folder.FolderType == FolderType.EditingRoom
|
||||
|| folder.FolderType == FolderType.ReviewRoom || folder.FolderType == FolderType.ReadOnlyRoom || folder.FolderType == FolderType.CustomRoom)
|
||||
? await _fileSecurity.CanEditRoomAsync(folder) : await _fileSecurity.CanRenameAsync(folder);
|
||||
? await _fileSecurity.CanEditRoomAsync(folder) : await _fileSecurity.CanEditAsync(folder);
|
||||
|
||||
ErrorIf(!canRename, FilesCommonResource.ErrorMassage_SecurityException_RenameFolder);
|
||||
if (!canRename && _userManager.GetUsers(_authContext.CurrentAccount.ID).IsVisitor(_userManager))
|
||||
ErrorIf(!canEdit, FilesCommonResource.ErrorMassage_SecurityException_RenameFolder);
|
||||
if (!canEdit && _userManager.GetUsers(_authContext.CurrentAccount.ID).IsVisitor(_userManager))
|
||||
{
|
||||
throw new SecurityException(FilesCommonResource.ErrorMassage_SecurityException_RenameFolder);
|
||||
}
|
||||
|
||||
ErrorIf(folder.RootFolderType == FolderType.TRASH, FilesCommonResource.ErrorMassage_ViewTrashItem);
|
||||
ErrorIf(folder.RootFolderType == FolderType.Archive, FilesCommonResource.ErrorMessage_UpdateArchivedRoom);
|
||||
|
||||
var folderAccess = folder.Access;
|
||||
|
||||
@ -604,7 +607,9 @@ public class FileStorageService<T> //: IFileStorageService
|
||||
if (!EqualityComparer<T>.Default.Equals(fileWrapper.ParentId, default(T)))
|
||||
{
|
||||
folder = await folderDao.GetFolderAsync(fileWrapper.ParentId);
|
||||
var canCreate = await _fileSecurity.CanCreateAsync(folder) && folder.FolderType != FolderType.VirtualRooms;
|
||||
var canCreate = await _fileSecurity.CanCreateAsync(folder) && folder.FolderType != FolderType.VirtualRooms
|
||||
&& folder.FolderType != FolderType.Archive;
|
||||
|
||||
if (!canCreate)
|
||||
{
|
||||
folder = null;
|
||||
|
@ -294,6 +294,16 @@ public class GlobalFolder
|
||||
|
||||
return await daoFactory.GetFolderDao<int>().GetFolderIDVirtualRooms(true);
|
||||
}
|
||||
|
||||
public async ValueTask<int> GetFolderArchive(IDaoFactory daoFactory)
|
||||
{
|
||||
if (!_coreBaseSettings.DocSpace)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return await daoFactory.GetFolderDao<int>().GetFolderIDArchive(true);
|
||||
}
|
||||
|
||||
public async ValueTask<int> GetFolderProjectsAsync(IDaoFactory daoFactory)
|
||||
{
|
||||
@ -715,6 +725,7 @@ public class GlobalFolderHelper
|
||||
public ValueTask<int> FolderFavoritesAsync => _globalFolder.GetFolderFavoritesAsync(_daoFactory);
|
||||
public ValueTask<int> FolderTemplatesAsync => _globalFolder.GetFolderTemplatesAsync(_daoFactory);
|
||||
public ValueTask<int> FolderVirtualRoomsAsync => _globalFolder.GetFolderVirtualRooms(_daoFactory);
|
||||
public ValueTask<int> FolderArchiveAsync => _globalFolder.GetFolderArchive(_daoFactory);
|
||||
|
||||
public T GetFolderMy<T>()
|
||||
{
|
||||
@ -746,6 +757,11 @@ public class GlobalFolderHelper
|
||||
return (T)Convert.ChangeType(await FolderVirtualRoomsAsync, typeof(T));
|
||||
}
|
||||
|
||||
public async ValueTask<T> GetFolderArchive<T>()
|
||||
{
|
||||
return (T)Convert.ChangeType(await FolderArchiveAsync, typeof(T));
|
||||
}
|
||||
|
||||
public void SetFolderMy<T>(T val)
|
||||
{
|
||||
_globalFolder.SetFolderMy(val);
|
||||
|
@ -780,6 +780,24 @@ namespace ASC.Files.Core.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to You don't have enough permission to archive the room.
|
||||
/// </summary>
|
||||
public static string ErrorMessage_ArchivingFolder {
|
||||
get {
|
||||
return ResourceManager.GetString("ErrorMessage_ArchivingFolder", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to You cannot edit archived rooms.
|
||||
/// </summary>
|
||||
public static string ErrorMessage_UpdateArchivedRoom {
|
||||
get {
|
||||
return ResourceManager.GetString("ErrorMessage_UpdateArchivedRoom", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Everyone.
|
||||
/// </summary>
|
||||
|
@ -357,6 +357,12 @@
|
||||
<data name="ErrorMassage_ViewTrashItem" xml:space="preserve">
|
||||
<value>You are not allowed to preview the elements in the Trash</value>
|
||||
</data>
|
||||
<data name="ErrorMessage_ArchivingFolder" xml:space="preserve">
|
||||
<value>You don't have enough permission to archive the room</value>
|
||||
</data>
|
||||
<data name="ErrorMessage_UpdateArchivedRoom" xml:space="preserve">
|
||||
<value>You cannot edit archived rooms</value>
|
||||
</data>
|
||||
<data name="Everyone" xml:space="preserve">
|
||||
<value>Everyone</value>
|
||||
</data>
|
||||
|
@ -60,6 +60,15 @@ namespace ASC.Files.Core.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Archive.
|
||||
/// </summary>
|
||||
public static string Archive {
|
||||
get {
|
||||
return ResourceManager.GetString("Archive", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Common.
|
||||
/// </summary>
|
||||
|
@ -117,6 +117,9 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="Archive" xml:space="preserve">
|
||||
<value>Archive</value>
|
||||
</data>
|
||||
<data name="CorporateFiles" xml:space="preserve">
|
||||
<value>Common</value>
|
||||
</data>
|
||||
|
@ -126,9 +126,12 @@ class FileMoveCopyOperation<T> : FileOperation<FileMoveCopyOperationData<T>, T>
|
||||
return;
|
||||
}
|
||||
|
||||
if (!await FilesSecurity.CanCreateAsync(toFolder))
|
||||
if (toFolder.FolderType != FolderType.VirtualRooms && toFolder.FolderType != FolderType.Archive)
|
||||
{
|
||||
throw new SecurityException(FilesCommonResource.ErrorMassage_SecurityException_Create);
|
||||
if (!await FilesSecurity.CanCreateAsync(toFolder))
|
||||
{
|
||||
throw new SecurityException(FilesCommonResource.ErrorMassage_SecurityException_Create);
|
||||
}
|
||||
}
|
||||
|
||||
var parentFolders = await folderDao.GetParentFoldersAsync(toFolder.Id);
|
||||
@ -152,15 +155,38 @@ class FileMoveCopyOperation<T> : FileOperation<FileMoveCopyOperationData<T>, T>
|
||||
rootFrom = await FolderDao.GetRootFolderByFileAsync(Files[0]);
|
||||
}
|
||||
|
||||
if (rootFrom != null && rootFrom.FolderType == FolderType.TRASH)
|
||||
if (rootFrom != null)
|
||||
{
|
||||
throw new InvalidOperationException("Can not copy from Trash.");
|
||||
if (rootFrom.FolderType == FolderType.TRASH)
|
||||
{
|
||||
throw new InvalidOperationException("Can not copy from Trash.");
|
||||
}
|
||||
|
||||
if (rootFrom.FolderType == FolderType.VirtualRooms)
|
||||
{
|
||||
throw new InvalidOperationException("Can not copy from VirtualRooms.");
|
||||
}
|
||||
|
||||
if (rootFrom.FolderType == FolderType.Archive)
|
||||
{
|
||||
throw new InvalidOperationException("Can not copy from Archive.");
|
||||
}
|
||||
}
|
||||
|
||||
if (toFolder.RootFolderType == FolderType.TRASH)
|
||||
{
|
||||
throw new InvalidOperationException("Can not copy to Trash.");
|
||||
}
|
||||
|
||||
if (toFolder.RootFolderType == FolderType.VirtualRooms)
|
||||
{
|
||||
throw new InvalidOperationException("Can not copy to VirtualRooms");
|
||||
}
|
||||
|
||||
if (toFolder.RootFolderType == FolderType.Archive)
|
||||
{
|
||||
throw new InvalidOperationException("Can not copy to Archive");
|
||||
}
|
||||
}
|
||||
|
||||
var needToMark = new List<FileEntry<TTo>>();
|
||||
@ -203,6 +229,10 @@ class FileMoveCopyOperation<T> : FileOperation<FileMoveCopyOperationData<T>, T>
|
||||
var folder = await FolderDao.GetFolderAsync(folderId);
|
||||
var taskError = WithErrorAsync(scope, await FileDao.GetFilesAsync(folder.Id, new OrderBy(SortedByType.AZ, true), FilterType.FilesOnly, false, Guid.Empty, string.Empty, false, true).ToListAsync());
|
||||
|
||||
var isRoom = folder.FolderType == FolderType.CustomRoom || folder.FolderType == FolderType.EditingRoom
|
||||
|| folder.FolderType == FolderType.ReviewRoom || folder.FolderType == FolderType.ReadOnlyRoom
|
||||
|| folder.FolderType == FolderType.FillingFormsRoom;
|
||||
|
||||
if (folder == null)
|
||||
{
|
||||
Error = FilesCommonResource.ErrorMassage_FolderNotFound;
|
||||
@ -211,6 +241,18 @@ class FileMoveCopyOperation<T> : FileOperation<FileMoveCopyOperationData<T>, T>
|
||||
{
|
||||
Error = FilesCommonResource.ErrorMassage_SecurityException_ReadFolder;
|
||||
}
|
||||
else if (!isRoom && (toFolder.FolderType != FolderType.VirtualRooms || toFolder.FolderType != FolderType.Archive))
|
||||
{
|
||||
Error = FilesCommonResource.ErrorMessage_ArchivingFolder;
|
||||
}
|
||||
else if (isRoom && toFolder.FolderType != FolderType.VirtualRooms && !await FilesSecurity.CanEditRoomAsync(folder))
|
||||
{
|
||||
Error = FilesCommonResource.ErrorMessage_ArchivingFolder;
|
||||
}
|
||||
else if (isRoom && toFolder.FolderType != FolderType.Archive && !await FilesSecurity.CanReadAsync(folder))
|
||||
{
|
||||
Error = FilesCommonResource.ErrorMessage_ArchivingFolder;
|
||||
}
|
||||
else if (folder.RootFolderType == FolderType.Privacy
|
||||
&& (copy || toFolder.RootFolderType != FolderType.Privacy))
|
||||
{
|
||||
@ -336,7 +378,11 @@ class FileMoveCopyOperation<T> : FileOperation<FileMoveCopyOperationData<T>, T>
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!await FilesSecurity.CanDeleteAsync(folder))
|
||||
if (!isRoom && !await FilesSecurity.CanDeleteAsync(folder))
|
||||
{
|
||||
Error = FilesCommonResource.ErrorMassage_SecurityException_MoveFolder;
|
||||
}
|
||||
else if (isRoom && !await FilesSecurity.CanEditRoomAsync(folder))
|
||||
{
|
||||
Error = FilesCommonResource.ErrorMassage_SecurityException_MoveFolder;
|
||||
}
|
||||
@ -415,6 +461,10 @@ class FileMoveCopyOperation<T> : FileOperation<FileMoveCopyOperationData<T>, T>
|
||||
{
|
||||
Error = FilesCommonResource.ErrorMassage_FileNotFound;
|
||||
}
|
||||
else if (toFolder.FolderType == FolderType.VirtualRooms || toFolder.FolderType == FolderType.Archive)
|
||||
{
|
||||
Error = FilesCommonResource.ErrorMassage_SecurityException_MoveFile;
|
||||
}
|
||||
else if (!await FilesSecurity.CanReadAsync(file))
|
||||
{
|
||||
Error = FilesCommonResource.ErrorMassage_SecurityException_ReadFile;
|
||||
|
@ -529,6 +529,24 @@ public class EntryManager
|
||||
|
||||
CalculateTotal();
|
||||
}
|
||||
else if (parent.FolderType != FolderType.Archive)
|
||||
{
|
||||
withSubfolders = false;
|
||||
|
||||
if (_global.IsAdministrator)
|
||||
{
|
||||
var folderDao = _daoFactory.GetFolderDao<T>();
|
||||
var thirdPartyFolderDao = _daoFactory.GetFolderDao<string>();
|
||||
|
||||
var folders = await folderDao.GetFoldersAsync(parent.Id, orderBy, filter, subjectGroup, subjectId, searchText, withSubfolders).ToListAsync();
|
||||
|
||||
entries = entries.Concat(folders);
|
||||
}
|
||||
else
|
||||
{
|
||||
entries = await fileSecurity.GetArchiveForMeAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parent.FolderType == FolderType.TRASH)
|
||||
@ -1508,7 +1526,7 @@ public class EntryManager
|
||||
throw new FileNotFoundException(FilesCommonResource.ErrorMassage_FileNotFound);
|
||||
}
|
||||
|
||||
if (!await _fileSecurity.CanRenameAsync(file))
|
||||
if (!await _fileSecurity.CanEditAsync(file))
|
||||
{
|
||||
throw new SecurityException(FilesCommonResource.ErrorMassage_SecurityException_RenameFile);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user