Skip to content

Commit

Permalink
Merge pull request Kunena#22 from xillibit/master
Browse files Browse the repository at this point in the history
Improve ccboard and agora support
  • Loading branch information
mahagr committed Jul 10, 2011
2 parents 0570c95 + 91ce826 commit 38e4392
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 10 deletions.
1 change: 1 addition & 0 deletions administrator/components/com_kunenaimporter/CHANGELOG.php
Expand Up @@ -35,6 +35,7 @@
10-July-2011 Xillibit
# [#18] Notice: Undefined property: KunenaimporterViewDefault::$options in \views\default\tmpl\default.php on line 47
^ [#21] Improve ccboard and agora support
9-July-2011 Matias
# [#5] phpBB3 support: Detect that php3 directory exists
Expand Down
110 changes: 105 additions & 5 deletions administrator/components/com_kunenaimporter/models/export_agora.php
Expand Up @@ -25,14 +25,40 @@ class KunenaimporterModelExport_Agora extends KunenaimporterModelExport {

public function checkConfig() {
parent::checkConfig();
if (JError::isError($this->ext_database)) return;

$query = "SELECT conf_value FROM `#__agora_config` WHERE `conf_name` = 'o_cur_version'";
$this->setQuery ( $query );
$this->version = $this->ext_database->loadResult ();
if (! $this->version) {
$this->error = $this->getErrorMsg ();
if (! $this->error)
$this->error = 'Configuration information missing: Agora version not found';
}
if ($this->error) {
$this->addMessage ( '<div>Agora version: <b style="color:red">FAILED</b></div>' );
return false;
}

if (version_compare($this->version, '3.0.142', '<'))
$this->error = "Unsupported forum: Agora $this->version";
if ($this->error) {
$this->addMessage ( '<div>Agora version: <b style="color:red">' . $this->version . '</b></div>' );
$this->addMessage ( '<div><b>Error:</b> ' . $this->error . '</div>' );
return false;
}
$this->addMessage ( '<div>Agora version: <b style="color:green">' . $this->version . '</b></div>' );
}

public function buildImportOps() {
// query: (select, from, where, groupby), functions: (count, export)
$importOps = array();
$importOps ['config'] = array ('count' => 'countConfig', 'export' => 'exportConfig' );
$importOps['categories'] = array('count'=>'countCategories', 'export'=>'exportCategories');
$importOps ['messages'] = array ('count' => 'countMessages', 'export' => 'exportMessages' );
$importOps ['subscriptions'] = array ('count' => 'countSubscriptions', 'export' => 'exportSubscriptions' );
$importOps ['smilies'] = array ('count' => 'countSmilies', 'export' => 'exportSmilies' );
$importOps ['ranks'] = array ('count' => 'countRanks', 'export' => 'exportRanks' );
$importOps ['userprofile'] = array ('count' => 'countUserprofile', 'export' => 'exportUserprofile' );
$this->importOps = $importOps;
}

Expand Down Expand Up @@ -211,6 +237,43 @@ public function &exportCategories($start=0, $limit=0) {
return $result;
}

public function countMessages() {
$query = "SELECT COUNT(*) FROM #__aogra_messages";
return $this->getCount ( $query );
}

public function &exportMessages($start = 0, $limit = 0) {
$query = "SELECT
t.id AS id,
t.poster AS name,
IF(p.topic_id=t.id,0,p.topic_id) AS parent,
t.sticky AS ordering,
t.subject AS subject,
t.num_views AS hits,
t.closed AS locked,
t.forum_id AS catid,
u.jos_id AS userid,
p.poster_ip AS ip,
p.poster_email AS email,
p.message AS message,
p.posted AS time,
p.topic_id AS thread
p.edited AS modified_time,
p.edited_by AS modified_by
FROM `#__aogra_topics` AS t
LEFT JOIN `#__agora_posts` AS p ON p.topic_id = t.id
LEFT JOIN `#__agora_users` AS u ON p.poster_id = u.id
WHERE t.announcements='0'
ORDER BY t.id";
$result = $this->getExportData ( $query, $start, $limit, 'id' );
foreach ( $result as &$row ) {
$row->subject = $this->prep ( $row->subject );
$row->message = $this->prep ( $row->message );
}
return $result;
}

public function countSmilies() {
return false;

Expand Down Expand Up @@ -239,14 +302,17 @@ public function &exportRanks($start=0, $limit=0)
return $result;
}

public function countUsers() {
public function countUserprofile() {
$query="SELECT count(*) FROM #__agora_users";
return $this->getCount($query);
}

public function &exportUsers($start=0, $limit=0) {
$query="SELECT url AS websiteurl, icq AS ICQ, msn AS MSN, aim AS AIM, yahoo AS YAHOO, skype AS SKYPE, location, signature, gender, birthday AS birhtdate, aboutme AS personnalText FROM #__agora_users";
public function &exportUserprofile($start=0, $limit=0) {
$query="SELECT url AS websiteurl, icq AS ICQ, msn AS MSN, aim AS AIM, yahoo AS YAHOO, skype AS SKYPE, location, signature, gender, birthday AS birhtdate, aboutme AS personnalText, num_posts AS posts FROM #__agora_users";
$result = $this->getExportData($query, $start, $limit);
foreach ( $result as $key => &$row ) {
//$row->avatarpath = JPATH_BASE . '/components/com_agora/img/pre_avatars/'. $row->id;
}
}

public function countPolls() {
Expand All @@ -255,10 +321,44 @@ public function countPolls() {
}

public function &exportPolls($start=0, $limit=0) {
$query="SELECT options,voters,votes FROM #__agora_polls";
$query="SELECT p.pollid AS id,p.options,p.voters,p.votes, t.question AS title
FROM #__agora_polls AS p
LEFT JOIN #__agora_topics AS t ON p.pollid=t.id";
$result = $this->getExportData($query, $start, $limit);
}

public function countSubscriptions() {
$query = "SELECT COUNT(*) FROM `#__agora_subscriptions`";
return $this->getCount ( $query );
}

public function &exportSubscriptions($start = 0, $limit = 0) {
$query = "SELECT
w.topic_id AS thread,
w.user_id AS userid
FROM `#__agora_subscriptions` AS w";
$result = $this->getExportData ( $query, $start, $limit );
return $result;
}

public function countBans() {
$query = "SELECT COUNT(*) FROM `#__agora_bans`";
return $this->getCount ( $query );
}

public function &exportBans($start = 0, $limit = 0) {
$query = "SELECT
ban.id AS id,
ban.ip AS ip,
u.jos_id AS userid,
ban.message AS comments,
ban.expire AS expiration
FROM `#__agora_bans` AS ban
LEFT JOIN `#__agora_users` AS u ON ban.username=u.username";
$result = $this->getExportData ( $query, $start, $limit );
return $result;
}

protected function prep($s) {
return $s;
}
Expand Down
Expand Up @@ -28,8 +28,6 @@ public function checkConfig() {
jimport ( 'joomla.filesystem.file' );

parent::checkConfig ();
if (JError::isError ( $this->ext_database ))
return;

// the ccboard config is only stored in ccboard.xml file
$xml = JPATH_ADMINISTRATOR . '/components/com_ccboard/ccboard.xml';
Expand Down Expand Up @@ -252,7 +250,7 @@ public function &exportAttachments($start = 0, $limit = 0) {
$query = "SELECT post_id AS mesid, ccb_name AS userid, filesize AS size, real_name AS filename, mimetype AS filetype FROM #__ccb_attachments";
$result = $this->getExportData ( $query, $start, $limit );
foreach ( $result as $key => &$row ) {
$row->userid = substr ( $row->userid, 0, 2 );
$row->location = JPATH_BASE.'/components/com_ccboard/assets/uploads/'.$row->ccb_name ;
}
return $result;
}
Expand Down Expand Up @@ -280,8 +278,8 @@ public function &exportRanks($start = 0, $limit = 0) {
$query = "SELECT rank_title,rank_min,rank_special,rank_image FROM #__ccb_ranks";
$result = $this->getExportData ( $query, $start, $limit );
foreach ( $result as $rank ) {
if ( JFile::exists(JPATH_BASE . 'components/com_ccboard/assets/ranks/' . $rank->rank_image) ) {
JFile::copy ( JPATH_BASE . 'components/com_ccboard/assets/ranks/' . $rank->rank_image, JPATH_BASE . 'components/com_kunena/template/default/images/ranks' );
if ( JFile::exists(JPATH_BASE . '/components/com_ccboard/assets/ranks/' . $rank->rank_image) ) {
JFile::copy ( JPATH_BASE . '/components/com_ccboard/assets/ranks/' . $rank->rank_image, JPATH_BASE . '/components/com_kunena/template/default/images/ranks' );
}
}

Expand Down Expand Up @@ -312,6 +310,7 @@ public function &exportUserprofile($start = 0, $limit = 0) {
$query = "SELECT user_id AS userid,location,signature,avatar,rank,post_count AS posts,gender,www,icq AS ICQ,aol AS AOL,msn AS MSN,yahoo AS YAHOO,jabber AS GTALK,skype AS SKYPE,showemail AS hideEmail,moderator,karma,karma_time,hits AS uhits FROM #__ccb_users";
$result = $this->getExportData ( $query, $start, $limit );
foreach ( $result as $key => &$row ) {
$row->avatarpath = JPATH_BASE . '/components/com_ccboard/assets/avatar/'. $row->avatar;
$row->signature = $this->prep ( $row->signature );
$row->gender = $row->gender == 'Male' ? '1' : '2';
}
Expand Down

0 comments on commit 38e4392

Please sign in to comment.