Migration complete
This commit is contained in:
97
Import/Importer/RHPZForums.php
Normal file
97
Import/Importer/RHPZForums.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace RomhackPlaza\Master\Import\Importer;
|
||||
|
||||
use RomhackPlaza\Master\Helper\Laravel;
|
||||
use XF\Import\StepState;
|
||||
use XFI\Import\Importer\XenForo23;
|
||||
|
||||
class RHPZForums extends XenForo23
|
||||
{
|
||||
public static function getListInfo(): array
|
||||
{
|
||||
return [
|
||||
'target' => 'XenForo',
|
||||
'source' => 'RHPZ Forums (XF)'
|
||||
];
|
||||
}
|
||||
|
||||
public function stepUserGroups(StepState $state)
|
||||
{
|
||||
$map = $this->getMigrationSetting('old_xf_group_to_xf_group');
|
||||
foreach( $map as $oldId => $newId ){
|
||||
$this->log('user_group', $oldId, $newId);
|
||||
$state->imported++;
|
||||
}
|
||||
|
||||
return $state->complete();
|
||||
}
|
||||
|
||||
public function stepUserFields(StepState $state)
|
||||
{
|
||||
return $state->complete();
|
||||
}
|
||||
|
||||
public function stepUsers(StepState $state, array $stepConfig, $maxTime)
|
||||
{
|
||||
$rows = $this->sourceDb->fetchAll("SELECT user_id FROM xf_user ORDER BY user_id" );
|
||||
|
||||
foreach ( $rows as $row ) {
|
||||
$oldId = $row['user_id'];
|
||||
$newId = $this->getNewUserId($oldId);
|
||||
|
||||
if( $newId ){
|
||||
$this->log('user', $oldId, $newId);
|
||||
$state->imported++;
|
||||
}
|
||||
}
|
||||
|
||||
return $state->complete();
|
||||
}
|
||||
|
||||
public function stepAvatars(StepState $state, array $stepConfig, $maxTime)
|
||||
{
|
||||
return $state->complete();
|
||||
}
|
||||
|
||||
public function stepNodes(StepState $state)
|
||||
{
|
||||
$map = $this->getMigrationSetting('old_xf_node_to_new_xf_node');
|
||||
foreach( $map as $oldId => $newId ){
|
||||
$this->log('node', $oldId, $newId);
|
||||
$state->imported++;
|
||||
}
|
||||
|
||||
return $state->complete();
|
||||
}
|
||||
|
||||
public function stepNodePermissions(StepState $state)
|
||||
{
|
||||
return $state->complete();
|
||||
}
|
||||
|
||||
public function stepModerators(StepState $state)
|
||||
{
|
||||
return $state->complete();
|
||||
}
|
||||
|
||||
private function getMigrationSetting(string $key): mixed
|
||||
{
|
||||
$db = Laravel::db();
|
||||
if( !$db )
|
||||
return null;
|
||||
|
||||
$row = $db->fetchOne("SELECT value FROM migration_settings WHERE `key` = ? ", [$key]);
|
||||
return $row ? json_decode( $row, true ) : [];
|
||||
}
|
||||
|
||||
private function getNewUserId(int $oldId): ?int
|
||||
{
|
||||
$db = Laravel::db();
|
||||
if( !$db )
|
||||
return null;
|
||||
|
||||
$row = $db->fetchOne("SELECT user_id FROM migration_user_plan WHERE xf_user_id = ?", [$oldId]);
|
||||
return $row ? (int) $row : null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user