<?php
/*
群组成员：pre_forum_groupuser
*/
if($start <= 1){
	truncatetable('forum_groupuser');
}
$maxmtagid = $xc->db['source']->result($xc->db['source']->query("SELECT max(id) FROM {$source_tablepre}cmembers"), 0);
if($start < $maxmtagid){
	$converted = 1;
}
$query = $xc->db['source']->query("SELECT * FROM {$source_tablepre}cmembers WHERE id >= $start AND id < $start + $rpp") or dexit();
while ($pwcmember = $xc->db['source']->fetch_array($query)) {
	$pwcmember		=	daddslashes($pwcmember);
	$pwcname		=	$xc->db['source']->result($xc->db['source']->query("SELECT cname FROM {$source_tablepre}colonys WHERE `id`={$pwcmember[colonyid]}"),0);
	$fid			=	$xc->db['discuz']->result($xc->db['discuz']->query("SELECT fid FROM {$discuz_tablepre}forum_forum WHERE status=3 AND name='$pwcname'"));
	$uid			=	$pwcmember['uid'];
	$username		=	$pwcmember['username'];
	$level			=	$pwcmember['ifadmin'] == 1 ? 1 : 4;							//成员等级(0:待审核 1:群主 2:副群主 3:明星成员 4:普通成员)
	$threads		=	0;							//成员主题数
	$replies		=	0;							//成员回复数
	$joindateline	=	time();						//加入时间
	$lastupdate		=	time();						//成员最后活动时间
	$privacy		=	0;							//成员隐私设置

	$field1	=	array('fid','uid','username','level','threads','replies','joindateline','lastupdate','privacy');
	$query1	=	getinsertsql("{$discuz_tablepre}forum_groupuser", $field1);

	if ($xc->db['discuz']->query($query1)) {
		$convertedrows ++;
	} else {
		reportlog("无法转换群组会员 fid = $fid ，SQL 语句如下 ：<br><textarea rows=\"3\" style=\"width: 100%;\">".$sql."</textarea>");
	}
	$converted = 1;
	$totalrows ++;
	$url = 'index.php?mod=dealdata&step='.$step.'&start='.($pwcmember['id']+1).'&stay='.$stay.'&totalrows='.$totalrows.'&convertedrows='.$convertedrows.'&sqlfilenum='.$sqlfilenum;
	file_put_contents(XCONVERT_ROOT.'./cache/lock/progress_'.$step.".txt", $url);
}
?>
