Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Organization.setCurrent())
            {
                Response.Redirect(LiftContext.Redirect);
            }

            PageAuthorized.check(Request, Response);

            idStr = Request["id"];
            if (!String.IsNullOrEmpty(idStr))
            {
                try
                {
                    int id = int.Parse(idStr);
                    LiftDomain.Request pr = new LiftDomain.Request();

                    actionStr = Request["action"];
                    if (!String.IsNullOrEmpty(actionStr))
                    {
                        action = actionStr;
                    }

                    pr["id"] = id;
                    pr.doCommand(action);

                    Response.ContentType = "text/javascript";
                }
                catch (Exception x)
                {
                    Logger.log(idStr, x, "Error deleting request");
                }
            }
        }
Example #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Organization.setCurrent())
     {
         Response.Redirect(LiftContext.Redirect);
     }
     //TODO: ???need to impl session mgr feature to track which requests have been prayed for
     idStr = Request["id"];
     if (idStr != null)
     {
         try
         {
             int id = int.Parse(idStr);
             LiftDomain.Request pr = new LiftDomain.Request();
             pr["id"] = id;
             long newTotal = pr.doCommand("update_total");
             newTotalStr          = newTotal.ToString();
             Response.ContentType = "text/javascript";
         }
         catch (Exception x)
         {
             Logger.log(idStr, x, "Error updating total_requests");
         }
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            int sessionId = Convert.ToInt32(Request["s"]);
            int requestId = Convert.ToInt32(Request["r"]);
            int viewed    = Convert.ToInt32(Request["v"]);
            int idx       = Convert.ToInt32(Request["i"]);
            int count     = Convert.ToInt32(Request["c"]);

            prevReqOrdinal    = idx;
            currentReqOrdinal = prevReqOrdinal - 1;

            Prayersession ps = new Prayersession();

            ps["id"] = sessionId;

            ps.doCommand("update_end_time");

            pr["id"] = requestId;

            pr = pr.doSingleObjectQuery <LiftDomain.Request>("get_request");

            pr.get_summary_info(ref title, ref description, ref from, ref requestType, ref aboutTime);

            currentRequestLabel  = Language.Current.PS_CURRENTLY_VIEWING_REQUEST;
            currentRequestLabel += " ";
            currentRequestLabel += idx.ToString();
            currentRequestLabel += " ";
            currentRequestLabel += Language.Current.PS_OF;
            currentRequestLabel += " ";
            currentRequestLabel += count.ToString();

            Response.ContentType = "text/plain";
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int sessionId = Convert.ToInt32(Request["s"]);
            int n         = 0;
            int count     = 0;

            string r = Request["r"];

            if (r == "undefined")
            {
                r = null;
            }

            if (!string.IsNullOrEmpty(r))
            {
                int requestId = Convert.ToInt32(r);
                int viewed    = Convert.ToInt32(Request["v"]);
                int idx       = Convert.ToInt32(Request["i"]);
                count = Convert.ToInt32(Request["c"]);

                n = idx + 1;

                prevReqOrdinal    = idx;
                currentReqOrdinal = prevReqOrdinal + 1;

                Prayersession ps = new Prayersession();
                ps["id"] = sessionId;

                if (viewed == 0)
                {
                    ps.doCommand("incr_total_requests");
                }

                ps.doCommand("update_end_time");

                pr["id"] = requestId;

                pr = pr.doSingleObjectQuery <LiftDomain.Request>("get_request");

                pr.doCommand("update_total");

                pr.get_summary_info(ref title, ref description, ref from, ref requestType, ref aboutTime);
            }
            else
            {
                description = LiftDomain.Language.Current.REQUEST_PRAYER_SESSION_COMPLETE;
                n           = 60;
                count       = 60;
            }
            currentRequestLabel  = Language.Current.PS_CURRENTLY_VIEWING_REQUEST;
            currentRequestLabel += " ";
            currentRequestLabel += n.ToString();
            currentRequestLabel += " ";
            currentRequestLabel += Language.Current.PS_OF;
            currentRequestLabel += " ";
            currentRequestLabel += count.ToString();

            Response.ContentType = "text/plain";
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            PageAuthorized.check(Request, Response);

            string idStr = Request["id"];

            valueStr = Request["value"];

            LiftDomain.Request pr = new LiftDomain.Request();

            pr.id.Value          = Convert.ToInt32(idStr);
            pr.description.Value = valueStr;

            pr.doCommand("update");
        }
