Exemple #1
0
        private void ShowInfo(int _id)
        {
            BLL.Forum_Topic   bll   = new BLL.Forum_Topic();
            Model.Forum_Topic model = bll.GetModel(_id);
            //编写赋值操作Begin

            txtUserId.Text           = model.PostUserId.ToString();
            ddlBoardId.SelectedValue = model.BoardId.ToString();
            txtTopicTypeId.Text      = model.TopicTypeId.ToString();
            txtTitle.Text            = model.Title;
            txtViewCount.Text        = model.ViewCount.ToString();
            txtPostDatetime.Text     = model.PostDatetime.ToString();

            if (model.Digest == 1)
            {
                cblItem.Items[0].Selected = true;
            }
            if (model.Top == 1)
            {
                cblItem.Items[1].Selected = true;
            }
            if (model.Ban == 1)
            {
                cblItem.Items[2].Selected = true;
            }

            rblClose.SelectedValue = model.Close.ToString();

            modelPost = new BLL.Forum_Post(model.PostSubTable).GetModel(" First=1 and TopicId=" + _id + " ");

            txtMessage.Text = modelPost.Message;

            //编写赋值操作End
        }
Exemple #2
0
        //批量删除
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("plugin_forum_post", DTEnums.ActionEnum.Delete.ToString()); //检查权限
            int sucCount   = 0;
            int errorCount = 0;

            BLL.Forum_Post  bll      = new BLL.Forum_Post(subTableId);
            BLL.Forum_Topic bllTopic = new BLL.Forum_Topic();

            for (int i = 0; i < rptList.Items.Count; i++)
            {
                int id      = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
                int topicId = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidTopicId")).Value);

                CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                if (cb.Checked)
                {
                    //调用与前台一样的方法
                    bllTopic.DeleterReply(id.ToString(), topicId);

                    sucCount += 1;
                }
            }
            AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), "删除dt_Forum_Post_"
                        + sucCount + "条,失败" + errorCount + "条"); //记录日志
            JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("Post_list.aspx", "keywords={0}&subTableId={1}", this.keywords, this.subTableId.ToString()));
        }
Exemple #3
0
        //批量删除
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("plugin_forum_topic", DTEnums.ActionEnum.Delete.ToString()); //检查权限
            int sucCount   = 0;
            int errorCount = 0;

            BLL.Forum_Topic bll = new BLL.Forum_Topic();
            for (int i = 0; i < rptList.Items.Count; i++)
            {
                int      id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
                CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                if (cb.Checked)
                {
                    if (bll.Delete(id))
                    {
                        sucCount += 1;
                    }
                    else
                    {
                        errorCount += 1;
                    }
                }
            }
            AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), "删除dt_Forum_Topic"
                        + sucCount + "条,失败" + errorCount + "条"); //记录日志
            JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("topic_list.aspx", "keywords={0}", this.keywords));
        }
Exemple #4
0
        private bool DoAdd()
        {
            Model.Forum_Topic model = new Model.Forum_Topic();
            BLL.Forum_Topic   bll   = new BLL.Forum_Topic();
            //编写添加操作Begin

            model.BoardId = Convert.ToInt32(ddlBoardId.SelectedValue);
            //model.TopicTypeId = txtTopicTypeId.Text;
            model.Title = txtTitle.Text;

            if (string.IsNullOrEmpty(txtPostDatetime.Text))
            {
                model.PostDatetime = System.DateTime.Now;
            }
            else
            {
                model.PostDatetime = Convert.ToDateTime(txtPostDatetime.Text);
            }

            model.Digest = 0;
            model.Top    = 0;
            model.Ban    = 0;
            model.Close  = 0;

            if (cblItem.Items[0].Selected)
            {
                model.Digest = 1;
            }
            if (cblItem.Items[1].Selected)
            {
                model.Top = 1;
            }
            if (cblItem.Items[2].Selected)
            {
                model.Ban = 1;
            }

            if (rblClose.SelectedValue == "1")
            {
                model.Close = 1;
            }

            model.Message = txtMessage.Text;

            model.PostDatetime = System.DateTime.Now;
            model.PostUserId   = Convert.ToInt32(txtUserId.Text);

            int _post_id = 0, _subTable_id = 0;

            //编写添加操作End

            if (bll.Add(model, out _subTable_id, out _post_id) > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加dt_Forum_Topic:"
                            + model.Title); //记录日志
                return(true);
            }
            return(false);
        }
