Ejemplo n.º 1
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.AtomFeed.AdditionalParameters =
                "f={0}".FormatWith(this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("f"));
            this.RssFeed.AdditionalParameters =
                "f={0}".FormatWith(this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("f"));
            this.MarkRead.Text = this.GetText("MARKREAD");
            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 (DataTable 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;
        }
Ejemplo n.º 2
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.IsPostBack)
            {
                return;
            }

            this.PageLinks.AddRoot();
            this.PageLinks.AddLink(
              this.GetText("ADMIN_ADMIN", "Administration"), YafBuildLink.GetLink(ForumPages.admin_admin));

            this.PageLinks.AddLink(this.GetText("TEAM", "FORUMS"), YafBuildLink.GetLink(ForumPages.admin_forums));
            this.PageLinks.AddLink(this.GetText("ADMIN_EDITFORUM", "TITLE"), string.Empty);

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

            this.Save.Text = this.GetText("SAVE");
            this.Cancel.Text = this.GetText("CANCEL");

            // Populate Forum Images Table
            this.CreateImagesDataTable();

            this.ForumImages.Attributes["onchange"] =
              "getElementById('{1}').src='{0}{2}/' + this.value".FormatWith(
                YafForumInfo.ForumClientFileRoot, this.Preview.ClientID, YafBoardFolders.Current.Forums);

            this.BindData();

            var forumId = this.GetQueryStringAsInt("fa") ?? this.GetQueryStringAsInt("copy");

            if (!forumId.HasValue)
            {
                // Currently creating a New Forum, and auto fill the Forum Sort Order + 1
                using (
                DataTable dt = LegacyDb.forum_list(this.PageContext.PageBoardID, null))
                {
                    int sortOrder = 1;

                    try
                    {
                        DataRow highestRow = dt.Rows[dt.Rows.Count - 1];

                        sortOrder = (short)highestRow["SortOrder"] + sortOrder;
                    }
                    catch
                    {
                        sortOrder = 1;
                    }

                    this.SortOrder.Text = sortOrder.ToString();

                    return;
                }
            }

            using (DataTable dt = LegacyDb.forum_list(this.PageContext.PageBoardID, forumId.Value))
            {
                DataRow row = dt.Rows[0];
                var flags = new ForumFlags(row["Flags"]);
                this.Name.Text = (string)row["Name"];
                this.Description.Text = (string)row["Description"];
                this.SortOrder.Text = row["SortOrder"].ToString();
                this.HideNoAccess.Checked = flags.IsHidden;
                this.Locked.Checked = flags.IsLocked;
                this.IsTest.Checked = flags.IsTest;
                this.ForumNameTitle.Text = this.Name.Text;
                this.Moderated.Checked = flags.IsModerated;
                this.Styles.Text = row["Styles"].ToString();

                this.CategoryList.SelectedValue = row["CategoryID"].ToString();

                this.Preview.Src = "{0}images/spacer.gif".FormatWith(YafForumInfo.ForumClientFileRoot);

                ListItem item = this.ForumImages.Items.FindByText(row["ImageURL"].ToString());
                if (item != null)
                {
                    item.Selected = true;
                    this.Preview.Src = "{0}{2}/{1}".FormatWith(
                      YafForumInfo.ForumClientFileRoot, row["ImageURL"], YafBoardFolders.Current.Forums); // path corrected
                }

                // populate parent forums list with forums according to selected category
                this.BindParentList();

                if (!row.IsNull("ParentID"))
                {
                    this.ParentList.SelectedValue = row["ParentID"].ToString();
                }

                if (!row.IsNull("ThemeURL"))
                {
                    this.ThemeList.SelectedValue = row["ThemeURL"].ToString();
                }

                this.remoteurl.Text = row["RemoteURL"].ToString();
            }

            this.NewGroupRow.Visible = false;
        }
Ejemplo n.º 3
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)
    {
      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.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.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.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.Rows.Count > 0 && (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"); // 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"]);
    }
