Exemple #1
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.User == null)
            {
                YafBuildLink.AccessDenied();
            }

            if (!this.IsPostBack)
            {
                // get user data...
                var user = UserMembershipHelper.GetMembershipUserById(this.UserID);

                if (user == null)
                {
                    YafBuildLink.AccessDenied(/*No such user exists*/);
                }

                var displayName = UserMembershipHelper.GetDisplayNameFromID(this.UserID);

                this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                this.PageLinks.AddLink(
                    this.PageContext.BoardSettings.EnableDisplayName ? displayName : user.UserName,
                    YafBuildLink.GetLink(
                        ForumPages.profile,
                        "u={0}&name={1}",
                        this.UserID,
                        this.PageContext.BoardSettings.EnableDisplayName ? displayName : user.UserName));
                this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty);

                // get full user data...
                var userData = new CombinedUserDataHelper(user, this.UserID);

                this.Msg.NavigateUrl   = "aim:goim?screenname={0}&message=Hi.+Are+you+there?".FormatWith(userData.Profile.AIM);
                this.Buddy.NavigateUrl = "aim:addbuddy?screenname={0}".FormatWith(userData.Profile.AIM);
            }
        }
Exemple #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="EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (!this.Get <YafBoardSettings>().EnableAlbum)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("u") == null ||
                this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("a") == null)
            {
                YafBuildLink.AccessDenied();
            }

            var userId  = Security.StringToLongOrRedirect(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("u"));
            var albumId = Security.StringToLongOrRedirect(
                this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("a"));

            var displayName = this.Get <IUserDisplayName>().GetName((int)userId);

            // Generate the page links.
            this.PageLinks.Clear();
            this.PageLinks.AddRoot();
            this.PageLinks.AddLink(displayName, YafBuildLink.GetLink(ForumPages.profile, "u={0}&name={1}", userId, displayName));
            this.PageLinks.AddLink(this.GetText("ALBUMS"), YafBuildLink.GetLink(ForumPages.albums, "u={0}", userId));
            this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty);

            // Set the title text.
            this.LocalizedLabel1.Param0 = this.Server.HtmlEncode(displayName);
            this.LocalizedLabel1.Param1 = this.Server.HtmlEncode(LegacyDb.album_gettitle(albumId));

            this.Back.Text = this.GetText("BACK_ALBUMS");

            // Initialize the Album Image List control.
            this.AlbumImageList1.UserID  = (int)userId;
            this.AlbumImageList1.AlbumID = (int)albumId;
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (User == null || !PageContext.BoardSettings.AllowEmailSending)
            {
                YafBuildLink.AccessDenied();
            }

            if (!IsPostBack)
            {
                // get user data...
                MembershipUser user = UserMembershipHelper.GetMembershipUser(UserID);

                if (user == null)
                {
                    YafBuildLink.AccessDenied(/*No such user exists*/);
                }

                PageLinks.AddLink(PageContext.BoardSettings.Name, YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.forum));
                PageLinks.AddLink(user.UserName, YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.profile, "u={0}", UserID));
                PageLinks.AddLink(GetText("TITLE"), "");

                Send.Text = GetText("SEND");
            }
        }
Exemple #4
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="EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.User == null || !this.Get <YafBoardSettings>().AllowEmailSending)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.IsPostBack)
            {
                return;
            }

            // get user data...
            var user = UserMembershipHelper.GetMembershipUserById(this.UserId);

            if (user == null)
            {
                YafBuildLink.AccessDenied(/*No such user exists*/);
            }
            else
            {
                var displayName = UserMembershipHelper.GetDisplayNameFromID(this.UserId);

                this.PageLinks.AddRoot();
                this.PageLinks.AddLink(
                    this.PageContext.BoardSettings.EnableDisplayName ? displayName : user.UserName,
                    YafBuildLink.GetLink(
                        ForumPages.profile,
                        "u={0}&name={1}",
                        this.UserId,
                        this.PageContext.BoardSettings.EnableDisplayName ? displayName : user.UserName));
                this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty);

                this.Send.Text = this.GetText("SEND");
            }
        }
Exemple #5
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>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            // we're in the admin section...
            this.ProfileEditControl.InAdminPages   = true;
            this.SignatureEditControl.InAdminPages = true;
            this.AvatarEditControl.InAdminPages    = true;

            this.PageContext.QueryIDs = new QueryStringIDHelper("u", true);

            DataTable dt = LegacyDb.user_list(this.PageContext.PageBoardID, this.CurrentUserID, null);

            if (dt.Rows.Count != 1)
            {
                return;
            }

            DataRow userRow = dt.Rows[0];

            // do admin permission check...
            if (!this.PageContext.IsHostAdmin && this.IsUserHostAdmin(userRow))
            {
                // user is not host admin and is attempted to edit host admin account...
                YafBuildLink.AccessDenied();
            }

            if (this.IsPostBack)
            {
                return;
            }

            this.PageLinks.AddLink(this.Get <YafBoardSettings>().Name, YafBuildLink.GetLink(ForumPages.forum));
            this.PageLinks.AddLink(
                this.GetText("ADMIN_ADMIN", "Administration"), YafBuildLink.GetLink(ForumPages.admin_admin));

            this.PageLinks.AddLink(this.GetText("ADMIN_USERS", "TITLE"), YafBuildLink.GetLink(ForumPages.admin_users));

            var userName = this.Get <YafBoardSettings>().EnableDisplayName
                               ? userRow["DisplayName"].ToString()
                               : userRow["Name"].ToString();

            // current page label (no link)
            this.PageLinks.AddLink(
                this.GetText("ADMIN_EDITUSER", "TITLE").FormatWith(userName),
                string.Empty);

            this.Page.Header.Title = "{0} - {1} - {2}".FormatWith(
                this.GetText("ADMIN_ADMIN", "Administration"),
                this.GetText("ADMIN_USERS", "TITLE"),
                this.GetText("ADMIN_EDITUSER", "TITLE").FormatWith(userName));

            // do a quick user membership sync...
            MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.CurrentUserID);

            // update if the user is not Guest
            if (!this.IsGuestUser)
            {
                RoleMembershipHelper.UpdateForumUser(user, this.PageContext.PageBoardID);
            }

            this.EditUserTabs.DataBind();
        }
Exemple #6
0
        /// <summary>
        /// the page load event.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (!this.Get <YafBoardSettings>().EnableAlbum)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.IsPostBack)
            {
                return;
            }

            var sigData = this.GetRepository <User>().AlbumsDataAsDataTable(
                this.PageContext.PageUserID,
                YafContext.Current.PageBoardID);

            var usrAlbumsAllowed = sigData.GetFirstRowColumnAsValue <int?>("UsrAlbums", null);

            var albumSize = this.GetRepository <UserAlbum>().CountUserAlbum(this.PageContext.PageUserID);
            int userID;

            switch (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("a"))
            {
            // A new album is being created. check the permissions.
            case "new":

                // Is album feature enabled?
                if (!this.Get <YafBoardSettings>().EnableAlbum)
                {
                    YafBuildLink.AccessDenied();
                }

                // Has the user created maximum number of albums?
                if (usrAlbumsAllowed.HasValue && usrAlbumsAllowed > 0)
                {
                    // Albums count. If we reached limit then we go to info page.
                    if (usrAlbumsAllowed > 0 && albumSize >= usrAlbumsAllowed)
                    {
                        YafBuildLink.RedirectInfoPage(InfoMessage.AccessDenied);
                    }
                }

                /* if (this.Get<YafBoardSettings>().AlbumsMax > 0 &&
                 *                  albumSize[0] > this.Get<YafBoardSettings>().AlbumsMax - 1)
                 *        {
                 *            YafBuildLink.RedirectInfoPage(InfoMessage.AccessDenied);
                 *        }*/
                userID = this.PageContext.PageUserID;
                break;

            default:
                userID = this.GetRepository <UserAlbum>().List(
                    Security.StringToIntOrRedirect(
                        this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("a")))
                         .FirstOrDefault().UserID;

                if (userID != this.PageContext.PageUserID)
                {
                    YafBuildLink.AccessDenied();
                }

                break;
            }

            var displayName = YafContext.Current.Get <YafBoardSettings>().EnableDisplayName
                                  ? UserMembershipHelper.GetDisplayNameFromID(userID)
                                  : UserMembershipHelper.GetUserNameFromID(userID);

            // Add the page links.
            this.PageLinks.AddRoot();
            this.PageLinks.AddLink(
                displayName,
                YafBuildLink.GetLink(ForumPages.profile, "u={0}&name={1}", userID.ToString(), displayName));
            this.PageLinks.AddLink(
                this.GetText("ALBUMS"),
                YafBuildLink.GetLink(ForumPages.albums, "u={0}", userID.ToString()));
            this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty);

            this.BindData();

            var usrAlbumImagesAllowed = sigData.GetFirstRowColumnAsValue <int?>("UsrAlbumImages", null);

            // Has the user uploaded maximum number of images?
            // vzrus: changed for DB check The default number of album images is 0. In the case albums are disabled.
            if (usrAlbumImagesAllowed.HasValue && usrAlbumImagesAllowed > 0)
            {
                if (this.List.Items.Count >= usrAlbumImagesAllowed)
                {
                    this.uploadtitletr.Visible = false;
                    this.selectfiletr.Visible  = false;
                }
                else
                {
                    this.uploadtitletr.Visible = true;
                    this.selectfiletr.Visible  = true;
                }

                this.imagesInfo.Text = this.GetTextFormatted(
                    "IMAGES_INFO",
                    this.List.Items.Count,
                    usrAlbumImagesAllowed,
                    this.Get <YafBoardSettings>().AlbumImagesSizeMax / 1024);
            }
            else
            {
                this.uploadtitletr.Visible = false;
                this.selectfiletr.Visible  = 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>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (!this.PageContext.IsHostAdmin)
            {
                YafBuildLink.AccessDenied();
            }

            if (!this.IsPostBack)
            {
                this.PageLinks.AddRoot();
                this.PageLinks.AddLink(
                    this.GetText("ADMIN_ADMIN", "Administration"),
                    YafBuildLink.GetLink(ForumPages.admin_admin));
                this.PageLinks.AddLink(this.GetText("ADMIN_HOSTSETTINGS", "TITLE"), string.Empty);

                this.Page.Header.Title = "{0} - {1}".FormatWith(
                    this.GetText("ADMIN_ADMIN", "Administration"),
                    this.GetText("ADMIN_HOSTSETTINGS", "TITLE"));

                this.RenderListItems();

                this.BindData();
            }

            var txtBoxes =
                this.ControlListRecursive(
                    c => (c.GetType() == typeof(TextBox) && ((TextBox)c).TextMode == TextBoxMode.SingleLine))
                .Cast <TextBox>()
                .ToList();

            // default to 100% width...
            txtBoxes.ForEach(x => x.Width = Unit.Percentage(100));

            // vzrus : 13/5/2010
            this.ServerTimeCorrection.AddStyleAttributeWidth("50px");
            this.ServerTimeCorrection.AddAttributeMaxWidth("4");

            this.ImageAttachmentResizeHeight.AddStyleAttributeWidth("50px");

            this.MaxPostSize.AddStyleAttributeWidth("50px");
            this.UserNameMaxLength.AddAttributeMaxWidth("5");

            this.UserNameMaxLength.AddStyleAttributeWidth("50px");
            this.UserNameMaxLength.AddAttributeMaxWidth("3");

            this.ActiveListTime.AddStyleAttributeWidth("50px");

            this.PictureAttachmentDisplayTreshold.AddStyleAttributeWidth("100px");
            this.PictureAttachmentDisplayTreshold.AddAttributeMaxWidth("11");

            this.ImageAttachmentResizeWidth.AddStyleAttributeWidth("50px");
            this.DisableNoFollowLinksAfterDay.AddStyleAttributeWidth("100px");

            // Ederon : 7/14/2007
            this.UserBox.AddStyleAttributeSize("350px", "100px");

            // CheckCache
            this.CheckCache();

            // Hide Some settings if yaf is inside dnn
            this.AvatarSettingsHolder.Visible = !Config.IsDotNetNuke;
            this.SSLSettings.Visible          = !Config.IsDotNetNuke;
            this.BotRegisterCheck.Visible     = !Config.IsDotNetNuke;
            this.LoginSettings.Visible        = !Config.IsDotNetNuke;
        }
