⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 createeditpost.cs

📁 本系统是在asp版《在线文件管理器》的基础上设计制作
💻 CS
📖 第 1 页 / 共 4 页
字号:
			postDetails = control.FindControl("ReplyDetails") as Literal;
			postDetails.Text = username + " wrote the following post at " + Formatter.FormatDate(post.PostDate, true) + ":";

            // Access check
            //
            Permissions.AccessCheck(forum, Permission.Reply, user, post);

            // Don't allow replies to locked posts
            if (post.IsLocked) 
            {
                HttpContext.Current.Response.Redirect(Globals.GetSiteUrls().Post(csContext.PostID));
                HttpContext.Current.Response.End();
            }
            */
        }
        #endregion

        #endregion

        #region Events

        #region PinnedPost_Changed
        /***********************************************************************
        // PinnedPost_Changed
        //
        /// <remarks>
        /// Event raised when the pinned post drop down list changes. If the user
        /// selected announcemnt we need to find the allow replies check box, check it,
        /// and then disable it.
        /// </remarks>
        /// <param name="control">Usercontrol used to control UI formatting</param>
        ***********************************************************************/
        private void PinnedPost_Changed (Object sender, EventArgs e) {

            // Do we have an announcement?
            if (Convert.ToInt32(pinnedPost.SelectedItem.Value) == 999) {
				//allowReply.ButtonOn = true;
                isLocked.Checked = true;
                isLocked.Enabled = false;
            } 
            else {
				//allowReply.ButtonOn = false;
				isLocked.Checked = false;
                isLocked.Enabled = true;
            }

        }
        #endregion

        #region BackButton_Click
        /***********************************************************************
        // BackButton_Click
        //
        /// <remarks>
        /// Event handler for the back button click from Preview mode
        /// </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        ************************************************************************/
        private void BackButton_Click (Object sender, EventArgs e) {
            Control form;

            // The event was raised by a button in the user control
            // the is the UI for the form -- get the Parent, e.g. the User Control
            form = ((Control)sender).Parent;

			form.FindControl("EditButton").Visible = false;
			form.FindControl("PreviewButton").Visible = true;

            // Find and hide the Preview display
            form.FindControl("Preview").Visible = false;

            // Find and enable the Post
            form.FindControl("Post").Visible = true;
        }
        #endregion
        
        #region PostButton_Click
        /***********************************************************************
        // PostButton_Click
        //
        /// <remarks>
        /// This event handler fires when the preview button is clicked.  It needs
        /// to show/hide the appropriate panels.
        /// </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        ************************************************************************/
        private void PostButton_Click (Object sender, EventArgs e) {
            Thread postToAdd = new Thread();
            ForumPost newPost = null;
            Control skin;
            RadioButtonList postIcon;
            int reportedPostID	= -1;
			ArrayList pmReceipients = null;
            
			// Is this an edit?
			if (PostMode == CreateEditPostMode.EditPost)
			{
				if (postReplyingTo.PostID != postReplyingTo.ParentID)
				{
					postToAdd.ParentID = postReplyingTo.ParentID;
				}

				postToAdd.PostLevel = postReplyingTo.PostLevel;
				postToAdd.SectionID = postReplyingTo.SectionID;

				// Get the current StickyDate
				Thread thread = Threads.GetThread(postReplyingTo.ThreadID);
				postToAdd.IsSticky = thread.IsSticky;
				postToAdd.StickyDate = thread.StickyDate;
			}
			else
				postToAdd.SectionID = postToAdd.ParentID = 0;

			// Only proceed if the post is valid
            //
            if (!Page.IsValid) 
                return;
			
            // Get the skin
            //
            skin = ((Control)sender).Parent;

            // Is the user allowed to add attachments?
            //
            if(!AllowAttachments)
				fileToUpload = null;

            // Get details on the post to be added
            //
            postToAdd.Username = user.Username;
            postToAdd.Subject = ((TextBox) skin.FindControl("PostSubject")).Text;
            postToAdd.IsLocked = ((CheckBox) skin.FindControl("IsLocked")).Checked;
			postToAdd.IsTracked = this.subscribeToThread.Checked;
			postToAdd.User = user;
            
            // Save if this post sould be seen as anonymous
            //
            if (isAnonymousPost.Visible) { 
                postToAdd.IsAnonymousPost = isAnonymousPost.Checked;
            } else { 
                postToAdd.IsAnonymousPost = false;
            }

            // Do we have a post icon?
            //
            postIcon =  (RadioButtonList) skin.FindControl("PostIcon");

            if (postIcon != null)
                if (postIcon.SelectedValue != "")
                    postToAdd.EmoticonID = int.Parse(postIcon.SelectedValue);

            // Set the body of the post
            //
            SetBodyContents(skin, postToAdd);

            // Set sticky post, but only change the setting if they have permission to do stickys
            //
			if(Permissions.ValidatePermissions( forum, Permission.Sticky, user ))
				SetSticky (skin, postToAdd);

            // Do we have edit notes?
            //
            if (PostMode == CreateEditPostMode.EditPost)
                SetEditNotes(skin, postToAdd);

            // Check for a reporting post. If so create a link to the offending post.
            if (PostMode == CreateEditPostMode.ReportingPost) 
            {
                reportedPostID = CSContext.Current.GetIntFromQueryString("ReportPostID",-1);
                if( reportedPostID != -1 ) 
                {

                    ForumPost reportedPost = Posts.GetPost( reportedPostID, CSContext.Current.UserID );

                    if( reportedPost != null ) 
                    {

                        postToAdd.Body += "<br /><br />";
                        postToAdd.Body += "<br />" + string.Format(ResourceManager.GetString("Moderate_PostsToModerateDescription"), reportedPost.Section.Name);
                        postToAdd.Body += "<br />" + ResourceManager.GetString("PostFlatView_PostDate") + reportedPost.PostDate.ToString(ResourceManager.GetString("Utility_CurrentTime_dateFormat")) + " " + string.Format( ResourceManager.GetString("Utility_CurrentTime_formatGMT"), CSContext.Current.SiteSettings.TimezoneOffset.ToString() );
						postToAdd.Body += "<br />" + ResourceManager.GetString("PostFlatView_PostSubject") + " <b>[url=\"" + Globals.GetSiteUrls().Post(reportedPost.PostID) + "#" + reportedPost.PostID + "\"]" + reportedPost.Subject + "[/url]</b>";
						postToAdd.Body += "<br />" + ResourceManager.GetString("PostFlatView_ReportingAuthor") + "[url=\"" + Globals.GetSiteUrls().UserProfile(reportedPost.User.UserID) + "\"]" + reportedPost.User.Username + "[/url]";

                        postToAdd.Body += "<hr>" + reportedPost.Body;
                    }
                }
            }

			// Attempt to get recipients
			string[] recipients = ((TextBox) skin.FindControl("To")).Text.Split(';');

			if (recipients.Length > 0) {
				pmReceipients = new ArrayList();

				pmReceipients.Add(user);

				foreach (string username in recipients) {
					try {
						User u = Users.FindUserByUsername(username);

						pmReceipients.Add(u);
					} 
					catch {}
				}
			}

			// See if we're removing the attachment
			if((PostMode == CreateEditPostMode.EditPost) && postToAdd.HasAttachment && deleteAttachment.Checked && AllowAttachments)
				Posts.DeleteAttachment(csContext.PostID);

			// If the post is a private message, add the 
            // users that are able to view the post
            if (PostMode == CreateEditPostMode.NewPrivateMessage) 
            {

                postToAdd.SectionID = 0;
                postToAdd.Section = Forums.GetForum(0);
				postToAdd.IsTracked = false;

                newPost = PrivateMessages.AddPrivateMessagePost(postToAdd, user, pmReceipients);

            } 
            else 
            {

                newPost = AddPost(postToAdd, PostMode, fileToUpload);

				if(PostMode == CreateEditPostMode.ReplyPrivateMessage)
				{
					postToAdd.IsTracked = false;

					// do we have recipients to send to?
					if (pmReceipients != null)
						PrivateMessages.AddRecipients(pmReceipients, newPost);
				}
			}

            // Redirect the user
            //
            if (newPost.IsApproved) 
            {

                switch (PostMode) 
                {
                    case CreateEditPostMode.NewPost:
						Context.Response.Redirect( Globals.GetSiteUrls().PostInPage(newPost.PostID, newPost.PostID), true );
                        break;

					case CreateEditPostMode.ReplyToPost:
						Thread thread = Threads.GetThread(newPost.ThreadID);
						int replies = thread.Replies;
						string url;
						if (replies > CSContext.Current.SiteSettings.PostsPerPage) 
						{
							int page;
				
							if (user.PostSortOrder == SortOrder.Descending)
								page = 1;
							else
								page = 1 + replies / CSContext.Current.SiteSettings.PostsPerPage;

							url = Globals.GetSiteUrls().PostPaged(newPost.PostID, page);
						} 
						else 
						{
							url = Globals.GetSiteUrls().PostInPage(newPost.PostID, newPost.PostID);
						}

						Context.Response.Redirect( url, true );
						break;

					case CreateEditPostMode.EditPost:
						Context.Response.Redirect( CSContext.Current.ReturnUrl, true );
						break;

                    case CreateEditPostMode.NewPrivateMessage:
						Context.Response.Redirect( Globals.GetSiteUrls().Post(newPost.PostID), true);
                        break;

                    case CreateEditPostMode.ReportingPost:
                        Context.Response.Redirect( Globals.GetSiteUrls().PostInPage(reportedPostID, reportedPostID), true);
                        break;

                    default:
						Context.Response.Redirect( Globals.GetSiteUrls().PostInPage(newPost.PostID, newPost.PostID), true);
                        break;
                }
            } 
            else 
            {
                //throw new CSException(CSExceptionType.PostPendingModeration);
				Context.Response.Redirect( ForumUrls.Instance().PostPendingModeration(newPost.Forum.SectionID) );
            }   
        }
        #endregion
        
        #region CancelButton_Click
        /***********************************************************************
        // CancelButton_Click
        //
        /// <remarks>
        /// Event raised when the user decides to cancel the post.
        /// </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        ************************************************************************/
        private void CancelButton_Click (Object sender, EventArgs e) {
            string redirectUrl = null;
			
            if ( csContext.PostID > 0 ) 
            {
                ForumPost post = Posts.GetPost(csContext.PostID, CSContext.Current.User.UserID);
                redirectUrl = Globals.GetSiteUrls().Post(post.PostID) + "#" + csContext.PostID;
            } 
            else 
            {
                // LN 6/24/04: Updated due to a bug reported
                // in forums.asp.net.
                if (csContext.ForumID == 0) 
                {
                    if (csContext.UserID > 0)
                        redirectUrl = Globals.GetSiteUrls().UserProfile(csContext.UserID, true);
                    else
                        redirectUrl = Globals.GetSiteUrls().UserPrivateMessages; 
                } 
                else 
                {
					if( csContext.ForumID > 0)
						redirectUrl = ForumUrls.Instance().Forum(csContext.ForumID);
					else
						redirectUrl = Globals.GetSiteUrls().ForumsHome;
                }
            }
			
            Page.Response.Redirect(redirectUrl);
            Page.Response.End();
        }
        #endregion

        #region PreviewButton_Click
        /***********************************************************************
        // PreviewButton_Click
        //

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -