diff --git a/Site5/App_GlobalResources/Pages.Security.resx b/Site5/App_GlobalResources/Pages.Security.resx index 2d8e98ba..8cb73a8b 100644 --- a/Site5/App_GlobalResources/Pages.Security.resx +++ b/Site5/App_GlobalResources/Pages.Security.resx @@ -133,11 +133,14 @@ Current organization - Do you want to work with another organization in this Swarmops installation which you can access in a member, staff, or activist role? No problem, just select it and switch. + You can be taking part in several organizations on this Swarmops installation. Here is where you switch between them. New organization + + You're not part of any other organizations on this Swarmops installation, so you can't switch to something else. Therefore, we're going back to Dashboard instead. + Change Organizations diff --git a/Site5/Images/Other/clipart-panda-free-sandbox-icon-64px.png b/Site5/Images/Other/clipart-panda-free-sandbox-icon-64px.png new file mode 100644 index 00000000..af9422bf Binary files /dev/null and b/Site5/Images/Other/clipart-panda-free-sandbox-icon-64px.png differ diff --git a/Site5/Pages/v5/Security/ChangeOrganizations.aspx b/Site5/Pages/v5/Security/ChangeOrganizations.aspx index 49330ac2..b74704c6 100644 --- a/Site5/Pages/v5/Security/ChangeOrganizations.aspx +++ b/Site5/Pages/v5/Security/ChangeOrganizations.aspx @@ -1,36 +1,84 @@ -<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="ChangeOrganizations.aspx.cs" Inherits="Swarmops.Frontend.Pages.Security.ChangeOrganizations" %> -<%@ Register TagPrefix="Swarmops5" TagName="ExternalScripts" Src="~/Controls/v5/UI/ExternalScripts.ascx" %> -<%@ Register TagPrefix="Swarmops5" TagName="ComboBudgets" Src="~/Controls/v5/Financial/ComboBudgets.ascx" %> +<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="ChangeOrganizations.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Security.ChangeOrganizations" %> +<%@ Import Namespace="Swarmops.Logic.Support" %> +<%@ Register src="~/Controls/v5/UI/ExternalScripts.ascx" tagname="ExternalScripts" tagprefix="Swarmops5" %> - + + + + + - + var organizationCount = <%=this.OrganizationCount %>; + + + + + - -
-  
- - - + <% if (!PilotInstallationIds.IsPilot(PilotInstallationIds.PiratePartySE)) // at the first pilot installation, the first live org was #1 and there was no sandbox + { %> +
+ +
Sandbox
- -
+
+ <% } %> + + +
';"> + +
<%# Eval("OrganizationName") %>
+
+
+
- diff --git a/Site5/Pages/v5/Security/ChangeOrganizations.aspx.cs b/Site5/Pages/v5/Security/ChangeOrganizations.aspx.cs index 7f6e0b03..96c4a8bc 100644 --- a/Site5/Pages/v5/Security/ChangeOrganizations.aspx.cs +++ b/Site5/Pages/v5/Security/ChangeOrganizations.aspx.cs @@ -1,39 +1,62 @@ using System; +using System.Collections.Generic; +using System.Drawing; using System.Globalization; -using System.Web.Security; +using System.ServiceModel.Security; +using System.Web; +using System.Web.Services; +using Swarmops.Logic.Financial; +using Swarmops.Logic.Support; +using Swarmops.Logic.Swarm; -namespace Swarmops.Frontend.Pages.Security +namespace Swarmops.Frontend.Pages.v5.Security { public partial class ChangeOrganizations : PageV5Base { protected void Page_Load(object sender, EventArgs e) { - if (!Page.IsPostBack) - { - Localize(); - } - - // this.PageAccessRequired = new Access(AccessAspect.Bookkeeping, AccessType.Write); // bogus, but will prevent bad ppl from entering until real security done - this.PageTitle = Resources.Pages.Security.ChangeOrganizations_PageTitle; this.PageIcon = "iconshock-organizations"; this.InfoBoxLiteral = Resources.Pages.Security.ChangeOrganizations_Info; - this.LabelCurrentOrganizationName.Text = CurrentOrganization.Name; + this.LabelNoOrganizations.Text = Resources.Pages.Security.ChangeOrganizations_NothingToChange; + + PopulateRepeater(); } - private void Localize() + private void PopulateRepeater() { - this.LabelCurrentOrganization.Text = Resources.Pages.Security.ChangeOrganizations_CurrentOrganization; - this.LabelNewOrganization.Text = Resources.Pages.Security.ChangeOrganizations_NewOrganization; + Memberships memberships = CurrentUser.GetMemberships(); + + List availableOrganizations = new List(); + foreach (Membership membership in memberships) + { + if (membership.OrganizationId == 1 && !PilotInstallationIds.IsPilot(PilotInstallationIds.PiratePartySE)) + { + // sandbox. Ignore. + continue; + } + + OrganizationParameters newOrganization = new OrganizationParameters(); + newOrganization.LogoUrl = "/Images/Flags/txl-64px.png"; + newOrganization.OrganizationId = membership.OrganizationId; + newOrganization.OrganizationName = membership.Organization.Name; + + availableOrganizations.Add(newOrganization); + } + + this.OrganizationCount = availableOrganizations.Count; + + this.RepeaterOrganizations.DataSource = availableOrganizations; + this.RepeaterOrganizations.DataBind(); } - protected void ButtonSwitch_Click(object sender, EventArgs e) + public int OrganizationCount { get; set; } + + private class OrganizationParameters { - int newOrganizationId = Int32.Parse(this.Request.Form["DropOrganizations"]); - - // TODO: Re-authorize user's ability to log onto this org - - FormsAuthentication.RedirectFromLoginPage(this.CurrentUser.Identity.ToString(CultureInfo.InvariantCulture) + "," + newOrganizationId.ToString(CultureInfo.InvariantCulture), true); + public string LogoUrl { get; set; } + public int OrganizationId { get; set; } + public string OrganizationName { get; set; } } } } \ No newline at end of file diff --git a/Site5/Pages/v5/Security/ChangeOrganizationsAdvanced.aspx b/Site5/Pages/v5/Security/ChangeOrganizationsAdvanced.aspx new file mode 100644 index 00000000..89c00e47 --- /dev/null +++ b/Site5/Pages/v5/Security/ChangeOrganizationsAdvanced.aspx @@ -0,0 +1,36 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="ChangeOrganizationsAdvanced.aspx.cs" Inherits="Swarmops.Frontend.Pages.Security.ChangeOrganizationsAdvanced" %> +<%@ Register TagPrefix="Swarmops5" TagName="ExternalScripts" Src="~/Controls/v5/UI/ExternalScripts.ascx" %> +<%@ Register TagPrefix="Swarmops5" TagName="ComboBudgets" Src="~/Controls/v5/Financial/ComboBudgets.ascx" %> + + + + + + + + + + +
+  
+ + + +
+ +
+
+ + + + diff --git a/Site5/Pages/v5/Security/ChangeOrganizationsAdvanced.aspx.cs b/Site5/Pages/v5/Security/ChangeOrganizationsAdvanced.aspx.cs new file mode 100644 index 00000000..193e00f5 --- /dev/null +++ b/Site5/Pages/v5/Security/ChangeOrganizationsAdvanced.aspx.cs @@ -0,0 +1,39 @@ +using System; +using System.Globalization; +using System.Web.Security; + +namespace Swarmops.Frontend.Pages.Security +{ + public partial class ChangeOrganizationsAdvanced : PageV5Base + { + protected void Page_Load(object sender, EventArgs e) + { + if (!Page.IsPostBack) + { + Localize(); + } + + // this.PageAccessRequired = new Access(AccessAspect.Bookkeeping, AccessType.Write); // bogus, but will prevent bad ppl from entering until real security done + + this.PageTitle = Resources.Pages.Security.ChangeOrganizations_PageTitle; + this.PageIcon = "iconshock-organizations"; + this.InfoBoxLiteral = Resources.Pages.Security.ChangeOrganizations_Info; + this.LabelCurrentOrganizationName.Text = CurrentOrganization.Name; + } + + private void Localize() + { + this.LabelCurrentOrganization.Text = Resources.Pages.Security.ChangeOrganizations_CurrentOrganization; + this.LabelNewOrganization.Text = Resources.Pages.Security.ChangeOrganizations_NewOrganization; + } + + protected void ButtonSwitch_Click(object sender, EventArgs e) + { + int newOrganizationId = Int32.Parse(this.Request.Form["DropOrganizations"]); + + // TODO: Re-authorize user's ability to log onto this org + + FormsAuthentication.RedirectFromLoginPage(this.CurrentUser.Identity.ToString(CultureInfo.InvariantCulture) + "," + newOrganizationId.ToString(CultureInfo.InvariantCulture), true); + } + } +} \ No newline at end of file diff --git a/Site5/Pages/v5/Security/SetCurrentOrganization.aspx b/Site5/Pages/v5/Security/SetCurrentOrganization.aspx new file mode 100644 index 00000000..ea6565dc --- /dev/null +++ b/Site5/Pages/v5/Security/SetCurrentOrganization.aspx @@ -0,0 +1 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SetCurrentOrganization.aspx.cs" MasterPageFile="~/Master-v5.master" Inherits="Swarmops.Frontend.Pages.v5.Security.SetCurrentOrganization" %> diff --git a/Site5/Pages/v5/Security/SetCurrentOrganization.aspx.cs b/Site5/Pages/v5/Security/SetCurrentOrganization.aspx.cs new file mode 100644 index 00000000..d803ba74 --- /dev/null +++ b/Site5/Pages/v5/Security/SetCurrentOrganization.aspx.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Web; +using System.Web.Security; +using System.Web.UI; +using System.Web.UI.WebControls; +using Swarmops.Logic.Structure; + +namespace Swarmops.Frontend.Pages.v5.Security +{ + public partial class SetCurrentOrganization : PageV5Base + { + protected void Page_Load(object sender, EventArgs e) + { + if (CurrentUser == null) + { + throw new UnauthorizedAccessException("No"); // may cause problems on login screen? + } + + string organizationIdString = Request.QueryString["OrganizationId"]; + int organizationId = Int32.Parse(organizationIdString); + Organization suggestedOrganization = null; + try + { + suggestedOrganization = Organization.FromIdentity(organizationId); + } + catch (ArgumentException) + { + suggestedOrganization = null; + } + + if (suggestedOrganization == null || !CurrentUser.MemberOf(suggestedOrganization)) + { + // Some work here on PPSE pilot - we want everybody to be able to switch to Sandbox, which is #1 + // except for in PPSE installation, where it is... #3 or something + + throw new UnauthorizedAccessException(); + } + + FormsAuthentication.RedirectFromLoginPage( + CurrentUser.Identity.ToString(CultureInfo.InvariantCulture) + "," + + suggestedOrganization.Identity.ToString(CultureInfo.InvariantCulture), true); // we're not using the original input for security reasons + + } + } +} \ No newline at end of file