Beispiel #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.User thisUser = new LiftDomain.User();
                    thisUser.id.Value = id;
                    thisUser.doCommand("delete");

                    LiftDomain.RolesUser thisRolesUser = new LiftDomain.RolesUser();
                    thisRolesUser.user_id.Value = thisUser.id.Value;
                    thisRolesUser.doQuery("delete_roles_users_by_user_id");

                    Response.Redirect(Request["redirect_to_page"]);

                    //Response.ContentType = "text/javascript";
                }
                catch (Exception x)
                {
                    Logger.log(idStr, x, "Error deleting user");
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            PageAuthorized.check(Request, Response);
            Organization.setCurrent();

            try
            {
                string idStr        = Request["id"];
                string userStateStr = Request["value"];

                int userState = Convert.ToInt32(userStateStr);

                LiftDomain.User u = new LiftDomain.User();
                u.id.Value    = Convert.ToInt32(idStr);
                u.state.Value = userState;

                userStatus = LiftDomain.User.getUserStatusDescription(userState);

                /* TODO - need a new method to change user status */
                u.doCommand("update_status");
            }
            catch
            {
            }
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Organization.setCurrent())
            {
                Response.Redirect(LiftContext.Redirect);
            }
            //-------------------------------------------------------------------------
            //-- 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;

            if (IsPostBack)
            {
                try
                {
                    //TODO: ??? HOW DO WE VALIDATE THE FORM FIELD DATA (required, max length, valid e-mail address, dangerous content?, etc.)

                    //-------------------------------------------------------------------------
                    //-- get the information entered on the web form
                    //-- and send it in an e-mail to the organization point of contact
                    //-------------------------------------------------------------------------
                    //-- (org_email and org_appearance will specify recipients and smtp settings)
                    //-------------------------------------------------------------------------

                    //YOUR NAME: = contact_from.Text;
                    //YOUR EMAIL: = contact_from_email.Text;
                    //SUBJECT: = contact_subject.Text;
                    //MESSAGE: = contact_message.Text;

                    Organization currentOrganization = Organization.Current;

                    LiftCommon.Email emailHelper = new LiftCommon.Email();

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

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

                    //-------------------------------------------------------------------------
                    //-- get list of all users for the current organization
                    //-------------------------------------------------------------------------
                    LiftDomain.User thisUserList = new LiftDomain.User();
                    thisUserList["search"] = currentOrganization.id.Value;
                    DataSet userListSet = thisUserList.doQuery("SearchUsersByOrg");

                    foreach (DataRow dr in userListSet.Tables[0].Rows)
                    {
                        string email = dr["email"].ToString();

                        if (!String.IsNullOrEmpty(email))
                        {
                            //TODO: ??? VALIDATE THAT THE EMAIL ADDRESS IS A VALID EMAIL ADDRESS FORMAT ???

                            emailHelper.addTo(email);
                        }
                    }

                    emailHelper.subject = email_subject.Text;   // field from the form
                    emailHelper.Body    = email_message.Text;   // field from the form

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

                    emailHelper.send();

                    //TODO: ??? WHERE DO WE REDIRECT TO ???
                    //Response.Redirect("Requests.aspx");
                }
                catch (Exception x)
                {
                    //TODO: ??? WHAT DO WE DO IF THE E-MAIL PROCESS FAILS
                    string m = x.Message;
                    System.Diagnostics.Debug.Print("[" + DateTime.Now.ToString() + "] *** ERROR SENDING E-MAIL: " + m);
                }
                finally
                {
                }
            }
        }
Beispiel #4
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>";
            }
        }
Beispiel #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string cell       = string.Empty;
            string wallId     = string.Empty;
            string dow        = string.Empty;
            string tod        = string.Empty;
            string login      = string.Empty;
            string first_name = string.Empty;
            string last_name  = string.Empty;
            string phone      = string.Empty;
            string email      = string.Empty;
            string password   = string.Empty;

            LiftDomain.Organization.setCurrent();

            cell = Request["cell"];
            string[] parts = cell.Split(new char[] { '_' });
            wallId = parts[0];
            dow    = parts[1];
            tod    = parts[2];

            login      = Request["login"];
            first_name = Request["first_name"];
            last_name  = Request["last_name"];
            phone      = Request["phone"];
            email      = Request["email"];
            password   = Request["password"];

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

            thisUser.password_hash_type.Value = "md5";
            string saltValue = LiftDomain.User.generateRandomSalt();

            thisUser.password_salt.Value = saltValue;

            thisUser.crypted_password.Value           = LiftDomain.User.hash(password, saltValue);
            thisUser.last_password_changed_date.Value = LiftTime.CurrentTime;

            thisUser.state.Value               = 1;
            thisUser.created_at.Value          = LiftTime.CurrentTime;
            thisUser.last_logged_in_at.Value   = new DateTime(2000, 1, 1, 0, 0, 0); //-- DateTime.MinValue;
            thisUser.login_failure_count.Value = 0;

            thisUser.login.Value = login;
            thisUser.email.Value = email;

            thisUser.first_name.Value     = first_name;
            thisUser.last_name.Value      = last_name;
            thisUser.address.Value        = string.Empty;
            thisUser.city.Value           = string.Empty;
            thisUser.state_province.Value = string.Empty;
            thisUser.postal_code.Value    = string.Empty;
            thisUser.phone.Value          = phone;

            thisUser.time_zone.Value   = Organization.Current.time_zone.Value;
            thisUser.language_id.Value = Organization.Current.language_id.Value;

            thisUser.previous_increment_id.Value = 0;
            thisUser.updated_at.Value            = LiftTime.CurrentTime;

            bool ok = true;

            if (LiftDomain.User.checkEmailExists(email))
            {
                ok = false;
            }

            if (LiftDomain.User.checkUsernameExists(login))
            {
                ok = false;
            }


            if (ok)
            {
                thisUser.id.Value = Convert.ToInt32(thisUser.doCommand("save"));

                Appt a = new Appt();

                a["dow"]     = dow;
                a["tod"]     = tod;
                a["user_id"] = thisUser.id.Value;
                a["wall_id"] = wallId;
                a.doCommand("subscribe");

                userId = thisUser.id.Value.ToString();
                appt   = first_name.Substring(0, 1);
                appt  += ". ";
                appt  += last_name;
            }
        }