Example #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Organization.setCurrent())
            {
                Response.Redirect(LiftContext.Redirect);
            }

            isApprovedStr = Request["ap"];

            if (isApprovedStr == "1")
            {
                PageAuthorized.check(Request, Response);
            }

            idStr = Request["id"];


            if (idStr != null)
            {
                try
                {
                    int id = int.Parse(idStr);
                    LiftDomain.Request pr = new LiftDomain.Request();
                    pr.id.Value          = id;
                    pr.is_approved.Value = (isApprovedStr == "1" ? 1 : 0);
                    pr.last_action.Value = LiftDomain.LiftTime.CurrentTime;
                    pr.updated_at.Value  = LiftDomain.LiftTime.CurrentTime;

                    pr.doCommand("approve");

                    LiftDomain.Encouragement enc = new LiftDomain.Encouragement();
                    enc.request_id.Value  = id;
                    enc.is_approved.Value = (isApprovedStr == "1" ? 1 : 0);
                    enc.approved_at.Value = LiftDomain.LiftTime.CurrentTime;
                    enc.doCommand("approve_all");

                    pr.notify(id);

                    Response.ContentType = "text/javascript";
                }
                catch (Exception x)
                {
                    Logger.log(idStr, x, "Error approving request");
                }
            }
        }
Example #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Organization.setCurrent())
            {
                Response.Redirect(LiftContext.Redirect);
            }

            User U = LiftDomain.User.Current;

            Response.ContentType = "text/javascript";

            currentSessionId = Convert.ToInt64(Request["sessionId"]);

            LiftDomain.Request prayerRequest = new LiftDomain.Request();

            prayerRequest["listed_threshold"] = (U.canSeePrivateRequests ? 0 : 1);

            prayerRequest["approval_threshold"] = 1;
            prayerRequest["active"]             = 1;

            int tf = -90; // last 90 days
            int rt = 0;   // all types

            prayerRequest["timeframe"]   = tf;
            prayerRequest["requesttype"] = rt;
            prayerRequest["search"]      = "";

            DataSet requestSet = prayerRequest.doQuery("get_requests");

            if (requestSet != null)
            {
                if (requestSet.Tables.Count > 0)
                {
                    for (int i = 0; i < Math.Min(requestSet.Tables[0].Rows.Count, 60); i++)
                    {
                        DataRow r = requestSet.Tables[0].Rows[i];
                        requests.Add(Convert.ToInt32(r["id"]));
                    }
                }
            }

            currentRequestLabel = Language.Current.PS_CURRENTLY_VIEWING_REQUEST;
            currentRequestOf    = Language.Current.PS_OF;
        }
