Re-bonjour,
Première étape:
Voici par exemple une ligne de codes dans le fichier xoops_trust_path\modules\d3forum\include\import_functions.php
Ce code reprend les noms des tables de newbb pour les importer dans les tables de d3forum.
function d3forum_import_from_newbb1( $mydirname , $import_mid )
{
$db =& Database::getInstance() ;
$from_prefix = 'bb' ;
// get group_ids
$group_handler =& xoops_gethandler( 'group' ) ;
$group_objects = $group_handler->getObjects() ;
$group_ids = array() ;
foreach( $group_objects as $group_object ) {
$group_ids[] = $group_object->getVar('groupid') ;
}
// categories
$table_name = 'categories' ;
$to_table = $db->prefix( $mydirname.'_'.$table_name ) ;
$from_table = $db->prefix( $from_prefix.'_'.$table_name ) ;
$db->query( "DELETE FROM `$to_table`" ) ;
$irs = $db->query( "INSERT INTO `$to_table` (cat_id,cat_title,cat_weight) SELECT cat_id,cat_title,cat_order FROM `$from_table`" ) ;
if( ! $irs ) d3forum_import_errordie() ;
// category_access
$crs = $db->query( "SELECT cat_id FROM `$from_table`" ) ;
$table_name = 'category_access' ;
$to_table = $db->prefix( $mydirname.'_'.$table_name ) ;
$from_table = $db->prefix( $from_prefix.'_'.$table_name ) ;
$db->query( "DELETE FROM `$to_table`" ) ;
while( list( $cat_id ) = $db->fetchRow( $crs ) ) {
foreach( $group_ids as $groupid ) {
$irs = $db->query( "INSERT INTO `$to_table` VALUES ($cat_id,null,$groupid,1,1,1,1,0,0)" ) ;
if( ! $irs ) d3forum_import_errordie() ;
}
}
// forums
$table_name = 'forums' ;
$to_table = $db->prefix( $mydirname.'_'.$table_name ) ;
$from_table = $db->prefix( $from_prefix.'_'.$table_name ) ;
$db->query( "DELETE FROM `$to_table`" ) ;
$irs = $db->query( "INSERT INTO `$to_table` (forum_id,forum_title,forum_desc,forum_weight,cat_id) SELECT forum_id,forum_name,forum_desc,0,cat_id FROM `$from_table`" ) ;
if( ! $irs ) d3forum_import_errordie() ;
// forum_access
$frs = $db->query( "SELECT forum_id,forum_access,forum_type FROM `$from_table`" ) ;
$table_name = 'forum_access' ;
$to_table = $db->prefix( $mydirname.'_'.$table_name ) ;
$from_table = $db->prefix( $from_prefix.'_'.$table_name ) ;
$from_mods_table = $db->prefix( $from_prefix.'_'.'forum_mods' ) ;
$db->query( "DELETE FROM `$to_table`" ) ;
while( list( $forum_id , $forum_access , $forum_type ) = $db->fetchRow( $frs ) ) {
// moderator by uid
$mrs = $db->query( "SELECT user_id FROM `$from_mods_table` WHERE forum_id=$forum_id" ) ;
while( list( $uid ) = $db->fetchRow( $mrs ) ) {
$irs = $db->query( "INSERT INTO `$to_table` VALUES ($forum_id,$uid,null,1,1,1,1,1)" ) ;
if( ! $irs ) d3forum_import_errordie() ;
}
// users on forum_access (ignore duplicate id error)
$irs = $db->query( "INSERT INTO `$to_table` (forum_id,uid,can_post) SELECT forum_id,user_id,can_post FROM `$from_table` WHERE forum_id=$forum_id" ) ;
// groups on forum_access
foreach( $group_ids as $groupid ) {
if( $forum_type ) {
/* @list( $can_read , $can_post ) = $db->fetchRow( $db->query( "SELECT groupid,can_post FROM `$from_table` WHERE user_id IS NULL AND forum_id=$forum_id AND groupid=$groupid" ) ) ;
if( ! empty( $can_read ) ) {
$irs = $db->query( "INSERT INTO `$to_table` VALUES ($forum_id,null,$groupid,$can_post,1,1,1,0)" ) ;
if( ! $irs ) d3forum_import_errordie() ;
} */
} else {
$can_post = 1 ;
if( ( $groupid == 3 && $forum_access == 1 ) || $forum_access == 3 ) {
$can_post = 0 ;
}
$irs = $db->query( "INSERT INTO `$to_table` VALUES ($forum_id,null,$groupid,$can_post,$can_post,$can_post,1,0)" ) ;
if( ! $irs ) d3forum_import_errordie() ;
}
}
}
// topics
$table_name = 'topics' ;
$to_table = $db->prefix( $mydirname.'_'.$table_name ) ;
$from_table = $db->prefix( $from_prefix.'_'.$table_name ) ;
$db->query( "DELETE FROM `$to_table`" ) ;
$irs = $db->query( "INSERT INTO `$to_table` (topic_id,topic_title,topic_views,forum_id,topic_locked,topic_sticky,topic_solved) SELECT topic_id,topic_title,topic_views,forum_id,topic_status,topic_sticky,1 FROM `$from_table`" ) ;
if( ! $irs ) d3forum_import_errordie() ;
// posts
$table_name = 'posts' ;
$to_table = $db->prefix( $mydirname.'_'.$table_name ) ;
$from_table = $db->prefix( $from_prefix.'_'.$table_name ) ;
$from_text_table = $db->prefix( $from_prefix.'_'.'posts_text') ;
$db->query( "DELETE FROM `$to_table`" ) ;
$irs = $db->query( "INSERT INTO `$to_table` (post_id,pid,topic_id,post_time,modified_time,uid,poster_ip,modifier_ip,subject,html,smiley,xcode,br,number_entity,special_entity,icon,attachsig,invisible,approval,post_text) SELECT p.post_id,pid,topic_id,post_time,post_time,uid,poster_ip,poster_ip,subject,!nohtml,!nosmiley,1,1,1,1,IF(SUBSTRING(icon,5,1),SUBSTRING(icon,5,1),1),attachsig,0,1,pt.post_text FROM `$from_table` p LEFT JOIN `$from_text_table` pt ON p.post_id=pt.post_id" ) ;
if( ! $irs ) d3forum_import_errordie() ;
// users2topics
$table_name = 'users2topics' ;
$to_table = $db->prefix( $mydirname.'_'.$table_name ) ;
$from_table = $db->prefix( $from_prefix.'_'.$table_name ) ;
$db->query( "DELETE FROM `$to_table`" ) ;
/*$irs = $db->query( "INSERT INTO `$to_table` (uid,topic_id,u2t_time,u2t_marked,u2t_rsv) SELECT uid,topic_id,u2t_time,u2t_marked,u2t_rsv FROM `$from_table`" ) ;
if( ! $irs ) d3forum_import_errordie() ;*/
}
Et voici les noms des tables de newbbex et d3forum à mettre en remplacement de celles de newbb ci-dessus:
============ NEWBBEX ==========================
TABLE NEWBBEX bbex_categories:
cat_id, cat_title, cat_order,
TABLE NEWBBEX bbex_forum_access:
forum_id, user_id, can_post
TABLE NEWBBEX bbex_forum_mods:
forum_id, user_id
TABLE NEWBBEX bbex_forums:
forum_id, forum_name, forum_desc, forum_access, forum_moderator, forum_topics, forum_posts, forum_last_post_id, cat_id, forum_type, allow_html, allow_sig, posts_per_page, hot_threshold, topics_per_page, show_name, show_icons_panel, show_smilies_panel, allow_upload,
TABLE NEWBBEX bbex_posts:
post_id, pid, topic_id, forum_id, post_time, uid, poster_ip, subject, nohtml, nosmiley, icon, attachsig,
TABLE NEWBBEX bbex_posts_text:
post_id, post_text,
TABLE NEWBBEX bbex_topics:
topic_id, topic_title, topic_poster, topic_time, topic_views, topic_replies, topic_last_post_id, forum_id, topic_status, topic_sticky,
TABLE NEWBBEX bbex_files:
fileid, filerealname, post_id, date, mimetype, downloadname, counter,
============ D3FORUM ==========================
TABLE D3FORUM category_access:
cat_id, uid, groupid, can_post, can_edit, can_delete, post_auto_approved, can_makeforum, is_moderator,
TABLE D3FORUM forum_access:
forum_id, uid, groupid, can_post, can_edit, can_delete, post_auto_approved, is_moderator,
TABLE D3FORUM categories:
cat_id, pid, cat_title, cat_desc, cat_topics_count, cat_posts_count, cat_last_post_id, cat_last_post_time, cat_topics_count_in_tree, cat_posts_count_in_tree, cat_last_post_id_in_tree, cat_last_post_time_in_tree, cat_depth_in_tree, cat_order_in_tree, cat_path_in_tree, cat_unique_path, cat_weight, cat_options,
TABLE D3FORUM forums:
forum_id, cat_id, forum_external_link_format, forum_title, forum_desc, forum_topics_count, forum_posts_count, forum_last_post_id, forum_last_post_time, forum_weight, forum_options,
TABLE D3FORUM topics:
topic_id, forum_id, topic_external_link_id, topic_title, topic_first_uid, topic_first_post_id, topic_first_post_time, topic_last_uid, topic_last_post_id, topic_last_post_time, topic_views, topic_posts_count, topic_locked, topic_sticky, topic_solved, topic_invisible, topic_votes_sum, topic_votes_count,
TABLE D3FORUM posts:
post_id, pid, topic_id, post_time, modified_time, uid, uid_hidden, poster_ip, modifier_ip, subject, subject_waiting, html, smiley, xcode, br, number_entity, special_entity, icon, attachsig, invisible, approval, votes_sum, votes_count, depth_in_tree, order_in_tree, path_in_tree, unique_path, guest_name, guest_email, guest_url, guest_pass_md5, guest_trip, post_text, post_text_waiting,
TABLE D3FORUM users2topics:
uid, topic_id, u2t_time, u2t_marked, u2t_rsv,
TABLE D3FORUM post_votes:
vote_id, post_id, uid, vote_point, vote_time, vote_ip,
TABLE D3FORUM post_histories:
history_id, post_id, history_time, data,
Si quelqu'un a une inspiration lumineuse.. en ce jour du seigneur... ce serai chouette
Bon dimanche