1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 21:57:51 +02:00

Import for Drupal and Wordpress, SMF still needs a bit of work.

This commit is contained in:
Cameron
2013-04-21 21:33:15 -07:00
parent 449f31546a
commit aaf787b0e6
3 changed files with 96 additions and 48 deletions

View File

@@ -30,7 +30,7 @@ require_once('import_classes.php');
class drupal_import extends base_import_class class drupal_import extends base_import_class
{ {
public $title = 'Drupal 5.7/6.1'; public $title = 'Drupal 5 - 8';
public $description = 'Basic import'; public $description = 'Basic import';
public $supported = array('users'); public $supported = array('users');
public $mprefix = false; public $mprefix = false;
@@ -49,10 +49,7 @@ class drupal_import extends base_import_class
$result = $this->ourDB->db_Select_gen("SELECT * FROM {$this->DBPrefix}users WHERE `status`=1"); $result = $this->ourDB->db_Select_gen("SELECT * FROM {$this->DBPrefix}users WHERE `status`=1");
if ($result === FALSE) return FALSE; if ($result === FALSE) return FALSE;
break; break;
case 'forumdefs' :
return FALSE;
case 'forumposts' :
return FALSE;
case 'polls' : case 'polls' :
return FALSE; return FALSE;
case 'news' : case 'news' :
@@ -74,7 +71,7 @@ class drupal_import extends base_import_class
//------------------------------------ //------------------------------------
// Copy data read from the DB into the record to be returned. // Copy data read from the DB into the record to be returned.
function copyUserData(&$target, &$source) function copyUserData(&$target, &$source) // http://drupal.org/files/er_db_schema_drupal_7.png
{ {
if ($this->copyUserInfo) if ($this->copyUserInfo)
{ {

View File

@@ -20,8 +20,12 @@ class smf_import extends base_import_class
public $mprefix = 'smf_'; public $mprefix = 'smf_';
public $sourceType = 'db'; public $sourceType = 'db';
function init()
{
}
// Set up a query for the specified task. // Set up a query for the specified task.
// Returns TRUE on success. FALSE on error // Returns TRUE on success. FALSE on error
function setupQuery($task, $blank_user=FALSE) function setupQuery($task, $blank_user=FALSE)
@@ -31,19 +35,26 @@ class smf_import extends base_import_class
switch ($task) switch ($task)
{ {
case 'users' : case 'users' :
// Set up Userclasses.
if($this->ourDB && $this->ourDB->gen("SELECT * FROM {$this->DBPrefix}membergroups WHERE group_name = 'Jr. Member' "))
{
e107::getMessage()->addDebug("Userclasses Found");
}
$result = $this->ourDB->gen("SELECT * FROM {$this->DBPrefix}members WHERE `is_activated`=1"); $result = $this->ourDB->gen("SELECT * FROM {$this->DBPrefix}members WHERE `is_activated`=1");
if ($result === FALSE) return FALSE; if ($result === FALSE) return FALSE;
break; break;
case 'forum' : case 'forum' :
//$result = $this->ourDB->gen("SELECT * FROM `{$this->DBPrefix}forums`"); $result = $this->ourDB->gen("SELECT * FROM `{$this->DBPrefix}boards`");
//if ($result === FALSE) return FALSE; if ($result === FALSE) return FALSE;
break; break;
case 'forumthread' : case 'forumthread' :
//$result = $this->ourDB->gen("SELECT * FROM `{$this->DBPrefix}topics`"); $result = $this->ourDB->gen("SELECT t.*,m.* FROM `{$this->DBPrefix}topics` AS t LEFT JOIN `{$this->DBPrefix}messages` AS m ON t.id_first_msg = m.id_msg GROUP BY t.id_topic");
//if ($result === FALSE) return FALSE; if ($result === FALSE) return FALSE;
break; break;
case 'forumpost' : case 'forumpost' :
@@ -60,12 +71,43 @@ class smf_import extends base_import_class
return FALSE; return FALSE;
} }
$this->copyUserInfo = !$blank_user; $this->copyUserInfo = false;
$this->currentTask = $task; $this->currentTask = $task;
return TRUE; return TRUE;
} }
function convertUserclass($data)
{
if($data == 1)
{
}
/*
1 Administrator #FF0000 -1 0 5#staradmin.gif 1 0 -2
2 Global Moderator #0000FF -1 0 5#stargmod.gif 0 0 -2
3 Moderator -1 0 5#starmod.gif 0 0 -2
4 Newbie 0 0 1#star.gif 0 0 -2
5 Jr. Member 50 0 2#star.gif 0 0 -2
6 Full Member 100 0 3#star.gif 0 0 -2
7 Sr. Member 250 0 4#star.gif 0 0 -2
8 Hero Member 500 0 5#star.gif 0 0 -2
*/
}
function convertAdmin($data)
{
if($data == 1)
{
return 1;
}
}
//------------------------------------ //------------------------------------
// Internal functions below here // Internal functions below here
//------------------------------------ //------------------------------------
@@ -73,30 +115,39 @@ class smf_import extends base_import_class
// Copy data read from the DB into the record to be returned. // Copy data read from the DB into the record to be returned.
function copyUserData(&$target, &$source) function copyUserData(&$target, &$source)
{ {
if ($this->copyUserInfo) $target['user_id'] = $source['ID_MEMBER']; if ($this->copyUserInfo)
$target['user_name'] = $source['realName']; {
$target['user_login'] = $source['realName']; $target['user_id'] = 0; // $source['id_member'];
$target['user_loginname'] = $source['memberName']; }
$target['user_password'] = $source['passwd']; // Check - could be plaintext
$target['user_email'] = $source['emailAddress']; $target['user_name'] = $source['real_name'];
$target['user_hideemail'] = $source['hideEmail']; $target['user_login'] = $source['member_name'];
$target['user_image'] = $source['avatar']; $target['user_loginname'] = $source['memberName'];
$target['user_signature'] = $source['signature']; $target['user_password'] = $source['passwd']; // Check - could be plaintext
$target['user_forums'] = $source['posts']; $target['user_email'] = $source['email_address'];
$target['user_chats'] = $source['instantMessages']; $target['user_hideemail'] = $source['hide_email'];
$target['user_join'] = $source['dateRegistered']; $target['user_image'] = $source['avatar'];
$target['user_lastvisit'] = $source['lastLogin']; $target['user_signature'] = $source['signature'];
$target['user_homepage'] = $source['websiteUrl'];
$target['user_location'] = $source['location']; $target['user_chats'] = $source['instant_messages'];
$target['user_icq'] = $source['ICQ']; $target['user_join'] = $source['date_registered'];
$target['user_aim'] = $source['AIM']; $target['user_lastvisit'] = $source['last_login'];
$target['user_yahoo'] = $source['YIM'];
$target['user_msn'] = $source['MSN']; $target['user_location'] = $source['location'];
$target['user_timezone'] = $source['timeOffset']; // Probably needs formatting $target['user_icq'] = $source['icq'];
$target['user_aim'] = $source['aim'];
$target['user_yahoo'] = $source['yim'];
$target['user_msn'] = $source['msn'];
$target['user_timezone'] = $source['time_offset']; // Probably needs formatting
$target['user_customtitle'] = $source['usertitle']; $target['user_customtitle'] = $source['usertitle'];
$target['user_ip'] = $source['memberIP']; $target['user_ip'] = $source['member_ip'];
// $target['user_'] = $source['']; $target['user_homepage'] = $source['website_url'];
// $target['user_'] = $source['']; $target['user_birthday'] = $source['birthdate'];
$target['user_admin'] = $this->convertadmin($source['id_group']);
$target['user_class'] = $this->convertadmin($source['id_group']);
$target['user_plugin_forum_viewed'] = 0;
$target['user_plugin_forum_posts'] = $source['posts'];
// $target['user_language'] = $source['lngfile']; // Guess to verify // $target['user_language'] = $source['lngfile']; // Guess to verify
return $target; return $target;
@@ -106,26 +157,26 @@ class smf_import extends base_import_class
/** /**
* $target - e107_forum table * $target - e107_forum table
* $source - smf table //TODO * $source - smf table boards
*/ */
function copyForumData(&$target, &$source) function copyForumData(&$target, &$source)
{ {
$target['forum_id'] = $source['forum_id']; $target['forum_id'] = $source['id_board'];
$target['forum_name'] = $source['forum_name']; $target['forum_name'] = $source['name'];
$target['forum_description'] = $source['forum_desc']; $target['forum_description'] = $source['description'];
$target['forum_parent'] = $source['parent_id']; $target['forum_parent'] = $source['id_parent'];
$target['forum_sub'] = ""; $target['forum_sub'] = "";
$target['forum_datestamp'] = time(); $target['forum_datestamp'] = time();
$target['forum_moderators'] = ""; $target['forum_moderators'] = "";
$target['forum_threads'] = $source['forum_topics']; $target['forum_threads'] = $source['num_topics'];
$target['forum_replies'] = ""; $target['forum_replies'] = $source['num_posts'];
$target['forum_lastpost_user'] = $source['forum_last_poster_id']; $target['forum_lastpost_user'] = '';
$target['forum_lastpost_user_anon'] = $source['forum_last_poster_name']; $target['forum_lastpost_user_anon'] = '';
$target['forum_lastpost_info'] = $source['forum_last_post_time']; $target['forum_lastpost_info'] = '';
// $target['forum_class'] = ""; // $target['forum_class'] = "";
// $target['forum_order'] $target['forum_order'] = $source['board_order'];
// $target['forum_postclass'] // $target['forum_postclass']
// $target['forum_threadclass'] // $target['forum_threadclass']
// $target['forum_options'] // $target['forum_options']
@@ -169,7 +220,7 @@ class smf_import extends base_import_class
/** /**
* $target - e107 forum_threads * $target - e107 forum_threads
* $source - smf //TODO * $source - smf topics.
*/ */
function copyForumThreadData(&$target, &$source) function copyForumThreadData(&$target, &$source)
{ {

View File

@@ -30,8 +30,8 @@ require_once('import_classes.php');
class wordpress_import extends base_import_class class wordpress_import extends base_import_class
{ {
public $title = 'Wordpress'; public $title = 'Wordpress 3.4+';
public $description = 'Tested with version 3.4.x (salted passwords)'; public $description = 'Import Users, News, Content and Links';
public $supported = array('users','news','page','links'); public $supported = array('users','news','page','links');
public $mprefix = 'wp_'; public $mprefix = 'wp_';