Exemple #1
0
        public static void DeleteForumTopicTypes(string typeidlist)
        {
            string[] array = typeidlist.Split(',');
            SortedList <int, string> sortedList = new SortedList <int, string>();

            sortedList = Caches.GetTopicTypeArray();
            DataTable forumListForDataTable = Forums.GetForumListForDataTable();

            foreach (DataRow dataRow in forumListForDataTable.Rows)
            {
                if (!(dataRow["topictypes"].ToString() == ""))
                {
                    string   text   = dataRow["topictypes"].ToString();
                    string[] array2 = array;
                    for (int i = 0; i < array2.Length; i++)
                    {
                        string text2 = array2[i];
                        text = text.Replace(text2 + "," + sortedList[int.Parse(text2)].ToString() + ",0|", "");
                        text = text.Replace(text2 + "," + sortedList[int.Parse(text2)].ToString() + ",1|", "");
                        Discuz.Data.Topics.ClearTopicType(int.Parse(text2));
                    }
                    ForumInfo forumInfo = Forums.GetForumInfo(int.Parse(dataRow["fid"].ToString()));
                    forumInfo.Topictypes = text;
                    AdminForums.UpdateForumInfo(forumInfo);
                }
            }
        }
Exemple #2
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);
            }
        }