Exemple #8
0
        /// <summary>
        /// The quick reply_ click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void QuickReply_Click([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (!this.PageContext.ForumReplyAccess || (this._topicFlags.IsLocked && !this.PageContext.ForumModeratorAccess))
            {
                YafBuildLink.AccessDenied();
            }

            if (this._quickReplyEditor.Text.Length <= 0)
            {
                this.PageContext.AddLoadMessage(this.GetText("EMPTY_MESSAGE"));
                return;
            }

            if (((this.PageContext.IsGuest && this.PageContext.BoardSettings.EnableCaptchaForGuests) ||
                 (this.PageContext.BoardSettings.EnableCaptchaForPost && !this.PageContext.IsCaptchaExcluded)) &&
                !CaptchaHelper.IsValid(this.tbCaptcha.Text.Trim()))
            {
                this.PageContext.AddLoadMessage(this.GetText("BAD_CAPTCHA"));
                return;
            }

            if (!(this.PageContext.IsAdmin || this.PageContext.IsModerator) &&
                this.PageContext.BoardSettings.PostFloodDelay > 0)
            {
                if (YafContext.Current.Get <YafSession>().LastPost > DateTime.UtcNow.AddSeconds(-this.PageContext.BoardSettings.PostFloodDelay))
                {
                    this.PageContext.AddLoadMessage(
                        this.GetTextFormatted(
                            "wait",
                            (YafContext.Current.Get <YafSession>().LastPost - DateTime.UtcNow.AddSeconds(-this.PageContext.BoardSettings.PostFloodDelay)).Seconds));
                    return;
                }
            }

            YafContext.Current.Get <YafSession>().LastPost = DateTime.UtcNow;

            // post message...
            long   nMessageId = 0;
            object replyTo    = -1;
            string msg        = this._quickReplyEditor.Text;
            long   topicID    = this.PageContext.PageTopicID;

            var tFlags = new MessageFlags
            {
                IsHtml     = this._quickReplyEditor.UsesHTML,
                IsBBCode   = this._quickReplyEditor.UsesBBCode,
                IsApproved = this.PageContext.IsAdmin || this.PageContext.IsModerator
            };

            // Bypass Approval if Admin or Moderator.
            if (
                !DB.message_save(
                    topicID,
                    this.PageContext.PageUserID,
                    msg,
                    null,
                    this.Request.UserHostAddress,
                    null,
                    replyTo,
                    tFlags.BitValue,
                    ref nMessageId))
            {
                topicID = 0;
            }

            // Check to see if the user has enabled "auto watch topic" option in his/her profile.
            if (this.PageContext.CurrentUserData.AutoWatchTopics)
            {
                using (DataTable dt = DB.watchtopic_check(this.PageContext.PageUserID, this.PageContext.PageTopicID))
                {
                    if (dt.Rows.Count == 0)
                    {
                        // subscribe to this forum
                        DB.watchtopic_add(this.PageContext.PageUserID, this.PageContext.PageTopicID);
                    }
                }
            }

            bool bApproved = false;

            using (DataTable dt = DB.message_list(nMessageId))
            {
                foreach (DataRow row in dt.Rows)
                {
                    bApproved = ((int)row["Flags"] & 16) == 16;
                }
            }

            if (bApproved)
            {
                // send new post notification to users watching this topic/forum
                this.Get <YafSendNotification>().ToWatchingUsers(nMessageId.ToType <int>());

                // redirect to newly posted message
                YafBuildLink.Redirect(ForumPages.posts, "m={0}&#post{0}", nMessageId);
            }
            else
            {
                if (this.PageContext.BoardSettings.EmailModeratorsOnModeratedPost)
                {
                    // not approved, notifiy moderators
                    this.Get <YafSendNotification>().ToModeratorsThatMessageNeedsApproval(
                        this.PageContext.PageForumID, (int)nMessageId);
                }

                string url = YafBuildLink.GetLink(ForumPages.topics, "f={0}", this.PageContext.PageForumID);
                if (Config.IsRainbow)
                {
                    YafBuildLink.Redirect(ForumPages.info, "i=1");
                }
                else
                {
                    YafBuildLink.Redirect(ForumPages.info, "i=1&url={0}", this.Server.UrlEncode(url));
                }
            }
        }
        /// <summary>
        /// The bind data.
        /// </summary>
        private void BindData()
        {
            DataTable activeUsers = null;

            switch (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefaultAs <int>("v"))
            {
            case 0:

                // Show all users
                activeUsers = this.GetActiveUsersData(
                    true,
                    this.PageContext.BoardSettings.ShowGuestsInDetailedActiveList);
                if (activeUsers != null)
                {
                    this.RemoveHiddenUsers(ref activeUsers);
                }

                break;

            case 1:

                // Show members
                activeUsers = this.GetActiveUsersData(false, false);
                if (activeUsers != null)
                {
                    this.RemoveHiddenUsers(ref activeUsers);
                }

                break;

            case 2:

                // Show guests
                activeUsers = this.GetActiveUsersData(true, this.PageContext.BoardSettings.ShowCrawlersInActiveList);
                if (activeUsers != null)
                {
                    this.RemoveAllButGuests(ref activeUsers);
                }

                break;

            case 3:

                // Show hidden
                if (this.PageContext.IsAdmin)
                {
                    activeUsers = this.GetActiveUsersData(false, false);
                    if (activeUsers != null)
                    {
                        this.RemoveAllButHiddenUsers(ref activeUsers);
                    }
                }
                else
                {
                    YafBuildLink.AccessDenied();
                }

                break;

            default:
                YafBuildLink.AccessDenied();
                break;
            }

            if (activeUsers == null || !activeUsers.HasRows())
            {
                return;
            }

            YafContext.Current.PageElements.RegisterJsBlock(
                "UnverifiedUserstablesorterLoadJs",
                JavaScriptBlocks.LoadTableSorter(
                    "#ActiveUsers",
                    "sortList: [[3,1],[0,0]]",
                    "#ActiveUsersPager"));

            this.UserList.DataSource = activeUsers;
            this.DataBind();
        }
Exemple #10
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="EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            this._messageRow = null;

            if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("m") != null)
            {
                this._messageRow =
                    LegacyDb.message_list(
                        Security.StringToLongOrRedirect(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("m")))
                    .GetFirstRowOrInvalid();

                if (!this.PageContext.ForumModeratorAccess &&
                    this.PageContext.PageUserID != (int)this._messageRow["UserID"])
                {
                    YafBuildLink.AccessDenied();
                }
            }

            this._forumFlags         = new ForumFlags(this._messageRow["ForumFlags"]);
            this._topicFlags         = new TopicFlags(this._messageRow["TopicFlags"]);
            this._ownerUserId        = (int)this._messageRow["UserID"];
            this._isModeratorChanged = this.PageContext.PageUserID != this._ownerUserId;

            if (this.PageContext.PageForumID == 0)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("t") == null &&
                !this.PageContext.ForumPostAccess)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("t") != null &&
                !this.PageContext.ForumReplyAccess)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.IsPostBack)
            {
                return;
            }

            // setup page links
            this.PageLinks.AddRoot();
            this.PageLinks.AddLink(
                this.PageContext.PageCategoryName,
                YafBuildLink.GetLink(ForumPages.forum, "c={0}", this.PageContext.PageCategoryID));
            this.PageLinks.AddForum(this.PageContext.PageForumID);

            this.EraseMessage.Checked    = false;
            this.EraseRow.Visible        = false;
            this.DeleteReasonRow.Visible = false;
            this.LinkedPosts.Visible     = false;

            this.Cancel.Text = this.GetText("Cancel");

            if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("m") == null)
            {
                return;
            }

            // delete message...
            this.PreviewRow.Visible = true;

            DataTable tempdb =
                LegacyDb.message_getRepliesList(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("m"));

            if (tempdb.HasRows() && (this.PageContext.ForumModeratorAccess || this.PageContext.IsAdmin))
            {
                this.LinkedPosts.Visible    = true;
                this.LinkedPosts.DataSource = tempdb;
                this.LinkedPosts.DataBind();
            }

            if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("action").ToLower() == "delete")
            {
                this.Title.Text  = this.GetText("EDIT");
                this.Delete.Text = this.GetText("DELETE");

                if (this.PageContext.IsAdmin)
                {
                    this.EraseRow.Visible = true;
                }
            }
            else
            {
                this.Title.Text  = this.GetText("EDIT");
                this.Delete.Text = this.GetText("UNDELETE");
            }

            this.Subject.Text            = Convert.ToString(this._messageRow["Topic"]);
            this.DeleteReasonRow.Visible = true;
            this.ReasonEditor.Text       = Convert.ToString(this._messageRow["DeleteReason"]);

            // populate the message preview with the message datarow...
            this.MessagePreview.Message      = this._messageRow["message"].ToString();
            this.MessagePreview.MessageFlags = new MessageFlags(this._messageRow["Flags"]);
        }
Exemple #11
0
        private void QuickReply_Click(object sender, EventArgs e)
        {
            if (!PageContext.ForumReplyAccess ||
                (_topicFlags.IsLocked && !PageContext.ForumModeratorAccess))
            {
                YafBuildLink.AccessDenied();
            }

            if (_quickReplyEditor.Text.Length <= 0)
            {
                PageContext.AddLoadMessage(GetText("EMPTY_MESSAGE"));
                return;
            }

            if ((
                    (PageContext.IsGuest && PageContext.BoardSettings.EnableCaptchaForGuests) ||
                    (PageContext.BoardSettings.EnableCaptchaForPost && !PageContext.IsCaptchaExcluded)
                    ) && Session["CaptchaImageText"].ToString() != tbCaptcha.Text.Trim())
            {
                PageContext.AddLoadMessage(GetText("BAD_CAPTCHA"));
                return;
            }

            if (!(PageContext.IsAdmin || PageContext.IsModerator) && PageContext.BoardSettings.PostFloodDelay > 0)
            {
                if (Mession.LastPost > DateTime.Now.AddSeconds(-PageContext.BoardSettings.PostFloodDelay))
                {
                    PageContext.AddLoadMessage(String.Format(GetText("wait"), (Mession.LastPost - DateTime.Now.AddSeconds(-PageContext.BoardSettings.PostFloodDelay)).Seconds));
                    return;
                }
            }
            Mession.LastPost = DateTime.Now;

            // post message...

            long   TopicID;
            long   nMessageID = 0;
            object replyTo    = -1;
            string msg        = _quickReplyEditor.Text;

            TopicID = PageContext.PageTopicID;

            MessageFlags tFlags = new MessageFlags();

            tFlags.IsHtml   = _quickReplyEditor.UsesHTML;
            tFlags.IsBBCode = _quickReplyEditor.UsesBBCode;

            // Bypass Approval if Admin or Moderator.
            tFlags.IsApproved = (PageContext.IsAdmin || PageContext.IsModerator);

            if (!YAF.Classes.Data.DB.message_save(TopicID, PageContext.PageUserID, msg, null, Request.UserHostAddress, null, replyTo, tFlags.BitValue, ref nMessageID))
            {
                TopicID = 0;
            }

            bool bApproved = false;

            using (DataTable dt = YAF.Classes.Data.DB.message_list(nMessageID))
                foreach (DataRow row in dt.Rows)
                {
                    bApproved = (( int )row ["Flags"] & 16) == 16;
                }

            if (bApproved)
            {
                // Ederon : 7/26/2007
                // send new post notification to users watching this topic/forum
                CreateMail.CreateWatchEmail(nMessageID);
                // redirect to newly posted message
                YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.posts, "m={0}&#post{0}", nMessageID);
            }
            else
            {
                string url = YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.topics, "f={0}", PageContext.PageForumID);
                if (YAF.Classes.Config.IsRainbow)
                {
                    YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.info, "i=1");
                }
                else
                {
                    YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.info, "i=1&url={0}", Server.UrlEncode(url));
                }
            }
        }
