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

160 lines
5.7 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;
2020-08-12 09:58:08 +00:00
using ASC.Common;
2020-02-17 08:58:14 +00:00
using ASC.Core.Common;
using ASC.Core.Common.Settings;
2020-08-12 09:58:08 +00:00
2020-02-17 08:58:14 +00:00
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
2019-06-07 08:59:07 +00:00
namespace ASC.Web.Core.WhiteLabel
{
[Serializable]
2019-11-08 15:11:30 +00:00
public class MailWhiteLabelSettings : ISettings
2019-06-07 08:59:07 +00:00
{
public bool FooterEnabled { get; set; }
public bool FooterSocialEnabled { get; set; }
public string SupportUrl { get; set; }
public string SupportEmail { get; set; }
public string SalesEmail { get; set; }
2020-09-17 12:04:28 +00:00
public string DemoUrl { get; set; }
2019-06-07 08:59:07 +00:00
public string SiteUrl { get; set; }
public Guid ID
2019-06-07 08:59:07 +00:00
{
get { return new Guid("{C3602052-5BA2-452A-BD2A-ADD0FAF8EB88}"); }
2020-02-17 08:58:14 +00:00
}
public ISettings GetDefault(IConfiguration configuration)
2020-02-17 08:58:14 +00:00
{
var mailWhiteLabelSettingsHelper = new MailWhiteLabelSettingsHelper(configuration);
return new MailWhiteLabelSettings
{
FooterEnabled = true,
FooterSocialEnabled = true,
SupportUrl = mailWhiteLabelSettingsHelper.DefaultMailSupportUrl,
SupportEmail = mailWhiteLabelSettingsHelper.DefaultMailSupportEmail,
SalesEmail = mailWhiteLabelSettingsHelper.DefaultMailSalesEmail,
2020-09-17 12:04:28 +00:00
DemoUrl = mailWhiteLabelSettingsHelper.DefaultMailDemoUrl,
2020-02-17 08:58:14 +00:00
SiteUrl = mailWhiteLabelSettingsHelper.DefaultMailSiteUrl
2019-08-15 12:04:42 +00:00
};
2020-02-17 08:58:14 +00:00
}
public bool IsDefault(IConfiguration configuration)
{
if (!(GetDefault(configuration) is MailWhiteLabelSettings defaultSettings)) return false;
return FooterEnabled == defaultSettings.FooterEnabled &&
FooterSocialEnabled == defaultSettings.FooterSocialEnabled &&
SupportUrl == defaultSettings.SupportUrl &&
SupportEmail == defaultSettings.SupportEmail &&
SalesEmail == defaultSettings.SalesEmail &&
2020-09-17 12:04:28 +00:00
DemoUrl == defaultSettings.DemoUrl &&
2020-02-17 08:58:14 +00:00
SiteUrl == defaultSettings.SiteUrl;
}
public static MailWhiteLabelSettings Instance(SettingsManager settingsManager)
{
return settingsManager.LoadForDefaultTenant<MailWhiteLabelSettings>();
2020-02-17 08:58:14 +00:00
}
public static bool IsDefault(SettingsManager settingsManager, IConfiguration configuration)
{
return Instance(settingsManager).IsDefault(configuration);
}
public ISettings GetDefault(IServiceProvider serviceProvider)
{
return GetDefault(serviceProvider.GetService<IConfiguration>());
}
}
2020-10-19 15:53:15 +00:00
[Singletone]
2020-02-17 08:58:14 +00:00
public class MailWhiteLabelSettingsHelper
{
public MailWhiteLabelSettingsHelper(IConfiguration configuration)
{
Configuration = configuration;
}
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);
2020-09-18 07:59:23 +00:00
return !string.IsNullOrEmpty(url) ? url : "http://helpdesk.onlyoffice.com";
2019-06-07 08:59:07 +00:00
}
}
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";
}
}
2020-09-17 12:04:28 +00:00
public string DefaultMailDemoUrl
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";
}
2020-02-17 08:58:14 +00:00
}
2020-08-12 09:58:08 +00:00
private IConfiguration Configuration { get; }
2020-02-17 08:58:14 +00:00
}
2019-06-07 08:59:07 +00:00
}