Skip to content

Commit

Permalink
^ [Kunena#1] Convert component to PHP5
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed Jul 5, 2011
1 parent 9caa0db commit f6d56fa
Show file tree
Hide file tree
Showing 16 changed files with 287 additions and 317 deletions.
5 changes: 4 additions & 1 deletion administrator/components/com_kunenaimporter/CHANGELOG.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

KunenaImporter 1.6.4
KunenaImporter 1.6.5

5-July-2011 Matias
^ [#1] Convert component to PHP5

29-November-2010 Xillibit
# [#20178] Fixes some issues with ccBoard importer
Expand Down
102 changes: 45 additions & 57 deletions administrator/components/com_kunenaimporter/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@
* Kunena importer Controller
*/
class KunenaImporterController extends JController {
function __construct() {
//Get View
if (JRequest::getCmd ( 'view' ) == '') {
JRequest::setVar ( 'view', 'default' );
}
public function __construct() {
$this->item_type = 'Default';
$this->addModelPath ( JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_kunenaimporter' . DS . 'models' );
$this->addModelPath ( JPATH_ADMINISTRATOR . '/components/com_kunenaimporter/models' );
parent::__construct ();
$this->registerTask ( 'truncatemap', 'truncatemap' );
$this->registerTask ( 'mapusers', 'mapusers' );
Expand All @@ -37,55 +33,21 @@ function __construct() {
$this->registerTask ( 'truncate', 'truncatetable' );
}

function checkTimeout() {
static $start = null;

list ( $usec, $sec ) = explode ( ' ', microtime () );
$time = (( float ) $usec + ( float ) $sec);

if (empty ( $start ))
$start = $time;

if ($time - $start < 4)
return false;
return true;
}

function getParams() {
$app = JFactory::getApplication ();
$form = JRequest::getBool ( 'form' );

if ($form) {
$state = JRequest::getVar ( 'cid', array (), 'post', 'array' );
$app->setUserState ( 'com_kunenaimporter.state', $state );
} else {
$state = $app->getUserState ( 'com_kunenaimporter.state' );
if (! is_array ( $state ))
$state = array ();
JRequest::setVar ( 'cid', $state, 'post' );
}
return array_flip ( $state );
}

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

function stopimport() {
$app = JFactory::getApplication ();
public function stopimport() {
$this->setredirect ( 'index.php?option=com_kunenaimporter' );
}

function truncatetable() {
public function truncatetable() {
$limit = 1000;
$timeout = false;

$db = JFactory::getDBO ();
$app = JFactory::getApplication ();

$importer = & $this->getModel ( 'import' );

$importer = $this->getModel ( 'import' );
$options = $importer->getImportOptions ();
$state = $this->getParams ();
$optlist = array ();
Expand All @@ -103,7 +65,7 @@ function truncatetable() {
$this->setredirect ( 'index.php?option=com_kunenaimporter' );
}

function truncatemap() {
public function truncatemap() {
$importer = $this->getModel ( 'import' );
$importer->truncateUsersMap ();
$app = JFactory::getApplication ();
Expand All @@ -112,11 +74,10 @@ function truncatemap() {
$this->setredirect ( 'index.php?option=com_kunenaimporter&view=users' );
}

function mapusers() {
public function mapusers() {
$limit = 100;
$timeout = false;

$db = JFactory::getDBO ();
$app = JFactory::getApplication ();

$component = JComponentHelper::getComponent ( 'com_kunenaimporter' );
Expand All @@ -139,7 +100,6 @@ function mapusers() {
$timeout = $this->checkTimeout ();
} while ( $result['now'] && ! $timeout );

//JToolBarHelper::back();
if ($timeout) {
$view = '&view=mapusers';
} else {
Expand All @@ -151,7 +111,7 @@ function mapusers() {
$this->setredirect ( 'index.php?option=com_kunenaimporter' . $view );
}

function selectuser() {
public function selectuser() {
$extid = JRequest::getInt ( 'extid', 0 );
$cid = JRequest::getVar ( 'cid', array (0 ), 'post', 'array' );
$userdata ['id'] = array_shift ( $cid );
Expand All @@ -163,7 +123,7 @@ function selectuser() {
require_once (JPATH_COMPONENT . DS . 'models' . DS . 'kunena.php');
$importer = $this->getModel ( 'import' );

$extuser = JTable::getInstance ( 'ExtUser', 'CKunenaTable' );
$extuser = JTable::getInstance ( 'ExtUser', 'KunenaImporterTable' );
$extuser->load ( $extid );
$success = true;
$oldid = $extuser->id;
Expand All @@ -177,15 +137,14 @@ function selectuser() {
$importer->updateUserData(-$extid, $oldid);
}

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

function importforum() {
public function importforum() {
$limit = 1000;
$timeout = false;

$db = JFactory::getDBO ();
$app = JFactory::getApplication ();

$component = JComponentHelper::getComponent ( 'com_kunenaimporter' );
Expand All @@ -207,7 +166,7 @@ function importforum() {
if (isset ( $state [$option] )) {
$count = 0;
do {
$data = & $exporter->exportData ( $option, $start, $limit );
$data = $exporter->exportData ( $option, $start, $limit );
$importer->importData ( $option, $data );
$count = count ( $data );
$start += $count;
Expand All @@ -220,7 +179,6 @@ function importforum() {
break;
}

//JToolBarHelper::back();
if ($timeout)
$view = '&view=import';
else {
Expand Down Expand Up @@ -251,7 +209,7 @@ function importforum() {
*/
}

function save() {
public function save() {
$component = 'com_kunenaimporter';

$table = JTable::getInstance ( 'component' );
Expand All @@ -277,7 +235,7 @@ function save() {
$this->setRedirect ( $link, $msg, $type );
}

function display() {
public function display() {
$params = $this->getParams ();
$cmd = JRequest::getCmd ( 'view', 'default' );
$view = $this->getView ( $cmd, 'html' );
Expand All @@ -291,4 +249,34 @@ function display() {

$view->display ();
}

protected function checkTimeout() {
static $start = null;

list ( $usec, $sec ) = explode ( ' ', microtime () );
$time = (( float ) $usec + ( float ) $sec);

if (empty ( $start ))
$start = $time;

if ($time - $start < 4)
return false;
return true;
}

protected function getParams() {
$app = JFactory::getApplication ();
$form = JRequest::getBool ( 'form' );

if ($form) {
$state = JRequest::getVar ( 'cid', array (), 'post', 'array' );
$app->setUserState ( 'com_kunenaimporter.state', $state );
} else {
$state = $app->getUserState ( 'com_kunenaimporter.state' );
if (! is_array ( $state ))
$state = array ();
JRequest::setVar ( 'cid', $state, 'post' );
}
return array_flip ( $state );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
defined ( '_JEXEC' ) or die ();

// Initialize the database
$db = & JFactory::getDBO ();
$db = JFactory::getDBO ();
$update_queries = array ("CREATE TABLE IF NOT EXISTS `#__kunenaimporter_users` (
`extid` int(11) NOT NULL auto_increment,
`extusername` varchar(150) NOT NULL default '',
Expand Down
34 changes: 17 additions & 17 deletions administrator/components/com_kunenaimporter/models/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ class KunenaimporterModelExport extends JModel {
var $importOps = array ();
var $auth_method;

function __construct() {
$app = JFactory::getApplication ();
public function __construct() {
parent::__construct ();

$component = JComponentHelper::getComponent ( 'com_kunenaimporter' );
Expand All @@ -44,13 +43,14 @@ function __construct() {
$this->ext_database = JFactory::getDBO ();
$this->ext_same = 1;
} else {
$app = JFactory::getApplication ();
$option ['driver'] = $app->getCfg ( 'dbtype' );
$option ['host'] = $params->get ( 'db_host' );
$option ['user'] = $params->get ( 'db_user' );
$option ['password'] = $params->get ( 'db_passwd' );
$option ['database'] = $params->get ( 'db_name' );
$option ['prefix'] = $params->get ( 'db_prefix' );
$this->ext_database = & JDatabase::getInstance ( $option );
$this->ext_database = JDatabase::getInstance ( $option );
}
}
// TODO: make this to work
Expand All @@ -59,7 +59,7 @@ function __construct() {
$this->buildImportOps ();
}

function getExportOptions($importer) {
public function getExportOptions($importer) {
$app = JFactory::getApplication ();

$options = $importer->getImportOptions ();
Expand All @@ -77,7 +77,7 @@ function getExportOptions($importer) {
return $exportOpt;
}

function checkConfig() {
public function checkConfig() {
$this->addMessage ( '<h2>Importer Status</h2>' );

// Kunena detection and version check
Expand All @@ -102,23 +102,23 @@ function checkConfig() {
$this->addMessage ( '<div>Database connection: <b style="color:green">OK</b></div>' );
}

function getAuthMethod() {
public function getAuthMethod() {
return $this->auth_method;
}

function addMessage($msg) {
protected function addMessage($msg) {
$this->messages [] = $msg;
}

function getMessages() {
public function getMessages() {
return implode ( '', $this->messages );
}

function getError() {
public function getError() {
return $this->error;
}

function getCount($query) {
public function getCount($query) {
$this->ext_database->setQuery ( $query );
$result = $this->ext_database->loadResult ();
if ($this->ext_database->getErrorNum ()) {
Expand All @@ -128,7 +128,7 @@ function getCount($query) {
return $result;
}

function &getExportData($query, $start = 0, $limit = 0, $key = null) {
public function &getExportData($query, $start = 0, $limit = 0, $key = null) {
$this->ext_database->setQuery ( $query, $start, $limit );
$result = $this->ext_database->loadObjectList ( $key );
if ($this->ext_database->getErrorNum ()) {
Expand All @@ -138,7 +138,7 @@ function &getExportData($query, $start = 0, $limit = 0, $key = null) {
return $result;
}

function countData($operation) {
public function countData($operation) {
$result = 0;
if (empty ( $this->importOps [$operation] ))
return false;
Expand All @@ -155,7 +155,7 @@ function countData($operation) {
return $result;
}

function &exportData($operation, $start = 0, $limit = 0) {
public function &exportData($operation, $start = 0, $limit = 0) {
$result = array ();
if (empty ( $this->importOps [$operation] ))
return $result;
Expand All @@ -172,14 +172,14 @@ function &exportData($operation, $start = 0, $limit = 0) {
return $result;
}

function countMapUsers() {
public function countMapUsers() {
$db = JFactory::getDBO();
$query = "SELECT COUNT(*) FROM #__users";
$db->setQuery ($query);
return $db->loadResult ();
}

function &exportMapUsers($start = 0, $limit = 0) {
public function &exportMapUsers($start = 0, $limit = 0) {
$db = JFactory::getDBO();
$query = "SELECT id, username FROM #__users";
$db->setQuery ( $query, $start, $limit );
Expand All @@ -189,7 +189,7 @@ function &exportMapUsers($start = 0, $limit = 0) {
$count++;
$extid = $this->mapJoomlaUser($user);
if ($extid) {
$extuser = JTable::getInstance ( 'ExtUser', 'CKunenaTable' );
$extuser = JTable::getInstance ( 'ExtUser', 'KunenaImporterTable' );
$extuser->load ( $extid );
if ($extuser->exists() && !$extuser->id) {
$extuser->id = $user->id;
Expand All @@ -202,7 +202,7 @@ function &exportMapUsers($start = 0, $limit = 0) {
return $users;
}

function &exportJoomlaUsers($start = 0, $limit = 0) {
public function &exportJoomlaUsers($start = 0, $limit = 0) {

}

Expand Down
Loading

0 comments on commit f6d56fa

Please sign in to comment.