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;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
using System.Web;
|
|
|
|
using ASC.Core;
|
|
|
|
using ASC.Core.Common;
|
2019-08-08 09:26:58 +00:00
|
|
|
using ASC.Core.Tenants;
|
2019-06-07 08:59:07 +00:00
|
|
|
using ASC.Core.Users;
|
|
|
|
using ASC.Security.Cryptography;
|
|
|
|
using ASC.Web.Core;
|
|
|
|
using ASC.Web.Core.WhiteLabel;
|
2019-07-02 15:30:31 +00:00
|
|
|
using Microsoft.AspNetCore.Http;
|
2019-06-07 08:59:07 +00:00
|
|
|
|
|
|
|
namespace ASC.Web.Studio.Utility
|
|
|
|
{
|
|
|
|
public enum ManagementType
|
|
|
|
{
|
|
|
|
General = 0,
|
|
|
|
Customization = 1,
|
|
|
|
ProductsAndInstruments = 2,
|
|
|
|
PortalSecurity = 3,
|
|
|
|
AccessRights = 4,
|
|
|
|
Backup = 5,
|
|
|
|
LoginHistory = 6,
|
|
|
|
AuditTrail = 7,
|
|
|
|
LdapSettings = 8,
|
|
|
|
ThirdPartyAuthorization = 9,
|
|
|
|
SmtpSettings = 10,
|
|
|
|
Statistic = 11,
|
|
|
|
Monitoring = 12,
|
|
|
|
SingleSignOnSettings = 13,
|
|
|
|
Migration = 14,
|
|
|
|
DeletionPortal = 15,
|
|
|
|
HelpCenter = 16,
|
|
|
|
DocService = 17,
|
|
|
|
FullTextSearch = 18,
|
|
|
|
WhiteLabel = 19,
|
|
|
|
MailService = 20,
|
|
|
|
Storage = 21
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class CommonLinkUtility
|
|
|
|
{
|
|
|
|
private static readonly Regex RegFilePathTrim = new Regex("/[^/]*\\.aspx", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
|
|
|
|
|
|
|
public const string ParamName_ProductSysName = "product";
|
|
|
|
public const string ParamName_UserUserName = "user";
|
|
|
|
public const string ParamName_UserUserID = "uid";
|
|
|
|
|
|
|
|
public static void Initialize(string serverUri)
|
|
|
|
{
|
|
|
|
BaseCommonLinkUtility.Initialize(serverUri);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static string VirtualRoot
|
|
|
|
{
|
|
|
|
get { return BaseCommonLinkUtility.VirtualRoot; }
|
|
|
|
}
|
|
|
|
|
2019-08-08 09:26:58 +00:00
|
|
|
public static string ServerRootPath(HttpContext context)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-08-08 09:26:58 +00:00
|
|
|
return BaseCommonLinkUtility.ServerRootPath(context);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static string GetFullAbsolutePath(string virtualPath)
|
|
|
|
{
|
2019-08-15 12:04:42 +00:00
|
|
|
return GetFullAbsolutePath(ASC.Common.HttpContext.Current, virtualPath);
|
2019-08-08 09:26:58 +00:00
|
|
|
}
|
|
|
|
public static string GetFullAbsolutePath(HttpContext context, string virtualPath)
|
|
|
|
{
|
|
|
|
return BaseCommonLinkUtility.GetFullAbsolutePath(context, virtualPath);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static string ToAbsolute(string virtualPath)
|
|
|
|
{
|
|
|
|
return BaseCommonLinkUtility.ToAbsolute(virtualPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static string Logout
|
|
|
|
{
|
|
|
|
get { return ToAbsolute("~/auth.aspx") + "?t=logout"; }
|
|
|
|
}
|
|
|
|
|
|
|
|
public static string GetDefault()
|
|
|
|
{
|
|
|
|
return VirtualRoot;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static string GetMyStaff()
|
|
|
|
{
|
|
|
|
return CoreContext.Configuration.Personal ? ToAbsolute("~/my.aspx") : ToAbsolute("~/products/people/profile.aspx");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static string GetEmployees()
|
|
|
|
{
|
|
|
|
return GetEmployees(EmployeeStatus.Active);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static string GetEmployees(EmployeeStatus empStatus)
|
|
|
|
{
|
|
|
|
return ToAbsolute("~/products/people/") +
|
|
|
|
(empStatus == EmployeeStatus.Terminated ? "#type=disabled" : string.Empty);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static string GetDepartment(Guid depId)
|
|
|
|
{
|
|
|
|
return depId != Guid.Empty ? ToAbsolute("~/products/people/#group=") + depId.ToString() : GetEmployees();
|
|
|
|
}
|
|
|
|
|
|
|
|
#region user profile link
|
|
|
|
|
2019-08-09 12:28:19 +00:00
|
|
|
public static string GetUserProfile(int tenantId, Guid userID)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-08-09 12:28:19 +00:00
|
|
|
if (!CoreContext.UserManager.UserExists(tenantId, userID))
|
2019-08-08 09:26:58 +00:00
|
|
|
return GetEmployees();
|
|
|
|
|
2019-08-09 12:28:19 +00:00
|
|
|
return GetUserProfile(tenantId, userID.ToString());
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
2019-08-30 12:40:57 +00:00
|
|
|
public static string GetUserProfile(UserInfo user)
|
|
|
|
{
|
|
|
|
if (!CoreContext.UserManager.UserExists(user))
|
|
|
|
return GetEmployees();
|
|
|
|
|
|
|
|
return GetUserProfile(user, true);
|
|
|
|
}
|
|
|
|
|
2019-08-09 12:28:19 +00:00
|
|
|
public static string GetUserProfile(int tenantId, string user, bool absolute = true)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
var queryParams = "";
|
|
|
|
|
2019-08-15 13:16:39 +00:00
|
|
|
if (!string.IsNullOrEmpty(user))
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
var guid = Guid.Empty;
|
2019-08-15 13:16:39 +00:00
|
|
|
if (!string.IsNullOrEmpty(user) && 32 <= user.Length && user[8] == '-')
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
guid = new Guid(user);
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-09 12:28:19 +00:00
|
|
|
queryParams = guid != Guid.Empty ? GetUserParamsPair(tenantId, guid) : ParamName_UserUserName + "=" + HttpUtility.UrlEncode(user);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var url = absolute ? ToAbsolute("~/products/people/") : "/products/people/";
|
|
|
|
url += "profile.aspx?";
|
|
|
|
url += queryParams;
|
|
|
|
|
|
|
|
return url;
|
|
|
|
}
|
2019-08-30 12:40:57 +00:00
|
|
|
|
|
|
|
public static string GetUserProfile(UserInfo user, bool absolute = true)
|
|
|
|
{
|
|
|
|
var queryParams = user.ID != Guid.Empty ? GetUserParamsPair(user) : ParamName_UserUserName + "=" + HttpUtility.UrlEncode(user.UserName);
|
|
|
|
|
|
|
|
var url = absolute ? ToAbsolute("~/products/people/") : "/products/people/";
|
|
|
|
url += "profile.aspx?";
|
|
|
|
url += queryParams;
|
|
|
|
|
|
|
|
return url;
|
|
|
|
}
|
2019-08-09 12:28:19 +00:00
|
|
|
public static string GetUserProfile(int tenantId, Guid user, bool absolute = true)
|
2019-08-08 09:26:58 +00:00
|
|
|
{
|
2019-08-09 12:28:19 +00:00
|
|
|
var queryParams = GetUserParamsPair(tenantId, user);
|
2019-08-08 09:26:58 +00:00
|
|
|
|
|
|
|
var url = absolute ? ToAbsolute("~/products/people/") : "/products/people/";
|
|
|
|
url += "profile.aspx?";
|
|
|
|
url += queryParams;
|
|
|
|
|
|
|
|
return url;
|
|
|
|
}
|
2019-06-07 08:59:07 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2019-08-08 09:26:58 +00:00
|
|
|
public static Guid GetProductID(Tenant tenant, HttpContext context)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
var productID = Guid.Empty;
|
|
|
|
|
2019-07-02 15:30:31 +00:00
|
|
|
if (context != null)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-08-16 09:08:46 +00:00
|
|
|
GetLocationByRequest(tenant, out var product, out _, context);
|
2019-06-07 08:59:07 +00:00
|
|
|
if (product != null) productID = product.ID;
|
|
|
|
}
|
|
|
|
|
|
|
|
return productID;
|
|
|
|
}
|
|
|
|
|
2019-08-08 09:26:58 +00:00
|
|
|
public static void GetLocationByRequest(Tenant tenant, out IProduct currentProduct, out IModule currentModule, HttpContext context)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
var currentURL = string.Empty;
|
|
|
|
if (context != null && context.Request != null)
|
|
|
|
{
|
2019-07-02 15:30:31 +00:00
|
|
|
currentURL = context.Request.GetUrlRewriter().AbsoluteUri;
|
2019-06-07 08:59:07 +00:00
|
|
|
|
|
|
|
//TODO ?
|
|
|
|
// http://[hostname]/[virtualpath]/[AjaxPro.Utility.HandlerPath]/[assembly],[classname].ashx
|
|
|
|
//if (currentURL.Contains("/" + AjaxPro.Utility.HandlerPath + "/") && HttpContext.Current.Request.Headers["Referer"].FirstOrDefault() != null)
|
|
|
|
//{
|
|
|
|
// currentURL = HttpContext.Current.Request.Headers["Referer"].FirstOrDefault().ToString();
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
|
2019-08-08 09:26:58 +00:00
|
|
|
GetLocationByUrl(tenant, currentURL, out currentProduct, out currentModule);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static IWebItem GetWebItemByUrl(string currentURL)
|
|
|
|
{
|
2019-08-15 13:16:39 +00:00
|
|
|
if (!string.IsNullOrEmpty(currentURL))
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
var itemName = GetWebItemNameFromUrl(currentURL);
|
|
|
|
if (!string.IsNullOrEmpty(itemName))
|
|
|
|
{
|
|
|
|
foreach (var item in WebItemManager.Instance.GetItemsAll())
|
|
|
|
{
|
|
|
|
var _itemName = GetWebItemNameFromUrl(item.StartURL);
|
2019-08-15 13:16:39 +00:00
|
|
|
if (string.Compare(itemName, _itemName, StringComparison.InvariantCultureIgnoreCase) == 0)
|
2019-06-07 08:59:07 +00:00
|
|
|
return item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var urlParams = HttpUtility.ParseQueryString(new Uri(currentURL).Query);
|
|
|
|
var productByName = GetProductBySysName(urlParams[ParamName_ProductSysName]);
|
|
|
|
var pid = productByName == null ? Guid.Empty : productByName.ID;
|
|
|
|
|
2019-08-15 13:16:39 +00:00
|
|
|
if (pid == Guid.Empty && !string.IsNullOrEmpty(urlParams["pid"]))
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
pid = new Guid(urlParams["pid"]);
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
pid = Guid.Empty;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pid != Guid.Empty)
|
|
|
|
return WebItemManager.Instance[pid];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2019-08-08 09:26:58 +00:00
|
|
|
public static void GetLocationByUrl(Tenant tenant, string currentURL, out IProduct currentProduct, out IModule currentModule)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
currentProduct = null;
|
|
|
|
currentModule = null;
|
|
|
|
|
2019-08-15 13:16:39 +00:00
|
|
|
if (string.IsNullOrEmpty(currentURL)) return;
|
2019-06-07 08:59:07 +00:00
|
|
|
|
|
|
|
var urlParams = HttpUtility.ParseQueryString(new Uri(currentURL).Query);
|
|
|
|
var productByName = GetProductBySysName(urlParams[ParamName_ProductSysName]);
|
|
|
|
var pid = productByName == null ? Guid.Empty : productByName.ID;
|
|
|
|
|
2019-08-15 13:16:39 +00:00
|
|
|
if (pid == Guid.Empty && !string.IsNullOrEmpty(urlParams["pid"]))
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
pid = new Guid(urlParams["pid"]);
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
pid = Guid.Empty;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var productName = GetProductNameFromUrl(currentURL);
|
|
|
|
var moduleName = GetModuleNameFromUrl(currentURL);
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(productName) || !string.IsNullOrEmpty(moduleName))
|
|
|
|
{
|
|
|
|
foreach (var product in WebItemManager.Instance.GetItemsAll<IProduct>())
|
|
|
|
{
|
|
|
|
var _productName = GetProductNameFromUrl(product.StartURL);
|
|
|
|
if (!string.IsNullOrEmpty(_productName))
|
|
|
|
{
|
2019-08-15 13:16:39 +00:00
|
|
|
if (string.Compare(productName, _productName, StringComparison.InvariantCultureIgnoreCase) == 0)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
currentProduct = product;
|
|
|
|
|
2019-08-15 13:16:39 +00:00
|
|
|
if (!string.IsNullOrEmpty(moduleName))
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-08-08 09:26:58 +00:00
|
|
|
foreach (var module in WebItemManager.Instance.GetSubItems(tenant, product.ID).OfType<IModule>())
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
var _moduleName = GetModuleNameFromUrl(module.StartURL);
|
|
|
|
if (!string.IsNullOrEmpty(_moduleName))
|
|
|
|
{
|
2019-08-15 13:16:39 +00:00
|
|
|
if (string.Compare(moduleName, _moduleName, StringComparison.InvariantCultureIgnoreCase) == 0)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
currentModule = module;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-08-08 09:26:58 +00:00
|
|
|
foreach (var module in WebItemManager.Instance.GetSubItems(tenant, product.ID).OfType<IModule>())
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
if (!module.StartURL.Equals(product.StartURL) && currentURL.Contains(RegFilePathTrim.Replace(module.StartURL, string.Empty)))
|
|
|
|
{
|
|
|
|
currentModule = module;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pid != Guid.Empty)
|
|
|
|
currentProduct = WebItemManager.Instance[pid] as IProduct;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static string GetWebItemNameFromUrl(string url)
|
|
|
|
{
|
|
|
|
var name = GetModuleNameFromUrl(url);
|
2019-08-15 13:16:39 +00:00
|
|
|
if (string.IsNullOrEmpty(name))
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
name = GetProductNameFromUrl(url);
|
2019-08-15 13:16:39 +00:00
|
|
|
if (string.IsNullOrEmpty(name))
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var pos = url.IndexOf("/addons/", StringComparison.InvariantCultureIgnoreCase);
|
|
|
|
if (0 <= pos)
|
|
|
|
{
|
|
|
|
url = url.Substring(pos + 8).ToLower();
|
|
|
|
pos = url.IndexOf('/');
|
|
|
|
return 0 < pos ? url.Substring(0, pos) : url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static string GetProductNameFromUrl(string url)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var pos = url.IndexOf("/products/", StringComparison.InvariantCultureIgnoreCase);
|
|
|
|
if (0 <= pos)
|
|
|
|
{
|
|
|
|
url = url.Substring(pos + 10).ToLower();
|
|
|
|
pos = url.IndexOf('/');
|
|
|
|
return 0 < pos ? url.Substring(0, pos) : url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static string GetModuleNameFromUrl(string url)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var pos = url.IndexOf("/modules/", StringComparison.InvariantCultureIgnoreCase);
|
|
|
|
if (0 <= pos)
|
|
|
|
{
|
|
|
|
url = url.Substring(pos + 9).ToLower();
|
|
|
|
pos = url.IndexOf('/');
|
|
|
|
return 0 < pos ? url.Substring(0, pos) : url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static IProduct GetProductBySysName(string sysName)
|
|
|
|
{
|
|
|
|
IProduct result = null;
|
|
|
|
|
2019-08-15 13:16:39 +00:00
|
|
|
if (!string.IsNullOrEmpty(sysName))
|
2019-06-07 08:59:07 +00:00
|
|
|
foreach (var product in WebItemManager.Instance.GetItemsAll<IProduct>())
|
|
|
|
{
|
2019-08-15 13:16:39 +00:00
|
|
|
if (string.CompareOrdinal(sysName, WebItemExtension.GetSysName(product as IWebItem)) == 0)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
result = product;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-08-09 12:28:19 +00:00
|
|
|
public static string GetUserParamsPair(int tenantId, Guid userID)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-08-30 12:40:57 +00:00
|
|
|
return GetUserParamsPair(CoreContext.UserManager.GetUsers(tenantId, userID));
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static string GetUserParamsPair(UserInfo user)
|
|
|
|
{
|
2019-08-30 12:40:57 +00:00
|
|
|
if (user == null || string.IsNullOrEmpty(user.UserName) || !CoreContext.UserManager.UserExists(user))
|
2019-06-07 08:59:07 +00:00
|
|
|
return "";
|
|
|
|
|
2019-08-15 13:16:39 +00:00
|
|
|
return string.Format("{0}={1}", ParamName_UserUserName, HttpUtility.UrlEncode(user.UserName.ToLowerInvariant()));
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#region Help Centr
|
|
|
|
|
|
|
|
public static string GetHelpLink(bool inCurrentCulture = true)
|
|
|
|
{
|
|
|
|
if (!AdditionalWhiteLabelSettings.Instance.HelpCenterEnabled)
|
2019-08-15 13:16:39 +00:00
|
|
|
return string.Empty;
|
2019-06-07 08:59:07 +00:00
|
|
|
|
|
|
|
var url = AdditionalWhiteLabelSettings.DefaultHelpCenterUrl;
|
|
|
|
|
2019-08-15 13:16:39 +00:00
|
|
|
if (string.IsNullOrEmpty(url))
|
|
|
|
return string.Empty;
|
2019-06-07 08:59:07 +00:00
|
|
|
|
|
|
|
return GetRegionalUrl(url, inCurrentCulture ? CultureInfo.CurrentCulture.TwoLetterISOLanguageName : null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static string GetRegionalUrl(string url, string lang)
|
|
|
|
{
|
2019-08-19 13:51:36 +00:00
|
|
|
return BaseCommonLinkUtility.GetRegionalUrl(url, lang);
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region management links
|
|
|
|
|
|
|
|
public static string GetAdministration(ManagementType managementType)
|
|
|
|
{
|
|
|
|
if (managementType == ManagementType.General)
|
|
|
|
return ToAbsolute("~/management.aspx") + string.Empty;
|
|
|
|
|
|
|
|
return ToAbsolute("~/management.aspx") + "?" + "type=" + ((int)managementType).ToString();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region confirm links
|
|
|
|
|
2019-09-03 12:23:58 +00:00
|
|
|
public static string GetConfirmationUrl(int tenantId, string email, ConfirmType confirmType, object postfix = null, Guid userId = default)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-09-03 12:23:58 +00:00
|
|
|
return GetFullAbsolutePath(GetConfirmationUrlRelative(tenantId, email, confirmType, postfix, userId));
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
2019-08-15 13:00:20 +00:00
|
|
|
public static string GetConfirmationUrlRelative(int tenantId, string email, ConfirmType confirmType, object postfix = null, Guid userId = default)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
var validationKey = EmailValidationKeyProvider.GetEmailKey(tenantId, email + confirmType + (postfix ?? ""));
|
|
|
|
|
2019-09-27 08:58:10 +00:00
|
|
|
var link = $"confirm/{confirmType}?key={validationKey}";
|
2019-06-07 08:59:07 +00:00
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(email))
|
|
|
|
{
|
2019-09-09 12:07:15 +00:00
|
|
|
link += $"&email={HttpUtility.UrlEncode(email)}";
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
2019-08-15 13:00:20 +00:00
|
|
|
if (userId != default)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-09-09 12:07:15 +00:00
|
|
|
link += $"&uid={userId}";
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (postfix != null)
|
|
|
|
{
|
|
|
|
link += "&p=1";
|
|
|
|
}
|
|
|
|
|
|
|
|
return link;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|