protected void Page_Load(object sender, EventArgs e) { EmailValidator1.ErrorMessage = LiftDomain.Language.Current.SHARED_MUST_BE_A_VALID_EMAIL_ADDRESS; EmailValidator2.ErrorMessage = LiftDomain.Language.Current.SHARED_MUST_BE_A_VALID_EMAIL_ADDRESS; EmailValidator3.ErrorMessage = LiftDomain.Language.Current.SHARED_MUST_BE_A_VALID_EMAIL_ADDRESS; EmailValidator4.ErrorMessage = LiftDomain.Language.Current.SHARED_MUST_BE_A_VALID_EMAIL_ADDRESS; PageAuthorized.check(Request, Response); if (!Organization.setCurrent()) { Response.Redirect(LiftContext.Redirect); } try { //------------------------------------------------------------------------- //-- do the language setting for the SUBMIT button here //-- (unable to place <%=LiftDomain.Language.Current.SHARED_SUBMIT %> in asp:Button Text field) //------------------------------------------------------------------------- this.submitBtn.Text = LiftDomain.Language.Current.SHARED_SUBMIT.Value; //------------------------------------------------------------------------- //-- instantiate object //------------------------------------------------------------------------- LiftDomain.OrgEmail thisOrgEmail = new LiftDomain.OrgEmail(); organization_from_email_address.ReadOnly = true; if (IsPostBack) { //------------------------------------------------------------------------- //-- get the object ID from the hidden id field on the page; //-- if there is a object ID value, then we are editing an EXISTING object //------------------------------------------------------------------------- if (!String.IsNullOrEmpty(id.Value) && (id.Value != "0")) { thisOrgEmail.id.Value = int.Parse(id.Value); } //------------------------------------------------------------------------- //-- transfer screen values to the object //------------------------------------------------------------------------- //TODO: ???what if data field validation fails??? // TO BE DONE IN JAVASCRIPT thisOrgEmail.webmaster_email_to.Value = organization_email_to_webmaster.Text; thisOrgEmail.contact_us_email_to.Value = organization_email_to_contact_us.Text; thisOrgEmail.encourager_email_to.Value = organization_email_to_encourager.Text; //thisOrgEmail.email_from.Value = organization_from_email_address.Text; //------------------------------------------------------------------------- //-- persist the object data to the database //------------------------------------------------------------------------- thisOrgEmail.id.Value = Convert.ToInt32(thisOrgEmail.doCommand("save")); //------------------------------------------------------------------------- //-- return to ??? //------------------------------------------------------------------------- //TODO: ???where to redirect after editing this page??? //Response.Redirect("???"); } else { //------------------------------------------------------------------------- //-- first time on this page, so get the organization ID from the ASP Request cache //------------------------------------------------------------------------- string orgIdStr = Request["o"]; if (String.IsNullOrEmpty(orgIdStr)) { //TODO: ??? HOW DO WE NOTIFY THE USER Logger.log(Logger.Level.ERROR, this, "Organization ID must be passed in the request string [EditOrganizationEmails.aspx]."); throw new ApplicationException("Organization ID must be passed in the request string [EditOrganizationEmails.aspx]."); } else { orgId.Value = orgIdStr; } LiftDomain.Organization thisOrganization = new LiftDomain.Organization(); thisOrganization.id.Value = Convert.ToInt32(orgIdStr); //------------------------------------------------------------------------- //-- query database for data for this organization //------------------------------------------------------------------------- thisOrganization = thisOrganization.doSingleObjectQuery <LiftDomain.Organization>("select"); title_label.Text = LiftDomain.Language.Current.ORGANIZATION_EDITING_ORGANIZATION.Value + " " + thisOrganization.title; //------------------------------------------------------------------------- //-- query database for data for this organization's emails //------------------------------------------------------------------------- thisOrgEmail.organization_id.Value = thisOrganization.id.Value; try { thisOrgEmail = thisOrgEmail.doSingleObjectQuery <LiftDomain.OrgEmail>("select"); id.Value = thisOrgEmail.id.Value.ToString(); //------------------------------------------------------------------------- //-- populate the screen controls //------------------------------------------------------------------------- organization_email_to_webmaster.Text = thisOrgEmail.webmaster_email_to; organization_email_to_contact_us.Text = thisOrgEmail.contact_us_email_to; organization_email_to_encourager.Text = thisOrgEmail.encourager_email_to; } catch { id.Value = "0"; } organization_from_email_address.Text = Organization.Current.getFromEmail(); organization_from_email_address.ReadOnly = true; } } catch (Exception x) { //TODO: ??? WHAT DO WE DO IF THERE IS AN ERROR ??? string m = x.Message; System.Diagnostics.Debug.Print("[" + DateTime.Now.ToString() + "] *** ERROR IN EditOrganizationEmails.aspx.cs::Page_Load(): " + m); Logger.log("EditOrganizationEmails.aspx.cs", x, "[" + DateTime.Now.ToString() + "] *** ERROR IN EditOrganizationEmails.aspx.cs::Page_Load(): " + m); } finally { } }
//------------------------------------------------------------------------- //-- 1) Create new org from scratch. There should be a placeholder for a terms of use agreement. //-- 2) Signup user as org admin for new org. This new user's email address will be copied to the webmaster email role in the org_emails table. //-- 3) Create email accounts using the HostingProvider interface //-- 4) Create org_emails records //-- 5) Create the /custom/org/images and /custom/org/stylesheets folders //-- 6) There will be a new org status - approved and unapproved. The org will initially be created in the unapproved state. //-- 7) The system will send an email to [email protected] to notify of org requesting approval. //-- 8) The org list page will show the approval status of orgs. //-- 9) The org edit page will enable the sys admin to approve an org. //-- 10) The system will generate an email to the org webmaster indicating that the new org has been approved. //------------------------------------------------------------------------- protected void Page_Load(object sender, EventArgs e) { EmailValidator.ErrorMessage = LiftDomain.Language.Current.SHARED_MUST_BE_A_VALID_EMAIL_ADDRESS; if (!Organization.setCurrent()) { Response.Redirect(LiftContext.Redirect); } PageAuthorized.check(Request, Response); string initialTimeZone = "Central Standard Time"; int initialLanguageId = 1; //-- 1 = English string saltValue = string.Empty; string thisDirectory = string.Empty; try { //------------------------------------------------------------------------- //-- do the language setting for the SUBMIT button here //-- (unable to place <%=LiftDomain.Language.Current.SHARED_SUBMIT %> in asp:Button Text field) //------------------------------------------------------------------------- this.submitBtn.Text = LiftDomain.Language.Current.SHARED_SUBMIT.Value; if (IsPostBack) { //------------------------------------------------------------------------- //-- instantiate the object //------------------------------------------------------------------------- LiftDomain.Organization thisOrganization = new LiftDomain.Organization(); //------------------------------------------------------------------------- //-- transfer screen values to the object //------------------------------------------------------------------------- //TODO: ???what if data field validation fails??? // TO BE DONE IN JAVASCRIPT //TODO: ???what if org title already exists??? // TO BE DONE IN JAVASCRIPT //TODO: ???what if org subdomain already exists??? // TO BE DONE IN JAVASCRIPT //TODO: ???should this be wrapped in a transaction??? //thisOrganization.id.Value = 0; //-- id of "0" means "new" thisOrganization.title.Value = organization_title.Text; thisOrganization.user_id.Value = 0; // LiftDomain.User.Current.id.Value; thisOrganization.address.Value = organization_address.Text; thisOrganization.city.Value = organization_city.Text; thisOrganization.state_province.Value = organization_state.Text; thisOrganization.postal_code.Value = organization_postal_code.Text; thisOrganization.phone.Value = organization_phone.Text; thisOrganization.subdomain.Value = organization_subdomain.Text; thisOrganization.time_zone.Value = initialTimeZone; thisOrganization.language_id.Value = initialLanguageId; thisOrganization.status.Value = 0; //-- 0 = unapproved; 1 = approved thisOrganization.created_at.Value = LiftTime.CurrentTime; //------------------------------------------------------------------------- //-- persist the object data to the database //------------------------------------------------------------------------- thisOrganization.id.Value = Convert.ToInt32(thisOrganization.doCommand("save")); if (thisOrganization.id.Value != 0) { //------------------------------------------------------------------------- //-- instantiate the child object //------------------------------------------------------------------------- //TODO: ???what if data field validation fails??? // TO BE DONE IN JAVASCRIPT LiftDomain.OrgEmail thisOrgEmail = new LiftDomain.OrgEmail(); //thisOrgEmail.id.Value = 0; //-- id of "0" means "new" thisOrgEmail.organization_id.Value = thisOrganization.id.Value; thisOrgEmail.smtp_server.Value = "smtp.liftprayer.cc"; thisOrgEmail.smtp_username.Value = thisOrganization.subdomain.Value + "*****@*****.**"; //thisOrgEmail.smtp_username.Value = "*****@*****.**"; thisOrgEmail.smtp_password.Value = "liftprayer"; thisOrgEmail.smtp_port.Value = 25; thisOrgEmail.email_from.Value = thisOrganization.subdomain.Value + "*****@*****.**"; //thisOrgEmail.email_from.Value = "*****@*****.**"; thisOrgEmail.email_to.Value = organization_email_to_webmaster.Text; thisOrgEmail.webmaster_email_to.Value = organization_email_to_webmaster.Text; //------------------------------------------------------------------------- //-- persist the child object data to the database //------------------------------------------------------------------------- thisOrgEmail.doCommand("save"); //************************************************************************* //TODO: ???create email accounts using the HostingProvider interface??? //************************************************************************* //------------------------------------------------------------------------- //-- create organization-specific file system directories //------------------------------------------------------------------------- thisDirectory = Server.MapPath("."); if (!Directory.Exists(thisDirectory + "\\..\\custom\\" + thisOrganization.subdomain.Value + "\\images")) { Directory.CreateDirectory(thisDirectory + "\\..\\custom\\" + thisOrganization.subdomain.Value + "\\images"); } if (!File.Exists(thisDirectory + "\\..\\custom\\" + thisOrganization.subdomain.Value + "\\images\\logo.gif")) { //File.Copy(thisDirectory + "\\..\\custom\\standard\\images\\logo.gif", thisDirectory + "\\custom\\" + thisOrganization.subdomain.Value + "\\images\\logo.gif"); copyDirectory(thisDirectory + "\\..\\custom\\standard\\images", thisDirectory + "\\..\\custom\\" + thisOrganization.subdomain.Value + "\\images"); } if (!Directory.Exists(thisDirectory + "\\..\\custom\\" + thisOrganization.subdomain.Value + "\\stylesheets")) { Directory.CreateDirectory(thisDirectory + "\\..\\custom\\" + thisOrganization.subdomain.Value + "\\stylesheets"); } if (!File.Exists(thisDirectory + "\\..\\custom\\" + thisOrganization.subdomain.Value + "\\stylesheets\\lift_custom.css")) { //File.Copy(thisDirectory + "\\..\\custom\\standard\\stylesheets\\lift_base.css", thisDirectory + "\\custom\\" + thisOrganization.subdomain.Value + "\\stylesheets\\lift_custom.css"); createStylesheet(thisDirectory + "\\..\\custom\\standard\\stylesheets", thisDirectory + "\\..\\custom\\" + thisOrganization.subdomain.Value + "\\stylesheets"); } //------------------------------------------------------------------------- //-- email a request for approval to the system administrator //------------------------------------------------------------------------- /* * LiftCommon.Email emailHelper = new LiftCommon.Email(); * * emailHelper.server = ConfigReader.getString("smtp_server", ""); // thisOrgEmail.smtp_server; * // emailHelper.username = ConfigReader.getString("smtp_username", ""); // thisOrgEmail.smtp_username; * emailHelper.password = ConfigReader.getString("smtp_password", ""); // thisOrgEmail.smtp_password; * emailHelper.port = ConfigReader.getInt("smtp_port", 25); // thisOrgEmail.smtp_port; * * //email.replyTo = thisOrgEmail.emailReplyTo; // not supported yet * * emailHelper.from = thisOrganization.getFromEmail(); * * //TODO: ??? THIS NEEDS TO BE A VALID E-MAIL ADDRESS * if (LiftCommon.Email.IsValidEmailAddress(thisOrgEmail.webmaster_email_to.Value)) * { * * } * else * { * //TODO: ??? HOW DO WE NOTIFY THE USER * Logger.log(Logger.Level.ERROR, this, "E-mail address '" + thisOrgEmail.webmaster_email_to.Value + "' is not in a correct format [SignupOrganization.aspx]."); * throw new ApplicationException("E-mail address '" + thisOrgEmail.webmaster_email_to.Value + "' is not in a correct format [SignupOrganization.aspx]."); * } * * emailHelper.addTo("*****@*****.**"); * //emailHelper.addTo("*****@*****.**"); * * emailHelper.subject = LiftDomain.Language.Current.SIGNUP_ORGANIZATION_APPROVAL_REQUEST_SUBJECT.Value; * emailHelper.Body = LiftDomain.Language.Current.SIGNUP_ORGANIZATION_APPROVAL_REQUEST_MESSAGE.Value + " " + thisOrganization.title.Value; * * //email.MIME = MIME.Text | MIME.HTML; // just supposing that it supports multiple formats. May not be necessary * * emailHelper.send(); * */ } else { //else, org ID is zero, but try-catch did not handle it for some reason??? } //------------------------------------------------------------------------- //-- navigate to the Organization edit screen //------------------------------------------------------------------------- Response.Redirect("EditOrganization.aspx?id=" + thisOrganization.id.Value.ToString()); } else { organization_email_to_webmaster.Text = LiftDomain.User.Current.email.Value; } } catch (Exception x) { //TODO: ??? WHAT DO WE DO IF THERE IS AN ERROR ??? string m = x.Message; System.Diagnostics.Debug.Print("[" + DateTime.Now.ToString() + "] *** ERROR IN SignupOrganization.aspx.cs::Page_Load(): " + m); Logger.log("SignupOrganization.aspx.cs", x, "[" + DateTime.Now.ToString() + "] *** ERROR IN SignupOrganization.aspx.cs::Page_Load(): " + m); } finally { } }