Exemplo n.º 1
0
        /// <summary>
        /// 获取主题帖信息
        /// </summary>
        /// <param name="admininfo"></param>
        /// <returns></returns>
        public PostInfo GetPostAndTopic(AdminGroupInfo admininfo)
        {
            PostInfo postinfo = new PostInfo();

            //如果帖子id和主题id都没有指定
            if (postid == -1 && topicid == -1)
            {
                AddErrLine("无效的主题ID");
                return(postinfo);
            }

            //如果帖子id被指定
            if (postid != -1)
            {
                postinfo = Posts.GetPostInfo(topicid, postid);
                if (postinfo == null)
                {
                    AddErrLine("无效的帖子ID");
                    return(postinfo);
                }
                if (topicid != postinfo.Tid)
                {
                    AddErrLine("主题ID无效");
                    return(postinfo);
                }

                //如果帖子作者是禁止发言,禁止访问,禁止IP用户组或者帖子invisible属性小于0,则不允许引用及回复


                if (!string.IsNullOrEmpty(DNTRequest.GetString("quote")))
                {
                    if (Utils.InArray(Users.GetShortUserInfo(postinfo.Posterid).Groupid.ToString(), "4,5,6") || postinfo.Invisible != 0)
                    {
                        postinfo.Message = "**** 作者被禁止或删除 内容自动屏蔽 ****";
                    }

                    if ((postinfo.Message.IndexOf("[hide]") > -1) && (postinfo.Message.IndexOf("[/hide]") > -1))
                    {
                        message = string.Format("[quote] 原帖由 [b]{0}[/b] 于 {1} 发表\r\n ***隐藏帖*** [/quote]", postinfo.Poster, postinfo.Postdatetime);
                    }
                    //message = "[quote] 原帖由 [b]" + postinfo.Poster + "[/b] 于 " + postinfo.Postdatetime + " 发表\r\n ***隐藏帖*** [/quote]";
                    else
                    {
                        message = string.Format("[quote]{0}\r\n [color=#999999]{1} 发表于 {2} [/color][url={3}#{4}][img]{5}images/common/back.gif[/img][/url][/size][/quote]"
                                                , UBB.ClearAttachUBB(Utils.GetSubString(postinfo.Message, 200, "......")), postinfo.Poster, postinfo.Postdatetime, DNTRequest.GetUrlReferrer(), postid, Utils.GetRootUrl(forumpath));
                    }
                }
            }

            // 获取该主题的信息
            topic = Topics.GetTopicInfo(topicid);
            // 如果该主题不存在
            if (topic == null)
            {
                AddErrLine("不存在的主题ID");
                return(postinfo);
            }

            topictitle = topic.Title.Trim();
            pagetitle  = topictitle;
            forumid    = topic.Fid;

            // 如果当前用户非管理员并且该主题已关闭,不允许用户发帖
            if ((admininfo == null || !Moderators.IsModer(admininfo.Admingid, userid, forumid)) && topic.Closed == 1)
            {
                AddErrLine("主题已关闭无法回复");
                return(postinfo);
            }

            if (topic.Readperm > usergroupinfo.Readaccess && topic.Posterid != userid && useradminid != 1)
            {
                if (forum.Moderators != null && !Utils.InArray(username, forum.Moderators.Split(',')))
                {
                    AddErrLine("本主题阅读权限为: " + topic.Readperm + ", 您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 阅读权限不够");
                }
            }

            return(postinfo);
        }
Exemplo n.º 2
0
        public Post GetPostAndTopic(AdminGroup admininfo)
        {
            var pi = new Post();

            if (this.postid == -1 && this.topicid == -1)
            {
                base.AddErrLine("无效的主题ID");
                return(pi);
            }
            if (this.postid != -1)
            {
                //pi = Posts.GetPostInfo(this.topicid, this.postid);
                pi = Post.FindByID(postid);
                if (pi == null)
                {
                    base.AddErrLine("无效的帖子ID");
                    return(pi);
                }
                if (this.topicid != pi.Tid)
                {
                    base.AddErrLine("主题ID无效");
                    return(pi);
                }
                if (!string.IsNullOrEmpty(DNTRequest.GetString("quote")))
                {
                    var msg = pi.Message;
                    if (pi.Invisible != 0)
                    {
                        msg = "**** 作者被禁止或删除 内容自动屏蔽 ****";
                    }
                    else
                    {
                        string str = (pi.PosterID > 0) ? BBX.Entity.User.FindByID(pi.PosterID).GroupID.ToString() : null;
                        if (Utils.InArray(str, "4.5.6"))
                        {
                            msg = "**** 作者被禁止或删除 内容自动屏蔽 ****";
                        }
                    }
                    if (msg.IndexOf("[hide]") > -1 && msg.IndexOf("[/hide]") > -1)
                    {
                        this.message = string.Format("[quote] 原帖由 [b]{0}[/b] 于 {1} 发表\r\n ***隐藏帖*** [/quote]", pi.Poster, pi.PostDateTime.ToFullString());
                    }
                    else
                    {
                        this.message = string.Format("[quote]{0}\r\n [color=#999999]{1} 发表于 {2} [/color][url={5}showtopic.aspx?topicid={3}&postid={4}#{4}][img]{5}images/common/back.gif[/img][/url][/size][/quote]", new object[]
                        {
                            UBB.ClearAttachUBB(Utils.GetSubString(Regex.Replace(msg, "\\[quote\\](.|\\n)+\\[/quote\\]", "", RegexOptions.Multiline), 200, "......")),
                            pi.Poster,
                            pi.PostDateTime,
                            this.topicid,
                            this.postid,
                            Utils.GetRootUrl(this.forumpath)
                        });
                    }
                    pi.Html = msg;
                }
            }
            //this.topic = Topics.GetTopicInfo(this.topicid);
            this.topic = Topic.FindByID(this.topicid);
            if (this.topic == null)
            {
                base.AddErrLine("不存在的主题ID");
                return(pi);
            }
            this.topictitle = this.topic.Title.Trim();
            this.pagetitle  = this.topictitle;
            this.forumid    = this.topic.Fid;
            if ((admininfo == null || !Moderators.IsModer(admininfo.ID, this.userid, this.forumid)) && this.topic.Closed == 1)
            {
                base.AddErrLine("主题已关闭无法回复");
                return(pi);
            }
            if (this.topic.ReadPerm > this.usergroupinfo.Readaccess && this.topic.PosterID != this.userid && this.useradminid != 1 && this.forum.Moderators != null && !Utils.InArray(this.username, this.forum.Moderators.Split(',')))
            {
                base.AddErrLine("本主题阅读权限为: " + this.topic.ReadPerm + ", 您当前的身份 \"" + this.usergroupinfo.GroupTitle + "\" 阅读权限不够");
            }
            return(pi);
        }