Beispiel #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Organization.setCurrent())
            {
                Response.Redirect(LiftContext.Redirect);
            }

            PageAuthorized.check(Request, Response);

            Organization org = Organization.Current;

            if (org != null)
            {
                customPath  = "/custom/";
                customPath += org.subdomain;
            }

            try
            {
                string    search = string.Empty;
                UserState state  = UserState.unknown;

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

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

                if (IsPostBack)
                {
                    search = liveSearchBox.Text;
                    state  = (UserState)Convert.ToInt32(user_status_list.SelectedValue);
                    if (search.Length == 0)
                    {
                        search = "%";
                    }
                }
                else
                {
                    if (Session["last_user_list_search"] != null)
                    {
                        search = Session["last_user_list_search"].ToString();
                    }
                    else
                    {
                        search = string.Empty;
                    }

                    if (Session["last_user_list_state"] != null)
                    {
                        state = (UserState)Convert.ToInt32(Session["last_user_list_state"]);
                    }
                    else
                    {
                        state = UserState.unknown;
                    }
                }

                initUserStatusList(state);

                //-------------------------------------------------------------------------
                //-- !!!KLUDGE ALERT:  if first time on this page -or- search string is blank,
                //-- !!!KLUDGE ALERT:  then use a dummy search value which will return no records
                //-------------------------------------------------------------------------
                if (String.IsNullOrEmpty(search))
                {
                    search = "%";
                }



                Session["last_user_list_search"] = search;
                Session["last_user_list_state"]  = (int)state;

                string searchAction = "SearchUsersByFirstOrLast";

                thisUserList["search"] = search;
                thisUserList["state"]  = (int)state;

                if (LiftDomain.User.Current.IsInRole(Role.SYS_ADMIN))
                {
                    thisUserList.OverrideAutoOrgAssignment = true;
                    searchAction = "SearchUsersByFirstOrLastSysAdmin";
                }

                userListSet = thisUserList.doQuery(searchAction);

                if (userListSet.Tables[0].Rows.Count > 0)
                {
                    userListSearchResultsLabel.Visible = false;
                    userListTablePanel.Visible         = true;
                    userListRenderer = // new PartialRenderer(HttpContext.Current, userListSet, "_UserList.htm", newPartialRenderer.RenderHelper(thisUserList.user_list_helper));
                                       userListRenderer = new UserRenderer(userListSet);
                }
                else
                {
                    if (IsPostBack)
                    {
                        userListSearchResultsLabel.Text = LiftDomain.Language.Current.USER_LIST_NO_MATCHING_RECORDS + ".";
                    }
                    else
                    {
                        userListSearchResultsLabel.Text = LiftDomain.Language.Current.USER_LIST_ENTER_VALUE_TO_MATCH + ".";
                    }
                    userListSearchResultsLabel.Visible = true;

                    userListTablePanel.Visible = false;
                }
            }
            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 UserList.aspx.cs::Page_Load(): " + m);
                Logger.log("UserList.aspx.cs", x, "[" + DateTime.Now.ToString() + "] *** ERROR IN UserList.aspx.cs::Page_Load(): " + m);
            }
            finally
            {
            }
        }
Beispiel #7
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();
        }
Beispiel #8
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();
        }
