Quota: user quota storage core_user -> webstudio_settings
This commit is contained in:
parent
d24f9db4c7
commit
cfb0c957e9
@ -148,7 +148,7 @@ public class LdapObjectExtension
|
||||
var emails = GetContacts(ldapUser, Mapping.AdditionalMail, settings);
|
||||
var skype = GetContacts(ldapUser, Mapping.Skype, settings);
|
||||
|
||||
var quotaSettings = _settingsManager.Load<UserQuotaSettings>();
|
||||
var quotaSettings = _settingsManager.Load<TenantUserQuotaSettings>();
|
||||
var quota = settings.LdapMapping.ContainsKey(Mapping.UserQuotaLimit) ? ByteConverter.ConvertSizeToBytes(GetAttribute(ldapUser, settings.LdapMapping[Mapping.UserQuotaLimit])) : quotaSettings.DefaultUserQuota;
|
||||
|
||||
if (string.IsNullOrEmpty(userName))
|
||||
@ -173,10 +173,14 @@ public class LdapObjectExtension
|
||||
Title = !string.IsNullOrEmpty(title) ? title : string.Empty,
|
||||
Location = !string.IsNullOrEmpty(location) ? location : string.Empty,
|
||||
WorkFromDate = _tenantUtil.DateTimeNow(),
|
||||
ContactsList = contacts,
|
||||
QuotaLimit = quotaSettings.EnableUserQuota ? quota : -1
|
||||
ContactsList = contacts
|
||||
};
|
||||
|
||||
if (quotaSettings.EnableUserQuota)
|
||||
{
|
||||
_settingsManager.SaveForUser(new UserQuotaSettings { UserQuota = quota }, Guid.Parse(user.Sid));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(firstName))
|
||||
{
|
||||
user.FirstName = firstName.Length > MAX_NUMBER_OF_SYMBOLS
|
||||
|
@ -199,11 +199,12 @@ public class EmployeeFullDtoHelper : EmployeeDtoHelper
|
||||
|
||||
result.UsedSpace = Math.Max(0, _userManager.FindUserQuotaRows(_context.Tenant.Id, userInfo.Id).Where(r => !string.IsNullOrEmpty(r.Tag)).Sum(r => r.Counter));
|
||||
|
||||
var quotaSettings = _settingsManager.Load<UserQuotaSettings>();
|
||||
var quotaSettings = _settingsManager.Load<TenantUserQuotaSettings>();
|
||||
var userQuotaSettings = _settingsManager.LoadForUser<UserQuotaSettings>(userInfo.IsSSO() ? Guid.Parse(userInfo.Sid) : userInfo.Id);
|
||||
|
||||
if (quotaSettings.EnableUserQuota)
|
||||
{
|
||||
result.QuotaLimit = userInfo.QuotaLimit;
|
||||
result.QuotaLimit = userQuotaSettings != null ? userQuotaSettings.UserQuota : quotaSettings.DefaultUserQuota;
|
||||
}
|
||||
|
||||
if (userInfo.Sex.HasValue)
|
||||
|
@ -53,7 +53,6 @@ public class UserManager
|
||||
private readonly IHttpContextAccessor _accessor;
|
||||
private readonly IUserService _userService;
|
||||
private readonly TenantManager _tenantManager;
|
||||
private readonly SettingsManager _settingsManager;
|
||||
private readonly PermissionContext _permissionContext;
|
||||
private readonly UserManagerConstants _userManagerConstants;
|
||||
private readonly CoreBaseSettings _coreBaseSettings;
|
||||
@ -77,7 +76,6 @@ public class UserManager
|
||||
IQuotaService quotaService,
|
||||
IUserService service,
|
||||
TenantManager tenantManager,
|
||||
SettingsManager settingsManager,
|
||||
PermissionContext permissionContext,
|
||||
UserManagerConstants userManagerConstants,
|
||||
CoreBaseSettings coreBaseSettings,
|
||||
@ -91,7 +89,6 @@ public class UserManager
|
||||
_quotaService = quotaService;
|
||||
_userService = service;
|
||||
_tenantManager = tenantManager;
|
||||
_settingsManager = settingsManager;
|
||||
_permissionContext = permissionContext;
|
||||
_userManagerConstants = userManagerConstants;
|
||||
_coreBaseSettings = coreBaseSettings;
|
||||
@ -108,7 +105,6 @@ public class UserManager
|
||||
IQuotaService quotaService,
|
||||
IUserService service,
|
||||
TenantManager tenantManager,
|
||||
SettingsManager settingsManager,
|
||||
PermissionContext permissionContext,
|
||||
UserManagerConstants userManagerConstants,
|
||||
CoreBaseSettings coreBaseSettings,
|
||||
@ -119,7 +115,7 @@ public class UserManager
|
||||
ILogger<UserManager> log,
|
||||
ICache cache,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
: this(quotaService, service, tenantManager, settingsManager, permissionContext, userManagerConstants, coreBaseSettings, coreSettings, instanceCrypto, radicaleClient, cardDavAddressbook, log, cache)
|
||||
: this(quotaService, service, tenantManager, permissionContext, userManagerConstants, coreBaseSettings, coreSettings, instanceCrypto, radicaleClient, cardDavAddressbook, log, cache)
|
||||
{
|
||||
_accessor = httpContextAccessor;
|
||||
}
|
||||
@ -362,15 +358,7 @@ public class UserManager
|
||||
}
|
||||
|
||||
var oldUserData = _userService.GetUserByUserName(_tenantManager.GetCurrentTenant().Id, u.UserName);
|
||||
if (oldUserData == null) //new user
|
||||
{
|
||||
var quotaSettings = _settingsManager.Load<UserQuotaSettings>();
|
||||
|
||||
if (quotaSettings.EnableUserQuota)
|
||||
{
|
||||
u.QuotaLimit = quotaSettings.DefaultUserQuota;
|
||||
}
|
||||
}
|
||||
var newUser = _userService.SaveUser(_tenantManager.GetCurrentTenant().Id, u);
|
||||
|
||||
if (syncCardDav)
|
||||
|
@ -74,7 +74,6 @@ public sealed class UserInfo : IDirectRecipient, ICloneable, IMapFrom<User>
|
||||
public string SsoNameId { get; set; } // SSO SAML user identificator
|
||||
public string SsoSessionId { get; set; } // SSO SAML user session identificator
|
||||
public DateTime CreateDate { get; set; }
|
||||
public long QuotaLimit { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
@ -53,7 +53,6 @@ public class User : BaseEntity, IMapFrom<UserInfo>
|
||||
public bool Removed { get; set; }
|
||||
public DateTime CreateDate { get; set; }
|
||||
public DateTime LastModified { get; set; }
|
||||
public long QuotaLimit { get; set; }
|
||||
|
||||
public override object[] GetKeys()
|
||||
{
|
||||
@ -236,10 +235,6 @@ public static class DbUserExtension
|
||||
entity.Property(e => e.WorkFromDate)
|
||||
.HasColumnName("workfromdate")
|
||||
.HasColumnType("datetime");
|
||||
|
||||
entity.Property(e => e.QuotaLimit)
|
||||
.HasColumnName("quota_limit")
|
||||
.HasDefaultValueSql("'-1'");
|
||||
});
|
||||
}
|
||||
|
||||
@ -352,10 +347,6 @@ public static class DbUserExtension
|
||||
.HasColumnName("username")
|
||||
.HasMaxLength(255);
|
||||
|
||||
entity.Property(e => e.QuotaLimit)
|
||||
.HasColumnName("quota_limit")
|
||||
.HasDefaultValueSql("'-1'");
|
||||
|
||||
entity.Property(e => e.WorkFromDate).HasColumnName("workfromdate");
|
||||
});
|
||||
}
|
||||
|
50
common/ASC.Core.Common/Tenants/TenantUserQuotaSettings.cs
Normal file
50
common/ASC.Core.Common/Tenants/TenantUserQuotaSettings.cs
Normal file
@ -0,0 +1,50 @@
|
||||
// (c) Copyright Ascensio System SIA 2010-2022
|
||||
//
|
||||
// This program is a free software product.
|
||||
// You can redistribute it and/or modify it under the terms
|
||||
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
|
||||
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
|
||||
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
|
||||
// any third-party rights.
|
||||
//
|
||||
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
|
||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
|
||||
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
//
|
||||
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
|
||||
//
|
||||
// The interactive user interfaces in modified source and object code versions of the Program must
|
||||
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
|
||||
//
|
||||
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
|
||||
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
|
||||
// trademark law for use of our trademarks.
|
||||
//
|
||||
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
|
||||
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
namespace ASC.Core.Tenants;
|
||||
|
||||
[Serializable]
|
||||
public class TenantUserQuotaSettings : ISettings<TenantUserQuotaSettings>
|
||||
{
|
||||
public bool EnableUserQuota { get; set; }
|
||||
|
||||
public long DefaultUserQuota { get; set; }
|
||||
|
||||
public TenantUserQuotaSettings GetDefault()
|
||||
{
|
||||
return new TenantUserQuotaSettings
|
||||
{
|
||||
EnableUserQuota = false,
|
||||
DefaultUserQuota = -1
|
||||
};
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public Guid ID
|
||||
{
|
||||
get { return new Guid("{5FE28053-BCD4-466B-8A4B-71B612F0D6FC}"); }
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
// (c) Copyright Ascensio System SIA 2010-2022
|
||||
// (c) Copyright Ascensio System SIA 2010-2022
|
||||
//
|
||||
// This program is a free software product.
|
||||
// You can redistribute it and/or modify it under the terms
|
||||
@ -29,22 +29,19 @@ namespace ASC.Core.Users;
|
||||
[Serializable]
|
||||
public class UserQuotaSettings : ISettings<UserQuotaSettings>
|
||||
{
|
||||
public bool EnableUserQuota { get; set; }
|
||||
|
||||
public long DefaultUserQuota { get; set; }
|
||||
public long UserQuota { get; set; }
|
||||
|
||||
public UserQuotaSettings GetDefault()
|
||||
{
|
||||
return new UserQuotaSettings
|
||||
{
|
||||
EnableUserQuota = false,
|
||||
DefaultUserQuota = -1
|
||||
UserQuota = -1
|
||||
};
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public Guid ID
|
||||
{
|
||||
get { return new Guid("{5FE28053-BCD4-466B-8A4B-71B612F0D6FC}"); }
|
||||
get { return new Guid("{5A097CFA-1A8E-45CB-A4BB-FE8D2B5E5908}"); }
|
||||
}
|
||||
}
|
||||
|
@ -413,11 +413,12 @@ internal class FileDao : AbstractDao, IFileDao<int>
|
||||
}
|
||||
|
||||
var user = _userManager.GetUsers(file.Id == default ? _authContext.CurrentAccount.ID : file.CreateBy);
|
||||
var quotaSettings = _settingsManager.Load<UserQuotaSettings>();
|
||||
var quotaSettings = _settingsManager.Load<TenantUserQuotaSettings>();
|
||||
var userQuotaSettings = _settingsManager.LoadForUser<UserQuotaSettings>(user.IsLDAP() ? Guid.Parse(user.Sid) : user.Id);
|
||||
|
||||
if (quotaSettings.EnableUserQuota && user.QuotaLimit != -1)
|
||||
if (quotaSettings.EnableUserQuota && userQuotaSettings.UserQuota != -1)
|
||||
{
|
||||
var quotaLimit = user.QuotaLimit;
|
||||
var quotaLimit = userQuotaSettings.UserQuota;
|
||||
|
||||
if (quotaLimit != -1)
|
||||
{
|
||||
|
@ -1122,8 +1122,9 @@ public class UserController : PeopleControllerBase
|
||||
}
|
||||
}
|
||||
|
||||
user.QuotaLimit = inDto.Quota;
|
||||
_userManager.SaveUserInfo(user, syncCardDav: true);
|
||||
var quotaSettings = _settingsManager.Load<TenantUserQuotaSettings>();
|
||||
|
||||
_settingsManager.SaveForUser(new UserQuotaSettings { UserQuota = inDto.Quota }, user.IsLDAP() ? Guid.Parse(user.Sid) : user.Id);
|
||||
|
||||
yield return await _employeeFullDtoHelper.GetFull(user);
|
||||
}
|
||||
|
@ -24,8 +24,6 @@
|
||||
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
using ASC.Web.Studio.Core.Quota;
|
||||
|
||||
using Constants = ASC.Core.Users.Constants;
|
||||
|
||||
namespace ASC.Web.Api.Controllers.Settings;
|
||||
@ -278,7 +276,7 @@ public class SettingsController : BaseSettingsController
|
||||
{
|
||||
_permissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
|
||||
|
||||
_settingsManager.Save(new UserQuotaSettings { EnableUserQuota = inDto.EnableUserQuota, DefaultUserQuota = inDto.DefaultUserQuota });
|
||||
_settingsManager.Save(new TenantUserQuotaSettings { EnableUserQuota = inDto.EnableUserQuota, DefaultUserQuota = inDto.DefaultUserQuota });
|
||||
|
||||
return Resource.SuccessfullySaveSettingsMessage;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user