Exemple #1
0
        /// <summary>
        /// Handles post moderation events/buttons.
        /// </summary>
        private void List_ItemCommand(object sender, RepeaterCommandEventArgs e)
        {
            // which command are we handling
            switch (e.CommandName.ToLower())
            {
            case "approve":
                // approve post
                DB.message_approve(e.CommandArgument);
                // re-bind data
                BindData();
                // tell user message was approved
                PageContext.AddLoadMessage(GetText("APPROVED"));
                // create subscriptions for topic
                CreateMail.CreateWatchEmail(e.CommandArgument);
                break;

            case "delete":
                // delete message
                DB.message_delete(e.CommandArgument, true, "", 1, true);
                // re-bind data
                BindData();
                // tell user message was deleted
                PageContext.AddLoadMessage(GetText("DELETED"));
                break;
            }

            // see if there are any items left...
            DataTable dt = DB.message_unapproved(PageContext.PageForumID);

            if (dt.Rows.Count == 0)
            {
                // nope -- redirect back to the moderate main...
                YafBuildLink.Redirect(ForumPages.moderate_index);
            }
        }
        /// <summary>
        /// Handles the PostReply click including: Replying, Editing and New post.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void PostReply_Click(object sender, System.EventArgs e)
        {
            if (!IsPostReplyVerified())
            {
                return;
            }
            if (IsPostReplyDelay())
            {
                return;
            }

            // update the last post time...
            Mession.LastPost = DateTime.Now.AddSeconds(30);

            long nMessageID = 0;

            if (TopicID != null)             // Reply to topic
            {
                nMessageID = PostReplyHandleReplyToTopic();
            }
            else if (EditTopicID != null)             // Edit existing post
            {
                nMessageID = PostReplyHandleEditPost();
            }
            else             // New post
            {
                nMessageID = PostReplyHandleNewPost();
            }

            // Check if message is approved
            bool bApproved = false;

            using (DataTable dt = DB.message_list(nMessageID))
                foreach (DataRow row in dt.Rows)
                {
                    bApproved = General.BinaryAnd(row["Flags"], MessageFlags.Flags.IsApproved);
                }

            // Create notification emails
            if (bApproved)
            {
                CreateMail.CreateWatchEmail(nMessageID);

                if (PageContext.ForumUploadAccess && TopicAttach.Checked)
                {
                    // redirect to the attachment page...
                    YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.attachments, "m={0}", nMessageID);
                }
                else
                {
                    // regular redirect...
                    YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.posts, "m={0}&#post{0}", nMessageID);
                }
            }
            else
            {
                // Tell user that his message will have to be approved by a moderator
                //PageContext.AddLoadMessage("Since you posted to a moderated forum, a forum moderator must approve your post before it will become visible.");
                string url = YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.topics, "f={0}", PageContext.PageForumID);

                if (YAF.Classes.Config.IsRainbow)
                {
                    YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.info, "i=1");
                }
                else
                {
                    YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.info, "i=1&url={0}", Server.UrlEncode(url));
                }
            }
        }
        private void QuickReply_Click(object sender, EventArgs e)
        {
            if (!PageContext.ForumReplyAccess ||
                (_topicFlags.IsLocked && !PageContext.ForumModeratorAccess))
            {
                YafBuildLink.AccessDenied();
            }

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

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

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

            // post message...

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

            TopicID = PageContext.PageTopicID;

            MessageFlags tFlags = new MessageFlags();

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

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

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

            bool bApproved = false;

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

            if (bApproved)
            {
                // Ederon : 7/26/2007
                // send new post notification to users watching this topic/forum
                CreateMail.CreateWatchEmail(nMessageID);
                // redirect to newly posted message
                YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.posts, "m={0}&#post{0}", nMessageID);
            }
            else
            {
                string url = YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.topics, "f={0}", PageContext.PageForumID);
                if (YAF.Classes.Config.IsRainbow)
                {
                    YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.info, "i=1");
                }
                else
                {
                    YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.info, "i=1&url={0}", Server.UrlEncode(url));
                }
            }
        }