DocSpace-buildtools/products/ASC.Files/Server/Configuration/ProductEntryPoint.cs

180 lines
6.8 KiB
C#
Raw Normal View History

2020-01-27 11:15:18 +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.Collections.Generic;
using System.Linq;
using System.Reflection;
2020-02-26 11:34:27 +00:00
using ASC.Common;
2020-01-27 11:15:18 +00:00
using ASC.Core;
2020-02-18 08:39:28 +00:00
using ASC.Files.Resources;
2020-01-27 11:15:18 +00:00
using ASC.Web.Core;
2020-02-06 08:56:12 +00:00
using ASC.Web.Core.PublicResources;
2020-01-27 11:15:18 +00:00
using ASC.Web.Files.Classes;
using SubscriptionManager = ASC.Web.Files.Classes.SubscriptionManager;
namespace ASC.Web.Files.Configuration
{
public class ProductEntryPoint : Product
{
public FilesSpaceUsageStatManager FilesSpaceUsageStatManager { get; }
public CoreBaseSettings CoreBaseSettings { get; }
public AuthContext AuthContext { get; }
public UserManager UserManager { get; }
2020-01-31 07:56:40 +00:00
public Global Global { get; }
2020-02-07 10:29:16 +00:00
public SubscriptionManager SubscriptionManager { get; }
2020-01-27 11:15:18 +00:00
public ProductEntryPoint(
FilesSpaceUsageStatManager filesSpaceUsageStatManager,
CoreBaseSettings coreBaseSettings,
AuthContext authContext,
2020-01-31 07:56:40 +00:00
UserManager userManager,
2020-02-07 10:29:16 +00:00
Global global,
SubscriptionManager subscriptionManager)
2020-01-27 11:15:18 +00:00
{
FilesSpaceUsageStatManager = filesSpaceUsageStatManager;
CoreBaseSettings = coreBaseSettings;
AuthContext = authContext;
UserManager = userManager;
2020-01-31 07:56:40 +00:00
Global = global;
2020-02-07 10:29:16 +00:00
SubscriptionManager = subscriptionManager;
2020-01-27 11:15:18 +00:00
}
public static readonly Guid ID = WebItemManager.DocumentsProductID;
private ProductContext _productContext;
public override bool Visible { get { return true; } }
public override void Init()
{
2020-02-06 08:56:12 +00:00
List<string> adminOpportunities() => (CoreBaseSettings.CustomMode
2020-01-27 11:15:18 +00:00
? CustomModeResource.ProductAdminOpportunitiesCustomMode
: FilesCommonResource.ProductAdminOpportunities).Split('|').ToList();
2020-02-06 08:56:12 +00:00
List<string> userOpportunities() => (CoreBaseSettings.CustomMode
2020-01-27 11:15:18 +00:00
? CustomModeResource.ProductUserOpportunitiesCustomMode
: FilesCommonResource.ProductUserOpportunities).Split('|').ToList();
_productContext =
new ProductContext
{
DisabledIconFileName = "product_disabled_logo.png",
IconFileName = "product_logo.png",
2020-02-25 11:47:50 +00:00
LargeIconFileName = "images/files.svg",
2020-01-27 11:15:18 +00:00
DefaultSortOrder = 10,
2020-02-07 10:29:16 +00:00
SubscriptionManager = SubscriptionManager,
2020-01-27 11:15:18 +00:00
SpaceUsageStatManager = FilesSpaceUsageStatManager,
AdminOpportunities = adminOpportunities,
UserOpportunities = userOpportunities,
CanNotBeDisabled = true,
};
//SearchHandlerManager.Registry(new SearchHandler());
}
public string GetModuleResource(string ResourceClassTypeName, string ResourseKey)
{
if (string.IsNullOrEmpty(ResourseKey)) return string.Empty;
try
{
return (string)Type.GetType(ResourceClassTypeName).GetProperty(ResourseKey, BindingFlags.Static | BindingFlags.Public).GetValue(null, null);
}
catch (Exception)
{
return string.Empty;
}
}
public override Guid ProductID
{
get { return ID; }
}
public override string Name
{
get { return FilesCommonResource.ProductName; }
}
public override string Description
{
get
{
var id = AuthContext.CurrentAccount.ID;
if (UserManager.IsUserInGroup(id, ASC.Core.Users.Constants.GroupVisitor.ID))
return FilesCommonResource.ProductDescriptionShort;
if (UserManager.IsUserInGroup(id, ASC.Core.Users.Constants.GroupAdmin.ID) || UserManager.IsUserInGroup(id, ID))
return FilesCommonResource.ProductDescriptionEx;
return FilesCommonResource.ProductDescription;
}
}
public override string StartURL
{
get { return PathProvider.StartURL; }
}
public override string HelpURL
{
get { return PathProvider.StartURL; }
}
public override string ProductClassName
{
get { return "documents"; }
}
public override ProductContext Context
{
get { return _productContext; }
}
public override string ApiURL
{
2020-02-26 10:01:12 +00:00
get => "api/2.0/documents/info.json";
2020-01-27 11:15:18 +00:00
}
}
2020-02-26 11:34:27 +00:00
public static class ProductEntryPointExtention
{
public static DIHelper AddProductEntryPointService(this DIHelper services)
{
services.TryAddScoped<ProductEntryPoint>();
return services
.AddFilesSpaceUsageStatManagerService()
.AddCoreBaseSettingsService()
.AddAuthContextService()
.AddUserManagerService()
.AddGlobalService()
.AddFilesSubscriptionManagerService();
}
}
2020-01-27 11:15:18 +00:00
}