This commit is contained in:
Virtuworks 2014-04-25 10:36:18 -04:00
commit d2f8d2e923
9 changed files with 173 additions and 35 deletions

View file

@ -168,4 +168,10 @@
<data name="Text.PageName" xml:space="preserve">
<value>Home</value>
</data>
<data name="gvOrgsDefault.HeaderText" xml:space="preserve">
<value>Default</value>
</data>
<data name="btnSetDefaultOrganization.Text" xml:space="preserve">
<value>Set Default Organization</value>
</data>
</root>

View file

@ -74,6 +74,13 @@
</ItemTemplate>
<HeaderStyle Wrap="False" />
</asp:TemplateField>
<asp:TemplateField meta:resourcekey="gvOrgsDefault">
<ItemTemplate>
<div style="text-align:center">
<input type="radio" name="DefaultOrganization" value='<%# Eval("ItemID") %>' <%# IsChecked(Convert.ToString(Eval("IsDefault")), Eval("ItemID").ToString()) %>/>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="20px">
<ItemTemplate>
<asp:ImageButton ID="cmdDelete" runat="server" Text="Delete" SkinID="ExchangeDelete"
@ -98,11 +105,15 @@
</asp:ObjectDataSource>
<br />
<asp:Localize ID="locQuota" runat="server" meta:resourcekey="locQuota" Text="Total Organizations Created:"></asp:Localize>
&nbsp;&nbsp;&nbsp;
<wsp:Quota ID="orgsQuota" runat="server" QuotaName="HostedSolution.Organizations" />
<br />
<br />
<div style="text-align: center">
<asp:Button ID="btnSetDefaultOrganization" runat="server" meta:resourcekey="btnSetDefaultOrganization"
Text="Set Default Organization" CssClass="Button1" OnClick="btnSetDefaultOrganization_Click" />
</div>
</div>
</div>
</div>

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014, Outercurve Foundation.
// Copyright (c) 2012, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -27,14 +27,18 @@
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Data;
using System.Text;
using System.Web.UI.WebControls;
using WebsitePanel.EnterpriseServer;
using WebsitePanel.Providers.HostedSolution;
namespace WebsitePanel.Portal.ExchangeServer
{
public partial class Organizations : WebsitePanelModuleBase
{
private int CurrentDefaultOrgId { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
// set display preferences
@ -50,16 +54,17 @@ namespace WebsitePanel.Portal.ExchangeServer
btnCreate.Enabled = false;
}
PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
if (cntx.Quotas.ContainsKey(Quotas.ORGANIZATIONS))
{
btnCreate.Enabled = (!(cntx.Quotas[Quotas.ORGANIZATIONS].QuotaAllocatedValue <= gvOrgs.Rows.Count)||(cntx.Quotas[Quotas.ORGANIZATIONS].QuotaAllocatedValue==-1));
}
//else
//if (gvOrgs.Rows.Count > 0) btnCreate.Enabled = false;
btnSetDefaultOrganization.Enabled = !(gvOrgs.Rows.Count < 2);
if (!Page.IsPostBack)
{
if (Request.UrlReferrer != null && PanelSecurity.SelectedUser.Role == UserRole.User)
@ -69,6 +74,8 @@ namespace WebsitePanel.Portal.ExchangeServer
if (Request.UrlReferrer.Query.Equals(queryBuilder.ToString(), StringComparison.InvariantCultureIgnoreCase) && gvOrgs.Rows.Count > 0)
{
if (CurrentDefaultOrgId > 0) Response.Redirect(GetOrganizationEditUrl(CurrentDefaultOrgId.ToString()));
Response.Redirect(((HyperLink)gvOrgs.Rows[0].Cells[1].Controls[1]).NavigateUrl);
}
}
@ -139,5 +146,33 @@ namespace WebsitePanel.Portal.ExchangeServer
}
}
}
protected void btnSetDefaultOrganization_Click(object sender, EventArgs e)
{
// get org
int newDefaultOrgId = Utils.ParseInt(Request.Form["DefaultOrganization"], CurrentDefaultOrgId);
try
{
ES.Services.Organizations.SetDefaultOrganization(newDefaultOrgId, CurrentDefaultOrgId);
ShowSuccessMessage("REQUEST_COMPLETED_SUCCESFULLY");
}
catch (Exception ex)
{
ShowErrorMessage("ORGANIZATION_SET_DEFAULT_ORG", ex);
}
}
public string IsChecked(string val, string itemId)
{
if (!string.IsNullOrEmpty(val) && val.ToLowerInvariant() == "true")
{
CurrentDefaultOrgId = Utils.ParseInt(itemId, 0);
return "checked";
}
return "";
}
}
}

View file

@ -1,31 +1,3 @@
// Copyright (c) 2014, 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.
@ -165,5 +137,14 @@ namespace WebsitePanel.Portal.ExchangeServer {
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::WebsitePanel.Portal.Quota orgsQuota;
/// <summary>
/// btnSetDefaultOrganization 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.Button btnSetDefaultOrganization;
}
}