DocSpace-buildtools/common/ASC.Core.Common/WhiteLabel/MailWhiteLabelSettings.cs

184 lines
6.1 KiB
C#
Raw Normal View History

2019-06-07 08:59:07 +00:00
/*
*
* (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL 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 more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
using System;
2019-08-15 12:04:42 +00:00
using System.Runtime.Serialization;
2019-09-13 11:18:27 +00:00
using ASC.Core;
2019-08-19 13:51:36 +00:00
using ASC.Core.Common;
2019-10-31 11:28:30 +00:00
using ASC.Core.Common.Settings;
2019-09-23 12:20:08 +00:00
using Microsoft.Extensions.Configuration;
2019-10-31 11:28:30 +00:00
using Microsoft.Extensions.DependencyInjection;
2019-09-23 12:20:08 +00:00
2019-06-07 08:59:07 +00:00
namespace ASC.Web.Core.WhiteLabel
{
[Serializable]
[DataContract]
public class MailWhiteLabelSettings : BaseSettings<MailWhiteLabelSettings>
{
[DataMember(Name = "FooterEnabled")]
public bool FooterEnabled { get; set; }
[DataMember(Name = "FooterSocialEnabled")]
public bool FooterSocialEnabled { get; set; }
[DataMember(Name = "SupportUrl")]
public string SupportUrl { get; set; }
[DataMember(Name = "SupportEmail")]
public string SupportEmail { get; set; }
[DataMember(Name = "SalesEmail")]
public string SalesEmail { get; set; }
[DataMember(Name = "DemotUrl")]
public string DemotUrl { get; set; }
[DataMember(Name = "SiteUrl")]
public string SiteUrl { get; set; }
public bool IsDefault
{
get
{
2019-08-15 13:41:38 +00:00
if (!(GetDefault() is MailWhiteLabelSettings defaultSettings)) return false;
2019-06-07 08:59:07 +00:00
return FooterEnabled == defaultSettings.FooterEnabled &&
FooterSocialEnabled == defaultSettings.FooterSocialEnabled &&
SupportUrl == defaultSettings.SupportUrl &&
SupportEmail == defaultSettings.SupportEmail &&
SalesEmail == defaultSettings.SalesEmail &&
DemotUrl == defaultSettings.DemotUrl &&
SiteUrl == defaultSettings.SiteUrl;
}
2019-09-13 11:18:27 +00:00
}
public MailWhiteLabelSettings()
{
}
2019-10-31 11:28:30 +00:00
public MailWhiteLabelSettings(
AuthContext authContext,
SettingsManager settingsManager,
TenantManager tenantManager,
IConfiguration configuration) :
2019-09-13 11:18:27 +00:00
base(authContext, settingsManager, tenantManager)
{
2019-09-23 12:20:08 +00:00
Configuration = configuration;
2019-09-13 11:18:27 +00:00
}
2019-06-07 08:59:07 +00:00
#region ISettings Members
public override Guid ID
{
get { return new Guid("{C3602052-5BA2-452A-BD2A-ADD0FAF8EB88}"); }
}
public override ISettings GetDefault()
{
2019-08-15 12:04:42 +00:00
return new MailWhiteLabelSettings
{
FooterEnabled = true,
FooterSocialEnabled = true,
SupportUrl = DefaultMailSupportUrl,
SupportEmail = DefaultMailSupportEmail,
SalesEmail = DefaultMailSalesEmail,
DemotUrl = DefaultMailDemotUrl,
SiteUrl = DefaultMailSiteUrl
};
2019-06-07 08:59:07 +00:00
}
#endregion
#region Default values
2019-09-23 12:20:08 +00:00
public string DefaultMailSupportUrl
2019-06-07 08:59:07 +00:00
{
get
{
2019-09-23 12:20:08 +00:00
var url = BaseCommonLinkUtility.GetRegionalUrl(Configuration["web:support-feedback"] ?? string.Empty, null);
2019-06-07 08:59:07 +00:00
return !string.IsNullOrEmpty(url) ? url : "http://support.onlyoffice.com";
}
}
2019-09-23 12:20:08 +00:00
public string DefaultMailSupportEmail
2019-06-07 08:59:07 +00:00
{
get
{
2019-09-23 12:20:08 +00:00
var email = Configuration["web:support:email"];
2019-06-07 08:59:07 +00:00
return !string.IsNullOrEmpty(email) ? email : "support@onlyoffice.com";
}
}
2019-09-23 12:20:08 +00:00
public string DefaultMailSalesEmail
2019-06-07 08:59:07 +00:00
{
get
{
2019-09-23 12:20:08 +00:00
var email = Configuration["web:payment:email"];
2019-06-07 08:59:07 +00:00
return !string.IsNullOrEmpty(email) ? email : "sales@onlyoffice.com";
}
}
2019-09-23 12:20:08 +00:00
public string DefaultMailDemotUrl
2019-06-07 08:59:07 +00:00
{
get
{
2019-09-23 12:20:08 +00:00
var url = BaseCommonLinkUtility.GetRegionalUrl(Configuration["web:demo-order"] ?? string.Empty, null);
2019-06-07 08:59:07 +00:00
return !string.IsNullOrEmpty(url) ? url : "http://www.onlyoffice.com/demo-order.aspx";
}
}
2019-09-23 12:20:08 +00:00
public string DefaultMailSiteUrl
2019-06-07 08:59:07 +00:00
{
get
{
2019-09-23 12:20:08 +00:00
var url = Configuration["web:teamlab-site"];
2019-06-07 08:59:07 +00:00
return !string.IsNullOrEmpty(url) ? url : "http://www.onlyoffice.com";
}
}
#endregion
2019-09-13 11:18:27 +00:00
public MailWhiteLabelSettings Instance
2019-06-07 08:59:07 +00:00
{
get
{
return LoadForDefaultTenant();
}
2019-09-23 12:20:08 +00:00
}
public IConfiguration Configuration { get; }
2019-10-31 11:28:30 +00:00
}
public static class MailWhiteLabelSettingsFactory
{
public static IServiceCollection AddMailWhiteLabelSettingsService(this IServiceCollection services)
{
return services.AddSettingsService<MailWhiteLabelSettings>();
2019-10-31 11:28:30 +00:00
}
2019-06-07 08:59:07 +00:00
}
}