Exemple #5
0
        //设置操作
        protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            ChkAdminLevel("plugin_forum_topic", DTEnums.ActionEnum.Edit.ToString()); //检查权限
            int id = Convert.ToInt32(((HiddenField)e.Item.FindControl("hidId")).Value);

            BLL.Forum_Topic   bll   = new BLL.Forum_Topic();
            Model.Forum_Topic model = bll.GetModel(id);

            switch (e.CommandName)
            {
            case "lbtnIsBan":
                if (model.Ban == 1)
                {
                    bll.UpdateField(id, "[Ban]=0");
                }
                else
                {
                    bll.UpdateField(id, "[Ban]=1");
                }
                break;

            case "lbtnIsTop":
                if (model.Top == 1)
                {
                    bll.UpdateField(id, "[Top]=0");
                }
                else
                {
                    bll.UpdateField(id, "[Top]=1");
                }
                break;

            case "lbtnDigest":
                if (model.Digest == 1)
                {
                    bll.UpdateField(id, "[Digest]=0");
                }
                else
                {
                    bll.UpdateField(id, "[Digest]=1");
                }
                break;

            case "lbtnClose":
                if (model.Close == 1)
                {
                    bll.UpdateField(id, "[Close]=0");
                }
                else
                {
                    bll.UpdateField(id, "[Close]=1");
                }
                break;
            }

            this.RptBind(" 1=1 " + CombSqlTxt(keywords), " id desc ");//添加where子句和order子句
        }
Exemple #6
0
        private void RptBind(string _strWhere, string _orderby)
        {
            this.page        = DTRequest.GetQueryInt("page", 1);
            txtKeywords.Text = this.keywords;
            BLL.Forum_Topic bll = new BLL.Forum_Topic();
            this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount);
            this.rptList.DataBind();

            //绑定页码
            txtPageNum.Text = this.pageSize.ToString();
            string pageUrl = Utils.CombUrlTxt("topic_list.aspx", "keywords={0}&page={1}", this.keywords, "__id__");

            PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8);
        }
Exemple #7
0
        /// <summary>
        /// 删除一条数据,所有标题和回贴都清掉
        /// </summary>
        public bool Delete(int Id)
        {
            //循环清除

            BLL.Forum_Topic bllTopic = new Forum_Topic();

            List <Model.Forum_Topic> listTopic = new BLL.Forum_Topic().GetModelList(" 1=1 ");

            foreach (Model.Forum_Topic item in listTopic)
            {
                bllTopic.Delete(item.Id);
            }

            return(dal.Delete(Id));
        }
Exemple #8
0
        /// <summary>
        /// 重写虚方法,此方法在Init事件执行
        /// </summary>
        protected override void InitPage()
        {
            topic_id = DTRequest.GetQueryInt("topic_id", 0);
            page     = DTRequest.GetQueryInt("page", 1);

            if (page < 0)
            {
                page = 900000;
            }

            if (topic_id != 0)
            {
                BLL.Forum_Topic bllTopic = new BLL.Forum_Topic();


                modelTopic = bllTopic.GetModel(topic_id);

                if (modelTopic == null)
                {
                    HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("我的天,贴子没啦!")));

                    return;

                    //modelTopic = new Model.Forum_Topic();
                }

                int _groupId = 0;

                if (modelUserExtended != null)
                {
                    _groupId = modelUserExtended.GroupId;
                }

                if (!BLL.Forum_BoardPermission.CheckPermission(modelTopic.BoardId + "|" + _groupId, "VisitTopic"))
                {
                    HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("不好意思,目前您还没有权限进入!")));
                    return;
                }


                bool bolViewCount = false;

                //禁止过于频繁的过度刷新
                if (HttpContext.Current.Session["SESSION_FORUM_TOPIC"] == null)
                {
                    HttpContext.Current.Session["SESSION_FORUM_TOPIC"] = topic_id;

                    bolViewCount = true;
                }
                else if (Convert.ToInt32(HttpContext.Current.Session["SESSION_FORUM_TOPIC"]) != topic_id)
                {
                    bolViewCount = true;
                }

                if (bolViewCount)
                {
                    bllTopic.UpdateField(topic_id, "ViewCount=ViewCount+1");
                }

                board_id = modelTopic.BoardId;
            }

            modelBoard = new BLL.Forum_Board().GetModel(board_id);

            if (modelBoard == null)
            {
                modelBoard = new Model.Forum_Board();
            }

            drPostList = new BLL.Forum_Post(modelTopic.PostSubTable).GetList(20, page, "", topic_id, "id asc", out totalcount).Tables[0].Select(" 1=1 ", "id asc");

            pagelist = OutPageList(20, page, totalcount, linkurl("forum_topic", topic_id, "__id__"), 10);

            //权限
            bolOperate = CheckOperate(board_id);
        }
