<?php
/*
pre_forum_poll
pre_forum_polloption
*/

if($start <= 1){
	truncatetable('forum_poll');
	truncatetable('forum_polloption');
}

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

while ($p = $xc->db['source']->fetch_assoc($query)) {
	$p = daddslashes(array_change_key_case($p));

	$tid		= $p['tid'];
	$multiple	= $p['multiple'];
	$visible	= $p['visible'];
	$maxchoices = $p['maxchoices'];
	$expiration = timetounix($p['expiration']);
	$pollpreview= '';
	$voters		= count(explode("\r\n",$p['voternames']));
	
	$fields1 = array('tid', 'multiple', 'visible', 'maxchoices', 'expiration', 'voters');
	$query1 = getinsertsql("{$discuz_tablepre}forum_poll", $fields1);
	if ($xc->db['discuz']->query($query1)) {
		$convertedrows ++;
	} else {
		reportlog("插入 DZ 用户组基本数据出错 groupid = $groupid grouptitle = $grouptitle");
	}
	$totalrows ++;
}

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

while ($op = $xc->db['source']->fetch_assoc($query_2)) {
	
	$op = daddslashes(array_change_key_case($op));

	$polloptionid	=	$op['polloptionid'];
	$tid			=	$op['tid'];
	$votes			=	$op['votes'];
	$displayorder	=	$op['displayorder'];
	$polloption		=	$op['polloption'];
	$names			=	explode("\t", $op['voternames']);
	$voterids		=	'';
	for($i=0; $i<count($names); $i++){
		$voterids	.=	getuid($names[$i])."\t";
	}
		
	$fields_3 = array('polloptionid', 'tid', 'votes', 'displayorder', 'polloption', 'voterids');
	$query_3 = getinsertsql("{$discuz_tablepre}forum_polloption", $fields_3);
	if ($xc->db['discuz']->query($query_3)) {
		$convertedrows ++;
	} else {
		reportlog("插入 DZ 用户组基本数据出错 groupid = $groupid grouptitle = $grouptitle");
	}
	$totalrows ++;
}

?>