Exemple #12
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Mession.UnreadTopics    = 0;
            RssFeed.NavigateUrl     = YAF.Classes.Utils.YafBuildLink.GetLinkNotEscaped(YAF.Classes.Utils.ForumPages.rsstopic, "pg=topics&f={0}", Request.QueryString["f"]);
            RssFeed.Text            = GetText("RSSFEED");
            RssFeed.Visible         = PageContext.BoardSettings.ShowRSSLink;
            MarkRead.Text           = GetText("MARKREAD");
            RSSLinkSpacer.Visible   = PageContext.BoardSettings.ShowRSSLink;
            ForumJumpHolder.Visible = PageContext.BoardSettings.ShowForumJump && PageContext.Settings.LockedForum == 0;

            if (!IsPostBack)
            {
                //PageLinks.Clear();

                if (PageContext.Settings.LockedForum == 0)
                {
                    PageLinks.AddLink(PageContext.BoardSettings.Name, YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.forum));
                    PageLinks.AddLink(PageContext.PageCategoryName, YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.forum, "c={0}", PageContext.PageCategoryID));
                }

                PageLinks.AddForumLinks(PageContext.PageForumID, true);

                ShowList.DataSource     = YafStaticData.TopicTimes( );
                ShowList.DataTextField  = "TopicText";
                ShowList.DataValueField = "TopicValue";
                _showTopicListSelected  = (Mession.ShowList == -1) ? PageContext.BoardSettings.ShowTopicsDefault : Mession.ShowList;

                HandleWatchForum();
            }

            if (Request.QueryString ["f"] == null)
            {
                YafBuildLink.AccessDenied();
            }

            if (!PageContext.ForumReadAccess)
            {
                YafBuildLink.AccessDenied();
            }

            using (DataTable dt = YAF.Classes.Data.DB.forum_list(PageContext.PageBoardID, PageContext.PageForumID))
                _forum = dt.Rows [0];

            if (_forum ["RemoteURL"] != DBNull.Value)
            {
                Response.Clear();
                Response.Redirect(( string )_forum ["RemoteURL"]);
            }

            _forumFlags = new ForumFlags(_forum["Flags"]);

            PageTitle.Text = ( string )_forum ["Name"];

            BindData();                 // Always because of yaf:TopicLine

            if (!PageContext.ForumPostAccess || (_forumFlags.IsLocked && !PageContext.ForumModeratorAccess))
            {
                NewTopic1.Visible = false;
                NewTopic2.Visible = false;
            }

            if (!PageContext.ForumModeratorAccess)
            {
                moderate1.Visible = false;
                moderate2.Visible = false;
            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            _messageRow = null;

            if (Request.QueryString ["m"] != null)
            {
                using (DataTable dt = DB.message_list(Request.QueryString ["m"]))
                {
                    _messageRow = dt.Rows [0];
                }

                if (!PageContext.ForumModeratorAccess && PageContext.PageUserID != ( int )_messageRow ["UserID"])
                {
                    YafBuildLink.AccessDenied();
                }
            }

            _forumFlags         = new ForumFlags(_messageRow ["ForumFlags"]);
            _topicFlags         = new TopicFlags(_messageRow ["TopicFlags"]);
            _ownerUserId        = ( int )_messageRow ["UserID"];
            _isModeratorChanged = (PageContext.PageUserID != _ownerUserId);

            if (PageContext.PageForumID == 0)
            {
                YafBuildLink.AccessDenied();
            }
            if (Request ["t"] == null && !PageContext.ForumPostAccess)
            {
                YafBuildLink.AccessDenied();
            }
            if (Request ["t"] != null && !PageContext.ForumReplyAccess)
            {
                YafBuildLink.AccessDenied();
            }

            if (!IsPostBack)
            {
                // setup page links
                PageLinks.AddLink(PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                PageLinks.AddLink(PageContext.PageCategoryName, YafBuildLink.GetLink(ForumPages.forum, "c={0}", PageContext.PageCategoryID));
                PageLinks.AddForumLinks(PageContext.PageForumID);

                EraseMessage.Checked    = false;
                ViewState ["delAll"]    = false;
                EraseRow.Visible        = false;
                DeleteReasonRow.Visible = false;
                LinkedPosts.Visible     = false;
                ReasonEditor.Attributes.Add("style", "width:100%");
                Cancel.Text = GetText("Cancel");

                if (Request.QueryString ["m"] != null)
                {
                    // delete message...
                    PreviewRow.Visible = true;

                    DataTable tempdb = DB.message_getRepliesList(Request.QueryString ["m"]);

                    if (tempdb.Rows.Count != 0 && (PageContext.ForumModeratorAccess || PageContext.IsAdmin))
                    {
                        LinkedPosts.Visible    = true;
                        LinkedPosts.DataSource = tempdb;
                        LinkedPosts.DataBind();
                    }

                    if (Request.QueryString ["action"].ToLower() == "delete")
                    {
                        Title.Text  = GetText("EDIT");                          //GetText("EDIT");
                        Delete.Text = GetText("DELETE");                        // "GetText("Save");

                        if (PageContext.IsAdmin)
                        {
                            EraseRow.Visible = true;
                        }
                    }
                    else
                    {
                        Title.Text  = GetText("EDIT");
                        Delete.Text = GetText("UNDELETE");                           // "GetText("Save");
                    }

                    Subject.Text            = Convert.ToString(_messageRow ["Topic"]);
                    DeleteReasonRow.Visible = true;
                    ReasonEditor.Text       = Convert.ToString(_messageRow ["DeleteReason"]);

                    // populate the message preview with the message datarow...
                    MessagePreview.Message = _messageRow["message"].ToString();
                    MessagePreview.MessageFlags.BitValue = Convert.ToInt32(_messageRow ["Flags"]);
                }
            }
        }
        /// <summary>
        /// the page load event.
        /// </summary>
        /// <param name="sender">
        /// the sender.
        /// </param>
        /// <param name="e">
        /// the e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (!this.PageContext.BoardSettings.EnableAlbum)
            {
                YafBuildLink.AccessDenied();
            }

            if (!this.IsPostBack)
            {
                DataTable sigData = DB.user_getalbumsdata(this.PageContext.PageUserID, YafContext.Current.PageBoardID);


                var usrAlbumsAllowed =
                    sigData.GetFirstRowColumnAsValue <int?>(
                        "UsrAlbums", null);

                int[] albumSize = DB.album_getstats(this.PageContext.PageUserID, null);
                int   userID;
                switch (this.Request.QueryString.GetFirstOrDefault("a"))
                {
                // A new album is being created. check the permissions.
                case "new":

                    // Is album feature enabled?
                    if (!this.PageContext.BoardSettings.EnableAlbum)
                    {
                        YafBuildLink.AccessDenied();
                    }

                    // Has the user created maximum number of albums?
                    if (usrAlbumsAllowed.HasValue && usrAlbumsAllowed > 0)
                    {
                        // Albums count. If we reached limit then we go to info page.
                        if (usrAlbumsAllowed > 0 &&
                            (albumSize[0] >= usrAlbumsAllowed))
                        {
                            YafBuildLink.RedirectInfoPage(InfoMessage.AccessDenied);
                        }
                    }

                    /* if (this.PageContext.BoardSettings.AlbumsMax > 0 &&
                     *                      albumSize[0] > this.PageContext.BoardSettings.AlbumsMax - 1)
                     *            {
                     *                YafBuildLink.RedirectInfoPage(InfoMessage.AccessDenied);
                     *            }*/
                    userID = this.PageContext.PageUserID;
                    break;

                default:
                    userID =
                        Convert.ToInt32(
                            DB.album_list(null, Security.StringToLongOrRedirect(this.Request.QueryString.GetFirstOrDefault("a"))).
                            Rows[0]["UserID"]);
                    if (userID != this.PageContext.PageUserID)
                    {
                        YafBuildLink.AccessDenied();
                    }

                    break;
                }

                string displayName = UserMembershipHelper.GetDisplayNameFromID(userID);

                // Add the page links.
                this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                this.PageLinks.AddLink(
                    !string.IsNullOrEmpty(displayName) ? displayName : UserMembershipHelper.GetUserNameFromID(userID),
                    YafBuildLink.GetLink(ForumPages.profile, "u={0}", userID.ToString()));
                this.PageLinks.AddLink(
                    this.GetText("ALBUMS"), YafBuildLink.GetLink(ForumPages.albums, "u={0}", userID.ToString()));
                this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty);

                this.Back.Text   = this.GetText("BACK");
                this.Upload.Text = this.GetText("UPLOAD");

                this.BindData();

                var usrAlbumImagesAllowed =
                    sigData.GetFirstRowColumnAsValue <int?>(
                        "UsrAlbumImages", null);
                // Has the user uploaded maximum number of images?
                // vzrus: changed for DB check The default number of album images is 0. In the case albums are disabled.
                if (usrAlbumImagesAllowed.HasValue && usrAlbumImagesAllowed > 0)
                {
                    if (List.Items.Count >= usrAlbumImagesAllowed)
                    {
                        this.uploadtitletr.Visible = false;
                        this.selectfiletr.Visible  = false;
                    }
                    else
                    {
                        this.uploadtitletr.Visible = true;
                        this.selectfiletr.Visible  = true;
                    }

                    this.imagesInfo.Text = this.PageContext.Localization.GetTextFormatted("IMAGES_INFO",
                                                                                          List.Items.Count, usrAlbumImagesAllowed);
                }
                else
                {
                    this.uploadtitletr.Visible = false;
                    this.selectfiletr.Visible  = false;
                }
            }
        }
Exemple #15
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            YafContext.Current.Get <YafSession>().UnreadTopics = 0;
            this.AtomFeed.AdditionalParameters = "f={0}".FormatWith(this.Request.QueryString.GetFirstOrDefault("f"));
            this.RssFeed.AdditionalParameters  = "f={0}".FormatWith(this.Request.QueryString.GetFirstOrDefault("f"));
            this.MarkRead.Text           = GetText("MARKREAD");
            this.ForumJumpHolder.Visible = PageContext.BoardSettings.ShowForumJump && PageContext.Settings.LockedForum == 0;
            this.lastPostImageTT         = this.PageContext.Localization.GetText("DEFAULT", "GO_LAST_POST");

            if (!IsPostBack)
            {
                // PageLinks.Clear();
                if (PageContext.Settings.LockedForum == 0)
                {
                    this.PageLinks.AddLink(PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                    this.PageLinks.AddLink(PageContext.PageCategoryName, YafBuildLink.GetLink(ForumPages.forum, "c={0}", PageContext.PageCategoryID));
                }

                this.PageLinks.AddForumLinks(PageContext.PageForumID, true);

                this.ShowList.DataSource     = StaticDataHelper.TopicTimes();
                this.ShowList.DataTextField  = "TopicText";
                this.ShowList.DataValueField = "TopicValue";
                this._showTopicListSelected  = (YafContext.Current.Get <YafSession>().ShowList == -1) ? PageContext.BoardSettings.ShowTopicsDefault : YafContext.Current.Get <YafSession>().ShowList;

                HandleWatchForum();
            }

            if (Request.QueryString.GetFirstOrDefault("f") == null)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.PageContext.IsGuest && !this.PageContext.ForumReadAccess)
            {
                // attempt to get permission by redirecting to login...
                this.Get <YafPermissions>().HandleRequest(ViewPermissions.RegisteredUsers);
            }
            else if (!this.PageContext.ForumReadAccess)
            {
                YafBuildLink.AccessDenied();
            }

            using (DataTable dt = DB.forum_list(PageContext.PageBoardID, PageContext.PageForumID))
            {
                this._forum = dt.Rows[0];
            }

            if (this._forum["RemoteURL"] != DBNull.Value)
            {
                Response.Clear();
                Response.Redirect((string)this._forum["RemoteURL"]);
            }

            this._forumFlags = new ForumFlags(this._forum["Flags"]);

            this.PageTitle.Text = HtmlEncode((string)this._forum["Name"]);

            BindData(); // Always because of yaf:TopicLine

            if (!PageContext.ForumPostAccess || (this._forumFlags.IsLocked && !PageContext.ForumModeratorAccess))
            {
                this.NewTopic1.Visible = false;
                this.NewTopic2.Visible = false;
            }

            if (!PageContext.ForumModeratorAccess)
            {
                this.moderate1.Visible = false;
                this.moderate2.Visible = false;
            }
        }