Beispiel #9
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);
            }

            int    initialUserStatus = 1; //-- 1 = unconfirmed
            string initialTimeZone   = "Central Standard Time";
            int    initialLanguageId = 1; //-- 1 = English
            string saltValue         = string.Empty;


            try
            {
                //-------------------------------------------------------------------------
                //-- do the language setting for the SUBMIT button here
                //-- (unable to place <%=LiftDomain.Language.Current.SIGNUP_USER_SIGN_ME_UP %> in asp:Button Text field)
                //-------------------------------------------------------------------------
                this.submitBtn.Text = LiftDomain.Language.Current.SIGNUP_USER_SIGN_ME_UP.Value;

                //-------------------------------------------------------------------------
                //-- do other language settings
                //-------------------------------------------------------------------------
                signup_user_fieldset_legend  = LiftDomain.Language.Current.SIGNUP_USER_NEW_USER_REGISTRATION.Value;
                signup_user_fieldset_legend2 = LiftDomain.Language.Current.SIGNUP_USER_ALL_FIELDS_REQUIRED.Value;

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

                if (IsPostBack)
                {
                    //TODO: ???what if CAPTCHA validation fails???
                    //TODO: ???should we be doing validation checking in Page_Load or submitBtn_Click???
                    //if (Page.IsValid && (txtCaptcha.Text.ToString() == Session["captchaValue"].ToString()))
                    if (txtCaptcha.Text.ToString().Trim().ToUpper() == Session["captchaValue"].ToString().Trim().ToUpper())
                    {
                        //Response.Write("CAPTCHA verification succeeded");



                        //-------------------------------------------------------------------------
                        //-- get the user ID from the hidden id field on the page;
                        //-- if there is a user ID value, then we are editing an EXISTING user
                        //-------------------------------------------------------------------------
                        if (!String.IsNullOrEmpty(id.Value) && (id.Value != "0"))
                        {
                            thisUser.id.Value = int.Parse(id.Value);

                            if (!String.IsNullOrEmpty(password.Text.Trim()))
                            {
                                //TODO: ???what if passwords do not match??? // TO BE DONE IN JAVASCRIPT
                                //(user_password.Text != password_confirmation.Text)

                                thisUser.password_hash_type.Value = "md5";
                                saltValue = LiftDomain.User.generateRandomSalt();
                                thisUser.password_salt.Value = saltValue;

                                thisUser.crypted_password.Value           = LiftDomain.User.hash(password.Text, saltValue);
                                thisUser.last_password_changed_date.Value = LiftTime.CurrentTime;
                            }
                        }
                        else
                        {
                            //-------------------------------------------------------------------------
                            //-- if the user ID is blank or zero (0), then set some NEW user values (NOT id)
                            //-------------------------------------------------------------------------
                            thisUser.state.Value               = initialUserStatus;
                            thisUser.created_at.Value          = LiftTime.CurrentTime;
                            thisUser.last_logged_in_at.Value   = new DateTime(2000, 1, 1, 0, 0, 0); //-- DateTime.MinValue;
                            thisUser.login_failure_count.Value = 0;
                            //thisUser.total_comments.Value = 0;
                            //thisUser.total_comments_needing_approval.Value = 0;
                            //thisUser.total_private_comments.Value = 0;

                            //TODO: ???what if password is blank??? // TO BE DONE IN JAVASCRIPT
                            if (String.IsNullOrEmpty(password.Text.Trim()))
                            {
                            }
                            else
                            {
                                //TODO: ???what if passwords do not match??? // TO BE DONE IN JAVASCRIPT
                                //(user_password.Text != password_confirmation.Text)

                                thisUser.password_hash_type.Value = "md5";
                                saltValue = LiftDomain.User.generateRandomSalt();
                                thisUser.password_salt.Value = saltValue;

                                thisUser.crypted_password.Value = LiftDomain.User.hash(password.Text, saltValue);
                            }
                        }

                        //-------------------------------------------------------------------------
                        //-- transfer screen values to the object
                        //-------------------------------------------------------------------------
                        thisUser.login.Value = user_email.Text;
                        thisUser.email.Value = user_email.Text;

                        thisUser.first_name.Value = user_first_name.Text;
                        thisUser.last_name.Value  = user_last_name.Text;
                        //thisUser.address.Value = user_address.Text;
                        thisUser.address.Value = "";
                        //thisUser.city.Value = user_city.Text;
                        thisUser.city.Value = "";
                        //thisUser.state_province.Value = user_state.Text;
                        thisUser.state_province.Value = "";
                        //thisUser.postal_code.Value = user_postal_code.Text;
                        thisUser.postal_code.Value = "";
                        thisUser.phone.Value       = user_phone.Text;

                        //thisUser.state.Value = initialUserStatus;
                        //thisUser.time_zone.Value = timezone_list.SelectedItem.Value;
                        thisUser.time_zone.Value = Organization.Current.time_zone.Value;
                        //thisUser.language_id.Value = Convert.ToInt32(language_list.SelectedItem.Value);
                        thisUser.language_id.Value = Organization.Current.language_id.Value;

                        thisUser.previous_increment_id.Value = 0;
                        thisUser.updated_at.Value            = LiftTime.CurrentTime;
                        thisUser.password_hash_type.Value    = "md5";

                        //thisUser.isapproved.Value = true; //TODO: ???need to fix when moderator user available

                        bool ok = true;
                        if (LiftDomain.User.checkEmailExists(user_email.Text))
                        {
                            ok = false;
                        }

                        if (user_login.Text.Length == 0)
                        {
                            user_login.Text = user_email.Text;
                        }

                        if (LiftDomain.User.checkUsernameExists(user_login.Text))
                        {
                            ok = false;
                        }

                        if (!ok)
                        {
                            errorMsg.Text  = Language.Current.SIGNUP_ACCT_EXISTS1;
                            errorMsg.Text += " ";
                            errorMsg.Text += Language.Current.SIGNUP_ACCT_EXISTS2;
                            errorMsg.Text += "<br/><br/>";
                            errorMsg.Text += " <a href=\"ForgotPassword.aspx?email=";
                            errorMsg.Text += thisUser.email.Value;
                            errorMsg.Text += "\">";
                            errorMsg.Text += LiftDomain.Language.Current.SIGNUP_RETRIEVE_YOUR_PASSWORD;
                            errorMsg.Text += "</a>";
                        }

                        if (ok)
                        {
                            //-------------------------------------------------------------------------
                            //-- persist the User object data to the database
                            //-------------------------------------------------------------------------
                            thisUser.id.Value = Convert.ToInt32(thisUser.doCommand("create_account"));

                            LiftMembershipProvider membership = new LiftMembershipProvider();

                            if (membership.ValidateUser(user_email.Text, password.Text))
                            {
                                FormsAuthentication.Initialize();

                                LiftRoleProvider roleProvider = new LiftRoleProvider();
                                roleProvider.Initialize(null, null);
                                //String strRole = membership.AssignRoles(txtUsername.Text);
                                string[] roles   = roleProvider.GetRolesForUser(user_login.Text);
                                string   strRole = "";
                                foreach (string role in roles)
                                {
                                    if (strRole.Length > 0)
                                    {
                                        strRole += ",";
                                    }
                                    strRole += role;
                                }

                                //FormsIdentity fi = new FormsIdentity((FormsIdentity)HttpContext.Current.User.Identity;
                                FormsAuthenticationTicket fat = new FormsAuthenticationTicket(1,
                                                                                              user_email.Text, DateTime.Now,
                                                                                              DateTime.Now.AddMinutes(30), false, strRole,
                                                                                              FormsAuthentication.FormsCookiePath);


                                FormsIdentity fi = new FormsIdentity(fat);

                                Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName,
                                                                    FormsAuthentication.Encrypt(fat)));


                                HttpContext.Current.User = new GenericPrincipal(fi, roles);

                                Response.Redirect(FormsAuthentication.GetRedirectUrl(user_email.Text, false));
                            }
                            else
                            {
                                Response.Redirect("SignUpThankYou.aspx");
                            }
                        }
                    }
                    else
                    {
                        errorMsg.Text = Language.Current.SIGNUP_USER_USER_REGISTRATION_FAILED;
                    }
                }
                else
                {
                    //-------------------------------------------------------------------------
                    //-- first time on this page, so get the user ID from the ASP Request cache
                    //-------------------------------------------------------------------------
                    string idStr = Request["id"];

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

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

                    //-------------------------------------------------------------------------
                    //-- if this is a NEW user...
                    //-------------------------------------------------------------------------
                    if (id.Value == "0")
                    {
                        //-------------------------------------------------------------------------
                        //-- set default values
                        //-------------------------------------------------------------------------
                        initialUserStatus = 1;  //-- 1 = unconfirmed
                        initialTimeZone   = LiftDomain.Organization.Current.time_zone.Value;
                        initialLanguageId = LiftDomain.Organization.Current.language_id.Value;
                    }

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

                        initialUserStatus = thisUser.state;
                        initialTimeZone   = thisUser.time_zone;
                        initialLanguageId = thisUser.language_id;
                    }

                    //-------------------------------------------------------------------------
                    //-- populate the screen controls
                    //-------------------------------------------------------------------------
                    user_login.Text       = thisUser.login;
                    user_email.Text       = thisUser.email;
                    user_first_name.Text  = thisUser.first_name;
                    user_last_name.Text   = thisUser.last_name;
                    user_address.Text     = thisUser.address;
                    user_city.Text        = thisUser.city;
                    user_state.Text       = thisUser.state_province;
                    user_postal_code.Text = thisUser.postal_code;
                    user_phone.Text       = thisUser.phone;

                    initTimeZoneList(initialTimeZone);
                    initLanguageList(initialLanguageId);
                }
            }
            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 SignupUser.aspx.cs::Page_Load(): " + m);
                Logger.log("SignupUser.aspx.cs", x, "[" + DateTime.Now.ToString() + "] *** ERROR IN SignupUser.aspx.cs::Page_Load(): " + m);
                //Response.Write(m);
            }
            finally
            {
            }
        }
