Narrowed down the capabilities of peer accounts within a consumer organization

This commit is contained in:
robvde 2012-09-04 15:07:38 +04:00
parent f4dfdd7b01
commit ba71e9b29c
11 changed files with 177 additions and 69 deletions

View file

@ -39,6 +39,7 @@ using System.Globalization;
using System.Text.RegularExpressions;
using System.Security.Cryptography;
using WebsitePanel.EnterpriseServer;
namespace WebsitePanel.Portal
{
@ -286,5 +287,13 @@ namespace WebsitePanel.Portal
return sb.ToString();
}
public static bool CheckQouta(string key, PackageContext cntx)
{
return cntx.Quotas.ContainsKey(key) &&
((cntx.Quotas[key].QuotaAllocatedValue == 1 && cntx.Quotas[key].QuotaTypeId == 1) ||
(cntx.Quotas[key].QuotaTypeId != 1 && (cntx.Quotas[key].QuotaAllocatedValue > 0 || cntx.Quotas[key].QuotaAllocatedValue == -1)));
}
}
}

View file

@ -39,10 +39,30 @@ namespace WebsitePanel.Portal.ExchangeServer
if (!IsPostBack)
{
BindSettings();
UserInfo user = UsersHelper.GetUser(PanelSecurity.EffectiveUserId);
if (user != null)
{
PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
if ((user.Role == UserRole.User) & (Utils.CheckQouta(Quotas.EXCHANGE2007_ISCONSUMER, cntx)))
{
chkHideAddressBook.Visible = false;
chkDisable.Visible = false;
}
}
}
}
private bool CheckQouta(string key, PackageContext cntx)
{
return cntx.Quotas.ContainsKey(key) &&
((cntx.Quotas[key].QuotaAllocatedValue == 1 && cntx.Quotas[key].QuotaTypeId == 1) ||
(cntx.Quotas[key].QuotaTypeId != 1 && (cntx.Quotas[key].QuotaAllocatedValue > 0 || cntx.Quotas[key].QuotaAllocatedValue == -1)));
}
private void BindSettings()
{
try

View file

@ -48,6 +48,7 @@
</table>
<br />
<table width="100%">
<asp:Panel runat="server" ID="organizationStatsPanel">
<tr>
<td class="OrgStatsGroup" width="100%" colspan="2">
<asp:Localize ID="locHeadStatistics" runat="server" meta:resourcekey="locHeadStatistics"
@ -72,6 +73,7 @@
<wsp:QuotaViewer ID="userStats" QuotaTypeId="2" runat="server" DisplayGauge="true" />
</td>
</tr>
</asp:Panel>
<asp:Panel runat="server" ID="exchangeStatsPanel">
<tr>
<td class="OrgStatsGroup" width="100%" colspan="2">
@ -110,7 +112,7 @@
<wsp:QuotaViewer ID="foldersStats" QuotaTypeId="2" runat="server" DisplayGauge="true" />
</td>
</tr>
<tr class="OrgStatsRow">
<tr class="OrgStatsRow" id="rowExchangeStorage" runat="server">
<td align="right" nowrap>
<asp:HyperLink ID="lnkExchangeStorage" runat="server" meta:resourcekey="lnkExchangeStorage"></asp:HyperLink>
</td>

View file

@ -43,7 +43,7 @@ namespace WebsitePanel.Portal.ExchangeServer
}
private void BindExchangeStats()
private void BindExchangeStats(bool hideItems)
{
OrganizationStatistics exchangeOrgStats = ES.Services.ExchangeServer.GetOrganizationStatisticsByOrganization(PanelRequest.ItemID);
OrganizationStatistics exchangeTenantStats = ES.Services.ExchangeServer.GetOrganizationStatistics(PanelRequest.ItemID);
@ -84,9 +84,14 @@ namespace WebsitePanel.Portal.ExchangeServer
if (exchangeOrgStats.AllocatedDistributionLists != -1) listsStats.QuotaAvailable = exchangeTenantStats.AllocatedDistributionLists - exchangeTenantStats.CreatedDistributionLists;
}
exchangeStorageStats.QuotaUsedValue = exchangeOrgStats.UsedDiskSpace;
exchangeStorageStats.QuotaValue = exchangeOrgStats.AllocatedDiskSpace;
if (exchangeOrgStats.AllocatedDiskSpace != -1) exchangeStorageStats.QuotaAvailable = exchangeTenantStats.AllocatedDiskSpace - exchangeTenantStats.UsedDiskSpace;
if (!hideItems)
{
exchangeStorageStats.QuotaUsedValue = exchangeOrgStats.UsedDiskSpace;
exchangeStorageStats.QuotaValue = exchangeOrgStats.AllocatedDiskSpace;
if (exchangeOrgStats.AllocatedDiskSpace != -1) exchangeStorageStats.QuotaAvailable = exchangeTenantStats.AllocatedDiskSpace - exchangeTenantStats.UsedDiskSpace;
}
else
this.rowExchangeStorage.Style.Add("display", "none");
if (exchangeTenantStats.AllocatedPublicFolders == 0) this.rowFolders.Style.Add("display", "none");
else
@ -100,42 +105,59 @@ namespace WebsitePanel.Portal.ExchangeServer
private void BindOrgStats()
{
Organization org = ES.Services.Organizations.GetOrganization(PanelRequest.ItemID);
PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
bool hideItems = false;
UserInfo user = UsersHelper.GetUser(PanelSecurity.EffectiveUserId);
if (user != null)
{
if ((user.Role == UserRole.User) & (Utils.CheckQouta(Quotas.EXCHANGE2007_ISCONSUMER, cntx)))
hideItems = true;
}
lblOrganizationNameValue.Text = org.Name;
lblOrganizationIDValue.Text = org.OrganizationId;
lblCreatedValue.Text = org.CreatedDate.Date.ToShortDateString();
OrganizationStatistics orgStats = ES.Services.Organizations.GetOrganizationStatisticsByOrganization(PanelRequest.ItemID);
OrganizationStatistics tenantStats = ES.Services.Organizations.GetOrganizationStatistics(PanelRequest.ItemID);
if (orgStats == null)
return;
domainStats.QuotaUsedValue = orgStats.CreatedDomains;
domainStats.QuotaValue = orgStats.AllocatedDomains;
if (orgStats.AllocatedDomains != -1) domainStats.QuotaAvailable = tenantStats.AllocatedDomains - tenantStats.CreatedDomains;
if (!hideItems)
{
userStats.QuotaUsedValue = orgStats.CreatedUsers;
userStats.QuotaValue = orgStats.AllocatedUsers;
if (orgStats.AllocatedUsers != -1) userStats.QuotaAvailable = tenantStats.AllocatedUsers - tenantStats.CreatedUsers;
domainStats.QuotaUsedValue = orgStats.CreatedDomains;
domainStats.QuotaValue = orgStats.AllocatedDomains;
if (orgStats.AllocatedDomains != -1) domainStats.QuotaAvailable = tenantStats.AllocatedDomains - tenantStats.CreatedDomains;
userStats.QuotaUsedValue = orgStats.CreatedUsers;
userStats.QuotaValue = orgStats.AllocatedUsers;
if (orgStats.AllocatedUsers != -1) userStats.QuotaAvailable = tenantStats.AllocatedUsers - tenantStats.CreatedUsers;
lnkDomains.NavigateUrl = EditUrl("ItemID", PanelRequest.ItemID.ToString(), "domains",
"SpaceID=" + PanelSecurity.PackageId);
lnkDomains.NavigateUrl = EditUrl("ItemID", PanelRequest.ItemID.ToString(), "domains",
"SpaceID=" + PanelSecurity.PackageId);
lnkUsers.NavigateUrl = EditUrl("ItemID", PanelRequest.ItemID.ToString(), "users",
"SpaceID=" + PanelSecurity.PackageId);
}
else
organizationStatsPanel.Visible = false;
lnkUsers.NavigateUrl = EditUrl("ItemID", PanelRequest.ItemID.ToString(), "users",
"SpaceID=" + PanelSecurity.PackageId);
PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
if (cntx.Groups.ContainsKey(ResourceGroups.Exchange))
{
exchangeStatsPanel.Visible = true;
BindExchangeStats();
BindExchangeStats(hideItems);
}
else
exchangeStatsPanel.Visible = false;
@ -233,6 +255,5 @@ namespace WebsitePanel.Portal.ExchangeServer
"SpaceID=" + PanelSecurity.PackageId.ToString());
}
}
}

