Esempio n. 1
0
        /// <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();
            }
        }
Esempio n. 2
0
        /// <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();
            }
        }