Example #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            EmailValidator.ErrorMessage    = LiftDomain.Language.Current.SHARED_MUST_BE_A_VALID_EMAIL_ADDRESS;
            PasswordValidator.ErrorMessage = LiftDomain.Language.Current.SHARED_PASSWORDS_DO_NOT_MATCH;

            if (!Organization.setCurrent())
            {
                Response.Redirect(LiftContext.Redirect);
            }

            PageAuthorized.check(Request, Response);

            int      initialLanguageId = 1; //-- 1 = English
            string   initialTimeZone   = string.Empty;
            string   saltValue         = string.Empty;
            int      sumTotalRequests  = 0;
            TimeSpan sumPrayerSessionsDurationTimeSpan = new TimeSpan();

            //-------------------------------------------------------------------------
            //-- 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;
            this.submitBtnPassword.Text = LiftDomain.Language.Current.SHARED_CHANGE;
            this.submitBtnTimeZone.Text = LiftDomain.Language.Current.SHARED_CHANGE;

            LiftDomain.User thisUser = new LiftDomain.User();

            if (IsPostBack)
            {
                //-------------------------------------------------------------------------
                //-- transfer screen values to the object
                //-------------------------------------------------------------------------
                thisUser.id.Value = int.Parse(id.Value);

                thisUser.login.Value          = login.Text;
                thisUser.first_name.Value     = first_name.Text;
                thisUser.last_name.Value      = last_name.Text;
                thisUser.email.Value          = email.Text;
                thisUser.address.Value        = address.Text;
                thisUser.city.Value           = city.Text;
                thisUser.state_province.Value = state_province.Text;
                thisUser.postal_code.Value    = postal_code.Text;
                thisUser.phone.Value          = phone.Text;

                thisUser.language_id.Value = Convert.ToInt32(language_list.SelectedItem.Value);

                //TODO: ???what if passwords do not match??? // TO BE DONE IN JAVASCRIPT
                //(user_password.Text != user_password_confirmation.Text)

                if (!String.IsNullOrEmpty(user_password.Text.Trim()))
                {
                    thisUser.password_hash_type.Value = "md5";
                    saltValue = LiftDomain.User.generateRandomSalt();
                    thisUser.password_salt.Value    = saltValue;
                    thisUser.crypted_password.Value = LiftDomain.User.hash(user_password.Text, saltValue);
                }

                thisUser.updated_at.Value            = LiftTime.CurrentTime;
                thisUser.time_zone.Value             = timezone_list.SelectedItem.Value;
                thisUser.previous_increment_id.Value = 0;

                //-------------------------------------------------------------------------
                //-- persist the User object data to the database
                //-------------------------------------------------------------------------
                thisUser.doCommand("save_current");

                Response.Redirect("MyAccount.aspx");
            }
            else
            {
                //-------------------------------------------------------------------------
                //-- query database for data for the current user
                //-------------------------------------------------------------------------
                id.Value          = LiftDomain.User.Current.id.Value.ToString();
                thisUser.id.Value = LiftDomain.User.Current.id.Value;
                thisUser          = thisUser.doSingleObjectQuery <LiftDomain.User>("select");
            }

            //-------------------------------------------------------------------------
            //-- populate the screen controls
            //-------------------------------------------------------------------------
            first_name_label.Text = thisUser.first_name;
            last_name_label.Text  = thisUser.last_name;
            login.Text            = thisUser.login;
            created_at.Text       = thisUser.created_at.Value.ToString("dddd MMMM dd, yyyy");

            first_name.Text     = thisUser.first_name;
            last_name.Text      = thisUser.last_name;
            email.Text          = thisUser.email;
            address.Text        = thisUser.address;
            city.Text           = thisUser.city;
            state_province.Text = thisUser.state_province;
            postal_code.Text    = thisUser.postal_code;
            phone.Text          = thisUser.phone;

            initialLanguageId = thisUser.language_id;
            initLanguageList(initialLanguageId);

            initialTimeZone = thisUser.time_zone;
            initTimeZoneList(initialTimeZone);

            //-------------------------------------------------------------------------
            //-- MY PRAYER REQUESTS
            //-------------------------------------------------------------------------

            LiftDomain.Request prayerRequest = new LiftDomain.Request();
            prayerRequest.user_id.Value = thisUser.id;
            prayerRequestSet            = prayerRequest.doQuery("get_my_account_requests");

            if (prayerRequestSet.Tables[0].Rows.Count > 0)
            {
                prayerRequestRenderer       = new PartialRenderer(HttpContext.Current, prayerRequestSet, "_MyAccountRequest.htm", new PartialRenderer.RenderHelper(prayerRequest.my_account_request_helper));
                prayerRequestRendererResult = prayerRequestRenderer;
            }
            else
            {
                prayerRequestRendererResult = "<p>" + LiftDomain.Language.Current.MY_ACCOUNT_YOU_HAVE_NO_REQUESTS.Value + ".</p>";
            }

            //-------------------------------------------------------------------------
            //-- MY PRAYER REQUEST SUBSCRIPTIONS
            //-------------------------------------------------------------------------
            LiftDomain.Subscription prayerRequestSubscription = new LiftDomain.Subscription();
            prayerRequestSubscription.user_id.Value = thisUser.id;
            prayerRequestSubscriptionSet            = prayerRequestSubscription.doQuery("get_subscription_by_user");

            if (prayerRequestSubscriptionSet.Tables[0].Rows.Count > 0)
            {
                prayerRequestSubscriptionRenderer       = new PartialRenderer(HttpContext.Current, prayerRequestSubscriptionSet, "_MyAccountPrayerRequestSubscription.htm", new PartialRenderer.RenderHelper(prayerRequestSubscription.my_account_prayer_request_subscription_helper));
                prayerRequestSubscriptionRendererResult = prayerRequestSubscriptionRenderer;
            }
            else
            {
                prayerRequestSubscriptionRendererResult = "<p>" + LiftDomain.Language.Current.MY_ACCOUNT_YOU_HAVE_NO_SUBSCRIPTIONS.Value + ".</p>";
            }

            //-------------------------------------------------------------------------
            //-- MY PRAYER SESSIONS
            //-------------------------------------------------------------------------
            LiftDomain.Prayersession prayerSessionObject = new LiftDomain.Prayersession();
            prayerSessionObject.user_id.Value = thisUser.id;
            prayerSessionSet = prayerSessionObject.doQuery("get_prayer_sessions_by_user_start_time_desc");

            if (prayerSessionSet.Tables[0].Rows.Count > 0)
            {
                prayerSessionRenderer       = new PartialRenderer(HttpContext.Current, prayerSessionSet, "_MyAccountPrayerSession.htm", new PartialRenderer.RenderHelper(prayerSessionObject.my_account_prayer_session_helper));
                prayerSessionRendererResult = prayerSessionRenderer;

                foreach (DataRow thisDataRow in prayerSessionSet.Tables[0].Rows)
                {
                    sumTotalRequests += Convert.ToInt32(thisDataRow["total_requests"]);
                    sumPrayerSessionsDurationTimeSpan = sumPrayerSessionsDurationTimeSpan.Add(Convert.ToDateTime(thisDataRow["end_time"]) - Convert.ToDateTime(thisDataRow["start_time"]));
                }

                prayer_requests_sum_label          = Convert.ToString(sumTotalRequests);
                prayer_sessions_duration_sum_label = Convert.ToString(sumPrayerSessionsDurationTimeSpan.Hours) + "." + (((float)((float)sumPrayerSessionsDurationTimeSpan.Minutes / (float)60)) * 10).ToString("0");
            }
            else
            {
                prayerSessionRendererResult = "<tr id='request0'><td valign='top' colspan='4' align='center'>" + LiftDomain.Language.Current.MY_ACCOUNT_YOU_HAVE_NO_SESSIONS.Value + ".</td></tr>";
            }
        }
