/// <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; } }
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) { // 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(); }
/// <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(); } }
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)); } }
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); } }
private void Page_Load(object sender, System.EventArgs e) { // clear tmp results in session SessionAdapter.AddSearchTermsAndResults(string.Empty, null); // Read all accessable forums for the current user. List <int> accessableForums = SessionAdapter.GetForumsWithActionRight(ActionRights.AccessForum); string[] forumIDs = Request.QueryString.GetValues("ForumID"); List <int> forumIDsToSearchIn = new List <int>(); if (forumIDs != null) { foreach (string forumIDAsString in forumIDs) { int forumID = HnDGeneralUtils.TryConvertToInt(forumIDAsString); if (accessableForums.Contains(forumID)) { forumIDsToSearchIn.Add(forumID); } } } else { // add all forums the user has access to forumIDsToSearchIn.AddRange(accessableForums); } string searchTerms = Request.QueryString.Get("SearchTerms"); if (searchTerms.Length > 1024) { searchTerms = searchTerms.Substring(0, 1024); } SearchResultTypedList results = BL.Searcher.DoSearch(searchTerms, forumIDsToSearchIn, SearchResultsOrderSetting.ForumAscending, SearchResultsOrderSetting.LastPostDateDescending, SessionAdapter.GetForumsWithActionRight(ActionRights.ViewNormalThreadsStartedByOthers), SessionAdapter.GetUserID(), SearchTarget.MessageText); // store results in session. SessionAdapter.AddSearchTermsAndResults(searchTerms, results); // view results. Response.Redirect("SearchResults.aspx?Page=1", true); }
private void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { this.Title += ApplicationAdapter.GetSiteName(); // first time loaded, fill in properties lblUserName.Text = SessionAdapter.GetUserNickName(); HttpContext hcCurrent = HttpContext.Current; DataTable bookmarkStatistics = null; // check if user is authenticated if (hcCurrent.Request.IsAuthenticated) { lblWelcomeTextLoggedIn.Visible = true; bookmarkStatistics = UserGuiHelper.GetBookmarkStatisticsAsDataTable(SessionAdapter.GetUserID()); } else { lblWelcomeTextNotLoggedIn.Visible = true; bookmarkStatistics = new DataTable(); } // check if the user has the action right to approve attachments on some forum. If so, show the # of attachments which need approval List <int> forumsWithApprovalRight = SessionAdapter.GetForumsWithActionRight(ActionRights.ApproveAttachment); bool canApproveAttachments = ((forumsWithApprovalRight != null) && (forumsWithApprovalRight.Count > 0)); if (canApproveAttachments) { int numberOfAttachmentsToApprove = MessageGuiHelper.GetTotalNumberOfAttachmentsToApprove( SessionAdapter.GetForumsWithActionRight(ActionRights.AccessForum), SessionAdapter.GetForumsWithActionRight(ActionRights.ApproveAttachment), SessionAdapter.GetForumsWithActionRight(ActionRights.ViewNormalThreadsStartedByOthers), SessionAdapter.GetUserID()); if (numberOfAttachmentsToApprove > 0) { phAttachmentsToApprove.Visible = true; phAttentionRemarks.Visible = true; } } if (SessionAdapter.HasSystemActionRight(ActionRights.QueueContentManagement)) { int numberOfThreadsInSupportQueues = SupportQueueGuiHelper.GetTotalNumberOfThreadsInSupportQueues( SessionAdapter.GetForumsWithActionRight(ActionRights.AccessForum)); if (numberOfThreadsInSupportQueues > 0) { phThreadsToSupport.Visible = true; phAttentionRemarks.Visible = true; } } DateTime lastVisitDate = SessionAdapter.GetLastVisitDate(); if (SessionAdapter.IsLastVisitDateValid()) { phLastVisitDate.Visible = true; lblLastVisitDate.Text = lastVisitDate.ToString("dd-MMM-yyyy HH:mm"); } // Get all sections which possibly can be displayed. Obtain this from the cache, as it's hardly changing data, and // this page is read a lot. _sectionsToDisplay = CacheManager.GetAllSections(); // Per section, create a view with all the forumdata and filter out the forums not visible for the current user. List <int> accessableForums = SessionAdapter.GetForumsWithActionRight(ActionRights.AccessForum); List <int> forumsWithThreadsFromOthers = SessionAdapter.GetForumsWithActionRight(ActionRights.ViewNormalThreadsStartedByOthers); _forumViewsPerDisplayedSection = ForumGuiHelper.GetAllAvailableForumsDataViews(_sectionsToDisplay, accessableForums, forumsWithThreadsFromOthers, SessionAdapter.GetUserID()); // filter out sections which do not have displayable forums for this user EntityView <SectionEntity> sectionsToUse = CreateFilteredSectionsCollection(); // show the sections with displayable forums, thus the displayable sections. rpSections.DataSource = sectionsToUse; rpSections.DataBind(); // get bookmarks and show them in the gui if ((bookmarkStatistics.Rows.Count <= 0) || ((bookmarkStatistics.Rows.Count == 1) && ((int)bookmarkStatistics.Rows[0][0] == 0))) { // no bookmarks yet lblAmountBookmarks.Text = "0"; lblAmountPostingsInBookmarks.Text = "0"; lblBookmarksLastPostingDate.Text = "Never"; imgIconBookmarkNoNewPosts.Visible = true; } else { lblAmountBookmarks.Text = bookmarkStatistics.Rows[0]["AmountThreads"].ToString(); lblAmountPostingsInBookmarks.Text = bookmarkStatistics.Rows[0]["AmountPostings"].ToString(); DateTime dateLastPosting = (DateTime)bookmarkStatistics.Rows[0]["LastPostingDate"]; lblBookmarksLastPostingDate.Text = dateLastPosting.ToString("dd-MMM-yyyy HH:mm"); if (dateLastPosting > lastVisitDate) { imgIconBookmarkNewPosts.Visible = true; } else { imgIconBookmarkNoNewPosts.Visible = true; } } DataTable activeThreadsStatistics = ThreadGuiHelper.GetActiveThreadsStatisticsAsDataTable(accessableForums, CacheManager.GetSystemData().HoursThresholdForActiveThreads, SessionAdapter.GetForumsWithActionRight(ActionRights.ViewNormalThreadsStartedByOthers), SessionAdapter.GetUserID()); if (activeThreadsStatistics != null) { if ((activeThreadsStatistics.Rows.Count <= 0) || ((activeThreadsStatistics.Rows.Count == 1) && ((int)activeThreadsStatistics.Rows[0][0] == 0))) { lblAmountActiveThreads.Text = "0"; lblAmountPostingsInActiveThreads.Text = "0"; lblActiveThreadsLastPostingDate.Text = "Never"; imgIconActiveThreadsNoNewPosts.Visible = true; } else { lblAmountActiveThreads.Text = activeThreadsStatistics.Rows[0]["AmountThreads"].ToString(); lblAmountPostingsInActiveThreads.Text = activeThreadsStatistics.Rows[0]["AmountPostings"].ToString(); DateTime dateLastPosting = (DateTime)activeThreadsStatistics.Rows[0]["LastPostingDate"]; lblActiveThreadsLastPostingDate.Text = dateLastPosting.ToString("dd-MMM-yyyy HH:mm"); if (dateLastPosting > lastVisitDate) { imgIconActiveThreadsNewPosts.Visible = true; } else { imgIconActiveThreadsNoNewPosts.Visible = true; } } } } RegisterCollapseExpandClientScript(); }
/// <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 userID = HnDGeneralUtils.TryConvertToInt(Request.QueryString["UserID"]); if (!Page.IsPostBack) { UserEntity user = UserGuiHelper.GetUserWithTitleDescription(userID); if (user == null) { // not found Response.Redirect("default.aspx", true); } // fill in the content. The user's data is already html encoded (it's stored htmlencoded in the db), so // we don't need to worry to htmlencode it before it's displayed in the form. lblNickName.Text = user.NickName; bool emailAddressIsPublic = false; if (user.EmailAddressIsPublic.HasValue) { emailAddressIsPublic = user.EmailAddressIsPublic.Value; } if (emailAddressIsPublic || (SessionAdapter.HasSystemActionRight(ActionRights.SystemManagement))) { lblEmailAddressNotPublicTxt.Visible = false; lnkEmailAddress.Visible = true; lnkEmailAddress.NavigateUrl = "mailto:" + user.EmailAddress; lnkEmailAddress.Text = user.EmailAddress; } else { lblEmailAddressNotPublicTxt.Visible = true; } // view admin section if the user has system admin rights, security management rights, or user management rights. phAdminSection.Visible = (SessionAdapter.HasSystemActionRight(ActionRights.SystemManagement) || SessionAdapter.HasSystemActionRight(ActionRights.SecurityManagement) || SessionAdapter.HasSystemActionRight(ActionRights.UserManagement)); if (!string.IsNullOrEmpty(user.IconURL)) { // show icon string sURL = "http://" + user.IconURL; imgIcon.ImageUrl = sURL; imgIcon.Visible = true; lblIconURL.Text = sURL; } if (user.LastVisitedDate.HasValue) { lblLastVisitDate.Text = user.LastVisitedDate.Value.ToString("dd-MMM-yyy HH:mm.ss"); } else { lblLastVisitDate.Text = "Unknown (tracked by cookie)"; } if (user.DateOfBirth.HasValue) { lblDateOfBirth.Text = user.DateOfBirth.Value.ToString("dd-MMM-yyyy"); } lblOccupation.Text = user.Occupation; lblLocation.Text = user.Location; if (!string.IsNullOrEmpty(user.Website)) { string sURL = "http://" + user.Website; lnkWebsite.Text = sURL; lnkWebsite.NavigateUrl = sURL; lnkWebsite.Visible = true; } lblSignature.Text = user.SignatureAsHTML; lblRegisteredOn.Text = user.JoinDate.Value.ToString("dd-MMM-yyyy HH:mm:ss"); lblAmountOfPosts.Text = user.AmountOfPostings.ToString(); lblUserTitle.Text = user.UserTitle.UserTitleDescription; lblIpAddress.Text = user.IPNumber; // get the last 25 threads. DataView lastThreads = UserGuiHelper.GetLastThreadsForUserAsDataView(SessionAdapter.GetForumsWithActionRight(ActionRights.AccessForum), userID, SessionAdapter.GetForumsWithActionRight(ActionRights.ViewNormalThreadsStartedByOthers), SessionAdapter.GetUserID(), 25); rpThreads.DataSource = lastThreads; rpThreads.DataBind(); } }
/// <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 callingUserID = SessionAdapter.GetUserID(); if (callingUserID == 0) { // anonymous, redirect Response.Redirect("default.aspx", true); } if (!Page.IsPostBack) { int rowCount = 0; int currentPage = HnDGeneralUtils.TryConvertToInt(Request["Page"]); if (currentPage == 0) { currentPage = 1; // reset # of rows in the session. rowCount = 0; } else { rowCount = SessionAdapter.GetTempResult <int>("MyThreadsRowCount"); } // check if the rowCount is valid if (rowCount <= 0) { // reload rowCount rowCount = UserGuiHelper.GetRowCountLastThreadsForUserAsDataView(SessionAdapter.GetForumsWithActionRight(ActionRights.AccessForum), callingUserID, SessionAdapter.GetForumsWithActionRight(ActionRights.ViewNormalThreadsStartedByOthers), callingUserID); SessionAdapter.SetTempResult("MyThreadsRowCount", rowCount); } short pageSize = CacheManager.GetSystemData().PageSizeSearchResults; if (pageSize <= 0) { pageSize = 50; } int rowCountCapped = rowCount; if (rowCount > 500) { // maximum is 500 rowCountCapped = 500; lblCappingWarning.Visible = true; } int amountPages = (rowCountCapped / pageSize); if ((amountPages * pageSize) < rowCountCapped) { amountPages++; } plPageListBottom.AmountPages = amountPages; plPageListBottom.CurrentPage = currentPage; plPageListTop.AmountPages = amountPages; plPageListTop.CurrentPage = currentPage; lblAmountThreads.Text = rowCount.ToString(); DataView lastThreads = UserGuiHelper.GetLastThreadsForUserAsDataView(SessionAdapter.GetForumsWithActionRight(ActionRights.AccessForum), callingUserID, SessionAdapter.GetForumsWithActionRight(ActionRights.ViewNormalThreadsStartedByOthers), callingUserID, pageSize, currentPage); rpThreads.DataSource = lastThreads; rpThreads.DataBind(); } }