public function stepPostThanks($start, array $options)
{
$options = array_merge(array(
'limit' => 200,
'max' => false
), $options);
$sDb = $this->_sourceDb;
$prefix = $this->_prefix;
/* @var $model PostThanksImporter_Model_Import */
$model = $this->_importModel;
if ($options['max'] === false)
{
$options['max'] = $sDb->fetchOne('
SELECT MAX(entryid)
FROM ' . $prefix . 'dbtech_thanks_entry
');
}
$postThanks = $sDb->fetchAll($sDb->limit(
'
SELECT pt.*, post.userid as content_userid
FROM ' . $prefix . 'dbtech_thanks_entry AS pt
LEFT JOIN ' . $prefix . 'post AS post ON (post.postid = pt.contentid)
WHERE pt.entryid > ?
ORDER BY pt.entryid
', $options['limit']
), $start);
if (!$postThanks)
{
return true;
}
$next = 0;
$total = 0;
$userIds = array();
$postIds = array();
foreach ($postThanks AS $thanks)
{
$userIds[] = $thanks['userid'];
$userIds[] = $thanks['content_userid'];
$postIds[] = $thanks['contentid'];
}
$userIdMap = $model->getImportContentMap('user', $userIds);
$postIdMap = $model->getImportContentMap('post', $postIds);
XenForo_Db::beginTransaction();
foreach ($postThanks AS $thanks)
{
$next = $thanks['entryid'];
$likeUserId = $this->_mapLookUp($userIdMap, $thanks['userid']);
$contentUserId = $this->_mapLookUp($userIdMap, $thanks['content_userid']);
$postId = $this->_mapLookUp($postIdMap, $thanks['contentid']);
if (!$likeUserId OR !$contentUserId OR !$postId)
{
continue;
}
$model->importPostThanks($postId, $contentUserId, $likeUserId, $thanks['dateline']);
$total++;
}
XenForo_Db::commit();
$this->_session->incrementStepImportTotal($total);
// 1.0.0 Beta 2 introduces percentage progress format
if (XenForo_Application::$versionId > 1000031)
{
return array($next, $options, $this->_getProgressOutput($next, $options['max']));
}
else
{
return array($next, $options, "$next / $options[max]");
}
}