View file

@ -1,31 +1,3 @@
// Copyright (c) 2012, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
@ -130,6 +102,15 @@ namespace WebsitePanel.Portal.ExchangeServer {
/// </remarks>
protected global::System.Web.UI.WebControls.Label lblCreatedValue;
/// <summary>
/// organizationStatsPanel control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Panel organizationStatsPanel;
/// <summary>
/// locHeadStatistics control.
/// </summary>
@ -292,6 +273,15 @@ namespace WebsitePanel.Portal.ExchangeServer {
/// </remarks>
protected global::WebsitePanel.Portal.QuotaViewer foldersStats;
/// <summary>
/// rowExchangeStorage control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlTableRow rowExchangeStorage;
/// <summary>
/// lnkExchangeStorage control.
/// </summary>

View file

@ -29,6 +29,8 @@
using System;
using System.Collections.Generic;
using WebsitePanel.Portal.Code.UserControls;
using WebsitePanel.WebPortal;
using WebsitePanel.EnterpriseServer;
namespace WebsitePanel.Portal.ExchangeServer.UserControls
{
@ -49,14 +51,25 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
private void BindTabs()
{
bool hideItems = false;
UserInfo user = UsersHelper.GetUser(PanelSecurity.EffectiveUserId);
if (user != null)
{
PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
if ((user.Role == UserRole.User) & (Utils.CheckQouta(Quotas.EXCHANGE2007_ISCONSUMER, cntx)))
hideItems = true;
}
List<Tab> tabsList = new List<Tab>();
tabsList.Add(CreateTab("edit_user", "Tab.General"));
tabsList.Add(CreateTab("mailbox_settings", "Tab.Settings"));
tabsList.Add(CreateTab("mailbox_addresses", "Tab.Addresses"));
tabsList.Add(CreateTab("mailbox_mailflow", "Tab.Mailflow"));
tabsList.Add(CreateTab("mailbox_permissions", "Tab.Permissions"));
if (!hideItems) tabsList.Add(CreateTab("mailbox_addresses", "Tab.Addresses"));
if (!hideItems) tabsList.Add(CreateTab("mailbox_mailflow", "Tab.Mailflow"));
if (!hideItems) tabsList.Add(CreateTab("mailbox_permissions", "Tab.Permissions"));
tabsList.Add(CreateTab("mailbox_setup", "Tab.Setup"));
tabsList.Add(CreateTab("mailbox_mobile", "Tab.Mobile"));
if (!hideItems) tabsList.Add(CreateTab("mailbox_mobile", "Tab.Mobile"));
//tabsList.Add(CreateTab("mailbddox_spam", "Tab.Spam"));
@ -83,5 +96,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
"ItemID=" + PanelRequest.ItemID.ToString(),
"Context=Mailbox"));
}
}
}

