1
0
mirror of https://github.com/e107inc/e107.git synced 2025-05-05 03:38:29 +02:00

d6 and d8 user import, moved lan strings to lan file

This commit is contained in:
Lóna Lore 2015-02-16 13:03:21 +01:00
parent 9501745c07
commit 6b17ed4c09
3 changed files with 49 additions and 42 deletions

View File

@ -40,8 +40,7 @@ require_once("../../class2.php");
$frm = e107::getForm(); $frm = e107::getForm();
$mes = e107::getMessage(); $mes = e107::getMessage();
e107::lan('import', true, true);
//e107::lan('import',e_LANGUAGE.'_admin_import.php');
//XXX A Fresh Start //XXX A Fresh Start
class import_admin extends e_admin_dispatcher class import_admin extends e_admin_dispatcher

View File

@ -75,3 +75,12 @@ define('LAN_CONVERT_45','Cannot read import code file');
define('LAN_CONVERT_46','Error: --ERRNUM-- while writing to --DB-- database, line '); define('LAN_CONVERT_46','Error: --ERRNUM-- while writing to --DB-- database, line ');
define('LAN_CONVERT_47','Batch --BLOCK-- import completed. --LINES-- read, --USERS-- added, --ERRORS-- errors'); define('LAN_CONVERT_47','Batch --BLOCK-- import completed. --LINES-- read, --USERS-- added, --ERRORS-- errors');
define('LAN_CONVERT_48','Forum posts'); define('LAN_CONVERT_48','Forum posts');
define('LAN_CONVERT_49','Drupal');
define('LAN_CONVERT_50','Basic import');
define('LAN_CONVERT_51','The version of targeted Drupal.');
define('LAN_CONVERT_52','Drupal Version');
define('LAN_CONVERT_53','The base URL of Drupal website (e.g., http://mydrupalsite.com).');
define('LAN_CONVERT_54','Drupal Base URL');
define('LAN_CONVERT_55','The base URL path (i.e., directory) of the Drupal installation (e.g., /drupal/).');
define('LAN_CONVERT_56','Drupal Base Path');

View File

