<?php
//4、转换主题分类
/*
truncatetable('forum_threadclass');

$query = $xc->db['source']->query("SELECT * FROM {$source_tablepre}topictypes") or die("检索数据表 '{$source_tablepre}topictypes' 错误！请将表 '{$source_tablepre}topictypes' 字段类型为 nText 的改为 Text 类型。");

while ($t = $xc->db['source']->fetch_assoc($query)) {

	$t = daddslashes(array_change_key_case($t));

	$typeid = $t['typeid'];
	$fid	= 0;
	$name	= $t['name'];
	$displayorder = $t['displayorder'];
	$icon	='';
	$moderators	= '';

	$fields1	= array('typeid', 'fid', 'name', 'displayorder', 'icon', 'moderators');
	$query1		= getinsertsql("{$discuz_tablepre}forum_threadclass", $fields1);
	if ($xc->db['discuz']->query($query1)) {
		$convertedrows ++;
	} else {
		reportlog("插入 DZ 主题分类数据出错 typeid = $typeid name = $name");
	}
	$totalrows ++;
}
*/
$query = $xc->db['discuz']->query("SELECT fid FROM {$discuz_tablepre}forum_forumfield");
while ($result = $xc->db['discuz']->fetch_array($query)) {
	$fid = $result['fid'];
	$types		= array();
	$typequery	= $xc->db['discuz']->query("SELECT * FROM {$discuz_tablepre}forum_threadclass WHERE fid = $fid");
	while ($type = $xc->db['discuz']->fetch_array($typequery)) {
		$types[$type['typeid']] = $type['name'];
	}
	$types = array_filter($types);
	if($types) {
		$threadtypes = daddslashes(serialize(array
							(
							'status' => 1,
							'required' => 1,
							'listable' => 1,
							'prefix' => 1,
							'types' => $types,
							'flat' => $types
							)));
	} else {
		$threadtypes = '';
	}
	$xc->db['discuz']->query("UPDATE {$discuz_tablepre}forum_forumfield SET threadtypes='$threadtypes' WHERE fid = $fid");
}

?>
