Пример #1
0
        protected void notify_user_account_status(string msgTemplate)
        {
            User u = new User();

            u.id.Value = this.id.Value;
            u          = (User)u.doSingleObjectQuery(typeof(User), "select");

            Organization o = Organization.Current;

            OrgEmail oe = new OrgEmail();

            oe.organization_id.Value = o.id.Value;
            oe = oe.doSingleObjectQuery <OrgEmail>("select");

            string notificationMsg = msgTemplate;

            notificationMsg = notificationMsg.Replace("$(ORGNAME)", o.title.Value);
            notificationMsg = notificationMsg.Replace("$(USERNAME)", u.email.Value);
            notificationMsg = notificationMsg.Replace("$(WEBMASTER)", oe.webmaster_email_to.Value);
            notificationMsg = notificationMsg.Replace("$(SUBDOMAIN)", o.subdomain.Value);


            Email email = new Email();

            email.subject = "New Account Request";
            email.Body    = notificationMsg;
            email.addTo(u.email.Value);
            email.from = Organization.Current.getFromEmail();
            email.send();
        }
Пример #2
0
        protected void notify_webmaster_new_account()
        {
            User u = new User();

            u.id.Value = this.id.Value;
            u          = (User)u.doSingleObjectQuery(typeof(User), "select");

            Organization o = Organization.Current;

            OrgEmail oe = new OrgEmail();

            oe.organization_id.Value = o.id.Value;
            oe = oe.doSingleObjectQuery <LiftDomain.OrgEmail>("select");


            string notification_msg = notify_webmaster_email;

            notification_msg = notification_msg.Replace("$(ORGNAME)", o.title);
            notification_msg = notification_msg.Replace("$(USERNAME)", u.email.Value);

            Email email = new Email();

            email.subject = "New Account Request";
            email.Body    = notification_msg;
            email.addTo(oe.webmaster_email_to.Value);
            email.from = Organization.Current.getFromEmail();
            email.send();
        }
Пример #3
0
        protected void notifySubscribers(LiftContext ctx)
        {
            Organization org = Organization.Current;

            OrgEmail oe = new OrgEmail();

            oe.organization_id.Value = org.id.Value;
            oe = oe.doSingleObjectQuery <OrgEmail>("select");

            Request r = new Request();

            r.id.Value = ctx.getInt("request_id");
            List <Request> rlist = r.doQuery <Request>("get_most_recent_update");


            StringBuilder body = new StringBuilder();

            string title = string.Empty;

            foreach (Request u in rlist)
            {
                if (title.Length == 0)
                {
                    title = u.title.Value;
                }

                body.Append("From: ");
                body.Append(u.from.Value);
                body.Append(" (");
                body.Append(u.from_email.Value);
                body.Append(")");
                // body.Append(u.getDateTime("post_date").ToString("G"));  // times are in utc - needs to be converted to subscriber tz
                body.Append("\r\n\r\n");
                body.Append(u.description.Value);
                body.Append("\r\n\r\n");
            }

            Email e = new Email();

            e.from = org.getFromEmail();
            e.Body = body.ToString();

            e.subject = "Update: " + title;

            Subscription s = new Subscription();

            s.request_id.Value = ctx.getInt("request_id");
            DataSet subsribers = s.doQuery("get_subscribers");

            if (DatabasePersist.hasData(subsribers))
            {
                foreach (DataRow subscriber in subsribers.Tables[0].Rows)
                {
                    e.clearRecipients();
                    e.addTo(subscriber["email"].ToString());
                    e.send();
                }
            }
        }
Пример #4
0
        public OrgEmail getOrgEmail(string orgEmailTitle)
        {
            OrgEmail thisOrgEmail = new OrgEmail();

            thisOrgEmail.organization_id.Value = this.id;
            thisOrgEmail.title.Value           = orgEmailTitle;
            thisOrgEmail = thisOrgEmail.doSingleObjectQuery <OrgEmail>("select");



            return(thisOrgEmail);
        }