Exemple #16
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            using (DataTable dt = LegacyDb.forum_list(this.PageContext.PageBoardID, this.PageContext.PageForumID))
            {
                this._forum = dt.Rows[0];
            }

            this._topic = LegacyDb.topic_info(this.PageContext.PageTopicID);

            if (this.IsPostBack)
            {
                return;
            }

            if (!this.PageContext.ForumModeratorAccess && !this.PageContext.ForumUploadAccess)
            {
                YafBuildLink.AccessDenied();
            }

            if (!this.PageContext.ForumReadAccess)
            {
                YafBuildLink.AccessDenied();
            }

            // Ederon : 9/9/2007 - moderaotrs can attach in locked posts
            if (this._topic["Flags"].BinaryAnd(TopicFlags.Flags.IsLocked) && !this.PageContext.ForumModeratorAccess)
            {
                YafBuildLink.AccessDenied(/*"The topic is closed."*/);
            }

            if (this._forum["Flags"].BinaryAnd(ForumFlags.Flags.IsLocked))
            {
                YafBuildLink.AccessDenied(/*"The forum is closed."*/);
            }

            // Check that non-moderators only edit messages they have written
            if (!this.PageContext.ForumModeratorAccess)
            {
                using (DataTable dt = LegacyDb.message_list(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("m")))
                {
                    if ((int)dt.Rows[0]["UserID"] != this.PageContext.PageUserID)
                    {
                        YafBuildLink.AccessDenied(/*"You didn't post this message."*/);
                    }
                }
            }

            if (this.PageContext.Settings.LockedForum == 0)
            {
                this.PageLinks.AddLink(this.Get <YafBoardSettings>().Name, YafBuildLink.GetLink(ForumPages.forum));
                this.PageLinks.AddLink(
                    this.PageContext.PageCategoryName,
                    YafBuildLink.GetLink(ForumPages.forum, "c={0}", this.PageContext.PageCategoryID));
            }

            this.PageLinks.AddForumLinks(this.PageContext.PageForumID);
            this.PageLinks.AddLink(
                this.PageContext.PageTopicName, YafBuildLink.GetLink(ForumPages.posts, "t={0}", this.PageContext.PageTopicID));
            this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty);

            this.Back.Text = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("t").IsNotSet()
                                 ? this.GetText("BACK")
                                 : this.GetText("COMMON", "CONTINUE");

            this.Upload.Text = this.GetText("UPLOAD");

            // MJ : 10/14/2007 - list of allowed file extensions
            DataTable extensionTable = this.GetRepository <FileExtension>().List();

            string types  = string.Empty;
            bool   bFirst = true;

            foreach (DataRow row in extensionTable.Rows)
            {
                types += "{1}*.{0}".FormatWith(row["Extension"].ToString(), bFirst ? string.Empty : ", ");
                if (bFirst)
                {
                    bFirst = false;
                }
            }

            if (types.IsSet())
            {
                this.ExtensionsList.Text = types;
            }

            if (this.Get <YafBoardSettings>().MaxFileSize > 0)
            {
                this.UploadNodePlaceHold.Visible = true;
                this.UploadNote.Text             = this.GetTextFormatted(
                    "UPLOAD_NOTE", (this.Get <YafBoardSettings>().MaxFileSize / 1024).ToString());
            }
            else
            {
                this.UploadNodePlaceHold.Visible = false;
            }

            this.BindData();
        }
Exemple #17
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="EventArgs" /> instance containing the event data.</param>
        private void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (Config.IsDotNetNuke)
            {
                // Not accessbile...
                YafBuildLink.AccessDenied();
            }

            if (!this.Get <YafBoardSettings>().AllowPasswordChange &&
                !(this.PageContext.IsAdmin || this.PageContext.IsForumModerator))
            {
                // Not accessbile...
                YafBuildLink.AccessDenied();
            }

            if (!this.IsPostBack)
            {
                this.PageLinks.AddRoot();
                this.PageLinks.AddLink(
                    this.Get <YafBoardSettings>().EnableDisplayName
                        ? this.PageContext.CurrentUserData.DisplayName
                        : this.PageContext.PageUserName,
                    YafBuildLink.GetLink(ForumPages.cp_profile));
                this.PageLinks.AddLink(this.GetText("TITLE"));
            }

            var oldPasswordRequired =
                this.ChangePassword1.ChangePasswordTemplateContainer.FindControlAs <RequiredFieldValidator>(
                    "CurrentPasswordRequired");
            var newPasswordRequired =
                this.ChangePassword1.ChangePasswordTemplateContainer.FindControlAs <RequiredFieldValidator>(
                    "NewPasswordRequired");
            var confirmNewPasswordRequired =
                this.ChangePassword1.ChangePasswordTemplateContainer.FindControlAs <RequiredFieldValidator>(
                    "ConfirmNewPasswordRequired");
            var passwordsEqual =
                this.ChangePassword1.ChangePasswordTemplateContainer.FindControlAs <CompareValidator>(
                    "NewPasswordCompare");
            var passwordsNotEqual =
                this.ChangePassword1.ChangePasswordTemplateContainer.FindControlAs <CompareValidator>(
                    "NewOldPasswordCompare");

            oldPasswordRequired.ToolTip                 = oldPasswordRequired.ErrorMessage = this.GetText("NEED_OLD_PASSWORD");
            newPasswordRequired.ToolTip                 = newPasswordRequired.ErrorMessage = this.GetText("NEED_NEW_PASSWORD");
            confirmNewPasswordRequired.ToolTip          =
                confirmNewPasswordRequired.ErrorMessage = this.GetText("NEED_NEW_CONFIRM_PASSWORD");
            passwordsEqual.ToolTip    = passwordsEqual.ErrorMessage = this.GetText("NO_PASSWORD_MATCH");
            passwordsNotEqual.ToolTip = passwordsNotEqual.ErrorMessage = this.GetText("PASSWORD_NOT_NEW");

            var changeButton =
                (this.ChangePassword1.ChangePasswordTemplateContainer.FindControlAs <Button>("ChangePasswordPushButton"));

            changeButton.Text = this.GetText("CHANGE_BUTTON");
            (this.ChangePassword1.ChangePasswordTemplateContainer.FindControlAs <Button>("CancelPushButton")).Text =
                this.GetText("CANCEL");
            (this.ChangePassword1.SuccessTemplateContainer.FindControlAs <Button>("ContinuePushButton")).Text =
                this.GetText("CONTINUE");

            // make failure text...
            // 1. Password incorrect or New Password invalid.
            // 2. New Password length minimum: {0}.t
            // 3. Non-alphanumeric characters required: {1}.
            var failureText = this.GetText("PASSWORD_INCORRECT");

            failureText += "<br />{0}".FormatWith(this.GetText("PASSWORD_BAD_LENGTH"));
            failureText += "<br />{0}".FormatWith(this.GetText("PASSWORD_NOT_COMPLEX"));

            this.ChangePassword1.ChangePasswordFailureText = failureText;

            var currentPassword =
                this.ChangePassword1.ChangePasswordTemplateContainer.FindControlAs <TextBox>("CurrentPassword");
            var newPassword        = this.ChangePassword1.ChangePasswordTemplateContainer.FindControlAs <TextBox>("NewPassword");
            var confirmNewPassword =
                this.ChangePassword1.ChangePasswordTemplateContainer.FindControlAs <TextBox>("ConfirmNewPassword");

            currentPassword.Attributes.Add("onKeyPress", "doClick('{0}',event)".FormatWith(changeButton.ClientID));

            newPassword.Attributes.Add("onKeyPress", "doClick('{0}',event)".FormatWith(changeButton.ClientID));

            confirmNewPassword.Attributes.Add("onKeyPress", "doClick('{0}',event)".FormatWith(changeButton.ClientID));

            this.DataBind();
        }
Exemple #18
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            _quickReplyEditor.BaseDir    = YafForumInfo.ForumRoot + "editors";
            _quickReplyEditor.StyleSheet = YafBuildLink.ThemeFile("theme.css");

            _topic = YAF.Classes.Data.DB.topic_info(PageContext.PageTopicID);

            // in case topic is deleted or not existant
            if (_topic == null)
            {
                YafBuildLink.Redirect(ForumPages.info, "i=6");                  // invalid argument message
            }
            // get topic flags
            _topicFlags = new TopicFlags(_topic["Flags"]);

            using (DataTable dt = YAF.Classes.Data.DB.forum_list(PageContext.PageBoardID, PageContext.PageForumID))
                _forum = dt.Rows [0];

            _forumFlags = new ForumFlags(_forum["Flags"]);

            if (!PageContext.ForumReadAccess)
            {
                YafBuildLink.AccessDenied();
            }

            #region Initial Setup
            if (!IsPostBack)
            {
                if (PageContext.Settings.LockedForum == 0)
                {
                    PageLinks.AddLink(PageContext.BoardSettings.Name, YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.forum));
                    PageLinks.AddLink(PageContext.PageCategoryName, YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.forum, "c={0}", PageContext.PageCategoryID));
                }

                QuickReply.Text         = GetText("POSTMESSAGE", "SAVE");
                DataPanel1.TitleText    = GetText("QUICKREPLY");
                DataPanel1.ExpandText   = GetText("QUICKREPLY_SHOW");
                DataPanel1.CollapseText = GetText("QUICKREPLY_HIDE");

                PageLinks.AddForumLinks(PageContext.PageForumID);
                PageLinks.AddLink(General.BadWordReplace(Server.HtmlDecode(PageContext.PageTopicName)), "");

                TopicTitle.Text = General.BadWordReplace(( string )_topic ["Topic"]);

                ViewOptions.Visible     = PageContext.BoardSettings.AllowThreaded;
                ForumJumpHolder.Visible = PageContext.BoardSettings.ShowForumJump && PageContext.Settings.LockedForum == 0;

                RssTopic.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLinkNotEscaped(YAF.Classes.Utils.ForumPages.rsstopic, "pg={0}&t={1}", Request.QueryString ["g"], PageContext.PageTopicID);
                RssTopic.Visible     = PageContext.BoardSettings.ShowRSSLink;

                QuickReplyPlaceHolder.Visible = PageContext.BoardSettings.ShowQuickAnswer;

                if ((PageContext.IsGuest && PageContext.BoardSettings.EnableCaptchaForGuests) ||
                    (PageContext.BoardSettings.EnableCaptchaForPost && !PageContext.IsCaptchaExcluded))
                {
                    Session ["CaptchaImageText"] = General.GetCaptchaString();
                    imgCaptcha.ImageUrl          = String.Format("{0}resource.ashx?c=1", YafForumInfo.ForumRoot);
                    CaptchaDiv.Visible           = true;
                }

                if (!PageContext.ForumPostAccess || (_forumFlags.IsLocked && !PageContext.ForumModeratorAccess))
                {
                    NewTopic1.Visible = false;
                    NewTopic2.Visible = false;
                }

                // Ederon : 9/9/2007 - moderators can relpy in locked topics
                if (!PageContext.ForumReplyAccess ||
                    ((_topicFlags.IsLocked || _forumFlags.IsLocked) && !PageContext.ForumModeratorAccess))
                {
                    PostReplyLink1.Visible        = PostReplyLink2.Visible = false;
                    QuickReplyPlaceHolder.Visible = false;
                }

                if (PageContext.ForumModeratorAccess)
                {
                    MoveTopic1.Visible = true;
                    MoveTopic2.Visible = true;
                }
                else
                {
                    MoveTopic1.Visible = false;
                    MoveTopic2.Visible = false;
                }

                if (!PageContext.ForumModeratorAccess)
                {
                    LockTopic1.Visible   = false;
                    UnlockTopic1.Visible = false;
                    DeleteTopic1.Visible = false;
                    LockTopic2.Visible   = false;
                    UnlockTopic2.Visible = false;
                    DeleteTopic2.Visible = false;
                }
                else
                {
                    LockTopic1.Visible   = !_topicFlags.IsLocked;
                    UnlockTopic1.Visible = !LockTopic1.Visible;
                    LockTopic2.Visible   = LockTopic1.Visible;
                    UnlockTopic2.Visible = !LockTopic2.Visible;
                }

                // handle custom BBCode javascript or CSS...
                BBCode.RegisterCustomBBCodePageElements(Page, this.GetType());
            }
            #endregion

            // Mark topic read
            Mession.SetTopicRead(PageContext.PageTopicID, DateTime.Now);

            BindData();
        }