Beispiel #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            PasswordRequired.Enabled       = false;
            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    initialUserStatus = 1; //-- 1 = unconfirmed
            string initialTimeZone   = "Central Standard Time";
            int    initialLanguageId = 1; //-- 1 = English
            int    initialOrgId      = 0;
            string saltValue         = string.Empty;

            LiftDomain.RolesUser thisRolesUser;

            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_user_fieldset_legend = LiftDomain.Language.Current.USER_EDIT_USER.Value;
                //this.user_roles_2.Text = LiftDomain.Language.Current.ROLES_ADMIN.Value;
                this.user_roles_7.Text  = LiftDomain.Language.Current.ROLES_MODERATOR.Value;
                this.user_roles_8.Text  = LiftDomain.Language.Current.ROLES_WALL_LEADER.Value;
                this.user_roles_10.Text = LiftDomain.Language.Current.ROLES_WATCHMAN.Value;
                this.user_roles_13.Text = LiftDomain.Language.Current.ROLES_SYSTEM_ADMIN.Value;
                this.user_roles_14.Text = LiftDomain.Language.Current.ROLES_ORGANIZATION_ADMIN.Value;
                //this.user_roles_11.Text = LiftDomain.Language.Current.ROLES_TESTADMIN.Value;
                //this.user_roles_12.Text = LiftDomain.Language.Current.ROLES_ADMINTEST.Value;

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

                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"))
                    {
                        thisUser.id.Value = int.Parse(id.Value);

                        if (!String.IsNullOrEmpty(password.Text.Trim()))
                        {
                            //TODO: ???what if passwords do not match??? // TO BE DONE IN JAVASCRIPT
                            //(user_password.Text != password_confirmation.Text)

                            thisUser.password_hash_type.Value = "md5";
                            saltValue = LiftDomain.User.generateRandomSalt();
                            thisUser.password_salt.Value = saltValue;

                            thisUser.crypted_password.Value           = LiftDomain.User.hash(password.Text, saltValue);
                            thisUser.last_password_changed_date.Value = LiftTime.CurrentTime;
                        }
                    }
                    else
                    {
                        //-------------------------------------------------------------------------
                        //-- if the object ID is blank or zero (0), then set some NEW object values (NOT id)
                        //-------------------------------------------------------------------------
                        thisUser.created_at.Value          = LiftTime.CurrentTime;
                        thisUser.last_logged_in_at.Value   = new DateTime(2000, 1, 1, 0, 0, 0); //-- DateTime.MinValue;
                        thisUser.login_failure_count.Value = 0;
                        //thisUser.total_comments.Value = 0;
                        //thisUser.total_comments_needing_approval.Value = 0;
                        //thisUser.total_private_comments.Value = 0;

                        //TODO: ???what if password is blank??? // TO BE DONE IN JAVASCRIPT
                        if (String.IsNullOrEmpty(password.Text.Trim()))
                        {
                        }
                        else
                        {
                            //TODO: ???what if passwords do not match??? // TO BE DONE IN JAVASCRIPT
                            //(user_password.Text != password_confirmation.Text)

                            thisUser.password_hash_type.Value = "md5";
                            saltValue = LiftDomain.User.generateRandomSalt();
                            thisUser.password_salt.Value = saltValue;

                            thisUser.crypted_password.Value           = LiftDomain.User.hash(password.Text, saltValue);
                            thisUser.last_password_changed_date.Value = LiftTime.CurrentTime;
                        }
                    }

                    //-------------------------------------------------------------------------
                    //-- transfer screen values to the object
                    //-------------------------------------------------------------------------
                    //TODO: ???what if data field validation fails??? // TO BE DONE IN JAVASCRIPT
                    //TODO: ???what if user login already exists??? // TO BE DONE IN JAVASCRIPT
                    thisUser.login.Value = user_login.Text;
                    thisUser.email.Value = user_email.Text;

                    thisUser.first_name.Value     = user_first_name.Text;
                    thisUser.last_name.Value      = user_last_name.Text;
                    thisUser.address.Value        = user_address.Text;
                    thisUser.city.Value           = user_city.Text;
                    thisUser.state_province.Value = user_state.Text;
                    thisUser.postal_code.Value    = user_postal_code.Text;
                    thisUser.phone.Value          = user_phone.Text;

                    thisUser.state.Value           = Convert.ToInt32(user_status_list.SelectedItem.Value);
                    thisUser.time_zone.Value       = timezone_list.SelectedItem.Value;
                    thisUser.language_id.Value     = Convert.ToInt32(language_list.SelectedItem.Value);
                    thisUser.organization_id.Value = Convert.ToInt32(org_list.SelectedItem.Value);

                    thisUser.previous_increment_id.Value = 0;
                    thisUser.updated_at.Value            = LiftTime.CurrentTime;

                    //thisUser.isapproved.Value = true; //TODO: ???need to fix when moderator user available

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

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

                    //-------------------------------------------------------------------------
                    //-- persist the RolesUser object data to the database
                    //-- first, delete all for this user...then insert in the selected roles
                    //-------------------------------------------------------------------------
                    thisRolesUser = new LiftDomain.RolesUser();
                    thisRolesUser.user_id.Value = thisUser.id.Value;
                    thisRolesUser.doQuery("delete_roles_users_by_user_id");

                    /*
                     * if (user_roles_2.Checked)
                     * {
                     *  thisRolesUser = new LiftDomain.RolesUser();
                     *  thisRolesUser.user_id.Value = thisUser.id.Value;
                     *  thisRolesUser.role_id.Value = 2;
                     *  thisRolesUser.created_at.Value = LiftTime.CurrentTime;
                     *  thisRolesUser.doCommand("save");
                     * }
                     */


                    if (user_roles_7.Checked)
                    {
                        thisRolesUser = new LiftDomain.RolesUser();
                        thisRolesUser.user_id.Value    = thisUser.id.Value;
                        thisRolesUser.role_id.Value    = 7;
                        thisRolesUser.created_at.Value = LiftTime.CurrentTime;
                        thisRolesUser.doCommand("save");
                    }

                    if (user_roles_8.Checked)
                    {
                        thisRolesUser = new LiftDomain.RolesUser();
                        thisRolesUser.user_id.Value    = thisUser.id.Value;
                        thisRolesUser.role_id.Value    = 8;
                        thisRolesUser.created_at.Value = LiftTime.CurrentTime;
                        thisRolesUser.doCommand("save");
                    }

                    if (user_roles_10.Checked)
                    {
                        thisRolesUser = new LiftDomain.RolesUser();
                        thisRolesUser.user_id.Value    = thisUser.id.Value;
                        thisRolesUser.role_id.Value    = 10;
                        thisRolesUser.created_at.Value = LiftTime.CurrentTime;
                        thisRolesUser.doCommand("save");
                    }

                    if (user_roles_13.Checked)
                    {
                        thisRolesUser = new LiftDomain.RolesUser();
                        thisRolesUser.user_id.Value    = thisUser.id.Value;
                        thisRolesUser.role_id.Value    = 13;
                        thisRolesUser.created_at.Value = LiftTime.CurrentTime;
                        thisRolesUser.doCommand("save");
                    }

                    if (user_roles_14.Checked)
                    {
                        thisRolesUser = new LiftDomain.RolesUser();
                        thisRolesUser.user_id.Value    = thisUser.id.Value;
                        thisRolesUser.role_id.Value    = 14;
                        thisRolesUser.created_at.Value = LiftTime.CurrentTime;
                        thisRolesUser.doCommand("save");
                    }

                    //if (user_roles_11.Checked)
                    //{
                    //    thisRolesUser = new LiftDomain.RolesUser();
                    //    thisRolesUser.user_id.Value = thisUser.id.Value;
                    //    thisRolesUser.role_id.Value = 11;
                    //    thisRolesUser.created_at.Value = LiftTime.CurrentTime;
                    //    thisRolesUser.doCommand("save");
                    //}

                    //if (user_roles_12.Checked)
                    //{
                    //    thisRolesUser = new LiftDomain.RolesUser();
                    //    thisRolesUser.user_id.Value = thisUser.id.Value;
                    //    thisRolesUser.role_id.Value = 12;
                    //    thisRolesUser.created_at.Value = LiftTime.CurrentTime;
                    //    thisRolesUser.doCommand("save");
                    //}

                    //-------------------------------------------------------------------------
                    //-- return to the User List page
                    //-------------------------------------------------------------------------
                    if (Session["last_user_list_search"] != null)
                    {
                        Response.Redirect("UserList.aspx?" + Session["last_user_list_search"]);
                    }
                    else
                    {
                        Response.Redirect("UserList.aspx");
                    }
                }
                else
                {
                    //-------------------------------------------------------------------------
                    //-- first time on this page, so get the object ID from the ASP Request cache
                    //-------------------------------------------------------------------------
                    string idStr = Request["id"];

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

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

                    //-------------------------------------------------------------------------
                    //-- if this is a NEW user...
                    //-------------------------------------------------------------------------
                    if (id.Value == "0")
                    {
                        //-------------------------------------------------------------------------
                        //-- set default values
                        //-------------------------------------------------------------------------
                        initialUserStatus = 1;  //-- 1 = unconfirmed
                        initialTimeZone   = LiftDomain.Organization.Current.time_zone.Value;
                        initialLanguageId = LiftDomain.Organization.Current.language_id.Value;
                        initialOrgId      = LiftDomain.Organization.Current.id.Value;

                        login_label.Visible       = false;
                        edit_user_fieldset_legend = LiftDomain.Language.Current.USER_CREATE_A_NEW_USER.Value;

                        bottomNavTableCellDelete.Visible = false;
                        delete_user_id = string.Empty;
                        redirect_after_delete_to_page = string.Empty;
                        PasswordRequired.Enabled      = true;
                    }

                    //-------------------------------------------------------------------------
                    //-- else, if this is an EXISTING user...
                    //-------------------------------------------------------------------------
                    else
                    {
                        //-------------------------------------------------------------------------
                        //-- query database for data for this user
                        //-------------------------------------------------------------------------

                        if (LiftDomain.User.Current.IsInRole(Role.SYS_ADMIN))
                        {
                            thisUser.OverrideAutoOrgAssignment = true;
                        }

                        thisUser = thisUser.doSingleObjectQuery <LiftDomain.User>("select");

                        initialUserStatus = thisUser.state;
                        initialTimeZone   = thisUser.time_zone;
                        initialLanguageId = thisUser.language_id;
                        initialOrgId      = thisUser.organization_id;

                        login_label.Text          = LiftDomain.Language.Current.USER_EDITING_USER.Value + " " + thisUser.login;
                        edit_user_fieldset_legend = LiftDomain.Language.Current.USER_EDIT_USER.Value;

                        bottomNavTableCellDelete.Visible = true;
                        delete_user_id = id.Value;

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

                    //-------------------------------------------------------------------------
                    //-- populate the screen controls
                    //-------------------------------------------------------------------------
                    user_login.Text       = thisUser.login;
                    user_email.Text       = thisUser.email;
                    user_first_name.Text  = thisUser.first_name;
                    user_last_name.Text   = thisUser.last_name;
                    user_address.Text     = thisUser.address;
                    user_city.Text        = thisUser.city;
                    user_state.Text       = thisUser.state_province;
                    user_postal_code.Text = thisUser.postal_code;
                    user_phone.Text       = thisUser.phone;

                    /*
                     * thisRolesUser = new LiftDomain.RolesUser();
                     * thisRolesUser.user_id.Value = thisUser.id.Value;
                     * thisRolesUser.role_id.Value = 2;
                     * thisRolesUser = thisRolesUser.doSingleObjectQuery<LiftDomain.RolesUser>("select");
                     * user_roles_2.Checked = (thisRolesUser.id.Value > 0);
                     * */

                    thisRolesUser = new LiftDomain.RolesUser();
                    thisRolesUser.user_id.Value = thisUser.id.Value;
                    thisRolesUser.role_id.Value = 7;
                    thisRolesUser        = thisRolesUser.doSingleObjectQuery <LiftDomain.RolesUser>("select");
                    user_roles_7.Checked = (thisRolesUser.id.Value > 0);

                    thisRolesUser = new LiftDomain.RolesUser();
                    thisRolesUser.user_id.Value = thisUser.id.Value;
                    thisRolesUser.role_id.Value = 8;
                    thisRolesUser        = thisRolesUser.doSingleObjectQuery <LiftDomain.RolesUser>("select");
                    user_roles_8.Checked = (thisRolesUser.id.Value > 0);

                    thisRolesUser = new LiftDomain.RolesUser();
                    thisRolesUser.user_id.Value = thisUser.id.Value;
                    thisRolesUser.role_id.Value = 10;
                    thisRolesUser         = thisRolesUser.doSingleObjectQuery <LiftDomain.RolesUser>("select");
                    user_roles_10.Checked = (thisRolesUser.id.Value > 0);

                    thisRolesUser = new LiftDomain.RolesUser();
                    thisRolesUser.user_id.Value = thisUser.id.Value;
                    thisRolesUser.role_id.Value = 13;
                    thisRolesUser         = thisRolesUser.doSingleObjectQuery <LiftDomain.RolesUser>("select");
                    user_roles_13.Checked = (thisRolesUser.id.Value > 0);

                    thisRolesUser = new LiftDomain.RolesUser();
                    thisRolesUser.user_id.Value = thisUser.id.Value;
                    thisRolesUser.role_id.Value = 14;
                    thisRolesUser         = thisRolesUser.doSingleObjectQuery <LiftDomain.RolesUser>("select");
                    user_roles_14.Checked = (thisRolesUser.id.Value > 0);

                    //thisRolesUser = new LiftDomain.RolesUser();
                    //thisRolesUser.user_id.Value = thisUser.id.Value;
                    //thisRolesUser.role_id.Value = 11;
                    //thisRolesUser = thisRolesUser.doSingleObjectQuery<LiftDomain.RolesUser>("select");
                    //user_roles_11.Checked = (thisRolesUser.id.Value > 0);

                    //thisRolesUser = new LiftDomain.RolesUser();
                    //thisRolesUser.user_id.Value = thisUser.id.Value;
                    //thisRolesUser.role_id.Value = 12;
                    //thisRolesUser = thisRolesUser.doSingleObjectQuery<LiftDomain.RolesUser>("select");
                    //user_roles_12.Checked = (thisRolesUser.id.Value > 0);

                    initUserStatusList(initialUserStatus);
                    initTimeZoneList(initialTimeZone);
                    initLanguageList(initialLanguageId);
                    initOrgList(initialOrgId);

                    enforceRoleSettings();
                }
            }
            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 EditUser.aspx.cs::Page_Load(): " + m);
                Logger.log("EditUser.aspx.cs", x, "[" + DateTime.Now.ToString() + "] *** ERROR IN EditUser.aspx.cs::Page_Load(): " + m);
            }
            finally
            {
            }
        }