Пример #5
0
        protected void notifyEncouragers(LiftContext ctx)
        {
            Organization org = Organization.Current;

            Request r = new Request();

            r.id.Value = ctx.getInt("request_id");
            r          = r.doSingleObjectQuery <Request>("getobject");

            if (r.needs_encouragement.Value == 1)
            {
                OrgEmail oe = new OrgEmail();
                oe.organization_id.Value = org.id.Value;
                oe = oe.doSingleObjectQuery <OrgEmail>("select");

                Email e = new Email();
                e.from = org.getFromEmail();
                e.addTo(oe.encourager_email_to.Value);
                e.subject  = "New Encouragement Request: ";
                e.subject += r.title.Value;

                StringBuilder body = new StringBuilder();
                if (r.listed.Value == 0)
                {
                    body.Append("*** PRIVATE ***\r\n\r\n");
                }
                body.Append("REQUEST ID: "); body.Append(r.id.Value); body.Append("\r\n\r\n");
                body.Append("TITLE\r\n"); body.Append(r.title.Value); body.Append("\r\n\r\n");
                body.Append("DESCRIPTION\r\n"); body.Append(r.description.Value); body.Append("\r\n\r\n");
                body.Append("POST DATE\r\n"); body.Append(r.post_date.Value.ToString("G")); body.Append("\r\n\r\n");
                // body.Append("IS FOR\r\n"); body.Append(r.is_for.Value); body.Append("\r\n");
                // body.Append("IS APPROVED\r\n"); body.Append(r.is_approved.Value.ToString("G")); body.Append("\r\n");
                body.Append("LAST ACTION\r\n"); body.Append(r.last_action.Value.ToString("G")); body.Append("\r\n\r\n");
                body.Append("FROM\r\n"); body.Append(r.from.Value); body.Append("\r\n\r\n");
                body.Append("FROM EMAIL\r\n"); body.Append(r.from_email.Value); body.Append("\r\n\r\n");
                body.Append("ENCOURAGEMENT ADDRESS\r\n"); body.Append(r.encouragement_address.Value); body.Append("\r\n\r\n");
                //body.Append("ENCOURAGEMENT EMAIL\r\n"); body.Append(r.encouragement_email.Value); body.Append("\r\n\r\n");
                body.Append("ENCOURAGEMENT PHONE\r\n"); body.Append(r.encouragement_phone.Value); body.Append("\r\n\r\n");

                e.Body = body.ToString();
                e.send();

                r.Clear();
                r.id.Value = id;
                r.needs_encouragement.Value = 0;
                r.doCommand("update");
            }
        }
Пример #6
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
            {
            }
        }
Пример #7
0
        //-------------------------------------------------------------------------
        //-- 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
            {
            }
        }