Exemple #19
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            // Put user code to initialize the page here
            if (!(this.Get <YafBoardSettings>().ShowRSSLink || this.Get <YafBoardSettings>().ShowAtomLink))
            {
                YafBuildLink.RedirectInfoPage(InfoMessage.AccessDenied);
            }

            // Atom feed as variable
            var atomFeedByVar = this.Request.QueryString.GetFirstOrDefault("ft")
                                == YafSyndicationFormats.Atom.ToInt().ToString();

            YafSyndicationFeed feed = null;

            // var syndicationItems = new List<SyndicationItem>();
            var lastPostIcon = BaseUrlBuilder.BaseUrl
                               + this.PageContext.CurrentForumPage.GetThemeContents("ICONS", "ICON_NEWEST");
            var lastPostName = this.GetText("DEFAULT", "GO_LAST_POST");

            YafRssFeeds feedType;

            try
            {
                feedType = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("pg").ToEnum <YafRssFeeds>(true);
            }
            catch
            {
                // default to Forum Feed.
                feedType = YafRssFeeds.Forum;
            }

            switch (feedType)
            {
            // Latest posts feed
            case YafRssFeeds.LatestPosts:
                if (
                    !(this.Get <YafBoardSettings>().ShowActiveDiscussions &&
                      this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().PostLatestFeedAccess)))
                {
                    YafBuildLink.AccessDenied();
                }

                this.GetPostLatestFeed(ref feed, feedType, atomFeedByVar, lastPostIcon, lastPostName);
                break;

            // Latest Announcements feed
            case YafRssFeeds.LatestAnnouncements:
                if (!this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().ForumFeedAccess))
                {
                    YafBuildLink.AccessDenied();
                }

                this.GetLatestAnnouncementsFeed(ref feed, feedType, atomFeedByVar);
                break;

            // Posts Feed
            case YafRssFeeds.Posts:
                if (
                    !(this.PageContext.ForumReadAccess &&
                      this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().PostsFeedAccess)))
                {
                    YafBuildLink.AccessDenied();
                }

                if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("t") != null)
                {
                    int topicId;
                    if (int.TryParse(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("t"), out topicId))
                    {
                        this.GetPostsFeed(ref feed, feedType, atomFeedByVar, topicId);
                    }
                }

                break;

            // Forum Feed
            case YafRssFeeds.Forum:
                if (!this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().ForumFeedAccess))
                {
                    YafBuildLink.AccessDenied();
                }

                object categoryId = null;

                if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("c") != null)
                {
                    int icategoryId;
                    if (int.TryParse(
                            this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("c"), out icategoryId))
                    {
                        categoryId = icategoryId;
                    }
                }

                this.GetForumFeed(ref feed, feedType, atomFeedByVar, categoryId);
                break;

            // Topics Feed
            case YafRssFeeds.Topics:
                if (
                    !(this.PageContext.ForumReadAccess &&
                      this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().TopicsFeedAccess)))
                {
                    YafBuildLink.AccessDenied();
                }

                if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("f") != null)
                {
                    int forumId;
                    if (int.TryParse(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("f"), out forumId))
                    {
                        this.GetTopicsFeed(ref feed, feedType, atomFeedByVar, lastPostIcon, lastPostName, forumId);
                    }
                }

                break;

            // Active Topics
            case YafRssFeeds.Active:
                if (!this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().ActiveTopicFeedAccess))
                {
                    YafBuildLink.AccessDenied();
                }

                int    categoryActiveIntId;
                object categoryActiveId = null;
                if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("f") != null
                    &&
                    int.TryParse(
                        this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("f"), out categoryActiveIntId))
                {
                    categoryActiveId = categoryActiveIntId;
                }

                this.GetActiveFeed(ref feed, feedType, atomFeedByVar, lastPostIcon, lastPostName, categoryActiveId);

                break;

            case YafRssFeeds.Favorite:
                if (!this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().FavoriteTopicFeedAccess))
                {
                    YafBuildLink.AccessDenied();
                }

                int    categoryFavIntId;
                object categoryFavId = null;
                if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("f") != null
                    &&
                    int.TryParse(
                        this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("f"), out categoryFavIntId))
                {
                    categoryFavId = categoryFavIntId;
                }

                this.GetFavoriteFeed(ref feed, feedType, atomFeedByVar, lastPostIcon, lastPostName, categoryFavId);
                break;

            default:
                YafBuildLink.AccessDenied();
                break;
            }

            // update the feed with the item list...
            // the list should be added after all other feed properties are set
            if (feed != null)
            {
                var writer = new XmlTextWriter(this.Response.OutputStream, Encoding.UTF8);
                writer.WriteStartDocument();

                // write the feed to the response writer);
                if (!atomFeedByVar)
                {
                    var rssFormatter = new Rss20FeedFormatter(feed);
                    rssFormatter.WriteTo(writer);
                    this.Response.ContentType = "application/rss+xml";
                }
                else
                {
                    var atomFormatter = new Atom10FeedFormatter(feed);
                    atomFormatter.WriteTo(writer);

                    this.Response.ContentType = "application/atom+xml";
                }

                writer.WriteEndDocument();
                writer.Close();

                this.Response.ContentEncoding = Encoding.UTF8;
                this.Response.Cache.SetCacheability(HttpCacheability.Public);

                this.Response.End();
            }
            else
            {
                YafBuildLink.RedirectInfoPage(InfoMessage.AccessDenied);
            }
        }
Exemple #20
0
        private void BindData()
        {
            int userID = ( int )Security.StringToLongOrRedirect(Request.QueryString ["u"]);

            MembershipUser user = UserMembershipHelper.GetMembershipUser(userID);

            if (user == null)
            {
                YafBuildLink.AccessDenied(/*No such user exists*/);
            }

            YafCombinedUserData userData = new YafCombinedUserData(user, userID);

            // populate user information controls...
            UserName.Text        = HtmlEncode(userData.Membership.UserName);
            Name.Text            = HtmlEncode(userData.Membership.UserName);
            Joined.Text          = String.Format("{0}", YafDateTime.FormatDateLong(Convert.ToDateTime(userData.Joined)));
            LastVisit.Text       = YafDateTime.FormatDateTime(userData.LastVisit);
            Rank.Text            = userData.RankName;
            Location.Text        = HtmlEncode(General.BadWordReplace(userData.Profile.Location));
            RealName.InnerHtml   = HtmlEncode(General.BadWordReplace(userData.Profile.RealName));
            Interests.InnerHtml  = HtmlEncode(General.BadWordReplace(userData.Profile.Interests));
            Occupation.InnerHtml = HtmlEncode(General.BadWordReplace(userData.Profile.Occupation));
            Gender.InnerText     = GetText("GENDER" + userData.Profile.Gender);

            PageLinks.Clear();
            PageLinks.AddLink(PageContext.BoardSettings.Name, YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.forum));
            PageLinks.AddLink(GetText("MEMBERS"), YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.members));
            PageLinks.AddLink(userData.Membership.UserName, "");

            double dAllPosts = 0.0;

            if (SqlDataLayerConverter.VerifyInt32(userData.DBRow["NumPostsForum"]) > 0)
            {
                dAllPosts = 100.0 * SqlDataLayerConverter.VerifyInt32(userData.DBRow["NumPosts"]) / SqlDataLayerConverter.VerifyInt32(userData.DBRow["NumPostsForum"]);
            }

            Stats.InnerHtml = String.Format("{0:N0}<br/>[{1} / {2}]",
                                            userData.DBRow ["NumPosts"],
                                            String.Format(GetText("NUMALL"), dAllPosts),
                                            String.Format(GetText("NUMDAY"), (double)SqlDataLayerConverter.VerifyInt32(userData.DBRow["NumPosts"]) / SqlDataLayerConverter.VerifyInt32(userData.DBRow["NumDays"]))
                                            );

            // private messages
            ///CHANGED THIS ON 12/1/2010
            //PM.Visible = !userData.IsGuest && User != null && PageContext.BoardSettings.AllowPrivateMessages;
            PM.Visible = false;

            PM.NavigateUrl = YafBuildLink.GetLinkNotEscaped(YAF.Classes.Utils.ForumPages.pmessage, "u={0}", userData.UserID);

            // email link
            Email.Visible     = !userData.IsGuest && User != null && PageContext.BoardSettings.AllowEmailSending;
            Email.NavigateUrl = YafBuildLink.GetLinkNotEscaped(YAF.Classes.Utils.ForumPages.im_email, "u={0}", userData.UserID);
            if (PageContext.IsAdmin)
            {
                Email.TitleNonLocalized = userData.Membership.Email;
            }

            // homepage link
            Home.Visible = !String.IsNullOrEmpty(userData.Profile.Homepage);
            SetupThemeButtonWithLink(Home, userData.Profile.Homepage);

            // blog link
            Blog.Visible = !String.IsNullOrEmpty(userData.Profile.Blog);
            SetupThemeButtonWithLink(Blog, userData.Profile.Blog);

            MSN.Visible     = (User != null && !String.IsNullOrEmpty(userData.Profile.MSN));
            MSN.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.im_email, "u={0}", userData.UserID);

            YIM.Visible     = (User != null && !String.IsNullOrEmpty(userData.Profile.YIM));
            YIM.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.im_yim, "u={0}", userData.UserID);

            AIM.Visible     = (User != null && !String.IsNullOrEmpty(userData.Profile.AIM));
            AIM.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.im_aim, "u={0}", userData.UserID);

            ICQ.Visible     = (User != null && !String.IsNullOrEmpty(userData.Profile.ICQ));
            ICQ.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.im_icq, "u={0}", userData.UserID);

            Skype.Visible     = (User != null && !String.IsNullOrEmpty(userData.Profile.Skype));
            Skype.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.im_skype, "u={0}", userData.UserID);

            // localize tab titles...
            AboutTab.HeaderText       = GetText("ABOUT");
            StatisticsTab.HeaderText  = GetText("STATISTICS");
            AvatarTab.HeaderText      = GetText("AVATAR");
            Last10PostsTab.HeaderText = GetText("LAST10");

            if (PageContext.BoardSettings.AvatarUpload && userData.HasAvatarImage)
            {
                Avatar.ImageUrl = YafForumInfo.ForumRoot + "resource.ashx?u=" + (userID);
            }
            else if (!String.IsNullOrEmpty(userData.Avatar))                 // Took out PageContext.BoardSettings.AvatarRemote
            {
                Avatar.ImageUrl = String.Format("{3}resource.ashx?url={0}&width={1}&height={2}",
                                                Server.UrlEncode(userData.Avatar),
                                                PageContext.BoardSettings.AvatarWidth,
                                                PageContext.BoardSettings.AvatarHeight,
                                                YafForumInfo.ForumRoot);
            }
            else
            {
                Avatar.Visible    = false;
                AvatarTab.Visible = false;
            }

            Groups.DataSource = Roles.GetRolesForUser(UserMembershipHelper.GetUserNameFromID(userID));

            //EmailRow.Visible = PageContext.IsAdmin;
            ModerateTab.Visible     = PageContext.IsAdmin || PageContext.IsForumModerator;
            AdminUserButton.Visible = PageContext.IsAdmin;

            if (LastPosts.Visible)
            {
                LastPosts.DataSource   = YAF.Classes.Data.DB.post_last10user(PageContext.PageBoardID, Request.QueryString ["u"], PageContext.PageUserID);
                SearchUser.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLinkNotEscaped(YAF.Classes.Utils.ForumPages.search,
                                                                                          "postedby={0}",
                                                                                          userData.Membership.UserName);
            }

            DataBind();
        }