Example #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Organization.setCurrent())
            {
                Response.Redirect(LiftContext.Redirect);
            }

            Organization org = Organization.Current;

            if (org != null)
            {
                customPath  = "/custom/";
                customPath += org.subdomain;
                if (org.subdomain == "upward")
                {
                    initialTimeframe      = -100;
                    duringTheLast         = "&nbsp;";
                    requesttype.Visible   = false;
                    timeframe.Visible     = false;
                    searchBtn.Visible     = false;
                    liveSearchBox.Visible = false;
                    viewingRequestsFor    = string.Empty;
                }
                else
                {
                    initialTimeframe   = -7;
                    duringTheLast      = LiftDomain.Language.Current.REQUESTS_DURING_THE_LAST;
                    viewingRequestsFor = LiftDomain.Language.Current.REQUESTS_VISUALIZE_PRAYER_REQUESTS;
                }
            }

            PageAuthorized.check(Request, Response);

            User U = LiftDomain.User.Current;

            searchBtn.Text = LiftDomain.Language.Current.SHARED_SEARCH;

            LiftDomain.Request prayerRequest = new LiftDomain.Request();

            prayerRequest["listed_threshold"] = (U.canSeePrivateRequests ? 0 : 1);

            prayerRequest["approval_threshold"] = (U.canApproveRequests ? 0 : 1);

            string strActive = Request["active"];

            if (!string.IsNullOrEmpty(strActive))
            {
                try
                {
                    active = int.Parse(strActive);
                }
                catch
                {
                    active = 1;
                }
            }

            active = (U.canApproveRequests ? active : 1);

            prayerRequest["active"] = active;

            if (IsPostBack)
            {
                int    tf     = Convert.ToInt32(timeframe.SelectedItem.Value);
                int    rt     = Convert.ToInt32(requesttype.SelectedItem.Value);
                string search = liveSearchBox.Text;
                prayerRequest["timeframe"]   = tf;
                prayerRequest["requesttype"] = rt;
                prayerRequest["search"]      = search;
                initTimeframe(tf);
                initRequestTypes(rt);
            }
            else
            {
                initRequestTypes(initialRequestType);
                initTimeframe(initialTimeframe);
                prayerRequest["search"]      = "";
                prayerRequest["timeframe"]   = initialTimeframe;
                prayerRequest["requesttype"] = initialRequestType;
            }

            requestSet                  = prayerRequest.doQuery("get_requests");
            requestRenderer             = new RequestRenderer(requestSet);
            requestRenderer.ShowUpdates = true;
            requestRenderer.ShowActive  = (active == 1);
        }