Ejemplo n.º 4
0
        /// <summary>
        /// The forum list 1_ item created.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void ForumList1_ItemCreated([NotNull] object sender, [NotNull] RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var row = (DataRow)e.Item.DataItem;
            var flags = new ForumFlags(row["Flags"]);

            DateTime lastRead =
                this.Get<IReadTrackCurrentUser>().GetForumTopicRead(
                    forumId: row["ForumID"].ToType<int>(),
                    topicId: row["LastTopicID"].ToType<int>(),
                    forumReadOverride: row["LastForumAccess"].ToType<DateTime?>() ?? DateTimeHelper.SqlDbMinTime(),
                    topicReadOverride: row["LastTopicAccess"].ToType<DateTime?>() ?? DateTimeHelper.SqlDbMinTime());

            DateTime lastPosted = row["LastPosted"].ToType<DateTime?>() ?? lastRead;

            if (string.IsNullOrEmpty(row["ImageUrl"].ToString()))
            {
                var forumIcon = e.Item.FindControl("ThemeForumIcon") as ThemeImage;
                if (forumIcon != null)
                {
                    forumIcon.ThemeTag = "FORUM";
                    forumIcon.LocalizedTitlePage = "ICONLEGEND";
                    forumIcon.LocalizedTitleTag = "NO_NEW_POSTS";
                    forumIcon.Visible = true;

                    try
                    {
                        if (flags.IsLocked)
                        {
                            forumIcon.ThemeTag = "FORUM_LOCKED";
                            forumIcon.LocalizedTitlePage = "ICONLEGEND";
                            forumIcon.LocalizedTitleTag = "FORUM_LOCKED";
                        }
                        else if (lastPosted > lastRead)
                        {
                            forumIcon.ThemeTag = "FORUM_NEW";
                            forumIcon.LocalizedTitlePage = "ICONLEGEND";
                            forumIcon.LocalizedTitleTag = "NEW_POSTS";
                        }
                        else
                        {
                            forumIcon.ThemeTag = "FORUM";
                            forumIcon.LocalizedTitlePage = "ICONLEGEND";
                            forumIcon.LocalizedTitleTag = "NO_NEW_POSTS";
                        }
                    }
                    catch
                    {
                    }
                }
            }
            else
            {
                var forumImage = e.Item.FindControl("ForumImage1") as HtmlImage;
                if (forumImage != null)
                {
                    forumImage.Src = "{0}{1}/{2}".FormatWith(
                        YafForumInfo.ForumServerFileRoot, YafBoardFolders.Current.Forums, row["ImageUrl"].ToString());

                    // TODO: vzrus: needs to be moved to css and converted to a more light control in the future.
                    // Highlight custom icon images and add tool tips to them. 
                    try
                    {
                        forumImage.Attributes.Clear();

                        if (flags.IsLocked)
                        {
                            forumImage.Attributes.Add("class", "forum_customimage_locked");
                            forumImage.Attributes.Add("alt", this.GetText("ICONLEGEND", "FORUM_LOCKED"));
                            forumImage.Attributes.Add("title", this.GetText("ICONLEGEND", "FORUM_LOCKED"));
                            forumImage.Attributes.Add(
                                "src",
                                "{0}{1}/{2}".FormatWith(
                                    YafForumInfo.ForumServerFileRoot,
                                    YafBoardFolders.Current.Forums,
                                    row["ImageUrl"].ToString()));
                        }
                        else if (lastPosted > lastRead)
                        {
                            forumImage.Attributes.Add("class", "forum_customimage_newposts");
                            forumImage.Attributes.Add("alt", this.GetText("ICONLEGEND", "NEW_POSTS"));
                            forumImage.Attributes.Add("title", this.GetText("ICONLEGEND", "NEW_POSTS"));
                            forumImage.Attributes.Add(
                                "src",
                                "{0}{1}/{2}".FormatWith(
                                    YafForumInfo.ForumServerFileRoot,
                                    YafBoardFolders.Current.Forums,
                                    row["ImageUrl"].ToString()));
                        }
                        else
                        {
                            forumImage.Attributes.Add("class", "forum_customimage_nonewposts");
                            forumImage.Attributes.Add(
                                "src",
                                "{0}{1}/{2}".FormatWith(
                                    YafForumInfo.ForumServerFileRoot,
                                    YafBoardFolders.Current.Forums,
                                    row["ImageUrl"].ToString()));
                            forumImage.Attributes.Add("alt", this.GetText("ICONLEGEND", "NO_NEW_POSTS"));
                            forumImage.Attributes.Add("title", this.GetText("ICONLEGEND", "NO_NEW_POSTS"));
                        }

                        forumImage.Visible = true;
                    }
                    catch
                    {
                    }

                    forumImage.Visible = true;
                }
            }

            if (!this.Get<YafBoardSettings>().ShowModeratorList)
            {
                return;
            }

            if (this.Get<YafBoardSettings>().ShowModeratorListAsColumn)
            {
                // hide moderator list...
                var moderatorColumn = e.Item.FindControl("ModeratorListTD") as HtmlTableCell;
                var modList = e.Item.FindControl("ModeratorList") as ForumModeratorList;

                if (modList != null)
                {
                    var dra = row.GetChildRows("FK_Moderator_Forum");

                    if (dra.GetLength(0) > 0)
                    {
                        modList.DataSource = dra;
                        modList.Visible = true;
                        modList.DataBind();
                    }

                    // set them as visible...
                    if (moderatorColumn != null)
                    {
                        moderatorColumn.Visible = true;
                    }
                }
            }
            else
            {
                var moderatorSpan = e.Item.FindControl("ModListMob_Span") as HtmlGenericControl;
                var modList1 = e.Item.FindControl("ForumModeratorListMob") as ForumModeratorList;

                if (modList1 != null)
                {
                    var dra = row.GetChildRows("FK_Moderator_Forum");
                    if (dra.GetLength(0) > 0)
                    {
                        modList1.DataSource = dra;
                        modList1.Visible = true;
                        modList1.DataBind();

                        // set them as visible...
                        if (moderatorSpan != null)
                        {
                            moderatorSpan.Visible = true;
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
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)
        {
            if (!this.PageContext.IsGuest)
            {
                // The html code for "Favorite Topic" theme buttons.
                string tagButtonHTML =
                    "'<a class=\"yafcssbigbutton rightItem\" href=\"javascript:addFavoriteTopic(' + res.d + ');\" onclick=\"jQuery(this).blur();\" title=\"{0}\"><span>{1}</span></a>'"
                        .FormatWith(this.GetText("BUTTON_TAGFAVORITE_TT"), this.GetText("BUTTON_TAGFAVORITE"));
                string untagButtonHTML =
                    "'<a class=\"yafcssbigbutton rightItem\" href=\"javascript:removeFavoriteTopic(' + res.d + ');\" onclick=\"jQuery(this).blur();\" title=\"{0}\"><span>{1}</span></a>'"
                        .FormatWith(this.GetText("BUTTON_UNTAGFAVORITE_TT"), this.GetText("BUTTON_UNTAGFAVORITE"));

                // Register the client side script for the "Favorite Topic".
                var favoriteTopicJs = JavaScriptBlocks.AddFavoriteTopicJs(untagButtonHTML) + Environment.NewLine +
                                      JavaScriptBlocks.RemoveFavoriteTopicJs(tagButtonHTML);

                YafContext.Current.PageElements.RegisterJsBlockStartup("favoriteTopicJs", favoriteTopicJs);
                YafContext.Current.PageElements.RegisterJsBlockStartup("asynchCallFailedJs", "function CallFailed(res){ alert('Error Occurred'); }");

                // Has the user already tagged this topic as favorite?
                if (this.Get<IFavoriteTopic>().IsFavoriteTopic(this.PageContext.PageTopicID))
                {
                    // Generate the "Untag" theme button with appropriate JS calls for onclick event.
                    this.TagFavorite1.NavigateUrl =
                        "javascript:removeFavoriteTopic({0});".FormatWith(this.PageContext.PageTopicID);
                    this.TagFavorite2.NavigateUrl =
                        "javascript:removeFavoriteTopic({0});".FormatWith(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({0});".FormatWith(this.PageContext.PageTopicID);
                    this.TagFavorite2.NavigateUrl =
                        "javascript:addFavoriteTopic({0});".FormatWith(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 = "{0}Scripts".FormatWith(YafForumInfo.ForumClientFileRoot);
            this._quickReplyEditor.StyleSheet = this.Get<ITheme>().BuildThemePath("theme.css");

            this._topic = LegacyDb.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 = LegacyDb.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<IPermissions>().HandleRequest(ViewPermissions.RegisteredUsers);
            }
            else if (!this.PageContext.ForumReadAccess)
            {
                YafBuildLink.AccessDenied();
            }

            var yafBoardSettings = this.Get<YafBoardSettings>();

            if (!this.IsPostBack)
            {
                // Clear Multiquotes if topic is different
                if (this.Get<IYafSession>().MultiQuoteIds != null)
                {
                    if (!this.Get<IYafSession>().MultiQuoteIds.Any(m => m.TopicID.Equals(this.PageContext.PageTopicID)))
                    {
                        this.Get<IYafSession>().MultiQuoteIds = null;
                    }
                }

                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.NewTopic2.NavigateUrl =
                    this.NewTopic1.NavigateUrl =
                    YafBuildLink.GetLinkNotEscaped(ForumPages.postmessage, "f={0}", this.PageContext.PageForumID);

                this.MoveTopic1.NavigateUrl =
                    this.MoveTopic2.NavigateUrl =
                    YafBuildLink.GetLinkNotEscaped(ForumPages.movetopic, "t={0}", this.PageContext.PageTopicID);

                this.PostReplyLink1.NavigateUrl =
                    this.PostReplyLink2.NavigateUrl =
                    YafBuildLink.GetLinkNotEscaped(
                        ForumPages.postmessage,
                        "t={0}&f={1}",
                        this.PageContext.PageTopicID,
                        this.PageContext.PageForumID);

                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.AddForum(this.PageContext.PageForumID);
                this.PageLinks.AddLink(
                    this.Get<IBadWordReplace>().Replace(this.Server.HtmlDecode(this.PageContext.PageTopicName)),
                    string.Empty);

                var topicSubject = this.Get<IBadWordReplace>().Replace(this.HtmlEncode(this._topic["Topic"]));

                if (this._topic["Status"].ToString().IsSet() && yafBoardSettings.EnableTopicStatus)
                {
                    var topicStatusIcon = this.Get<ITheme>().GetItem("TOPIC_STATUS", this._topic["Status"].ToString());

                    if (topicStatusIcon.IsSet() && !topicStatusIcon.Contains("[TOPIC_STATUS."))
                    {
                        topicSubject =
                            @"<img src=""{0}"" alt=""{1}"" title=""{1}"" class=""topicStatusIcon"" />&nbsp;{2}"
                                .FormatWith(
                                    this.Get<ITheme>().GetItem("TOPIC_STATUS", this._topic["Status"].ToString()),
                                    this.GetText("TOPIC_STATUS", this._topic["Status"].ToString()),
                                    topicSubject);
                    }
                    else
                    {
                        topicSubject =
                            "[{0}]&nbsp;{1}".FormatWith(
                                this.GetText("TOPIC_STATUS", this._topic["Status"].ToString()), topicSubject);
                    }
                }

                if (!this._topic["Description"].IsNullOrEmptyDBField()
                    && yafBoardSettings.EnableTopicDescription)
                {
                    this.TopicTitle.Text = "{0} - <em>{1}</em>".FormatWith(
                        topicSubject, this.Get<IBadWordReplace>().Replace(this.HtmlEncode(this._topic["Description"])));
                }
                else
                {
                    this.TopicTitle.Text = this.Get<IBadWordReplace>().Replace(topicSubject);
                }

                this.TopicLink.ToolTip = this.Get<IBadWordReplace>().Replace(
                    this.HtmlEncode(this._topic["Description"]));
                this.TopicLink.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                    ForumPages.posts, "t={0}", this.PageContext.PageTopicID);
                this.ViewOptions.Visible = yafBoardSettings.AllowThreaded;
                this.ForumJumpHolder.Visible = yafBoardSettings.ShowForumJump
                                               && this.PageContext.Settings.LockedForum == 0;

                this.RssTopic.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                    ForumPages.rsstopic, "pg={0}&t={1}", YafRssFeeds.Posts.ToInt(), this.PageContext.PageTopicID);
                this.RssTopic.Visible = yafBoardSettings.ShowRSSLink;

                this.QuickReplyPlaceHolder.Visible = yafBoardSettings.ShowQuickAnswer;

                if ((this.PageContext.IsGuest && yafBoardSettings.EnableCaptchaForGuests)
                    || (yafBoardSettings.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;
                }

                if (this.PageContext.ForumReplyAccess ||
                    ((!this._topicFlags.IsLocked || !this._forumFlags.IsLocked) && this.PageContext.ForumModeratorAccess))
                {
                    YafContext.Current.PageElements.RegisterJsBlockStartup(
                        "SelectedQuotingJs",
                        JavaScriptBlocks.SelectedQuotingJs(
                            YafBuildLink.GetLinkNotEscaped(
                                ForumPages.postmessage,
                                "t={0}&f={1}",
                                this.PageContext.PageTopicID,
                                this.PageContext.PageForumID),
                                this.GetText("POSTS", "QUOTE_SELECTED")));
                }
            }

            #endregion

            this.BindData();

            if (!this.Get<IPermissions>().Check(yafBoardSettings.ShowShareTopicTo) || !Config.FacebookAPIKey.IsSet())
            {
                return;
            }

            YafContext.Current.PageElements.RegisterJsBlockStartup("facebookInitJs", JavaScriptBlocks.FacebookInitJs);

            var message =
                BBCodeHelper.StripBBCode(
                    HtmlHelper.StripHtml(HtmlHelper.CleanHtmlString((string)this._topic["Topic"]))).RemoveMultipleWhitespace();

            var meta = this.Page.Header.FindControlType<HtmlMeta>().ToList();

            string description = string.Empty;

            if (meta.Any(x => x.Name.Equals("description")))
            {
                var descriptionMeta = meta.FirstOrDefault(x => x.Name.Equals("description"));
                if (descriptionMeta != null)
                {
                    description = descriptionMeta.Content;
                }
            }

            YafContext.Current.PageElements.RegisterJsBlockStartup(
                "facebookPostJs",
                JavaScriptBlocks.FacebookPostJs(
                    this.Server.HtmlEncode(message),
                    this.Server.HtmlEncode(description),
                    this.Get<HttpRequestBase>().Url.ToString(),
                    "{0}/YAFLogo.jpg".FormatWith(
                        Path.Combine(YafForumInfo.ForumBaseUrl, YafBoardFolders.Current.Images)),
                    "Logo"));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// The get topic image.
        /// </summary>
        /// <param name="o">
        /// The o.
        /// </param>
        /// <param name="imgTitle">
        /// The img title.
        /// </param>
        /// <returns>
        /// Returns the Topic Image
        /// </returns>
        protected string GetTopicImage([NotNull] object o, [NotNull] ref string imgTitle)
        {
            CodeContracts.ArgumentNotNull(o, "o");
            CodeContracts.ArgumentNotNull(imgTitle, "imgTitle");

            var row = (DataRowView)o;
            if (this.ShowTopicImages())
            {

                if (row["TopicImage"].ToString().Length > 0)
                {

                    // remote
                    imgTitle = HttpUtility.HtmlEncode(row["Subject"].ToString());
                    if (this.Get<YafBoardSettings>().TopicImageDirectThumbnail)
                    {
                        // local image thumbnail
                        return "{0}resource.ashx?ti={1}&thumb={2}".FormatWith(
                                                       YafForumInfo.ForumClientFileRoot,
                                                       row["TopicID"].ToType<int>(),                                        
                                                       this.Server.UrlEncode(ImagePathHelper.GetThumbnailImageRealFileName(row["TopicImage"].ToString(), "thumb")));
                    }

                    // Remote image. 
                    if (row["TopicImage"].ToString().Contains("http"))
                    {
                        return
                        "{0}resource.ashx?ti={1}&url={2}&width={3}&height={4}&remote=1".FormatWith(
                            YafForumInfo.ForumClientFileRoot,
                            row["TopicID"].ToType<int>(),
                            this.Server.UrlEncode(row["TopicImage"].ToString()),
                            this.Get<YafBoardSettings>().TopicImageWidth,
                            this.Get<YafBoardSettings>().TopicImageHeight);
                    }
                    else
                    {
                        return
                              "{0}resource.ashx?ti={1}&thumb={2}&type={3}".FormatWith(
                                  YafForumInfo.ForumClientFileRoot,
                                  row["TopicID"].ToType<int>(),
                                  this.Server.UrlEncode(row["TopicImage"].ToString()),
                                  row["TopicImageType"]);
                    }
                }

                if (row["TopicImageBin"] != null && row["TopicImageBin"].ToString().Length > 0)
                {
                    imgTitle = HttpUtility.HtmlEncode(row["Subject"].ToString());
                    return "{0}resource.ashx?ti={1}".FormatWith(
                        YafForumInfo.ForumClientFileRoot, row["TopicID"].ToType<int>());
                }
            }

            DateTime lastPosted = row["LastPosted"] != DBNull.Value
                                      ? (DateTime)row["LastPosted"]
                                      : DateTimeHelper.SqlDbMinTime();

            var topicFlags = new TopicFlags(row["TopicFlags"]);
            var forumFlags = new ForumFlags(row["ForumFlags"]);

            var isHot = this.IsPopularTopic(lastPosted, row);


            if (topicFlags.IsDeleted)
            {
                imgTitle = this.GetText("DELETED");
                return this.Get<ITheme>().GetItem("ICONS", "TOPIC_DELETED");
            }

            if (row["TopicMovedID"].ToString().Length > 0)
            {
                imgTitle = this.GetText("MOVED");
                return this.Get<ITheme>().GetItem("ICONS", "TOPIC_MOVED");
            }

            DateTime lastRead = this.Get<IReadTrackCurrentUser>().GetForumTopicRead(
                row["ForumID"].ToType<int>(),
                row["TopicID"].ToType<int>(),
                row["LastForumAccess"].IsNullOrEmptyDBField() ? DateTimeHelper.SqlDbMinTime() : row["LastForumAccess"].ToType<DateTime?>(),
                row["LastTopicAccess"].IsNullOrEmptyDBField() ? DateTimeHelper.SqlDbMinTime() : row["LastForumAccess"].ToType<DateTime?>());

            if (lastPosted > lastRead)
            {
                this.Get<IYafSession>().UnreadTopics++;

                if (row["PollID"] != DBNull.Value)
                {
                    imgTitle = this.GetText("POLL_NEW");
                    return this.Get<ITheme>().GetItem("ICONS", "TOPIC_POLL_NEW");
                }

                switch (row["Priority"].ToString())
                {
                    case "1":
                        imgTitle = this.GetText("STICKY_NEW");
                        return this.Get<ITheme>().GetItem("ICONS", "TOPIC_STICKY_NEW");
                    case "2":
                        imgTitle = this.GetText("ANNOUNCEMENT");
                        return this.Get<ITheme>().GetItem("ICONS", "TOPIC_ANNOUNCEMENT_NEW");
                    default:
                        if (topicFlags.IsLocked || forumFlags.IsLocked)
                        {
                            imgTitle = this.GetText("NEW_POSTS_LOCKED");
                            return this.Get<ITheme>().GetItem("ICONS", "TOPIC_NEW_LOCKED");
                        }

                        if (isHot)
                        {
                            imgTitle = this.GetText("ICONLEGEND", "HOT_NEW_POSTS");
                            return this.Get<ITheme>().GetItem(
                                "ICONS", "TOPIC_HOT_NEW", this.Get<ITheme>().GetItem("ICONS", "TOPIC_NEW"));
                        }

                        imgTitle = this.GetText("ICONLEGEND", "NEW_POSTS");
                        return this.Get<ITheme>().GetItem("ICONS", "TOPIC_NEW");
                }
            }

            if (row["PollID"] != DBNull.Value)
            {
                imgTitle = this.GetText("POLL");
                return this.Get<ITheme>().GetItem("ICONS", "TOPIC_POLL");
            }

            switch (row["Priority"].ToString())
            {
                case "1":
                    imgTitle = this.GetText("STICKY");
                    return this.Get<ITheme>().GetItem("ICONS", "TOPIC_STICKY");
                case "2":
                    imgTitle = this.GetText("ANNOUNCEMENT");
                    return this.Get<ITheme>().GetItem("ICONS", "TOPIC_ANNOUNCEMENT");
                default:
                    if (topicFlags.IsLocked || forumFlags.IsLocked)
                    {
                        imgTitle = this.GetText("NO_NEW_POSTS_LOCKED");
                        return this.Get<ITheme>().GetItem("ICONS", "TOPIC_LOCKED");
                    }

                    if (isHot)
                    {
                        imgTitle = this.GetText("HOT_NO_NEW_POSTS");
                        return this.Get<ITheme>().GetItem(
                            "ICONS", "TOPIC_HOT", this.Get<ITheme>().GetItem("ICONS", "TOPIC"));
                    }

                    imgTitle = this.GetText("NO_NEW_POSTS");
                    return this.Get<ITheme>().GetItem("ICONS", "TOPIC");
            }
        }
        /// <summary>
        /// The get topic image.
        /// </summary>
        /// <param name="o">
        /// The o.
        /// </param>
        /// <param name="imgTitle">
        /// The img title.
        /// </param>
        /// <returns>
        /// Returns the Topic Image
        /// </returns>
        protected string GetTopicImage([NotNull] object o, [NotNull] ref string imgTitle)
        {
            CodeContracts.ArgumentNotNull(o, "o");
            CodeContracts.ArgumentNotNull(imgTitle, "imgTitle");

            var row = (DataRowView)o;
            DateTime lastPosted = row["LastPosted"] != DBNull.Value
                                      ? (DateTime)row["LastPosted"]
                                      : new DateTime(2000, 1, 1);

            var topicFlags = new TopicFlags(row["TopicFlags"]);
            var forumFlags = new ForumFlags(row["ForumFlags"]);

            var isHot = this.IsPopularTopic(lastPosted, row);

            if (row["TopicMovedID"].ToString().Length > 0)
            {
                imgTitle = this.GetText("MOVED");
                return this.Get<ITheme>().GetItem("ICONS", "TOPIC_MOVED");
            }

            DateTime lastRead = this.Get<IReadTrackCurrentUser>().GetForumTopicRead(
                row["ForumID"].ToType<int>(),
                row["TopicID"].ToType<int>(),
                row["LastForumAccess"].IsNullOrEmptyDBField() ? DateTime.MinValue : row["LastForumAccess"].ToType<DateTime?>(),
                row["LastTopicAccess"].IsNullOrEmptyDBField() ? DateTime.MinValue : row["LastForumAccess"].ToType<DateTime?>());

            if (lastPosted > lastRead)
            {
                this.Get<IYafSession>().UnreadTopics++;

                if (row["PollID"] != DBNull.Value)
                {
                    imgTitle = this.GetText("POLL_NEW");
                    return this.Get<ITheme>().GetItem("ICONS", "TOPIC_POLL_NEW");
                }

                switch (row["Priority"].ToString())
                {
                    case "1":
                        imgTitle = this.GetText("STICKY_NEW");
                        return this.Get<ITheme>().GetItem("ICONS", "TOPIC_STICKY_NEW");
                    case "2":
                        imgTitle = this.GetText("ANNOUNCEMENT");
                        return this.Get<ITheme>().GetItem("ICONS", "TOPIC_ANNOUNCEMENT_NEW");
                    default:
                        if (topicFlags.IsLocked || forumFlags.IsLocked)
                        {
                            imgTitle = this.GetText("NEW_POSTS_LOCKED");
                            return this.Get<ITheme>().GetItem("ICONS", "TOPIC_NEW_LOCKED");
                        }

                        if (isHot)
                        {
                            imgTitle = this.GetText("ICONLEGEND", "HOT_NEW_POSTS");
                            return this.Get<ITheme>().GetItem(
                                "ICONS", "TOPIC_HOT_NEW", this.Get<ITheme>().GetItem("ICONS", "TOPIC_NEW"));
                        }

                        imgTitle = this.GetText("ICONLEGEND", "NEW_POSTS");
                        return this.Get<ITheme>().GetItem("ICONS", "TOPIC_NEW");
                }
            }

            if (row["PollID"] != DBNull.Value)
            {
                imgTitle = this.GetText("POLL");
                return this.Get<ITheme>().GetItem("ICONS", "TOPIC_POLL");
            }

            switch (row["Priority"].ToString())
            {
                case "1":
                    imgTitle = this.GetText("STICKY");
                    return this.Get<ITheme>().GetItem("ICONS", "TOPIC_STICKY");
                case "2":
                    imgTitle = this.GetText("ANNOUNCEMENT");
                    return this.Get<ITheme>().GetItem("ICONS", "TOPIC_ANNOUNCEMENT");
                default:
                    if (topicFlags.IsLocked || forumFlags.IsLocked)
                    {
                        imgTitle = this.GetText("NO_NEW_POSTS_LOCKED");
                        return this.Get<ITheme>().GetItem("ICONS", "TOPIC_LOCKED");
                    }

                    if (isHot)
                    {
                        imgTitle = this.GetText("HOT_NO_NEW_POSTS");
                        return this.Get<ITheme>().GetItem(
                            "ICONS", "TOPIC_HOT", this.Get<ITheme>().GetItem("ICONS", "TOPIC"));
                    }

                    imgTitle = this.GetText("NO_NEW_POSTS");
                    return this.Get<ITheme>().GetItem("ICONS", "TOPIC");
            }
        }
Ejemplo n.º 8
0
        public static bool SetTreeNodesAdminForumMove(
    string trno,
    string trn,
    string trnp,
    string trnop,
    string trna)
        {
            int? boardId = null;
            int? categoryId = null;
            int? forumId = null;
            int? parentId = null;
            int? adjacentForumId = null;
            int? adjacentCategoryId = null;
            int? adjacentPosition = null;

            switch (trna)
            {
                case "before":
                    adjacentPosition = 1;
                    break;
                case "after":
                    adjacentPosition = 2;
                    break;
                case "over":
                    adjacentPosition = 3;
                    break;
            }

            // trno - other node - the node key being moved
            // trn - node around that the other node is being moved
            // trnp,trnop respective parents
            // trna nodde move position

            var keyTrno = TreeViewUtils.GetParcedTreeNode(trno);
            var keyTrn = TreeViewUtils.GetParcedTreeNode(trn);

            // we move forum as a forum child 
            if (trn == trnop && trna == "over")
            {
                forumId = keyTrno.ForumId;
                adjacentForumId = parentId = keyTrn.ForumId;
                categoryId = keyTrn.CategoryId;
                boardId = keyTrn.BoardId;
            }

            // we move forum right into category 
            if (trnp == trnop)
            {
                forumId = keyTrno.ForumId;
                categoryId = keyTrn.CategoryId;
                boardId = keyTrn.BoardId;
                adjacentForumId = keyTrn.ForumId;
            }

            // we move a category
            if (trnp == trnop && trnp.Contains("root"))
            {
                forumId = keyTrno.ForumId;
                categoryId = keyTrno.CategoryId;
                boardId = keyTrn.BoardId;
                adjacentCategoryId = keyTrn.CategoryId;
            }          

            // a forum is being moved
            if (forumId.HasValue)
            {
                DataRow row = CommonDb.forum_list(YafContext.Current.ModuleID, boardId, forumId).Rows[0];
                string errorMessage;
                var flags = new ForumFlags(Convert.ToInt32(row["Flags"]));
                // schedule...
                ForumSaveTask.Start(YafContext.Current.ModuleID,
                    forumId,
                    categoryId,
                    parentId,
                    row["Name"],
                    row["Description"],
                    0,
                    flags.IsLocked,
                    flags.IsHidden,
                    flags.IsTest,
                    flags.IsModerated,
                    null,
                    row["RemoteURL"],
                    row["ImageURL"],
                    row["ThemeURL"],
                    row["Styles"],
                    true,
                    row["CreatedByUserID"],
                    row["IsUserForum"].ToType<bool>(),
                    row["CanHavePersForums"].ToType<bool>(),
                    adjacentForumId,
                    adjacentPosition,
                    out errorMessage);
            }
            else if (categoryId.HasValue)
            {
                DataRow crow = CommonDb.category_list(YafContext.Current.ModuleID, boardId, categoryId).Rows[0];
                // Saving a category
                string failureMessage;
                CategorySaveTask.Start(YafContext.Current.ModuleID, boardId, categoryId, crow["Name"],
                    crow["CategoryImage"], crow["SortOrder"], crow["CanHavePersForums"], adjacentCategoryId,
                    adjacentPosition, out failureMessage);
            }

            return true;
        }
Ejemplo n.º 9
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)
        {
            this.canHaveForumsAsSubforums = this.Get<YafBoardSettings>().AllowPersonalForumsAsSubForums;
            this.canHaveForumsInCategories = this.Get<YafBoardSettings>().AllowPersonalForumsInCategories;  

            if (this.IsPostBack)
            {
                return;
            }
            

            // A new forum case
            if (this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("fa") == null)
            {
                if (PageContext.PersonalForumsNumber >= PageContext.UsrPersonalForums)
                {
                    YafBuildLink.AccessDenied();
                }

                if (!this.canHaveForumsAsSubforums && !this.canHaveForumsInCategories)
                {
                    YafBuildLink.RedirectInfoPage(InfoMessage.HostAdminShouldSetAllowedPersonalForums);
                }
            }

            // the calling user is not the owner
            if (this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("u") == null || !ValidationHelper.IsValidInt(this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("u")) || this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("u").ToType<int>() != PageContext.PageUserID)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("fa") != null)
            {
                if (!ValidationHelper.IsValidInt(this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("fa")))
                {
                    YafBuildLink.AccessDenied();
                }

                // checking if the personal forum of the page user exists.
                DataTable dt = CommonDb.forum_byuserlist(
                    PageContext.PageModuleID,
                    PageContext.PageBoardID,
                    this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("fa").ToType<int>(),
                    this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("u").ToType<int>(),
                    true);

                if (dt != null && dt.Rows.Count > 0)
                {
                    ftitle = dt.Rows[0]["Name"].ToString();
                }
                else
                {
                    YafBuildLink.AccessDenied();
                }
            }
           
            accessMaskListId = CommonDb.accessmask_pforumlist(
              mid: PageContext.PageModuleID,
              boardId: this.PageContext.PageBoardID,
              accessMaskId: null,
              excludeFlags: 0,
              pageUserId: this.PageContext.PageUserID,
              isUserMask: true,             
              isCommonMask: !this.Get<YafBoardSettings>().AllowPersonalMasksOnlyForPersonalForums);
           
            if (accessMaskListId.Rows.Count == 0 && this.Get<YafBoardSettings>().AllowPersonalMasksOnlyForPersonalForums)
            {
                if (PageContext.PersonalAccessMasksNumber <= 0 && PageContext.UsrPersonalMasks > 0)
                {
                    YafBuildLink.Redirect(ForumPages.personalaccessmask, "u={0}".FormatWith(PageContext.PageUserID));
                }

                if (PageContext.UsrPersonalMasks <= 0)
                {
                    YafBuildLink.RedirectInfoPage(InfoMessage.ForumAdminShouldSetPersonalMasksOrEnableCommonMasks);
                }

                CommonDb.eventlog_create(PageContext.PageModuleID, PageContext.PageUserID, this, "Bad logic in the editpersonalforum masks.", EventLogTypes.Information);
            }

            this.PageLinks.AddLink(this.Get<YafBoardSettings>().Name, YafBuildLink.GetLink(ForumPages.forum));

            // user profile
            this.PageLinks.AddLink(this.Get<YafBoardSettings>().EnableDisplayName ? this.PageContext.CurrentUserData.DisplayName : this.PageContext.PageUserName, YafBuildLink.GetLink(ForumPages.cp_profile));

            // personalforum page
            this.PageLinks.AddLink(this.GetText("PERSONALFORUM", "TITLE"), YafBuildLink.GetLink(ForumPages.personalforum, "u={0}".FormatWith(PageContext.PageUserID)));

            // this page link
            this.PageLinks.AddLink(this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("fa") == null ? this.GetText("ADMIN_FORUMS", "NEW_FORUM") : this.HtmlEncode(ftitle), string.Empty);

            this.Page.Header.Title = "{0} - {1}".FormatWith(
                this.Get<YafBoardSettings>().EnableDisplayName ? this.PageContext.CurrentUserData.DisplayName : this.PageContext.PageUserName,
                ftitle.IsSet() ? this.HtmlEncode(ftitle) : this.GetText("PERSONALFORUM", "TITLE"));

            // Populate Forum Images Table
            this.CreateImagesDataTable();

            /*  this.ForumImages.Attributes["onchange"] =
                "getElementById('{1}').src='{0}{2}/' + this.value".FormatWith(
                  YafForumInfo.ForumClientFileRoot, this.Preview.ClientID, YafBoardFolders.Current.Forums); */

            this.BindData();

            var forumId = this.GetQueryStringAsInt("fa") ?? this.GetQueryStringAsInt("copy");


            if (!forumId.HasValue)
            {
                // Currently creating a New Forum, and auto fill the Forum Sort Order + 1
                using (
                DataTable dt = CommonDb.forum_list(PageContext.PageModuleID, this.PageContext.PageBoardID, null))
                {
                    int sortOrder = 1;

                    try
                    {
                        DataRow highestRow = dt.Rows[dt.Rows.Count - 1];

                        sortOrder = (short)highestRow["SortOrder"] + sortOrder;
                    }
                    catch
                    {
                        sortOrder = 1;
                    }

                    this.SortOrder.Text = sortOrder.ToString(CultureInfo.InvariantCulture);

                    return;
                }
            }
            using (
                   DataTable dt = CommonDb.forum_list(
                       PageContext.PageModuleID,
                       this.PageContext.PageBoardID,
                       forumId.Value))
            {        
                    DataRow row = dt.Rows[0];
                    var flags = new ForumFlags(row["Flags"]);
                    this.Name.Text = (string)row["Name"];
                    this.Description.Text = row["Description"].ToString();
                    this.SortOrder.Text = row["SortOrder"].ToString();
                    this.HideNoAccess.Checked = flags.IsHidden;
                    this.Locked.Checked = flags.IsLocked;
                    this.IsTest.Checked = flags.IsTest;
                    this.ForumNameTitle.Text = this.Name.Text;
                    this.Moderated.Checked = flags.IsModerated;
                    this.Styles.Text = row["Styles"].ToString();
                    this.Preview.Src = "{0}images/spacer.gif".FormatWith(YafForumInfo.ForumClientFileRoot);
                    this.CanHavePersForums.Checked = row["CanHavePersForums"].ToType<bool>();
                    this.remoteurl.Text = row["RemoteURL"].ToString();

                    if (this.canHaveForumsInCategories && this.CategoryList.DataSource != null)
                    {
                        this.CategoryAllowed.SelectedValue = row["CategoryID"].ToString();
                    }

                    if (this.canHaveForumsAsSubforums)
                    {
                        this.CategoryList.SelectedValue = row["CategoryID"].ToString();
                        // populate parent forums list with forums according to selected category
                        this.BindParentList();
                        if (!row.IsNull("ParentID"))
                        {
                            this.ParentList.SelectedValue = row["ParentID"].ToString();
                        }

                        if (!row.IsNull("ThemeURL"))
                        {
                            this.ThemeList.SelectedValue = row["ThemeURL"].ToString();
                        }
                    }          

                    /* ListItem item = this.ForumImages.Items.FindByText(row["ImageURL"].ToString());
                if (item != null)
                {
                    item.Selected = true;
                    this.Preview.Src = "{0}{2}/{1}".FormatWith(
                      YafForumInfo.ForumClientFileRoot, row["ImageURL"], YafBoardFolders.Current.Forums); // path corrected
                } */       
            }

            this.NewGroupRow.Visible = false;
        }
Ejemplo n.º 10
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)
        {
            this._messageRow = null;

            if (this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("m") != null)
            {
                int messageId;
                if (!int.TryParse(this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("m"), out messageId))
                {
                    YafBuildLink.RedirectInfoPage(InfoMessage.Invalid);
                }

                this._messageRow = CommonDb.MessageList(PageContext.PageModuleID, messageId).FirstOrDefault();

                // first message should not be deleted
                if (this._messageRow == null || (int)this._messageRow.Position <= 0)
                {
                    YafBuildLink.RedirectInfoPage(InfoMessage.Invalid);
                }

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

            this._forumFlags = this._messageRow.ForumFlags;
            this._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.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.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.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("m") == null)
            {
                return;
            }

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

            DataTable tempdb = CommonDb.message_getRepliesList(
                PageContext.PageModuleID,
                this.Get<HttpRequestBase>().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.Get<HttpRequestBase>().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;
            this.MessagePreview.MessageFlags = this._messageRow.Flags;
        }