Exemple #21
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="EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            // if user isn't authenticated, redirect him to login page
            if (this.User == null || YafContext.Current.IsGuest)
            {
                this.RedirectNoAccess();
            }

            // set attributes of editor
            this._editor.BaseDir    = YafForumInfo.ForumClientFileRoot + "editors";
            this._editor.StyleSheet = this.Get <ITheme>().BuildThemePath("theme.css");

            // this needs to be done just once, not during postbacks
            if (this.IsPostBack)
            {
                return;
            }

            // create page links
            this.CreatePageLinks();

            // localize button labels
            this.FindUsers.Text  = this.GetText("FINDUSERS");
            this.AllUsers.Text   = this.GetText("ALLUSERS");
            this.AllBuddies.Text = this.GetText("ALLBUDDIES");
            this.Clear.Text      = this.GetText("CLEAR");

            // only administrators can send messages to all users
            this.AllUsers.Visible = YafContext.Current.IsAdmin;

            this.AllBuddies.Visible = this.PageContext.UserHasBuddies;

            // Is Reply
            if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("p").IsSet())
            {
                // PM is a reply or quoted reply (isQuoting)
                // to the given message id "p"
                bool isQuoting = this.Request.QueryString.GetFirstOrDefault("q") == "1";

                // get quoted message
                DataRow row =
                    LegacyDb.pmessage_list(
                        Security.StringToLongOrRedirect(this.Request.QueryString.GetFirstOrDefault("p"))).GetFirstRow();

                // there is such a message
                if (row == null)
                {
                    return;
                }

                // get message sender/recipient
                var toUserId   = row["ToUserID"].ToType <int>();
                var fromUserId = row["FromUserID"].ToType <int>();

                // verify access to this PM
                if (toUserId != YafContext.Current.PageUserID && fromUserId != YafContext.Current.PageUserID)
                {
                    YafBuildLink.AccessDenied();
                }

                // handle subject
                var subject = row["Subject"].ToType <string>();
                if (!subject.StartsWith("Re: "))
                {
                    subject = "Re: {0}".FormatWith(subject);
                }

                this.PmSubjectTextBox.Text = subject;

                string displayName = this.Get <IUserDisplayName>().GetName(fromUserId);

                // set "To" user and disable changing...
                this.To.Text            = displayName;
                this.To.Enabled         = false;
                this.FindUsers.Enabled  = false;
                this.AllUsers.Enabled   = false;
                this.AllBuddies.Enabled = false;

                if (!isQuoting)
                {
                    return;
                }

                // PM is a quoted reply
                string body = row["Body"].ToString();

                if (this.Get <YafBoardSettings>().RemoveNestedQuotes)
                {
                    body = this.Get <IFormatMessage>().RemoveNestedQuotes(body);
                }

                // Ensure quoted replies have bad words removed from them
                body = this.Get <IBadWordReplace>().Replace(body);

                // Quote the original message
                body = "[QUOTE={0}]{1}[/QUOTE]".FormatWith(displayName, body);

                // we don't want any whitespaces at the beginning of message
                this._editor.Text = body.TrimStart();
            }
            else if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("u").IsSet() &&
                     this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("r").IsSet())
            {
                // We check here if the user have access to the option
                if (!this.PageContext.IsModeratorInAnyForum && !this.PageContext.IsForumModerator)
                {
                    return;
                }

                // PM is being sent to a predefined user
                int toUser;
                int reportMessage;

                if (!int.TryParse(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("u"), out toUser) ||
                    !int.TryParse(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("r"), out reportMessage))
                {
                    return;
                }

                // get quoted message
                DataRow messagesRow =
                    LegacyDb.message_listreporters(
                        Security.StringToLongOrRedirect(
                            this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("r")).ToType <int>(),
                        Security.StringToLongOrRedirect(
                            this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("u")).ToType <int>())
                    .GetFirstRow();

                // there is such a message
                // message info should be always returned as 1 row
                if (messagesRow == null)
                {
                    return;
                }

                // handle subject
                this.PmSubjectTextBox.Text = this.GetText("REPORTED_SUBJECT");

                string displayName =
                    this.Get <IUserDisplayName>().GetName(messagesRow.Field <int>("UserID"));

                // set "To" user and disable changing...
                this.To.Text            = displayName;
                this.To.Enabled         = false;
                this.FindUsers.Enabled  = false;
                this.AllUsers.Enabled   = false;
                this.AllBuddies.Enabled = false;

                // Parse content with delimiter '|'
                string[] quoteList = messagesRow.Field <string>("ReportText").Split('|');

                // Quoted replies should have bad words in them
                // Reply to report PM is always a quoted reply
                // Quote the original message in a cycle
                for (int i = 0; i < quoteList.Length; i++)
                {
                    // Add quote codes
                    quoteList[i] = "[QUOTE={0}]{1}[/QUOTE]".FormatWith(displayName, quoteList[i]);

                    // Replace DateTime delimiter '??' by ': '
                    // we don't want any whitespaces at the beginning of message
                    this._editor.Text = quoteList[i].Replace("??", ": ") + this._editor.Text.TrimStart();
                }
            }
            else if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("u").IsSet())
            {
                // PM is being send as a reply to a reported post

                // find user
                int toUserId;

                if (!int.TryParse(this.Request.QueryString.GetFirstOrDefault("u"), out toUserId))
                {
                    return;
                }

                DataRow currentRow =
                    LegacyDb.user_list(YafContext.Current.PageBoardID, toUserId, true).GetFirstRow();

                if (currentRow == null)
                {
                    return;
                }

                this.To.Text    = this.Get <IUserDisplayName>().GetName(currentRow.Field <int>("UserID"));
                this.To.Enabled = false;

                // hide find user/all users buttons
                this.FindUsers.Enabled  = false;
                this.AllUsers.Enabled   = false;
                this.AllBuddies.Enabled = false;
            }
            else
            {
                // Blank PM

                // multi-receiver info is relevant only when sending blank PM
                if (this.Get <YafBoardSettings>().PrivateMessageMaxRecipients <= 1)
                {
                    return;
                }

                // format localized string
                this.MultiReceiverInfo.Text =
                    "<br />{0}<br />{1}".FormatWith(
                        this.GetText("MAX_RECIPIENT_INFO")
                        .FormatWith(this.Get <YafBoardSettings>().PrivateMessageMaxRecipients),
                        this.GetText("MULTI_RECEIVER_INFO"));

                // display info
                this.MultiReceiverInfo.Visible = true;
            }
        }
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            this._messageRow = null;

            if (this.Request.QueryString.GetFirstOrDefault("m") != null)
            {
                this._messageRow =
                    DBHelper.GetFirstRowOrInvalid(DB.message_list(Security.StringToLongOrRedirect(this.Request.QueryString.GetFirstOrDefault("m"))));

                if (!this.PageContext.ForumModeratorAccess && this.PageContext.PageUserID != (int)this._messageRow["UserID"])
                {
                    YafBuildLink.AccessDenied();
                }
            }

            this._forumFlags         = new ForumFlags(this._messageRow["ForumFlags"]);
            this._topicFlags         = new TopicFlags(this._messageRow["TopicFlags"]);
            this._ownerUserId        = (int)this._messageRow["UserID"];
            this._isModeratorChanged = this.PageContext.PageUserID != this._ownerUserId;

            if (this.PageContext.PageForumID == 0)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.Request["t"] == null && !this.PageContext.ForumPostAccess)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.Request["t"] != null && !this.PageContext.ForumReplyAccess)
            {
                YafBuildLink.AccessDenied();
            }

            if (!this.IsPostBack)
            {
                // setup page links
                this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                this.PageLinks.AddLink(
                    this.PageContext.PageCategoryName,
                    YafBuildLink.GetLink(ForumPages.forum, "c={0}", this.PageContext.PageCategoryID));
                this.PageLinks.AddForumLinks(this.PageContext.PageForumID);

                this.EraseMessage.Checked    = false;
                this.ViewState["delAll"]     = false;
                this.EraseRow.Visible        = false;
                this.DeleteReasonRow.Visible = false;
                this.LinkedPosts.Visible     = false;
                this.ReasonEditor.Attributes.Add("style", "width:100%");
                this.Cancel.Text = this.GetText("Cancel");

                if (this.Request.QueryString.GetFirstOrDefault("m") != null)
                {
                    // delete message...
                    this.PreviewRow.Visible = true;

                    DataTable tempdb = DB.message_getRepliesList(this.Request.QueryString.GetFirstOrDefault("m"));

                    if (tempdb.Rows.Count != 0 && (this.PageContext.ForumModeratorAccess || this.PageContext.IsAdmin))
                    {
                        this.LinkedPosts.Visible    = true;
                        this.LinkedPosts.DataSource = tempdb;
                        this.LinkedPosts.DataBind();
                    }

                    if (this.Request.QueryString.GetFirstOrDefault("action").ToLower() == "delete")
                    {
                        this.Title.Text  = this.GetText("EDIT");   // GetText("EDIT");
                        this.Delete.Text = this.GetText("DELETE"); // "GetText("Save");

                        if (this.PageContext.IsAdmin)
                        {
                            this.EraseRow.Visible = true;
                        }
                    }
                    else
                    {
                        this.Title.Text  = this.GetText("EDIT");
                        this.Delete.Text = this.GetText("UNDELETE"); // "GetText("Save");
                    }

                    this.Subject.Text            = Convert.ToString(this._messageRow["Topic"]);
                    this.DeleteReasonRow.Visible = true;
                    this.ReasonEditor.Text       = Convert.ToString(this._messageRow["DeleteReason"]);

                    // populate the message preview with the message datarow...
                    this.MessagePreview.Message      = this._messageRow["message"].ToString();
                    this.MessagePreview.MessageFlags = new MessageFlags(this._messageRow["Flags"]);
                }
            }
        }
