×
Kunena 5.2 Beta 1 Released (24 Sep 2020)

The Kunena team is thrilled to announce the first public beta release of Kunena 5.2, a native Joomla extension for Joomla 3.9. This is a development release and should be only be used for testing; this version is not recommended for live websites at this stage.

The purpose of this release is to encourage testing by downloading, installing and identifying any problems or shortcomings that people may discover. K 5.2.0 B1 is stable and we are aware that people will discover defects. We encourage you to use the forum to report defects, as soon as they are discovered, so that the development team can work through the problems before the release of K 5.1 as a stable product. Reporting defects does not mean that the problems can or will be fixed. The Kunena team is looking forward to hearing your feedback on how well we have achieved our design goals.

× This is for users to help other users, to discuss topics that relate to migrating from other web-based forums and converting the data into a form that will operate with Kunena.

It is important to note that the Kunena team does not have a standard, recommended or supported protocol for these ideas and that posting questions in this category may not receive advice from team members.

Important Agora to Kunena script - PHP help wanted

More
5 years 11 months ago - 5 years 10 months ago #1 by Symbiot
Hi

I found an old script and modified it to work with kunena 3 & agora 3..

but it seems there's some error with converting the messages & messages_text .
it runs ok, but no data is migrated.

everything else looks fine..


can someone help with the last part of the script. it's at the bottom.
<?php
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AGORA 3.0.x to Kunena 2.0.x converter //////////////////////////////////////////////////////////////////////////////////////
// Converter version 0.2.1                 //////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
//enter your database credentials here.
$host = "localhost";
$user = "user";
$pass = "pass";
$db = "test";
 
$link = mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_selectdb($db,$link) or die(mysql_error());
$ag_forums_to_kunena_categories = array();
 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// converting Agora categories to Kunena categories using original category-ID ////////////////////////////////////////////////
mysql_query("TRUNCATE bzhv8_kunena_categories");
$sql = "
SELECT
 c.id AS categories_id,
 c.cat_name AS categories_name,
 c.disp_position AS categories_ordering, 
 c.enable AS categories_published
 
FROM jos_agora_categories AS c
 
ORDER BY c.disp_position ASC
";
 