Exemple #9
0
        private void editor(HttpContext context)
        {
            string _v = verify_code(context, vc);

            if (_v != "success")
            {
                JsonHelper.WriteJson(context, new
                {
                    error       = 1,
                    description = _v
                });
            }

            if (string.IsNullOrEmpty(message))
            {
                JsonHelper.WriteJson(context, new
                {
                    error       = 1,
                    description = "内容不写你打算做什么呢!"
                });
            }

            if (!BLL.Forum_BoardPermission.CheckPermission(board_id + "|" + modelUser.GroupId, "UpdateMyselfReply"))
            {
                JsonHelper.WriteJson(context, new
                {
                    error       = 1,
                    description = "您当前还没有权限哦!"
                });
            }

            message = FilterWord(message);

            Model.Forum_Topic modelTopic = new BLL.Forum_Topic().GetModel(topic_id);

            foreach (string item in context.Request.Form.AllKeys)
            {
                if (item.ToLower().IndexOf("attachment_description_") != -1)
                {
                    string strDescription = context.Request.Form[item].ToString();

                    string _id = item.ToLower().Replace("attachment_description_", "").Replace("'", "");

                    new BLL.Forum_Attachment().UpdateField("Id=" + _id, " Description='" + strDescription + "' ");
                }
            }


            //上传图片的张数
            int attachment_count = new BLL.Forum_Attachment().GetCount(" [BoardId]=" + board_id + " and [UserId]=" + modelUser.UserId + " and  [PostId]=" + post_id + " ");

            Model.Forum_Post modelPost = new BLL.Forum_Post(modelTopic.PostSubTable).GetModel(post_id);

            modelPost.Signature = signature;
            modelPost.Url       = autoUrl;
            modelPost.Message   = message;

            modelPost.Attachment = attachment_count;

            new BLL.Forum_Post(modelTopic.PostSubTable).Update(modelPost);

            JsonHelper.WriteJson(context, new
            {
                tid  = modelTopic.Id,
                turl = turl
            });
        }