Пример #8
0
        public void notifyAdjacent(int currentWallId, int userId, int dow, int tod, bool subscribe)
        {
            string header         = headerMsg;
            string recvMsg        = string.Empty;
            string giveMsg        = string.Empty;
            string subj           = string.Empty;
            string thisUserHeader = string.Empty;

            if (subscribe)
            {
                recvMsg        = recvWatchMsg;
                giveMsg        = giveWatchMsg;
                subj           = "New Watchman Notification";
                thisUserHeader = headerMsg;
            }
            else
            {
                recvMsg        = noLongerRecvWatchMsg;
                giveMsg        = noLongerGiveWatchMsg;
                subj           = "Watchman Change Notifcation";
                thisUserHeader = unsubscribeHeaderMsg;
            }


            OrgEmail oe = new OrgEmail();

            oe.organization_id.Value = Organization.Current.id.Value;
            oe = oe.doSingleObjectQuery <OrgEmail>("select");

            int prevDow = 0;
            int prevTod = 0;
            int nextDow = 0;
            int nextTod = 0;

            calcPrev(dow, tod, ref prevDow, ref prevTod);
            calcNext(dow, tod, ref nextDow, ref nextTod);

            Appt adj = new Appt();

            adj["wall_id"]  = currentWallId;
            adj["next_tod"] = nextTod;
            adj["next_dow"] = nextDow;
            adj["prev_tod"] = prevTod;
            adj["prev_dow"] = prevDow;

            adj["tzoffset"] = LiftTime.UserTzOffset;

            DataSet neighbors = adj.doQuery("get_adjacent");
            User    thisUser  = new User();

            thisUser.id.Value = userId;
            thisUser          = thisUser.doSingleObjectQuery <User>("getobject");

            User prior = null;
            User next  = null;

            if (DatabasePersist.hasData(neighbors))
            {
                foreach (DataRow neighbor in neighbors.Tables[0].Rows)
                {
                    string rel = neighbor["rel"].ToString();

                    if (rel == "before")
                    {
                        prior          = new User();
                        prior.id.Value = Convert.ToInt32(neighbor["user_id"]);
                        prior          = prior.doSingleObjectQuery <User>("getobject");
                    }

                    if (rel == "after")
                    {
                        next          = new User();
                        next.id.Value = Convert.ToInt32(neighbor["user_id"]);
                        next          = next.doSingleObjectQuery <User>("getobject");
                    }
                }
            }

            StringBuilder currentBody = new StringBuilder(thisUserHeader);

            replace(currentBody, "day_name", getDay(dow));
            replace(currentBody, "time", getTime(tod));

            if (prior != null)
            {
                StringBuilder priorBody = new StringBuilder(header);
                replace(priorBody, "day_name", getDay(prevDow));
                replace(priorBody, "time", getTime(prevTod));

                priorBody.Append(giveMsg);
                replace(priorBody, "next_first_name", thisUser.first_name.Value);
                replace(priorBody, "next_last_name", thisUser.last_name.Value);
                replace(priorBody, "next_email", thisUser.email.Value);
                replace(priorBody, "next_phone", thisUser.phone.Value);

                currentBody.Append(recvMsg);
                replace(currentBody, "prev_first_name", prior.first_name.Value);
                replace(currentBody, "prev_last_name", prior.last_name.Value);
                replace(currentBody, "prev_email", prior.email.Value);
                replace(currentBody, "prev_phone", prior.phone.Value);

                priorBody.Append(footerMsg);

                Email priorEmail = new Email();
                priorEmail.subject = subj;
                priorEmail.Body    = priorBody.ToString();
                priorEmail.addTo(prior.email.Value);
                priorEmail.from = Organization.Current.getFromEmail();
                priorEmail.send();
            }

            if (next != null)
            {
                StringBuilder nextBody = new StringBuilder(header);
                replace(nextBody, "day_name", getDay(nextDow));
                replace(nextBody, "time", getTime(nextTod));

                nextBody.Append(recvMsg);
                replace(nextBody, "prev_first_name", thisUser.first_name.Value);
                replace(nextBody, "prev_last_name", thisUser.last_name.Value);
                replace(nextBody, "prev_email", thisUser.email.Value);
                replace(nextBody, "prev_phone", thisUser.phone.Value);

                currentBody.Append(giveMsg);
                replace(currentBody, "next_first_name", next.first_name.Value);
                replace(currentBody, "next_last_name", next.last_name.Value);
                replace(currentBody, "next_email", next.email.Value);
                replace(currentBody, "next_phone", next.phone.Value);

                nextBody.Append(footerMsg);

                Email nextEmail = new Email();
                nextEmail.subject = subj;
                nextEmail.Body    = nextBody.ToString();
                nextEmail.addTo(next.email.Value);
                nextEmail.from = Organization.Current.getFromEmail();
                nextEmail.send();
            }

            currentBody.Append(footerMsg);

            Email thisEmail = new Email();

            thisEmail.subject = subj;
            thisEmail.Body    = currentBody.ToString();
            thisEmail.addTo(thisUser.email.Value);
            thisEmail.from = Organization.Current.getFromEmail();
            thisEmail.send();
        }
Пример #9
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
            {
            }
        }