$res = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_object($res))
{
	echo $row->c.id;
	echo "<br />";
	$sql = "INSERT INTO `bzhv8_kunena_categories` VALUES (".$row->categories_id.", 0, '".mysql_real_escape_string($row->categories_name)."', '', 0, 0, 'joomla.group', 2, 2, 1, 8, 0, ".$row->categories_ordering.", ".$row->categories_published.", NULL, 0, '0000-00-00 00:00:00', 0, 0, 0, 0, '', '', '', 0, 'lastpost', 0, 0, 0, 0, 0, '{}')";
	echo $sql;
	echo "<br />";
	mysql_query($sql) or die(mysql_error());
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// converting Agora Forums to Kunena categories using modified category-ID ////////////////////////////////////////////////////
// first of all count how many agory categories are here. Start catid plus 1 for Forums ///////////////////////////////////////
$sqlnum = "SELECT * FROM jos_agora_categories";
$resnum = mysql_query($sqlnum);
$rows = mysql_num_rows($resnum); 
 
$maxidquery = "SELECT id FROM jos_agora_categories ORDER BY id DESC LIMIT 0,1";
$resmax = mysql_query($maxidquery);
$resmaxid = mysql_fetch_array($resmax);
$maxid = $resmaxid['id'];
 
$cat_mod_id=$maxid+1;
////////////////////////////////////////////////
$sql = "
SELECT
 f.id AS categories_id,
 f.enable AS categories_published,
 f.forum_name AS categories_name,
 f.forum_desc AS categories_description,
 f.num_topics AS categories_numTopics,
 f.num_posts AS categories_numPosts,
 f.last_post AS categories_last_post_time,
 f.last_post_id AS categories_last_post_id,
 f.disp_position AS categories_ordering,
 f.cat_id AS categories_parent_id,
 f.closed AS categories_locked
 
FROM jos_agora_forums AS f
 
ORDER BY f.disp_position ASC
";
$res = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_object($res))
{
	echo $cat_mod_id;
	echo "<br />";
	if($row->categories_last_post_time == '')
	{
		$row->categories_last_post_time = 0;
		$row->categories_last_post_id = 0;
	}
	echo $row->categories_last_post_time;
	echo "<br />";
	$sql = "INSERT INTO `bzhv8_kunena_categories` VALUES (".$cat_mod_id.", ".$row->categories_parent_id.", '".mysql_real_escape_string($row->categories_name)."', '', 0, 0, 'joomla.group', 1, 2, 1, 8, 0, ".$row->categories_ordering.", 1, NULL, 0, '0000-00-00 00:00:00', 0, 0, 0, 0, '".mysql_real_escape_string($row->categories_description)."', '', '', 1, 'lastpost', ".$row->categories_numTopics.", ".$row->categories_numPosts.", 0, ".$row->categories_last_post_id.", ".$row->categories_last_post_time.", '{\"access_post\":[\"6\",\"7\",\"2\",\"3\",\"4\",\"5\",\"8\"],\"access_reply\":[\"6\",\"7\",\"2\",\"3\",\"4\",\"5\",\"8\"]}')";
	echo $sql;
	echo "<br />";
	mysql_query($sql) or die(mysql_error());
	$ag_forums_to_kunena_categories [$row->categories_id] = $cat_mod_id;
	$cat_mod_id++;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
echo "ARRAY:";
echo "<br />";
print_r($ag_forums_to_kunena_categories);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// convert topics from Agora to Kunena ////////////////////////////////////////////////////////////////////////////////////////
mysql_query("TRUNCATE bzhv8_kunena_topics");
$sql = "
SELECT
 t.id AS topic_id,
 t.poster AS topic_poster,
 t.subject AS topic_subject, 
 t.posted AS topic_first_post_time, 
 t.last_post AS topic_last_post_time, 
 t.last_post_id AS topic_last_post_id, 
 t.last_poster AS topic_last_poster, 
 t.num_views AS topic_hits, 
 t.num_replies AS topic_posts, 
 t.closed AS topic_locked, 
 t.sticky AS topic_hold, 
 t.moved_to AS topic_moved_id, 
 t.forum_id AS topic_category_id, 
 t.question AS topic_poll_id,
 p.id AS topic_first_post_id, 
 p.posted AS topic_first_post_time, 
 a.jos_id AS topic_first_post_userid,
 p.message AS topic_first_post_message
 
FROM jos_agora_topics AS t
LEFT JOIN jos_agora_users AS a ON a.username = t.poster
LEFT JOIN jos_agora_posts AS p ON t.posted = p.posted
ORDER BY t.id ASC
";
 
$res = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_object($res))
{
	echo $row->topic_id;
	echo "<br />";
	if($row->topic_first_post_userid == '')
	{
		$row->topic_first_post_userid = 0;
	}
 
	$cat_id = $ag_forums_to_kunena_categories[$row->topic_category_id];
	echo $cat_id;
	echo "<br />";
	$sql = "INSERT INTO `bzhv8_kunena_topics` VALUES (".$row->topic_id.", ".$cat_id.", '".mysql_escape_string($row->topic_subject)."', 0, ".$row->topic_locked.", ".$row->topic_hold.", 0, ".$row->topic_posts.", ".$row->topic_hits.", 0, 0, 0, ".$row->topic_first_post_id.", ".$row->topic_first_post_time.", ".$row->topic_first_post_userid.", '".mysql_escape_string($row->topic_first_post_message)."', NULL, ".$row->topic_last_post_id.", ".$row->topic_last_post_time.", 0, NULL, NULL, '')";
	echo $sql;
	echo "<br />";
	mysql_query($sql) or die(mysql_error());
}
 
$sql = "
SELECT
 t.id AS topic_id, 
 t.last_post AS topic_last_post_time, 
 t.last_post_id AS topic_last_post_id, 
 t.last_poster AS topic_last_poster,
 a.jos_id AS topic_last_post_userid,
 p.message AS topic_last_post_message
 
FROM jos_agora_topics AS t
LEFT JOIN jos_agora_users AS a ON a.username = t.last_poster
LEFT JOIN jos_agora_posts AS p ON t.last_post_id = p.id
ORDER BY t.id ASC
";
 