@ -20,8 +20,8 @@ require_once('import_classes.php');
class drupal_import extends base_import_class class drupal_import extends base_import_class
{ {
public $title = 'Drupal'; public $title = LAN_CONVERT_49;
public $description = 'Basic import'; public $description = LAN_CONVERT_50;
// array('users', 'news','page','links'); //XXX Modify to enable copyNewsData() etc. // array('users', 'news','page','links'); //XXX Modify to enable copyNewsData() etc.
public $supported = array('users'); public $supported = array('users');
public $mprefix = false; public $mprefix = false;
@ -71,25 +71,25 @@ class drupal_import extends base_import_class
'8' => 'Drupal 8', '8' => 'Drupal 8',
); );
$dscVersion = 'The version of targeted Drupal.'; $dscVersion = LAN_CONVERT_51;
$frmElements[] = array( $frmElements[] = array(
'caption' => "Drupal Version", 'caption' => LAN_CONVERT_52,
'html' => $frm->select('version', $versions, $this->version, 50, array( 'html' => $frm->select('version', $versions, $this->version, 50, array(
'required' => 1, 'required' => 1,
)) . '<div class="field-help">' . $dscVersion . '</div>', )) . '<div class="field-help">' . $dscVersion . '</div>',
); );
$dscBaseUrl = 'The base URL of Drupal website (e.g., http://mydrupalsite.com).'; $dscBaseUrl = LAN_CONVERT_53;
$frmElements[] = array( $frmElements[] = array(
'caption' => "Drupal Base URL", 'caption' => LAN_CONVERT_54,
'html' => $frm->text('baseUrl', $this->baseUrl, 50, array( 'html' => $frm->text('baseUrl', $this->baseUrl, 50, array(
'required' => 1, 'required' => 1,
)) . '<div class="field-help">' . $dscBaseUrl . '</div>', )) . '<div class="field-help">' . $dscBaseUrl . '</div>',
); );
$dscBasePath = 'The base URL path (i.e., directory) of the Drupal installation (e.g., /drupal/).'; $dscBasePath = LAN_CONVERT_55;
$frmElements[] = array( $frmElements[] = array(
'caption' => "Drupal Base Path", 'caption' => LAN_CONVERT_56,
'html' => $frm->text('basePath', $this->basePath, 50, array( 'html' => $frm->text('basePath', $this->basePath, 50, array(
'required' => 1, 'required' => 1,
)) . '<div class="field-help">' . $dscBasePath . '</div>', )) . '<div class="field-help">' . $dscBasePath . '</div>',
@ -163,7 +163,10 @@ class drupal_import extends base_import_class
switch ((int) $this->version) switch ((int) $this->version)
{ {
case 6: case 6:
return false; $query = "SELECT * FROM " . $this->DBPrefix . "users AS u ";
$query .= "WHERE u.status = 1 AND u.uid > 1 ";
return $this->ourDB->gen($query);
break; break;
case 7: case 7:
@ -182,7 +185,15 @@ class drupal_import extends base_import_class
break; break;
case 8: case 8:
return false; $fields = array(
'ufd.*',
);
$query = "SELECT " . implode(',', $fields) . " FROM " . $this->DBPrefix . "users AS u ";
$query .= "LEFT JOIN " . $this->DBPrefix . "users_field_data AS ufd ON u.uid = ufd.uid";
$query .= "WHERE ufd.status = 1 AND ufd.uid > 1 ";
return $this->ourDB->gen($query);
break; break;
default: default:
@ -207,39 +218,17 @@ class drupal_import extends base_import_class
{ {
if ($this->copyUserInfo) if ($this->copyUserInfo)
{ {
// int(10)
$target['user_id'] = $source['uid']; $target['user_id'] = $source['uid'];
// varchar(100)
$target['user_name'] = $source['name']; $target['user_name'] = $source['name'];
// varchar(100)
$target['user_loginname'] = $source['name']; $target['user_loginname'] = $source['name'];
// varchar(50)
$target['user_password'] = $source['pass']; $target['user_password'] = $source['pass'];
// varchar(100)
$target['user_email'] = $source['mail']; $target['user_email'] = $source['mail'];
// text
$target['user_signature'] = $source['signature']; $target['user_signature'] = $source['signature'];
// int(10)
$target['user_join'] = (int) $source['created']; $target['user_join'] = (int) $source['created'];
// int(10)
$target['user_lastvisit'] = (int) $source['login']; $target['user_lastvisit'] = (int) $source['login'];
// May need conversion varchar(8)
$target['user_timezone'] = $source['timezone']; $target['user_timezone'] = $source['timezone'];
// May need conversion varchar(12)
$target['user_language'] = $source['language']; $target['user_language'] = $source['language'];
$user_image = $this->fileSaveAvatar($source); $user_image = $this->fileSaveAvatar($source);
// varchar(100)
$target['user_image'] = $user_image; $target['user_image'] = $user_image;
return $target; return $target;
@ -332,9 +321,6 @@ class drupal_import extends base_import_class
/** /**
* TODO: resizing avatar...?
* TODO: process_uploaded_files() should be used?
*
* Save avatar picture from Drupal filesystem. * Save avatar picture from Drupal filesystem.
* a) create remote URL to stream file contents * a) create remote URL to stream file contents
* b) get remote file contents * b) get remote file contents
@ -351,12 +337,25 @@ class drupal_import extends base_import_class
// Set default return value. // Set default return value.
$local_path = ''; $local_path = '';
$src_uri = $row['uri']; switch ((int) $this->version) {
$src_pth = unserialize($row['public_file_path']); case 6:
$src_pth = $this->fileCreateUrl($src_uri, $src_pth); $src_pth = $this->fileCreateUrl($row['picture'], "");
break;
case 7:
$src_uri = $row['uri'];
$src_pth = unserialize($row['public_file_path']);
$src_pth = $this->fileCreateUrl($src_uri, $src_pth);
break;
case 8:
// TODO: need to get user pictures url.
return $local_path;
break;
}
// If $src_pth is empty, we cannot save remote file, so return... // If $src_pth is empty, we cannot save remote file, so return...
if (empty($src_pth)) if (!isset($src_pth) || empty($src_pth))
{ {
return $local_path; return $local_path;
} }
@ -420,7 +419,7 @@ class drupal_import extends base_import_class
*/ */
function fileCreateUrl($uri, $path) function fileCreateUrl($uri, $path)
{ {
if (empty($uri) || !(substr($uri, 0, 9) == 'public://')) if (empty($uri))
{ {
return ""; return "";
} }