Example #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            public_private_selected.ErrorMessage = Language.Current.REQUEST_PUBLIC_OR_PRIVATE;

            if (!Organization.setCurrent())
            {
                Response.Redirect(LiftContext.Redirect);
            }

            PageAuthorized.check(Request, Response);

            L = LiftDomain.Language.Current;
            LiftDomain.User U = LiftDomain.User.Current;

            submitBtn.Text = L.SHARED_SUBMIT;

            string idStr = Request.Params["id"];

            if (idStr != null)
            {
                if (idStr.Length > 0)
                {
                    request_id.Value = idStr;
                }
            }


            int active = 1;

            LiftDomain.Request prayerRequest = new LiftDomain.Request();
            prayerRequest.id.Value = Convert.ToInt32(request_id.Value);

            // TODO - turn off links to updates and subscriptions here
            // prayerRequest["mode"] = "update_request";
            requestSet                = prayerRequest.doQuery("get_request");
            requestRenderer           = new RequestRenderer(requestSet);
            requestRenderer.ShowLinks = false;

            LiftDomain.Encouragement enc = new LiftDomain.Encouragement();
            enc.request_id.Value      = Convert.ToInt32(request_id.Value);
            enc["listed_threshold"]   = (U.canSeePrivateRequests ? 0 : 1);
            enc["approval_threshold"] = (U.canApproveRequests ? 0 : 1);
            encSet = enc.doQuery("get_updates");

            encRenderer = new EncouragementRenderer(encSet);

            if (IsPostBack)
            {
                if (txtCaptcha.Text.ToString().Trim().ToUpper() == Session["captchaValue"].ToString().Trim().ToUpper())
                {
                    //Response.Write("CAPTCHA verification succeeded");

                    LiftDomain.Encouragement en = new LiftDomain.Encouragement();
                    en.note.Value = note.Text;
                    int t = Convert.ToInt32(encouragement_type.SelectedValue);
                    en.encouragement_type.Value = t;
                    en.from.Value       = from.Text;
                    en.from_email.Value = from_email.Text;

                    if (request_is_public.Checked)
                    {
                        en.listed.Value = 1;
                    }
                    else
                    {
                        en.listed.Value = 0;
                    }

                    en.is_approved.Value = 1;
                    en.created_at.Value  = LiftDomain.LiftTime.CurrentTime;
                    en.post_date.Value   = LiftDomain.LiftTime.CurrentTime;
                    en.updated_at.Value  = LiftDomain.LiftTime.CurrentTime;
                    en.user_id.Value     = LiftDomain.User.Current.id;
                    en.request_id.Value  = Convert.ToInt32(request_id.Value);

                    en.doCommand("save_encouragement");

                    LiftDomain.Request savedRequest = new Request();
                    savedRequest.id.Value = en.request_id.Value;
                    savedRequest          = savedRequest.doSingleObjectQuery <Request>("getobject");
                    active = savedRequest.active.Value;

                    Response.Redirect("Requests.aspx?active=" + active.ToString());
                }
                else
                {
                    errMsg.Text = LiftDomain.Language.Current.REQUEST_UPDATE_NOT_SUCCESSFUL;
                }
            }
            else
            {
                initEncTypes(0);

                from.Text       = LiftDomain.User.Current.FullName;
                from_email.Text = LiftDomain.User.Current.email;
            }

            note.Focus();
        }