View file

@ -102,12 +102,6 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
set { selectedItem = value; }
}
private bool CheckQouta(string key, PackageContext cntx)
{
return cntx.Quotas.ContainsKey(key) &&
((cntx.Quotas[key].QuotaAllocatedValue == 1 && cntx.Quotas[key].QuotaTypeId == 1) ||
(cntx.Quotas[key].QuotaTypeId != 1 && (cntx.Quotas[key].QuotaAllocatedValue > 0 || cntx.Quotas[key].QuotaAllocatedValue == -1)));
}
private void PrepareExchangeMenu(PackageContext cntx, List<MenuGroup> groups, string imagePath)
{
@ -117,34 +111,34 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
if (user != null)
{
if ((user.Role == UserRole.User) & (CheckQouta(Quotas.EXCHANGE2007_ISCONSUMER, cntx)))
if ((user.Role == UserRole.User) & (Utils.CheckQouta(Quotas.EXCHANGE2007_ISCONSUMER, cntx)))
hideItems = true;
}
MenuGroup exchangeGroup = new MenuGroup(GetLocalizedString("Text.ExchangeGroup"), imagePath + "exchange24.png");
if (CheckQouta(Quotas.EXCHANGE2007_MAILBOXES, cntx))
if (Utils.CheckQouta(Quotas.EXCHANGE2007_MAILBOXES, cntx))
exchangeGroup.MenuItems.Add(CreateMenuItem("Mailboxes", "mailboxes"));
if (CheckQouta(Quotas.EXCHANGE2007_CONTACTS, cntx))
if (Utils.CheckQouta(Quotas.EXCHANGE2007_CONTACTS, cntx))
exchangeGroup.MenuItems.Add(CreateMenuItem("Contacts", "contacts"));
if (CheckQouta(Quotas.EXCHANGE2007_DISTRIBUTIONLISTS, cntx))
if (Utils.CheckQouta(Quotas.EXCHANGE2007_DISTRIBUTIONLISTS, cntx))
exchangeGroup.MenuItems.Add(CreateMenuItem("DistributionLists", "dlists"));
if (CheckQouta(Quotas.EXCHANGE2007_PUBLICFOLDERS, cntx))
if (Utils.CheckQouta(Quotas.EXCHANGE2007_PUBLICFOLDERS, cntx))
exchangeGroup.MenuItems.Add(CreateMenuItem("PublicFolders", "public_folders"));
if (!hideItems)
if (CheckQouta(Quotas.EXCHANGE2007_ACTIVESYNCALLOWED, cntx))
if (Utils.CheckQouta(Quotas.EXCHANGE2007_ACTIVESYNCALLOWED, cntx))
exchangeGroup.MenuItems.Add(CreateMenuItem("ActiveSyncPolicy", "activesync_policy"));
if (!hideItems)
if (CheckQouta(Quotas.EXCHANGE2007_MAILBOXES, cntx))
if (Utils.CheckQouta(Quotas.EXCHANGE2007_MAILBOXES, cntx))
exchangeGroup.MenuItems.Add(CreateMenuItem("MailboxPlans", "mailboxplans"));
if (!hideItems)
if (CheckQouta(Quotas.ORGANIZATION_DOMAINS, cntx))
if (Utils.CheckQouta(Quotas.ORGANIZATION_DOMAINS, cntx))
exchangeGroup.MenuItems.Add(CreateMenuItem("DomainNames", "domains"));
if (!hideItems)
@ -163,7 +157,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
if (user != null)
{
if ((user.Role == UserRole.User) & (CheckQouta(Quotas.EXCHANGE2007_ISCONSUMER, cntx)))
if ((user.Role == UserRole.User) & (Utils.CheckQouta(Quotas.EXCHANGE2007_ISCONSUMER, cntx)))
hideItems = true;
}
@ -172,7 +166,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
MenuGroup organizationGroup = new MenuGroup(GetLocalizedString("Text.OrganizationGroup"), imagePath + "company24.png");
//if (CheckQouta(Quotas.ORGANIZATION_DOMAINS, cntx))
// organizationGroup.MenuItems.Add(CreateMenuItem("DomainNames", "domains"));
if (CheckQouta(Quotas.ORGANIZATION_USERS, cntx))
if (Utils.CheckQouta(Quotas.ORGANIZATION_USERS, cntx))
organizationGroup.MenuItems.Add(CreateMenuItem("Users", "users"));
if (organizationGroup.MenuItems.Count > 0)
@ -237,7 +231,7 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
lyncGroup.MenuItems.Add(CreateMenuItem("LyncUserPlans", "lync_userplans"));
if (CheckQouta(Quotas.LYNC_FEDERATION, cntx))
if (Utils.CheckQouta(Quotas.LYNC_FEDERATION, cntx))
lyncGroup.MenuItems.Add(CreateMenuItem("LyncFederationDomains", "lync_federationdomains"));
groups.Add(lyncGroup);

View file

@ -46,6 +46,19 @@ namespace WebsitePanel.Portal
protected void Page_Load(object sender, EventArgs e)
{
BindSpace();
UserInfo user = UsersHelper.GetUser(PanelSecurity.EffectiveUserId);
if (user != null)
{
PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
if ((user.Role == UserRole.User) & (Utils.CheckQouta(Quotas.EXCHANGE2007_ISCONSUMER, cntx)))
{
lnkSummaryLetter.Visible = false;
}
}
}
private void BindSpace()

View file

@ -76,6 +76,19 @@ namespace WebsitePanel.Portal
{
// bind quotas
BindQuotas();
UserInfo user = UsersHelper.GetUser(PanelSecurity.EffectiveUserId);
if (user != null)
{
PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
if ((user.Role == UserRole.User) & (Utils.CheckQouta(Quotas.EXCHANGE2007_ISCONSUMER, cntx)))
{
btnViewQuotas.Visible = lnkViewDiskspaceDetails.Visible = false;
}
}
}
private void BindQuotas()

View file

@ -58,6 +58,20 @@ namespace WebsitePanel.Portal
lnkBackup.Visible = lnkRestore.Visible = ToolsHeader.Visible;
}
UserInfo user = UsersHelper.GetUser(PanelSecurity.EffectiveUserId);
if (user != null)
{
PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
if ((user.Role == UserRole.User) & (Utils.CheckQouta(Quotas.EXCHANGE2007_ISCONSUMER, cntx)))
{
lnkBackup.Visible = lnkRestore.Visible = ToolsHeader.Visible = false;
}
}
}
}
}

View file

@ -37,6 +37,9 @@ using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using WebsitePanel.WebPortal;
using WebsitePanel.EnterpriseServer;
namespace WebsitePanel.Portal
{
public partial class UserAccountTools : WebsitePanelModuleBase
@ -52,6 +55,20 @@ namespace WebsitePanel.Portal
{
lnkBackup.Visible = lnkRestore.Visible = ToolsHeader.Visible = false;
}
UserInfo user = UsersHelper.GetUser(PanelSecurity.EffectiveUserId);
if (user != null)
{
PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
if ((user.Role == UserRole.User) & (Utils.CheckQouta(Quotas.EXCHANGE2007_ISCONSUMER, cntx)))
{
lnkBackup.Visible = lnkRestore.Visible = ToolsHeader.Visible = false;
}
}
}
}
}