diff --git a/Logic/Cache/OrganizationCache.cs b/Logic/Cache/OrganizationCache.cs index b6418e2f..e068fb01 100644 --- a/Logic/Cache/OrganizationCache.cs +++ b/Logic/Cache/OrganizationCache.cs @@ -266,6 +266,7 @@ namespace Activizr.Logic.Cache } } + [Obsolete ("Never use this function. Mark the org as unused, deleted. Records are needed for historic reasons.", true)] internal static void DeleteOrganization (int p) { PirateDb.GetDatabaseForWriting().DeleteOrganization(p); diff --git a/Logic/DataObjects/OrganizationDataObject.cs b/Logic/DataObjects/OrganizationDataObject.cs index 233361a5..5f1301e6 100644 --- a/Logic/DataObjects/OrganizationDataObject.cs +++ b/Logic/DataObjects/OrganizationDataObject.cs @@ -351,7 +351,7 @@ namespace Activizr.Logic.DataObjects } org.Identity = Organization.Create(org.ParentOrganizationId, org.NameInternational, org.Name, org.NameShort, org.Domain, org.MailPrefix, org.AnchorGeographyId, org.AcceptsMembers, - org.AutoAssignNewMembers, org.DefaultCountryId); + org.AutoAssignNewMembers, org.DefaultCountryId).Identity; // Return true if precisely one row was inserted, otherwise false return org.Identity; } diff --git a/Logic/Structure/Organization.cs b/Logic/Structure/Organization.cs index 767fbc20..696fc81b 100644 --- a/Logic/Structure/Organization.cs +++ b/Logic/Structure/Organization.cs @@ -622,20 +622,21 @@ namespace Activizr.Logic.Structure } - internal static int Create (int ParentOrganizationId, string NameInternational, string Name, string NameShort, string Domain, string MailPrefix, int AnchorGeographyId, bool AcceptsMembers, bool AutoAssignNewMembers, int DefaultCountryId) + public static Organization Create (int parentOrganizationId, string nameInternational, string name, string nameShort, string domain, string mailPrefix, int anchorGeographyId, bool acceptsMembers, bool autoAssignNewMembers, int defaultCountryId) { - return OrganizationCache.CreateOrganization(ParentOrganizationId, - NameInternational, - Name, - NameShort, - Domain, - MailPrefix, - AnchorGeographyId, - AcceptsMembers, - AutoAssignNewMembers, - DefaultCountryId); + return FromIdentity(OrganizationCache.CreateOrganization(parentOrganizationId, + nameInternational, + name, + nameShort, + domain, + mailPrefix, + anchorGeographyId, + acceptsMembers, + autoAssignNewMembers, + defaultCountryId)); } + [Obsolete("Never use this function. Mark the organization as unused. Records are needed for history.", true)] public void Delete () { string problems = ""; diff --git a/Site5/Pages/v5/Init/Default.aspx b/Site5/Pages/v5/Init/Default.aspx index d6d83c40..ac201b11 100644 --- a/Site5/Pages/v5/Init/Default.aspx +++ b/Site5/Pages/v5/Init/Default.aspx @@ -49,6 +49,9 @@ function validateStep(stepNumber) { var isValid = false; + var textBoxes; + var loop; + var fieldContents; if (stepNumber == 1) { // Validate Hostname, Host Address @@ -108,12 +111,12 @@ else if (stepNumber == 2) { isValid = true; // assume true, make false as we go - var textBoxes = ["<%=this.TextCredentialsReadDatabase.ClientID %>", "<%=this.TextCredentialsReadServer.ClientID %>", "<%=this.TextCredentialsReadUser.ClientID %>", "<%=this.TextCredentialsReadPassword.ClientID %>", + textBoxes = ["<%=this.TextCredentialsReadDatabase.ClientID %>", "<%=this.TextCredentialsReadServer.ClientID %>", "<%=this.TextCredentialsReadUser.ClientID %>", "<%=this.TextCredentialsReadPassword.ClientID %>", "<%=this.TextCredentialsWriteDatabase.ClientID %>", "<%=this.TextCredentialsWriteServer.ClientID %>", "<%=this.TextCredentialsWriteUser.ClientID %>", "<%=this.TextCredentialsWritePassword.ClientID %>", "<%=this.TextCredentialsAdminDatabase.ClientID %>", "<%=this.TextCredentialsAdminServer.ClientID %>", "<%=this.TextCredentialsAdminUser.ClientID %>", "<%=this.TextCredentialsAdminPassword.ClientID %>"]; - for (var loop = 0; loop < textBoxes.length; loop++) { - var fieldContents = $('#' + textBoxes[loop]).val(); + for (loop = 0; loop < textBoxes.length; loop++) { + fieldContents = $('#' + textBoxes[loop]).val(); if (fieldContents && fieldContents.length > 0) { $('#' + textBoxes[loop]).css('background-image', "none"); @@ -134,6 +137,58 @@ } } + else if (stepNumber == 3) { + isValid = true; // assume true, make false as we go + + // Check that all four boxes are filled in, and that Password1 and Password2 equal each other. + + textBoxes = ["<%=this.TextFirstUserName.ClientID %>", "<%=this.TextFirstUserMail.ClientID %>", "<%=this.TextFirstUserPassword1.ClientID %>", "<%=this.TextFirstUserPassword2.ClientID %>"]; + + for (loop = 0; loop < textBoxes.length; loop++) { + fieldContents = $('#' + textBoxes[loop]).val(); + + if (fieldContents && fieldContents.length > 0) { + $('#' + textBoxes[loop]).css('background-image', "none"); + } else { + $('#' + textBoxes[loop]).css('background-image', "url('/Images/Icons/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat'); + isValid = false; + } + } + + // As we exit the zero-length check, fieldContents contains Password2.Text, so we can compare it to Password1.Text right away. + + if (isValid) { + if (fieldContents != $('#<%=this.TextFirstUserPassword1.ClientID %>').val()) { + $('#<%=this.TextFirstUserPassword1.ClientID %>').css('background-image', "url('/Images/Icons/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat'); + $('#<%=this.TextFirstUserPassword2.ClientID %>').css('background-image', "url('/Images/Icons/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat'); + isValid = false; + } + } + + // If all is valid, create the first user. + // TODO: this WILL fuck up when somebody enters O'Hara as name, or anything else containing a single quote. Protect against that. + // TODO: make this throw server-side if there is already a Person.FromIdentity(1). + + if (isValid) { + $.ajax({ + type: "POST", + url: "Default.aspx/CreateFirstUser", + data: "{'name': '" + $('#<%=this.TextFirstUserName.ClientID %>').val() + "', 'mail': '" + $('#<%=this.TextFirstUserMail.ClientID %>').val() + "', 'address': '" + $('#<%=this.TextFirstUserPassword1.ClientID %>').val() + "'}", // TODO: injection vulnerability - strip single quotes from input + contentType: "application/json; charset=utf-8", + dataType: "json", + success: function (msg) { + // Don't care + } + }); + } + } + else if (stepNumber == 4) { + // If we get here, we're always good + + isValid = true; + // TODO: Click the magic button that logs the first user in + } + return isValid; } @@ -181,8 +236,16 @@ } else { // We're not done yet. Keep the progress bar on-screen and keep re-checking. - $('#DivProgressDatabase').progressbar("value", msg.d); - setTimeout('updateInitProgressBar();', 1500); + if (msg.d == 1) { + $('#DivProgressDatabase').progressbar("value", msg.d); + } else { + $("#DivProgressDatabase .ui-progressbar-value").animate( + { + width: msg.d + "%" + }, { queue: false }); + } + + setTimeout('updateInitProgressBar();', 1000); } } }); @@ -205,7 +268,7 @@ // We're not done yet. Keep the progress bar on-screen and keep re-checking. $('#SpanInitProgressMessage').text(msg.d); - setTimeout('updateInitProgressMessage();', 2000); + setTimeout('updateInitProgressMessage();', 500); } } }); @@ -467,24 +530,29 @@

Initializing database

-

Please wait while the database is being initialized with schemas and geographic data from the Activizr servers. This is going to take a significant amount of time; we're loading tons of geodata onto your new server.

+

Please wait while the database is being initialized with schemas and geographic data from the Activizr servers. This is going to take a significant amount of time; we're loading tons of geodata onto your new server.

Initializing...