/// <summary> /// Handles the ItemDataBound event of the rptQueues control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterItemEventArgs"/> instance containing the event data.</param> protected void rpQueues_ItemDataBound(object sender, RepeaterItemEventArgs e) { switch (e.Item.ItemType) { case ListItemType.AlternatingItem: case ListItemType.Item: SupportQueueEntity currentSupportQueue = (SupportQueueEntity)e.Item.DataItem; // get the threads in the queue and bind it to the repeater. If there are no threads, show the placeholder and hide the repeater. DataView threadsInQueue = SupportQueueGuiHelper.GetAllThreadsInSupportQueueAsDataView( SessionAdapter.GetForumsWithActionRight(ActionRights.AccessForum), currentSupportQueue.QueueID); if (threadsInQueue.Count > 0) { // there is data, bind it to the repeater // Find repeater control in this item Repeater rpThreads = (Repeater)e.Item.FindControl("rpThreads"); // bind it rpThreads.DataSource = threadsInQueue; rpThreads.DataBind(); } else { // no data, show the placeholder PlaceHolder noDataText = (PlaceHolder)e.Item.FindControl("phNoDataText"); noDataText.Visible = true; } break; } }
/// <summary> /// Loads the user and his rights and audits to the session object. /// </summary> /// <param name="user">The user to be added to the session.</param> public static void LoadUserSessionData(UserEntity user) { // Adds the user object to session AddUserObject(user); ActionRightCollection systemActionRights = SecurityGuiHelper.GetSystemActionRightsForUser(user.UserID); // add user system rights to the session object AddSystemActionRights(systemActionRights); AuditActionCollection auditActions = SecurityGuiHelper.GetAuditActionsForUser(user.UserID); // add user audit actions to the session object AddAuditActions(auditActions); ForumRoleForumActionRightCollection forumActionRights = SecurityGuiHelper.GetForumsActionRightsForUser(user.UserID); // add user forums rights to the session object AddForumsActionRights(forumActionRights); // set the last visit date. if ((user.UserID > 0) && (user.LastVisitedDate.HasValue)) { SessionAdapter.AddLastVisitDate(user.LastVisitedDate.Value, true); } else { SessionAdapter.AddLastVisitDate(DateTime.Now, true); } }
protected void Page_Load(object sender, EventArgs e) { // check if the calling user is able to approve attachments in 1 or more forums List <int> forumsWithApprovalRight = SessionAdapter.GetForumsWithActionRight(ActionRights.ApproveAttachment); List <int> accessableForums = SessionAdapter.GetForumsWithActionRight(ActionRights.AccessForum); if (((forumsWithApprovalRight == null) || (forumsWithApprovalRight.Count <= 0)) || ((accessableForums == null) || (accessableForums.Count <= 0))) { // no, this user doesn't have the right to approve attachments or doesn't have access to any forums. Response.Redirect("default.aspx", true); } List <int> forumsWithAttachmentDeleteRight = SessionAdapter.GetForumsWithActionRight(ActionRights.ManageOtherUsersAttachments); phAttachmentDelete.Visible = ((forumsWithAttachmentDeleteRight != null) && (forumsWithAttachmentDeleteRight.Count > 0)); if (!Page.IsPostBack) { // get all attachments which aren't approved yet as a dataview. DataView allAttachmentsToApprove = MessageGuiHelper.GetAllAttachmentsToApproveAsDataView(accessableForums, forumsWithApprovalRight, SessionAdapter.GetForumsWithActionRight(ActionRights.ViewNormalThreadsStartedByOthers), SessionAdapter.GetUserID()); rpAttachments.DataSource = allAttachmentsToApprove; rpAttachments.DataBind(); } }
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); } // Check access credentials bool userHasAccess = SessionAdapter.CanPerformForumActionRight(_thread.ForumID, ActionRights.AccessForum); bool userMayDoThreadManagement = SessionAdapter.CanPerformForumActionRight(_thread.ForumID, ActionRights.ForumSpecificThreadManagement) || SessionAdapter.HasSystemActionRight(ActionRights.SystemWideThreadManagement); if (!userHasAccess || !userMayDoThreadManagement) { // doesn't have access to this forum or may not alter the thread's properties. redirect Response.Redirect("default.aspx"); } if (!Page.IsPostBack) { chkIsClosed.Checked = _thread.IsClosed; chkIsSticky.Checked = _thread.IsSticky; tbxSubject.Value = _thread.Subject; } }
private void btnLogin_ServerClick(object sender, System.EventArgs e) { // try to authenticate the user UserEntity user = null; SecurityManager.AuthenticateResult result = SecurityManager.AuthenticateUser(tbxUserName.Value, tbxPassword.Value, out user); switch (result) { case SecurityManager.AuthenticateResult.AllOk: // authenticated // Save session cacheable data SessionAdapter.LoadUserSessionData(user); // update last visit date in db UserManager.UpdateLastVisitDateForUser(user.UserID); // done FormsAuthentication.RedirectFromLoginPage(tbxUserName.Value, chkPersistentLogin.Checked); // Audit the login action, if it was defined to be logged for this role. if (SessionAdapter.CheckIfNeedsAuditing(AuditActions.AuditLogin)) { SecurityManager.AuditLogin(SessionAdapter.GetUserID()); } break; case SecurityManager.AuthenticateResult.IsBanned: lblErrorMessage.Text = "You are banned. Login won't work for you."; break; case SecurityManager.AuthenticateResult.WrongUsernamePassword: lblErrorMessage.Text = "You specified a wrong User name - Password combination. Try again."; break; } }
protected void PostMessageHandler(object sender, System.EventArgs e) { int userID = SessionAdapter.GetUserID(); // store the new message in the given thread string mailTemplate = ApplicationAdapter.GetEmailTemplate(EmailTemplate.ThreadUpdatedNotification); int messageID = ThreadManager.CreateNewMessageInThread(_thread.ThreadID, userID, meMessageEditor.MessageText, meMessageEditor.MessageTextHTML, Request.UserHostAddress.ToString(), meMessageEditor.MessageTextXML, meMessageEditor.SubscribeToThread, mailTemplate, ApplicationAdapter.GetEmailData(), CacheManager.GetSystemData().SendReplyNotifications); // invalidate forum RSS in cache ApplicationAdapter.InvalidateCachedForumRSS(_thread.ForumID); // if auditing is required, we've to do this now. if (SessionAdapter.CheckIfNeedsAuditing(AuditActions.AuditNewMessage)) { SecurityManager.AuditNewMessage(userID, messageID); } // invalidate forum in asp.net cache CacheManager.InvalidateCachedItem(CacheManager.ProduceCacheKey(CacheKeys.SingleForum, _thread.ForumID)); // all ok, redirect to message list int startAtMessageIndex = ThreadGuiHelper.GetStartAtMessageForGivenMessageAndThread(_thread.ThreadID, messageID, SessionAdapter.GetUserDefaultNumberOfMessagesPerPage()); if (meMessageEditor.AddAttachment) { // redirect to manage attachment form for this message Response.Redirect(string.Format("Attachments.aspx?SourceType=1&MessageID={0}", messageID), true); } else { Response.Redirect(string.Format("Messages.aspx?ThreadID={0}&StartAtMessage={1}&#{2}", _thread.ThreadID, startAtMessageIndex, messageID), true); } }
protected void Page_Load(object sender, EventArgs e) { int attachmentID = HnDGeneralUtils.TryConvertToInt(Request.QueryString["AttachmentID"]); MessageEntity relatedMessage = MessageGuiHelper.GetMessageWithAttachmentLogic(attachmentID); if (relatedMessage == null) { // not found Response.Redirect("default.aspx", true); } // thread has been loaded into the related message object as well. This is needed for the forum access right check if (!SessionAdapter.CanPerformForumActionRight(relatedMessage.Thread.ForumID, ActionRights.AccessForum)) { // user can't access this forum Response.Redirect("default.aspx", true); } // Check if the thread is sticky, or that the user can see normal threads started // by others. If not, the user isn't allowed to view the thread the message is in, and therefore is denied access. if ((relatedMessage.Thread.StartedByUserID != SessionAdapter.GetUserID()) && !SessionAdapter.CanPerformForumActionRight(relatedMessage.Thread.ForumID, ActionRights.ViewNormalThreadsStartedByOthers) && !relatedMessage.Thread.IsSticky) { // user can't view the thread the message is in, because: // - the thread isn't sticky // AND // - the thread isn't posted by the calling user and the user doesn't have the right to view normal threads started by others Response.Redirect("default.aspx", true); } AttachmentEntity toStream = MessageGuiHelper.GetAttachment(attachmentID); if (toStream == null) { // not found Response.Redirect("default.aspx", true); } if (!toStream.Approved && !SessionAdapter.CanPerformForumActionRight(relatedMessage.Thread.ForumID, ActionRights.ApproveAttachment)) { // the attachment hasn't been approved yet, and the caller isn't entitled to approve attachments, so deny. // approval of attachments requires to be able to load the attachment without the attachment being approved Response.Redirect("default.aspx", true); } // all set, load stream the attachment data to the browser // create header Response.ClearHeaders(); Response.ClearContent(); Response.AddHeader("Content-Type", "application/unknown"); Response.AddHeader("Content-length", toStream.Filecontents.Length.ToString()); Response.AddHeader("Content-Disposition", "attachment; filename=" + toStream.Filename.Replace(" ", "_")); Response.AddHeader("Content-Transfer-Encoding", "Binary"); // stream the data Response.BinaryWrite(toStream.Filecontents); Response.Flush(); Response.End(); }
/// <summary> /// Event handler for the ItemDataBound event for the repeater control for the pagelist in the Messages page. In here the decision is made /// if the current item will be a link (we're not on this page) or not (thus a label) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void rptPageListMessages_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e) { int maxAmountMessagesPerPage = SessionAdapter.GetUserDefaultNumberOfMessagesPerPage(); switch (e.Item.ItemType) { case ListItemType.AlternatingItem: case ListItemType.Item: int currentPage = (_startMessageNo / maxAmountMessagesPerPage) + 1; if ((currentPage) == (int)(e.Item.DataItem)) { // the current number emitted by the repeater is the page number we're on at the moment. Label lblMessagePage = (Label)e.Item.FindControl("lblMessagesPage"); lblMessagePage.Visible = true; } else { HyperLink lnkMessagePage = (HyperLink)e.Item.FindControl("lnkMessagesPage"); lnkMessagePage.NavigateUrl += "?ThreadID=" + _threadID + "&StartAtMessage=" + (((int)(e.Item.DataItem) - 1) * maxAmountMessagesPerPage); if (_highLight) { lnkMessagePage.NavigateUrl += "&HighLight=1"; } lnkMessagePage.Visible = true; } break; } }
private void Page_Load(object sender, System.EventArgs e) { // logout user FormsAuthentication.SignOut(); // Abandone session SessionAdapter.Abandon(); }
protected void btnUnSubscribeFromThread_Click(object sender, ImageClickEventArgs e) { if (!_userMayDoBasicThreadOperations) { return; } UserManager.RemoveSingleSubscription(_thread.ThreadID, SessionAdapter.GetUserID()); Response.Redirect("Messages.aspx?ThreadID=" + _thread.ThreadID + "&StartAtMessage=" + _startMessageNo); }
private void Page_Load(object sender, System.EventArgs e) { // fill the page's content DataView bookmarks = UserGuiHelper.GetBookmarksAsDataView(SessionAdapter.GetUserID()); rpThreads.DataSource = bookmarks; rpThreads.DataBind(); btnRemoveChecked.Visible = (bookmarks.Count > 0); }
private void Page_Load(object sender, System.EventArgs e) { // fill the page's content List <int> accessableForums = SessionAdapter.GetForumsWithActionRight(ActionRights.AccessForum); DataView activeThreads = ThreadGuiHelper.GetActiveThreadsAsDataView(accessableForums, CacheManager.GetSystemData().HoursThresholdForActiveThreads, SessionAdapter.GetForumsWithActionRight(ActionRights.ViewNormalThreadsStartedByOthers), SessionAdapter.GetUserID()); rpThreads.DataSource = activeThreads; rpThreads.DataBind(); }
protected void btnSubscribeToThread_Click(object sender, ImageClickEventArgs e) { if (!_userMayDoBasicThreadOperations) { return; } bool result = UserManager.AddThreadToSubscriptions(_thread.ThreadID, SessionAdapter.GetUserID(), null); Response.Redirect("Messages.aspx?ThreadID=" + _thread.ThreadID + "&StartAtMessage=" + _startMessageNo); }
protected void btnThreadDone_Click(object sender, ImageClickEventArgs e) { if (!_userMayMarkThreadAsDone) { return; } // thread is re-opened, mark it as not done. ThreadManager.UnMarkThreadAsDone(_thread.ThreadID, SessionAdapter.GetUserID()); Response.Redirect("Messages.aspx?ThreadID=" + _thread.ThreadID + "&StartAtMessage=" + _startMessageNo); }
protected void btnUnbookmarkThread_Click(object sender, System.Web.UI.ImageClickEventArgs e) { if (!_userMayDoBasicThreadOperations) { return; } // remove the bookmark on this thread. UserManager.RemoveSingleBookmark(_thread.ThreadID, SessionAdapter.GetUserID()); Response.Redirect("Messages.aspx?ThreadID=" + _thread.ThreadID + "&StartAtMessage=" + _startMessageNo); }
/// <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 start page Response.Redirect("default.aspx"); } // Check credentials bool userHasAccess = SessionAdapter.CanPerformForumActionRight(_thread.ForumID, ActionRights.AccessForum); if (!userHasAccess) { // doesn't have access to this forum. redirect Response.Redirect("default.aspx"); } // show user IP addresses if the user has system admin rights, security admin rights or user admin rights. _showIPAddresses = (SessionAdapter.HasSystemActionRight(ActionRights.SystemManagement) || SessionAdapter.HasSystemActionRight(ActionRights.SecurityManagement) || SessionAdapter.HasSystemActionRight(ActionRights.UserManagement)); // Get the forum entity related to the thread. 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) { // not found, orphaned thread, return to default page. Response.Redirect("default.aspx"); } // check if the user can view this thread. If not, don't continue. if ((_thread.StartedByUserID != SessionAdapter.GetUserID()) && !SessionAdapter.CanPerformForumActionRight(_thread.ForumID, ActionRights.ViewNormalThreadsStartedByOthers) && !_thread.IsSticky) { // can't view this thread, it isn't visible to the user Response.Redirect("default.aspx", true); } lblForumName_Header.Text = forum.ForumName; if (!Page.IsPostBack) { bool threadStartedByCurrentUser = (_thread.StartedByUserID == SessionAdapter.GetUserID()); // Get messages and bind it to the repeater control. Use the startmessage to get only the message visible on the current page. MessagesInThreadTypedList messages = ThreadGuiHelper.GetAllMessagesInThreadAsTypedList(threadID, 0, 0); rptMessages.DataSource = messages; rptMessages.DataBind(); } }
protected void PostMessageHandler(object sender, System.EventArgs e) { ThreadManager.UpdateMemo(_thread.ThreadID, meMessageEditor.MessageText); if (SessionAdapter.CheckIfNeedsAuditing(AuditActions.AuditEditMemo)) { SecurityManager.AuditEditMemo(SessionAdapter.GetUserID(), _thread.ThreadID); } // all ok, redirect to thread list Response.Redirect("Messages.aspx?ThreadID=" + _thread.ThreadID + "&StartAtMessage=" + _startAtMessage, false); }
protected void btnBookmarkThread_Click(object sender, System.Web.UI.ImageClickEventArgs e) { if (!_userMayDoBasicThreadOperations) { return; } // bookmark this thread. bool result = UserManager.AddThreadToBookmarks(SessionAdapter.GetUserID(), _thread.ThreadID); Response.Redirect("Messages.aspx?ThreadID=" + _thread.ThreadID + "&StartAtMessage=" + _startMessageNo); }
protected void btnClaim_Click(object sender, EventArgs e) { if (!_userMayManageSupportQueueContents) { return; } // claim this thread SupportQueueManager.ClaimThread(SessionAdapter.GetUserID(), _thread.ThreadID); // done redirect to this page to refresh. Response.Redirect("Messages.aspx?ThreadID=" + _thread.ThreadID + "&StartAtMessage=" + _startMessageNo); }
/// <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 currentPage = HnDGeneralUtils.TryConvertToInt(Request["Page"]); if (currentPage == 0) { currentPage = 1; } if (!Page.IsPostBack) { plPageListTop.CurrentPage = currentPage; plPageListBottom.CurrentPage = currentPage; DataTable results = SessionAdapter.GetSearchResults(); if (results == null) { // no results, redirect to search page Response.Redirect("Search.aspx"); } short pageSize = CacheManager.GetSystemData().PageSizeSearchResults; if (pageSize <= 0) { pageSize = 50; } int amountPages = (results.Rows.Count / pageSize); if ((amountPages * pageSize) < results.Rows.Count) { amountPages++; } plPageListBottom.AmountPages = amountPages; plPageListTop.AmountPages = amountPages; // get the page of the resultset to bind. We page in-memory, so we have to execute the search query just once. DataTable toBind = results.Clone(); for (int i = 0; (i < pageSize) && ((((currentPage - 1) * pageSize) + i) < results.Rows.Count); i++) { toBind.ImportRow(results.Rows[((currentPage - 1) * pageSize) + i]); } rptResults.DataSource = toBind; rptResults.DataBind(); lblAmountThreads.Text = results.Rows.Count.ToString(); lblSearchTerms.Text = HttpUtility.HtmlEncode(SessionAdapter.GetSearchTerms()); } }
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); } // Check credentials bool userHasAccess = SessionAdapter.CanPerformForumActionRight(_thread.ForumID, ActionRights.AccessForum); if (!userHasAccess) { // doesn't have access to this forum. redirect Response.Redirect("default.aspx"); } bool userMayDeleteThread = SessionAdapter.HasSystemActionRight(ActionRights.SystemWideThreadManagement); if (!userMayDeleteThread) { // doesn't have the right to delete a thread. redirect Response.Redirect("Messages.aspx?ThreadID=" + threadID, true); } // check if the user can view this thread. If not, don't continue. if ((_thread.StartedByUserID != SessionAdapter.GetUserID()) && !SessionAdapter.CanPerformForumActionRight(_thread.ForumID, ActionRights.ViewNormalThreadsStartedByOthers) && !_thread.IsSticky) { // can't view this thread, it isn't visible to the user Response.Redirect("default.aspx", true); } if (!Page.IsPostBack) { // fill the page's content ForumEntity forum = CacheManager.GetForum(_thread.ForumID); if (forum == null) { // Orphaned thread Response.Redirect("default.aspx", true); } lblForumName.Text = forum.ForumName; lblThreadSubject.Text = HttpUtility.HtmlEncode(_thread.Subject); } }
private void Page_Load(object sender, System.EventArgs e) { int forumID = HnDGeneralUtils.TryConvertToInt(Request.QueryString["ForumID"]); _forum = CacheManager.GetForum(forumID); if (_forum == null) { // not found Response.Redirect("default.aspx", true); } bool userHasAccess = SessionAdapter.CanPerformForumActionRight(forumID, ActionRights.AccessForum); if (!userHasAccess) { // doesn't have access to this forum. redirect Response.Redirect("default.aspx", true); } _userCanCreateNormalThreads = SessionAdapter.CanPerformForumActionRight(forumID, ActionRights.AddNormalThread); _userCanCreateStickyThreads = SessionAdapter.CanPerformForumActionRight(forumID, ActionRights.AddStickyThread); if (!(_userCanCreateNormalThreads || _userCanCreateStickyThreads)) { // doesn't have the right to add new threads to this forum. redirect Response.Redirect("default.aspx", true); } meMessageEditor.ShowAddAttachment = ((_forum.MaxNoOfAttachmentsPerMessage > 0) && SessionAdapter.CanPerformForumActionRight(forumID, ActionRights.AddAttachment)); if (!String.IsNullOrEmpty(_forum.NewThreadWelcomeTextAsHTML)) { phWelcomeText.Visible = true; litWelcomeText.Text = _forum.NewThreadWelcomeTextAsHTML; } if (!Page.IsPostBack) { // fill the page's content lnkThreads.Text = HttpUtility.HtmlEncode(_forum.ForumName); lnkThreads.NavigateUrl += "?ForumID=" + forumID; meMessageEditor.ForumName = _forum.ForumName; meMessageEditor.ForumDescription = HttpUtility.HtmlEncode(_forum.ForumDescription); meMessageEditor.CanBeSticky = _userCanCreateStickyThreads; meMessageEditor.CanBeNormal = _userCanCreateNormalThreads; meMessageEditor.IsThreadStart = true; lblSectionName.Text = CacheManager.GetSectionName(_forum.SectionID); } }
protected void PostMessageHandler(object sender, System.EventArgs e) { int userID = SessionAdapter.GetUserID(); bool result = MessageManager.UpdateEditedMessage(userID, _editMessageID, meMessageEditor.MessageText, meMessageEditor.MessageTextHTML, Request.UserHostAddress, meMessageEditor.MessageTextXML); if (SessionAdapter.CheckIfNeedsAuditing(AuditActions.AuditAlteredMessage)) { SecurityManager.AuditAlteredMessage(userID, _editMessageID); } // all ok, redirect to thread list int startAtMessageID = ThreadGuiHelper.GetStartAtMessageForGivenMessageAndThread(_thread.ThreadID, _editMessageID, SessionAdapter.GetUserDefaultNumberOfMessagesPerPage()); Response.Redirect("Messages.aspx?ThreadID=" + _thread.ThreadID + "&StartAtMessage=" + startAtMessageID + "&#" + _editMessageID, false); }
/// <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) { // this is necessary so the 'clever' IE will also understand what to do: the enter key will then submit the form. this.ClientScript.RegisterHiddenField("__EVENTTARGET", "btnSearch"); if (!Page.IsPostBack) { // clear tmp results in session SessionAdapter.AddSearchTermsAndResults(string.Empty, null); // Read all the current existing forums and their section names. ForumsWithSectionNameTypedList forumsWithSectionName = ForumGuiHelper.GetAllForumsWithSectionNames(); // Get a list of Forum IDs to which the user has access right. List <int> accessableForums = SessionAdapter.GetForumsWithActionRight(ActionRights.AccessForum); foreach (ForumsWithSectionNameRow currentRow in forumsWithSectionName) { // filter out forums the user doesn't have access rights for. if (accessableForums.Contains(currentRow.ForumID)) { // forum is accessable to the user ListItem newItem = new ListItem(String.Format("{0} - {1}", currentRow.SectionName, currentRow.ForumName), currentRow.ForumID.ToString()); newItem.Selected = true; lbxForums.Items.Add(newItem); } } // make listbox as high as # of forums, with a maximum of 15 and a minimum of 8 if (lbxForums.Items.Count <= 15) { if (lbxForums.Items.Count > 8) { lbxForums.Rows = lbxForums.Items.Count; } else { lbxForums.Rows = 8; } } else { lbxForums.Rows = 15; } lblNumberOfPosts.Text = MessageGuiHelper.GetTotalNumberOfMessages().ToString(); } }
/// <summary> /// Event handler for the ItemDataBound for the repeater control. Will set/reset controls inside the repeater /// template according to the user and his rights. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void rptMessages_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e) { switch (e.Item.ItemType) { case ListItemType.AlternatingItem: case ListItemType.Item: // check if the thread is closed. If so, no editing nor new postings are allowed. if (!_thread.IsClosed) { HyperLink lnkEditMessage = (HyperLink)e.Item.FindControl("lnkEditMessage"); HyperLink lnkDeleteMessage = (HyperLink)e.Item.FindControl("lnkDeleteMessage"); HyperLink lnkNewMessageWQuote = (HyperLink)e.Item.FindControl("lnkNewMessageWQuote"); // editing and new messages are allowed when the rights are ok and the user isn't the AC // Check if the current message is posted by the current user bool showEditLink = _showEditMessageLink; int currentUserID = SessionAdapter.GetUserID(); if ((currentUserID == (int)((DataRowView)e.Item.DataItem)["UserID"]) && (currentUserID != 0)) { // yes. so enable editing showEditLink = true; } // you can only delete a message that's not the first message of the first thread. int currentPageNumber = HnDGeneralUtils.TryConvertToInt(lblCurrentPage.Text); bool showDeleteLink = (currentPageNumber > 1 || e.Item.ItemIndex > 0) && _showDeleteMessageLink; lnkEditMessage.Visible = showEditLink; lnkNewMessageWQuote.Visible = _showQuoteMessageLink; lnkDeleteMessage.Visible = showDeleteLink; if (showEditLink && showDeleteLink) { // enable separator lable ((Label)e.Item.FindControl("lblMessageCmdSepDeleteEdit")).Visible = true; } if ((showEditLink && _showQuoteMessageLink) || (showDeleteLink && _showQuoteMessageLink)) { // enable separator lable ((Label)e.Item.FindControl("lblMessageCmdSepEditQuote")).Visible = true; } } break; } }
/// <summary> /// Handles the ItemDataBound event of the rpForums control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterItemEventArgs"/> instance containing the event data.</param> protected void rpForums_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e) { switch (e.Item.ItemType) { case ListItemType.AlternatingItem: case ListItemType.Item: { Label forumLastPostingDateLabel = (Label)e.Item.FindControl("lblForumLastPostingDate"); // check if date is NULL if (((DataRowView)e.Item.DataItem)["ForumLastPostingDate"] is System.DBNull) { forumLastPostingDateLabel.Text = "Never"; // Date is null, there are no messages. System.Web.UI.WebControls.Image noNewPostsIcon = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgIconNoNewPosts"); noNewPostsIcon.Visible = true; } else { HttpContext hcCurrent = HttpContext.Current; DateTime forumLastPostingDate = (DateTime)(((DataRowView)e.Item.DataItem)["ForumLastPostingDate"]); DateTime lastVisitDate = SessionAdapter.GetLastVisitDate(); forumLastPostingDateLabel.Text = forumLastPostingDate.ToString("dd-MMM-yyyy HH:mm"); // date is not 0, check if the date is > than the date in the session variable. If so, the posting is newer and we // should visualize the New Messages image, otherwise the No new Messages image. System.Web.UI.WebControls.Image postsIcon; if (forumLastPostingDate > lastVisitDate) { // there are new messages since last visit postsIcon = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgIconNewPosts"); } else { // no new messages postsIcon = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgIconNoNewPosts"); } postsIcon.Visible = true; } } break; } }
private void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { // Check some credentials/properties and decide then which controls to show. // enable/disable the controls for logged in visitors. phNotLoggedIn.Visible = !Request.IsAuthenticated; phLoggedIn.Visible = Request.IsAuthenticated; phLoggedInBottom.Visible = Request.IsAuthenticated; phAdministrate.Visible = SessionAdapter.CanAdministrate(); phSupportQueues.Visible = SessionAdapter.HasSystemActionRight(ActionRights.QueueContentManagement); // check if the user has the action right to approve attachments on some forum. If so, show the menu item List <int> forumsWithApprovalRight = SessionAdapter.GetForumsWithActionRight(ActionRights.ApproveAttachment); phAttachmentApproval.Visible = ((forumsWithApprovalRight != null) && (forumsWithApprovalRight.Count > 0)); } }
protected void Page_Load(object sender, EventArgs e) { // check if the user has the right to be here bool userMayManageQueues = SessionAdapter.HasSystemActionRight(ActionRights.QueueContentManagement); if (!userMayManageQueues) { // doesn't have the right to manage queue contents. redirect Response.Redirect("default.aspx", true); } if (!Page.IsPostBack) { SupportQueueCollection supportQueues = CacheManager.GetAllSupportQueues(); rpQueues.DataSource = supportQueues; rpQueues.DataBind(); } }
private void btnSearch_ServerClick(object sender, System.EventArgs e) { if (Page.IsValid) { // grab forum id's List <int> forumIDs = new List <int>(); for (int i = 0; i < lbxForums.Items.Count; i++) { if (lbxForums.Items[i].Selected) { forumIDs.Add(Convert.ToInt32(lbxForums.Items[i].Value)); } } if (forumIDs.Count <= 0) { // no forums selected, add all of them for (int i = 0; i < lbxForums.Items.Count; i++) { forumIDs.Add(Convert.ToInt32(lbxForums.Items[i].Value)); } } SearchResultsOrderSetting orderFirstElement = (SearchResultsOrderSetting)cbxSortByFirstElement.SelectedIndex; SearchResultsOrderSetting orderSecondElement = (SearchResultsOrderSetting)cbxSortBySecondElement.SelectedIndex; SearchTarget targetToSearch = (SearchTarget)cbxElementToSearch.SelectedIndex; string searchTerms = tbxSearchString.Value; if (searchTerms.Length > 1024) { searchTerms = searchTerms.Substring(0, 1024); } // Use Full text search variant. SearchResultTypedList results = BL.Searcher.DoSearch(searchTerms, forumIDs, orderFirstElement, orderSecondElement, SessionAdapter.GetForumsWithActionRight(ActionRights.ViewNormalThreadsStartedByOthers), SessionAdapter.GetUserID(), targetToSearch); // store results in session. SessionAdapter.AddSearchTermsAndResults(searchTerms, results); // view results. Response.Redirect("SearchResults.aspx?Page=1", true); } }
/// <summary> /// Event handler for the ItemDataBound event for the repeater control for the pagelist in the Threads page. In here the decision is made /// if the current item will be a link (we're not on this page) or not (thus a label) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void rptPageListThreads_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e) { int maxAmountMessagesPerPage = SessionAdapter.GetUserDefaultNumberOfMessagesPerPage(); switch (e.Item.ItemType) { case ListItemType.AlternatingItem: case ListItemType.Item: int currentPage = (_startMessageNo / maxAmountMessagesPerPage) + 1; HyperLink lnkMessagePage = (HyperLink)e.Item.FindControl("lnkMessagesPage"); lnkMessagePage.NavigateUrl += "?ThreadID=" + _threadID + "&StartAtMessage=" + (((int)(e.Item.DataItem) - 1) * maxAmountMessagesPerPage); if (_highLight) { lnkMessagePage.NavigateUrl += "&HighLight=1"; } break; } }