diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index 80899c0a..796722b9 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -4523,6 +4523,12 @@ CREATE TABLE SupportServiceLevels ) GO +IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='ExchangeAccounts' AND COLS.name='LevelID') +ALTER TABLE [dbo].[ExchangeAccounts] ADD + [LevelID] [int] NULL, + [IsVIP] [bit] NOT NULL DEFAULT 0 +GO + IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetSupportServiceLevels') DROP PROCEDURE GetSupportServiceLevels GO @@ -4707,13 +4713,7 @@ END RETURN GO -IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='ExchangeAccounts' AND COLS.name='LevelID') -BEGIN -ALTER TABLE [dbo].[ExchangeAccounts] ADD - [LevelID] [int] NULL, - [IsVIP] [bit] NOT NULL DEFAULT 0 -END -GO + IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type IN ('FN', 'IF', 'TF') AND name = 'GetPackageServiceLevelResource') DROP FUNCTION GetPackageServiceLevelResource diff --git a/WebsitePanel/Sources/Tools/WebsitePanel.Import.CsvBulk/ExchangeImport.cs b/WebsitePanel/Sources/Tools/WebsitePanel.Import.CsvBulk/ExchangeImport.cs index 35b5a7cb..4988105d 100644 --- a/WebsitePanel/Sources/Tools/WebsitePanel.Import.CsvBulk/ExchangeImport.cs +++ b/WebsitePanel/Sources/Tools/WebsitePanel.Import.CsvBulk/ExchangeImport.cs @@ -618,7 +618,7 @@ namespace WebsitePanel.Import.CsvBulk mailbox.JobTitle, mailbox.Company, mailbox.Department, mailbox.Office, null, mailbox.BusinessPhone, mailbox.Fax, mailbox.HomePhone, mailbox.MobilePhone, mailbox.Pager, mailbox.WebPage, mailbox.Notes, // these are new and not in csv ... - mailbox.ExternalEmail, mailbox.SubscriberNumber); + mailbox.ExternalEmail, mailbox.SubscriberNumber,mailbox.LevelId, mailbox.IsVIP); ret = true; } catch (Exception ex) @@ -762,7 +762,7 @@ namespace WebsitePanel.Import.CsvBulk null, false, user.Disabled, user.Locked, user.FirstName, user.Initials, user.LastName, user.Address, user.City, user.State, user.Zip, user.Country, user.JobTitle, user.Company, user.Department, user.Office, null, user.BusinessPhone, - user.Fax, user.HomePhone, user.MobilePhone, user.Pager, user.WebPage, user.Notes, user.ExternalEmail, user.SubscriberNumber); + user.Fax, user.HomePhone, user.MobilePhone, user.Pager, user.WebPage, user.Notes, user.ExternalEmail, user.SubscriberNumber, user.LevelId, user.IsVIP); ret = true; } catch (Exception ex) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Themes/Default/Images/Exchange/vip_user_16.png b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Themes/Default/Images/Exchange/vip_user_16.png new file mode 100644 index 00000000..e470ca6e Binary files /dev/null and b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Themes/Default/Images/Exchange/vip_user_16.png differ diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx index 9425e414..ee7a1c81 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx @@ -61,7 +61,6 @@ - <%# Eval("DisplayName") %> diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx.cs index 4764dd12..6473cd61 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx.cs @@ -45,6 +45,8 @@ namespace WebsitePanel.Portal.ExchangeServer } } + private PackageContext cntx; + private ServiceLevel[] ServiceLevels; protected void Page_Load(object sender, EventArgs e) @@ -60,7 +62,7 @@ namespace WebsitePanel.Portal.ExchangeServer BindServiceLevels(); - PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId); + cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId); if (cntx.Quotas.ContainsKey(Quotas.EXCHANGE2007_ISCONSUMER)) { if (cntx.Quotas[Quotas.EXCHANGE2007_ISCONSUMER].QuotaAllocatedValue != 1) @@ -122,7 +124,7 @@ namespace WebsitePanel.Portal.ExchangeServer else if (accountType == ExchangeAccountType.Equipment) imgName = "equipment_16.gif"; - if (vip) imgName = "admin_16.png"; + if (vip && cntx.Groups.ContainsKey(ResourceGroups.ServiceLevels)) imgName = "vip_user_16.png"; return GetThemedImage("Exchange/" + imgName); } @@ -197,7 +199,21 @@ namespace WebsitePanel.Portal.ExchangeServer public ServiceLevel GetServiceLevel(int levelId) { - return ServiceLevels.Where(x => x.LevelId == levelId).DefaultIfEmpty(new ServiceLevel { LevelName = "", LevelDescription = "" }).FirstOrDefault(); + ServiceLevel serviceLevel = ServiceLevels.Where(x => x.LevelId == levelId).DefaultIfEmpty(new ServiceLevel { LevelName = "", LevelDescription = "" }).FirstOrDefault(); + + bool enable = !string.IsNullOrEmpty(serviceLevel.LevelName); + + enable = enable ? cntx.Quotas.ContainsKey(Quotas.SERVICE_LEVELS + serviceLevel.LevelName) : false; + enable = enable ? cntx.Quotas[Quotas.SERVICE_LEVELS + serviceLevel.LevelName].QuotaAllocatedValue > 0 : false; + + if (!enable) + { + serviceLevel.LevelName = ""; + serviceLevel.LevelDescription = ""; + } + + //return ServiceLevels.Where(x => x.LevelId == levelId).DefaultIfEmpty(new ServiceLevel { LevelName = "", LevelDescription = "" }).FirstOrDefault(); + return serviceLevel; } } } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserGeneralSettings.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserGeneralSettings.ascx.cs index b8c6c70c..1c04de23 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserGeneralSettings.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserGeneralSettings.ascx.cs @@ -86,17 +86,7 @@ namespace WebsitePanel.Portal.HostedSolution txtInitials.Text = user.Initials; txtLastName.Text = user.LastName; - if (user.LevelId > 0 && secServiceLevels.Visible) - { - ServiceLevel serviceLevel = ES.Services.Organizations.GetSupportServiceLevel(user.LevelId); - if (ddlServiceLevels.Items.FindByValue(serviceLevel.LevelId.ToString()) == null) - ddlServiceLevels.Items.Add(new ListItem(serviceLevel.LevelName, serviceLevel.LevelId.ToString())); - - ddlServiceLevels.Items.FindByValue(string.Empty).Selected = false; - ddlServiceLevels.Items.FindByValue(serviceLevel.LevelId.ToString()).Selected = true; - } - chkVIP.Checked = user.IsVIP && secServiceLevels.Visible; txtJobTitle.Text = user.JobTitle; txtCompany.Text = user.Company; @@ -136,6 +126,26 @@ namespace WebsitePanel.Portal.HostedSolution } } + if (user.LevelId > 0 && secServiceLevels.Visible) + { + ServiceLevel serviceLevel = ES.Services.Organizations.GetSupportServiceLevel(user.LevelId); + + bool addLevel = ddlServiceLevels.Items.FindByValue(serviceLevel.LevelId.ToString()) == null; + + addLevel = addLevel && cntx.Quotas.ContainsKey(Quotas.SERVICE_LEVELS + serviceLevel.LevelName); + + addLevel = addLevel ? cntx.Quotas[Quotas.SERVICE_LEVELS + serviceLevel.LevelName].QuotaAllocatedValue > 0 : addLevel; + + if (addLevel) + { + ddlServiceLevels.Items.Add(new ListItem(serviceLevel.LevelName, serviceLevel.LevelId.ToString())); + + ddlServiceLevels.Items.FindByValue(string.Empty).Selected = false; + ddlServiceLevels.Items.FindByValue(serviceLevel.LevelId.ToString()).Selected = true; + } + } + chkVIP.Checked = user.IsVIP && secServiceLevels.Visible; + if (cntx.Quotas.ContainsKey(Quotas.ORGANIZATION_ALLOWCHANGEUPN)) { diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx index ea25b612..6b8ba886 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx @@ -62,7 +62,6 @@ - <%# Eval("DisplayName") %> diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx.cs index 9ed6f6d7..ffe51701 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx.cs @@ -39,6 +39,7 @@ namespace WebsitePanel.Portal.HostedSolution public partial class OrganizationUsers : WebsitePanelModuleBase { private ServiceLevel[] ServiceLevels; + private PackageContext cntx; protected void Page_Load(object sender, EventArgs e) { @@ -49,7 +50,7 @@ namespace WebsitePanel.Portal.HostedSolution BindServiceLevels(); - PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId); + cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId); if (cntx.Quotas.ContainsKey(Quotas.EXCHANGE2007_ISCONSUMER)) { if (cntx.Quotas[Quotas.EXCHANGE2007_ISCONSUMER].QuotaAllocatedValue != 1) @@ -191,7 +192,7 @@ namespace WebsitePanel.Portal.HostedSolution imgName = "admin_16.png"; break; } - if (vip) imgName = "admin_16.png"; + if (vip && cntx.Groups.ContainsKey(ResourceGroups.ServiceLevels)) imgName = "vip_user_16.png"; return GetThemedImage("Exchange/" + imgName); } @@ -311,7 +312,21 @@ namespace WebsitePanel.Portal.HostedSolution public ServiceLevel GetServiceLevel(int levelId) { - return ServiceLevels.Where(x => x.LevelId == levelId).DefaultIfEmpty(new ServiceLevel { LevelName = "", LevelDescription = "" }).FirstOrDefault(); + ServiceLevel serviceLevel = ServiceLevels.Where(x => x.LevelId == levelId).DefaultIfEmpty(new ServiceLevel { LevelName = "", LevelDescription = "" }).FirstOrDefault(); + + bool enable = !string.IsNullOrEmpty(serviceLevel.LevelName); + + enable = enable ? cntx.Quotas.ContainsKey(Quotas.SERVICE_LEVELS + serviceLevel.LevelName) : false; + enable = enable ? cntx.Quotas[Quotas.SERVICE_LEVELS + serviceLevel.LevelName].QuotaAllocatedValue > 0 : false; + + if (!enable) + { + serviceLevel.LevelName = ""; + serviceLevel.LevelDescription = ""; + } + + //return ServiceLevels.Where(x => x.LevelId == levelId).DefaultIfEmpty(new ServiceLevel { LevelName = "", LevelDescription = "" }).FirstOrDefault(); + return serviceLevel; } } } \ No newline at end of file