Beispiel #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string randomPassword = string.Empty;
            string saltValue      = string.Empty;
            int    ok             = 0;
            string targetEmail    = string.Empty;

            EmailValidator.ErrorMessage = LiftDomain.Language.Current.SHARED_MUST_BE_A_VALID_EMAIL_ADDRESS;

            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;

                string email = Request["email"];
                if (!string.IsNullOrEmpty(email))
                {
                    user_email.Text = email;
                }

                //-------------------------------------------------------------------------
                //-- do other language settings
                //-------------------------------------------------------------------------
                forgot_password_fieldset_legend = LiftDomain.Language.Current.FORGOT_PASSWORD_INSTRUCTIONS.Value;

                if (IsPostBack)
                {
                    //TODO: ???what if CAPTCHA validation fails???
                    //TODO: ???should we be doing validation checking in Page_Load or submitBtn_Click???
                    //if (Page.IsValid && (txtCaptcha.Text.ToString() == Session["captchaValue"].ToString()))
                    if (txtCaptcha.Text.ToString().Trim().ToUpper() == Session["captchaValue"].ToString().Trim().ToUpper())
                    {
                        //Response.Write("CAPTCHA verification succeeded");


                        //-------------------------------------------------------------------------
                        //-- validate given e-mail (required, valid e-mail)
                        //-------------------------------------------------------------------------

                        //-------------------------------------------------------------------------
                        //-- determine if user exists for given e-mail
                        //-------------------------------------------------------------------------
                        LiftDomain.User thisUserList = new LiftDomain.User();
                        thisUserList["search"] = user_email.Text;
                        userListSet            = thisUserList.doQuery("SearchUsersByEmail");

                        //TODO: ???what if multiple user records are found for the given email address???
                        if (userListSet.Tables[0].Rows.Count > 0)
                        {
                            LiftDomain.User thisUser = new LiftDomain.User();

                            thisUser.id.Value = Convert.ToInt32(userListSet.Tables[0].Rows[0]["id"]);
                            string username = userListSet.Tables[0].Rows[0]["username"].ToString();

                            //-------------------------------------------------------------------------
                            //-- create new random password for user
                            //-------------------------------------------------------------------------
                            randomPassword = LiftDomain.User.generatePassword();

                            //-------------------------------------------------------------------------
                            //-- update user record with new password
                            //-------------------------------------------------------------------------
                            thisUser.password_hash_type.Value = "md5";
                            saltValue = LiftDomain.User.generateRandomSalt();
                            thisUser.password_salt.Value              = saltValue;
                            thisUser.crypted_password.Value           = LiftDomain.User.hash(randomPassword, saltValue);
                            thisUser.last_password_changed_date.Value = LiftTime.CurrentTime;
                            thisUser.updated_at.Value = LiftTime.CurrentTime;

                            thisUser.id.Value = Convert.ToInt32(thisUser.doCommand("save"));

                            //-------------------------------------------------------------------------
                            //-- send new randomly-generated password to the given e-mail address
                            //-------------------------------------------------------------------------
                            LiftCommon.Email emailHelper = new LiftCommon.Email();
                            //email.replyTo = thisOrgEmail.emailReplyTo;  // not supported yet

                            emailHelper.from = Organization.Current.getFromEmail();

                            if (LiftCommon.Email.IsValidEmailAddress(user_email.Text))
                            {
                                targetEmail = user_email.Text;
                                try
                                {
                                    StringBuilder body = new StringBuilder();
                                    emailHelper.addTo(targetEmail);

                                    emailHelper.subject = LiftDomain.Language.Current.FORGOT_PASSWORD_NOTIFICATION_SUBJECT.Value;
                                    body.Append(LiftDomain.Language.Current.FORGOT_PASSWORD_NOTIFICATION_MESSAGE.Value);
                                    body.Append("\r\n");
                                    body.Append(LiftDomain.Language.Current.USER_EMAIL);
                                    body.Append("\t");
                                    body.Append(targetEmail);
                                    body.Append("\r\n");
                                    body.Append(LiftDomain.Language.Current.LOGIN_THE_NEW_PASSWORD);
                                    body.Append("\t");
                                    body.Append(randomPassword);
                                    body.Append("\r\n");
                                    emailHelper.Body = body.ToString();

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

                                    emailHelper.send();
                                    ok = 1;
                                }
                                catch
                                {
                                    ok = 0;
                                }
                            }
                        }
                    }
                    //-------------------------------------------------------------------------
                    //-- redirect to the "password has been reset, you should receive an e-mail" page
                    //-------------------------------------------------------------------------
                    Response.Redirect("PasswordReset.aspx?ok=" + ok.ToString() + "&e=" + targetEmail);
                }
                else
                {
                    //-------------------------------------------------------------------------
                    //-- first time on this page, so ...???
                    //-------------------------------------------------------------------------
                }
            }
            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 ForgotPassword.aspx.cs::Page_Load(): " + m);
                Logger.log("ForgotPassword.aspx.cs", x, "[" + DateTime.Now.ToString() + "] *** ERROR IN ForgotPassword.aspx.cs::Page_Load(): " + m);
                //Response.Write(m);
            }
            finally
            {
            }
        }
Beispiel #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();
        }