Exemple #10
0
        private void reply(HttpContext context)
        {
            string _v = verify_code(context, vc);

            if (_v != "success")
            {
                JsonHelper.WriteJson(context, new
                {
                    error       = 1,
                    description = _v
                });
            }


            if (string.IsNullOrEmpty(message))
            {
                JsonHelper.WriteJson(context, new
                {
                    error       = 1,
                    description = "内容不写你打算做什么呢!"
                });
            }

            if (!BLL.Forum_BoardPermission.CheckPermission(board_id + "|" + modelUser.GroupId, "PostReply"))
            {
                JsonHelper.WriteJson(context, new
                {
                    error       = 1,
                    description = "您当前还没有权限哦!"
                });
            }

            message = FilterWord(message);

            Model.Forum_Topic modelTopic = new BLL.Forum_Topic().GetModel(topic_id);

            int _post_id = new BLL.Forum_PostId().Add(new Model.Forum_PostId {
                TopicId = topic_id
            });

            int attachment_count = 0;

            foreach (string item in context.Request.Form.AllKeys)
            {
                if (item.ToLower().IndexOf("attachment_description_") != -1)
                {
                    attachment_count += 1;

                    string strDescription = context.Request.Form[item].ToString().Replace("'", "");

                    string _id = item.ToLower().Replace("attachment_description_", "").Replace("'", "");

                    new BLL.Forum_Attachment().UpdateField("Id=" + _id, " [TopicId]=" + modelTopic.Id + ",[PostId]=" + _post_id + " , Description='" + strDescription + "' ");
                }
            }

            //int attachment_count = new BLL.Forum_Attachment().UpdateField(" [BoardId]=" + board_id + " and [UserId]=" + modelUser.UserId + " and  [PostId]=0 ", " [TopicId]=" + modelTopic.Id + ",[PostId]=" + _post_id + " ");

            Model.Forum_Post modelPost = new Model.Forum_Post();

            modelPost.BoardId   = modelTopic.BoardId;
            modelPost.Title     = modelTopic.Title;
            modelPost.Signature = signature;
            modelPost.Url       = autoUrl;
            modelPost.Message   = message;
            modelPost.TopicId   = topic_id;

            modelPost.PostUserId   = modelUser.UserId;
            modelPost.PostUsername = modelUser.UserName;
            modelPost.PostNickname = modelUser.Nickname;
            modelPost.PostDateTime = System.DateTime.Now;
            modelPost.Id           = _post_id;
            modelPost.Attachment   = attachment_count;

            BLL.Forum_Post bll = new BLL.Forum_Post(modelTopic.PostSubTable);

            //引用
            if (post_id != 0)
            {
                Model.Forum_Post modelQuotePost = bll.GetModel(post_id);

                if (modelQuotePost != null)
                {
                    if (string.IsNullOrEmpty(modelQuotePost.QuotePostIds))
                    {
                        modelPost.QuotePostIds = modelQuotePost.Id.ToString();
                    }
                    else
                    {
                        //拼接
                        modelPost.QuotePostIds = modelQuotePost.QuotePostIds + "," + modelQuotePost.Id.ToString();
                    }

                    modelPost.QuoteUserId   = modelQuotePost.PostUserId;
                    modelPost.QuoteNickname = modelQuotePost.PostNickname;
                    modelPost.QuoteMessage  = modelQuotePost.Message;
                }
            }

            bll.Add(modelTopic, modelPost);

            HttpContext.Current.Session["SESSION_USER_EXTENDED"] = new BLL.Forum_UserExtended().SetGroupId(modelUser);

            JsonHelper.WriteJson(context, new
            {
                tid  = modelTopic.Id,
                turl = new DTcms.Web.UI.BasePage().linkurl("forum_topic", modelTopic.Id, -_post_id) + "#reply_" + _post_id
            });
        }
Exemple #11
0
        private bool DoEdit(int _id)
        {
            bool result = false;

            BLL.Forum_Topic   bll   = new BLL.Forum_Topic();
            Model.Forum_Topic model = bll.GetModel(_id);


            //编写编辑操作Begin

            model.BoardId = Convert.ToInt32(ddlBoardId.SelectedValue);
            //model.TopicTypeId = txtTopicTypeId.Text;
            model.Title        = txtTitle.Text;
            model.PostDatetime = Convert.ToDateTime(txtPostDatetime.Text);


            model.Digest = 0;
            model.Top    = 0;
            model.Ban    = 0;
            model.Close  = 0;

            if (cblItem.Items[0].Selected)
            {
                model.Digest = 1;
            }
            if (cblItem.Items[1].Selected)
            {
                model.Top = 1;
            }
            if (cblItem.Items[2].Selected)
            {
                model.Ban = 1;
            }

            if (rblClose.SelectedValue == "1")
            {
                model.Close = 1;
            }

            model.Message = txtMessage.Text;

            modelPost         = new BLL.Forum_Post(model.PostSubTable).GetModel(" First=1 and TopicId=" + _id + " ");
            modelPost.Message = txtMessage.Text;


            //编写编辑操作End

            model.PostUserId   = modelUser.id;
            model.PostUsername = modelUser.user_name;
            model.PostNickname = modelUser.nick_name;

            modelPost.PostUserId   = modelUser.id;
            modelPost.PostUsername = modelUser.user_name;
            modelPost.PostNickname = modelUser.nick_name;

            if (bll.Update(model, modelPost))
            {
                AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改管理员:" + model.Title); //记录日志
                result = true;
            }

            return(result);
        }