2022-03-15 18:00:53 +00:00
|
|
|
|
// (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.Web.Api.Controllers.Settings;
|
2022-03-01 10:58:02 +00:00
|
|
|
|
|
|
|
|
|
public class CustomSchemasController : BaseSettingsController
|
|
|
|
|
{
|
|
|
|
|
private readonly MessageService _messageService;
|
|
|
|
|
private readonly CustomNamingPeople _customNamingPeople;
|
|
|
|
|
private readonly TenantManager _tenantManager;
|
|
|
|
|
private readonly PermissionContext _permissionContext;
|
|
|
|
|
|
2022-03-02 08:08:59 +00:00
|
|
|
|
public CustomSchemasController(
|
|
|
|
|
MessageService messageService,
|
2022-03-01 10:58:02 +00:00
|
|
|
|
ApiContext apiContext,
|
|
|
|
|
TenantManager tenantManager,
|
|
|
|
|
PermissionContext permissionContext,
|
|
|
|
|
WebItemManager webItemManager,
|
|
|
|
|
CustomNamingPeople customNamingPeople,
|
2022-04-15 10:27:48 +00:00
|
|
|
|
IMemoryCache memoryCache,
|
|
|
|
|
IHttpContextAccessor httpContextAccessor) : base(apiContext, memoryCache, webItemManager, httpContextAccessor)
|
2022-03-02 08:08:59 +00:00
|
|
|
|
{
|
|
|
|
|
_messageService = messageService;
|
2022-03-01 10:58:02 +00:00
|
|
|
|
_customNamingPeople = customNamingPeople;
|
|
|
|
|
_tenantManager = tenantManager;
|
|
|
|
|
_permissionContext = permissionContext;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-23 15:48:23 +00:00
|
|
|
|
[HttpGet("customschemas")]
|
2022-03-15 10:00:41 +00:00
|
|
|
|
public List<SchemaRequestsDto> PeopleSchemas()
|
2022-03-01 10:58:02 +00:00
|
|
|
|
{
|
|
|
|
|
return _customNamingPeople
|
|
|
|
|
.GetSchemas()
|
|
|
|
|
.Select(r =>
|
|
|
|
|
{
|
|
|
|
|
var names = _customNamingPeople.GetPeopleNames(r.Key);
|
|
|
|
|
|
2022-03-15 10:00:41 +00:00
|
|
|
|
return new SchemaRequestsDto
|
2022-03-01 10:58:02 +00:00
|
|
|
|
{
|
|
|
|
|
Id = names.Id,
|
|
|
|
|
Name = names.SchemaName,
|
|
|
|
|
UserCaption = names.UserCaption,
|
|
|
|
|
UsersCaption = names.UsersCaption,
|
|
|
|
|
GroupCaption = names.GroupCaption,
|
|
|
|
|
GroupsCaption = names.GroupsCaption,
|
|
|
|
|
UserPostCaption = names.UserPostCaption,
|
|
|
|
|
RegDateCaption = names.RegDateCaption,
|
|
|
|
|
GroupHeadCaption = names.GroupHeadCaption,
|
|
|
|
|
GuestCaption = names.GuestCaption,
|
|
|
|
|
GuestsCaption = names.GuestsCaption,
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-23 15:48:23 +00:00
|
|
|
|
[HttpPost("customschemas")]
|
2022-03-15 10:56:22 +00:00
|
|
|
|
public SchemaRequestsDto SaveNamingSettings(SchemaRequestsDto inDto)
|
2022-03-01 10:58:02 +00:00
|
|
|
|
{
|
|
|
|
|
_permissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
|
|
|
|
|
|
2022-03-15 10:56:22 +00:00
|
|
|
|
_customNamingPeople.SetPeopleNames(inDto.Id);
|
2022-03-01 10:58:02 +00:00
|
|
|
|
|
|
|
|
|
_tenantManager.SaveTenant(_tenantManager.GetCurrentTenant());
|
|
|
|
|
|
|
|
|
|
_messageService.Send(MessageAction.TeamTemplateChanged);
|
|
|
|
|
|
2022-03-15 10:56:22 +00:00
|
|
|
|
return PeopleSchema(inDto.Id);
|
2022-03-01 10:58:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-23 15:48:23 +00:00
|
|
|
|
[HttpPut("customschemas")]
|
2022-03-15 10:56:22 +00:00
|
|
|
|
public SchemaRequestsDto SaveCustomNamingSettings(SchemaRequestsDto inDto)
|
2022-03-01 10:58:02 +00:00
|
|
|
|
{
|
|
|
|
|
_permissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
|
|
|
|
|
|
2022-03-15 10:56:22 +00:00
|
|
|
|
var usrCaption = (inDto.UserCaption ?? "").Trim();
|
|
|
|
|
var usrsCaption = (inDto.UsersCaption ?? "").Trim();
|
|
|
|
|
var grpCaption = (inDto.GroupCaption ?? "").Trim();
|
|
|
|
|
var grpsCaption = (inDto.GroupsCaption ?? "").Trim();
|
|
|
|
|
var usrStatusCaption = (inDto.UserPostCaption ?? "").Trim();
|
|
|
|
|
var regDateCaption = (inDto.RegDateCaption ?? "").Trim();
|
|
|
|
|
var grpHeadCaption = (inDto.GroupHeadCaption ?? "").Trim();
|
|
|
|
|
var guestCaption = (inDto.GuestCaption ?? "").Trim();
|
|
|
|
|
var guestsCaption = (inDto.GuestsCaption ?? "").Trim();
|
2022-03-01 10:58:02 +00:00
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(usrCaption)
|
|
|
|
|
|| string.IsNullOrEmpty(usrsCaption)
|
|
|
|
|
|| string.IsNullOrEmpty(grpCaption)
|
|
|
|
|
|| string.IsNullOrEmpty(grpsCaption)
|
|
|
|
|
|| string.IsNullOrEmpty(usrStatusCaption)
|
|
|
|
|
|| string.IsNullOrEmpty(regDateCaption)
|
|
|
|
|
|| string.IsNullOrEmpty(grpHeadCaption)
|
|
|
|
|
|| string.IsNullOrEmpty(guestCaption)
|
|
|
|
|
|| string.IsNullOrEmpty(guestsCaption))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception(Resource.ErrorEmptyFields);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var names = new PeopleNamesItem
|
|
|
|
|
{
|
|
|
|
|
Id = PeopleNamesItem.CustomID,
|
|
|
|
|
UserCaption = usrCaption.Substring(0, Math.Min(30, usrCaption.Length)),
|
|
|
|
|
UsersCaption = usrsCaption.Substring(0, Math.Min(30, usrsCaption.Length)),
|
|
|
|
|
GroupCaption = grpCaption.Substring(0, Math.Min(30, grpCaption.Length)),
|
|
|
|
|
GroupsCaption = grpsCaption.Substring(0, Math.Min(30, grpsCaption.Length)),
|
|
|
|
|
UserPostCaption = usrStatusCaption.Substring(0, Math.Min(30, usrStatusCaption.Length)),
|
|
|
|
|
RegDateCaption = regDateCaption.Substring(0, Math.Min(30, regDateCaption.Length)),
|
|
|
|
|
GroupHeadCaption = grpHeadCaption.Substring(0, Math.Min(30, grpHeadCaption.Length)),
|
|
|
|
|
GuestCaption = guestCaption.Substring(0, Math.Min(30, guestCaption.Length)),
|
|
|
|
|
GuestsCaption = guestsCaption.Substring(0, Math.Min(30, guestsCaption.Length)),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_customNamingPeople.SetPeopleNames(names);
|
|
|
|
|
|
|
|
|
|
_tenantManager.SaveTenant(_tenantManager.GetCurrentTenant());
|
|
|
|
|
|
|
|
|
|
_messageService.Send(MessageAction.TeamTemplateChanged);
|
|
|
|
|
|
|
|
|
|
return PeopleSchema(PeopleNamesItem.CustomID);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-23 15:48:23 +00:00
|
|
|
|
[HttpGet("customschemas/{id}")]
|
2022-03-15 10:00:41 +00:00
|
|
|
|
public SchemaRequestsDto PeopleSchema(string id)
|
2022-03-01 10:58:02 +00:00
|
|
|
|
{
|
|
|
|
|
var names = _customNamingPeople.GetPeopleNames(id);
|
2022-03-15 10:00:41 +00:00
|
|
|
|
var schemaItem = new SchemaRequestsDto
|
2022-03-01 10:58:02 +00:00
|
|
|
|
{
|
|
|
|
|
Id = names.Id,
|
|
|
|
|
Name = names.SchemaName,
|
|
|
|
|
UserCaption = names.UserCaption,
|
|
|
|
|
UsersCaption = names.UsersCaption,
|
|
|
|
|
GroupCaption = names.GroupCaption,
|
|
|
|
|
GroupsCaption = names.GroupsCaption,
|
|
|
|
|
UserPostCaption = names.UserPostCaption,
|
|
|
|
|
RegDateCaption = names.RegDateCaption,
|
|
|
|
|
GroupHeadCaption = names.GroupHeadCaption,
|
|
|
|
|
GuestCaption = names.GuestCaption,
|
|
|
|
|
GuestsCaption = names.GuestsCaption,
|
|
|
|
|
};
|
|
|
|
|
return schemaItem;
|
|
|
|
|
}
|
|
|
|
|
}
|