Skip to content

Commit

Permalink
+ [Kunena#17] Enable SMF2 support
Browse files Browse the repository at this point in the history
* Fix broken configuration import
* Import avatar galleries
  • Loading branch information
mahagr committed Jul 9, 2011
1 parent 49e67ca commit 4274593
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 18 deletions.
3 changes: 3 additions & 0 deletions administrator/components/com_kunenaimporter/CHANGELOG.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
# [#5] phpBB3 support: Detect that php3 directory exists
+ [#5] phpBB3 support: Remove dependence to rokBridge by adding missing functions
+ [#5] phpBB3 support: Add automatic user mapping
+ [#17] Enable SMF2 support
# [#17] SMF2 support: Fix broken configuration import
+ [#17] SMF2 support: Import avatar galleries

8-July-2011 Matias
+ [#5] phpBB3 support: Store passwords with some metadata (phpbb2/phpbb3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ td.notes {
color: green;
}
div.info {
background:#FFFFDD; color:#333 ;padding:10px;
background:#FFFFDD;
color:#333;
padding:10px;
border: 1px solid #CCCC66;
}
div.info h2 {
margin-top: 2px;
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_kunenaimporter/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<option value='phpbb3'>phpBB3</option>
<!-- <option value='phpbb2'>phpBB2</option> -->
<!-- <option value='pnphpbb2'>PNphpBB2</option> -->
<!-- <option value='smf2'>SMF2</option> -->
<option value='smf2'>SMF2</option>
</param>
<param name='path' type='text' default='' label='Relative Path to Forum' description='Please enter the relative system path to the installation of the forum you want to import from.' size='30' />
<!-- <param name='db_host' type='text' default='localhost' label='Database Host' description='' size='30' />
Expand Down
81 changes: 65 additions & 16 deletions administrator/components/com_kunenaimporter/models/export_smf2.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class KunenaimporterModelExport_Smf2 extends KunenaimporterModelExport {
var $auth_method;
var $params;
protected $config = null;
protected $settings = null;

public function __construct() {
$component = JComponentHelper::getComponent ( 'com_kunenaimporter' );
Expand All @@ -44,6 +45,16 @@ public function __construct() {
parent::__construct ();
}

protected function getSettings() {
if (empty($this->settings)) {
// Check if database settings are correct
$query = "SELECT variable, value FROM #__settings";
$this->ext_database->setQuery ( $query );
$this->settings = $this->ext_database->loadObjectList ('variable');
}
return $this->settings;
}

public function getConfiguration() {
if (!$this->config) {
$configFile = JPATH_ROOT . '/' . $this->params->get('path') . '/Settings.php';
Expand Down Expand Up @@ -89,7 +100,8 @@ public function checkConfig() {
return false;
}
$this->addMessage ( '<div>SMF version: <b style="color:green">' . $this->version . '</b></div>' );
}
$this->getSettings();
}

public function getAuthMethod() {
return $this->auth_method;
Expand All @@ -106,6 +118,7 @@ public function buildImportOps() {
$importOps ['sessions'] = array ('count' => 'countSessions', 'export' => 'exportSessions' );
$importOps ['subscriptions'] = array ('count' => 'countSubscriptions', 'export' => 'exportSubscriptions' );
$importOps ['userprofile'] = array ('count' => 'countUserProfile', 'export' => 'exportUserProfile' );
$importOps ['avatargalleries'] = array ('count' => 'countAvatarGalleries', 'export' => 'exportAvatarGalleries' );
$this->importOps = $importOps;
}

Expand Down Expand Up @@ -203,15 +216,15 @@ public function &exportConfig($start = 0, $limit = 0) {
$config = array ();
if ($start)
return $config;
$query = "SELECT * FROM `#__settings`";
$query = "SELECT variable, value FROM `#__settings`";
$this->ext_database->setQuery ( $query );
$result = $this->ext_database->loadObjectList ();
$result = $this->ext_database->loadObjectList ('variable');

$config ['id'] = 1;
$config ['board_title'] = $this->config['mbname'];
$config ['email'] = $this->config['webmaster_email'];
$config ['board_offline'] = (bool)$this->config['maintenance'];
$config ['board_ofset'] = $result->time_offset; // + default_timezone
$config ['board_ofset'] = $result['time_offset']->value; // + default_timezone
$config ['offline_message'] = "<h1>{$this->config['mmessage']}</h1><p>{$this->config['mmessage']}</p>";
// $config ['default_view'] = null;
// $config ['enablerss'] = null;
Expand Down Expand Up @@ -272,19 +285,19 @@ public function &exportConfig($start = 0, $limit = 0) {
// $config ['avatarsmallwidth'] = null;
// $config ['avatarheight'] = null;
// $config ['avatarwidth'] = null;
$config ['avatarlargeheight'] = $result->avatar_max_height_upload;
$config ['avatarlargewidth'] = $result->avatar_max_width_upload;
$config ['avatarlargeheight'] = $result['avatar_max_height_upload']->value;
$config ['avatarlargewidth'] = $result['avatar_max_width_upload']->value;
// $config ['avatarquality'] = null;
// $config ['avatarsize'] = null;
$config ['allowimageupload'] = $result->attachmentEnable;
$config ['allowimageupload'] = $result['attachmentEnable']->value;
// $config ['allowimageregupload'] = null;
$config ['imageheight'] = $result->max_image_height;
$config ['imagewidth'] = $result->max_image_width;
$config ['imagesize'] = $result->attachmentSizeLimit;
$config ['allowfileupload'] = $result->attachmentEnable;
$config ['imageheight'] = $result['max_image_height']->value;
$config ['imagewidth'] = $result['max_image_width']->value;
$config ['imagesize'] = $result['attachmentSizeLimit']->value;
$config ['allowfileupload'] = $result['attachmentEnable']->value;
// $config ['allowfileregupload'] = null;
// $config ['filetypes'] = null;
$config ['filesize'] = $result->attachmentSizeLimit;
$config ['filesize'] = $result['attachmentSizeLimit']->value;
// $config ['showranking'] = null;
// $config ['rankimages'] = null;
// $config ['avatar_src'] = null;
Expand Down Expand Up @@ -315,7 +328,7 @@ public function &exportConfig($start = 0, $limit = 0) {
// $config ['latestshowhits'] = null;
// $config ['latestshowauthor'] = null;
// $config ['showstats'] = null;
$config ['showwhoisonline'] = $result->who_enabled;
$config ['showwhoisonline'] = $result['who_enabled']->value;
// $config ['showgenstats'] = null;
// $config ['showpopuserstats'] = null;
// $config ['popusercount'] = null;
Expand Down Expand Up @@ -368,8 +381,8 @@ public function &exportConfig($start = 0, $limit = 0) {
// $config ['checkmimetypes'] = null;
// $config ['imagemimetypes'] = null;
// $config ['imagequality'] = null;
$config ['thumbheight'] = $result->attachmentThumbHeight;
$config ['thumbwidth'] = $result->attachmentThumbWidth;
$config ['thumbheight'] = $result['attachmentThumbHeight']->value;
$config ['thumbwidth'] = $result['attachmentThumbWidth']->value;
// $config ['hideuserprofileinfo'] = null;
// $config ['integration_access'] = null;
// $config ['integration_login'] = null;
Expand Down Expand Up @@ -513,7 +526,23 @@ public function &exportUserProfile($start = 0, $limit = 0) {
FROM `#__members` AS u
ORDER BY u.id_member";
$result = $this->getExportData ( $query, $start, $limit, 'userid' );

if (!empty($this->settings['custom_avatar_enabled']->value)) {
$avatar_path = $this->settings['custom_avatar_dir']->value;
} elseif (!empty($this->settings['currentAttachmentUploadDir']->value)) {
$avatar_path = $this->settings['custom_avatar_dir']->value;
}
foreach ( $result as &$row ) {
if ($row->avatar) {
if (stristr($row->avatar, 'http://')) {
// URLs are not supported
$row->avatar = '';
} else {
// Gallery
$row->avatar = "gallery/{$row->avatar}";
}
}

// Convert bbcode in signature
$row->signature = $this->prep ( $row->signature );
$row->location = $this->prep ( $row->location );
Expand All @@ -533,7 +562,7 @@ public function &exportUsers($start = 0, $limit = 0) {
u.real_name AS name,
u.member_name AS username,
u.email_address AS email,
CONCAT(u.password_salt,':',u.passwd) AS password,
CONCAT('smf2::', u.password_salt,':',u.passwd) AS password,
'Registered' AS usertype,
IF(is_activated>0,0,1) AS block,
0 AS gid,
Expand Down Expand Up @@ -582,6 +611,26 @@ public function mapJoomlaUser($joomlauser) {
return $result;
}

protected function &getAvatarGalleries() {
static $galleries = false;
if ($galleries === false) {
$path = $this->settings['avatar_directory']->value;
$galleries = array();
$folders = JFolder::folders($path);
foreach ($folders as $folder) {
$galleries[$folder] = "{$path}/{$folder}";
}
}
return $galleries;
}
public function countAvatarGalleries() {
return count($this->getAvatarGalleries());
}
public function &exportAvatarGalleries($start = 0, $limit = 0) {
$galleries = $this->getAvatarGalleries();
return array_slice($galleries, $start, $limit);
}

protected function prep($s) {
$s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
$s = preg_replace ( "/\r/", '', $s );
Expand Down

0 comments on commit 4274593

Please sign in to comment.