$res = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_object($res))
{
	echo $row->topic_id;
	echo "<br />";
	$topic_last_post_message = mysql_real_escape_string($row->topic_last_post_message);
 
	if($row->topic_last_post_userid == '')
	{
		$row->topic_last_post_userid = 0;
	}
 
	$cat_id = $ag_forums_to_kunena_categories[$row->topic_category_id];
	echo $cat_id;
	echo "<br />";
	$sql = "UPDATE `bzhv8_kunena_topics` SET `last_post_id` = ".$row->topic_last_post_id.",`last_post_time` = ".$row->topic_last_post_time.",`last_post_userid` = ".$row->topic_last_post_userid.",`last_post_message` = '".mysql_escape_string($row->topic_last_post_message)."',`last_post_guest_name` = NULL,`params` = '' WHERE  `bzhv8_kunena_topics`.`id` = ".$row->topic_id."";
	echo $sql;
	echo "<br />";
	mysql_query($sql) or die(mysql_error());
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
 
// convert Posts from Agora tu Kunena /////////////////////////////////////////////////////////////////////////////////////////
 
mysql_query("TRUNCATE bzhv8_kunena_messages");
mysql_query("TRUNCATE bzhv8_kunena_messages_text");
$sql = "
SELECT
 p.id AS messages_id, 
 u.name AS messages_name, 
 a.jos_id AS messages_userid, 
 p.message AS messages_text_message,
 p.posted AS messages_time,
 p.edited AS messages_modified_time,
 p.edited_by AS messages_modified_by,
 p.topic_id AS messages_thread,
 t.forum_id AS messages_catid
 
FROM jos_agora_posts AS p
LEFT JOIN jos_agora_users AS a ON a.username = p.poster
LEFT JOIN jos_agora_topics AS t ON t.id = p.topic_id
LEFT JOIN bzhv8_users AS u ON u.id = a.jos_id
 
ORDER BY p.id ASC
";
 
$res = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_object($res))
{
	echo $row->messages_id;
	echo "<br />";
	if($row->messages_userid == '')
	{
		$row->messages_userid = 0;
	}
 
	$cat_id = $ag_forums_to_kunena_categories[$row->messages_catid];
	if ($cat_id != 0)
	{
		echo $cat_id;
		echo "<br />";
		$sql = "INSERT INTO `bzhv8_kunena_messages` VALUES (".$row->messages_id.", 0, ".$row->messages_thread.", ".$cat_id.", '".$row->messages_name."', ".$row->messages_userid.", '', '', ".$row->messages_time.", NULL, 0, 0, 0, 0, 0, 0, 0, 0, '')";
		$sql2 = "INSERT INTO `bzhv8_kunena_messages_text` VALUES (".$row->messages_id.", '".mysql_escape_string($row->messages_text_message)."')";
		echo $sql;
		echo "<br />";
		echo $sql2;
		echo "<br />";
		mysql_query($sql) or die(mysql_error());
		mysql_query($sql2) or die(mysql_error());
	}
}
mysql_close();
Last edit: 5 years 10 months ago by xillibit.

Please Log in or Create an account to join the conversation.

More
5 years 11 months ago #2 by Symbiot
it seems that this part:
$res = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_object($res))
{
echo $row->messages_id;
echo "<br />";
if($row->messages_userid == '')
{
$row->messages_userid = 0;
}

it echo's the $row-messages_id; and the br of course..

but that's as far as the script goes...

Please Log in or Create an account to join the conversation.

More
5 years 11 months ago #3 by Symbiot
Sooo.. I think I've narrowed it down a bit..

this part:
$cat_id = $ag_forums_to_kunena_categories[$row->messages_catid];

Seems to be the problem. As far as I can tell.. it doesn't return the correct result.. cat_id seems to be empty..

the sql part runs as it should..

any ideas?

Please Log in or Create an account to join the conversation.

More
5 years 10 months ago - 5 years 10 months ago #4 by xillibit
I don't like very much this script, you can leverage Joomla! framework into the script : docs.joomla.org/How_to_create_a_stand-al...the_Joomla!_Platform

Some work has been done with Kunena importer, we haven't touched it since a while : github.com/Kunena/com_kunenaimporter/blo...els/export_agora.php

I don't provide support by PM, because this can be useful for someone else.
Last edit: 5 years 10 months ago by xillibit.

Please Log in or Create an account to join the conversation.

More
5 years 10 months ago #5 by Symbiot

xillibit wrote: I don't like very much this script, you can leverage Joomla! framework into the script : docs.joomla.org/How_to_create_a_stand-al...the_Joomla!_Platform

Some work has been done with Kunena importer, we haven't touched it since a while : github.com/Kunena/com_kunenaimporter/blo...els/export_agora.php


Hi Xillibit..

Thank you for your reply.

I am sorry to say.. I don't know anything about coding, using frameworks etc.. so I am basically stuck with whatever I can find. That's why I'm trying to get the script I pasted to work.

Do you have any plans to restart the converter project?

Please Log in or Create an account to join the conversation.

More
5 years 10 months ago #6 by xillibit
We are focused only on Kunena and his modules/plugins because we don't the time to do everything, if you was a developer you could help but like you said it's not the case

I don't provide support by PM, because this can be useful for someone else.

Please Log in or Create an account to join the conversation.

  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to edit your message.
Time to create page: 0.155 seconds