From 02c59802db5bf5db6411d72e36d103bf5ab238f9 Mon Sep 17 00:00:00 2001 From: robvde Date: Mon, 3 Sep 2012 17:29:59 +0400 Subject: [PATCH] Tighten the ResellerCSR and PlatformCSR roles and give them the capabilities to update chargeable items such as plan assignement and add ons Fixed plan quota viewer that got broken with last commit --- .../Code/Packages/PackageController.cs | 27 ++++++++++ .../App_Data/SiteSettings.config | 1 + .../App_Data/WebsitePanel_Pages.config | 50 +++++++++---------- .../WebsitePanel_SharedResources.ascx.resx | 3 ++ .../Code/PortalUtils.cs | 15 ++++++ .../ExchangeDomainNames.ascx.cs | 5 +- .../WebsitePanel/SpaceEditDetails.ascx.cs | 18 +++++++ .../WebsitePanel/SpaceQuotasControl.ascx | 3 +- .../WebsitePanel/SpaceQuotasControl.ascx.cs | 3 ++ .../SpaceQuotasControl.ascx.designer.cs | 3 +- .../UserAccountEditDetails.ascx.cs | 3 +- .../WebsitePanel/UserControls/Quota.ascx.cs | 2 + .../WebsitePanel/UserCreateSpace.ascx.cs | 4 ++ .../UserCreateUserAccount.ascx.cs | 5 ++ 14 files changed, 111 insertions(+), 31 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Packages/PackageController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Packages/PackageController.cs index 24b440d5..7e6a729a 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Packages/PackageController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Packages/PackageController.cs @@ -719,6 +719,15 @@ namespace WebsitePanel.EnterpriseServer // check account result.Result = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive | DemandAccount.IsReseller); + + if (result.Result < 0) + result.Result = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive + | DemandAccount.IsPlatformCSR); + + if (result.Result < 0) + result.Result = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive + | DemandAccount.IsResellerCSR); + if (result.Result < 0) return result; // load package @@ -979,6 +988,15 @@ namespace WebsitePanel.EnterpriseServer // check account result.Result = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive | DemandAccount.IsReseller); + + if (result.Result < 0) + result.Result = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive + | DemandAccount.IsPlatformCSR); + + if (result.Result < 0) + result.Result = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive + | DemandAccount.IsResellerCSR); + if (result.Result < 0) return result; int addonId = 0; @@ -1004,6 +1022,15 @@ namespace WebsitePanel.EnterpriseServer // check account result.Result = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive | DemandAccount.IsReseller); + + if (result.Result < 0) + result.Result = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive + | DemandAccount.IsPlatformCSR); + + if (result.Result < 0) + result.Result = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive + | DemandAccount.IsResellerCSR); + if (result.Result < 0) return result; result.ExceedingQuotas = DataProvider.UpdatePackageAddon(SecurityContext.User.UserId, addon.PackageAddonId, diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/SiteSettings.config b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/SiteSettings.config index 0a99be01..36e107ed 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/SiteSettings.config +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/SiteSettings.config @@ -37,4 +37,5 @@ Edit.ascx false + true diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Pages.config b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Pages.config index 0dce0ea2..9143f106 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Pages.config +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Pages.config @@ -197,7 +197,7 @@ - + @@ -289,12 +289,12 @@ - + - + @@ -309,12 +309,12 @@ - + - + @@ -329,12 +329,12 @@ - + - + @@ -349,12 +349,12 @@ - + - + @@ -369,12 +369,12 @@ - + - + @@ -389,12 +389,12 @@ - + - + @@ -409,7 +409,7 @@ - + @@ -420,7 +420,7 @@ - + @@ -431,7 +431,7 @@ - + @@ -442,7 +442,7 @@ - + @@ -453,7 +453,7 @@ - + @@ -464,7 +464,7 @@ - + @@ -478,7 +478,7 @@ - + @@ -489,8 +489,8 @@ - - + + @@ -500,19 +500,19 @@ 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 45518d8f..89300fac 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx @@ -975,6 +975,9 @@ You should have Reseller priviledges to perform this operation + + You have not enough priviledges to perform this operation + Web Site does not exist diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/Code/PortalUtils.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/Code/PortalUtils.cs index 7e6bc2fb..45099e45 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/Code/PortalUtils.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/Code/PortalUtils.cs @@ -404,6 +404,21 @@ namespace WebsitePanel.Portal return bResult; } + public static bool GetHideDemoCheckbox() + { + bool bResult = false; + + try + { + bResult = Convert.ToBoolean(PortalConfiguration.SiteSettings["HideDemoCheckbox"]); + } + catch (Exception) + { + + } + + return bResult; + } private static int GetAuthenticationFormsTimeout() diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeDomainNames.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeDomainNames.ascx.cs index 6a2caaed..f950f5b9 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeDomainNames.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeDomainNames.ascx.cs @@ -51,10 +51,11 @@ namespace WebsitePanel.Portal.ExchangeServer private void BindStats() { // set quotas - OrganizationStatistics stats = - ES.Services.Organizations.GetOrganizationStatistics(PanelRequest.ItemID); + OrganizationStatistics stats = ES.Services.Organizations.GetOrganizationStatisticsByOrganization(PanelRequest.ItemID); + OrganizationStatistics tenantStats = ES.Services.Organizations.GetOrganizationStatistics(PanelRequest.ItemID); domainsQuota.QuotaUsedValue = stats.CreatedDomains; domainsQuota.QuotaValue = stats.AllocatedDomains; + if (stats.AllocatedDomains != -1) domainsQuota.QuotaAvailable = tenantStats.AllocatedDomains - tenantStats.CreatedDomains; } public string GetDomainRecordsEditUrl(string domainId) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SpaceEditDetails.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SpaceEditDetails.ascx.cs index a6aa62dc..6fdb3eeb 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SpaceEditDetails.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SpaceEditDetails.ascx.cs @@ -40,9 +40,27 @@ namespace WebsitePanel.Portal { BindSpace(); BindSpaceAddons(); + BindRoles(PanelSecurity.EffectiveUserId); } } + private void BindRoles(int userId) + { + // load selected user + UserInfo user = UsersHelper.GetUser(userId); + + if (user != null) + { + if ((user.Role == UserRole.User) | + (PanelSecurity.LoggedUser.Role == UserRole.ResellerCSR) | + (PanelSecurity.LoggedUser.Role == UserRole.ResellerHelpdesk) | + (PanelSecurity.LoggedUser.Role == UserRole.PlatformCSR) | + (PanelSecurity.LoggedUser.Role == UserRole.PlatformHelpdesk)) + this.rbPackageQuotas.Enabled = this.rbPlanQuotas.Enabled = false; + } + } + + private void BindSpace() { PackageInfo package = ES.Services.Packages.GetPackage(PanelSecurity.PackageId); diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SpaceQuotasControl.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SpaceQuotasControl.ascx index fcb26d65..dd82036b 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SpaceQuotasControl.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SpaceQuotasControl.ascx @@ -19,7 +19,8 @@ + QuotaValue='<%# Eval("QuotaValue") %>' + QuotaAvailable='<%# Eval("QuotaAvailable") %>'/> diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SpaceQuotasControl.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SpaceQuotasControl.ascx.cs index 036b2613..4abe68d6 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SpaceQuotasControl.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SpaceQuotasControl.ascx.cs @@ -54,6 +54,9 @@ namespace WebsitePanel.Portal try { dsQuotas = ES.Services.Packages.GetPackageQuotas(packageId); + dsQuotas.Tables[1].Columns.Add("QuotaAvailable", typeof(int)); + foreach (DataRow r in dsQuotas.Tables[1].Rows) r["QuotaAvailable"] = -1; + dlGroups.DataSource = dsQuotas.Tables[0]; dlGroups.DataBind(); } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SpaceQuotasControl.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SpaceQuotasControl.ascx.designer.cs index 4389d0db..78fb2cc0 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SpaceQuotasControl.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SpaceQuotasControl.ascx.designer.cs @@ -1,10 +1,9 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.3074 // // Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// the code is regenerated. // //------------------------------------------------------------------------------ diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserAccountEditDetails.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserAccountEditDetails.ascx.cs index 07c4bbb5..43906bb2 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserAccountEditDetails.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserAccountEditDetails.ascx.cs @@ -191,7 +191,8 @@ namespace WebsitePanel.Portal { if (user.Role == UserRole.Reseller || user.Role == UserRole.User) role.Items.Remove("Administrator"); - if (user.Role == UserRole.User) + if ((user.Role == UserRole.User) |(PanelSecurity.LoggedUser.Role == UserRole.ResellerCSR) | + (PanelSecurity.LoggedUser.Role == UserRole.ResellerHelpdesk)) role.Items.Remove("Reseller"); } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/Quota.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/Quota.ascx.cs index a4e8fb7e..0931504d 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/Quota.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/Quota.ascx.cs @@ -77,6 +77,7 @@ namespace WebsitePanel.Portal quotaViewer.QuotaTypeId = quota.QuotaTypeId; quotaViewer.QuotaUsedValue = quota.QuotaUsedValue; quotaViewer.QuotaValue = quota.QuotaAllocatedValue; + quotaViewer.QuotaAvailable = -1; //this.Visible = quota.QuotaAllocatedValue != 0; } else @@ -85,6 +86,7 @@ namespace WebsitePanel.Portal quotaViewer.QuotaTypeId = 1; // bool quotaViewer.QuotaUsedValue = 0; quotaViewer.QuotaValue = 0; + quotaViewer.QuotaAvailable = -1; } } catch diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserCreateSpace.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserCreateSpace.ascx.cs index 38026cac..cda7fe79 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserCreateSpace.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserCreateSpace.ascx.cs @@ -74,6 +74,10 @@ namespace WebsitePanel.Portal if (!createResources) return; + if ((PanelSecurity.LoggedUser.Role == UserRole.ResellerCSR) | + (PanelSecurity.LoggedUser.Role == UserRole.ResellerHelpdesk)) + this.chkCreateResources.Enabled = this.chkIntegratedOUProvisioning.Enabled = false; + bool systemEnabled = false; bool webEnabled = false; diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserCreateUserAccount.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserCreateUserAccount.ascx.cs index 229ae889..32eab9cb 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserCreateUserAccount.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserCreateUserAccount.ascx.cs @@ -62,6 +62,7 @@ namespace WebsitePanel.Portal bool accountSummaryEmailEnabled = !String.IsNullOrEmpty(settings["EnableLetter"]) && Utils.ParseBool(settings["EnableLetter"], false); this.chkAccountLetter.Enabled = accountSummaryEmailEnabled; this.pnlDisabledSummaryLetterHint.Visible = !accountSummaryEmailEnabled; + if (PortalUtils.GetHideDemoCheckbox()) this.lblDemoAccount.Visible = this.chkDemo.Checked = this.chkDemo.Visible = false; //reseller.UserId = PanelSecurity.SelectedUserId; userPassword.SetUserPolicy(PanelSecurity.SelectedUserId, UserSettings.WEBSITEPANEL_POLICY, "PasswordPolicy"); @@ -71,6 +72,10 @@ namespace WebsitePanel.Portal { if (user.Role == UserRole.User) role.Items.Remove("Reseller"); + + if ((PanelSecurity.LoggedUser.Role == UserRole.ResellerCSR) | + (PanelSecurity.LoggedUser.Role == UserRole.ResellerHelpdesk)) + role.Items.Remove("Reseller"); } private void SaveUser()