/// <summary> /// Processes the specified file. /// </summary> /// <param name="fileGuid">File guid</param> protected void ProcessFile(Guid fileGuid) { // Get the file ForumAttachmentInfo fileInfo = ForumAttachmentInfoProvider.GetForumAttachmentInfoWithoutBinary(fileGuid, CMSContext.CurrentSiteName); if (fileInfo != null) { #region "Security" // Indicates whether current user is granted to see this attachment bool attachmentAllowed = false; // Get forum ForumInfo fi = ForumInfoProvider.GetForumInfo(fileInfo.AttachmentForumID); if (fi != null) { // Check acess if (ForumViewer.CheckPermission("AccessToForum", SecurityHelper.GetSecurityAccessEnum(fi.ForumAccess, 6), fi.ForumGroupID, fi.ForumID)) { attachmentAllowed = true; } } // If attachment is not allowed for current user, redirect to the access denied page if (!attachmentAllowed) { URLHelper.Redirect(URLRewriter.AccessDeniedPageURL(CurrentSiteName)); } #endregion bool resizeImage = (ImageHelper.IsMimeImage(fileInfo.AttachmentMimeType) && ForumAttachmentInfoProvider.CanResizeImage(fileInfo, Width, Height, MaxSideSize)); // Get the data if ((outputFile == null) || (outputFile.ForumAttachment == null)) { outputFile = new CMSOutputForumAttachment(fileInfo, fileInfo.AttachmentBinary); outputFile.Width = Width; outputFile.Height = Height; outputFile.MaxSideSize = MaxSideSize; outputFile.Resized = resizeImage; } } }
/// <summary> /// Renders ForumPost control for specified node. /// </summary> /// <param name="postRow">Forum post data row</param> /// <param name="sbRendered">String builder instance containing rendered text of control</param> private string DynamicForumPostRender(DataRow postRow, out StringBuilder sbRendered) { // Create detail of post to string sbRendered = new StringBuilder(); string mId = ""; ForumPostInfo fpi = new ForumPostInfo(postRow); if (ShowMode != ShowModeEnum.TreeMode) { StringWriter sw = new StringWriter(sbRendered); Html32TextWriter writer = new Html32TextWriter(sw); ForumViewer post = (ForumViewer)Page.LoadUserControl("~/CMSModules/Forums/Controls/Posts/ForumPost.ascx"); post.ID = "forumPost" + fpi.PostId; CopyValues(post); post.SetValue("PostInfo", fpi); post.ReloadData(); post.RenderControl(writer); mId = ClientID + fpi.PostId; } return(mId); }
/// <summary> /// Processes the file. /// </summary> protected void ProcessFile() { if (fileGuid == Guid.Empty) { return; } // Get the file ForumAttachmentInfo fileInfo = ForumAttachmentInfoProvider.GetForumAttachmentInfoWithoutBinary(fileGuid, SiteContext.CurrentSiteName); if (fileInfo == null) { return; } // Check forum access var forum = ForumInfoProvider.GetForumInfo(fileInfo.AttachmentForumID); if ((forum == null) || !ForumViewer.CheckPermission("AccessToForum", SecurityHelper.GetSecurityAccessEnum(forum.ForumAccess, 6), forum.ForumGroupID, forum.ForumID, CurrentUser)) { // If attachment is not allowed for current user, redirect to the access denied page URLHelper.Redirect(PageSecurityHelper.AccessDeniedPageURL(CurrentSiteName)); } bool resizeImage = (ImageHelper.IsMimeImage(fileInfo.AttachmentMimeType) && ForumAttachmentInfoProvider.CanResizeImage(fileInfo, Width, Height, MaxSideSize)); // Get the data if ((outputFile == null) || (outputFile.ForumAttachment == null)) { outputFile = new CMSOutputForumAttachment(fileInfo, fileInfo.AttachmentBinary); outputFile.Width = Width; outputFile.Height = Height; outputFile.MaxSideSize = MaxSideSize; outputFile.Resized = resizeImage; } }
/// <summary> /// Initializes the control properties. /// </summary> public void SetupControl() { if (StopProcessing) { // Do nothing } else { // Clear placeholder first plcHolder.Controls.Clear(); // Group settings ForumDivider1.ForumLayout = ForumLayout; // Friendly URLs ForumDivider1.UseFriendlyURL = UseFriendlyURL; ForumDivider1.FriendlyURLExtension = FriendlyURLExtension; ForumDivider1.FriendlyBaseURL = FriendlyBaseURL; // Post options ForumDivider1.DisplayAttachmentImage = DisplayAttachmentImage; ForumDivider1.AttachmentImageMaxSideSize = AttachmentImageMaxSideSize; ForumDivider1.EnableAvatars = EnableAvatars; ForumDivider1.AvatarMaxSideSize = AvatarMaxSideSize; ForumDivider1.ViewMode = ThreadViewMode; ForumDivider1.EnableFavorites = EnableFavorites; ForumDivider1.EnableSignature = EnableSignature; ForumDivider1.MaxRelativeLevel = MaxRelativeLevel; ForumDivider1.DisplayBadgeInfo = DisplayBadgeInfo; ForumDivider1.RedirectToUserProfile = RedirectToUserProfile; ForumDivider1.BaseURL = BaseURL; ForumDivider1.UnsubscriptionURL = UnsubscriptionURL; ForumDivider1.EnableFriendship = EnableFriendship && UIHelper.IsFriendsModuleEnabled(CMSContext.CurrentSiteName); ForumDivider1.EnableMessaging = EnableMessaging; // Behaviour ForumDivider1.EnableSubscription = EnableSubscription; ForumDivider1.EnableOnSiteManagement = OnSiteManagement; ForumDivider1.HideForumForUnauthorized = HideForumForUnauthorized; ForumDivider1.RedirectUnauthorized = RedirectUnauthorized; ForumDivider1.LogonPageURL = LogonPageURL; ForumDivider1.AccessDeniedPageURL = AccessDeniedPageURL; // Abuse report ForumDivider1.AbuseReportAccess = AbuseReportAccess; ForumDivider1.AbuseReportRoles = AbuseReportRoles; //Paging ForumDivider1.EnableThreadPaging = EnableThreadPaging; ForumDivider1.ThreadPageSize = ThreadPageSize; ForumDivider1.EnablePostsPaging = EnablePostsPaging; ForumDivider1.PostsPageSize = PostsPageSize; // Tree forum properties ForumDivider1.ShowMode = ShowMode; ForumDivider1.ExpandTree = ExpandTree; if (CommunityContext.CurrentGroup != null) { ForumDivider1.CommunityGroupID = CommunityContext.CurrentGroup.GroupID; } if (UseUpdatePanel) { ForumDivider1.UseRedirectAfterAction = false; } string path = ResolveUrl("~/CMSModules/Forums/Controls/ForumDivider.ascx"); GroupInfo gi = GroupInfoProvider.GetGroupInfo(GroupName, CMSContext.CurrentSiteName); if (gi != null) { forumGroups = ForumGroupInfoProvider.GetGroups("GroupGroupID = " + gi.GroupID + "AND ((SELECT Count(ForumID) FROM Forums_Forum WHERE (ForumOpen = 1) AND ForumGroupID = GroupID ) > 0)", "GroupOrder"); if (!DataHelper.DataSourceIsEmpty(forumGroups)) { int ctrlId = 0; bool wasAdded = false; // Load all the groups foreach (DataRow dr in forumGroups.Tables[0].Rows) { Control ctrl = this.LoadUserControl(path); if (ctrl != null) { ctrl.ID = "groupElem" + ctrlId; ForumViewer frmv = ctrl as ForumViewer; if (frmv != null) { // Copy values ForumDivider1.CopyValues(frmv); if (wasAdded && !String.IsNullOrEmpty(GroupsSeparator)) { plcHolder.Controls.Add(new LiteralControl(GroupsSeparator)); } frmv.GroupID = ValidationHelper.GetInteger(dr["GroupID"], 0); plcHolder.Controls.Add(frmv); wasAdded = true; } } ctrlId++; } } } } }
protected void Page_Load(object sender, EventArgs e) { // Show back link if is opened from listing if (!String.IsNullOrEmpty(ListingPost) && (PostInfo != null)) { listingParameter = "&listingpost=" + HTMLHelper.HTMLEncode(ListingPost); } ThreadMove1 = Page.LoadUserControl("~/CMSModules/Forums/Controls/ThreadMove.ascx") as ForumViewer; ThreadMove1.ID = "ctrlThreadMove"; ThreadMove1.IsLiveSite = IsLiveSite; plcThreadMove.Controls.Add(ThreadMove1); if (!Visible) { EnableViewState = false; } PostEdit1.OnCancelClick += ForumNewPost1_OnCancelClick; PostEdit1.OnCheckPermissions += PostEdit1_OnCheckPermissions; PostEdit1.IsLiveSite = false; if (Reply != 0) { NewThreadTitle.TitleText = GetString("ForumPost_View.PostTitleText"); pnlBody.Visible = false; PanelNewThread.Visible = true; PostEdit1.ReplyToPostID = PostID; PostEdit1.ForumID = ForumID; PostEdit1.OnInsertPost += ForumNewPost1_OnInsertPost; } else { //New thread if (ForumID != 0) { NewThreadTitle.TitleText = GetString("ForumPost_View.NewThreadHeaderCaption"); pnlBody.Visible = false; PanelNewThread.Visible = true; PostEdit1.ForumID = ForumID; PostEdit1.OnInsertPost += ForumNewPost1_OnInsertPost; } else { ForumInfo fi = ForumInfoProvider.GetForumInfo(PostInfo.PostForumID); if (fi != null) { ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ForumScripts", ScriptHelper.GetScript(" function ReplyToPost(postId)\n" + "{ if (postId != 0){\n" + "location.href='ForumPost_View.aspx?postid=' + postId + '&reply=1&forumId=" + fi.ForumID + listingParameter + "' }}\n")); } //Create menu using inserted skmMenu control InitializeMenu(); ltlScript.Text += ScriptHelper.GetScript( "function DeletePost(postId) { if (confirm(" + ScriptHelper.GetString(GetString("ForumPost_View.DeleteConfirmation")) + ")) { " + Page.ClientScript.GetPostBackEventReference(btnDelete, null) + "; } } \n" + "function ApprovePost(postId) { " + Page.ClientScript.GetPostBackEventReference(btnApprove, null) + "; } \n" + "function ApproveSubTree(postId) { " + Page.ClientScript.GetPostBackEventReference(btnApproveSubTree, null) + "; } \n" + "function RejectSubTree(postId) { " + Page.ClientScript.GetPostBackEventReference(btnRejectSubTree, null) + "; } \n" + "function StickThread(postId) { " + Page.ClientScript.GetPostBackEventReference(btnStickThread, null) + "; } \n" + "function SplitThread(postId) { " + Page.ClientScript.GetPostBackEventReference(btnSplitThread, null) + "; } \n" + "function LockThread(postId) { " + Page.ClientScript.GetPostBackEventReference(btnLockThread, null) + "; } \n" ); ForumPost1.ForumID = ForumID; ForumPost1.PostID = PostID; ForumPost1.DisplayOnly = true; if ((PostInfo != null) && (PostInfo.PostAttachmentCount > 0)) { ReloadAttachmentData(PostID); } } } }
/// <summary> /// Page_Load - Set properties for current control. /// </summary> protected void Page_Load(object sender, EventArgs e) { try { // Check stop processing if (this.StopProcessing) { return; } EnsureUnsubscription(); if (!this.SearchResult) { ForumContext.GroupID = this.GroupID; ForumContext.ForumID = this.ForumID; ForumContext.CommunityGroupID = this.CommunityGroupID; } // If search result control, check whether search is performed if (this.SearchResult && (ForumContext.CurrentState != ForumStateEnum.Search)) { return; } // Get current state currentState = CheckPermissions(ForumContext.CurrentState); if (currentState != ForumStateEnum.Search) { // Group if (startingMode == 0) { // Check whether forum is defined if ((ForumContext.CurrentForum != null) && (currentState != ForumStateEnum.Forums)) { // For nested level call request to single display if ((ForumContext.CurrentGroup != null) && (ForumContext.CurrentForum.ForumGroupID == ForumContext.CurrentGroup.GroupID)) { ForumContext.DisplayOnlyMe(this); } else { // Hide current forum because ids not match return; } } } // Forum else if (startingMode == 1) { // Hide all others forums ForumContext.DisplayOnlyMe(this); } else { // Hide forum because none of mandatory property was set return; } } // Display correspondent control with dependence on current mode switch (currentState) { // Threads case ForumStateEnum.Threads: ctrl = LoadControl(defaultPath + ForumLayout + "/Threads.ascx"); ctrl.ID = ControlsHelper.GetUniqueID(this.plcForum, "threadsElem", ctrl); break; // Thread case ForumStateEnum.Thread: // Log thread views if ((ForumContext.CurrentThread != null) && (!QueryHelper.Contains("tpage"))) { ThreadViewCounter.LogThreadView(ForumContext.CurrentThread.PostId); } ctrl = LoadControl(defaultPath + ForumLayout + "/Thread.ascx"); ctrl.ID = ControlsHelper.GetUniqueID(this.plcForum, "threadElem", ctrl); break; // New post, reply or edit post case ForumStateEnum.NewThread: case ForumStateEnum.ReplyToPost: case ForumStateEnum.EditPost: ctrl = LoadControl(defaultPath + ForumLayout + "/ThreadEdit.ascx"); ctrl.ID = ControlsHelper.GetUniqueID(this.plcForum, "editElem", ctrl); break; // Subscription to forum or subscription to post case ForumStateEnum.NewSubscription: case ForumStateEnum.SubscribeToPost: ctrl = LoadControl(defaultPath + ForumLayout + "/SubscriptionEdit.ascx"); ctrl.ID = ControlsHelper.GetUniqueID(this.plcForum, "subscriptionElem", ctrl); break; // Forums case ForumStateEnum.Forums: ctrl = LoadControl(defaultPath + ForumLayout + "/Forums.ascx"); ctrl.ID = ControlsHelper.GetUniqueID(this.plcForum, "forumsElem", ctrl); break; case ForumStateEnum.Attachments: ctrl = LoadControl(defaultPath + ForumLayout + "/Attachments.ascx"); ctrl.ID = ControlsHelper.GetUniqueID(this.plcForum, "attachmentElem", ctrl); break; case ForumStateEnum.Search: if (this.SearchResult) { ctrl = LoadControl(defaultPath + ForumLayout + "/SearchResults.ascx"); ctrl.ID = ControlsHelper.GetUniqueID(this.plcForum, "searchElem", ctrl); } else { return; } break; case ForumStateEnum.AccessDenied: this.Visible = false; return; // Unknown case ForumStateEnum.Unknown: if (!this.SearchResult) { throw new Exception("[Forum divider]: Unknown forum state."); } return; } // Clear controls collection plcForum.Controls.Clear(); // Add loaded control to the control collection plcForum.Controls.Add(ctrl); // Get forum viewer control ForumViewer frmv = ctrl as ForumViewer; // If control exists set forum properties if (frmv != null) { CopyValues(frmv); } } catch (Exception ex) { lblError.Visible = true; lblError.Text = ex.Message; } }
/// <summary> /// Check permissions. /// </summary> /// <param name="state">Current state</param> public ForumStateEnum CheckPermissions(ForumStateEnum state) { // Return original state for selected types if ((state == ForumStateEnum.Forums) || (state == ForumStateEnum.Unknown) || (state == ForumStateEnum.Search)) { return(state); } // If forum doesn't exist display default if (ForumContext.CurrentForum == null) { return(ForumStateEnum.Forums); } // If forum is closed => hide if ((!IsAdHocForum) && (!ForumContext.CurrentForum.ForumOpen)) { return(ForumStateEnum.Forums); } // Sets threads state for every action if forum is locked if (ForumContext.CurrentForum.ForumIsLocked) { switch (state) { case ForumStateEnum.NewSubscription: case ForumStateEnum.NewThread: case ForumStateEnum.ReplyToPost: case ForumStateEnum.SubscribeToPost: case ForumStateEnum.Attachments: return(ForumStateEnum.Threads); } } // If user is global admin, forum admin, community admin or modrator if (ForumContext.UserIsModerator(ForumContext.CurrentForum.ForumID, this.CommunityGroupID)) { return(state); } // Sets thread state for locked post if ((ForumContext.CurrentThread != null) && (ForumContext.CurrentThread.PostIsLocked)) { if (!ForumContext.UserIsModerator(ForumContext.CurrentForum.ForumID, this.CommunityGroupID)) { switch (state) { case ForumStateEnum.NewSubscription: case ForumStateEnum.SubscribeToPost: case ForumStateEnum.NewThread: case ForumStateEnum.ReplyToPost: case ForumStateEnum.Attachments: return(ForumStateEnum.Thread); } } } bool hasPermissions = true; // Check permissions for action switch (state) { case ForumStateEnum.ReplyToPost: hasPermissions = ForumViewer.CheckPermission("Reply", ForumContext.CurrentForum.AllowReply, ForumContext.CurrentForum.ForumGroupID, ForumContext.CurrentForum.ForumID); break; case ForumStateEnum.NewThread: hasPermissions = ForumViewer.CheckPermission("Post", ForumContext.CurrentForum.AllowPost, ForumContext.CurrentForum.ForumGroupID, ForumContext.CurrentForum.ForumID); break; case ForumStateEnum.Attachments: hasPermissions = ForumViewer.CheckPermission("AttachFiles", ForumContext.CurrentForum.AllowAttachFiles, ForumContext.CurrentForum.ForumGroupID, ForumContext.CurrentForum.ForumID); break; case ForumStateEnum.TopicMove: hasPermissions = ForumContext.UserIsModerator(ForumContext.CurrentForum.ForumID, this.CommunityGroupID); break; case ForumStateEnum.SubscribeToPost: case ForumStateEnum.NewSubscription: hasPermissions = ForumViewer.CheckPermission("Subscribe", ForumContext.CurrentForum.AllowSubscribe, ForumContext.CurrentForum.ForumGroupID, ForumContext.CurrentForum.ForumID) && this.EnableSubscription; break; case ForumStateEnum.EditPost: hasPermissions = ForumContext.UserIsModerator(ForumContext.CurrentForum.ForumID, this.CommunityGroupID) || (ForumContext.CurrentForum.ForumAuthorEdit && (ForumContext.CurrentPost != null && !CMSContext.CurrentUser.IsPublic() && (ForumContext.CurrentPost.PostUserID == CMSContext.CurrentUser.UserID))); break; } // Check ForumAccess permission if (ForumContext.CurrentForum != null) { hasPermissions = hasPermissions && ForumViewer.CheckPermission("AccessToForum", ForumContext.CurrentForum.AllowAccess, ForumContext.CurrentForum.ForumGroupID, ForumContext.CurrentForum.ForumID); } // Check whether user has permissions for selected state if (!hasPermissions) { // Check whether public user should be redirected to logon page if (this.RedirectUnauthorized && CMSContext.CurrentUser.IsPublic()) { URLHelper.Redirect(URLHelper.AddParameterToUrl(ResolveUrl(this.LogonPageURL), "returnurl", HttpUtility.UrlEncode(URLHelper.CurrentURL))); } else if (!String.IsNullOrEmpty(this.AccessDeniedPageURL)) { URLHelper.Redirect(URLHelper.AddParameterToUrl(ResolveUrl(this.AccessDeniedPageURL), "returnurl", HttpUtility.UrlEncode(URLHelper.CurrentURL))); } // Sets state with dependence on current settings else { if (startingMode == 0) { return(ForumStateEnum.Forums); } else { return(ForumStateEnum.AccessDenied); } } } return(state); }
protected void Page_Load(object sender, EventArgs e) { // Show back link if is opened from listing if (!String.IsNullOrEmpty(this.ListingPost) && (this.PostInfo != null)) { listingParameter = "&listingpost=" + HTMLHelper.HTMLEncode(this.ListingPost); lnkBackListing.Text = GetString("Forums.BackToListing"); lnkBackListing.NavigateUrl = "javascript:BackToListing();"; pnlListing.Visible = true; pnlListing.Attributes.Add("style", "border-bottom:1px solid #CCCCCC;font-size:12px; padding:5px 10px;"); } ThreadMove1 = this.Page.LoadControl("~/CMSModules/Forums/Controls/ThreadMove.ascx") as ForumViewer; ThreadMove1.ID = "ctrlThreadMove"; plcThreadMove.Controls.Add(ThreadMove1); if (!this.Visible) { this.EnableViewState = false; } PostEdit1.OnCancelClick += new EventHandler(ForumNewPost1_OnCancelClick); PostEdit1.OnCheckPermissions += new CheckPermissionsEventHandler(PostEdit1_OnCheckPermissions); PostEdit1.IsLiveSite = false; if (this.Reply != 0) { NewThreadTitle.TitleText = GetString("ForumPost_View.PostTitleText"); NewThreadTitle.TitleImage = GetImageUrl("CMSModules/CMS_Forums/newthread.png"); pnlBody.Visible = false; PanelNewThread.Visible = true; PostEdit1.ReplyToPostID = this.PostID; PostEdit1.ForumID = this.ForumID; PostEdit1.OnInsertPost += new EventHandler(ForumNewPost1_OnInsertPost); } else { //New thread if (this.ForumID != 0) { NewThreadTitle.TitleText = GetString("ForumPost_View.NewThreadHeaderCaption"); NewThreadTitle.TitleImage = GetImageUrl("CMSModules/CMS_Forums/newthread.png"); pnlBody.Visible = false; PanelNewThread.Visible = true; PostEdit1.ForumID = this.ForumID; PostEdit1.OnInsertPost += new EventHandler(ForumNewPost1_OnInsertPost); } else { // Selected post PostTitle.TitleText = GetString("ForumPost_View.PostTitleText"); PostTitle.TitleImage = GetImageUrl("Objects/Forums_ForumPost/object.png"); PostAttachmentTitle.TitleText = GetString("ForumPost_View.PostAttachmentTitle"); PostAttachmentTitle.TitleImage = GetImageUrl("CMSModules/CMS_Forums/attachments.png"); if (BrowserHelper.IsIE()) { upload.Style.Add("height", "24px;"); } if (this.PostInfo == null) { pnlMenu.Visible = false; return; } ForumInfo fi = ForumInfoProvider.GetForumInfo(this.PostInfo.PostForumID); if (fi != null) { ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ForumScripts", ScriptHelper.GetScript(" function ReplyToPost(postId)\n" + "{ if (postId != 0){\n" + "location.href='ForumPost_View.aspx?postid=' + postId + '&reply=1&forumId=" + fi.ForumID + listingParameter + "' }}\n")); } //Create menu using inserted skmMenu control InitializeMenu(); this.ltlScript.Text += ScriptHelper.GetScript( "function DeletePost(postId) { if (confirm(" + ScriptHelper.GetString(GetString("ForumPost_View.DeleteConfirmation")) + ")) { " + this.Page.ClientScript.GetPostBackEventReference(this.btnDelete, null) + "; } } \n" + "function ApprovePost(postId) { " + this.Page.ClientScript.GetPostBackEventReference(this.btnApprove, null) + "; } \n" + "function ApproveSubTree(postId) { " + this.Page.ClientScript.GetPostBackEventReference(this.btnApproveSubTree, null) + "; } \n" + "function RejectSubTree(postId) { " + this.Page.ClientScript.GetPostBackEventReference(this.btnRejectSubTree, null) + "; } \n" + "function StickThread(postId) { " + this.Page.ClientScript.GetPostBackEventReference(this.btnStickThread, null) + "; } \n" + "function SplitThread(postId) { " + this.Page.ClientScript.GetPostBackEventReference(this.btnSplitThread, null) + "; } \n" + "function LockThread(postId) { " + this.Page.ClientScript.GetPostBackEventReference(this.btnLockThread, null) + "; } \n" ); ForumPost1.ForumID = this.ForumID; ForumPost1.PostID = this.PostID; ForumPost1.DisplayOnly = true; if ((this.PostInfo != null) && (this.PostInfo.PostAttachmentCount > 0)) { ReloadAttachmentData(this.PostID); } } } }
protected void Page_Load(object sender, EventArgs e) { EnsureEditedObject(); // Show back link if is opened from listing if (!String.IsNullOrEmpty(ListingPost) && (PostInfo != null)) { mListingParameter = "&listingpost=" + HTMLHelper.HTMLEncode(ListingPost); } mThreadMove = Page.LoadUserControl("~/CMSModules/Forums/Controls/ThreadMove.ascx") as ForumViewer; mThreadMove.ID = "ctrlThreadMove"; mThreadMove.IsLiveSite = IsLiveSite; plcThreadMove.Controls.Add(mThreadMove); if (!Visible) { EnableViewState = false; } PostEdit1.OnCancelClick += ForumNewPost1_OnCancelClick; PostEdit1.OnCheckPermissions += PostEdit1_OnCheckPermissions; PostEdit1.IsLiveSite = false; if (Reply != 0) { NewThreadTitle.TitleText = GetString("ForumPost_View.PostTitleText"); pnlBody.Visible = false; PanelNewThread.Visible = true; PostEdit1.ReplyToPostID = PostID; PostEdit1.ForumID = ForumID; PostEdit1.OnInsertPost += ForumNewPost1_OnInsertPost; } else { //New thread if (NewForumPostIsBeingCreated) { NewThreadTitle.TitleText = GetString("ForumPost_View.NewThreadHeaderCaption"); pnlBody.Visible = false; PanelNewThread.Visible = true; PostEdit1.ForumID = ForumID; PostEdit1.OnInsertPost += ForumNewPost1_OnInsertPost; } else { // ReSharper disable once PossibleNullReferenceException - edited object is ensured => no null reference is possible ForumInfo fi = ForumInfoProvider.GetForumInfo(PostInfo.PostForumID); if (fi != null) { ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ForumScripts", ScriptHelper.GetScript(" function ReplyToPost(postId)\n" + "{ if (postId != 0){\n" + "location.href='ForumPost_View.aspx?postid=' + postId + '&reply=1&forumId=" + fi.ForumID + mListingParameter + "' }}\n")); } InitializeMenu(); ltlScript.Text += ScriptHelper.GetScript( "function DeletePost(postId) { if (confirm(" + ScriptHelper.GetString(GetString("ForumPost_View.DeleteConfirmation")) + ")) { " + Page.ClientScript.GetPostBackEventReference(btnDelete, null) + "; } } \n" + "function ApprovePost(postId) { " + Page.ClientScript.GetPostBackEventReference(btnApprove, null) + "; } \n" + "function ApproveSubTree(postId) { " + Page.ClientScript.GetPostBackEventReference(btnApproveSubTree, null) + "; } \n" + "function RejectSubTree(postId) { " + Page.ClientScript.GetPostBackEventReference(btnRejectSubTree, null) + "; } \n" + "function StickThread(postId) { " + Page.ClientScript.GetPostBackEventReference(btnStickThread, null) + "; } \n" + "function SplitThread(postId) { " + Page.ClientScript.GetPostBackEventReference(btnSplitThread, null) + "; } \n" + "function LockThread(postId) { " + Page.ClientScript.GetPostBackEventReference(btnLockThread, null) + "; } \n" ); ForumPost1.ForumID = ForumID; ForumPost1.PostID = PostID; ForumPost1.DisplayOnly = true; if (PostInfo.PostAttachmentCount > 0) { ReloadAttachmentData(PostID); } } } }
protected void Page_Load(object sender, EventArgs e) { // Show back link if is opened from listing if (!String.IsNullOrEmpty(ListingPost) && (PostInfo != null)) { listingParameter = "&listingpost=" + HTMLHelper.HTMLEncode(ListingPost); lnkBackListing.Text = GetString("Forums.BackToListing"); lnkBackListing.NavigateUrl = "javascript:BackToListing();"; pnlListing.Visible = true; pnlListing.Attributes.Add("style", "border-bottom:1px solid #CCCCCC;font-size:12px; padding:5px 10px;"); } ThreadMove1 = Page.LoadUserControl("~/CMSModules/Forums/Controls/ThreadMove.ascx") as ForumViewer; ThreadMove1.ID = "ctrlThreadMove"; ThreadMove1.IsLiveSite = IsLiveSite; plcThreadMove.Controls.Add(ThreadMove1); if (!Visible) { EnableViewState = false; } PostEdit1.OnCancelClick += new EventHandler(ForumNewPost1_OnCancelClick); PostEdit1.OnCheckPermissions += new CheckPermissionsEventHandler(PostEdit1_OnCheckPermissions); PostEdit1.IsLiveSite = false; if (Reply != 0) { NewThreadTitle.TitleText = GetString("ForumPost_View.PostTitleText"); NewThreadTitle.TitleImage = GetImageUrl("CMSModules/CMS_Forums/newthread.png"); pnlBody.Visible = false; PanelNewThread.Visible = true; PostEdit1.ReplyToPostID = PostID; PostEdit1.ForumID = ForumID; PostEdit1.OnInsertPost += new EventHandler(ForumNewPost1_OnInsertPost); } else { //New thread if (ForumID != 0) { NewThreadTitle.TitleText = GetString("ForumPost_View.NewThreadHeaderCaption"); NewThreadTitle.TitleImage = GetImageUrl("CMSModules/CMS_Forums/newthread.png"); pnlBody.Visible = false; PanelNewThread.Visible = true; PostEdit1.ForumID = ForumID; PostEdit1.OnInsertPost += new EventHandler(ForumNewPost1_OnInsertPost); } else { // Selected post PostTitle.TitleText = GetString("ForumPost_View.PostTitleText"); PostTitle.TitleImage = GetImageUrl("Objects/Forums_ForumPost/object.png"); PostAttachmentTitle.TitleText = GetString("ForumPost_View.PostAttachmentTitle"); PostAttachmentTitle.TitleImage = GetImageUrl("CMSModules/CMS_Forums/attachments.png"); if (BrowserHelper.IsIE()) { upload.Style.Add("height", "24px;"); } if (PostInfo == null) { pnlMenu.Visible = false; return; } ForumInfo fi = ForumInfoProvider.GetForumInfo(PostInfo.PostForumID); if (fi != null) { ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ForumScripts", ScriptHelper.GetScript(" function ReplyToPost(postId)\n" + "{ if (postId != 0){\n" + "location.href='ForumPost_View.aspx?postid=' + postId + '&reply=1&forumId=" + fi.ForumID + listingParameter + "' }}\n")); } //Create menu using inserted skmMenu control InitializeMenu(); ltlScript.Text += ScriptHelper.GetScript( "function DeletePost(postId) { if (confirm(" + ScriptHelper.GetString(GetString("ForumPost_View.DeleteConfirmation")) + ")) { " + Page.ClientScript.GetPostBackEventReference(btnDelete, null) + "; } } \n" + "function ApprovePost(postId) { " + Page.ClientScript.GetPostBackEventReference(btnApprove, null) + "; } \n" + "function ApproveSubTree(postId) { " + Page.ClientScript.GetPostBackEventReference(btnApproveSubTree, null) + "; } \n" + "function RejectSubTree(postId) { " + Page.ClientScript.GetPostBackEventReference(btnRejectSubTree, null) + "; } \n" + "function StickThread(postId) { " + Page.ClientScript.GetPostBackEventReference(btnStickThread, null) + "; } \n" + "function SplitThread(postId) { " + Page.ClientScript.GetPostBackEventReference(btnSplitThread, null) + "; } \n" + "function LockThread(postId) { " + Page.ClientScript.GetPostBackEventReference(btnLockThread, null) + "; } \n" ); ForumPost1.ForumID = ForumID; ForumPost1.PostID = PostID; ForumPost1.DisplayOnly = true; if ((PostInfo != null) && (PostInfo.PostAttachmentCount > 0)) { ReloadAttachmentData(PostID); } } } }