Example #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Organization.setCurrent())
            {
                Response.Redirect(LiftContext.Redirect);
            }

            string foo = LiftDomain.Language.Current.REQUEST_FIELDS_OPTIONAL;



            PageAuthorized.check(Request, Response);

            L = LiftDomain.Language.Current;
            LiftDomain.User U = LiftDomain.User.Current;

            submitBtn.Text = L.SHARED_SUBMIT;

            string idStr = Request.Params["id"];

            if (idStr != null)
            {
                if (idStr.Length > 0)
                {
                    request_id.Value = idStr;
                }
            }

            LiftDomain.Request prayerRequest = new LiftDomain.Request();
            prayerRequest.id.Value = Convert.ToInt32(request_id.Value);

            // TODO - turn off links to updates and subscriptions here
            // prayerRequest["mode"] = "update_request";
            requestSet                = prayerRequest.doQuery("get_request");
            requestRenderer           = new RequestRenderer(requestSet);
            requestRenderer.ShowLinks = false;

            LiftDomain.Encouragement enc = new LiftDomain.Encouragement();
            enc.request_id.Value      = Convert.ToInt32(request_id.Value);
            enc["listed_threshold"]   = (U.canSeePrivateRequests ? 0 : 1);
            enc["approval_threshold"] = (U.canApproveRequests ? 0 : 1);
            encSet = enc.doQuery("get_updates");

            encRenderer = new EncouragementRenderer(encSet);

            if (IsPostBack)
            {
                if (txtCaptcha.Text.ToString().Trim().ToUpper() == Session["captchaValue"].ToString().Trim().ToUpper())
                {
                    //Response.Write("CAPTCHA verification succeeded");

                    LiftDomain.Encouragement en = new LiftDomain.Encouragement();
                    en.note.Value = note.Text;

                    en.encouragement_type.Value = (int)Encouragement.Report;
                    en.from.Value       = from.Text;
                    en.from_email.Value = from_email.Text;


                    en.listed.Value = 0;  // always make reports private


                    en.is_approved.Value = 0;
                    en.created_at.Value  = LiftDomain.LiftTime.CurrentTime;
                    en.post_date.Value   = LiftDomain.LiftTime.CurrentTime;
                    en.updated_at.Value  = LiftDomain.LiftTime.CurrentTime;
                    en.user_id.Value     = LiftDomain.User.Current.id;
                    en.request_id.Value  = Convert.ToInt32(request_id.Value);

                    en.doCommand("save_encouragement");

                    LiftDomain.Request pr = new LiftDomain.Request();
                    pr.id.Value          = Convert.ToInt32(request_id.Value);
                    pr.is_approved.Value = 0;
                    pr.last_action.Value = LiftDomain.LiftTime.CurrentTime;
                    pr.updated_at.Value  = LiftDomain.LiftTime.CurrentTime;

                    pr.doCommand("approve");

                    LiftDomain.Encouragement allEnc = new LiftDomain.Encouragement();
                    allEnc.request_id.Value  = Convert.ToInt32(request_id.Value);
                    allEnc.is_approved.Value = 0;
                    allEnc.approved_at.Value = LiftDomain.LiftTime.CurrentTime;
                    allEnc.doCommand("approve_all");

                    Response.Redirect("Requests.aspx");
                }
                else
                {
                    errMsg.Text = LiftDomain.Language.Current.REQUEST_UPDATE_NOT_SUCCESSFUL;
                }
            }
            else
            {
                from.Text       = "";
                from_email.Text = "";
            }

            this.note.Focus();
        }
