Exemplo n.º 1
0
        public static Organization getOrg(int organizationId)
        {
            Organization org = new Organization();

            org.id.Value = organizationId;
            org          = (Organization)org.doSingleObjectQuery(typeof(Organization), "select");

            if (org != null)
            {
                string subdomain = org.subdomain.Value;

                lock (orgSync)
                {
                    if (orgs.ContainsKey(subdomain))
                    {
                        org = (Organization)orgs[subdomain];
                    }
                    else
                    {
                        Organization.loadAll();
                        if (orgs.ContainsKey(subdomain))
                        {
                            org = (Organization)orgs[subdomain];
                        }
                    }
                }
            }
            return(org);
        }
Exemplo n.º 2
0
        public long save()
        {
            long result = ((DatabasePersist)persistence).save();

            if (ContainsKey("id"))
            {
                Organization newOrg = new Organization();
                newOrg.id.Value = getInt("id");

                newOrg = newOrg.doSingleObjectQuery <Organization>("getobject");

                lock (orgSync)
                {
                    orgs[newOrg.subdomain.Value] = newOrg;
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        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
            {
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Organization.setCurrent())
            {
                Response.Redirect(LiftContext.Redirect);
            }

            PageAuthorized.check(Request, Response);

            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)
                {
                    string idStr = Request["id"];

                    if (String.IsNullOrEmpty(idStr))
                    {
                        //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
                    {
                        id.Value = idStr;
                    }

                    LiftDomain.Organization thisOrganization = new LiftDomain.Organization();
                    thisOrganization.id.Value = Convert.ToInt32(id.Value);

                    //-------------------------------------------------------------------------
                    //-- 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;
                    this.subdomain.Value = thisOrganization.subdomain;

                    string serverFileLocation = Server.MapPath("/custom/" + this.subdomain.Value + "/stylesheets/lift_custom.css");

                    if (File.Exists(serverFileLocation))
                    {
                        StreamReader sr;
                        sr = File.OpenText(serverFileLocation);
                        this.lift_custom_css.Text = sr.ReadToEnd();
                        sr.Close();
                    }
                }
            }
            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 EditOrganizationAppearance.aspx.cs::Page_Load(): " + m);
                Logger.log("EditOrganizationAppearance.aspx.cs", x, "[" + DateTime.Now.ToString() + "] *** ERROR IN EditOrganizationAppearance.aspx.cs::Page_Load(): " + m);
            }
            finally
            {
            }
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Organization.setCurrent())
            {
                Response.Redirect(LiftContext.Redirect);
            }

            PageAuthorized.check(Request, Response);

            try
            {
                //-------------------------------------------------------------------------
                //-- do the language settings for the buttons here
                //-- (e.g., unable to place <%=LiftDomain.Language.Current.SHARED_UPLOAD %> in asp:Button Text field)
                //-------------------------------------------------------------------------
                this.addBtn.Text    = LiftDomain.Language.Current.ORGANIZATION_IMAGES_ADD_TO_LIST.Value;
                this.removeBtn.Text = LiftDomain.Language.Current.ORGANIZATION_IMAGES_REMOVE_FROM_LIST.Value;
                this.uploadBtn.Text = LiftDomain.Language.Current.ORGANIZATION_IMAGES_UPLOAD_TO_SERVER.Value;

                if (!IsPostBack)
                {
                    string idStr = Request["id"];

                    if (String.IsNullOrEmpty(idStr))
                    {
                        //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
                    {
                        id.Value = idStr;
                    }

                    LiftDomain.Organization thisOrganization = new LiftDomain.Organization();
                    thisOrganization.id.Value = Convert.ToInt32(id.Value);

                    //-------------------------------------------------------------------------
                    //-- 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;
                    this.subdomain.Value = thisOrganization.subdomain;
                }

                //-------------------------------------------------------------------------
                //-- display list of server-side image files for this organization
                //-------------------------------------------------------------------------
                DisplayOrganizationImageList();
            }
            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 EditOrganizationImages.aspx.cs::Page_Load(): " + m);
                Logger.log("EditOrganizationImages.aspx.cs", x, "[" + DateTime.Now.ToString() + "] *** ERROR IN EditOrganizationImages.aspx.cs::Page_Load(): " + m);
            }
            finally
            {
            }
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Organization.setCurrent())
            {
                Response.Redirect(LiftContext.Redirect);
            }

            PageAuthorized.check(Request, Response);

            string initialTimeZone        = "Central Standard Time";
            int    initialLanguageId      = 1; //-- 1 = English
            int    initialStatusId        = 0; //-- 0 = Unapproved; 1 = Approved
            string saltValue              = string.Empty;
            bool   sendOrgIsApprovedEmail = false;

            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;

                //-------------------------------------------------------------------------
                //-- do other language settings
                //-------------------------------------------------------------------------
                edit_organization_fieldset_legend = LiftDomain.Language.Current.ORGANIZATION_EDIT_ORGANIZATION.Value;

                LiftDomain.Organization thisOrganization = new LiftDomain.Organization();

                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"))
                    {
                        thisOrganization.id.Value = int.Parse(id.Value);
                    }
                    else
                    {
                        //-------------------------------------------------------------------------
                        //-- if the object ID is blank or zero (0), then set some NEW object values (NOT id)
                        //-------------------------------------------------------------------------
                        thisOrganization.created_at.Value = LiftTime.CurrentTime;
                    }

                    //-------------------------------------------------------------------------
                    //-- 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
                    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      = timezone_list.SelectedItem.Value;
                    thisOrganization.language_id.Value    = Convert.ToInt32(language_list.SelectedItem.Value);
                    thisOrganization.footer.Value         = organization_footer.Text;

                    thisOrganization.default_approval.Value = (default_approved.Checked ? 1 : 0);

                    thisOrganization.default_signup_mode.Value = (new_users_require_approval.Checked ? 1 : 0);


                    //-------------------------------------------------------------------------
                    //-- if the status changes from "Unapproved" to "Approved,"
                    //-- then we want to notify the organization's webmaster
                    //-------------------------------------------------------------------------
                    if (thisOrganization.id.Value != 0)
                    {
                        LiftDomain.Organization tempOrganization = new LiftDomain.Organization();
                        tempOrganization.id.Value = thisOrganization.id.Value;
                        tempOrganization          = tempOrganization.doSingleObjectQuery <LiftDomain.Organization>("select");

                        if ((tempOrganization.status == 0) && (Convert.ToInt32(language_list.SelectedItem.Value) == 1))
                        {
                            sendOrgIsApprovedEmail = true;
                        }
                    }
                    thisOrganization.status.Value = Convert.ToInt32(organization_status_list.SelectedItem.Value);

                    //-------------------------------------------------------------------------
                    //-- persist the object data to the database
                    //-------------------------------------------------------------------------
                    thisOrganization.id.Value = Convert.ToInt32(thisOrganization.doCommand("save"));

                    //id.Value = thisOrganization.id.Value.ToString();

                    //-------------------------------------------------------------------------
                    //-- send the approval email to the organization's webmaster
                    //-------------------------------------------------------------------------
                    if (sendOrgIsApprovedEmail)
                    {
                        LiftCommon.Email    emailHelper  = new LiftCommon.Email();
                        LiftDomain.OrgEmail thisOrgEmail = new LiftDomain.OrgEmail();
                        thisOrgEmail.organization_id.Value = thisOrganization.id.Value;
                        thisOrgEmail = thisOrgEmail.doSingleObjectQuery <LiftDomain.OrgEmail>("select");

                        //email.replyTo = thisOrgEmail.emailReplyTo;  // not supported yet

                        emailHelper.from = "*****@*****.**";

                        //TODO: ??? THIS NEEDS TO BE A VALID E-MAIL ADDRESS
                        if (LiftCommon.Email.IsValidEmailAddress(thisOrgEmail.webmaster_email_to.Value))
                        {
                            emailHelper.addTo(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.subject = LiftDomain.Language.Current.SIGNUP_ORGANIZATION_APPROVAL_RESPONSE_SUBJECT.Value;
                        emailHelper.Body    = LiftDomain.Language.Current.SIGNUP_ORGANIZATION_APPROVAL_RESPONSE_MESSAGE.Value + "  " + thisOrganization.title.Value;

                        //email.MIME = MIME.Text | MIME.HTML;  // just supposing that it supports multiple formats. May not be necessary

                        emailHelper.send();
                    }

                    if (LiftDomain.User.Current.isSysAdmin)
                    {
                        //-------------------------------------------------------------------------
                        //-- return to the Organization List page
                        //-------------------------------------------------------------------------
                        if (Session["last_org_list_search"] != null)
                        {
                            Response.Redirect("OrganizationList.aspx?" + Session["last_org_list_search"]);
                        }
                        else
                        {
                            Response.Redirect("OrganizationList.aspx");
                        }
                    }
                    else
                    {
                        Response.Redirect("Admin.aspx");
                    }
                }
                else
                {
                    //-------------------------------------------------------------------------
                    //-- first time on this page, so get the organization ID from the ASP Request cache
                    //-------------------------------------------------------------------------
                    string idStr = Request["id"];

                    if (String.IsNullOrEmpty(idStr))
                    {
                        id.Value = "0";
                    }
                    else
                    {
                        id.Value = idStr;
                    }

                    thisOrganization.id.Value = Convert.ToInt32(id.Value);

                    //-------------------------------------------------------------------------
                    //-- if this is a NEW organization...
                    //-------------------------------------------------------------------------
                    if (id.Value == "0")
                    {
                        //-------------------------------------------------------------------------
                        //-- set default values
                        //-------------------------------------------------------------------------
                        initialTimeZone   = LiftDomain.Organization.Current.time_zone.Value;
                        initialLanguageId = LiftDomain.Organization.Current.language_id.Value;
                        initialStatusId   = 0; //-- 0 = Unapproved; 1 = Approved

                        title_label.Visible = false;
                        edit_organization_fieldset_legend = LiftDomain.Language.Current.ORGANIZATION_CREATE_A_NEW_ORGANIZATION.Value;

                        delete_organization_id        = string.Empty;
                        redirect_after_delete_to_page = string.Empty;
                    }

                    //-------------------------------------------------------------------------
                    //-- else, if this is an EXISTING organization...
                    //-------------------------------------------------------------------------
                    else
                    {
                        //-------------------------------------------------------------------------
                        //-- query database for data for this organization
                        //-------------------------------------------------------------------------
                        thisOrganization = thisOrganization.doSingleObjectQuery <LiftDomain.Organization>("select");

                        initialTimeZone   = thisOrganization.time_zone;
                        initialLanguageId = thisOrganization.language_id;
                        initialStatusId   = thisOrganization.status;

                        title_label.Text = LiftDomain.Language.Current.ORGANIZATION_EDITING_ORGANIZATION.Value + " " + thisOrganization.title;
                        edit_organization_fieldset_legend = LiftDomain.Language.Current.ORGANIZATION_EDIT_ORGANIZATION.Value;

                        delete_organization_id = id.Value;

                        if (Session["last_org_list_search"] != null)
                        {
                            redirect_after_delete_to_page = "OrganizationList.aspx?" + Session["last_org_list_search"];
                        }
                        else
                        {
                            redirect_after_delete_to_page = "OrganizationList.aspx";
                        }
                    }

                    //-------------------------------------------------------------------------
                    //-- populate the screen controls
                    //-------------------------------------------------------------------------
                    organization_title.Text       = thisOrganization.title;
                    organization_address.Text     = thisOrganization.address;
                    organization_city.Text        = thisOrganization.city;
                    organization_state.Text       = thisOrganization.state_province;
                    organization_postal_code.Text = thisOrganization.postal_code;
                    organization_phone.Text       = thisOrganization.phone;
                    organization_subdomain.Text   = thisOrganization.subdomain;
                    organization_footer.Text      = thisOrganization.footer;
                    if (thisOrganization.default_approval.Value == 1)
                    {
                        this.default_approved.Checked     = true;
                        this.default_not_approved.Checked = false;
                    }
                    else
                    {
                        this.default_approved.Checked     = false;
                        this.default_not_approved.Checked = true;
                    }

                    if (thisOrganization.default_signup_mode.Value == (int)UserSignupMode.user_create_account)
                    {
                        this.new_users_create_accounts.Checked  = true;
                        this.new_users_require_approval.Checked = false;
                    }
                    else
                    {
                        this.new_users_create_accounts.Checked  = false;
                        this.new_users_require_approval.Checked = true;
                    }

                    initTimeZoneList(initialTimeZone);
                    initLanguageList(initialLanguageId);
                    initOrganizationStatusList(initialStatusId);
                }
            }
            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 EditOrganization.aspx.cs::Page_Load(): " + m);
                Logger.log("EditOrganization.aspx.cs", x, "[" + DateTime.Now.ToString() + "] *** ERROR IN EditOrganization.aspx.cs::Page_Load(): " + m);
            }
            finally
            {
            }
        }