Skip to content

Commit

Permalink
update fork
Browse files Browse the repository at this point in the history
  • Loading branch information
xillibit committed Jul 20, 2011
2 parents 030223c + 6c13d0b commit 0c14050
Show file tree
Hide file tree
Showing 43 changed files with 2,223 additions and 1,024 deletions.
29 changes: 29 additions & 0 deletions administrator/components/com_kunenaimporter/CHANGELOG.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,42 @@
18-July-2011 Xillibit
# [#21] Improve ccboard and agora support (improve catégories, messages import)

18-July-2011 Matias
^ [#30] Code cleanup in importer & exporter
^ [#5] Reviewed and fixed phpBB3 support, closes #5

17-July-2011 Xillibit
# [#21] Improve ccboard and agora support (avatar galleries import for agora)

17-July-2011 Matias
# [#30] Example exporter: Fix topic subscriptions import
# [#5] phpBB3 support: Fix dates in session import
+ [#30] Example exporter: Add polls support
+ [#37] Add nearly complete support for deprecated phpBB2
^ [#35] Improve usability: Add menu image and missing gray icons, mark unfinished importers as gray

16-July-2011 Matias
^ [#35] Improve usability: Cleaner look
^ [#35] Improve usability: Don't show unused configuration parameters
^ [#35] Improve usability: Select all import options by default (one click import)
# [#35] Improve usability: Truncate selected tables before import (no more white screens on duplicate entries)
^ [#35] Improve usability: Unselect already imported tasks
^ [#35] Improve usability: Changing configuration options should have effect when clicking "Import" or "Truncate"
# [#5] phpBB3 support: Fix various issues with user import
+ [#30] Example exporter: Add missing functions countUsers() and exportUsers()
# [#5] phpBB3 support: Fix database version detection for deprecated phpBB2
+ [#37] Add initial support for deprecated phpBB2

15-July-2011 Matias
+ [#5] phpBB3 and SMF2 support: allow user to create new Joomla users, either manually or automatically

14-July-2011 Xillibit
# [#21] Improve ccboard and agora support (improvements on agora categories import, messages import)
# [#21] Improve ccboard and agora support (improvements on messages import)

14-July-2011 Matias
+ [#35] Improve usability: Nice startup screen with cool icons and usage instructions

13-July-2011 Matias
+ [#27] Full support for ccBoard 1.2-RC
+ [#27] ccBoard: Convert all code to use example exporter as a base
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 7 additions & 9 deletions administrator/components/com_kunenaimporter/assets/importer.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
*
**/

table#kunenaimporter {
background-color: inherit;
}
table.kunenaimporter {
}
div.header {
Expand All @@ -16,10 +19,10 @@ div.header {
div.icon-48-kunenaimporter {
background-image:url(kunena-48.png);
}
td.config {
width: 50%;
td.kleft {
padding-right: 10px;
}
td.info {
td.config {
width: 50%;
}
td.title {
Expand All @@ -38,12 +41,7 @@ td.notes {
.success {
color: green;
}
div.info {
table.adminlist td.info {
background:#FFFFDD;
color:#333;
padding:10px;
border: 1px solid #CCCC66;
}
div.info h2 {
margin-top: 2px;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 14 additions & 16 deletions administrator/components/com_kunenaimporter/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,21 @@
<config>
<!-- Joomla 1.5 support -->
<params>
<param name="extforum" type="list" default="localhost" label="COM_KUNENAIMPORTER_CONFIG_EXTFORUM_LABEL" description="COM_KUNENAIMPORTER_CONFIG_EXTFORUM_DESC" size="30">
<option value="">COM_KUNENAIMPORTER_EXTFORUM_OPTION_EMPTY</option>
<option value="agora">Agora</option>
<option value="ccboard">ccBoard</option>
<option value="ninjaboard">NinjaBoard</option>
<!-- <option value="kunena">Kunena</option> -->
<option value="phpbb3">phpBB3</option>
<!-- <option value="phpbb2">phpBB2</option> -->
<!-- <option value="pnphpbb2">PNphpBB2</option> -->
<option value="smf2">SMF2</option>
</param>
<param name="extforum" type="hidden" default="localhost" label="COM_KUNENAIMPORTER_CONFIG_EXTFORUM_LABEL" description="COM_KUNENAIMPORTER_CONFIG_EXTFORUM_DESC" size="30" />
<param name="path" type="text" default="" label="COM_KUNENAIMPORTER_CONFIG_PATH_LABEL" description="COM_KUNENAIMPORTER_CONFIG_PATH_DESC" size="30" />
<!-- <param name="db_host" type="text" default="localhost" label="Database Host" description="" size="30" />
<param name="db_user" type="text" default="" label="Database User" description="" size="30" />
<param name="db_passwd" type="password" default="" label="Database Password" description="" size="30" />
<param name="db_name" type="text" default="" label="Forum Database Name" description="" size="30" />
<param name="db_prefix" type="text" default="phpbb_" label="Forum Table Prefix" description="Please enter the table prefix used for the forum you want to import from." size="30" /> -->
<param name="usermode" type="list" default="yes" label="User Import Mode" description="COM_KUNENAIMPORTER_CONFIG_PATH_DESC" size="30">
<option value="joomla">Use existing Joomla users</option>
<option value="external">Delete existing Joomla users</option>
</param>
<!-- <param name="userconflicts" type="list" default="0" label="Resolve User Conflicts" description="COM_KUNENAIMPORTER_CONFIG_PATH_DESC" size="30">
<option value="no">No, let me do it</option>
<option value="joomla">Yes, favor Joomla users</option>
<option value="external">Yes, favor external users</option>
</param> -->
<param name="useradd" type="list" default="0" label="Create Missing Users" description="COM_KUNENAIMPORTER_CONFIG_PATH_DESC" size="30">
<option value="no">No, let me do it</option>
<option value="yes">Yes, create automatically</option>
</param>
</params>

<!-- Joomla 1.6 Support -->
Expand Down
141 changes: 121 additions & 20 deletions administrator/components/com_kunenaimporter/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function __construct() {
$this->item_type = 'Default';
$this->addModelPath ( JPATH_ADMINISTRATOR . '/components/com_kunenaimporter/models' );
parent::__construct ();
$this->registerTask ( 'start', 'start' );
$this->registerTask ( 'truncatemap', 'truncatemap' );
$this->registerTask ( 'mapusers', 'mapusers' );
$this->registerTask ( 'stopmapping', 'stopmapping' );
Expand All @@ -31,6 +32,49 @@ public function __construct() {
$this->registerTask ( 'truncate', 'truncatetable' );
}

public function start() {
$app = JFactory::getApplication ();
if (! JRequest::checkToken (true)) {
$app->enqueueMessage ( JText::_ ( 'COM_KUNENAIMPORTER_ERROR_TOKEN' ), 'error' );
$this->redirectBack();
}
$params = getKunenaImporterParams();
$params->set('path', '');
$forum = JRequest::getString ( 'select', '' );
$success = false;
if ($forum) {
$exporter = $this->getModel ( 'export_' . $forum );
if ($exporter) $success = $exporter->detectComponent ();
}
if (!$success) {
$app->enqueueMessage ( JText::sprintf ( "Component '%s' was not detected!", $forum ), 'error' );
$this->redirectBack();
}

if ($params->get('extforum') != $forum) {
$table = JTable::getInstance ( 'component' );
if (! $table->loadByOption ( 'com_kunenaimporter' )) {
JError::raiseWarning ( 500, 'Not a valid component' );
return false;
}
$post = array('params' => array('extforum'=>$forum, 'path'=>$exporter->getPath(), 'usermode'=>'joomla', 'useradd'=>'no'));
$table->bind ( $post );
if (!$table->save ( $post )) {
$app->enqueueMessage ( JText::_ ( 'Saving configuration failed!' ), 'error' );
$this->redirectBack();
}
$app->setUserState ( 'com_kunenaimporter.state', null );
$app->setUserState ( 'com_kunenaimporter.Users', null );
$importer = $this->getModel ( 'import' );
$options = $importer->getImportOptions ();
foreach ( $options as $option ) {
$app->setUserState ( 'com_kunenaimporter.' . $option, -1 );
}
}

$this->setredirect ( 'index.php?option=com_kunenaimporter' );
}

public function stopmapping() {
$this->setredirect ( 'index.php?option=com_kunenaimporter&view=users' );
}
Expand All @@ -45,28 +89,41 @@ public function truncatetable() {

$app = JFactory::getApplication ();

$component = JComponentHelper::getComponent ( 'com_kunenaimporter' );
$params = new JParameter ( $component->params );
$newparams = JRequest::getVar ( 'params' );
if (!empty($newparams)) {
foreach ($newparams as $param=>$value) {
if ($params->get ( $param ) != $value) {
$this->save();
break;
}
}
}

$importer = $this->getModel ( 'import' );
$options = $importer->getImportOptions ();
$state = $this->getParams ();
$optlist = array ();
foreach ( $options as $option ) {
if (isset ( $state [$option] )) {
$app->setUserState ( 'com_kunenaimporter.' . $option, 0 );
$app->setUserState ( 'com_kunenaimporter.' . $option, -1 );
$importer->truncateData ( $option );
$optlist [] = $option;
}
}
// FIXME: !!!
//$importer->truncateJoomlaUsers();

$app->enqueueMessage ( 'Deleted ' . implode ( ', ', $optlist ) );
$this->setredirect ( 'index.php?option=com_kunenaimporter' );
}

public function truncatemap() {
$importer = $this->getModel ( 'import' );
$importer->truncateUsersMap ();
$importer->truncateData ('users');
$app = JFactory::getApplication ();
$app->setUserState ( 'com_kunenaimporter.users', -1 );
$app->setUserState ( 'com_kunenaimporter.mapusers', -1 );
$app->setUserState ( 'com_kunenaimporter.createusers', -1 );
$app->setUserState ( 'com_kunenaimporter.Users', 0 );
$app->enqueueMessage ( 'Deleted user mapping' );
$this->setredirect ( 'index.php?option=com_kunenaimporter&view=users' );
Expand All @@ -85,7 +142,6 @@ public function mapusers() {
$success = $exporter->detect ();
$errormsg = $exporter->getError ();
$importer = $this->getModel ( 'import' );
$importer->setAuthMethod ( $exporter->getAuthMethod () );

if (!$success || $errormsg)
return;
Expand All @@ -112,13 +168,18 @@ public function mapusers() {

public function selectuser() {
$extid = JRequest::getInt ( 'extid', 0 );
$cid = JRequest::getVar ( 'cid', array (0 ), 'post', 'array' );
$cid = JRequest::getVar ( 'cid', array (0), 'post', 'array' );
$userdata ['id'] = array_shift ( $cid );
if ($userdata ['id'] < 0) {
if ($userdata ['id'] == 'NEW') {
$userdata ['id'] = 0;
} elseif (!intval($userdata ['id'])) {
$this->setredirect ( 'index.php?option=com_kunenaimporter&view=users' );
return;
} elseif ($userdata ['id'] < 0) {
$userdata ['id'] = JRequest::getInt ( 'userid', 0 );
}
$replace = JRequest::getInt ( 'replace', 0 );

require_once (JPATH_COMPONENT . DS . 'models' . DS . 'kunena.php');
$importer = $this->getModel ( 'import' );

Expand All @@ -127,16 +188,22 @@ public function selectuser() {
$success = true;
$oldid = $extuser->id;
if ($oldid > 0) $importer->updateUserData($oldid, -$extid);
if ($userdata ['id'] == 0) {
$userdata ['id'] = $importer->createUser($extuser);
if (!is_numeric($userdata ['id'] )) {
$this->setredirect ( 'index.php?option=com_kunenaimporter&view=users', $userdata ['id'], 'notice' );
return;
}
}
if ($userdata ['id'] > 0) $success = $importer->updateUserData(-$extid, $userdata ['id'], $replace);
if ($success && $extuser->save ( $userdata ) === false) {
echo "ERROR: Saving external data for $userdata->username failed: " . $extuser->getError () . "<br />";
die("ERROR: Saving external data for $userdata->username failed: " . $extuser->getError () . "<br />");
$importer->updateUserData($userdata ['id'], $oldid);
}
if (!$success) {
$importer->updateUserData(-$extid, $oldid);
}

$app = JFactory::getApplication ();
$this->setredirect ( 'index.php?option=com_kunenaimporter&view=users' );
}

Expand All @@ -148,12 +215,22 @@ public function importforum() {

$component = JComponentHelper::getComponent ( 'com_kunenaimporter' );
$params = new JParameter ( $component->params );
$newparams = JRequest::getVar ( 'params' );
if (!empty($newparams)) {
foreach ($newparams as $param=>$value) {
if ($params->get ( $param ) != $value) {
$this->save();
$this->setredirect ( 'index.php?option=com_kunenaimporter', 'Configuration saved. Please try again.', 'notice' );
return;
}
}
}

$extforum = $params->get ( 'extforum' );
$exporter = $this->getModel ( $extforum ? 'export_' . $extforum : 'export' );
$success = $exporter->detect ();
$errormsg = $exporter->getError ();
$importer = $this->getModel ( 'import' );
$importer->setAuthMethod ( $exporter->getAuthMethod () );

$options = $importer->getImportOptions ();
$state = $this->getParams ();
Expand All @@ -165,11 +242,20 @@ public function importforum() {
$start = ( int ) $app->getUserState ( 'com_kunenaimporter.' . $option );
if (isset ( $state [$option] )) {
$count = 0;
// Whether to truncate Joomla users table
$truncatejoomla = $exporter->external && $params->get ('usermode') == 'external';
do {
if ($start < 0 || $state [$option]) {
$importer->truncateData ( $option, $truncatejoomla );
$state [$option] = $start = 0;
}
$data = $exporter->exportData ( $option, $start, $limit );
$importer->importData ( $option, $data );
$icount = $importer->importData ( $option, $data );
$count = count ( $data );
$start += $count;
if ($option == 'createusers') {
$app->setUserState ( 'com_kunenaimporter.mapusers', $app->getUserState ( 'com_kunenaimporter.mapusers' )+$icount );
}
$app->setUserState ( 'com_kunenaimporter.' . $option, $start );
$timeout = $this->checkTimeout ();
unset ( $data );
Expand All @@ -179,13 +265,15 @@ public function importforum() {
break;
}

$message = null;
$view = '';
if ($timeout)
$view = '&view=import';
else {
$app->enqueueMessage ( "Import done!" );
$view = '';
$message = "Import done!";
}
$this->setredirect ( 'index.php?option=com_kunenaimporter' . $view );
$app->setUserState ( 'com_kunenaimporter.state', $state );
$this->setredirect ( 'index.php?option=com_kunenaimporter' . $view, $message );

/*
// Check errors
Expand Down Expand Up @@ -236,17 +324,25 @@ public function save() {
}

public function display() {
$params = $this->getParams ();
$cmd = JRequest::getCmd ( 'view', 'default' );
$params = getKunenaImporterParams();
$forum = $params->get('extforum');
if (!$forum) {
$cmd = 'start';
}

$cmd = !empty($cmd) ? $cmd : JRequest::getCmd ( 'view', 'default' );
$view = $this->getView ( $cmd, 'html' );
$component = JComponentHelper::getComponent ( 'com_kunenaimporter' );
$params = new JParameter ( $component->params );
$view->setModel ( $this->getModel ( 'import' ), true );
$extforum = $params->get ( 'extforum' );
$view->setModel ( $this->getModel ( $extforum ? 'export_' . $extforum : 'export' ), false );

JSubMenuHelper::addEntry ( JText::_ ( 'Importer Configuration' ), 'index.php?option=com_kunenaimporter', $cmd == 'default' );
JSubMenuHelper::addEntry ( JText::_ ( 'Migrate Users' ), 'index.php?option=com_kunenaimporter&view=users', $cmd == 'users' );
if ($cmd != 'start') {
JSubMenuHelper::addEntry ( JText::_ ( 'Choose Your Software' ), 'index.php?option=com_kunenaimporter&view=start', $cmd == 'default' );
JSubMenuHelper::addEntry ( JText::_ ( 'Importer Configuration' ), 'index.php?option=com_kunenaimporter', $cmd == 'default' );
JSubMenuHelper::addEntry ( JText::_ ( 'Migrate Users' ), 'index.php?option=com_kunenaimporter&view=users', $cmd == 'users' );
}

$view->display ();
}
Expand Down Expand Up @@ -278,6 +374,11 @@ protected function getParams() {
$state = array ();
JRequest::setVar ( 'cid', $state, 'post' );
}
return array_flip ( $state );
return $state;
}

protected function redirectBack() {
$httpReferer = JRequest::getVar ( 'HTTP_REFERER', JURI::base ( true ), 'server' );
JFactory::getApplication ()->redirect ( $httpReferer );
}
}
Loading

0 comments on commit 0c14050

Please sign in to comment.