TnT
Member
Sure, I would appreciate it. Sorry yo had to do that.
No Problem:
Add to function getSteps()
PHP:
'rebuildgroups' => array(
'title' => new XenForo_Phrase('Rebuild Group Information'),
'depends' => array( /*'groups', 'threads', 'posts'*/ )
)
and finally:
PHP:
/**
* This will rebuild Group Information
*
* @param int $startIndex at which to start the import
* @param array $optionsAny options that were set for the step
* @return array
*/
public function stepRebuildGroups($start, array $options)
{
$options = array_merge(array(
'limit' => 5,
'max' => false
), $options);
$db = XenForo_Application::getDb();
if ($options['max'] === false)
{
$options['max'] = $db->fetchOne("SELECT MAX(group_id) FROM xfa_group");
}
// pull threads
$groups = $db->fetchAll($db->limit('
SELECT * FROM xfa_group thread
WHERE group_id > ' . $db->quote($start) . '
ORDER BY group_id
', $options['limit']
));
if (!$groups)
{
return true;
}
XenForo_Db::beginTransaction();
$next = 0;
$total = 0;
foreach ($groups AS $group)
{
$next = $group['group_id'];
$threads = $db->fetchOne("SELECT COUNT(thread_id) FROM xfa_group_thread WHERE group_id = ?", $group['group_id']);
$replies = $db->fetchOne("SELECT COUNT(post_id)
FROM xfa_group_thread t,
xfa_group_post p
WHERE t.group_id = ?
AND t.thread_id = p.thread_id", $group['group_id']);
$last_thread_id = $db->fetchOne("SELECT MAX(thread_id)
FROM xfa_group_thread
WHERE group_id = ?", $group['group_id']);
$postinfo = $db->fetchRow("SELECT p.post_id, p.user_id, u.username
FROM xfa_group_post p
LEFT JOIN xf_user u ON u.user_id = p.user_id
WHERE p.thread_id = ? ORDER BY post_id DESC", $last_thread_id);
$members = $db->fetchOne("SELECT COUNT(member_id)
FROM xfa_group_member
WHERE group_id = ?", $group['group_id']);
$db->query("UPDATE xfa_group
SET group_thread_count = '" . $threads . "',
group_reply_count = '" . $replies . "',
last_post_date = '" . ($last_thread_id != null ? $last_thread_id : 0) . "',
last_post_id = '" . (isset($postinfo['post_id']) ? $postinfo['post_id'] : 0) . "',
last_post_user_id = '" . (isset($postinfo['user_id']) ? $postinfo['user_id'] : 0) . "',
last_post_username = '" . (isset($postinfo['username']) ? $postinfo['username'] : '') . "',
members_total = '" . $members . "'
WHERE group_id = ?", $group['group_id']);
$total++;
}
XenForo_Db::commit();
$this->_session->incrementStepImportTotal($total);
return array($next, $options, $this->_getProgressOutput($next, $options['max']));
}
I'll add the group icons to the list, I need to revisit vBulletin to remember whether they were stored in filesystem/database.
Images are stored in this filepath at my forum (this is not the original vBulletin filepath):
Can I have it anyway? Will modify it for my needs. So I do not have to write it completely by myself.I already have a script for the icons but it is definitely not for public consumption (hardcoded server paths, etc)
Regards
Thomas