/// <summary> /// Handler for the selectclicked event of the finduser control. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SelectClickedHandler(object sender, System.EventArgs e) { phDeleteResult.Visible = false; List <int> selectedUserIDs = userFinder.SelectedUserIDs; if (selectedUserIDs.Count < 0) { // nothing selected, return return; } // just use the first selected user int selectedUserID = selectedUserIDs[0]; if ((selectedUserID == 0) || (selectedUserID == SessionAdapter.GetUserID())) { // can't delete anonymous coward or him/herself return; } UserEntity user = UserGuiHelper.GetUser(selectedUserID); lblNickname.Text = user.NickName; lblUserID.Text = user.UserID.ToString(); phUserInfo.Visible = true; }
/// <summary> /// Handler for the selectclicked event of the finduser control. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SelectClickedHandler(object sender, System.EventArgs e) { phModifyResult.Visible = false; List <int> selectedUserIDs = userFinder.SelectedUserIDs; if (selectedUserIDs.Count < 0) { // nothing selected, return return; } // just use the first selected user _selectedUserID = selectedUserIDs[0]; UserEntity user = UserGuiHelper.GetUser(_selectedUserID); if (user == null) { // not found return; } phFindUserArea.Visible = false; phProfileEditArea.Visible = true; // fill in the form with data lblNickname.Text = string.Format("{0} (UserId: {1})", user.NickName, user.UserID); tbxEmailAddress.Value = user.EmailAddress; tbxIconURL.Value = user.IconURL; if (user.DateOfBirth.HasValue) { DateTime dateOfBirth = user.DateOfBirth.Value; tbxDateOfBirth.Value = dateOfBirth.Month.ToString("0#") + "/" + dateOfBirth.Day.ToString("0#") + "/" + dateOfBirth.Year.ToString("####"); } tbxOccupation.Value = user.Occupation; tbxLocation.Value = user.Location; tbxWebsite.Value = user.Website; tbxSignature.Value = user.Signature; if (user.EmailAddressIsPublic.HasValue) { _emailAddressIsVisible.Value = user.EmailAddressIsPublic.Value.ToString().ToLowerInvariant(); } else { _emailAddressIsVisible.Value = "true"; } _defaultNumberOfMessagesPerPage.Value = user.DefaultNumberOfMessagesPerPage.ToString(); _autoSubscribeToThread.Value = user.AutoSubscribeToThread.ToString().ToLowerInvariant(); cmbUserTitle.SelectedValue = user.UserTitleID.ToString(); SetViewstate(); }
private void Page_Load(object sender, System.EventArgs e) { // use the UserID from the session, so it's impossible to edit another user. _userID = SessionAdapter.GetUserID(); if (_userID <= 0) { // anonymous Response.Redirect("default.aspx"); } if (!Page.IsPostBack) { // load the user entity from the db. UserEntity user = UserGuiHelper.GetUser(_userID); // fill in the form with data lblNickname.Text = user.NickName; tbxEmailAddress.Value = user.EmailAddress; tbxIconURL.Value = user.IconURL; if (user.DateOfBirth.HasValue) { DateTime dateOfBirth = user.DateOfBirth.Value; tbxDateOfBirth.Value = dateOfBirth.Month.ToString("0#") + "/" + dateOfBirth.Day.ToString("0#") + "/" + dateOfBirth.Year.ToString("####"); } tbxOccupation.Value = user.Occupation; tbxLocation.Value = user.Location; tbxWebsite.Value = user.Website; tbxSignature.Value = user.Signature; if (user.EmailAddressIsPublic.HasValue) { chkEmailAddressIsHidden.Checked = !user.EmailAddressIsPublic.Value; } else { chkEmailAddressIsHidden.Checked = false; } chkAutoSubscribeToThread.Checked = user.AutoSubscribeToThread; tbxDefaultNumberOfMessagesPerPage.Value = user.DefaultNumberOfMessagesPerPage.ToString(); } }
/// <summary> /// Handler for the selectclicked event of the finduser control. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SelectClickedHandler(object sender, System.EventArgs e) { List <int> selectedUserIDs = userFinder.SelectedUserIDs; if (selectedUserIDs.Count < 0) { // nothing selected, return return; } // just use the first selected user int selectedUserID = selectedUserIDs[0]; UserEntity user = UserGuiHelper.GetUser(selectedUserID); lblUserName.Text = user.NickName; AuditDataCoreCollection audits = SecurityGuiHelper.GetAllAuditsForUser(selectedUserID); phAuditInfo.Visible = true; rptAudits.DataSource = audits; rptAudits.DataBind(); }
private void btnUpdate_ServerClick(object sender, System.EventArgs e) { if (Page.IsValid) { // user has filled in the right values, update the user's data. string nickName = string.Empty; DateTime?dateOfBirth = null; string emailAddress = string.Empty; bool emailAddressIsPublic = false; string iconURL = string.Empty; string ipNumber = string.Empty; string location = string.Empty; string occupation = string.Empty; string password = string.Empty; string signature = string.Empty; string website = string.Empty; bool autoSubscribeThreads = true; short defaultMessagesPerPage = 10; if (tbxPassword1.Value.Length > 0) { password = tbxPassword1.Value; } emailAddress = tbxEmailAddress.Value; iconURL = tbxIconURL.Value; if (tbxDateOfBirth.Value.Length > 0) { try { dateOfBirth = System.DateTime.Parse(tbxDateOfBirth.Value, CultureInfo.InvariantCulture.DateTimeFormat); } catch (FormatException) { // format exception, date invalid, ignore, will resolve to default. } } emailAddressIsPublic = !chkEmailAddressIsHidden.Checked; location = tbxLocation.Value; occupation = tbxOccupation.Value; signature = tbxSignature.Value; website = tbxWebsite.Value; //Preferences autoSubscribeThreads = chkAutoSubscribeToThread.Checked; if (tbxDefaultNumberOfMessagesPerPage.Value.Length > 0) { defaultMessagesPerPage = HnDGeneralUtils.TryConvertToShort(tbxDefaultNumberOfMessagesPerPage.Value); } bool result = UserManager.UpdateUserProfile(SessionAdapter.GetUserID(), dateOfBirth, emailAddress, emailAddressIsPublic, iconURL, location, occupation, password, signature, website, SessionAdapter.GetUserTitleID(), ApplicationAdapter.GetParserData(), autoSubscribeThreads, defaultMessagesPerPage); if (result) { // get user back and update session object. UserEntity user = UserGuiHelper.GetUser(SessionAdapter.GetUserID()); if (user != null) { SessionAdapter.AddUserObject(user); } // all ok Response.Redirect("EditProfileSuccessful.aspx", true); } } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void Page_Load(object sender, System.EventArgs e) { int threadID = HnDGeneralUtils.TryConvertToInt(Request.QueryString["ThreadID"]); _thread = ThreadGuiHelper.GetThread(threadID); if (_thread == null) { // not found, return to default page Response.Redirect("default.aspx", true); } _startAtMessageIndex = HnDGeneralUtils.TryConvertToInt(Request.QueryString["StartAtMessage"]); _quoteMessageID = HnDGeneralUtils.TryConvertToInt(Request.QueryString["QuoteMessageID"]); // Check credentials bool userHasAccess = SessionAdapter.CanPerformForumActionRight(_thread.ForumID, ActionRights.AccessForum); if (!userHasAccess) { // doesn't have access to this forum. redirect Response.Redirect("default.aspx"); } // Check if the current user is allowed to add new messages to the thread. bool userMayAddNewMessages = false; if (!_thread.IsClosed) { if (_thread.IsSticky) { if (SessionAdapter.CanPerformForumActionRight(_thread.ForumID, ActionRights.AddAndEditMessageInSticky)) { userMayAddNewMessages = true; } } else { if (SessionAdapter.CanPerformForumActionRight(_thread.ForumID, ActionRights.AddAndEditMessage)) { userMayAddNewMessages = true; } } } if (!userMayAddNewMessages) { // is not allowed to post a new message Response.Redirect("Messages.aspx?ThreadID=" + threadID, true); } // use BL class. We could have used Lazy loading, though for the sake of separation, we'll call into the BL class. ForumEntity forum = CacheManager.GetForum(_thread.ForumID); if (forum == null) { // orphaned thread Response.Redirect("default.aspx"); } // check if the user can view the thread the message is in. If not, don't continue. if ((_thread.StartedByUserID != SessionAdapter.GetUserID()) && !SessionAdapter.CanPerformForumActionRight(_thread.ForumID, ActionRights.ViewNormalThreadsStartedByOthers)) { // can't add a message, it's in a thread which isn't visible to the user Response.Redirect("default.aspx", true); } meMessageEditor.ShowAddAttachment = ((forum.MaxNoOfAttachmentsPerMessage > 0) && SessionAdapter.CanPerformForumActionRight(_thread.ForumID, ActionRights.AddAttachment)); meMessageEditor.ShowSubscribeToThread = !UserGuiHelper.CheckIfThreadIsAlreadySubscribed(SessionAdapter.GetUserID(), _thread.ThreadID); // User is able to post a new message to the current thread. if (!Page.IsPostBack) { // fill the page's content lnkThreads.Text = HttpUtility.HtmlEncode(forum.ForumName); lnkThreads.NavigateUrl += "?ForumID=" + _thread.ForumID; meMessageEditor.ForumName = forum.ForumName; meMessageEditor.ThreadSubject = _thread.Subject; lblSectionName.Text = CacheManager.GetSectionName(forum.SectionID); lnkMessages.NavigateUrl += threadID; lnkMessages.Text = HttpUtility.HtmlEncode(_thread.Subject); phLastPostingInThread.Visible = (_quoteMessageID <= 0); bool userMayEditMemo = SessionAdapter.CanPerformForumActionRight(_thread.ForumID, ActionRights.EditThreadMemo); // get quoted message if passed in. if (_quoteMessageID > 0) { // get message and insert it into the textbox including quote tags. MessageEntity messageToQuote = MessageGuiHelper.GetMessage(_quoteMessageID); if (messageToQuote != null) { // message found. UserEntity quotedUser = UserGuiHelper.GetUser(messageToQuote.PostedByUserID); if (quotedUser != null) { // user found. proceed meMessageEditor.OriginalMessageText = TextParser.MakeStringQuoted(messageToQuote.MessageText, quotedUser.NickName); } } } else { // no quoted message. Load the last message from the active thread and display it in the form. This // message entity has the poster user entity prefetched, together with the usertitle of the user. MessageEntity lastMessageInThread = ThreadGuiHelper.GetLastMessageInThreadWithUserInfo(threadID); if (lastMessageInThread != null) { litMessageBody.Text = lastMessageInThread.MessageTextAsHTML; lblPostingDate.Text = lastMessageInThread.PostingDate.ToString("dd-MMM-yyyy HH:mm:ss"); if (lastMessageInThread.PostedByUser != null) { UserEntity messagePoster = lastMessageInThread.PostedByUser; if (messagePoster.UserTitle != null) { lblUserTitleDescription.Text = messagePoster.UserTitle.UserTitleDescription; } lblLocation.Text = messagePoster.Location; if (messagePoster.JoinDate.HasValue) { lblJoinDate.Text = messagePoster.JoinDate.Value.ToString("dd-MMM-yyyy HH:mm:ss"); } if (messagePoster.AmountOfPostings.HasValue) { lblAmountOfPostings.Text = messagePoster.AmountOfPostings.Value.ToString(); } if (messagePoster.SignatureAsHTML != null) { litSignature.Text = messagePoster.SignatureAsHTML; } lblNickname.Text = messagePoster.NickName; } } } if ((_thread.Memo.Length > 0) && userMayEditMemo) { // convert memo contents to HTML so it's displayed above the thread. string parserLog, messageTextXml; bool errorsOccured = false; string memoAsHTML = TextParser.TransformUBBMessageStringToHTML(_thread.Memo, ApplicationAdapter.GetParserData(), out parserLog, out errorsOccured, out messageTextXml); lblMemo.Text = memoAsHTML; } phMemo.Visible = userMayEditMemo; } }