Example #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            public_private_selected.ErrorMessage = Language.Current.REQUEST_PUBLIC_OR_PRIVATE;

            if (!Organization.setCurrent())
            {
                Response.Redirect(LiftContext.Redirect);
            }

            PageAuthorized.check(Request, Response);

            submitBtn.Text = LiftDomain.Language.Current.SHARED_SUBMIT;
            LiftDomain.User U = LiftDomain.User.Current;
            encouragementRenderer = new EncouragementRenderer();

            int active = 1;

            if (IsPostBack)
            {
                string sessionCaptcha = Session["captchaValue"].ToString();
                string pageCaptcha    = txtCaptcha.Text.ToString().Trim().ToUpper();

                if (txtCaptcha.Text.ToString().Trim().ToUpper() == Session["captchaValue"].ToString().Trim().ToUpper())
                {
                    //Response.Write("CAPTCHA verification succeeded");


                    LiftDomain.Request prayerRequest = new LiftDomain.Request();

                    prayerRequest.title.Value                      = request_title.Text;
                    prayerRequest.description.Value                = request_description.Text;
                    prayerRequest.from.Value                       = request_from.Text;
                    prayerRequest.requesttype_id.Value             = Convert.ToInt32(request_type.SelectedItem.Value);
                    prayerRequest.group_relationship_type_id.Value = Convert.ToInt32(request_group_relationship.SelectedItem.Value);
                    prayerRequest.encouragement_address.Value      = request_encouragement_address.Text;
                    prayerRequest.needs_encouragement.Value        = (request_encouragement_address.Text.Length > 1 ? 1 : 0);

                    prayerRequest.encouragement_phone.Value = request_encouragement_phone.Text;
                    prayerRequest.from_email.Value          = request_from_email.Text;

                    prayerRequest.listed.Value = (request_is_public.Checked ? 1 : 0);

                    prayerRequest.last_action.Value = LiftTime.CurrentTime;
                    prayerRequest.post_date.Value   = LiftTime.CurrentTime;
                    prayerRequest.updated_at.Value  = LiftTime.CurrentTime;

                    prayerRequest.is_approved.Value = Organization.Current.default_approval.Value;

                    prayerRequest.user_id.Value = U.id;

                    if ((id.Value == "0") || (id.Value == ""))
                    {
                        prayerRequest.created_at.Value     = LiftTime.CurrentTime;
                        prayerRequest.total_requests.Value = 0;
                        prayerRequest.total_comments.Value = 0;
                        prayerRequest.total_comments_needing_approval.Value = 0;
                        prayerRequest.total_private_comments.Value          = 0;
                        prayerRequest.active.Value = 1;
                    }
                    else
                    {
                        prayerRequest.id.Value = int.Parse(id.Value);
                        LiftDomain.Request savedRequest = new Request();
                        savedRequest.id.Value = prayerRequest.id.Value;
                        savedRequest          = savedRequest.doSingleObjectQuery <Request>("getobject");
                        active = savedRequest.active.Value;
                    }

                    long ident = prayerRequest.doCommand("save");



                    try
                    {
                        Email ackEmail = new Email();
                        ackEmail.subject = "Thank you for your prayer request";
                        ackEmail.Body    = "Your prayer request has been received.  If you have indicated that your request can be made public, it will appear on the prayer wall as soon as it is approved.";
                        ackEmail.addTo(prayerRequest.from_email.Value);
                        ackEmail.from = Organization.Current.getFromEmail();
                        ackEmail.send();
                    }
                    catch   // ignore any errors
                    { }
                }

                /*
                 * else
                 * {
                 *  // else captcha failed...
                 * }
                 */

                Response.Redirect("Requests.aspx?active=" + active.ToString());
            }
            else
            {
                LiftDomain.Request prayerRequest = new LiftDomain.Request();
                string             idStr         = Request["id"];

                int reqId = 0;
                try
                {
                    if (idStr != null)
                    {
                        if (idStr.Length > 0)
                        {
                            reqId = int.Parse(idStr);
                        }
                    }
                }
                catch
                {
                }

                if (reqId > 0)
                {
                    try
                    {
                        prayerRequest["id"] = reqId;
                        id.Value            = idStr;
                        prayerRequest       = prayerRequest.doSingleObjectQuery <LiftDomain.Request>("getobject");
                        if (!U.canEditRequest(prayerRequest.user_id.Value))
                        {
                            Response.Redirect("Requests.aspx");
                        }

                        request_title.Text                 = prayerRequest.title;
                        request_description.Text           = prayerRequest.description;
                        request_from.Text                  = prayerRequest.from;
                        initialRequestType                 = prayerRequest.requesttype_id;
                        initialGroupType                   = prayerRequest.group_relationship_type_id;
                        request_encouragement_address.Text = prayerRequest.encouragement_address;
                        request_encouragement_phone.Text   = prayerRequest.encouragement_phone;
                        request_from_email.Text            = prayerRequest.from_email;

                        if (prayerRequest.listed == 1)
                        {
                            request_is_private.Checked = false;
                            request_is_public.Checked  = true;
                        }
                        else
                        {
                            request_is_private.Checked = true;
                            request_is_public.Checked  = false;
                        }

                        initUserInfo(prayerRequest.user_id);

                        LiftDomain.Encouragement enc = new LiftDomain.Encouragement();
                        enc.request_id.Value      = reqId;
                        enc["listed_threshold"]   = (U.canApproveRequests ? 0 : 1);
                        enc["approval_threshold"] = (U.canApproveRequests ? 0 : 1);

                        DataSet encDs = enc.doQuery("get_updates");
                        encouragementRenderer.DataSource = encDs;
                        encouragementRenderer.Filename   = "_updateRequest2.htm";
                    }
                    catch (Exception x)
                    {
                        Logger.log(prayerRequest, x, "Error retrieving prayer request.");
                    }
                }
                else
                {
                    initUserInfo(-1);
                }
            }

            initRequestTypes(initialRequestType);
            initGroupRelTypes(1);

            //initTimeZoneList();
            request_title.Focus();
        }