diff --git a/Database/Database-Documents.cs b/Database/Database-Documents.cs index 0a1f2cc8..e4f7d3db 100644 --- a/Database/Database-Documents.cs +++ b/Database/Database-Documents.cs @@ -30,7 +30,7 @@ namespace Swarmops.Database return ReadDocumentFromDataReader(reader); } - throw new ArgumentException("Unknown Account Id"); + throw new ArgumentException("Unknown Document Id"); } } } diff --git a/Database/Database-SwarmopsLog.cs b/Database/Database-SwarmopsLog.cs index d6c0c84f..c5b5b0b9 100644 --- a/Database/Database-SwarmopsLog.cs +++ b/Database/Database-SwarmopsLog.cs @@ -15,7 +15,7 @@ namespace Swarmops.Database private const string swarmopsLogFieldSequence = " SwarmopsLogEntryId,DateTime,PersonId,EntryTypeId,EntryXml " + // 0-4 - "FROM SwarmopsLog"; + "FROM SwarmopsLog "; private static BasicSwarmopsLogEntry ReadSwarmopsLogEntryFromDataReader(IDataRecord reader) { @@ -104,6 +104,7 @@ namespace Swarmops.Database AddParameterWithName(command, "personId", personId); AddParameterWithName(command, "entryType", entryType); AddParameterWithName(command, "entryXml", entryXml); + AddParameterWithName(command, "dateTime", DateTime.UtcNow); return Convert.ToInt32(command.ExecuteScalar()); } diff --git a/Logic/Support/Document.cs b/Logic/Support/Document.cs index 7007b15f..0b220794 100644 --- a/Logic/Support/Document.cs +++ b/Logic/Support/Document.cs @@ -18,12 +18,17 @@ namespace Swarmops.Logic.Support } - public static Document FromIdentity (int documentId) + public static Document FromIdentity(int documentId) { return FromBasic(SwarmDb.GetDatabaseForReading().GetDocument(documentId)); } - public static Document FromBasic (BasicDocument basicDocument) + public static Document FromIdentityAggressive(int documentId) + { + return FromBasic(SwarmDb.GetDatabaseForWriting().GetDocument(documentId)); // "For writing" is intentional - bypasses a race condition in replication + } + + public static Document FromBasic(BasicDocument basicDocument) { return new Document(basicDocument); } @@ -34,7 +39,7 @@ namespace Swarmops.Logic.Support int newDocumentId = SwarmDb.GetDatabaseForWriting(). CreateDocument(serverFileName, clientFileName, fileSize, description, GetDocumentTypeForObject(identifiableObject), identifiableObject == null? 0: identifiableObject.Identity, uploader.Identity); - return FromIdentity(newDocumentId); + return FromIdentityAggressive(newDocumentId); } public static DocumentType GetDocumentTypeForObject (IHasIdentity foreignObject) diff --git a/Logic/Support/LogEntries/CashAdvanceRequestedLogEntry.cs b/Logic/Support/LogEntries/CashAdvanceRequestedLogEntry.cs index 6619b702..07343636 100644 --- a/Logic/Support/LogEntries/CashAdvanceRequestedLogEntry.cs +++ b/Logic/Support/LogEntries/CashAdvanceRequestedLogEntry.cs @@ -25,7 +25,7 @@ namespace Swarmops.Logic.Support.LogEntries this.FinancialAccountId = budget.Identity; this.FinancialAccountName = budget.Name; // redundancy in case of future name changes this.OwnerPersonId = budget.OwnerPersonId; - this.OwnerPersonName = budget.Owner.Name; + this.OwnerPersonName = budget.OwnerPersonId != 0 ? budget.Owner.Name : string.Empty; this.ActingPersonId = actingPerson.Identity; // do not save name for data retention reasons this.BeneficiaryPersonId = beneficiaryPerson.Identity; } diff --git a/Logic/Support/LogEntries/ExpenseClaimFiledLogEntry.cs b/Logic/Support/LogEntries/ExpenseClaimFiledLogEntry.cs index 44ae9871..c4b8d428 100644 --- a/Logic/Support/LogEntries/ExpenseClaimFiledLogEntry.cs +++ b/Logic/Support/LogEntries/ExpenseClaimFiledLogEntry.cs @@ -25,7 +25,7 @@ namespace Swarmops.Logic.Support.LogEntries this.FinancialAccountId = budget.Identity; this.FinancialAccountName = budget.Name; // redundancy in case of future name changes this.OwnerPersonId = budget.OwnerPersonId; - this.OwnerPersonName = budget.Owner.Name; + this.OwnerPersonName = budget.OwnerPersonId != 0 ? budget.Owner.Name : string.Empty; this.ActingPersonId = filingPerson.Identity; // do not save name for data retention reasons this.BeneficiaryPersonId = beneficiaryPerson.Identity; } diff --git a/Logic/Support/LogEntries/FinancialActionBase.cs b/Logic/Support/LogEntries/FinancialActionBase.cs index 344abc0a..e506c7a1 100644 --- a/Logic/Support/LogEntries/FinancialActionBase.cs +++ b/Logic/Support/LogEntries/FinancialActionBase.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using Swarmops.Logic.Support.Log; + namespace Swarmops.Logic.Support.LogEntries { diff --git a/Logic/Support/LogEntries/LogEntryBase.cs b/Logic/Support/LogEntries/LogEntryBase.cs index 94f67a12..bab06ee5 100644 --- a/Logic/Support/LogEntries/LogEntryBase.cs +++ b/Logic/Support/LogEntries/LogEntryBase.cs @@ -1,18 +1,16 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; using System.Xml.Serialization; -namespace Swarmops.Logic.Support.Log +namespace Swarmops.Logic.Support.LogEntries { [Serializable] public class LogEntryBase: IXmlPayload { - public string ToXml() + public virtual string ToXml() { - var serializer = new XmlSerializer(typeof(T)); + var serializer = new XmlSerializer(this.GetType()); var stream = new MemoryStream(); serializer.Serialize(stream, this); @@ -21,7 +19,7 @@ namespace Swarmops.Logic.Support.Log return Encoding.UTF8.GetString(xmlBytes); } - public static T FromXml (string xml) + public static T FromXml (string xml) // 'T' might not work here, like it didn't in ToXml() { // Compensate for stupid Mono encoding bugs diff --git a/Logic/Support/SwarmopsLog.cs b/Logic/Support/SwarmopsLog.cs index fe1fbbe9..a01f4680 100644 --- a/Logic/Support/SwarmopsLog.cs +++ b/Logic/Support/SwarmopsLog.cs @@ -13,9 +13,9 @@ namespace Swarmops.Logic.Support { string logEntryClass = logEntry.GetType().ToString(); - if (logEntryClass.StartsWith("Swarmops.Logic.Support.Logentries.")) + if (logEntryClass.StartsWith("Swarmops.Logic.Support.LogEntries.")) { - logEntryClass = logEntryClass.Substring("Swarmops.Logic.Support.Logentries.".Length); + logEntryClass = logEntryClass.Substring("Swarmops.Logic.Support.LogEntries.".Length); } int logEntryId = SwarmDb.GetDatabaseForWriting().CreateSwarmopsLogEntry( diff --git a/Logic/Support/SwarmopsLogEntry.cs b/Logic/Support/SwarmopsLogEntry.cs index a30ce3a5..0968ef57 100644 --- a/Logic/Support/SwarmopsLogEntry.cs +++ b/Logic/Support/SwarmopsLogEntry.cs @@ -54,7 +54,7 @@ namespace Swarmops.Logic.Support string className = affectedObject.GetType().ToString(); int dotIndex = className.LastIndexOf('.'); - className = className.Substring(dotIndex); // assumes there's always at least one dot in a class name + className = className.Substring(dotIndex + 1); // assumes there's always at least one dot in a class name SwarmDb.GetDatabaseForWriting().CreateSwarmopsLogEntryAffectedObject(this.Identity, className, affectedObject.Identity); diff --git a/Site5/App_Code/DataV5Base.cs b/Site5/App_Code/DataV5Base.cs index beb70ace..8d1feefd 100644 --- a/Site5/App_Code/DataV5Base.cs +++ b/Site5/App_Code/DataV5Base.cs @@ -215,5 +215,10 @@ public class DataV5Base : System.Web.UI.Page } + protected static string JsonSanitize (string input) + { + return input.Replace("\"", "\\\""); + } + } diff --git a/Site5/App_GlobalResources/Pages.Security.resx b/Site5/App_GlobalResources/Pages.Security.resx index 70cbd2dc..44bf5782 100644 --- a/Site5/App_GlobalResources/Pages.Security.resx +++ b/Site5/App_GlobalResources/Pages.Security.resx @@ -129,4 +129,19 @@ <p>The Activizr security framework has denied you access to the page you were trying to go to. This usually means that its functions were above the access levels granted to you for the currently selected organization (<em>{0}</em>). This has not been logged nor reported anywhere.</p><p>There are several reasons why this may have happened:</p> + + 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. + + + New organization + + + Change Organizations + + + Switch + \ No newline at end of file diff --git a/Site5/Automation/Json-ExpensableBudgetsTree.aspx.cs b/Site5/Automation/Json-ExpensableBudgetsTree.aspx.cs index edc9917d..0347430a 100644 --- a/Site5/Automation/Json-ExpensableBudgetsTree.aspx.cs +++ b/Site5/Automation/Json-ExpensableBudgetsTree.aspx.cs @@ -78,7 +78,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial foreach (FinancialAccount account in treeMap[node]) { string element = string.Format("\"id\":{0},\"text\":\"{1}\"", account.Identity, - account.Name.Replace("\"", "\\\"")); + JsonSanitize(account.Name)); if (treeMap.ContainsKey(account.Identity)) { diff --git a/Site5/Automation/Json-TransactionTagsTree.aspx.cs b/Site5/Automation/Json-TransactionTagsTree.aspx.cs index a368973b..16b36688 100644 --- a/Site5/Automation/Json-TransactionTagsTree.aspx.cs +++ b/Site5/Automation/Json-TransactionTagsTree.aspx.cs @@ -88,7 +88,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial foreach (FinancialTransactionTagType tagType in treeMap[node]) { string element = string.Format("\"id\":{0},\"text\":\"{1}\"", tagType.Identity, - tagType.Name.Replace("\"", "\\\"")); + JsonSanitize(tagType.Name)); if (treeMap.ContainsKey(tagType.Identity)) { diff --git a/Site5/Images/PageIcons/iconshock-organizations-16px.png b/Site5/Images/PageIcons/iconshock-organizations-16px.png new file mode 100644 index 00000000..51728bdd Binary files /dev/null and b/Site5/Images/PageIcons/iconshock-organizations-16px.png differ diff --git a/Site5/Images/PageIcons/iconshock-organizations-40px.png b/Site5/Images/PageIcons/iconshock-organizations-40px.png new file mode 100644 index 00000000..5a558b7c Binary files /dev/null and b/Site5/Images/PageIcons/iconshock-organizations-40px.png differ diff --git a/Site5/Master-v5.master b/Site5/Master-v5.master index 1f12967b..96553fb8 100644 --- a/Site5/Master-v5.master +++ b/Site5/Master-v5.master @@ -33,7 +33,7 @@ + + + + +
+ ​
+ + + +
+ +
+ + + + diff --git a/Site5/Pages/v5/Security/ChangeOrganizations.aspx.cs b/Site5/Pages/v5/Security/ChangeOrganizations.aspx.cs new file mode 100644 index 00000000..0d50bcd2 --- /dev/null +++ b/Site5/Pages/v5/Security/ChangeOrganizations.aspx.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace Swarmops.Frontend.Pages.Security +{ + public partial class ChangeOrganizations : PageV5Base + { + protected void Page_Load(object sender, EventArgs e) + { + if (!Page.IsPostBack) + { + Localize(); + } + + 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) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file