protected void radSendTestMessage_Click(object sender, EventArgs e) { int currentUserID = Convert.ToInt32(Context.Items["UserID"]); qPtl_User user = new qPtl_User(Convert.ToInt32(Request.QueryString["userID"])); qPtl_UserProfile profile = new qPtl_UserProfile(Convert.ToInt32(Request.QueryString["userID"])); string userMobile = string.Empty; string smsMessage = string.Empty; string smsMessageURI = string.Empty; userMobile = txtMobileNumber.Text; // create object string smsMode = System.Configuration.ConfigurationManager.AppSettings["SMSMode"]; Guid authToken = new Guid(System.Configuration.ConfigurationManager.AppSettings["SMSLicenseKey"]); Quartz.Communication.qCom_SMSMessageLog sendLong = new Quartz.Communication.qCom_SMSMessageLog(); // send message + add log if (smsMode == "did") { // use custom number + key string did = System.Configuration.ConfigurationManager.AppSettings["SMSDid"]; Quartz.Communication.CDYNE.SMSResponse[] response = Quartz.Communication.qCom_SMSMessage.SendSMSAdvancedSendMessage(userMobile, smsMessage, authToken, did, 0, false); sendLong.Insert(1, DateTime.Now, user.UserID, 0, smsMessageURI, userMobile, did, smsMessage, "sent", Convert.ToString(response[0].MessageID), 0, 0, "", false, false, 0, false, false, 0, string.Empty); } lblMessage.Text += "Finished sending text message to " + userMobile + "<br>"; lblMessage.Visible = true; }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { // see if user already has a number signed up and that he user preference is set to mobile ok int curr_user_id = Convert.ToInt32(Context.Items["UserID"]); bool mobile_exists = false; bool mobile_active = false; lblCampaignID.Text = Convert.ToString(campaign_id); lblReturnURL.Text = return_url; qPtl_UserProfile profile = new qPtl_UserProfile(curr_user_id); string mobile_number = string.Empty; if (profile.Phone1Type == "Mobile") { mobile_number = profile.Phone1; } else if (profile.Phone2Type == "Mobile") { mobile_number = profile.Phone2; } plhCurrentlyVerified.Visible = false; plhNotYetVerified.Visible = true; if (!String.IsNullOrEmpty(mobile_number)) { mobile_exists = true; litStatus.Text = "Use this form to change the number you want to use.<br><br>"; btnEnroll.Text = "Update Number"; plhCurrentlyVerified.Visible = true; plhNotYetVerified.Visible = false; } qCom_UserPreference pref = new qCom_UserPreference(curr_user_id); if (!String.IsNullOrEmpty(Convert.ToString(pref.MobilePINverified)) && pref.OkSms == "Yes") { mobile_active = true; } if (mobile_exists == true) { txtMobileNumber.Text = mobile_number; } if (mobile_active == true) { btnEnroll.Text = "Turn Off Text Messages"; } if (mobile_active == false && mobile_verification_required == true) { // mobile is required and has not been completed } } }
protected void btnSave_Click(object sender, EventArgs e) { int user_id = Convert.ToInt32(Request.QueryString["userID"]); int training_id = Convert.ToInt32(ddlTrainings.SelectedValue); qLrn_UserTraining u_training = qLrn_UserTraining.GetUserTraining(user_id, training_id); qPtl_UserProfile u_profile = new qPtl_UserProfile(user_id); qLrn_Training training = new qLrn_Training(training_id); u_profile.Phone1 = txtPhone.Text; u_profile.Phone1Type = "Work"; u_profile.LastModified = DateTime.Now; u_profile.Update(); // if changing from waitlist then display option for email notification if (u_training.Status.Contains("Waitlist") && !Convert.ToString(ddlStatus.SelectedValue).Contains("Waitlist")) btnSendWaitlistEmail.Visible = true; else btnSendWaitlistEmail.Visible = false; u_training.Status = Convert.ToString(ddlStatus.SelectedValue); u_training.PaymentMethod = rblPaymentOption.SelectedValue; u_training.ApplyingForCECredits = ddlCredits.SelectedValue; string evalDate = Convert.ToString(dpkCompletedDate.SelectedDate); DateTime newCompletedDate = new DateTime(); if (training.TrainingTypeID == 3 && ddlStatus.SelectedValue == "Completed" && !String.IsNullOrEmpty(evalDate)) if (DateTime.TryParse(evalDate, out newCompletedDate)) u_training.Completed = newCompletedDate; else if (training.TrainingTypeID == 3 && ddlStatus.SelectedValue == "Completed") u_training.Completed = training.EndTime; else u_training.Completed = null; if (!String.IsNullOrEmpty(ddlSelectCredit.SelectedValue)) u_training.CECreditID = Convert.ToInt32(ddlSelectCredit.SelectedValue); else u_training.CECreditID = 0; u_training.Update(); lblMessage.Text = " * Training information successfully updated"; }
protected void btnAgreeRules_Click(object sender, EventArgs e) { int user_id = Convert.ToInt32(Context.Items["UserID"]); qPtl_UserProfile profile = new qPtl_UserProfile(user_id); profile.AgreeRules = DateTime.Now; profile.Update(); // see if this is the action page -- if so, update actionID int action_id = 0; if (!String.IsNullOrEmpty(Convert.ToString(Request.QueryString["actionID"]))) { action_id = Convert.ToInt32(Request.QueryString["actionID"]); qPtl_UserAction action = new qPtl_UserAction(user_id, action_id); action.LastModified = DateTime.Now; action.LastModifiedBy = user_id; action.UserCompleted = DateTime.Now; action.Update(); Response.Redirect(action.RedirectURL); } }
protected void btnEnroll_Click(object sender, EventArgs e) { // run check for mobile text if (!String.IsNullOrEmpty(lblCampaignID.Text)) { campaign_id = Convert.ToInt32(lblCampaignID.Text); } return_url = lblReturnURL.Text; string mobile_number = txtMobileNumber.Text; bool error_occurred = false; bool phone_belongs_to_another_user = false; // check to see if this number is already being used by another user int curr_user_id = Convert.ToInt32(Context.Items["UserID"]); int scope_id = Convert.ToInt32(Context.Items["ScopeID"]); var check_user = qPtl_User.GetUserByPhone(txtMobileNumber.Text, scope_id); if (check_user.UserID > 0) { if (check_user.UserID != curr_user_id) { error_occurred = true; phone_belongs_to_another_user = true; } } // replace characters if (mobile_number.Contains("-")) mobile_number = mobile_number.Replace("-", ""); if (mobile_number.Contains(".")) mobile_number = mobile_number.Replace(".", ""); if (mobile_number.Contains("/")) mobile_number = mobile_number.Replace("/", ""); if (mobile_number.Contains("(")) mobile_number = mobile_number.Replace("(", ""); if (mobile_number.Contains(")")) mobile_number = mobile_number.Replace(")", ""); if (mobile_number.Contains("*")) mobile_number = mobile_number.Replace("*", ""); if (mobile_number.Contains(" ")) mobile_number = mobile_number.Replace(" ", ""); try { string first_char = mobile_number.Substring(0, 1); if (mobile_number.Length == 11 && first_char == "1") mobile_number = mobile_number.Substring(1, 10); } catch { litMsg.Text = "<br><br>* Make sure to enter a 10 digit phone number"; error_occurred = true; } if (String.IsNullOrEmpty(mobile_number)) { litMsg.Text = "<br><br>* Make sure to enter a 10 digit phone number"; error_occurred = true; } string pat_m = @"^[0-9]{10}$"; Regex r_m = new Regex(pat_m, RegexOptions.IgnoreCase); Match m_m = r_m.Match(mobile_number); if (!m_m.Success) { error_occurred = true; litMsg.Text = "<br><br>* Make sure to enter a 10 digit phone number"; } if (error_occurred == false) { if (btnEnroll.Text == "Turn Off Text Messages") { qCom_UserPreference pref = new qCom_UserPreference(curr_user_id); pref.OkSms = "No"; pref.Update(); } else { // save phone number to profile qPtl_UserProfile profile = new qPtl_UserProfile(curr_user_id); if (profile.Phone1Type == "Mobile") { profile.Phone1 = string.Empty; profile.Phone1Type = string.Empty; } if (profile.Phone2Type == "Mobile") { profile.Phone2 = string.Empty; profile.Phone2Type = string.Empty; } profile.Phone1 = txtMobileNumber.Text; profile.Phone1Type = "Mobile"; profile.Update(); // add new mobile verification code to qCom_UserPreferences var pref = qCom_UserPreference.GetUserPreference(curr_user_id); int new_pin = qCom_UserPreference.GenerateMobilePIN(); if (pref != null) { if (pref.UserID > 0) { pref.MobilePIN = Convert.ToString(new_pin); pref.Update(); } } else { qCom_UserPreference pref2 = new qCom_UserPreference(); pref2.ScopeID = Convert.ToInt32(Context.Items["ScopeID"]); pref2.Available = "Yes"; pref2.Created = DateTime.Now; pref2.CreatedBy = curr_user_id; pref2.LastModified = DateTime.Now; pref2.LastModifiedBy = curr_user_id; pref2.UserID = curr_user_id; pref2.OkBulkEmail = "Yes"; pref2.OkSms = "Yes"; pref2.OkEmail = "Yes"; pref2.MobilePIN = Convert.ToString(new_pin); pref2.Insert(); } // get correct DID string alt_did = string.Empty; // see if user has custom record var camp_pref = qCom_UserCampaignPreference.GetUserCampaignPreferences(campaign_id, curr_user_id); if (camp_pref != null) alt_did = camp_pref.DID; else { // see if campaign has available dedicated DIDs qSoc_Campaign campaign = new qSoc_Campaign(campaign_id); qPtl_User user = new qPtl_User(curr_user_id); alt_did = AddCampaignUserPreference(campaign, user, scope_id); if (String.IsNullOrEmpty(alt_did)) alt_did = System.Configuration.ConfigurationManager.AppSettings["SMSDid"]; } string alt_pin_message_uri = string.Empty; var c_pref = qCom_CampaignPreference.GetCampaignPreferences(campaign_id); if (c_pref != null) { if (c_pref.CampaignPreferenceID > 0) { alt_pin_message_uri = c_pref.MobileVerifySMSURI; } } // send mobile pin qCom_UserPreference.SendMobilePIN(Convert.ToString(new_pin), curr_user_id, alt_did, alt_pin_message_uri); plhManage.Visible = false; plhVerify.Visible = true; } } else { if (phone_belongs_to_another_user == true) litMsg.Text = "<br><br>* This phone number belongs to another user."; } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { // see if user already has a number signed up and that he user preference is set to mobile ok int curr_user_id = Convert.ToInt32(Context.Items["UserID"]); bool mobile_exists = false; bool mobile_active = false; lblCampaignID.Text = Convert.ToString(campaign_id); lblReturnURL.Text = return_url; qPtl_UserProfile profile = new qPtl_UserProfile(curr_user_id); string mobile_number = string.Empty; if (profile.Phone1Type == "Mobile") mobile_number = profile.Phone1; else if (profile.Phone2Type == "Mobile") mobile_number = profile.Phone2; plhCurrentlyVerified.Visible = false; plhNotYetVerified.Visible = true; if (!String.IsNullOrEmpty(mobile_number)) { mobile_exists = true; litStatus.Text = "Use this form to change the number you want to use.<br><br>"; btnEnroll.Text = "Update Number"; plhCurrentlyVerified.Visible = true; plhNotYetVerified.Visible = false; } qCom_UserPreference pref = new qCom_UserPreference(curr_user_id); if (!String.IsNullOrEmpty(Convert.ToString(pref.MobilePINverified)) && pref.OkSms == "Yes") mobile_active = true; if (mobile_exists == true) txtMobileNumber.Text = mobile_number; if (mobile_active == true) btnEnroll.Text = "Turn Off Text Messages"; if (mobile_active == false && mobile_verification_required == true) { // mobile is required and has not been completed } } }
protected void btnSignUp_Click(object sender, EventArgs e) { Page.Validate("register"); if (Page.IsValid) { string sqlCode = string.Empty; string returnMessage = string.Empty; qDbs_SQLcode sql = new qDbs_SQLcode(); string register_mode = "new"; int existing_user_id = 0; int scope_id = 1; // would have to be changed to support multiple organizations on a single platform int role_id = 0; int moderator_role_id = 0; if (!String.IsNullOrEmpty(Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["Register_ModeratorRoleID"]))) moderator_role_id = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["Register_ModeratorRoleID"]); // **************************************************** // STEP 1: DETERMINE IF USER IS ALREADY A LIMITED MOBILE USER if (plhMobileNumber.Visible == true) { //Determine if upgrade of mobile account or new registration qPtl_UserProfile mobile_test = qPtl_UserProfile.GetProfileByMobileNumber(txtMobileNumber.Text); if (mobile_test != null) { if (mobile_test.UserID > 0) { // make sure that the user is eligible for upgrade from mobile only status qPtl_User eval_user = new qPtl_User(mobile_test.UserID); if (eval_user.HighestRole == "Mobile") { register_mode = "update"; existing_user_id = mobile_test.UserID; } } else { register_mode = "new"; } } else { register_mode = "new"; } } // **************************************************** // STEP 2a: Mode == new; then add new user string currAvailableStatus = string.Empty; currAvailableStatus = "Yes"; if (register_mode == "new") { qPtl_User new_user = new qPtl_User(); new_user.Available = "Yes"; new_user.ScopeID = scope_id; new_user.Created = DateTime.Now; new_user.CreatedBy = 0; new_user.LastModified = DateTime.Now; new_user.LastModifiedBy = 0; new_user.MarkAsDelete = 0; new_user.Status = ""; // used to include a default message for their status, now leave blank new_user.FirstName = txtFirstName.Text; new_user.LastName = txtLastName.Text; new_user.Email = txtEmail.Text; new_user.UserName = txtUserName.Text; string password_for_storing = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "sha1"); new_user.Password = password_for_storing; new_user.AccountStatus = "Active"; new_user.Insert(); existing_user_id = new_user.UserID; DateTime DOB; try { DOB = new DateTime(int.Parse(ddlYear.SelectedValue), int.Parse(ddlMonth.SelectedValue), int.Parse(ddlDay.SelectedValue)); ;//Convert.ToDateTime(ddlMonth.SelectedValue + "/" + ddlDay.SelectedValue + "/" + ddlYear.SelectedValue); } catch { // no valid date so use default value DOB = new DateTime(1900, 1, 1); ////Convert.ToDateTime("1/1/1900"); } qPtl_UserProfile new_profile = new qPtl_UserProfile(); new_profile.UserID = existing_user_id; new_profile.ScopeID = scope_id; new_profile.Available = "Yes"; new_profile.Created = DateTime.Now; new_profile.CreatedBy = existing_user_id; new_profile.LastModified = DateTime.Now; new_profile.LastModifiedBy = existing_user_id; new_profile.MarkAsDelete = 0; new_profile.Style = "default"; new_profile.Visibility = "all"; new_profile.Gender = ddlGender.SelectedValue; new_profile.DOB = DOB; if (plhRace.Visible == true) { string race = string.Empty; int n = 0; foreach (ListItem item in cblRace.Items) { if (item.Selected) { if (n > 0) { race += "," + item.Value; } else { race += item.Value; } n++; } } n = 0; new_profile.Race = race; } new_profile.Insert(); } qPtl_User user = new qPtl_User(existing_user_id); // STEP 2b: Mode == update; then update mobile info //mode mobile = update existing account if (register_mode == "update") { user.FirstName = txtFirstName.Text; user.LastName = txtLastName.Text; user.UserName = txtEmail.Text; user.Email = txtEmail.Text; string password_for_storing = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "sha1"); user.Password = password_for_storing; user.AccountStatus = "Mobile Verification Pending"; user.Update(); } // **************************************************** // STEP 3: Process invitation & perform invitation-specific work // OPTION #1 -- an invitation is required as part of the registration process and a collection of additional actions are related to that string code = string.Empty; string process_code_mode = string.Empty; if (plhInvitation.Visible == true) { code = txtInvitationCode.Text; if (String.IsNullOrEmpty(process_code_mode)) process_code_mode = "invitation"; // deal with default/null values } else if (plhSpaceCode.Visible == true) { code = txtSpaceCode.Text; if (String.IsNullOrEmpty(process_code_mode)) { qSoc_Space space = new qSoc_Space(code); if (space.SpaceID > 0) { process_code_mode = "space"; } else { qSoc_Campaign campaign = new qSoc_Campaign(code); if (campaign.CampaignID > 0) { process_code_mode = "campaign"; } } } } if (!String.IsNullOrEmpty(code) && process_code_mode == "invitation") { //Process invitation int invitationID = 0; qPtl_Invitation invite = null; invite = new qPtl_Invitation(code); invitationID = invite.InvitationID; role_id = invite.RoleID; // update invitation records as necessary if (invite.InvitationAudience == "family") { invite.UserID = user.UserID; invite.InvitationStatus = "Redeemed"; invite.LastModified = DateTime.Now; invite.LastModifiedBy = user.UserID; invite.CurrRedemptions = invite.CurrRedemptions + 1; } else if (invite.InvitationAudience == "individual") { invite.UserID = user.UserID; invite.InvitationStatus = "Redeemed"; invite.LastModified = DateTime.Now; invite.LastModifiedBy = user.UserID; invite.CurrRedemptions = invite.CurrRedemptions + 1; } else if (invite.InvitationAudience == "group") { invite.UserID = user.UserID; invite.LastModified = DateTime.Now; invite.LastModifiedBy = user.UserID; invite.CurrRedemptions = invite.CurrRedemptions + 1; if (invite.MaxRedemptions > 0 && invite.CurrRedemptions >= invite.MaxRedemptions) invite.InvitationStatus = "Redeemed"; } else if (invite.InvitationAudience == "moderated group") { invite.UserID = user.UserID; invite.LastModified = DateTime.Now; invite.LastModifiedBy = user.UserID; invite.CurrRedemptions = invite.CurrRedemptions + 1; if (invite.MaxRedemptions > 0 && invite.CurrRedemptions >= invite.MaxRedemptions) invite.InvitationStatus = "Redeemed"; } invite.Update(); // add possible space associated with invitation & space-specific elements if (invite.SpaceID > 0) { qSoc_Space space = new qSoc_Space(invite.SpaceID); if (space != null) { if (space.SpaceID > 0) { qSoc_UserSpace u_space = new qSoc_UserSpace(); u_space.ScopeID = scope_id; u_space.Available = "Yes"; u_space.Created = DateTime.Now; u_space.CreatedBy = user.UserID; u_space.LastModified = DateTime.Now; u_space.LastModifiedBy = user.UserID; u_space.MarkAsDelete = 0; u_space.UserID = user.UserID; u_space.SpaceID = space.SpaceID; u_space.PrimarySpace = true; if (role_id == moderator_role_id) u_space.SpaceRole = "Moderator"; u_space.Insert(); } if (space.SchoolID > 0) { qOrg_UserSchool school = new qOrg_UserSchool(); school.UserID = user.UserID; school.SchoolID = space.SchoolID; school.Insert(); } // set space to visibile in directory it not already visible if (space.VisibleInDirectory == "No") { space.VisibleInDirectory = "Yes"; space.Update(); } // add campaign -- includes check to insure that campaigns aren't added twice AddSpaceCampaigns(space, user, scope_id); } } // add possible campaign associated with invitation -- includes check to insure that campaigns aren't added twice if (invite.CampaignID > 0) { qSoc_UserCampaign checkc = new qSoc_UserCampaign(user.UserID, invite.CampaignID); if (checkc.UserCampaignID == 0) { AddUserCampaign(invite.CampaignID, scope_id, user); } } if (invite.FunctionalRoleID > 0) { sqlCode = "INSERT INTO qLrn_UserFunctionalRoles ([UserID],[FunctionalRoleID]) VALUES(" + user.UserID + "," + invite.FunctionalRoleID + ")"; sql.ExecuteSQL(sqlCode); UserFunctions.AddUserTrainingsByFunctionalRole(user.UserID, invite.FunctionalRoleID); } } else { // else use default role types int teen_max_age = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["Register_TeenMaxAge"]); qPtl_UserProfile profile = new qPtl_UserProfile(user.UserID); if (profile.Age <= teen_max_age) role_id = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["Register_TeenRoleID"]); else role_id = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["Register_ParentRoleID"]); } // OPTION #2 -- User might have entered a registration code; this will assign them to a space which might have one or more associated campaigns if (!String.IsNullOrEmpty(code) && process_code_mode == "space") { if (!string.IsNullOrEmpty(code)) { qSoc_Space space = new qSoc_Space(code); if (space != null) { if (space.SpaceID > 0) { qSoc_UserSpace u_space = new qSoc_UserSpace(); u_space.ScopeID = scope_id; u_space.Available = "Yes"; u_space.Created = DateTime.Now; u_space.CreatedBy = user.UserID; u_space.LastModified = DateTime.Now; u_space.LastModifiedBy = user.UserID; u_space.MarkAsDelete = 0; u_space.UserID = user.UserID; u_space.SpaceID = space.SpaceID; u_space.PrimarySpace = true; if (role_id == moderator_role_id) u_space.SpaceRole = "Moderator"; u_space.Insert(); } space_redirect = true; new_space_id = space.SpaceID; AddSpaceCampaigns(space, user, scope_id); } } } else if (!String.IsNullOrEmpty(code) && process_code_mode == "campaign") { qSoc_Campaign campaign = new qSoc_Campaign(code); AddUserCampaign(campaign.CampaignID, scope_id, user); } // **************************************************** // STEP 4: Add School Information if (plhSchool.Visible == true) { string school_name = string.Empty; string school_other_name = string.Empty; if (radCBSearch.Visible == true) school_name = radCBSearch.SelectedValue; else { school_other_name = txtSchoolOther.Text; school_name = "Other"; } var school = qOrg_School.GetSchoolFromAutoPopulateDropdown(school_name); if (school != null) { if (school.SchoolID > 0) { qOrg_UserSchool user_school = new qOrg_UserSchool(); user_school.Available = "Yes"; user_school.ScopeID = scope_id; user_school.Created = DateTime.Now; user_school.CreatedBy = user.UserID; user_school.LastModified = DateTime.Now; user_school.LastModifiedBy = user.UserID; user_school.MarkAsDelete = 0; user_school.UserID = user.UserID; user_school.SchoolID = school.SchoolID; user_school.OtherName = school_other_name; user_school.Insert(); // see if this school is already a space var school_space = qSoc_Space.GetSpacesBySchool(school.SchoolID); qSoc_Space curr_space = new qSoc_Space(); if (school_space == null) { qSoc_Space new_space = new qSoc_Space(); new_space.ScopeID = scope_id; new_space.Available = "Yes"; new_space.Created = DateTime.Now; new_space.CreatedBy = 0; new_space.LastModified = DateTime.Now; new_space.LastModifiedBy = 0; new_space.MarkAsDelete = 0; new_space.SpaceName = school.School; new_space.SpaceShortName = school.School; new_space.SpaceType = "school"; new_space.AccessMode = "open"; new_space.VisibleInDirectory = "Yes"; new_space.SpaceCategoryID = 1; new_space.SchoolID = school.SchoolID; new_space.Insert(); school_space = new_space; } if (school_space != null) { qSoc_UserSpace s_space = new qSoc_UserSpace(); s_space.ScopeID = scope_id; s_space.Available = "Yes"; s_space.Created = DateTime.Now; s_space.CreatedBy = user.UserID; s_space.LastModified = DateTime.Now; s_space.LastModifiedBy = user.UserID; s_space.MarkAsDelete = 0; s_space.UserID = user.UserID; s_space.SpaceID = school_space.SpaceID; s_space.PrimarySpace = true; if (role_id == moderator_role_id) s_space.SpaceRole = "Moderator"; s_space.Insert(); } } } } // **************************************************** // STEP 5: Add User Role & Supporting Role Structures // Add role /* qPtl_UserRole role = new qPtl_UserRole(); role.UserID = user.UserID; role.RoleID = role_id; role.Insert(); */ sqlCode = "INSERT INTO qPtl_UserRoles ([UserID],[RoleID]) VALUES(" + user.UserID + "," + role_id + ")"; sql.ExecuteSQL(sqlCode); // Add possible role actions for the new user role AddRoleAction(role_id, scope_id, user); // Add possible role campaigns AddRoleCampaigns(role_id, scope_id, user); // Redundancy check -- write Highest Level into qPtl_User table in case DB trigger not working qPtl_Role role = new qPtl_Role(role_id); user.HighestRank = role.RoleRank; user.HighestRole = role.RoleName; user.Update(); // **************************************************** // STEP 6: User Utilties to finalize/prep account // Add username folder for images string rootLocation = Server.MapPath("~/") + "user_data\\"; if (!Directory.Exists(rootLocation + user.UserName)) Directory.CreateDirectory(rootLocation + user.UserName); // Create default album qSoc_Album album = new qSoc_Album(); album.ScopeID = scope_id; album.Available = "Yes"; album.Created = DateTime.Now; album.CreatedBy = user.UserID; album.LastModified = DateTime.Now; album.LastModifiedBy = user.UserID; album.MarkAsDelete = 0; album.UserID = user.UserID; album.Name = "My Pics"; album.Insert(); // Add communications preferences if (register_mode == "new") { qCom_UserPreference connect = new qCom_UserPreference(); connect.UserID = user.UserID; connect.Created = DateTime.Now; connect.CreatedBy = user.UserID; connect.LastModified = DateTime.Now; connect.LastModifiedBy = user.UserID; connect.Available = "Yes"; connect.ScopeID = 1; connect.MarkAsDelete = 0; connect.OkBulkEmail = "Yes"; connect.OkEmail = "Yes"; connect.OkSms = "Yes"; connect.LanguageID = 1; connect.Insert(); } qCom_UserPreference user_connect = qCom_UserPreference.GetUserPreference(user.UserID); user_connect.OkBulkEmail = "Yes"; user_connect.OkEmail = "Yes"; user_connect.Update(); // **************************************************** // STEP 7: Log user in and redirect to account setup page/ // initial session created -- will last for 24 hours before timing out qPtl_Sessions session = new qPtl_Sessions(); session.Created = DateTime.Now; session.StartTime = DateTime.Now; session.LastTimeSeen = DateTime.Now; session.ScopeID = user.ScopeID; session.UserID = user.UserID; session.BrowserType = Request.Browser.Browser; session.ComputerType = Request.Browser.Platform; session.Insert(); int sessionID = session.SessionID; int scopeID = user.ScopeID; var u_roles = qPtl_UserRole_View.GetUserRoles(user.UserID); string role_list = string.Empty; if (u_roles != null) { foreach (var u in u_roles) { role_list += string.Format("{0},", u.RoleName, ","); } } role_list.TrimEnd(','); string userData = string.Format("{0};{1};{2}", sessionID, role_list, scopeID); FormsAuthenticationTicket tkt; string cookiestr; HttpCookie ck; tkt = new FormsAuthenticationTicket(1, user.UserID.ToString(), DateTime.Now, DateTime.Now.AddMinutes(3600), false, userData); cookiestr = FormsAuthentication.Encrypt(tkt); ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr); ck.Path = FormsAuthentication.FormsCookiePath; Response.Cookies.Add(ck); HttpCookie cookie2 = new HttpCookie("UserID", Convert.ToString(user.UserID)); if (tkt.IsPersistent) { cookie2.Expires = tkt.Expiration.AddMinutes(3605); } Response.Cookies.Add(cookie2); if (space_redirect == true && new_space_id > 0) Response.Redirect("~/utilities/manage-user-access.aspx?mode=registration&spaceID=" + new_space_id); else Response.Redirect("~/utilities/manage-user-access.aspx?mode=registration"); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { profile_id = Convert.ToInt32(Request.QueryString["userID"]); qPtl_User profile = new qPtl_User(profile_id); hplManageTrainings.NavigateUrl = "member-learning.aspx?userID=" + profile_id; string nav_mode = System.Configuration.ConfigurationManager.AppSettings["Site_NavMode"]; if (nav_mode == "lms") plhSchoolDisplay.Visible = false; string img_url = string.Empty; string baseUrl = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') + "/"; if (!String.IsNullOrEmpty(profile.ProfilePict)) img_url = baseUrl + "user_data/" + profile.UserName + "/" + profile.ProfilePict + ".ashx?width=84&height=84&mode=crop"; else img_url = baseUrl + "images/mylife_portrait_default.jpg.ashx?width=84&height=84&mode=crop"; litProfilePict.Text = "<img src=\"" + img_url + "\" />"; lblUsername.Text = profile.UserName; lblFullName.Text = profile.FirstName + " " + profile.LastName; lblEmail.Text = profile.Email; lblUserID.Text = Convert.ToString(profile.UserID); lblCreated.Text = Convert.ToString(profile.Created); lblMostRecentLogin.Text = Convert.ToString(profile.LastTimeSeen); lblMostRecentIPAddress.Text = profile.LastIPAddress; lblRoleName.Text = profile.HighestRole; txtFirstName.Text = profile.FirstName; txtLastName.Text = profile.LastName; txtEmail.Text = profile.Email; lblUsernameProfile.Text = profile.UserName; if (profile.HighestRole == "Mobile") { lblMemberTypeProfile.Text = "Mobile Only"; } else { lblMemberTypeProfile.Text = "Social"; required_indicator = " *"; if (race_required == true) race_required_indicator = " *"; } qPtl_UserProfile full_profile = new qPtl_UserProfile(profile_id); DateTime check = new DateTime(); check = Convert.ToDateTime("1/1/1900"); if (full_profile.DOB != check) { try { rdtDOB.SelectedDate = Convert.ToDateTime(full_profile.DOB).Date; } catch { // do nothing } } var user_space = qSoc_UserSpace_View.GetMostRecentUserspace(profile_id); if (user_space != null) { if (user_space.UserSpaceID > 0) { lblSchool.Text = user_space.School; string full_info = string.Empty; full_info = user_space.SpaceShortName; if (!String.IsNullOrEmpty(user_space.CategoryName)) full_info += " [" + user_space.CategoryName + "]"; if (!String.IsNullOrEmpty(user_space.School)) full_info += " at " + user_space.School; lblGroupTabGroupName.Text = "<a href=\"/manage/members/space-edit.aspx?spaceID=" + user_space.SpaceID + "\">" + full_info + " <i class=\"icon-circle-arrow-right\"></i></a>"; string full_group_name = user_space.SpaceShortName; if (!String.IsNullOrEmpty(user_space.CategoryName)) full_group_name += " [" + user_space.CategoryName + "]"; lblGroupName.Text = "<a href=\"/manage/members/space-edit.aspx?spaceID=" + user_space.SpaceID + "\">" + full_group_name + " <i class=\"icon-circle-arrow-right\"></i></a>"; } else { btnChangeGroup.Text = "Add To Group"; } } // profile gender string gender_options = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["Register_SupportedGenderValues"]); ddlGender.Items.FindByValue("Intersex").Enabled = false; ddlGender.Items.FindByValue("Transgender").Enabled = false; if (gender_options.Contains("Intersex")) ddlGender.Items.FindByValue("Intersex").Enabled = true; if (gender_options.Contains("Transgender")) ddlGender.Items.FindByValue("Transgender").Enabled = true; ddlGender.SelectedValue = full_profile.Gender; // evaluate race if (!String.IsNullOrEmpty(full_profile.Race)) { if (full_profile.Race.Contains("Asian/SouthAsian")) cblRace.Items.FindByValue("Asian/SouthAsian").Selected = true; if (full_profile.Race.Contains("Biracial")) cblRace.Items.FindByValue("Biracial").Selected = true; if (full_profile.Race.Contains("Black/African American")) cblRace.Items.FindByValue("Black/African American").Selected = true; if (full_profile.Race.Contains("Latino/a")) cblRace.Items.FindByValue("Latino/a").Selected = true; if (full_profile.Race.Contains("Middle Eastern")) cblRace.Items.FindByValue("Middle Eastern").Selected = true; if (full_profile.Race.Contains("Multiracial")) cblRace.Items.FindByValue("Multiracial").Selected = true; if (full_profile.Race.Contains("Pacific Islander")) cblRace.Items.FindByValue("Pacific Islander").Selected = true; if (full_profile.Race.Contains("White/European-American")) cblRace.Items.FindByValue("White/European-American").Selected = true; } // **** PERMISSIONS **** string sqlCode = string.Empty; qDbs_SQLcode sql = new qDbs_SQLcode(); q_Helper helper = new q_Helper(); // get roles sqlCode = "SELECT RoleID, RoleName FROM qPtl_Roles WHERE Available = 'Yes' ORDER BY RoleRank"; DataTable dtRoles; using (dtRoles = sql.GetDataTable(sqlCode)) { cblRoles.DataSource = dtRoles; cblRoles.DataValueField = "RoleID"; cblRoles.DataTextField = "RoleName"; cblRoles.DataBind(); } // mark current permissions sqlCode = "SELECT RoleID FROM qPtl_UserRoles WHERE UserID = " + Request.QueryString["userID"]; SqlDataReader rReader; using (rReader = sql.GetDataReader(sqlCode)) { while (rReader.Read()) { ListItem currentCheckBox = cblRoles.Items.FindByValue(rReader["RoleID"].ToString()); if (currentCheckBox != null) { currentCheckBox.Selected = true; } } } // *** GROUP *** // load group information and all other available groups ddlSpaces.DataSource = qSoc_Space.GetSpaces(); ddlSpaces.DataTextField = "SpaceShortName"; ddlSpaces.DataValueField = "SpaceID"; ddlSpaces.DataBind(); ddlSpaces.Items.Insert(0, new ListItem("", "0")); /* // no longer used since we now want to automatically remove any existing user spaces from the list of options for adding if (user_space != null) { if (user_space.UserSpaceID > 0) { ddlSpaces.SelectedValue = Convert.ToString(user_space.SpaceID); } } */ // get other groups enrolled var u_groups = qSoc_UserSpace_View.GetAllAvailableUserSpacesOrderMostRecent(profile_id); if (u_groups != null) { int j = 0; string group_list = string.Empty; foreach (var g in u_groups) { Quartz.Controls.MemberEnrolledGroup curr_group = (Quartz.Controls.MemberEnrolledGroup)LoadControl("~/manage/members/controls/MemberEnrolledGroup.ascx"); curr_group.UserSpaceID = g.UserSpaceID; curr_group.UserID = g.UserID; curr_group.SpaceID = g.SpaceID; if (g.PrimarySpace == true) curr_group.IsPrimary = true; pnlUserGroups.Controls.Add(curr_group); // remove each of these spaces from the spaces pull down if (ddlSpaces.Items.Count > 0) { try { ddlSpaces.Items.FindByValue(Convert.ToString(g.SpaceID)).Enabled = false; } catch { // do nothing } } j++; } } // *** TAB MANAGEMENT *** string curr_tab = string.Empty; curr_tab = Request.QueryString["currTab"]; litOverviewClass.Text = ""; litProfileClass.Text = ""; litPermissionClass.Text = ""; litGroupClass.Text = ""; litWarningsClass.Text = ""; litTabOverviewClass.Text = "class=\"tab-pane\""; litTabProfileClass.Text = "class=\"tab-pane\""; litTabPermissionsClass.Text = "class=\"tab-pane\""; litTabWarningsClass.Text = "class=\"tab-pane\""; litTabGroupClass.Text = "class=\"tab-pane\""; if (curr_tab == "profile") { litProfileClass.Text = "class='active'"; litTabProfileClass.Text = "class=\"tab-pane active\""; if (!String.IsNullOrEmpty(Request.QueryString["message"])) lblProfileMessage.Text = " *** " + Request.QueryString["message"] + "***"; } else if (curr_tab == "permissions") { litPermissionClass.Text = "class='active'"; litTabPermissionsClass.Text = "class=\"tab-pane active\""; if (!String.IsNullOrEmpty(Request.QueryString["message"])) lblPermissionsMessage.Text = " *** " + Request.QueryString["message"] + "***"; } else if (curr_tab == "group") { litGroupClass.Text = "class='active'"; litTabGroupClass.Text = "class=\"tab-pane active\""; if (!String.IsNullOrEmpty(Request.QueryString["message"])) lblGroupMessage.Text = " *** " + Request.QueryString["message"] + "***<br><br>"; } else if (curr_tab == "warnings") { litWarningsClass.Text = "class='active'"; litTabWarningsClass.Text = "class=\"tab-pane active\""; } else { litOverviewClass.Text = "class='active'"; litTabOverviewClass.Text = "class=\"tab-pane active\""; } } }
protected void btnUpdateProfile_Click(object sender, EventArgs e) { profile_id = Convert.ToInt32(Request.QueryString["userID"]); Page.Validate("profile"); if (Page.IsValid) { qPtl_User user = new qPtl_User(profile_id); user.FirstName = txtFirstName.Text; user.LastName = txtLastName.Text; user.Email = txtEmail.Text; user.Update(); qPtl_UserProfile profile = new qPtl_UserProfile(profile_id); profile.Gender = ddlGender.SelectedValue; if (!String.IsNullOrEmpty(Convert.ToString(rdtDOB))) profile.DOB = rdtDOB.SelectedDate; string race = string.Empty; int n = 0; foreach (ListItem item in cblRace.Items) { if (item.Selected) { if (n > 0) { race += "," + item.Value; } else { race += item.Value; } n++; } } n = 0; profile.Race = race; profile.Update(); Response.Redirect("/manage/members/member-profile.aspx?userID=" + profile_id + "&currTab=profile&message=successfully updated member profile"); } }
protected void DisplayManageTools(int user_id, int training_id) { qLrn_UserTraining userTraining = qLrn_UserTraining.GetUserTraining(user_id, training_id); TrainingID = userTraining.TrainingID; if (userTraining != null && userTraining.UserTrainingID > 0) { plhManage.Visible = true; qLrn_Training training = new qLrn_Training(userTraining.TrainingID); if (training.TrainingTypeID == 3) { plhInPersonTraining.Visible = true; dpkCompletedDate.SelectedDate = userTraining.Completed; ddlStatus.SelectedValue = userTraining.Status; qPtl_UserProfile u_profile = new qPtl_UserProfile(user_id); if (u_profile.Phone1Type == "Work") txtPhone.Text = u_profile.Phone1; else txtPhone.Text = u_profile.Phone2; populateCECredits(TrainingID); ddlCredits.SelectedValue = userTraining.ApplyingForCECredits; if (userTraining.CECreditID > 0) ddlSelectCredit.SelectedValue = Convert.ToString(userTraining.CECreditID); rblPaymentOption.SelectedValue = userTraining.PaymentMethod; } else plhInPersonTraining.Visible = false; } }
public static qPtl_User RegisterNewUser(RegistrationData data) { int existing_user_id = 0; int new_space_id = 0; string sqlCode = string.Empty; // Redundancy check -- write Highest Level into qPtl_User table in case DB trigger not working qPtl_Role role = new qPtl_Role(data.default_role_id); // add user qPtl_User new_user = new qPtl_User(); new_user.Available = "Yes"; new_user.OrgUnitID = data.scope_id; new_user.ScopeID = data.scope_id; new_user.Created = DateTime.Now; new_user.CreatedBy = 0; new_user.LastModified = DateTime.Now; new_user.LastModifiedBy = 0; new_user.MarkAsDelete = 0; new_user.Status = ""; // used to include a default message for their status, now leave blank new_user.FirstName = data.firstname; new_user.LastName = data.lastname; new_user.Email = data.email; new_user.UserName = data.username; string password_for_storing = FormsAuthentication.HashPasswordForStoringInConfigFile(data.password, "sha1"); new_user.Password = password_for_storing; new_user.AccountStatus = "Active"; new_user.HighestRank = role.RoleRank; new_user.HighestRole = role.RoleName; new_user.Insert(); existing_user_id = new_user.UserID; DateTime DOB; try { DOB = Convert.ToDateTime(data.dob); } catch { // no valid date so use default value DOB = Convert.ToDateTime("1/1/1900"); } // add user profile qPtl_UserProfile new_profile = new qPtl_UserProfile(); new_profile.UserID = existing_user_id; new_profile.ScopeID = data.scope_id; new_profile.Available = "Yes"; new_profile.Created = DateTime.Now; new_profile.CreatedBy = existing_user_id; new_profile.LastModified = DateTime.Now; new_profile.LastModifiedBy = existing_user_id; new_profile.MarkAsDelete = 0; new_profile.Style = "default"; new_profile.Visibility = "all"; new_profile.Division = data.division; new_profile.Agency = data.agency; new_profile.Position = data.position; new_profile.Degrees = data.degrees; new_profile.Address1 = data.address; new_profile.Address2 = data.address2; new_profile.City = data.city; new_profile.StateProvince = data.state; new_profile.PostalCode = data.postal_code; new_profile.Country = data.country; new_profile.Gender = data.gender; new_profile.DOB = DOB; new_profile.Race = data.race; new_profile.EmploymentLocation = data.employment_location; new_profile.EmploymentSetting = data.employment_setting; new_profile.WorkSites = data.employment_sites; new_profile.Profession = data.profession; new_profile.Phone1 = data.work_phone; new_profile.Phone1Type = "work"; new_profile.Insert(); qPtl_User user = new qPtl_User(existing_user_id); // add user communication preference if (!String.IsNullOrEmpty(user.Email)) { qCom_UserPreference connect = new qCom_UserPreference(); connect.UserID = user.UserID; connect.Created = DateTime.Now; connect.CreatedBy = user.UserID; connect.LastModified = DateTime.Now; connect.LastModifiedBy = user.UserID; connect.Available = "Yes"; connect.ScopeID = 1; connect.MarkAsDelete = 0; connect.OkBulkEmail = "Yes"; connect.OkEmail = "Yes"; connect.OkSms = "Yes"; connect.LanguageID = 1; connect.Insert(); } // **************************************************** // STEP 5: Add User Role & Supporting Role Structures // Add role /* qPtl_UserRole role = new qPtl_UserRole(); role.UserID = user.UserID; role.RoleID = role_id; role.Insert(); */ qDbs_SQLcode sql = new qDbs_SQLcode(); sqlCode = "INSERT INTO qPtl_UserRoles ([UserID],[RoleID]) VALUES(" + user.UserID + "," + data.default_role_id + ")"; sql.ExecuteSQL(sqlCode); // Add possible role actions for the new user role AddRoleAction(data.default_role_id, data.scope_id, user); // add folder for user_data string rootLocation = HttpContext.Current.Server.MapPath("~/") + "user_data\\"; if (!Directory.Exists(rootLocation + user.UserName)) Directory.CreateDirectory(rootLocation + user.UserName); if (new_user.UserID > 0) return new_user; else return null; }
protected void btnEnroll_Click(object sender, EventArgs e) { // run check for mobile text if (!String.IsNullOrEmpty(lblCampaignID.Text)) { campaign_id = Convert.ToInt32(lblCampaignID.Text); } return_url = lblReturnURL.Text; string mobile_number = txtMobileNumber.Text; bool error_occurred = false; bool phone_belongs_to_another_user = false; // check to see if this number is already being used by another user int curr_user_id = Convert.ToInt32(Context.Items["UserID"]); int scope_id = Convert.ToInt32(Context.Items["ScopeID"]); var check_user = qPtl_User.GetUserByPhone(txtMobileNumber.Text, scope_id); if (check_user.UserID > 0) { if (check_user.UserID != curr_user_id) { error_occurred = true; phone_belongs_to_another_user = true; } } // replace characters if (mobile_number.Contains("-")) { mobile_number = mobile_number.Replace("-", ""); } if (mobile_number.Contains(".")) { mobile_number = mobile_number.Replace(".", ""); } if (mobile_number.Contains("/")) { mobile_number = mobile_number.Replace("/", ""); } if (mobile_number.Contains("(")) { mobile_number = mobile_number.Replace("(", ""); } if (mobile_number.Contains(")")) { mobile_number = mobile_number.Replace(")", ""); } if (mobile_number.Contains("*")) { mobile_number = mobile_number.Replace("*", ""); } if (mobile_number.Contains(" ")) { mobile_number = mobile_number.Replace(" ", ""); } try { string first_char = mobile_number.Substring(0, 1); if (mobile_number.Length == 11 && first_char == "1") { mobile_number = mobile_number.Substring(1, 10); } } catch { litMsg.Text = "<br><br>* Make sure to enter a 10 digit phone number"; error_occurred = true; } if (String.IsNullOrEmpty(mobile_number)) { litMsg.Text = "<br><br>* Make sure to enter a 10 digit phone number"; error_occurred = true; } string pat_m = @"^[0-9]{10}$"; Regex r_m = new Regex(pat_m, RegexOptions.IgnoreCase); Match m_m = r_m.Match(mobile_number); if (!m_m.Success) { error_occurred = true; litMsg.Text = "<br><br>* Make sure to enter a 10 digit phone number"; } if (error_occurred == false) { if (btnEnroll.Text == "Turn Off Text Messages") { qCom_UserPreference pref = new qCom_UserPreference(curr_user_id); pref.OkSms = "No"; pref.Update(); } else { // save phone number to profile qPtl_UserProfile profile = new qPtl_UserProfile(curr_user_id); if (profile.Phone1Type == "Mobile") { profile.Phone1 = string.Empty; profile.Phone1Type = string.Empty; } if (profile.Phone2Type == "Mobile") { profile.Phone2 = string.Empty; profile.Phone2Type = string.Empty; } profile.Phone1 = txtMobileNumber.Text; profile.Phone1Type = "Mobile"; profile.Update(); // add new mobile verification code to qCom_UserPreferences var pref = qCom_UserPreference.GetUserPreference(curr_user_id); int new_pin = qCom_UserPreference.GenerateMobilePIN(); if (pref != null) { if (pref.UserID > 0) { pref.MobilePIN = Convert.ToString(new_pin); pref.Update(); } } else { qCom_UserPreference pref2 = new qCom_UserPreference(); pref2.ScopeID = Convert.ToInt32(Context.Items["ScopeID"]); pref2.Available = "Yes"; pref2.Created = DateTime.Now; pref2.CreatedBy = curr_user_id; pref2.LastModified = DateTime.Now; pref2.LastModifiedBy = curr_user_id; pref2.UserID = curr_user_id; pref2.OkBulkEmail = "Yes"; pref2.OkSms = "Yes"; pref2.OkEmail = "Yes"; pref2.MobilePIN = Convert.ToString(new_pin); pref2.Insert(); } // get correct DID string alt_did = string.Empty; // see if user has custom record var camp_pref = qCom_UserCampaignPreference.GetUserCampaignPreferences(campaign_id, curr_user_id); if (camp_pref != null) { alt_did = camp_pref.DID; } else { // see if campaign has available dedicated DIDs qSoc_Campaign campaign = new qSoc_Campaign(campaign_id); qPtl_User user = new qPtl_User(curr_user_id); alt_did = AddCampaignUserPreference(campaign, user, scope_id); if (String.IsNullOrEmpty(alt_did)) { alt_did = System.Configuration.ConfigurationManager.AppSettings["SMSDid"]; } } string alt_pin_message_uri = string.Empty; var c_pref = qCom_CampaignPreference.GetCampaignPreferences(campaign_id); if (c_pref != null) { if (c_pref.CampaignPreferenceID > 0) { alt_pin_message_uri = c_pref.MobileVerifySMSURI; } } // send mobile pin qCom_UserPreference.SendMobilePIN(Convert.ToString(new_pin), curr_user_id, alt_did, alt_pin_message_uri); plhManage.Visible = false; plhVerify.Visible = true; } } else { if (phone_belongs_to_another_user == true) { litMsg.Text = "<br><br>* This phone number belongs to another user."; } } }