use Friendica\Worker\Delivery;
/**
- * @brief UserImport class
+ * UserImport class
*/
class UserImport
{
}
/**
- * @brief Import account file exported from mod/uexport
+ * Import account file exported from mod/uexport
*
* @param array $file array from $_FILES
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
$account = json_decode(file_get_contents($file['tmp_name']), true);
if ($account === null) {
- notice(L10n::t("Error decoding account file"));
+ notice(DI::l10n()->t("Error decoding account file"));
return;
}
if (empty($account['version'])) {
- notice(L10n::t("Error! No version data in file! This is not a Friendica account file?"));
+ notice(DI::l10n()->t("Error! No version data in file! This is not a Friendica account file?"));
return;
}
// check if username matches deleted account
if (DBA::exists('user', ['nickname' => $account['user']['nickname']])
|| DBA::exists('userd', ['username' => $account['user']['nickname']])) {
- notice(L10n::t("User '%s' already exists on this server!", $account['user']['nickname']));
+ notice(DI::l10n()->t("User '%s' already exists on this server!", $account['user']['nickname']));
return;
}
$oldbaseurl = $account['baseurl'];
- $newbaseurl = System::baseUrl();
+ $newbaseurl = DI::baseUrl();
$oldaddr = str_replace('http://', '@', Strings::normaliseLink($oldbaseurl));
$newaddr = str_replace('http://', '@', Strings::normaliseLink($newbaseurl));
$r = self::dbImportAssoc('user', $account['user']);
if ($r === false) {
Logger::log("uimport:insert user : ERROR : " . DBA::errorMessage(), Logger::INFO);
- notice(L10n::t("User creation error"));
+ notice(DI::l10n()->t("User creation error"));
return;
}
$newuid = self::lastInsertId();
- PConfig::set($newuid, 'system', 'previous_addr', $old_handle);
+ DI::pConfig()->set($newuid, 'system', 'previous_addr', $old_handle);
foreach ($account['profile'] as &$profile) {
foreach ($profile as $k => &$v) {
$r = self::dbImportAssoc('profile', $profile);
if ($r === false) {
Logger::log("uimport:insert profile " . $profile['profile-name'] . " : ERROR : " . DBA::errorMessage(), Logger::INFO);
- info(L10n::t("User profile creation error"));
+ info(DI::l10n()->t("User profile creation error"));
DBA::delete('user', ['uid' => $newuid]);
return;
}
}
}
if ($errorcount > 0) {
- notice(L10n::tt("%d contact not imported", "%d contacts not imported", $errorcount));
+ notice(DI::l10n()->tt("%d contact not imported", "%d contacts not imported", $errorcount));
}
foreach ($account['group'] as &$group) {
// send relocate messages
Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, $newuid);
- info(L10n::t("Done. You can now login with your username and password"));
+ info(DI::l10n()->t("Done. You can now login with your username and password"));
DI::baseUrl()->redirect('login');
}
}