Exemple #23
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (!this.PageContext.IsGuest)
            {
                // Register Ajax Pro.
                Utility.RegisterTypeForAjax(typeof(YafFavoriteTopic));

                // The html code for "Favorite Topic" theme buttons.
                string tagButtonHTML =
                    "'<a class=\"yafcssbigbutton rightItem\" href=\"javascript:addFavoriteTopic(' + res.value + ');\" onclick=\"blur();\" title=\"{0}\"><span>{1}</span></a>'"
                    .FormatWith(
                        this.PageContext.Localization.GetText("BUTTON_TAGFAVORITE_TT"),
                        this.PageContext.Localization.GetText("BUTTON_TAGFAVORITE"));
                string untagButtonHTML =
                    "'<a class=\"yafcssbigbutton rightItem\" href=\"javascript:removeFavoriteTopic(' + res.value + ');\" onclick=\"blur();\" title=\"{0}\"><span>{1}</span></a>'"
                    .FormatWith(
                        this.PageContext.Localization.GetText("BUTTON_UNTAGFAVORITE_TT"),
                        this.PageContext.Localization.GetText("BUTTON_UNTAGFAVORITE"));

                // Register the client side script for the "Favorite Topic".
                YafContext.Current.PageElements.RegisterJsBlockStartup(
                    "addFavoriteTopicJs", JavaScriptBlocks.addFavoriteTopicJs(untagButtonHTML));
                YafContext.Current.PageElements.RegisterJsBlockStartup(
                    "removeFavoriteTopicJs", JavaScriptBlocks.removeFavoriteTopicJs(tagButtonHTML));
                YafContext.Current.PageElements.RegisterJsBlockStartup(
                    "asynchCallFailedJs", JavaScriptBlocks.asynchCallFailedJs);

                // Has the user already tagged this topic as favorite?
                if (this.Get <YafFavoriteTopic>().IsFavoriteTopic(this.PageContext.PageTopicID))
                {
                    // Generate the "Untag" theme button with appropriate JS calls for onclick event.
                    this.TagFavorite1.NavigateUrl       = "javascript:removeFavoriteTopic(" + this.PageContext.PageTopicID + ");";
                    this.TagFavorite2.NavigateUrl       = "javascript:removeFavoriteTopic(" + this.PageContext.PageTopicID + ");";
                    this.TagFavorite1.TextLocalizedTag  = "BUTTON_UNTAGFAVORITE";
                    this.TagFavorite1.TitleLocalizedTag = "BUTTON_UNTAGFAVORITE_TT";
                    this.TagFavorite2.TextLocalizedTag  = "BUTTON_UNTAGFAVORITE";
                    this.TagFavorite2.TitleLocalizedTag = "BUTTON_UNTAGFAVORITE_TT";
                }
                else
                {
                    // Generate the "Tag" theme button with appropriate JS calls for onclick event.
                    this.TagFavorite1.NavigateUrl       = "javascript:addFavoriteTopic(" + this.PageContext.PageTopicID + ");";
                    this.TagFavorite2.NavigateUrl       = "javascript:addFavoriteTopic(" + this.PageContext.PageTopicID + ");";
                    this.TagFavorite1.TextLocalizedTag  = "BUTTON_TAGFAVORITE";
                    this.TagFavorite1.TitleLocalizedTag = "BUTTON_TAGFAVORITE_TT";
                    this.TagFavorite2.TextLocalizedTag  = "BUTTON_TAGFAVORITE";
                    this.TagFavorite2.TitleLocalizedTag = "BUTTON_TAGFAVORITE_TT";
                }
            }
            else
            {
                this.TagFavorite1.Visible = false;
                this.TagFavorite2.Visible = false;
            }

            this._quickReplyEditor.BaseDir    = YafForumInfo.ForumClientFileRoot + "editors";
            this._quickReplyEditor.StyleSheet = this.PageContext.Theme.BuildThemePath("theme.css");

            this._topic = DB.topic_info(this.PageContext.PageTopicID);

            // in case topic is deleted or not existant
            if (this._topic == null)
            {
                YafBuildLink.RedirectInfoPage(InfoMessage.Invalid);
            }

            // get topic flags
            this._topicFlags = new TopicFlags(this._topic["Flags"]);

            using (DataTable dt = DB.forum_list(this.PageContext.PageBoardID, this.PageContext.PageForumID))
            {
                this._forum = dt.Rows[0];
            }

            this._forumFlags = new ForumFlags(this._forum["Flags"]);

            if (this.PageContext.IsGuest && !this.PageContext.ForumReadAccess)
            {
                // attempt to get permission by redirecting to login...
                this.Get <YafPermissions>().HandleRequest(ViewPermissions.RegisteredUsers);
            }
            else if (!this.PageContext.ForumReadAccess)
            {
                YafBuildLink.AccessDenied();
            }

            if (!this.IsPostBack)
            {
                if (this.PageContext.Settings.LockedForum == 0)
                {
                    this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                    this.PageLinks.AddLink(
                        this.PageContext.PageCategoryName,
                        YafBuildLink.GetLink(ForumPages.forum, "c={0}", this.PageContext.PageCategoryID));
                }

                this.QuickReply.Text         = this.GetText("POSTMESSAGE", "SAVE");
                this.DataPanel1.TitleText    = this.GetText("QUICKREPLY");
                this.DataPanel1.ExpandText   = this.GetText("QUICKREPLY_SHOW");
                this.DataPanel1.CollapseText = this.GetText("QUICKREPLY_HIDE");

                this.PageLinks.AddForumLinks(this.PageContext.PageForumID);
                this.PageLinks.AddLink(
                    this.Get <YafBadWordReplace>().Replace(this.Server.HtmlDecode(this.PageContext.PageTopicName)), string.Empty);

                this.TopicTitle.Text = this.Get <YafBadWordReplace>().Replace(this.HtmlEncode((string)this._topic["Topic"]));

                this.ViewOptions.Visible     = this.PageContext.BoardSettings.AllowThreaded;
                this.ForumJumpHolder.Visible = this.PageContext.BoardSettings.ShowForumJump &&
                                               this.PageContext.Settings.LockedForum == 0;

                this.RssTopic.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                    ForumPages.rsstopic,
                    "pg={0}&t={1}",
                    this.Request.QueryString.GetFirstOrDefault("g"),
                    this.PageContext.PageTopicID);
                this.RssTopic.Visible = this.PageContext.BoardSettings.ShowRSSLink;

                this.QuickReplyPlaceHolder.Visible = this.PageContext.BoardSettings.ShowQuickAnswer;

                if ((this.PageContext.IsGuest && this.PageContext.BoardSettings.EnableCaptchaForGuests) ||
                    (this.PageContext.BoardSettings.EnableCaptchaForPost && !this.PageContext.IsCaptchaExcluded))
                {
                    this.imgCaptcha.ImageUrl = "{0}resource.ashx?c=1".FormatWith(YafForumInfo.ForumClientFileRoot);
                    this.CaptchaDiv.Visible  = true;
                }

                if (!this.PageContext.ForumPostAccess || (this._forumFlags.IsLocked && !this.PageContext.ForumModeratorAccess))
                {
                    this.NewTopic1.Visible = false;
                    this.NewTopic2.Visible = false;
                }

                // Ederon : 9/9/2007 - moderators can reply in locked topics
                if (!this.PageContext.ForumReplyAccess ||
                    ((this._topicFlags.IsLocked || this._forumFlags.IsLocked) && !this.PageContext.ForumModeratorAccess))
                {
                    this.PostReplyLink1.Visible        = this.PostReplyLink2.Visible = false;
                    this.QuickReplyPlaceHolder.Visible = false;
                }

                if (this.PageContext.ForumModeratorAccess)
                {
                    this.MoveTopic1.Visible = true;
                    this.MoveTopic2.Visible = true;
                }
                else
                {
                    this.MoveTopic1.Visible = false;
                    this.MoveTopic2.Visible = false;
                }

                if (!this.PageContext.ForumModeratorAccess)
                {
                    this.LockTopic1.Visible   = false;
                    this.UnlockTopic1.Visible = false;
                    this.DeleteTopic1.Visible = false;
                    this.LockTopic2.Visible   = false;
                    this.UnlockTopic2.Visible = false;
                    this.DeleteTopic2.Visible = false;
                }
                else
                {
                    this.LockTopic1.Visible   = !this._topicFlags.IsLocked;
                    this.UnlockTopic1.Visible = !this.LockTopic1.Visible;
                    this.LockTopic2.Visible   = this.LockTopic1.Visible;
                    this.UnlockTopic2.Visible = !this.LockTopic2.Visible;
                }
            }

            // Mark topic read
            YafContext.Current.Get <YafSession>().SetTopicRead(this.PageContext.PageTopicID, DateTime.UtcNow);

            this.BindData();
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            using (DataTable dt = YAF.Classes.Data.DB.forum_list(PageContext.PageBoardID, PageContext.PageForumID))
                _forum = dt.Rows [0];
            _topic = YAF.Classes.Data.DB.topic_info(PageContext.PageTopicID);

            if (!IsPostBack)
            {
                if (!PageContext.ForumModeratorAccess && !PageContext.ForumUploadAccess)
                {
                    YafBuildLink.AccessDenied();
                }

                if (!PageContext.ForumReadAccess)
                {
                    YafBuildLink.AccessDenied();
                }

                // Ederon : 9/9/2007 - moderaotrs can attach in locked posts
                if (General.BinaryAnd(_topic["Flags"], TopicFlags.Flags.IsLocked) && !PageContext.ForumModeratorAccess)
                {
                    YafBuildLink.AccessDenied(/*"The topic is closed."*/);
                }

                if (General.BinaryAnd(_forum["Flags"], ForumFlags.Flags.IsLocked))
                {
                    YafBuildLink.AccessDenied(/*"The forum is closed."*/);
                }

                // Check that non-moderators only edit messages they have written
                if (!PageContext.ForumModeratorAccess)
                {
                    using (DataTable dt = YAF.Classes.Data.DB.message_list(Request.QueryString ["m"]))
                        if (( int )dt.Rows [0] ["UserID"] != PageContext.PageUserID)
                        {
                            YafBuildLink.AccessDenied(/*"You didn't post this message."*/);
                        }
                }

                if (PageContext.Settings.LockedForum == 0)
                {
                    PageLinks.AddLink(PageContext.BoardSettings.Name, YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.forum));
                    PageLinks.AddLink(PageContext.PageCategoryName, YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.forum, "c={0}", PageContext.PageCategoryID));
                }
                PageLinks.AddForumLinks(PageContext.PageForumID);
                PageLinks.AddLink(PageContext.PageTopicName, YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.posts, "t={0}", PageContext.PageTopicID));
                PageLinks.AddLink(GetText("TITLE"), "");

                Back.Text   = GetText("BACK");
                Upload.Text = GetText("UPLOAD");

                // MJ : 10/14/2007 - list of allowed file extensions
                DataTable extensionTable = YAF.Classes.Data.DB.extension_list(PageContext.PageBoardID);

                string types  = "";
                bool   bFirst = true;

                foreach (DataRow row in extensionTable.Rows)
                {
                    types += String.Format("{1}*.{0}", row ["Extension"].ToString(), (bFirst ? "" : ", "));
                    if (bFirst)
                    {
                        bFirst = false;
                    }
                }

                if (!String.IsNullOrEmpty(types))
                {
                    ExtensionsList.Text = types;
                }

                BindData();
            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            DataRow currentRow = null;

            if (QuotedTopicID != null)
            {
                using (DataTable dt = DB.message_list(QuotedTopicID))
                    currentRow = dt.Rows[0];

                if (Convert.ToInt32(currentRow["TopicID"]) != PageContext.PageTopicID)
                {
                    YafBuildLink.AccessDenied();
                }

                if (!CanQuotePostCheck(currentRow))
                {
                    YafBuildLink.AccessDenied();
                }
            }
            else if (EditTopicID != null)
            {
                using (DataTable dt = DB.message_list(EditTopicID))
                    currentRow = dt.Rows[0];
                _ownerUserId = Convert.ToInt32(currentRow["UserId"]);
                if (!CanEditPostCheck(currentRow))
                {
                    YafBuildLink.AccessDenied();
                }
            }

            if (PageContext.PageForumID == 0)
            {
                YafBuildLink.AccessDenied();
            }
            if (Request["t"] == null && Request["m"] == null && !PageContext.ForumPostAccess)
            {
                YafBuildLink.AccessDenied();
            }
            if (Request["t"] != null && !PageContext.ForumReplyAccess)
            {
                YafBuildLink.AccessDenied();
            }

            //Message.EnableRTE = PageContext.BoardSettings.AllowRichEdit;
            _forumEditor.StyleSheet = YafBuildLink.ThemeFile("theme.css");
            _forumEditor.BaseDir    = YafForumInfo.ForumRoot + "editors";

            Title.Text = GetText("NEWTOPIC");
            PollExpire.Attributes.Add("style", "width:50px");

            if (!IsPostBack)
            {
                // helper bool -- true if this is a completely new topic...
                bool isNewTopic = (TopicID == null) && (QuotedTopicID == null) && (EditTopicID == null);

                Priority.Items.Add(new ListItem(GetText("normal"), "0"));
                Priority.Items.Add(new ListItem(GetText("sticky"), "1"));
                Priority.Items.Add(new ListItem(GetText("announcement"), "2"));
                Priority.SelectedIndex = 0;

                EditReasonRow.Visible = false;
                Preview.Text          = GetText("preview");
                PostReply.Text        = GetText("Save");
                Cancel.Text           = GetText("Cancel");
                CreatePoll.Text       = GetText("createpoll");
                RemovePoll.Text       = GetText("removepoll");

                PersistencyRow.Visible = PageContext.ForumPriorityAccess;
                PriorityRow.Visible    = PageContext.ForumPriorityAccess;
                CreatePollRow.Visible  = !HasPoll(currentRow) && CanHavePoll(currentRow) && PageContext.ForumPollAccess;
                RemovePollRow.Visible  = HasPoll(currentRow) && CanHavePoll(currentRow) && PageContext.ForumPollAccess && PageContext.ForumModeratorAccess;

                if (RemovePollRow.Visible)
                {
                    InitPollUI(currentRow);
                }

                // Show post to blog option only to a new post
                BlogRow.Visible = (PageContext.BoardSettings.AllowPostToBlog && isNewTopic && !PageContext.IsGuest);

                // handle new topic options...
                NewTopicOptionsRow.Visible = isNewTopic && !PageContext.IsGuest;
                if (isNewTopic && PageContext.ForumUploadAccess)
                {
                    TopicAttach.Visible      = true;
                    TopicAttachLabel.Visible = true;
                }

                if ((PageContext.IsGuest && PageContext.BoardSettings.EnableCaptchaForGuests) ||
                    (PageContext.BoardSettings.EnableCaptchaForPost && !PageContext.IsCaptchaExcluded))
                {
                    Session ["CaptchaImageText"] = General.GetCaptchaString();
                    imgCaptcha.ImageUrl          = String.Format("{0}resource.ashx?c=1", YafForumInfo.ForumRoot);
                    tr_captcha1.Visible          = true;
                    tr_captcha2.Visible          = true;
                }

                if (PageContext.Settings.LockedForum == 0)
                {
                    PageLinks.AddLink(PageContext.BoardSettings.Name, YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.forum));
                    PageLinks.AddLink(PageContext.PageCategoryName, YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.forum, "c={0}", PageContext.PageCategoryID));
                }
                PageLinks.AddForumLinks(PageContext.PageForumID);

                // check if it's a reply to a topic...
                if (TopicID != null)
                {
                    InitReplyToTopic();
                }

                // If currentRow != null, we are quoting a post in a new reply, or editing an existing post
                if (currentRow != null)
                {
                    MessageFlags messageFlags = new MessageFlags(currentRow["Flags"]);
                    string       message      = currentRow["Message"].ToString();

                    if (QuotedTopicID != null)
                    {
                        // quoting a reply to a topic...
                        InitQuotedReply(currentRow, message, messageFlags);
                    }
                    else if (EditTopicID != null)
                    {
                        // editing a message...
                        InitEditedPost(currentRow, message, messageFlags);
                    }
                }

                // add the "New Topic" page link last...
                if (isNewTopic)
                {
                    PageLinks.AddLink(GetText("NEWTOPIC"));
                }

                // form user is only for "Guest"
                From.Text = PageContext.PageUserName;
                if (User != null)
                {
                    FromRow.Visible = false;
                }
            }
        }
