Ejemplo n.º 1
0
        //将得到的主题列表中加入主题类型名称字段
        public static DataTable GetTopicTypeName(DataTable topiclist)
        {
            DataColumn dc = new DataColumn();

            dc.ColumnName   = "topictypename";
            dc.DataType     = Type.GetType("System.String");
            dc.DefaultValue = "";
            dc.AllowDBNull  = true;
            topiclist.Columns.Add(dc);

            SortedList <int, string> topictypearray = Caches.GetTopicTypeArray();
            object typictypename = null;

            foreach (DataRow dr in topiclist.Rows)
            {
                typictypename       = topictypearray[Int32.Parse(dr["typeid"].ToString())];
                dr["topictypename"] = (typictypename != null && typictypename.ToString().Trim() != "") ? "[" + typictypename.ToString().Trim() + "]" : "";
            }
            return(topiclist);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 加载主题列表附加信息
        /// </summary>
        /// <param name="fid">板块ID</param>
        /// <param name="autocloseTime">自动关闭时间</param>
        /// <param name="topicTypePrefix">主题分类前缀</param>
        /// <param name="list">主题列表</param>
        private static void LoadTopicListExtraInfo(int autoCloseTime, int topicTypePrefix, int newMinutes, int hotReplyNumber, Discuz.Common.Generic.List <TopicInfo> list)
        {
            SortedList <int, string> topicTypeList = Caches.GetTopicTypeArray();
            StringBuilder            closedIds     = new StringBuilder();

            foreach (TopicInfo topic in list)
            {
                if (topic.Closed == 0 && autoCloseTime > 0 && Utils.StrDateDiffHours(topic.Postdatetime, autoCloseTime * 24) > 0)
                {
                    closedIds.Append(topic.Tid.ToString());
                    closedIds.Append(",");
                }
                LoadTopicFolder(autoCloseTime, newMinutes, hotReplyNumber, topic);
                LoadTopicHighlightTitle(topic);
                LoadTopicType(topicTypePrefix, topicTypeList, topic);
            }

            if (closedIds.Length > 0)
            {
                TopicAdmins.SetClose(closedIds.ToString().TrimEnd(','), 1);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 删除所选的主题分类
        /// </summary>
        /// <param name="typeidlist"></param>
        public static void DeleteForumTopicTypes(string typeidlist)
        {
            //取得ID的数组
            string[] ids = typeidlist.Split(',');

            //取得主题分类的缓存
            Discuz.Common.Generic.SortedList <int, string> topictypearray = new Discuz.Common.Generic.SortedList <int, string>();
            topictypearray = Caches.GetTopicTypeArray();

            //取得版块的fid,topictypes字段

            DataTable dt = Forums.GetForumListForDataTable();

            //处理每一个版块
            foreach (DataRow dr in dt.Rows)
            {
                //如果版块的主题分类字段为空(topictypes==""),则处理下一个
                if (dr["topictypes"].ToString() == "")
                {
                    continue;
                }

                string topictypes = dr["topictypes"].ToString();
                //处理每一个要删除的ID
                foreach (string id in ids)
                {
                    //将删除的ID拼成相应的格式串后,将原来的剔除掉,形成一个新的主题分类的字段
                    topictypes = topictypes.Replace(id + "," + topictypearray[Int32.Parse(id)].ToString() + ",0|", "");
                    topictypes = topictypes.Replace(id + "," + topictypearray[Int32.Parse(id)].ToString() + ",1|", "");
                    //将帖子列表(dnt_topics)中typeid为当前要删除的Id更新为0
                    Data.Topics.ClearTopicType(int.Parse(id));
                }
                //用剔除了要删除的主题ID的主题列表值更新数据库
                ForumInfo forumInfo = Forums.GetForumInfo(int.Parse(dr["fid"].ToString()));
                forumInfo.Topictypes = topictypes;
                AdminForums.UpdateForumInfo(forumInfo);
            }
        }