From 0b31970c7143e647a6d5981d1f3d003bf7ccc49d Mon Sep 17 00:00:00 2001 From: robvde Date: Mon, 10 Sep 2012 21:26:38 +0400 Subject: [PATCH] Extended hosting plans (quotas) option to block tenant from creating and deleting top domains. --- WebsitePanel/Database/install_db.sql | 3 +++ WebsitePanel/Database/update_db.sql | 5 +++++ .../Packages/Quotas.cs | 1 + .../Sources/WebsitePanel.EnterpriseServer.sln | 3 +-- WebsitePanel/Sources/WebsitePanel.WebPortal.sln | 3 +-- .../WebsitePanel_SharedResources.ascx.resx | 3 +++ .../DomainsAddDomainSelectType.ascx.cs | 15 +++++++++++++++ .../WebsitePanel/DomainsEditDomain.ascx.cs | 14 ++++++++++++++ 8 files changed, 43 insertions(+), 4 deletions(-) diff --git a/WebsitePanel/Database/install_db.sql b/WebsitePanel/Database/install_db.sql index cd015077..a8b29b45 100644 --- a/WebsitePanel/Database/install_db.sql +++ b/WebsitePanel/Database/install_db.sql @@ -4063,6 +4063,9 @@ INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDe GO INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) VALUES (400, 20, 3, N'HostedSharePoint.UseSharedSSL', N'Use shared SSL Root', 1, 0, NULL) GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) VALUES (410, 1, 12, N'OS.AllowTenantCreateDomains', N'Allow Tenants to Create Top Level Domains', 1, 0, NULL) +GO + SET ANSI_NULLS ON GO diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index 7477ecd3..a19a94b4 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -467,6 +467,11 @@ END GO +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'OS.AllowTenantCreateDomains') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) VALUES (410, 1, 12, N'OS.AllowTenantCreateDomains', N'Allow Tenants to Create Top Level Domains', 1, 0, NULL) +END +GO DELETE FROM [dbo].[PackageQuotas] WHERE [QuotaID] IN (SELECT [QuotaID] FROM [dbo].[Quotas] WHERE [QuotaName] = N'Exchange2007.POP3Enabled') diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs index 2922d7c7..49d6bc9d 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs @@ -50,6 +50,7 @@ order by rg.groupOrder public const string OS_MINIMUMTASKINTERVAL = "OS.MinimumTaskInterval"; // Minimum Tasks Interval, minutes public const string OS_APPINSTALLER = "OS.AppInstaller"; // Applications Installer public const string OS_EXTRAAPPLICATIONS = "OS.ExtraApplications"; // Extra Application Packs + public const string OS_ALLOWTENANTCREATEDOMAINS = "OS.AllowTenantCreateDomains"; // Allow tenant to create top level domains public const string WEB_SITES = "Web.Sites"; // Web Sites public const string WEB_ASPNET11 = "Web.AspNet11"; // ASP.NET 1.1 public const string WEB_ASPNET20 = "Web.AspNet20"; // ASP.NET 2.0 diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.sln b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.sln index 55e84608..f28eaeef 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.sln +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.sln @@ -1,5 +1,5 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 +# Visual Studio 2010 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C57D3F9F-7BA0-4D38-A159-B6EDA5C19B13}" ProjectSection(SolutionItems) = preProject ..\Database\install_db.sql = ..\Database\install_db.sql @@ -7,7 +7,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\..\Readme.htm = ..\..\Readme.htm ..\..\ReleaseNotes.htm = ..\..\ReleaseNotes.htm ..\Database\update_db.sql = ..\Database\update_db.sql - VersionInfo.cs = VersionInfo.cs VersionInfo.vb = VersionInfo.vb EndProjectSection EndProject diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal.sln b/WebsitePanel/Sources/WebsitePanel.WebPortal.sln index c027a445..bacd747a 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal.sln +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal.sln @@ -1,11 +1,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 +# Visual Studio 2010 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{BB38798E-1528-493C-868E-005102316536}" ProjectSection(SolutionItems) = preProject ..\..\LICENSE.txt = ..\..\LICENSE.txt ..\..\Readme.htm = ..\..\Readme.htm ..\..\ReleaseNotes.htm = ..\..\ReleaseNotes.htm - VersionInfo.cs = VersionInfo.cs VersionInfo.vb = VersionInfo.vb EndProjectSection EndProject diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx index 89300fac..3dbe097a 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx @@ -1590,6 +1590,9 @@ File Manager + + Tenant Top-Level Domain creation Allowed + SharePoint Groups diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsAddDomainSelectType.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsAddDomainSelectType.ascx.cs index 5a844226..91a8bd2f 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsAddDomainSelectType.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsAddDomainSelectType.ascx.cs @@ -55,6 +55,21 @@ namespace WebsitePanel.Portal DomainLink.Enabled = (cntx.Quotas.ContainsKey(Quotas.OS_DOMAINS) && !cntx.Quotas[Quotas.OS_DOMAINS].QuotaExhausted); + if (DomainLink.Enabled) + { + UserInfo user = UsersHelper.GetUser(PanelSecurity.EffectiveUserId); + + if (user != null) + { + if (user.Role == UserRole.User) + { + DomainLink.Enabled = Utils.CheckQouta(Quotas.OS_ALLOWTENANTCREATEDOMAINS, cntx); + } + } + } + + + DomainInfo[] myDomains = ES.Services.Servers.GetMyDomains(PanelSecurity.PackageId); bool enableSubDomains = false; foreach(DomainInfo domain in myDomains) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsEditDomain.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsEditDomain.ascx.cs index 98698245..4fc70883 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsEditDomain.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsEditDomain.ascx.cs @@ -142,6 +142,20 @@ namespace WebsitePanel.Portal { ResellersPanel.Visible = true; } + + if (!(domain.IsDomainPointer || domain.IsSubDomain || domain.IsInstantAlias)) + { + UserInfo user = UsersHelper.GetUser(PanelSecurity.EffectiveUserId); + + if (user != null) + { + if (user.Role == UserRole.User) + { + btnDelete.Enabled = Utils.CheckQouta(Quotas.OS_ALLOWTENANTCREATEDOMAINS, cntx); + } + } + } + } catch (Exception ex) {