示例#1
0
 /// <summary>
 /// 发表评论
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (this.Page.IsValid)
     {
         if (!buser.CheckLogin())
         {
             function.WriteErrMsg("只有登陆用户才能发表评论!");
         }
         string    UserID  = HttpContext.Current.Request.Cookies["UserState"]["UserID"];
         M_Comment comment = new M_Comment();
         comment.CommentID   = 0;
         comment.GeneralID   = DataConverter.CLng(this.HdnItemID.Value);
         m_ItemID            = DataConverter.CLng(this.HdnItemID.Value);
         comment.UserID      = DataConverter.CLng(UserID);
         comment.Title       = this.HdnTitle.Value;
         m_Title             = this.HdnTitle.Value;
         comment.Contents    = this.TxtContents.Text.Trim();
         comment.Score       = DataConverter.CLng(this.DDLScore.SelectedValue);
         comment.PK          = DataConverter.CBool(this.RBLPK.SelectedValue);
         comment.Audited     = true;
         comment.CommentTime = DateTime.Now;
         bcomment.Add(comment);
         Response.Write("<script language=\"javascript\" type=\"text/javascript\">alert(\"评论添加成功\")</script>");
         RepBind();
     }
 }
 //-------------Tools
 private void AddComment(M_Comment cmtMod)
 {
     cmtBll.Add(cmtMod);
     if (SiteConfig.UserConfig.CommentRule > 0 && cmtMod.UserID > 0)//增加积分
     {
         buser.ChangeVirtualMoney(cmtMod.UserID, new M_UserExpHis()
         {
             score     = SiteConfig.UserConfig.CommentRule,
             detail    = "发表评论增加积分",
             ScoreType = (int)M_UserExpHis.SType.Point
         });
     }
 }
示例#3
0
        // 发表评论
        protected string SenderComm()
        {
            M_UserInfo mu = buser.GetLogin(false);

            if (!ZoomlaSecurityCenter.VCodeCheck(Request.Form["VCode_hid"], Request.Form["VCode"]))//Need
            {
                return("-1");
            }
            M_Comment comment = new M_Comment();

            comment.CommentID = 0;
            comment.GeneralID = ItemID;
            M_CommonData cdata = bll.GetCommonData(ItemID);

            if (cdata.IsComm != 1)
            {
                return("-4");
            }
            //GetNodePreate(cdata.NodeID);
            M_Node mnode = nodeBll.GetNodeXML(cdata.NodeID);

            if (mnode.CommentType.Equals("2") && !buser.CheckLogin())
            {
                return("-2");
            }

            comment.UserID = mu.UserID;//支持一个支持匿名方法
            comment.Title  = BaseClass.CheckInjection(this.HdnTitle.Value);
            if (string.IsNullOrEmpty(Request.Form["content"]))
            {
                return("-3");
            }
            comment.Contents = BaseClass.CheckInjection(sll.ProcessSen(Request.Form["content"]));
            comment.Audited  = false;
            DataTable dts = bcomment.SeachComment_ByGeneralID2(ItemID);

            if (mnode.Purview != null && mnode.Purview != "")
            {
                string    Purview = mnode.Purview;
                DataTable AuitDT  = nodeBll.GetNodeAuitDT(mnode.Purview);
                if (AuitDT == null && AuitDT.Rows.Count <= 0)
                {
                    return("-4");
                }
                DataRow auitdr  = AuitDT.Rows[0];
                string  forum_v = auitdr["forum"].ToString();
                if (string.IsNullOrEmpty(forum_v))
                {
                    return("-4");
                }
                string[] forumarr = forum_v.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                if (!forumarr.Contains("1"))//不允许评论
                {
                    return("-4");
                }
                if (!forumarr.Contains("2"))//不需要审核
                {
                    comment.Audited = true;
                }
                if (forumarr.Contains("3")) //一个文章只评论一次
                {
                    if (bcomment.SearchByUser(mu.UserID, cdata.NodeID).Rows.Count > 0)
                    {
                        return("-5");
                    }
                }
            }
            comment.Status      = 0;
            comment.Score       = DataConverter.CLng(Request.Form["Score"]);
            comment.CommentTime = DateTime.Now;
            DataTable dt = bcomment.SeachComment_ByGeneralID2(ItemID);

            if (bcomment.Add(comment))
            {
                if (SiteConfig.UserConfig.CommentRule > 0 && mu.UserID > 0)//增加积分
                {
                    buser.ChangeVirtualMoney(mu.UserID, new M_UserExpHis()
                    {
                        score     = SiteConfig.UserConfig.CommentRule,
                        detail    = "发表评论增加积分",
                        ScoreType = (int)M_UserExpHis.SType.Point
                    });
                }
            }
            return(comment.Audited ? "2" : "1");
        }