Exemple #26
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            using (
                var dt =
                    LegacyDb.pmessage_list(
                        Security.StringToLongOrRedirect(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("pm"))))
            {
                if (dt.HasRows())
                {
                    var row = dt.Rows[0];

                    // if the pm isn't from or two the current user--then it's access denied
                    if ((int)row["ToUserID"] != this.PageContext.PageUserID &&
                        (int)row["FromUserID"] != this.PageContext.PageUserID)
                    {
                        YafBuildLink.AccessDenied();
                    }

                    this.SetMessageView(
                        row["FromUserID"],
                        row["ToUserID"],
                        Convert.ToBoolean(row["IsInOutbox"]),
                        Convert.ToBoolean(row["IsArchived"]));

                    // get the return link to the pm listing
                    if (this.IsOutbox)
                    {
                        this.PageLinks.AddLink(
                            this.GetText("SENTITEMS"), YafBuildLink.GetLink(ForumPages.cp_pm, "v=out"));
                    }
                    else if (this.IsArchived)
                    {
                        this.PageLinks.AddLink(
                            this.GetText("ARCHIVE"), YafBuildLink.GetLink(ForumPages.cp_pm, "v=arch"));
                    }
                    else
                    {
                        this.PageLinks.AddLink(this.GetText("INBOX"), YafBuildLink.GetLink(ForumPages.cp_pm));
                    }

                    this.PageLinks.AddLink(row["Subject"].ToString());

                    this.Inbox.DataSource = dt;
                }
                else
                {
                    YafBuildLink.Redirect(ForumPages.cp_pm);
                }
            }

            this.DataBind();

            if (this.IsOutbox)
            {
                return;
            }

            var userPmessageId = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("pm").ToType <int>();

            LegacyDb.pmessage_markread(userPmessageId);
            this.Get <IDataCache>().Remove(Constants.Cache.ActiveUserLazyData.FormatWith(this.PageContext.PageUserID));
            this.Get <IRaiseEvent>().Raise(
                new UpdateUserPrivateMessageEvent(this.PageContext.PageUserID, userPmessageId));
        }
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.Request.QueryString.GetFirstOrDefault("t") == null || !this.PageContext.ForumReadAccess)
            {
                YafBuildLink.AccessDenied();
            }

            this.ShowToolBar = false;

            if (this.IsPostBack)
            {
                return;
            }

            if (this.PageContext.Settings.LockedForum == 0)
            {
                this.PageLinks.AddRoot();
                this.PageLinks.AddLink(
                    this.PageContext.PageCategoryName,
                    YafBuildLink.GetLink(ForumPages.forum, "c={0}", this.PageContext.PageCategoryID));
            }

            this.PageLinks.AddForum(this.PageContext.PageForumID);
            this.PageLinks.AddLink(
                this.PageContext.PageTopicName, YafBuildLink.GetLink(ForumPages.posts, "t={0}", this.PageContext.PageTopicID));
            bool showDeleted = false;
            int  userId      = 0;

            if (this.Get <YafBoardSettings>().ShowDeletedMessagesToAll)
            {
                showDeleted = true;
            }

            if (!showDeleted && ((this.Get <YafBoardSettings>().ShowDeletedMessages&&
                                  !this.Get <YafBoardSettings>().ShowDeletedMessagesToAll) ||
                                 this.PageContext.IsAdmin ||
                                 this.PageContext.ForumModeratorAccess))
            {
                userId = this.PageContext.PageUserID;
            }

            var dt = LegacyDb.post_list(
                this.PageContext.PageTopicID,
                this.PageContext.PageUserID,
                userId,
                !PageContext.IsCrawler ? 1 : 0,
                showDeleted,
                false,
                false,
                DateTimeHelper.SqlDbMinTime(),
                DateTime.UtcNow,
                DateTimeHelper.SqlDbMinTime(),
                DateTime.UtcNow,
                0,
                500,
                2,
                0,
                0,
                false,
                -1);

            this.Posts.DataSource = dt.AsEnumerable();

            this.DataBind();
        }
Exemple #28
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            this.Get <IYafSession>().UnreadTopics = 0;

            this.RssFeed.AdditionalParameters =
                "f={0}".FormatWith(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("f"));

            this.ForumJumpHolder.Visible = this.Get <YafBoardSettings>().ShowForumJump &&
                                           this.PageContext.Settings.LockedForum == 0;

            this.LastPostImageTT = this.GetText("DEFAULT", "GO_LAST_POST");

            if (this.ForumSearchHolder.Visible)
            {
                this.forumSearch.Attributes["onkeydown"] =
                    "if(event.which || event.keyCode){{if ((event.which == 13) || (event.keyCode == 13)) {{document.getElementById('{0}').click();return false;}}}} else {{return true}}; "
                    .FormatWith(this.forumSearchOK.ClientID);
            }

            if (!this.IsPostBack)
            {
                // PageLinks.Clear();
                if (this.PageContext.Settings.LockedForum == 0)
                {
                    this.PageLinks.AddRoot();
                    this.PageLinks.AddLink(
                        this.PageContext.PageCategoryName,
                        YafBuildLink.GetLink(ForumPages.forum, "c={0}", this.PageContext.PageCategoryID));
                }

                this.PageLinks.AddForum(this.PageContext.PageForumID, true);

                this.ShowList.DataSource     = StaticDataHelper.TopicTimes();
                this.ShowList.DataTextField  = "TopicText";
                this.ShowList.DataValueField = "TopicValue";
                this._showTopicListSelected  = (this.Get <IYafSession>().ShowList == -1)
                                                  ? this.Get <YafBoardSettings>().ShowTopicsDefault
                                                  : this.Get <IYafSession>().ShowList;

                this.moderate1.NavigateUrl     =
                    this.moderate2.NavigateUrl =
                        YafBuildLink.GetLinkNotEscaped(ForumPages.moderating, "f={0}", this.PageContext.PageForumID);

                this.NewTopic1.NavigateUrl     =
                    this.NewTopic2.NavigateUrl =
                        YafBuildLink.GetLinkNotEscaped(ForumPages.postmessage, "f={0}", this.PageContext.PageForumID);

                this.HandleWatchForum();
            }

            if (this.Request.QueryString.GetFirstOrDefault("f") == null)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.PageContext.IsGuest && !this.PageContext.ForumReadAccess)
            {
                // attempt to get permission by redirecting to login...
                this.Get <IPermissions>().HandleRequest(ViewPermissions.RegisteredUsers);
            }
            else if (!this.PageContext.ForumReadAccess)
            {
                YafBuildLink.AccessDenied();
            }

            using (var dt = LegacyDb.forum_list(this.PageContext.PageBoardID, this.PageContext.PageForumID))
            {
                this._forum = dt.Rows[0];
            }

            if (this._forum["RemoteURL"] != DBNull.Value)
            {
                this.Response.Clear();
                this.Response.Redirect((string)this._forum["RemoteURL"]);
            }

            this._forumFlags = new ForumFlags(this._forum["Flags"]);

            this.PageTitle.Text = this._forum["Description"].ToString().IsSet()
                                      ? "{0} - <em>{1}</em>".FormatWith(
                this.HtmlEncode(this._forum["Name"]),
                this.HtmlEncode(this._forum["Description"]))
                                      : this.HtmlEncode(this._forum["Name"]);

            this.BindData(); // Always because of yaf:TopicLine

            if (!this.PageContext.ForumPostAccess ||
                (this._forumFlags.IsLocked && !this.PageContext.ForumModeratorAccess))
            {
                this.NewTopic1.Visible = false;
                this.NewTopic2.Visible = false;
            }

            if (this.PageContext.ForumModeratorAccess)
            {
                return;
            }

            this.moderate1.Visible = false;
            this.moderate2.Visible = false;
        }
Exemple #29
0
        /// <summary>
        /// The bind data.
        /// </summary>
        private void BindData()
        {
            MembershipUser user = UserMembershipHelper.GetMembershipUserById(this.UserId);

            if (user == null || user.ProviderUserKey.ToString() == "0")
            {
                // No such user exists or this is an nntp user ("0")
                YafBuildLink.AccessDenied();
            }

            var userData = new CombinedUserDataHelper(user, this.UserId);

            // populate user information controls...
            // Is BuddyList feature enabled?
            if (this.Get <YafBoardSettings>().EnableBuddyList)
            {
                this.SetupBuddyList(this.UserId, userData);
            }
            else
            {
                // BuddyList feature is disabled. don't show any link.
                this.lnkBuddy.Visible    = false;
                this.ltrApproval.Visible = false;
            }

            // Is album feature enabled?
            if (this.Get <YafBoardSettings>().EnableAlbum)
            {
                this.AlbumList1.UserID = this.UserId;
            }
            else
            {
                this.AlbumList1.Dispose();
            }

            var userNameOrDisplayName = this.Get <YafBoardSettings>().EnableDisplayName
                                            ? userData.DisplayName
                                            : userData.UserName;

            this.SetupUserProfileInfo(this.UserId, user, userData, userNameOrDisplayName);

            this.AddPageLinks(userNameOrDisplayName);

            this.SetupUserStatistics(userData);

            this.SetupUserLinks(userData, userNameOrDisplayName);

            this.SetupAvatar(this.UserId, userData);

            this.Groups.DataSource = RoleMembershipHelper.GetRolesForUser(userData.UserName);

            // EmailRow.Visible = PageContext.IsAdmin;
            this.ModerateTab.Visible = this.PageContext.IsAdmin || this.PageContext.IsForumModerator;
            this.ModerateLi.Visible  = this.PageContext.IsAdmin || this.PageContext.IsForumModerator;

            this.AdminUserButton.Visible = this.PageContext.IsAdmin;

            if (this.LastPosts.Visible)
            {
                this.LastPosts.DataSource =
                    LegacyDb.post_alluser(this.PageContext.PageBoardID, this.UserId, this.PageContext.PageUserID, 10)
                    .AsEnumerable();

                this.SearchUser.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                    ForumPages.search,
                    "postedby={0}",
                    this.Get <YafBoardSettings>().EnableDisplayName ? userData.DisplayName : userData.UserName);
            }

            this.DataBind();
        }
Exemple #30
0
        /// <summary>
        /// The bind data.
        /// </summary>
        private void BindData()
        {
            int mode = 0;

            if (Int32.TryParse(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("v"), out mode))
            {
                DataView activeUsers = null;
                switch (mode)
                {
                case 0:

                    // Show all users
                    activeUsers =
                        this.GetActiveUsersData(true, this.PageContext.BoardSettings.ShowGuestsInDetailedActiveList).DefaultView;
                    if (activeUsers != null)
                    {
                        this.RemoveHiddenUsers(ref activeUsers);
                    }

                    break;

                case 1:

                    // Show members
                    activeUsers = this.GetActiveUsersData(false, false).DefaultView;
                    if (activeUsers != null)
                    {
                        this.RemoveHiddenUsers(ref activeUsers);
                    }

                    break;

                case 2:

                    // Show guests
                    activeUsers =
                        this.GetActiveUsersData(true, this.PageContext.BoardSettings.ShowCrawlersInActiveList).DefaultView;
                    if (activeUsers != null)
                    {
                        this.RemoveAllButGusts(ref activeUsers);
                    }

                    break;

                case 3:

                    // Show hidden
                    if (this.PageContext.IsAdmin)
                    {
                        activeUsers = this.GetActiveUsersData(false, false).DefaultView;
                        if (activeUsers != null)
                        {
                            this.RemoveAllButHiddenUsers(ref activeUsers);
                        }
                    }
                    else
                    {
                        YafBuildLink.AccessDenied();
                    }

                    break;

                default:
                    YafBuildLink.AccessDenied();
                    break;
                }

                if (activeUsers != null && activeUsers.Count > 0)
                {
                    this.Pager.PageSize = 20;

                    var pds = new PagedDataSource {
                        AllowPaging = true, PageSize = this.Pager.PageSize
                    };
                    this.Pager.Count     = activeUsers.Count;
                    pds.DataSource       = activeUsers;
                    pds.CurrentPageIndex = this.Pager.CurrentPageIndex;

                    if (pds.CurrentPageIndex >= pds.PageCount)
                    {
                        pds.CurrentPageIndex = pds.PageCount - 1;
                    }

                    this.UserList.DataSource = pds;
                    this.DataBind();
                }
            }
        }