first commit
This commit is contained in:
663
wp-content/plugins/bbpress/includes/admin/converters/AEF.php
Normal file
663
wp-content/plugins/bbpress/includes/admin/converters/AEF.php
Normal file
@@ -0,0 +1,663 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress AEF Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of AEF Forum converter.
|
||||
*
|
||||
* @since 2.5.0 bbPress (r5139)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/aef
|
||||
*/
|
||||
class AEF extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
/** Forum Section *****************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'fid',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum parent id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'par_board_id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_parent_id'
|
||||
);
|
||||
|
||||
// Forum topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'ntopic',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_topic_count'
|
||||
);
|
||||
|
||||
// Forum reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'nposts',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_reply_count'
|
||||
);
|
||||
|
||||
// Forum total topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'ntopic',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_topic_count'
|
||||
);
|
||||
|
||||
// Forum total reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'nposts',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_reply_count'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'fname',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'fname',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'description',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'forum_order',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Set a default value 'forum', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'default' => 'forum'
|
||||
);
|
||||
|
||||
// Forum status (Unlocked = 1 or Locked = 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'status',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'callback_method' => 'callback_forum_status'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
/** Topic Section *****************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'tid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'n_posts',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'n_posts',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_total_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 't_bid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
// Note: We join the 'posts' table because 'topics' table does not include author id.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'poster_id',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON topics.first_post_id = posts.pid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic Author ip (Stored in postmeta)
|
||||
// Note: We join the 'posts' table because 'topics' table does not include author ip.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'poster_ip',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON topics.first_post_id = posts.pid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
// Note: We join the 'posts' table because 'topics' table does not include topic content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'post',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON topics.first_post_id = posts.pid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'topic',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'topic',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 't_bid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Sticky status (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 't_sticky',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_sticky_status_id',
|
||||
'callback_method' => 'callback_sticky_status'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
// Note: We join the 'posts' table because 'topics' table does not include topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'ptime',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON topics.first_post_id = posts.pid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'ptime',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON topics.first_post_id = posts.pid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'ptime',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON topics.first_post_id = posts.pid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'ptime',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON topics.first_post_id = posts.pid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'ptime',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON topics.first_post_id = posts.pid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// Topic status (Open = 1 or Closed = 0, AEF v1.0.9)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 't_status',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_topic_status'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
/**
|
||||
* AEF v1.0.9 Forums do not support topic tags out of the box
|
||||
*/
|
||||
|
||||
/** Reply Section *****************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'pid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'post_fid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_topicid_to_forumid'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'post_tid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'poster_ip',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'poster_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'post',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'post_tid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'ptime',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'ptime',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'ptime',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'ptime',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old user password (Stored in usermeta serialized with salt)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'password',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password',
|
||||
'callback_method' => 'callback_savepass'
|
||||
);
|
||||
|
||||
// Store old user salt (This is only used for the SELECT row info for the above password save)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'salt',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => ''
|
||||
);
|
||||
|
||||
// User password verify class (Stored in usermeta for verifying password)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'users',
|
||||
'to_fieldname' => '_bbp_class',
|
||||
'default' => 'AEF'
|
||||
);
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User nice name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_nicename'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'email',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User homepage.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'www',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_url'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'r_time',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// User AIM (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'aim',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_aef_user_aim'
|
||||
);
|
||||
|
||||
// User Yahoo (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'yim',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_aef_user_yim'
|
||||
);
|
||||
|
||||
// Store ICQ (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'icq',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_aef_user_icq'
|
||||
);
|
||||
|
||||
// Store MSN (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'msn',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_aef_user_msn'
|
||||
);
|
||||
|
||||
// Store Gmail (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'gmail',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_aef_user_gmail'
|
||||
);
|
||||
|
||||
// Store Signature (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'sig',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_aef_user_sig',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Store Location (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'location',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_aef_user_location'
|
||||
);
|
||||
|
||||
// Store PrivateText (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'users_text',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_aef_user_private_text'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass( $field, $row ) {
|
||||
$pass_array = array( 'hash' => $field, 'salt' => $row['salt'] );
|
||||
return $pass_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*/
|
||||
public function authenticate_pass( $password, $serialized_pass ) {
|
||||
$pass_array = unserialize( $serialized_pass );
|
||||
return ( $pass_array['hash'] == md5( md5( $password ). $pass_array['salt'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the forum status from AEF v1.0.9 numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status AEF v1.0.9 numeric forum status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_forum_status( $status = 1 ) {
|
||||
switch ( $status ) {
|
||||
case 0 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
default :
|
||||
$status = 'open';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the post status from AEF v1.0.9 numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status AEF v1.0.9 numeric topic status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_status( $status = 1 ) {
|
||||
switch ( $status ) {
|
||||
case 0 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
default :
|
||||
$status = 'publish';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the topic sticky status type from AEF 1.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status AEF 1.x numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_sticky_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'sticky'; // AEF Sticky 't_sticky = 1'
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'normal'; // AEF normal topic 't_sticky = 0'
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the topic/reply count.
|
||||
*
|
||||
* @param int $count AEF v1.0.9 topic/reply counts
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_reply_count( $count = 1 ) {
|
||||
$count = absint( (int) $count - 1 );
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
662
wp-content/plugins/bbpress/includes/admin/converters/Drupal7.php
Normal file
662
wp-content/plugins/bbpress/includes/admin/converters/Drupal7.php
Normal file
@@ -0,0 +1,662 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress Drupal7 Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of Drupal v7.x Forum converter.
|
||||
*
|
||||
* @since 2.5.0 bbPress (r5138)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/drupal
|
||||
*/
|
||||
class Drupal7 extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
/** Forum Section *****************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'taxonomy_term_data',
|
||||
'from_fieldname' => 'tid',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum parent id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'taxonomy_term_hierarchy',
|
||||
'from_fieldname' => 'parent',
|
||||
'join_tablename' => 'taxonomy_term_data',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (tid)',
|
||||
'from_expression' => 'LEFT JOIN taxonomy_vocabulary AS taxonomy_vocabulary USING (vid) WHERE module = "forum"',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_parent_id'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'taxonomy_term_data',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'taxonomy_term_data',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'taxonomy_term_data',
|
||||
'from_fieldname' => 'description',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'taxonomy_term_data',
|
||||
'from_fieldname' => 'weight',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Set a default value 'forum', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'default' => 'forum'
|
||||
);
|
||||
|
||||
// Forum status (Set a default value 'open', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'default' => 'open'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
/** Topic Section *****************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_index',
|
||||
'from_fieldname' => 'nid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_index',
|
||||
'from_fieldname' => 'comment_count',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_index',
|
||||
'from_fieldname' => 'comment_count',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_total_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_index',
|
||||
'from_fieldname' => 'tid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
// Note: We join the 'node' table because 'forum_index' table does not include author id.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'node',
|
||||
'from_fieldname' => 'uid',
|
||||
'join_tablename' => 'forum_index',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON node.nid = forum_index.nid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic author name (Stored in postmeta as _bbp_anonymous_name)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_author_name_id',
|
||||
'default' => 'Anonymous'
|
||||
);
|
||||
|
||||
// Is the topic anonymous (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'node',
|
||||
'from_fieldname' => 'uid',
|
||||
'join_tablename' => 'forum_index',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON node.nid = forum_index.nid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_is_topic_anonymous_id',
|
||||
'callback_method' => 'callback_check_anonymous'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
// Note: We join the 'field_data_body' table because 'node' or 'forum_index' table does not include topic content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'field_data_body',
|
||||
'from_fieldname' => 'body_value',
|
||||
'join_tablename' => 'node',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON field_data_body.revision_id = node.vid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_index',
|
||||
'from_fieldname' => 'title',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_index',
|
||||
'from_fieldname' => 'title',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_index',
|
||||
'from_fieldname' => 'tid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic status (Publish or Unpublished, Drupal v7.x publish = 1, pending = 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'node',
|
||||
'from_fieldname' => 'status',
|
||||
'join_tablename' => 'forum_index',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON node.nid = forum_index.nid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_status',
|
||||
'callback_method' => 'callback_status'
|
||||
);
|
||||
|
||||
// Sticky status (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_index',
|
||||
'from_fieldname' => 'sticky',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_sticky_status_id',
|
||||
'callback_method' => 'callback_sticky_status'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_index',
|
||||
'from_fieldname' => 'created',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_index',
|
||||
'from_fieldname' => 'created',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_index',
|
||||
'from_fieldname' => 'last_comment_timestamp',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_index',
|
||||
'from_fieldname' => 'last_comment_timestamp',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_index',
|
||||
'from_fieldname' => 'last_comment_timestamp',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// Topic status (Drupal v7.x Comments Enabled no = 0, closed = 1 & open = 2)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'node',
|
||||
'from_fieldname' => 'comment',
|
||||
'join_tablename' => 'forum_index',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON node.nid = forum_index.nid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_topic_status'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
// Topic id.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'field_data_field_tags',
|
||||
'from_fieldname' => 'entity_id',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'objectid',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Taxonomy ID.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'field_data_field_tags',
|
||||
'from_fieldname' => 'field_tags_tid',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'taxonomy'
|
||||
);
|
||||
|
||||
// Term name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'taxonomy_term_data',
|
||||
'from_fieldname' => 'name',
|
||||
'join_tablename' => 'field_data_field_tags',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON field_tags_tid = taxonomy_term_data.tid',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'name'
|
||||
);
|
||||
|
||||
// Term slug.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'taxonomy_term_data',
|
||||
'from_fieldname' => 'name',
|
||||
'join_tablename' => 'field_data_field_tags',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON field_tags_tid = taxonomy_term_data.tid',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'slug',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Term description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'taxonomy_term_data',
|
||||
'from_fieldname' => 'description',
|
||||
'join_tablename' => 'field_data_field_tags',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON field_tags_tid = taxonomy_term_data.tid',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'description'
|
||||
);
|
||||
|
||||
/** Reply Section *****************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'comment',
|
||||
'from_fieldname' => 'cid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'comment',
|
||||
'from_fieldname' => 'nid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_topicid_to_forumid'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'comment',
|
||||
'from_fieldname' => 'nid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply parent reply id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'comment',
|
||||
'from_fieldname' => 'pid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_to_id'
|
||||
);
|
||||
|
||||
// Reply author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'comment',
|
||||
'from_fieldname' => 'hostname',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'comment',
|
||||
'from_fieldname' => 'uid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply status (Publish or Unpublished, Drupal v7.x publish = 1, pending = 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'comment',
|
||||
'from_fieldname' => 'status',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_status',
|
||||
'callback_method' => 'callback_status'
|
||||
);
|
||||
|
||||
// Reply author name (Stored in postmeta as _bbp_anonymous_name)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'comment',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_author_name_id'
|
||||
);
|
||||
|
||||
// Is the reply anonymous (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'comment',
|
||||
'from_fieldname' => 'uid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_is_reply_anonymous_id',
|
||||
'callback_method' => 'callback_check_anonymous'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
// Note: We join the 'field_data_comment_body' table because 'comment' table does not include reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'field_data_comment_body',
|
||||
'from_fieldname' => 'comment_body_value',
|
||||
'join_tablename' => 'comment',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON field_data_comment_body.entity_id = comment.cid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'comment',
|
||||
'from_fieldname' => 'nid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'comment',
|
||||
'from_fieldname' => 'created',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'comment',
|
||||
'from_fieldname' => 'created',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'comment',
|
||||
'from_fieldname' => 'changed',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'comment',
|
||||
'from_fieldname' => 'changed',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
// Don't import user uid = 0, this is Drupal 7's guest user
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'uid',
|
||||
'from_expression' => 'WHERE uid != 0',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old user password (Stored in usermeta serialized with salt)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'pass',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password'
|
||||
// 'callback_method' => 'callback_savepass'
|
||||
);
|
||||
|
||||
// Store old user salt (This is only used for the SELECT row info for the above password save)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'pass',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => ''
|
||||
);
|
||||
|
||||
// User password verify class (Stored in usermeta for verifying password)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'users',
|
||||
'to_fieldname' => '_bbp_class',
|
||||
'default' => 'Drupal7'
|
||||
);
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User nice name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_nicename'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'mail',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'created',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// Store Signature (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'signature',
|
||||
'to_fieldname' => '_bbp_drupal7_user_sig',
|
||||
'to_type' => 'user',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass( $field, $row ) {
|
||||
$pass_array = array( 'hash' => $field, 'salt' => $row['salt'] );
|
||||
return $pass_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*/
|
||||
public function authenticate_pass( $password, $serialized_pass ) {
|
||||
$pass_array = unserialize( $serialized_pass );
|
||||
return ( $pass_array['hash'] == md5( md5( $password ). $pass_array['salt'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the post status from Drupal v7.x numerics to WordPress's
|
||||
* strings.
|
||||
*
|
||||
* @param int $status Drupal v7.x numeric post status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_status( $status = 1 ) {
|
||||
switch ( $status ) {
|
||||
case 0 :
|
||||
$status = 'pending'; // bbp_get_pending_status_id()
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
default :
|
||||
$status = 'publish'; // bbp_get_public_status_id()
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the post status from Drupal v7.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status Drupal v7.x numeric topic status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_status( $status = 2 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 2 :
|
||||
default :
|
||||
$status = 'publish';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the topic sticky status type from Drupal v7.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status Drupal v7.x numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_sticky_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'sticky'; // Drupal Sticky 'topic_sticky = 1'
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'normal'; // Drupal Normal Topic 'sticky = 0'
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the topic/reply count.
|
||||
*
|
||||
* @param int $count Drupal v7.x topic/reply counts
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_reply_count( $count = 1 ) {
|
||||
$count = absint( (int) $count - 1 );
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
711
wp-content/plugins/bbpress/includes/admin/converters/Example.php
Normal file
711
wp-content/plugins/bbpress/includes/admin/converters/Example.php
Normal file
@@ -0,0 +1,711 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress Example Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Example converter base impoprter template for bbPress
|
||||
*
|
||||
* @since 2.3.0 bbPress (r4689)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/custom-import
|
||||
*/
|
||||
class Example extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
/** Forum Section *****************************************************/
|
||||
|
||||
// Setup table joins for the forum section at the base of this section
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums_table',
|
||||
'from_fieldname' => 'the_forum_id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum parent id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums_table',
|
||||
'from_fieldname' => 'the_parent_id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_parent_id'
|
||||
);
|
||||
|
||||
// Forum topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums_table',
|
||||
'from_fieldname' => 'the_topic_count',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_topic_count'
|
||||
);
|
||||
|
||||
// Forum reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums_table',
|
||||
'from_fieldname' => 'the_reply_count',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_reply_count'
|
||||
);
|
||||
|
||||
// Forum total topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums_table',
|
||||
'from_fieldname' => 'the_total_topic_count',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_topic_count'
|
||||
);
|
||||
|
||||
// Forum total reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums_table',
|
||||
'from_fieldname' => 'the_total_reply_count',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_reply_count'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums_table',
|
||||
'from_fieldname' => 'the_forum_title',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid confilcts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums_table',
|
||||
'from_fieldname' => 'the_forum_slug',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums_table',
|
||||
'from_fieldname' => 'the_forum_description',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums_table',
|
||||
'from_fieldname' => 'the_forum_order',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Category = 0 or Forum = 1, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums_table',
|
||||
'from_fieldname' => 'the_forum_type',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'callback_method' => 'callback_forum_type'
|
||||
);
|
||||
|
||||
// Forum status (Unlocked = 0 or Locked = 1, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums_table',
|
||||
'from_fieldname' => 'the_forum_status',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'callback_method' => 'callback_forum_status'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
// Setup the table joins for the forum section
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'groups_table',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'join_tablename' => 'forums_table',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING groups_table.forum_id = forums_table.forum_id',
|
||||
// 'from_expression' => 'WHERE forums_table.forum_id != 1',
|
||||
'to_type' => 'forum'
|
||||
);
|
||||
|
||||
/** Forum Subscriptions Section ***************************************/
|
||||
|
||||
// Subscribed forum ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_subscriptions_table',
|
||||
'from_fieldname' => 'the_forum_id',
|
||||
'to_type' => 'forum_subscriptions',
|
||||
'to_fieldname' => '_bbp_forum_subscriptions'
|
||||
);
|
||||
|
||||
// Subscribed user ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_subscriptions_table',
|
||||
'from_fieldname' => 'the_user_id',
|
||||
'to_type' => 'forum_subscriptions',
|
||||
'to_fieldname' => 'user_id',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
/** Topic Section *****************************************************/
|
||||
|
||||
// Setup table joins for the topic section at the base of this section
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics_table',
|
||||
'from_fieldname' => 'the_topic_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics_table',
|
||||
'from_fieldname' => 'the_topic_reply_count',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic total reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics_table',
|
||||
'from_fieldname' => 'the_total_topic_reply_count',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_total_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics_table',
|
||||
'from_fieldname' => 'the_topic_parent_forum_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics_table',
|
||||
'from_fieldname' => 'the_topic_author_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics_table',
|
||||
'from_fieldname' => 'the_topic_author_ip_address',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics_table',
|
||||
'from_fieldname' => 'the_topic_content',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics_table',
|
||||
'from_fieldname' => 'the_topic_title',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics_table',
|
||||
'from_fieldname' => 'the_topic_slug',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic status (Open or Closed)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics_table',
|
||||
'from_fieldname' => 'the_topic_status',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_topic_status'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics_table',
|
||||
'from_fieldname' => 'the_topic_parent_forum_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Sticky status (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics_table',
|
||||
'from_fieldname' => 'the_topic_sticky_status',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_sticky_status_id',
|
||||
'callback_method' => 'callback_sticky_status'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics_table',
|
||||
'from_fieldname' => 'the_topic_creation_date',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics_table',
|
||||
'from_fieldname' => 'the_topic_creation_date',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics_table',
|
||||
'from_fieldname' => 'the_topic_modified_date',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics_table',
|
||||
'from_fieldname' => 'the_topic_modified_date',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics_table',
|
||||
'from_fieldname' => 'the_topic_modified_date',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// Setup any table joins needed for the topic section
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'replies_table',
|
||||
'from_fieldname' => 'the_topic_id',
|
||||
'join_tablename' => 'topics_table',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING replies_table.the_topic_id = topics_table.the_topic_id',
|
||||
'from_expression' => 'WHERE forums_table.the_topic_id = 0',
|
||||
'to_type' => 'topic'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
// Setup table joins for the tag section at the base of this section
|
||||
// Setup any table joins needed for the tags section
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'tag_table',
|
||||
'from_fieldname' => 'the_topic_id',
|
||||
'join_tablename' => 'tagcontent_table',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING tagcontent_table.tag_id = tags_table.tag_id',
|
||||
'from_expression' => 'WHERE tagcontent_table.tag_id = tag_table.tag_id',
|
||||
'to_type' => 'tags'
|
||||
);
|
||||
|
||||
// Topic id.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'tagcontent_table',
|
||||
'from_fieldname' => 'contentid',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'objectid',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Taxonomy ID.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'tagcontent_table',
|
||||
'from_fieldname' => 'tagid',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'taxonomy'
|
||||
);
|
||||
|
||||
// Term text.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'tag_table',
|
||||
'from_fieldname' => 'tagtext',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'name'
|
||||
);
|
||||
|
||||
// Term slug.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'tag_table',
|
||||
'from_fieldname' => 'tagslug',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'slug',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Term description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'tag_table',
|
||||
'from_fieldname' => 'tagdescription',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'description'
|
||||
);
|
||||
|
||||
/** Topic Subscriptions Section ***************************************/
|
||||
|
||||
// Subscribed topic ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topic_subscriptions_table',
|
||||
'from_fieldname' => 'the_topic_id',
|
||||
'to_type' => 'topic_subscriptions',
|
||||
'to_fieldname' => '_bbp_subscriptions'
|
||||
);
|
||||
|
||||
// Subscribed user ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topic_subscriptions_table',
|
||||
'from_fieldname' => 'the_user_id',
|
||||
'to_type' => 'topic_subscriptions',
|
||||
'to_fieldname' => 'user_id',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
/** Favorites Section *************************************************/
|
||||
|
||||
// Favorited topic ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'favorites_table',
|
||||
'from_fieldname' => 'the_favorite_topic_id',
|
||||
'to_type' => 'favorites',
|
||||
'to_fieldname' => '_bbp_favorites'
|
||||
);
|
||||
|
||||
// Favorited user ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'favorites_table',
|
||||
'from_fieldname' => 'the_user_id',
|
||||
'to_type' => 'favorites',
|
||||
'to_fieldname' => 'user_id',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
/** Reply Section *****************************************************/
|
||||
|
||||
// Setup table joins for the reply section at the base of this section
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'replies_table',
|
||||
'from_fieldname' => 'the_reply_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'replies_table',
|
||||
'from_fieldname' => 'the_reply_parent_forum_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'replies_table',
|
||||
'from_fieldname' => 'the_reply_parent_topic_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'replies_table',
|
||||
'from_fieldname' => 'the_reply_author_ip_address',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'replies_table',
|
||||
'from_fieldname' => 'the_reply_author_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply title and reply slugs
|
||||
// Note: We don't actually want either a reply title or a reply slug as
|
||||
// we want single replies to use their ID as the permalink.
|
||||
|
||||
// Reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'replies_table',
|
||||
'from_fieldname' => 'the_reply_content',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply order.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'replies_table',
|
||||
'from_fieldname' => 'the_reply_order',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'replies_table',
|
||||
'from_fieldname' => 'the_reply_parent_topic_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'replies_table',
|
||||
'from_fieldname' => 'the_reply_creation_date',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'replies_table',
|
||||
'from_fieldname' => 'the_reply_creation_date',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'replies_table',
|
||||
'from_fieldname' => 'the_reply_modified_date',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'replies_table',
|
||||
'from_fieldname' => 'the_reply_modified_date',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// Setup any table joins needed for the reply section
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics_table',
|
||||
'from_fieldname' => 'the_topic_id',
|
||||
'join_tablename' => 'replies_table',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING topics_table.the_topic_id = replies_table.the_topic_id',
|
||||
'from_expression' => 'WHERE topics_table.first_post != 0',
|
||||
'to_type' => 'reply'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
// Setup table joins for the user section at the base of this section
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users_table',
|
||||
'from_fieldname' => 'the_users_id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old user password (Stored in usermeta serialized with salt)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users_table',
|
||||
'from_fieldname' => 'the_users_password',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password',
|
||||
'callback_method' => 'callback_savepass'
|
||||
);
|
||||
|
||||
// Store old user salt (This is only used for the SELECT row info for the above password save)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users_table',
|
||||
'from_fieldname' => 'the_users_password_salt',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => ''
|
||||
);
|
||||
|
||||
// User password verify class (Stored in usermeta for verifying password)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_class',
|
||||
'default' => 'Example'
|
||||
);
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users_table',
|
||||
'from_fieldname' => 'the_users_username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User nice name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users_table',
|
||||
'from_fieldname' => 'the_users_nicename',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_nicename'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users_table',
|
||||
'from_fieldname' => 'the_users_email_address',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User homepage.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users_table',
|
||||
'from_fieldname' => 'the_users_homepage_url',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_url'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users_table',
|
||||
'from_fieldname' => 'the_users_registration_date',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// User status.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users_table',
|
||||
'from_fieldname' => 'the_users_status',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_status'
|
||||
);
|
||||
|
||||
// User display name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users_table',
|
||||
'from_fieldname' => 'the_users_display_name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'display_name'
|
||||
);
|
||||
|
||||
// User Profile Field 1 (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users_table',
|
||||
'from_fieldname' => 'the_users_custom_profile_field_1',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_example_profile_field_1'
|
||||
);
|
||||
|
||||
// User Profile Field 2 (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users_table',
|
||||
'from_fieldname' => 'the_users_custom_profile_field_2',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_example_profile_field_2'
|
||||
);
|
||||
|
||||
// User Profile Field 3 (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users_table',
|
||||
'from_fieldname' => 'the_users_custom_profile_field_3',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_example_profile_field_3'
|
||||
);
|
||||
|
||||
// Setup any table joins needed for the user section
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users_profile_table',
|
||||
'from_fieldname' => 'the_users_id',
|
||||
'join_tablename' => 'users_table',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING users_profile_table.the_user_id = users_table.the_user_id',
|
||||
'from_expression' => 'WHERE users_table.the_user_id != -1',
|
||||
'to_type' => 'user'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass( $field, $row ) {
|
||||
$pass_array = array( 'hash' => $field, 'salt' => $row['salt'] );
|
||||
return $pass_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*/
|
||||
public function authenticate_pass( $password, $serialized_pass ) {
|
||||
$pass_array = unserialize( $serialized_pass );
|
||||
return ( $pass_array['hash'] == md5( md5( $password ). $pass_array['salt'] ) );
|
||||
}
|
||||
}
|
||||
664
wp-content/plugins/bbpress/includes/admin/converters/FluxBB.php
Normal file
664
wp-content/plugins/bbpress/includes/admin/converters/FluxBB.php
Normal file
@@ -0,0 +1,664 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress FluxBB Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of FluxBB Forum converter.
|
||||
*
|
||||
* @since 2.5.0 bbPress (r5138)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/fluxbb
|
||||
*/
|
||||
class FluxBB extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main Constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
/** Forum Section *****************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'num_topics',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_topic_count'
|
||||
);
|
||||
|
||||
// Forum reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'num_posts',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_reply_count'
|
||||
);
|
||||
|
||||
// Forum total topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'num_topics',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_topic_count'
|
||||
);
|
||||
|
||||
// Forum total reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'num_posts',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_reply_count'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'forum_name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'forum_name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'forum_desc',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'disp_position',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Set a default value 'forum', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'default' => 'forum'
|
||||
);
|
||||
|
||||
// Forum status (Set a default value 'open', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'default' => 'open'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
/** Forum Subscriptions Section ***************************************/
|
||||
|
||||
// Subscribed forum ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_subscriptions',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'forum_subscriptions',
|
||||
'to_fieldname' => '_bbp_forum_subscriptions'
|
||||
);
|
||||
|
||||
// Subscribed user ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_subscriptions',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'forum_subscriptions',
|
||||
'to_fieldname' => 'user_id',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
/** Topic Section *****************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'num_replies',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'num_replies',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_total_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
// Note: We join the 'posts' table because 'topics' table does include numeric user id.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'poster_id',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON topics.first_post_id = posts.id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic Author ip (Stored in postmeta)
|
||||
// Note: We join the 'posts' table because 'topics' table does not include author IP addresses.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'poster_ip',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON topics.first_post_id = posts.id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
// Note: We join the 'posts' table because 'topics' table does not include topic content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'message',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON topics.first_post_id = posts.id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'subject',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'subject',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Sticky status (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'sticky',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_sticky_status_id',
|
||||
'callback_method' => 'callback_sticky_status'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'posted',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'posted',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'posted',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'posted',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'posted',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// Topic status (Open = 0 or Closed = 1, FluxBB v1.5.3)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'closed',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_topic_status'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
/**
|
||||
* FluxBB v1.5.3 Forums do not support topic tags out of the box
|
||||
*/
|
||||
|
||||
/** Topic Subscriptions Section ***************************************/
|
||||
|
||||
// Subscribed topic ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topic_subscriptions',
|
||||
'from_fieldname' => 'topic_id',
|
||||
'to_type' => 'topic_subscriptions',
|
||||
'to_fieldname' => '_bbp_subscriptions'
|
||||
);
|
||||
|
||||
// Subscribed user ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topic_subscriptions',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'topic_subscriptions',
|
||||
'to_fieldname' => 'user_id',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
/** Reply Section *****************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'topic_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_topicid_to_forumid'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'topic_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'poster_ip',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'poster_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'message',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'topic_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'posted',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'posted',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'posted',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'posted',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old user password (Stored in usermeta serialized with salt)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'password',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password',
|
||||
'callback_method' => 'callback_savepass'
|
||||
);
|
||||
|
||||
// Store old user salt (This is only used for the SELECT row info for the above password save)
|
||||
// $this->field_map[] = array(
|
||||
// 'from_tablename' => 'users',
|
||||
// 'from_fieldname' => 'salt',
|
||||
// 'to_type' => 'user',
|
||||
// 'to_fieldname' => ''
|
||||
// );
|
||||
|
||||
// User password verify class (Stored in usermeta for verifying password)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'users',
|
||||
'to_fieldname' => '_bbp_class',
|
||||
'default' => 'FluxBB'
|
||||
);
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User nice name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_nicename'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'email',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User homepage.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'url',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_url'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'registered',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// User display name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'realname',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'display_name'
|
||||
);
|
||||
|
||||
// User AIM (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'aim',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_fluxbb_user_aim'
|
||||
);
|
||||
|
||||
// User Yahoo (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'yahoo',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_fluxbb_user_yim'
|
||||
);
|
||||
|
||||
// Store Jabber
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'jabber',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_fluxbb_user_jabber'
|
||||
);
|
||||
|
||||
// Store ICQ (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'icq',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_fluxbb_user_icq'
|
||||
);
|
||||
|
||||
// Store MSN (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'msn',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_fluxbb_user_msn'
|
||||
);
|
||||
|
||||
// Store Location (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'location',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_fluxbb_user_location'
|
||||
);
|
||||
|
||||
// Store Signature (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'signature',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_fluxbb_user_sig',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Store Admin Note (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'admin_note',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_fluxbb_user_admin_note'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass( $field, $row ) {
|
||||
$pass_array = array( 'hash' => $field, 'salt' => $row['salt'] );
|
||||
return $pass_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*/
|
||||
public function authenticate_pass( $password, $serialized_pass ) {
|
||||
$pass_array = unserialize( $serialized_pass );
|
||||
return ( $pass_array['hash'] == md5( md5( $password ). $pass_array['salt'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the post status from FluxBB v1.5.3 numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status FluxBB v1.5.3 numeric topic status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'publish';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the topic sticky status type from FluxBB v1.5.3 numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status FluxBB v1.5.3 numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_sticky_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'sticky'; // FluxBB Sticky 'sticky = 1'
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'normal'; // FluxBB Normal Topic 'sticky = 0'
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the topic/reply count.
|
||||
*
|
||||
* @param int $count FluxBB v1.5.3 topic/reply counts
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_reply_count( $count = 1 ) {
|
||||
$count = absint( (int) $count - 1 );
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,638 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress Invision Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of Invision Power Board v3.x converter.
|
||||
*
|
||||
* @since 2.3.0 bbPress (r4713)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/invision
|
||||
*/
|
||||
class Invision extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main Constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
// Setup smiley URL & path
|
||||
$this->bbcode_parser_properties = array(
|
||||
'smiley_url' => false,
|
||||
'smiley_dir' => false
|
||||
);
|
||||
|
||||
/** Forum Section *****************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum parent id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'parent_id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_parent_id'
|
||||
);
|
||||
|
||||
// Forum topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'topics',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_topic_count'
|
||||
);
|
||||
|
||||
// Forum reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'posts',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_reply_count'
|
||||
);
|
||||
|
||||
// Forum total topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'topics',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_topic_count'
|
||||
);
|
||||
|
||||
// Forum total reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'posts',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_reply_count'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid confilcts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'name_seo',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'description',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'position',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Forum = 0 or Category = -1, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'parent_id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'callback_method' => 'callback_forum_type'
|
||||
);
|
||||
|
||||
// Forum status (Set a default value 'open', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'default' => 'open'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
/** Topic Section *****************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'tid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'posts',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'starter_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
// Note: We join the posts table because topics do not have content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'post',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON(topics.tid = posts.topic_id) WHERE posts.new_topic = 1',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'title',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'title',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Sticky status (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'pinned',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_sticky_status_id',
|
||||
'callback_method' => 'callback_sticky_status'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'start_date',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'start_date',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'last_post',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'last_post',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'last_post',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
// Topic id.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'core_tags',
|
||||
'from_fieldname' => 'tag_meta_id',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'objectid',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Term text.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'core_tags',
|
||||
'from_fieldname' => 'tag_text',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'name'
|
||||
);
|
||||
|
||||
/** Reply Section *****************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'pid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'topic_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_topicid_to_forumid'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'topic_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'ip_address',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'author_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'post',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'topic_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'post_date',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'post_date',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'edit_time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'edit_time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'member_id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old user password (Stored in usermeta serialized with salt)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'members_pass_hash',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password',
|
||||
'callback_method' => 'callback_savepass'
|
||||
);
|
||||
|
||||
// Store old user salt (This is only used for the SELECT row info for the above password save)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'members_pass_salt',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => ''
|
||||
);
|
||||
|
||||
// User password verify class (Stored in usermeta for verifying password)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_class',
|
||||
'default' => 'Invision'
|
||||
);
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User nice name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_nicename'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'email',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'joined',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// User display name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'members_display_name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'display_name'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the forum type from Invision numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status Invision numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_forum_type( $status = 0 ) {
|
||||
if ( $status == -1 ) {
|
||||
$status = 'category';
|
||||
} else {
|
||||
$status = 'forum';
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the topic sticky status type from Invision numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status Invision numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_sticky_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'sticky'; // Invision Pinned Topic 'pinned = 1'
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'normal'; // Invision Normal Topic 'pinned = 0'
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the topic reply count.
|
||||
*
|
||||
* @param int $count Invision reply count
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_reply_count( $count = 1 ) {
|
||||
$count = absint( (int) $count - 1 );
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass( $field, $row ) {
|
||||
return array( 'hash' => $field, 'salt' => $row['members_pass_salt'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*/
|
||||
public function authenticate_pass( $password, $serialized_pass ) {
|
||||
$pass_array = unserialize( $serialized_pass );
|
||||
return ( $pass_array['hash'] == md5( md5( $pass_array['salt'] ) . md5( $this->to_char( $password ) ) ) );
|
||||
}
|
||||
|
||||
private function to_char( $input ) {
|
||||
$output = "";
|
||||
for ( $i = 0; $i < strlen( $input ); $i++ ) {
|
||||
$j = ord( $input[$i] );
|
||||
if ( ( $j >= 65 && $j <= 90 )
|
||||
|| ( $j >= 97 && $j <= 122 )
|
||||
|| ( $j >= 48 && $j <= 57 ) )
|
||||
{
|
||||
$output .= $input[$i];
|
||||
} else {
|
||||
$output .= "&#" . ord( $input[$i] ) . ";";
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* This callback processes any custom BBCodes with parser.php
|
||||
*/
|
||||
protected function callback_html( $field ) {
|
||||
|
||||
// Strips Invision custom HTML first from $field before parsing $field to parser.php
|
||||
$invision_markup = $field;
|
||||
$invision_markup = html_entity_decode( $invision_markup );
|
||||
|
||||
// Replace '[html]' with '<pre><code>'
|
||||
$invision_markup = preg_replace( '/\[html\]/', '<pre><code>', $invision_markup );
|
||||
// Replace '[/html]' with '</code></pre>'
|
||||
$invision_markup = preg_replace( '/\[\/html\]/', '</code></pre>', $invision_markup );
|
||||
// Replace '[sql]' with '<pre><code>'
|
||||
$invision_markup = preg_replace( '/\[sql\]/', '<pre><code>', $invision_markup );
|
||||
// Replace '[/sql]' with '</code></pre>'
|
||||
$invision_markup = preg_replace( '/\[\/sql\]/', '</code></pre>', $invision_markup );
|
||||
// Replace '[php]' with '<pre><code>'
|
||||
$invision_markup = preg_replace( '/\[php\]/', '<pre><code>', $invision_markup );
|
||||
// Replace '[/php]' with '</code></pre>'
|
||||
$invision_markup = preg_replace( '/\[\/php\]/', '</code></pre>', $invision_markup );
|
||||
// Replace '[xml]' with '<pre><code>'
|
||||
$invision_markup = preg_replace( '/\[xml\]/', '<pre><code>', $invision_markup );
|
||||
// Replace '[/xml]' with '</code></pre>'
|
||||
$invision_markup = preg_replace( '/\[\/xml\]/', '</code></pre>', $invision_markup );
|
||||
// Replace '[CODE]' with '<pre><code>'
|
||||
$invision_markup = preg_replace( '/\[CODE\]/', '<pre><code>', $invision_markup );
|
||||
// Replace '[/CODE]' with '</code></pre>'
|
||||
$invision_markup = preg_replace( '/\[\/CODE\]/', '</code></pre>', $invision_markup );
|
||||
|
||||
// Replace '[quote:XXXXXXX]' with '<blockquote>'
|
||||
$invision_markup = preg_replace( '/\[quote:(.*?)\]/', '<blockquote>', $invision_markup );
|
||||
// Replace '[quote="$1"]' with '<em>@$1 wrote:</em><blockquote>'
|
||||
$invision_markup = preg_replace( '/\[quote="(.*?)":(.*?)\]/', '<em>@$1 wrote:</em><blockquote>', $invision_markup );
|
||||
// Replace '[/quote:XXXXXXX]' with '</blockquote>'
|
||||
$invision_markup = preg_replace( '/\[\/quote:(.*?)\]/', '</blockquote>', $invision_markup );
|
||||
|
||||
// Replace '[twitter]$1[/twitter]' with '<a href="https://twitter.com/$1">@$1</a>"
|
||||
$invision_markup = preg_replace( '/\[twitter\](.*?)\[\/twitter\]/', '<a href="https://twitter.com/$1">@$1</a>', $invision_markup );
|
||||
|
||||
// Replace '[member='username']' with '@username"
|
||||
$invision_markup = preg_replace( '/\[member=\'(.*?)\'\]/', '@$1 ', $invision_markup );
|
||||
|
||||
// Replace '[media]' with ''
|
||||
$invision_markup = preg_replace( '/\[media\]/', '', $invision_markup );
|
||||
// Replace '[/media]' with ''
|
||||
$invision_markup = preg_replace( '/\[\/media\]/', '', $invision_markup );
|
||||
|
||||
// Replace '[list:XXXXXXX]' with '<ul>'
|
||||
$invision_markup = preg_replace( '/\[list\]/', '<ul>', $invision_markup );
|
||||
// Replace '[list=1:XXXXXXX]' with '<ul>'
|
||||
$invision_markup = preg_replace( '/\[list=1\]/', '<ul>', $invision_markup );
|
||||
// Replace '[*:XXXXXXX]' with '<li>'
|
||||
$invision_markup = preg_replace( '/\[\*\](.*?)\<br \/\>/', '<li>$1</li>', $invision_markup );
|
||||
// Replace '[/list:u:XXXXXXX]' with '</ul>'
|
||||
$invision_markup = preg_replace( '/\[\/list\]/', '</ul>', $invision_markup );
|
||||
|
||||
// Replace '[hr]' with '<hr>"
|
||||
$invision_markup = preg_replace( '/\[hr\]/', '<hr>', $invision_markup );
|
||||
|
||||
// Replace '[font=XXXXXXX]' with ''
|
||||
$invision_markup = preg_replace( '/\[font=(.*?)\]/', '', $invision_markup );
|
||||
// Replace '[/font]' with ''
|
||||
$invision_markup = preg_replace( '/\[\/font\]/', '', $invision_markup );
|
||||
|
||||
// Replace any Invision smilies from path '/sp-resources/forum-smileys/sf-smily.gif' with the equivelant WordPress Smilie
|
||||
$invision_markup = preg_replace( '/\<img src=(.*?)EMO\_DIR(.*?)bbc_emoticon(.*?)alt=\'(.*?)\' \/\>/', '$4', $invision_markup );
|
||||
$invision_markup = preg_replace( '/\:angry\:/', ':mad:', $invision_markup );
|
||||
$invision_markup = preg_replace( '/\:mellow\:/', ':neutral:', $invision_markup );
|
||||
$invision_markup = preg_replace( '/\:blink\:/', ':eek:', $invision_markup );
|
||||
$invision_markup = preg_replace( '/B\)/', ':cool:', $invision_markup );
|
||||
$invision_markup = preg_replace( '/\:rolleyes\:/', ':roll:', $invision_markup );
|
||||
$invision_markup = preg_replace( '/\:unsure\:/', ':???:', $invision_markup );
|
||||
|
||||
// Now that Invision custom HTML has been stripped put the cleaned HTML back in $field
|
||||
$field = $invision_markup;
|
||||
|
||||
// Parse out any bbCodes in $field with the BBCode 'parser.php'
|
||||
return parent::callback_html( $field );
|
||||
}
|
||||
}
|
||||
523
wp-content/plugins/bbpress/includes/admin/converters/Kunena1.php
Normal file
523
wp-content/plugins/bbpress/includes/admin/converters/Kunena1.php
Normal file
@@ -0,0 +1,523 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress Kunena 1.x Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of Kunena v1.x Forums for Joomla Forum converter.
|
||||
*
|
||||
* @since 2.5.0 bbPress (r5144)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/kunena/
|
||||
*/
|
||||
class Kunena1 extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main Constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
/** Forum Section *****************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum parent id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'parent',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_parent_id'
|
||||
);
|
||||
|
||||
// Forum topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'numTopics',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_topic_count'
|
||||
);
|
||||
|
||||
// Forum reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'numPosts',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_reply_count'
|
||||
);
|
||||
|
||||
// Forum total topic count (Includes unpublished topics, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'numTopics',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_topic_count'
|
||||
);
|
||||
|
||||
// Forum total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'numPosts',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_reply_count'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'description',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'ordering',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Category = 0 or Forum > 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'parent',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'callback_method' => 'callback_forum_type'
|
||||
);
|
||||
|
||||
// Forum status (Open = 0 or Closed = 1, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'locked',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'callback_method' => 'callback_forum_status'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
/** Topic Section *****************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'thread',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'catid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'userid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic Author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'ip',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
// Note: We join the 'kunena_messages_text' table because 'kunena_messages' table does not include topic content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages_text',
|
||||
'from_fieldname' => 'message',
|
||||
'join_tablename' => 'kunena_messages',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON kunena_messages_text.mesid = kunena_messages.id WHERE kunena_messages.parent = 0',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'subject',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'subject',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'catid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// Topic status (Open or Closed, Kunena v3.x 0=open & 1=closed)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'locked',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_topic_status'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
/**
|
||||
* Kunena v1.x Forums do not support topic tags out of the box
|
||||
*/
|
||||
|
||||
/** Reply Section *****************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'catid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_topicid_to_forumid'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'thread',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'ip',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'userid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
// Note: We join the 'kunena_messages_text' table because 'kunena_messages' table does not include reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages_text',
|
||||
'from_fieldname' => 'message',
|
||||
'join_tablename' => 'kunena_messages',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON kunena_messages.id = kunena_messages_text.mesid WHERE kunena_messages.parent != 0',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'thread',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
//Note: We are importing the Joomla User details and the Kunena v1.x user profile details.
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old user password (Stored in usermeta serialized with salt)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'password',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password',
|
||||
'callback_method' => 'callback_savepass'
|
||||
);
|
||||
|
||||
// Store old user salt (This is only used for the SELECT row info for the above password save)
|
||||
// $this->field_map[] = array(
|
||||
// 'from_tablename' => 'user',
|
||||
// 'from_fieldname' => 'salt',
|
||||
// 'to_type' => 'user',
|
||||
// 'to_fieldname' => ''
|
||||
// );
|
||||
|
||||
// User password verify class (Stored in usermeta for verifying password)
|
||||
// $this->field_map[] = array(
|
||||
// 'to_type' => 'user',
|
||||
// 'to_fieldname' => '_bbp_class',
|
||||
// 'default' => 'Kunena1'
|
||||
// );
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'email',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'registerDate',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass($field, $row) {
|
||||
$pass_array = array('hash' => $field, 'salt' => $row['salt']);
|
||||
return $pass_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*/
|
||||
public function authenticate_pass($password, $serialized_pass) {
|
||||
$pass_array = unserialize($serialized_pass);
|
||||
return ( $pass_array['hash'] == md5(md5($password) . $pass_array['salt']) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the forum type from Kunena v1.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status Kunena v1.x numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_forum_type( $status = 0 ) {
|
||||
if ( $status == 0 ) {
|
||||
$status = 'category';
|
||||
} else {
|
||||
$status = 'forum';
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the forum status from Kunena v1.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status Kunena v1.x numeric forum status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_forum_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'open';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the post status from Kunena v1.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status Kunena v1.x numeric topic status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'publish';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
564
wp-content/plugins/bbpress/includes/admin/converters/Kunena2.php
Normal file
564
wp-content/plugins/bbpress/includes/admin/converters/Kunena2.php
Normal file
@@ -0,0 +1,564 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress Kunena 2.x Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of Kunena v2.x Forums for Joomla Forum converter.
|
||||
*
|
||||
* @since 2.5.0 bbPress (r5144)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/kunena/
|
||||
*/
|
||||
class Kunena2 extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main Constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
/** Forum Section *****************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum parent id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'parent_id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_parent_id'
|
||||
);
|
||||
|
||||
// Forum topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'numTopics',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_topic_count'
|
||||
);
|
||||
|
||||
// Forum reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'numPosts',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_reply_count'
|
||||
);
|
||||
|
||||
// Forum total topic count (Includes unpublished topics, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'numTopics',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_topic_count'
|
||||
);
|
||||
|
||||
// Forum total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'numPosts',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_reply_count'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'alias',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'description',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'ordering',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Category = 0 or Forum = >0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'parent_id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'callback_method' => 'callback_forum_type'
|
||||
);
|
||||
|
||||
// Forum status (Open = 0 or Closed = 1, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'locked',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'callback_method' => 'callback_forum_status'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
/** Topic Section *****************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'posts',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'posts',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_total_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'category_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'first_post_userid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic Author ip (Stored in postmeta)
|
||||
// Note: We join the 'kunena_messages' table because 'kunena_topics' table does not include author ip.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'ip',
|
||||
'join_tablename' => 'kunena_topics',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'USING (id)',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'first_post_message',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'subject',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'subject',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'category_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'first_post_time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'first_post_time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'last_post_time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'last_post_time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'last_post_time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// Topic status (Open or Closed, Kunena v2.x 0=open & 1=closed)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'locked',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_topic_status'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
/**
|
||||
* Kunena v2.x Forums do not support topic tags out of the box
|
||||
*/
|
||||
|
||||
/** Reply Section *****************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'catid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_topicid_to_forumid'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'thread',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'ip',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'userid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
// Note: We join the 'kunena_messages_text' table because 'kunena_messages' table does not include reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages_text',
|
||||
'from_fieldname' => 'message',
|
||||
'join_tablename' => 'kunena_messages',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_messages_text.mesid = kunena_messages.id LEFT JOIN jos_kunena_topics AS kunena_topics ON kunena_messages.thread = kunena_topics.id WHERE kunena_messages.parent != 0',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'thread',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
//Note: We are importing the Joomla User details and the Kunena v2.x user profile details.
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old user password (Stored in usermeta serialized with salt)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'password',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password',
|
||||
'callback_method' => 'callback_savepass'
|
||||
);
|
||||
|
||||
// Store old user salt. This is only used for the SELECT row info for the above password save
|
||||
/*
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'salt',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => ''
|
||||
);
|
||||
*/
|
||||
|
||||
// User password verify class. Stores in usermeta for verifying password.
|
||||
/*
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_class',
|
||||
'default' => 'Kunena2'
|
||||
);
|
||||
*/
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'email',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'registerDate',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// User display name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'display_name'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass($field, $row) {
|
||||
$pass_array = array('hash' => $field, 'salt' => $row['salt']);
|
||||
return $pass_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*/
|
||||
public function authenticate_pass($password, $serialized_pass) {
|
||||
$pass_array = unserialize($serialized_pass);
|
||||
return ( $pass_array['hash'] == md5(md5($password) . $pass_array['salt']) );
|
||||
}
|
||||
/**
|
||||
* Translate the forum type from Kunena v2.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status Kunena v2.x numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_forum_type( $status = 0 ) {
|
||||
if ( $status == 0 ) {
|
||||
$status = 'category';
|
||||
} else {
|
||||
$status = 'forum';
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the forum status from Kunena v2.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status Kunena v2.x numeric forum status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_forum_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'open';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the post status from Kunena v2.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status Kunena v2.x numeric topic status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'publish';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the topic/reply count.
|
||||
*
|
||||
* @param int $count Kunena v2.x topic/reply counts
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_reply_count( $count = 1 ) {
|
||||
$count = absint( (int) $count - 1 );
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
789
wp-content/plugins/bbpress/includes/admin/converters/Kunena3.php
Normal file
789
wp-content/plugins/bbpress/includes/admin/converters/Kunena3.php
Normal file
@@ -0,0 +1,789 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress Kunena 3.x Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of Kunena v3.x Forums for Joomla Forum converter.
|
||||
*
|
||||
* @since 2.5.0 bbPress (r5144)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/kunena/
|
||||
*/
|
||||
class Kunena3 extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main Constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
/** Forum Section *****************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum parent id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'parent_id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_parent_id'
|
||||
);
|
||||
|
||||
// Forum topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'numTopics',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_topic_count'
|
||||
);
|
||||
|
||||
// Forum reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'numPosts',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_reply_count'
|
||||
);
|
||||
|
||||
// Forum total topic count (Includes unpublished topics, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'numTopics',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_topic_count'
|
||||
);
|
||||
|
||||
// Forum total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'numPosts',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_reply_count'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'alias',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'description',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'ordering',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Category = 0 or Forum = >0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'parent_id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'callback_method' => 'callback_forum_type'
|
||||
);
|
||||
|
||||
// Forum status (Open = 0 or Closed = 1, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_categories',
|
||||
'from_fieldname' => 'locked',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'callback_method' => 'callback_forum_status'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
/** Topic Section *****************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'posts',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'posts',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_total_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'category_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'first_post_userid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic Author ip (Stored in postmeta)
|
||||
// Note: We join the 'kunena_messages' table because 'kunena_topics' table does not include author ip.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'ip',
|
||||
'join_tablename' => 'kunena_topics',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'USING (id)',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'first_post_message',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'subject',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'subject',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'category_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'first_post_time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'first_post_time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'last_post_time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'last_post_time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'last_post_time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// Topic status (Open or Closed, Kunena v3.x 0=open & 1=closed)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_topics',
|
||||
'from_fieldname' => 'locked',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_topic_status'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
/**
|
||||
* Kunena v3.x Forums do not support topic tags out of the box
|
||||
*/
|
||||
|
||||
/** Reply Section ******************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'catid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_topicid_to_forumid'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'thread',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'ip',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'userid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
// Note: We join the 'kunena_messages_text' table because 'kunena_messages' table does not include reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages_text',
|
||||
'from_fieldname' => 'message',
|
||||
'join_tablename' => 'kunena_messages',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_messages_text.mesid = kunena_messages.id LEFT JOIN jos_kunena_topics AS kunena_topics ON kunena_messages.thread = kunena_topics.id WHERE kunena_messages.parent != 0',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'thread',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_messages',
|
||||
'from_fieldname' => 'time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
//Note: We are importing the Joomla User details and the Kunena v3.x user profile details.
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old user password (Stored in usermeta serialized with salt)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'password',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password',
|
||||
'callback_method' => 'callback_savepass'
|
||||
);
|
||||
|
||||
// Store old user salt (This is only used for the SELECT row info for the above password save)
|
||||
// $this->field_map[] = array(
|
||||
// 'from_tablename' => 'users',
|
||||
// 'from_fieldname' => 'salt',
|
||||
// 'to_type' => 'user',
|
||||
// 'to_fieldname' => ''
|
||||
// );
|
||||
|
||||
// User password verify class (Stored in usermeta for verifying password)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'users',
|
||||
'to_fieldname' => '_bbp_class',
|
||||
'default' => 'Kunena3'
|
||||
);
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User nice name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_nicename'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'email',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User homepage.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_users',
|
||||
'from_fieldname' => 'websiteurl',
|
||||
'join_tablename' => 'users',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_users.userid = users.id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_url'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'registerDate',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// User display name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'display_name'
|
||||
);
|
||||
|
||||
// User AIM (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_users',
|
||||
'from_fieldname' => 'aim',
|
||||
'join_tablename' => 'users',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_users.userid = users.id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_kunena3_user_aim'
|
||||
);
|
||||
|
||||
// User Yahoo (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_users',
|
||||
'from_fieldname' => 'yim',
|
||||
'join_tablename' => 'users',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_users.userid = users.id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_kunena3_user_yim'
|
||||
);
|
||||
|
||||
// Store Google Tak (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_users',
|
||||
'from_fieldname' => 'gtalk',
|
||||
'join_tablename' => 'users',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_users.userid = users.id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_kunena3_user_jabber'
|
||||
);
|
||||
|
||||
// Store ICQ (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_users',
|
||||
'from_fieldname' => 'icq',
|
||||
'join_tablename' => 'users',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_users.userid = users.id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_kunena3_user_icq'
|
||||
);
|
||||
|
||||
// Store MSN (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_users',
|
||||
'from_fieldname' => 'msn',
|
||||
'join_tablename' => 'users',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_users.userid = users.id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_kunena3_user_msn'
|
||||
);
|
||||
|
||||
// Store Skype (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_users',
|
||||
'from_fieldname' => 'skype',
|
||||
'join_tablename' => 'users',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_users.userid = users.id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_kunena3_user_skype'
|
||||
);
|
||||
|
||||
// Store Twitter (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_users',
|
||||
'from_fieldname' => 'twitter',
|
||||
'join_tablename' => 'users',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_users.userid = users.id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_kunena3_user_twitter'
|
||||
);
|
||||
|
||||
// Store Facebook (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_users',
|
||||
'from_fieldname' => 'facebook',
|
||||
'join_tablename' => 'users',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_users.userid = users.id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_kunena3_user_facebook'
|
||||
);
|
||||
|
||||
// Store myspace (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_users',
|
||||
'from_fieldname' => 'myspace',
|
||||
'join_tablename' => 'users',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_users.userid = users.id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_kunena3_user_myspace'
|
||||
);
|
||||
|
||||
// Store linkedin (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_users',
|
||||
'from_fieldname' => 'linkedin',
|
||||
'join_tablename' => 'users',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_users.userid = users.id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_kunena3_user_linkedin'
|
||||
);
|
||||
|
||||
// Store delicious (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_users',
|
||||
'from_fieldname' => 'delicious',
|
||||
'join_tablename' => 'users',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_users.userid = users.id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_kunena3_user_delicious'
|
||||
);
|
||||
|
||||
// Store friendfeed (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_users',
|
||||
'from_fieldname' => 'friendfeed',
|
||||
'join_tablename' => 'users',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_users.userid = users.id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_kunena3_user_friendfeed'
|
||||
);
|
||||
|
||||
// Store digg (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_users',
|
||||
'from_fieldname' => 'digg',
|
||||
'join_tablename' => 'users',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_users.userid = users.id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_kunena3_user_digg'
|
||||
);
|
||||
|
||||
// Store blogspot (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_users',
|
||||
'from_fieldname' => 'blogspot',
|
||||
'join_tablename' => 'users',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_users.userid = users.id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_kunena3_user_blogspot'
|
||||
);
|
||||
|
||||
// Store flickr (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_users',
|
||||
'from_fieldname' => 'flickr',
|
||||
'join_tablename' => 'users',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_users.userid = users.id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_kunena3_user_flickr'
|
||||
);
|
||||
|
||||
// Store bebo (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_users',
|
||||
'from_fieldname' => 'bebo',
|
||||
'join_tablename' => 'users',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_users.userid = users.id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_kunena3_user_bebo'
|
||||
);
|
||||
|
||||
// Store websitename (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_users',
|
||||
'from_fieldname' => 'websitename',
|
||||
'join_tablename' => 'users',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_users.userid = users.id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_kunena3_user_websitename'
|
||||
);
|
||||
|
||||
// Store location (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_users',
|
||||
'from_fieldname' => 'location',
|
||||
'join_tablename' => 'users',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_users.userid = users.id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_kunena3_user_location'
|
||||
);
|
||||
|
||||
// Store Signature (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'kunena_users',
|
||||
'from_fieldname' => 'signature',
|
||||
'join_tablename' => 'users',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON kunena_users.userid = users.id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_kunena3_user_sig',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass( $field, $row ) {
|
||||
$pass_array = array( 'hash' => $field, 'salt' => $row['salt'] );
|
||||
return $pass_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*/
|
||||
public function authenticate_pass( $password, $serialized_pass ) {
|
||||
$pass_array = unserialize( $serialized_pass );
|
||||
return ( $pass_array['hash'] == md5( md5( $password ). $pass_array['salt'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the forum type from Kunena v3.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status Kunena v3.x numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_forum_type( $status = 0 ) {
|
||||
if ( $status == 0 ) {
|
||||
$status = 'category';
|
||||
} else {
|
||||
$status = 'forum';
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the forum status from Kunena v3.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status Kunena v3.x numeric forum status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_forum_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'open';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the post status from Kunena v3.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status Kunena v3.x numeric topic status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'publish';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the topic/reply count.
|
||||
*
|
||||
* @param int $count Kunena v3.x topic/reply counts
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_reply_count( $count = 1 ) {
|
||||
$count = absint( (int) $count - 1 );
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
480
wp-content/plugins/bbpress/includes/admin/converters/Mingle.php
Normal file
480
wp-content/plugins/bbpress/includes/admin/converters/Mingle.php
Normal file
@@ -0,0 +1,480 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress Mingle Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of Mingle Forums converter.
|
||||
*
|
||||
* @since 2.3.0 bbPress (r4691)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/mingle
|
||||
*/
|
||||
class Mingle extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
// Setup smiley URL & path
|
||||
$this->bbcode_parser_properties = array(
|
||||
'smiley_url' => false,
|
||||
'smiley_dir' => false
|
||||
);
|
||||
|
||||
/** Forum Section ******************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_forums',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum parent id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_forums',
|
||||
'from_fieldname' => 'parent_id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_parent_id'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_forums',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid confilcts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_forums',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_forums',
|
||||
'from_fieldname' => 'description',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_forums',
|
||||
'from_fieldname' => 'sort',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Set a default value 'forum', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'default' => 'forum'
|
||||
);
|
||||
|
||||
// Forum status (Set a default value 'open', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'default' => 'open'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
/** Topic Section ******************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_threads',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_threads',
|
||||
'from_fieldname' => 'parent_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_threads',
|
||||
'from_fieldname' => 'starter',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
// Note: We join the forum_posts table because forum_topics do not have topic content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_posts',
|
||||
'from_fieldname' => 'text',
|
||||
'join_tablename' => 'forum_threads',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON forum_posts.parent_id = forum_threads.id GROUP BY forum_threads.id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_threads',
|
||||
'from_fieldname' => 'subject',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_threads',
|
||||
'from_fieldname' => 'subject',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_threads',
|
||||
'from_fieldname' => 'parent_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Sticky status (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_threads',
|
||||
'from_fieldname' => 'status',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_sticky_status_id',
|
||||
'callback_method' => 'callback_sticky_status'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_threads',
|
||||
'from_fieldname' => 'date',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_threads',
|
||||
'from_fieldname' => 'date',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_threads',
|
||||
'from_fieldname' => 'last_post',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_threads',
|
||||
'from_fieldname' => 'last_post',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_threads',
|
||||
'from_fieldname' => 'last_post',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time'
|
||||
);
|
||||
|
||||
// Topic status (Open or Closed)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_threads',
|
||||
'from_fieldname' => 'closed',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_topic_status'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
/**
|
||||
* Mingle Forums do not support topic tags
|
||||
*/
|
||||
|
||||
/** Reply Section ******************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_posts',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Setup reply section table joins
|
||||
// We need join the 'forum_threads' table to only import replies
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_threads',
|
||||
'from_fieldname' => 'date',
|
||||
'join_tablename' => 'forum_posts',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON forum_posts.parent_id = forum_threads.id',
|
||||
'from_expression' => 'WHERE forum_threads.subject != forum_posts.subject',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_last_active_time'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_posts',
|
||||
'from_fieldname' => 'parent_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_topicid_to_forumid'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_posts',
|
||||
'from_fieldname' => 'parent_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_posts',
|
||||
'from_fieldname' => 'author_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_posts',
|
||||
'from_fieldname' => 'text',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_posts',
|
||||
'from_fieldname' => 'parent_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_posts',
|
||||
'from_fieldname' => 'date',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_posts',
|
||||
'from_fieldname' => 'date',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_posts',
|
||||
'from_fieldname' => 'date',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_posts',
|
||||
'from_fieldname' => 'date',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'ID',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old user password (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_pass',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password'
|
||||
);
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_login',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User nice name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_nicename',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_nicename'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_email',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User homepage.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_url',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_url'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_registered',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered'
|
||||
);
|
||||
|
||||
// User status.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_status',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_status'
|
||||
);
|
||||
|
||||
// User display name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'display_name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'display_name'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass( $field, $row ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*/
|
||||
public function authenticate_pass( $password, $serialized_pass ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the topic status from Mingle numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status Mingle v1.x numeric topic status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'publish';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the topic sticky status type from Mingle numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status Mingle numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_sticky_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 'sticky' :
|
||||
$status = 'sticky'; // Mingle Sticky 'status = sticky'
|
||||
break;
|
||||
|
||||
case 'open' :
|
||||
default :
|
||||
$status = 'normal'; // Mingle Normal Topic 'status = open'
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
590
wp-content/plugins/bbpress/includes/admin/converters/MyBB.php
Normal file
590
wp-content/plugins/bbpress/includes/admin/converters/MyBB.php
Normal file
@@ -0,0 +1,590 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress MyBB Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of MyBB Forum converter.
|
||||
*
|
||||
* @since 2.5.0 bbPress (r5140)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/mybb
|
||||
*/
|
||||
class MyBB extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main Constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
/** Forum Section *****************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'fid',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum parent id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'pid',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_parent_id'
|
||||
);
|
||||
|
||||
// Forum topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'threads',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_topic_count'
|
||||
);
|
||||
|
||||
// Forum reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'posts',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_reply_count'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'description',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'disporder',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Set a default value 'forum', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'default' => 'forum'
|
||||
);
|
||||
|
||||
// Forum status (Set a default value 'open', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'default' => 'open'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
/** Topic Section *****************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'tid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'replies',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'replies',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_total_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'fid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'uid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic Author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'ipaddress',
|
||||
'join_tablename' => 'threads',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (tid) WHERE replyto = 0',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
// Note: We join the 'posts' table because 'threads' table does not have content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'message',
|
||||
'join_tablename' => 'threads',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (tid) WHERE replyto = 0',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'subject',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'subject',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'fid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Sticky status (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'sticky',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_sticky_status_id',
|
||||
'callback_method' => 'callback_sticky_status'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'lastpost',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'lastpost',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'lastpost',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// Topic status (Open or Closed, MyBB v1.6.10 open = null & closed = 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'closed',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_topic_status'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
/**
|
||||
* MyBB v1.6.10 Forums do not support topic tags out of the box
|
||||
*/
|
||||
|
||||
/** Reply Section *****************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'pid',
|
||||
'from_expression' => 'WHERE replyto != 0',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'fid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_topicid_to_forumid'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'tid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'ipaddress',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'uid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'message',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'tid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'edittime',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'edittime',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'uid',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old user password (Stored in usermeta serialized with salt)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'password',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password',
|
||||
'callback_method' => 'callback_savepass'
|
||||
);
|
||||
|
||||
// Store old user salt (This is only used for the SELECT row info for the above password save)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'salt',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => ''
|
||||
);
|
||||
|
||||
// User password verify class (Stored in usermeta for verifying password)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'users',
|
||||
'to_fieldname' => '_bbp_class',
|
||||
'default' => 'MyBB'
|
||||
);
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User nice name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_nicename'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'email',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User homepage.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'website',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_url'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'regdate',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// User display name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'usertitle',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'display_name'
|
||||
);
|
||||
|
||||
// User AIM (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'aim',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_mybb_user_aim'
|
||||
);
|
||||
|
||||
// User Yahoo (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'yahoo',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_mybb_user_yim'
|
||||
);
|
||||
|
||||
// Store ICQ (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'icq',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_mybb_user_icq'
|
||||
);
|
||||
|
||||
// Store MSN (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'msn',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_mybb_user_msn'
|
||||
);
|
||||
|
||||
// Store Signature (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'signature',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_mybb_user_sig',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass( $field, $row ) {
|
||||
$pass_array = array( 'hash' => $field, 'salt' => $row['salt'] );
|
||||
return $pass_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*/
|
||||
public function authenticate_pass( $password, $serialized_pass ) {
|
||||
$pass_array = unserialize( $serialized_pass );
|
||||
return ( $pass_array['hash'] == md5( md5( $password ). $pass_array['salt'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the post status from MyBB v1.6.10 numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status MyBB v1.6.10 numeric topic status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'publish';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the topic sticky status type from MyBB v1.6.10 numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status MyBB v1.6.10 numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_sticky_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'sticky'; // MyBB Sticky 'topic_sticky = 1'
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'normal'; // MyBB Normal Topic 'topic_sticky = 0'
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the topic/reply count.
|
||||
*
|
||||
* @param int $count MyBB v1.6.10 topic/reply counts
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_reply_count( $count = 1 ) {
|
||||
$count = absint( (int) $count - 1 );
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
620
wp-content/plugins/bbpress/includes/admin/converters/PHPFox3.php
Normal file
620
wp-content/plugins/bbpress/includes/admin/converters/PHPFox3.php
Normal file
@@ -0,0 +1,620 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress PHPFox3 Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of PHPFox v3.x Forum converter.
|
||||
*
|
||||
* @since 2.5.0 bbPress (r5146)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/phpfox
|
||||
*/
|
||||
class PHPFox3 extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main Constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
/** Forum Section *****************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum parent id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'parent_id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_parent_id'
|
||||
);
|
||||
|
||||
// Forum topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'total_thread',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_topic_count'
|
||||
);
|
||||
|
||||
// Forum reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'total_post',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_reply_count'
|
||||
);
|
||||
|
||||
// Forum total topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'total_thread',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_topic_count'
|
||||
);
|
||||
|
||||
// Forum total reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'total_post',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_reply_count'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'name_url',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'description',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'ordering',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Forum = 0 or Category = 1, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'is_category',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'callback_method' => 'callback_forum_type'
|
||||
);
|
||||
|
||||
// Forum status (0=Open or 1=Closed, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'is_closed',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'callback_method' => 'callback_forum_status'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
/** Topic Section *****************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_thread',
|
||||
'from_fieldname' => 'thread_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_thread',
|
||||
'from_fieldname' => 'total_post',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_thread',
|
||||
'from_fieldname' => 'total_post',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_total_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_thread',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_thread',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
// Note: We join the 'forum_post_text' table because 'forum_thread' table does not include content.
|
||||
// Note: We can use 'text' for original text OR 'text_parsed' for pre-parsed text output
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_post_text',
|
||||
'from_fieldname' => 'text_parsed',
|
||||
'join_tablename' => 'forum_thread',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON forum_thread.start_id = forum_post_text.post_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_thread',
|
||||
'from_fieldname' => 'title',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_thread',
|
||||
'from_fieldname' => 'title_url',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_thread',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic status (Open or Closed, PHPFox v3.5.x 0=open & 1=closed)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_thread',
|
||||
'from_fieldname' => 'is_closed',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_topic_status'
|
||||
);
|
||||
|
||||
// Sticky status (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_thread',
|
||||
'from_fieldname' => 'order_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_sticky_status_id',
|
||||
'callback_method' => 'callback_sticky_status'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_thread',
|
||||
'from_fieldname' => 'time_stamp',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_thread',
|
||||
'from_fieldname' => 'time_stamp',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_thread',
|
||||
'from_fieldname' => 'time_update',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_thread',
|
||||
'from_fieldname' => 'time_update',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_thread',
|
||||
'from_fieldname' => 'time_update',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
// Topic id.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'tag',
|
||||
'from_fieldname' => 'item_id',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'objectid',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Taxonomy ID.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'tag',
|
||||
'from_fieldname' => 'tag_id',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'taxonomy'
|
||||
);
|
||||
|
||||
// Term text.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'tag',
|
||||
'from_fieldname' => 'tag_text',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'name'
|
||||
);
|
||||
|
||||
// Term slug.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'tag',
|
||||
'from_fieldname' => 'tag_url',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'slug',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
/** Reply Section *****************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_post',
|
||||
'from_fieldname' => 'post_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_thread',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'join_tablename' => 'forum_post',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'USING (thread_id)',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_topicid_to_forumid'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_post',
|
||||
'from_fieldname' => 'thread_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_post',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
// Note: We join the 'forum_post_text' table because 'forum_post' table does not include content.
|
||||
// Note: We can use 'text' for original text OR 'text_parsed' for pre-parsed text output
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_post_text',
|
||||
'from_fieldname' => 'text_parsed',
|
||||
'join_tablename' => 'forum_post',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON forum_post_text.post_id = forum_post.post_id WHERE forum_thread.start_id != forum_post.post_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_post',
|
||||
'from_fieldname' => 'thread_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_post',
|
||||
'from_fieldname' => 'time_stamp',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_post',
|
||||
'from_fieldname' => 'time_stamp',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_post',
|
||||
'from_fieldname' => 'time_stamp',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_post',
|
||||
'from_fieldname' => 'time_stamp',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old user password (Stored in usermeta serialized with salt)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'password',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password',
|
||||
'callback_method' => 'callback_savepass'
|
||||
);
|
||||
|
||||
// Store old user salt (This is only used for the SELECT row info for the above password save)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'password_salt',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => ''
|
||||
);
|
||||
|
||||
// User password verify class (Stored in usermeta for verifying password)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_class',
|
||||
'default' => 'PHPFox3'
|
||||
);
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'user_name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User nice name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'user_name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_nicename'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'email',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'joined',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// User display name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'full_name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'display_name'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass( $field, $row ) {
|
||||
$pass_array = array( 'hash' => $field, 'salt' => $row['salt'] );
|
||||
return $pass_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*/
|
||||
public function authenticate_pass( $password, $serialized_pass ) {
|
||||
$pass_array = unserialize( $serialized_pass );
|
||||
return ( $pass_array['hash'] == md5( md5( $password ). $pass_array['salt'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the forum type from PHPFox v3.5.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status PHPFox v3.5.x numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_forum_type( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'category';
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'forum';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the forum status from PHPFox v3.5.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status PHPFox v3.5.x numeric forum status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_forum_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'open';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the post status from PHPFox v3.5.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status PHPFox v3.5.x numeric topic status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'publish';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the topic sticky status type from PHPFox v3.5.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status PHPFox v3.5.x numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_sticky_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'sticky'; // PHPFox Sticky 'topic_sticky = 1'
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'normal'; // PHPFox Normal Topic 'topic_sticky = 0'
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the topic/reply count.
|
||||
*
|
||||
* @param int $count PHPFox v3.5.x topic/reply counts
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_reply_count( $count = 1 ) {
|
||||
$count = absint( (int) $count - 1 );
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
569
wp-content/plugins/bbpress/includes/admin/converters/PHPWind.php
Normal file
569
wp-content/plugins/bbpress/includes/admin/converters/PHPWind.php
Normal file
@@ -0,0 +1,569 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress PHPWind Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of PHPWind Forum converter.
|
||||
*
|
||||
* @since 2.5.0 bbPress (r5142)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/phpwind
|
||||
*/
|
||||
class PHPWind extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main Constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
/** Forum Section *****************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_forum',
|
||||
'from_fieldname' => 'fid',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum parent id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_forum',
|
||||
'from_fieldname' => 'parentid',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_parent_id'
|
||||
);
|
||||
|
||||
// Forum topic count (Stored in postmeta)
|
||||
// Note: We join the 'bbs_forum_statistics' table because 'bbs_forum' table does not include topic and reply counts.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_forum_statistics',
|
||||
'from_fieldname' => 'threads',
|
||||
'join_tablename' => 'bbs_forum',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'USING (fid)',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_topic_count'
|
||||
);
|
||||
|
||||
// Forum reply count (Stored in postmeta)
|
||||
// Note: We join the 'bbs_forum_statistics' table because 'bbs_forum' table does not include topic and reply counts.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_forum_statistics',
|
||||
'from_fieldname' => 'posts',
|
||||
'join_tablename' => 'bbs_forum',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'USING (fid)',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_reply_count'
|
||||
);
|
||||
|
||||
// Forum total topic count (Stored in postmeta)
|
||||
// Note: We join the 'bbs_forum_statistics' table because 'bbs_forum' table does not include topic and reply counts.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_forum_statistics',
|
||||
'from_fieldname' => 'threads',
|
||||
'join_tablename' => 'bbs_forum',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'USING (fid)',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_topic_count'
|
||||
);
|
||||
|
||||
// Forum total reply count (Stored in postmeta)
|
||||
// Note: We join the 'bbs_forum_statistics' table because 'bbs_forum' table does not include topic and reply counts.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_forum_statistics',
|
||||
'from_fieldname' => 'posts',
|
||||
'join_tablename' => 'bbs_forum',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'USING (fid)',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_reply_count'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_forum',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_forum',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_forum',
|
||||
'from_fieldname' => 'descrip',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_forum',
|
||||
'from_fieldname' => 'vieworder',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Category = category or Forum = forum, sub or sub2, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_forum',
|
||||
'from_fieldname' => 'type',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'callback_method' => 'callback_forum_type'
|
||||
);
|
||||
|
||||
// Forum status (Set a default value 'open', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'default' => 'open'
|
||||
);
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'bbs_forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'bbs_forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'bbs_forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'bbs_forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
/** Topic Section *****************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_threads',
|
||||
'from_fieldname' => 'tid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_threads',
|
||||
'from_fieldname' => 'replies',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_threads',
|
||||
'from_fieldname' => 'replies',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_total_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_threads',
|
||||
'from_fieldname' => 'fid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_threads',
|
||||
'from_fieldname' => 'created_userid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic Author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_threads',
|
||||
'from_fieldname' => 'created_ip',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
// Note: We join the 'bbs_threads_content' table because 'bbs_threads' table does not have content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_threads_content',
|
||||
'from_fieldname' => 'content',
|
||||
'join_tablename' => 'bbs_threads',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (tid)',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_threads',
|
||||
'from_fieldname' => 'subject',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_threads',
|
||||
'from_fieldname' => 'subject',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_threads',
|
||||
'from_fieldname' => 'fid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_threads',
|
||||
'from_fieldname' => 'created_time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_threads',
|
||||
'from_fieldname' => 'created_time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_threads',
|
||||
'from_fieldname' => 'lastpost_time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_threads',
|
||||
'from_fieldname' => 'lastpost_time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_threads',
|
||||
'from_fieldname' => 'lastpost_time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// Topic status (Open or Closed, PHPWind v9.x 0=no, 1=closed & 2=open)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_threads',
|
||||
'from_fieldname' => 'tpcstatus',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_topic_status'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
/**
|
||||
* PHPWind v9.x Forums do not support topic tags out of the box
|
||||
*/
|
||||
|
||||
/** Reply Section *****************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_posts',
|
||||
'from_fieldname' => 'pid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_posts',
|
||||
'from_fieldname' => 'fid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_posts',
|
||||
'from_fieldname' => 'tid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_posts',
|
||||
'from_fieldname' => 'created_ip',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_posts',
|
||||
'from_fieldname' => 'created_userid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_posts',
|
||||
'from_fieldname' => 'content',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_posts',
|
||||
'from_fieldname' => 'tid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_posts',
|
||||
'from_fieldname' => 'created_time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_posts',
|
||||
'from_fieldname' => 'created_time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_posts',
|
||||
'from_fieldname' => 'created_time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'bbs_posts',
|
||||
'from_fieldname' => 'created_time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'uid',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old user password (Stored in usermeta serialized with salt)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'password',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password'
|
||||
// 'callback_method' => 'callback_savepass'
|
||||
);
|
||||
|
||||
// Store old user salt (This is only used for the SELECT row info for the above password save)
|
||||
/* $this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'pass',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => ''
|
||||
);
|
||||
*/
|
||||
// User password verify class (Stored in usermeta for verifying password)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_class',
|
||||
'default' => 'PHPWind'
|
||||
);
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User nice name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_nicename'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'email',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'regdate',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// User display name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'realname',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'display_name'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass( $field, $row ) {
|
||||
$pass_array = array( 'hash' => $field, 'salt' => $row['salt'] );
|
||||
return $pass_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*/
|
||||
public function authenticate_pass( $password, $serialized_pass ) {
|
||||
$pass_array = unserialize( $serialized_pass );
|
||||
return ( $pass_array['hash'] == md5( md5( $password ). $pass_array['salt'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the forum type from PHPWind v9.x Capitalised case to WordPress's non-capatilise case strings.
|
||||
*
|
||||
* @param int $status PHPWind v9.x numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_forum_type( $status = 1 ) {
|
||||
switch ( $status ) {
|
||||
case 'category' :
|
||||
$status = 'category';
|
||||
break;
|
||||
|
||||
case 'sub' :
|
||||
$status = 'forum';
|
||||
break;
|
||||
|
||||
case 'sub2' :
|
||||
$status = 'forum';
|
||||
break;
|
||||
|
||||
case 'forum' :
|
||||
default :
|
||||
$status = 'forum';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the post status from PHPWind v9.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status PHPWind v9.x numeric topic status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_status( $status = 2 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 2 :
|
||||
default :
|
||||
$status = 'publish';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the topic/reply count.
|
||||
*
|
||||
* @param int $count PHPWind v9.x topic/reply counts
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_reply_count( $count = 1 ) {
|
||||
$count = absint( (int) $count - 1 );
|
||||
return $count;
|
||||
}
|
||||
|
||||
}
|
||||
590
wp-content/plugins/bbpress/includes/admin/converters/Phorum.php
Normal file
590
wp-content/plugins/bbpress/includes/admin/converters/Phorum.php
Normal file
@@ -0,0 +1,590 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress Phorum Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of Phorum Forum converter.
|
||||
*
|
||||
* @since 2.5.0 bbPress (r5141)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/phorum
|
||||
*/
|
||||
class Phorum extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main Constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
/** Forum Section *****************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum parent id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'parent_id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_parent_id'
|
||||
);
|
||||
|
||||
// Forum topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'thread_count',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_topic_count'
|
||||
);
|
||||
|
||||
// Forum reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'message_count',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_reply_count'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'description',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'display_order',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Category = 1 or Forum = 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'folder_flag',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'callback_method' => 'callback_forum_type'
|
||||
);
|
||||
|
||||
// Forum status (Set a default value 'open', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'default' => 'open'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
/** Topic Section *****************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'thread',
|
||||
'from_expression' => 'WHERE parent_id = 0',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'thread_count',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'thread_count',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_total_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic author name (Stored in postmeta as _bbp_anonymous_name)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'author',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_author_name_id'
|
||||
);
|
||||
|
||||
// Is the topic anonymous (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_is_topic_anonymous_id',
|
||||
'callback_method' => 'callback_check_anonymous'
|
||||
);
|
||||
|
||||
// Topic Author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'ip',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'body',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'subject',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'subject',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'datestamp',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'datestamp',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'datestamp',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'datestamp',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'datestamp',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// Topic status (Open = 0 or Closed = 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'closed',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_topic_status'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
/**
|
||||
* Phorum v5.2.19 Forums do not support topic tags out of the box
|
||||
*/
|
||||
|
||||
/** Topic Subscriptions Section ***************************************/
|
||||
|
||||
// Subscribed topic ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'subscribers',
|
||||
'from_fieldname' => 'thread',
|
||||
'to_type' => 'topic_subscriptions',
|
||||
'to_fieldname' => '_bbp_subscriptions'
|
||||
);
|
||||
|
||||
// Subscribed user ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'subscribers',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'topic_subscriptions',
|
||||
'to_fieldname' => 'user_id',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
/** Reply Section *****************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'message_id',
|
||||
'from_expression' => 'WHERE parent_id != 0',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'thread',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'ip',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply author name (Stored in postmeta as _bbp_anonymous_name)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'author',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_author_name_id'
|
||||
);
|
||||
|
||||
// Is the reply anonymous (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_is_reply_anonymous_id',
|
||||
'callback_method' => 'callback_check_anonymous'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'body',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'thread',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'datestamp',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'datestamp',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'datestamp',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'datestamp',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old user password (Stored in usermeta serialized with salt)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'password',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password',
|
||||
'callback_method' => 'callback_savepass'
|
||||
);
|
||||
|
||||
// Store old user salt (This is only used for the SELECT row info for the above password save)
|
||||
// $this->field_map[] = array(
|
||||
// 'from_tablename' => 'users',
|
||||
// 'from_fieldname' => 'salt',
|
||||
// 'to_type' => 'user',
|
||||
// 'to_fieldname' => ''
|
||||
// );
|
||||
|
||||
// User password verify class (Stored in usermeta for verifying password)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'users',
|
||||
'to_fieldname' => '_bbp_class',
|
||||
'default' => 'Phorum'
|
||||
);
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User nice name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'display_name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_nicename'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'email',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'date_added',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// User display name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'real_name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'display_name'
|
||||
);
|
||||
|
||||
// Store Signature (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'signature',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_phorum_user_sig',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass( $field, $row ) {
|
||||
$pass_array = array( 'hash' => $field, 'salt' => $row['salt'] );
|
||||
return $pass_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*/
|
||||
public function authenticate_pass( $password, $serialized_pass ) {
|
||||
$pass_array = unserialize( $serialized_pass );
|
||||
return ( $pass_array['hash'] == md5( md5( $password ). $pass_array['salt'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the forum type from Phorum v5.2.19 numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status Phorum v5.2.19 numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_forum_type( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'category';
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'forum';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the post status from Phorum v5.2.19 numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status Phorum v5.2.19 numeric topic status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'publish';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the topic/reply count.
|
||||
*
|
||||
* @param int $count Phorum v5.2.19 topic/reply counts
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_reply_count( $count = 1 ) {
|
||||
$count = absint( (int) $count - 1 );
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
737
wp-content/plugins/bbpress/includes/admin/converters/PunBB.php
Normal file
737
wp-content/plugins/bbpress/includes/admin/converters/PunBB.php
Normal file
@@ -0,0 +1,737 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress PunBB Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of PunBB v1.4.2 Forum converter.
|
||||
*
|
||||
* @since 2.5.0 bbPress (r5153)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/punbb
|
||||
*/
|
||||
class PunBB extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main Constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
/** Forum Section *****************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'num_topics',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_topic_count'
|
||||
);
|
||||
|
||||
// Forum reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'num_posts',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_reply_count'
|
||||
);
|
||||
|
||||
// Forum total topic count (Includes unpublished topics, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'num_topics',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_topic_count'
|
||||
);
|
||||
|
||||
// Forum total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'num_posts',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_reply_count'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'forum_name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'forum_name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'forum_desc',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'disp_position',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Set a default value 'forum', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'default' => 'forum'
|
||||
);
|
||||
|
||||
// Forum status (Set a default value 'open', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'default' => 'open'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
/** Forum Subscriptions Section ***************************************/
|
||||
|
||||
// Subscribed forum ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_subscriptions',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'forum_subscriptions',
|
||||
'to_fieldname' => '_bbp_forum_subscriptions'
|
||||
);
|
||||
|
||||
// Subscribed user ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_subscriptions',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'forum_subscriptions',
|
||||
'to_fieldname' => 'user_id',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
/** Topic Section *****************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'num_replies',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'num_replies',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_total_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
// Note: We join the 'posts' table because 'topics' table does not have user id's.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'poster_id',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON topics.first_post_id = posts.id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic author name (Stored in postmeta as _bbp_anonymous_name)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'poster',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_author_name_id'
|
||||
);
|
||||
|
||||
// Is the topic anonymous (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'poster_id',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON topics.first_post_id = posts.id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_is_topic_anonymous_id',
|
||||
'callback_method' => 'callback_check_anonymous'
|
||||
);
|
||||
|
||||
// Topic Author ip (Stored in postmeta)
|
||||
// Note: We join the 'posts' table because 'topics' table does not have author ip.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'poster_ip',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON topics.first_post_id = posts.id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
// Note: We join the 'posts' table because 'topics' table does not have content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'message',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON topics.first_post_id = posts.id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'subject',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'subject',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic status (Open or Closed, PunBB v1.4.2 0=open & 1=closed)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'closed',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_topic_status'
|
||||
);
|
||||
|
||||
// Sticky status (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'sticky',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_sticky_status_id',
|
||||
'callback_method' => 'callback_sticky_status'
|
||||
);
|
||||
// Topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'posted',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'posted',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'last_post',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'last_post',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'last_post',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
/**
|
||||
* PunBB v1.4.2 Forums do not support topic tags out of the box
|
||||
*/
|
||||
|
||||
/** Topic Subscriptions Section ***************************************/
|
||||
|
||||
// Subscribed topic ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'subscriptions',
|
||||
'from_fieldname' => 'topic_id',
|
||||
'to_type' => 'topic_subscriptions',
|
||||
'to_fieldname' => '_bbp_subscriptions'
|
||||
);
|
||||
|
||||
// Subscribed user ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'subscriptions',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'topic_subscriptions',
|
||||
'to_fieldname' => 'user_id',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
/** Reply Section *****************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
// Note: We join the 'topics' table because 'posts' table does not have parent forum id's.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'join_tablename' => 'posts',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON topics.id = posts.topic_id WHERE topics.first_post_id != posts.id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_topicid_to_forumid'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'topic_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'poster_ip',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'poster_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply author name (Stored in postmeta as _bbp_anonymous_name)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'poster',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_author_name_id'
|
||||
);
|
||||
|
||||
// Is the reply anonymous (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'poster_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_is_reply_anonymous_id',
|
||||
'callback_method' => 'callback_check_anonymous'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'message',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'topic_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'posted',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'posted',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'edited',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'edited',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
// Don't import user id 1, this is PunBB's guest user
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'id',
|
||||
'from_expression' => 'WHERE id != 1',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old user password (Stored in usermeta serialized with salt)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'password',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password',
|
||||
'callback_method' => 'callback_savepass'
|
||||
);
|
||||
|
||||
// Store old user salt (This is only used for the SELECT row info for the above password save)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'salt',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => ''
|
||||
);
|
||||
|
||||
// User password verify class (Stored in usermeta for verifying password)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'users',
|
||||
'to_fieldname' => '_bbp_class',
|
||||
'default' => 'PunBB'
|
||||
);
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User nice name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_nicename'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'email',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User homepage.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'url',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_url'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'registered',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// User display name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'realname',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'display_name'
|
||||
);
|
||||
|
||||
// User AIM (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'aim',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_punbb_user_aim'
|
||||
);
|
||||
|
||||
// User Yahoo (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'yahoo',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_punbb_user_yim'
|
||||
);
|
||||
|
||||
// Store Jabber
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'jabber',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_punbb_user_jabber'
|
||||
);
|
||||
|
||||
// Store ICQ (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'icq',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_punbb_user_icq'
|
||||
);
|
||||
|
||||
// Store MSN (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'msn',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_punbb_user_msn'
|
||||
);
|
||||
|
||||
// Store Facebook (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'facebook',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_punbb_user_facebook'
|
||||
);
|
||||
|
||||
// Store Twitter (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'twitter',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_punbb_user_twitter'
|
||||
);
|
||||
|
||||
// Store LinkedIn (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'linkedin',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_punbb_user_linkedin'
|
||||
);
|
||||
|
||||
// Store Skype (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'skype',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_punbb_user_skype'
|
||||
);
|
||||
|
||||
// Store Signature (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'signature',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_punbb_user_sig',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Store Location (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'location',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_punbb_user_from'
|
||||
);
|
||||
|
||||
// Store Admin Note (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'admin_note',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_punbb_user_admin_note'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass( $field, $row ) {
|
||||
$pass_array = array( 'hash' => $field, 'salt' => $row['salt'] );
|
||||
return $pass_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*/
|
||||
public function authenticate_pass( $password, $serialized_pass ) {
|
||||
$pass_array = unserialize( $serialized_pass );
|
||||
return ( $pass_array['hash'] == md5( md5( $password ). $pass_array['salt'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the post status from PunBB v1.4.2 numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status PunBB v1.4.2 numeric topic status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'publish';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the topic sticky status type from PunBB v1.4.2 numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status PunBB v1.4.2 numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_sticky_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'sticky'; // PunBB Sticky 'topic_sticky = 1'
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'normal'; // PunBB Normal Topic 'topic_sticky = 0'
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the topic/reply count.
|
||||
*
|
||||
* @param int $count PunBB v1.4.2 topic/reply counts
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_reply_count( $count = 1 ) {
|
||||
$count = absint( (int) $count - 1 );
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
812
wp-content/plugins/bbpress/includes/admin/converters/SMF.php
Normal file
812
wp-content/plugins/bbpress/includes/admin/converters/SMF.php
Normal file
@@ -0,0 +1,812 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress SMF Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of SMF Forum converter.
|
||||
*
|
||||
* @since 2.5.0 bbPress (r5189)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/smf
|
||||
*/
|
||||
class SMF extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main Constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
// Setup smiley URL & path
|
||||
$this->bbcode_parser_properties = array(
|
||||
'smiley_url' => false,
|
||||
'smiley_dir' => false
|
||||
);
|
||||
|
||||
/** Forum Section ******************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'boards',
|
||||
'from_fieldname' => 'id_board',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum parent id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'boards',
|
||||
'from_fieldname' => 'id_parent',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_parent_id'
|
||||
);
|
||||
|
||||
// Forum topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'boards',
|
||||
'from_fieldname' => 'num_topics',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_topic_count'
|
||||
);
|
||||
|
||||
// Forum reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'boards',
|
||||
'from_fieldname' => 'num_posts',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_reply_count'
|
||||
);
|
||||
|
||||
// Forum total topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'boards',
|
||||
'from_fieldname' => 'num_topics',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_topic_count'
|
||||
);
|
||||
|
||||
// Forum total reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'boards',
|
||||
'from_fieldname' => 'num_posts',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_reply_count'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'boards',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'boards',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'boards',
|
||||
'from_fieldname' => 'description',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'boards',
|
||||
'from_fieldname' => 'board_order',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Set a default value 'forum', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'default' => 'forum'
|
||||
);
|
||||
|
||||
// Forum status (Set a default value 'open', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'default' => 'open'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
/** Forum Subscriptions Section ***************************************/
|
||||
|
||||
// Subscribed forum ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'log_notify',
|
||||
'from_fieldname' => 'id_board',
|
||||
'from_expression' => 'WHERE log_notify.id_board != 0',
|
||||
'to_type' => 'forum_subscriptions',
|
||||
'to_fieldname' => '_bbp_forum_subscriptions'
|
||||
);
|
||||
|
||||
// Subscribed user ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'log_notify',
|
||||
'from_fieldname' => 'id_member',
|
||||
'from_expression' => 'WHERE log_notify.id_board != 0',
|
||||
'to_type' => 'forum_subscriptions',
|
||||
'to_fieldname' => 'user_id',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
/** Topic Section ******************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'id_topic',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'num_replies',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'num_replies',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_total_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'id_board',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'id_member_started',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic author name (Stored in postmeta as _bbp_anonymous_name)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'poster_name',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON topics.id_first_msg = messages.id_msg',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_author_name_id'
|
||||
);
|
||||
|
||||
// Is the topic anonymous (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'id_member_started',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_is_topic_anonymous_id',
|
||||
'callback_method' => 'callback_check_anonymous'
|
||||
);
|
||||
|
||||
// Topic Author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'poster_ip',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON topics.id_first_msg = messages.id_msg',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
// Note: We join the 'messages' table because 'topics' table does not have content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'body',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON topics.id_first_msg = messages.id_msg',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'subject',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON topics.id_first_msg = messages.id_msg',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'subject',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON topics.id_first_msg = messages.id_msg',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'id_board',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic status (Open or Closed, SMF v2.0.4 0=open & 1=closed)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'locked',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_topic_status'
|
||||
);
|
||||
|
||||
// Sticky status (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'is_sticky',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_sticky_status_id',
|
||||
'callback_method' => 'callback_sticky_status'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'poster_time',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON topics.id_first_msg = messages.id_msg',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'poster_time',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON topics.id_first_msg = messages.id_msg',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'poster_time',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON topics.id_first_msg = messages.id_msg',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'poster_time',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON topics.id_first_msg = messages.id_msg',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'poster_time',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON topics.id_first_msg = messages.id_msg',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
/**
|
||||
* SMF v2.0.4 Forums do not support topic tags out of the box
|
||||
*/
|
||||
|
||||
/** Topic Subscriptions Section ***************************************/
|
||||
|
||||
// Subscribed topic ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'log_notify',
|
||||
'from_fieldname' => 'id_topic',
|
||||
'from_expression' => 'WHERE log_notify.id_topic != 0',
|
||||
'to_type' => 'topic_subscriptions',
|
||||
'to_fieldname' => '_bbp_subscriptions'
|
||||
);
|
||||
|
||||
// Subscribed user ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'log_notify',
|
||||
'from_fieldname' => 'id_member',
|
||||
'from_expression' => 'WHERE log_notify.id_topic != 0',
|
||||
'to_type' => 'topic_subscriptions',
|
||||
'to_fieldname' => 'user_id',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
/** Reply Section *****************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'id_msg',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'id_board',
|
||||
'join_tablename' => 'messages',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'USING (id_topic) WHERE topics.id_first_msg != messages.id_msg',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_topicid_to_forumid'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'id_topic',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'poster_ip',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'id_member',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply author name (Stored in postmeta as _bbp_anonymous_name)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'poster_name',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_author_name_id'
|
||||
);
|
||||
|
||||
// Is the reply anonymous (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'id_member',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_is_reply_anonymous_id',
|
||||
'callback_method' => 'callback_check_anonymous'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'body',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'id_topic',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'poster_time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'poster_time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'poster_time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'messages',
|
||||
'from_fieldname' => 'poster_time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'id_member',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old user password (Stored in usermeta serialized with salt)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'passwd',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password',
|
||||
'callback_method' => 'callback_savepass'
|
||||
);
|
||||
|
||||
// User password verify class (Stored in usermeta for verifying password)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_class',
|
||||
'default' => 'SMF'
|
||||
);
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'member_name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User nice name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'member_name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_nicename'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'email_address',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User homepage.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'website_url',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_url'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'date_registered',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// User display name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'real_name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'display_name'
|
||||
);
|
||||
|
||||
// User AIM (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'aim',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_smf_user_aim'
|
||||
);
|
||||
|
||||
// User Yahoo (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'yim',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_smf_user_yim'
|
||||
);
|
||||
|
||||
// Store ICQ (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'icq',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_smf_user_icq'
|
||||
);
|
||||
|
||||
// Store MSN (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'msn',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_smf_user_msn'
|
||||
);
|
||||
|
||||
// Store Signature (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'signature',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_smf_user_sig',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Store Avatar (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'avatar',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_smf_user_avatar',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Store Location (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'location',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_smf_user_location',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Store Personal Text (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'personal_text',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_smf_user_personal_text',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass( $field, $row ) {
|
||||
$pass_array = array( 'hash' => $field, 'username' => $row['member_name'] );
|
||||
return $pass_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*/
|
||||
public function authenticate_pass( $password, $serialized_pass ) {
|
||||
$pass_array = unserialize( $serialized_pass );
|
||||
return ( $pass_array['hash'] === sha1( strtolower( $pass_array['username'] ) . $password ) ? true : false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the post status from SMF v2.0.4 numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status SMF v2.0.4 numeric topic status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'publish';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the topic sticky status type from SMF v2.0.4 numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status SMF v2.0.4 numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_sticky_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'sticky'; // SMF Sticky 'is_sticky = 1'
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'normal'; // SMF normal topic 'is_sticky = 0'
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the topic/reply count.
|
||||
*
|
||||
* @param int $count SMF v2.0.4 topic/reply counts
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_reply_count( $count = 1 ) {
|
||||
$count = absint( (int) $count - 1 );
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* This callback processes any custom parser.php attributes and custom code with preg_replace
|
||||
*/
|
||||
protected function callback_html( $field ) {
|
||||
|
||||
// Strips SMF custom HTML first from $field before parsing $field to parser.php
|
||||
$SMF_markup = $field;
|
||||
$SMF_markup = html_entity_decode( $SMF_markup );
|
||||
|
||||
// Replace '[quote]' with '<blockquote>'
|
||||
$SMF_markup = preg_replace( '/\[quote\]/', '<blockquote>', $SMF_markup );
|
||||
// Replace '[quote ($1)]' with '<blockquote>"
|
||||
$SMF_markup = preg_replace( '/\[quote (.*?)\]/' , '<blockquote>', $SMF_markup );
|
||||
// Replace '[/quote]' with '</blockquote>'
|
||||
$SMF_markup = preg_replace( '/\[\/quote\]/', '</blockquote>', $SMF_markup );
|
||||
|
||||
// Replace '[glow]' with ''
|
||||
$SMF_markup = preg_replace( '/\[glow\]/', '', $SMF_markup );
|
||||
// Replace '[glow]' with ''
|
||||
$SMF_markup = preg_replace( '/\[glow=(.*?)\]/', '', $SMF_markup );
|
||||
// Replace '[/glow]' with ''
|
||||
$SMF_markup = preg_replace( '/\[\/glow\]/', '', $SMF_markup );
|
||||
|
||||
// Replace '[shadow]' with ''
|
||||
$SMF_markup = preg_replace( '/\[shadow\]/', '', $SMF_markup );
|
||||
// Replace '[shadow]' with ''
|
||||
$SMF_markup = preg_replace( '/\[shadow=(.*?)\]/', '', $SMF_markup );
|
||||
// Replace '[/shadow]' with ''
|
||||
$SMF_markup = preg_replace( '/\[\/shadow\]/', '', $SMF_markup );
|
||||
|
||||
// Replace '[move]' with ''
|
||||
$SMF_markup = preg_replace( '/\[move\]/', '', $SMF_markup );
|
||||
// Replace '[/move]' with ''
|
||||
$SMF_markup = preg_replace( '/\[\/move\]/', '', $SMF_markup );
|
||||
|
||||
// Replace '[table]' with '<table>'
|
||||
$SMF_markup = preg_replace( '/\[table\]/', '<table>', $SMF_markup );
|
||||
// Replace '[/table]' with '</table>'
|
||||
$SMF_markup = preg_replace( '/\[\/table\]/', '</table>', $SMF_markup );
|
||||
// Replace '[tr]' with '<tr>'
|
||||
$SMF_markup = preg_replace( '/\[tr\]/', '<tr>', $SMF_markup );
|
||||
// Replace '[/tr]' with '</tr>'
|
||||
$SMF_markup = preg_replace( '/\[\/tr\]/', '</tr>', $SMF_markup );
|
||||
// Replace '[td]' with '<td>'
|
||||
$SMF_markup = preg_replace( '/\[td\]/', '<td>', $SMF_markup );
|
||||
// Replace '[/td]' with '</td>'
|
||||
$SMF_markup = preg_replace( '/\[\/td\]/', '</td>', $SMF_markup );
|
||||
|
||||
// Replace '[list]' with '<ul>'
|
||||
$SMF_markup = preg_replace( '/\[list\]/', '<ul>', $SMF_markup );
|
||||
// Replace '[liist type=decimal]' with '<ol type="a">'
|
||||
$SMF_markup = preg_replace( '/\[list\ type=decimal\]/', '<ol type="a">', $SMF_markup );
|
||||
// Replace '[li]' with '<li>'
|
||||
$SMF_markup = preg_replace( '/\[li\]/', '<li>', $SMF_markup );
|
||||
// Replace '[/li]' with '</li>'
|
||||
$SMF_markup = preg_replace( '/\[\/li\]/', '</li>', $SMF_markup );
|
||||
|
||||
// Replace '[tt]' with '<tt>'
|
||||
$SMF_markup = preg_replace( '/\[tt\]/', '<tt>', $SMF_markup );
|
||||
// Replace '[/tt]' with '</tt>'
|
||||
$SMF_markup = preg_replace( '/\[\/tt\]/', '</tt>', $SMF_markup );
|
||||
|
||||
// Replace '<br />' with '<br>'
|
||||
$SMF_markup = preg_replace( '/\<br \/\>/', '<br>', $SMF_markup );
|
||||
|
||||
// Replace '[size=$1]' with '<span style="font-size:$1%;">$3</span>'
|
||||
$SMF_markup = preg_replace( '/\[size=(.*?)\]/', '<span style="font-size:$1">', $SMF_markup );
|
||||
// Replace '[/size]' with '</span>'
|
||||
$SMF_markup = preg_replace( '/\[\/size\]/', '</span>', $SMF_markup );
|
||||
|
||||
// Replace non-break space ' ' with space ' '
|
||||
$SMF_markup = preg_replace( '/ /', ' ', $SMF_markup );
|
||||
|
||||
// Now that SMF custom HTML has been stripped put the cleaned HTML back in $field
|
||||
$field = $SMF_markup;
|
||||
|
||||
// Parse out any bbCodes in $field with the BBCode 'parser.php'
|
||||
return parent::callback_html( $field );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,616 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress SimplePress5 Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of SimplePress v5 converter.
|
||||
*
|
||||
* @since 2.3.0 bbPress (r4638)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/simplepress/
|
||||
*/
|
||||
class SimplePress5 extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main Constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
// Setup smiley URL & path
|
||||
$this->bbcode_parser_properties = array(
|
||||
'smiley_url' => false,
|
||||
'smiley_dir' => false
|
||||
);
|
||||
|
||||
/** Forum Section *****************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfforums',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum parent id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfforums',
|
||||
'from_fieldname' => 'parent',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_parent_id'
|
||||
);
|
||||
|
||||
// Forum topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfforums',
|
||||
'from_fieldname' => 'topic_count',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_topic_count'
|
||||
);
|
||||
|
||||
// Forum reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfforums',
|
||||
'from_fieldname' => 'post_count',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_reply_count'
|
||||
);
|
||||
|
||||
// Forum total topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfforums',
|
||||
'from_fieldname' => 'topic_count',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_topic_count'
|
||||
);
|
||||
|
||||
// Forum total reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfforums',
|
||||
'from_fieldname' => 'post_count',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_reply_count'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfforums',
|
||||
'from_fieldname' => 'forum_name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfforums',
|
||||
'from_fieldname' => 'forum_name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfforums',
|
||||
'from_fieldname' => 'forum_desc',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfforums',
|
||||
'from_fieldname' => 'forum_seq',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Set a default value 'forum', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'default' => 'forum'
|
||||
);
|
||||
|
||||
// Forum status (Set a default value 'open', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'default' => 'open'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forums',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forums',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forums',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forums',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
/** Topic Section *****************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sftopics',
|
||||
'from_fieldname' => 'topic_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sftopics',
|
||||
'from_fieldname' => 'post_count',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sftopics',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sftopics',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfposts',
|
||||
'from_fieldname' => 'poster_ip',
|
||||
'join_tablename' => 'sftopics',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (topic_id) WHERE sfposts.post_index = 1',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Topic author name (Stored in postmeta as _bbp_anonymous_name)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfposts',
|
||||
'from_fieldname' => 'guest_name',
|
||||
'join_tablename' => 'sftopics',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (topic_id) WHERE sfposts.post_index = 1',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_author_name_id'
|
||||
);
|
||||
|
||||
// Is the topic anonymous (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sftopics',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_is_topic_anonymous_id',
|
||||
'callback_method' => 'callback_check_anonymous'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
// Note: We join the sfposts table because sftopics do not have content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfposts',
|
||||
'from_fieldname' => 'post_content',
|
||||
'join_tablename' => 'sftopics',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (topic_id) WHERE sfposts.post_index = 1',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sftopics',
|
||||
'from_fieldname' => 'topic_name',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sftopics',
|
||||
'from_fieldname' => 'topic_name',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sftopics',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic status (Open or Closed)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sftopics',
|
||||
'from_fieldname' => 'topic_status',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_status'
|
||||
);
|
||||
|
||||
// Sticky status (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sftopics',
|
||||
'from_fieldname' => 'topic_pinned',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_sticky_status_id',
|
||||
'callback_method' => 'callback_sticky_status'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sftopics',
|
||||
'from_fieldname' => 'topic_date',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sftopics',
|
||||
'from_fieldname' => 'topic_date',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sftopics',
|
||||
'from_fieldname' => 'topic_date',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sftopics',
|
||||
'from_fieldname' => 'topic_date',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sftopics',
|
||||
'from_fieldname' => 'topic_date',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
/**
|
||||
* SimplePress Forums do not support topic tags without paid extensions
|
||||
*/
|
||||
|
||||
/** Reply Section *****************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfposts',
|
||||
'from_fieldname' => 'post_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfposts',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'from_expression' => 'WHERE post_index != 1',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfposts',
|
||||
'from_fieldname' => 'topic_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfposts',
|
||||
'from_fieldname' => 'poster_ip',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfposts',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply author name (Stored in postmeta as _bbp_anonymous_name)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfposts',
|
||||
'from_fieldname' => 'guest_name',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_author_name_id'
|
||||
);
|
||||
|
||||
// Is the reply anonymous (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfposts',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_is_reply_anonymous_id',
|
||||
'callback_method' => 'callback_check_anonymous'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfposts',
|
||||
'from_fieldname' => 'post_content',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfposts',
|
||||
'from_fieldname' => 'topic_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfposts',
|
||||
'from_fieldname' => 'post_date',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfposts',
|
||||
'from_fieldname' => 'post_date',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfposts',
|
||||
'from_fieldname' => 'post_date',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'sfposts',
|
||||
'from_fieldname' => 'post_date',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'ID',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old user password (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_pass',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password'
|
||||
);
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_login',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User nice name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_nicename',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_nicename'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_email',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User homepage.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_url',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_url'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_registered',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered'
|
||||
);
|
||||
|
||||
// User status.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_status',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_status'
|
||||
);
|
||||
|
||||
// User display name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'display_name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'display_name'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass( $field, $row ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*/
|
||||
public function authenticate_pass( $password, $serialized_pass ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the post status from Simple:Press v5.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status Simple:Press numeric status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'publish';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the topic sticky status type from Simple:Press v5.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status Simple:Press v5.x numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_sticky_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'sticky'; // Simple:Press Sticky 'topic_sticky = 1'
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'normal'; // Simple:Press Normal Topic 'topic_sticky = 0'
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the topic reply count.
|
||||
*
|
||||
* @param int $count Simple:Press v5.x reply count
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_reply_count( $count = 1 ) {
|
||||
$count = absint( (int) $count - 1 );
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* This callback processes any custom parser.php attributes and custom HTML code with preg_replace
|
||||
*/
|
||||
protected function callback_html( $field ) {
|
||||
|
||||
// Strip any custom HTML not supported by parser.php first from $field before parsing $field to parser.php
|
||||
$simplepress_markup = $field;
|
||||
$simplepress_markup = html_entity_decode( $simplepress_markup );
|
||||
|
||||
// Replace any SimplePress smilies from path '/sp-resources/forum-smileys/sf-smily.gif' with the equivelant WordPress Smilie
|
||||
$simplepress_markup = preg_replace( '/\<img src=(.*?)\/sp-resources\/forum-smileys\/sf-confused\.gif(.*?)\" \/>/', ':?' , $simplepress_markup );
|
||||
$simplepress_markup = preg_replace( '/\<img src=(.*?)\/sp-resources\/forum-smileys\/sf-cool\.gif(.*?)\" \/>/', ':cool:', $simplepress_markup );
|
||||
$simplepress_markup = preg_replace( '/\<img src=(.*?)\/sp-resources\/forum-smileys\/sf-cry\.gif(.*?)\" \/>/', ':cry:', $simplepress_markup );
|
||||
$simplepress_markup = preg_replace( '/\<img src=(.*?)\/sp-resources\/forum-smileys\/sf-embarassed\.gif(.*?)\" \/>/' , ':oops:', $simplepress_markup );
|
||||
$simplepress_markup = preg_replace( '/\<img src=(.*?)\/sp-resources\/forum-smileys\/sf-frown\.gif(.*?)\" \/>/', ':(', $simplepress_markup );
|
||||
$simplepress_markup = preg_replace( '/\<img src=(.*?)\/sp-resources\/forum-smileys\/sf-kiss\.gif(.*?)\" \/>/', ':P', $simplepress_markup );
|
||||
$simplepress_markup = preg_replace( '/\<img src=(.*?)\/sp-resources\/forum-smileys\/sf-laugh\.gif(.*?)\" \/>/', ':D', $simplepress_markup );
|
||||
$simplepress_markup = preg_replace( '/\<img src=(.*?)\/sp-resources\/forum-smileys\/sf-smile\.gif(.*?)\" \/>/', ':smile:', $simplepress_markup );
|
||||
$simplepress_markup = preg_replace( '/\<img src=(.*?)\/sp-resources\/forum-smileys\/sf-surprised\.gif(.*?)\" \/>/', ':o', $simplepress_markup );
|
||||
$simplepress_markup = preg_replace( '/\<img src=(.*?)\/sp-resources\/forum-smileys\/sf-wink\.gif(.*?)\" \/>/', ':wink:', $simplepress_markup );
|
||||
$simplepress_markup = preg_replace( '/\<img src=(.*?)\/sp-resources\/forum-smileys\/sf-yell\.gif(.*?)\" \/>/', ':x', $simplepress_markup );
|
||||
|
||||
// Replace '<div class="sfcode">example code</div>' with '<code>*</code>'
|
||||
$simplepress_markup = preg_replace( '/\<div class\=\"sfcode\"\>(.*?)\<\/div\>/' , '<code>$1</code>' , $simplepress_markup );
|
||||
|
||||
// Replace '<strong>username said </strong>' with '@username said:'
|
||||
$simplepress_markup = preg_replace( '/\<strong\>(.*?)\ said\ \<\/strong\>/', '@$1 said:', $simplepress_markup );
|
||||
|
||||
// Replace '<p> </p>' with '<p> </p>'
|
||||
$simplepress_markup = preg_replace( '/\n( |[\s\p{Z}\xA0\x{00A0}]+)\r/', '<br>', $simplepress_markup );
|
||||
|
||||
// Now that SimplePress' custom HTML codes have been stripped put the cleaned HTML back in $field
|
||||
$field = $simplepress_markup;
|
||||
|
||||
// Parse out any bbCodes in $field with the BBCode 'parser.php'
|
||||
return parent::callback_html( $field );
|
||||
}
|
||||
}
|
||||
608
wp-content/plugins/bbpress/includes/admin/converters/Vanilla.php
Normal file
608
wp-content/plugins/bbpress/includes/admin/converters/Vanilla.php
Normal file
@@ -0,0 +1,608 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress Vanilla Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of Vanilla 2.0.18.1 Converter
|
||||
*
|
||||
* @since 2.3.0 bbPress (r4717)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/vanilla
|
||||
*/
|
||||
class Vanilla extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main Constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
// Setup smiley URL & path
|
||||
$this->bbcode_parser_properties = array(
|
||||
'smiley_url' => false,
|
||||
'smiley_dir' => false
|
||||
);
|
||||
|
||||
/** Forum Section *****************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Category',
|
||||
'from_fieldname' => 'CategoryID',
|
||||
'from_expression' => 'WHERE Category.CategoryID > 0',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum parent id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Category',
|
||||
'from_fieldname' => 'ParentCategoryID',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_parent_id',
|
||||
'callback_method' => 'callback_forum_parent'
|
||||
);
|
||||
|
||||
// Forum topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Category',
|
||||
'from_fieldname' => 'CountDiscussions',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_topic_count'
|
||||
);
|
||||
|
||||
// Forum reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Category',
|
||||
'from_fieldname' => 'CountComments',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_reply_count'
|
||||
);
|
||||
|
||||
// Forum total topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Category',
|
||||
'from_fieldname' => 'CountDiscussions',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_topic_count'
|
||||
);
|
||||
|
||||
// Forum total reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Category',
|
||||
'from_fieldname' => 'CountComments',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_reply_count'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Category',
|
||||
'from_fieldname' => 'Name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid confilcts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Category',
|
||||
'from_fieldname' => 'Name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Category',
|
||||
'from_fieldname' => 'Description',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Category',
|
||||
'from_fieldname' => 'Sort',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Set a default value 'forum', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'default' => 'forum'
|
||||
);
|
||||
|
||||
// Forum status (Set a default value 'open', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'default' => 'open'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Category',
|
||||
'from_fieldname' => 'DateInserted',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Category',
|
||||
'from_fieldname' => 'DateInserted',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Category',
|
||||
'from_fieldname' => 'DateUpdated',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Category',
|
||||
'from_fieldname' => 'DateUpdated',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
);
|
||||
|
||||
/** Topic Section *****************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
// Don't import Vanilla 2's deleted topics
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Discussion',
|
||||
'from_fieldname' => 'DiscussionID',
|
||||
'from_expression' => 'WHERE Format != "Deleted"',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Discussion',
|
||||
'from_fieldname' => 'CountComments',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Discussion',
|
||||
'from_fieldname' => 'CountComments',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_total_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Discussion',
|
||||
'from_fieldname' => 'CategoryID',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Discussion',
|
||||
'from_fieldname' => 'InsertUserID',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic author name (Stored in postmeta as _bbp_anonymous_name)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_author_name_id',
|
||||
'default' => 'Anonymous'
|
||||
);
|
||||
|
||||
// Is the topic anonymous (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Discussion',
|
||||
'from_fieldname' => 'InsertUserID',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_is_topic_anonymous_id',
|
||||
'callback_method' => 'callback_check_anonymous'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Discussion',
|
||||
'from_fieldname' => 'Name',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Discussion',
|
||||
'from_fieldname' => 'Name',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Discussion',
|
||||
'from_fieldname' => 'Body',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic status (Open or Closed)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Discussion',
|
||||
'from_fieldname' => 'closed',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_topic_status'
|
||||
);
|
||||
|
||||
// Topic author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Discussion',
|
||||
'from_fieldname' => 'InsertIPAddress',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Discussion',
|
||||
'from_fieldname' => 'CategoryID',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Sticky status (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Discussion',
|
||||
'from_fieldname' => 'Announce',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_sticky_status_id',
|
||||
'callback_method' => 'callback_sticky_status'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Discussion',
|
||||
'from_fieldname' => 'DateInserted',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Discussion',
|
||||
'from_fieldname' => 'DateInserted',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Discussion',
|
||||
'from_fieldname' => 'DateUpdated',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Discussion',
|
||||
'from_fieldname' => 'DateUpdated',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Discussion',
|
||||
'from_fieldname' => 'DateLastComment',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
// Topic id.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'TagDiscussion',
|
||||
'from_fieldname' => 'DiscussionID',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'objectid',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Taxonomy ID.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'TagDiscussion',
|
||||
'from_fieldname' => 'TagID',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'taxonomy'
|
||||
);
|
||||
|
||||
// Term text.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Tag',
|
||||
'from_fieldname' => 'Name',
|
||||
'join_tablename' => 'TagDiscussion',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (tagid)',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'name'
|
||||
);
|
||||
|
||||
/** Reply Section *****************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
// Don't import Vanilla 2's deleted replies
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Comment',
|
||||
'from_fieldname' => 'CommentID',
|
||||
'from_expression' => 'WHERE Format != "Deleted"',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Comment',
|
||||
'from_fieldname' => 'DiscussionID',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Comment',
|
||||
'from_fieldname' => 'DiscussionID',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_topicid_to_forumid'
|
||||
);
|
||||
|
||||
// Reply author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Comment',
|
||||
'from_fieldname' => 'InsertIPAddress',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Comment',
|
||||
'from_fieldname' => 'InsertUserID',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply author name (Stored in postmeta as _bbp_anonymous_name)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_author_name_id',
|
||||
'default' => 'Anonymous'
|
||||
);
|
||||
|
||||
// Is the reply anonymous (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Comment',
|
||||
'from_fieldname' => 'InsertUserID',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_is_reply_anonymous_id',
|
||||
'callback_method' => 'callback_check_anonymous'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Comment',
|
||||
'from_fieldname' => 'Body',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Comment',
|
||||
'from_fieldname' => 'DiscussionID',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Comment',
|
||||
'from_fieldname' => 'DateInserted',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Comment',
|
||||
'from_fieldname' => 'DateInserted',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Comment',
|
||||
'from_fieldname' => 'DateUpdated',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'Comment',
|
||||
'from_fieldname' => 'DateUpdated',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
// Don't import user Vanilla's deleted users
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'User',
|
||||
'from_fieldname' => 'UserID',
|
||||
'from_expression' => 'WHERE Deleted !=1',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old user password (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'User',
|
||||
'from_fieldname' => 'Password',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password'
|
||||
);
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'User',
|
||||
'from_fieldname' => 'Name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User nice name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'User',
|
||||
'from_fieldname' => 'Name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_nicename'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'User',
|
||||
'from_fieldname' => 'Email',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'User',
|
||||
'from_fieldname' => 'DateInserted',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered'
|
||||
);
|
||||
|
||||
// Display Name
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'User',
|
||||
'from_fieldname' => 'Name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'display_name'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the topic status from Vanilla v2.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status Vanilla v2.x numeric topic status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'publish';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the topic sticky status type from Vanilla v2.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status Vanilla v2.x numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_sticky_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'sticky'; // Vanilla Sticky 'Announce = 1'
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'normal'; // Vanilla normal topic 'Announce = 0'
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean Root Parent ID -1 to 0
|
||||
*
|
||||
* @param int $parent Vanilla v2.x Parent ID
|
||||
* @return int
|
||||
*/
|
||||
public function callback_forum_parent( $parent = 0 ) {
|
||||
if ( $parent == -1 ) {
|
||||
return 0;
|
||||
} else {
|
||||
return $parent;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the topic reply count.
|
||||
*
|
||||
* @param int $count Vanilla v2.x reply count
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_reply_count( $count = 1 ) {
|
||||
$count = absint( (int) $count - 1 );
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass( $field, $row ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*/
|
||||
public function authenticate_pass( $password, $serialized_pass ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
721
wp-content/plugins/bbpress/includes/admin/converters/XMB.php
Normal file
721
wp-content/plugins/bbpress/includes/admin/converters/XMB.php
Normal file
@@ -0,0 +1,721 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress XMB Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of XMB Forum converter.
|
||||
*
|
||||
* @since 2.5.0 bbPress (r5143)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/xmb
|
||||
*/
|
||||
class XMB extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main Constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
/** Forum Section *****************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'fid',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum parent id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'fup',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_parent_id'
|
||||
);
|
||||
|
||||
// Forum topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'threads',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_topic_count'
|
||||
);
|
||||
|
||||
// Forum reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'posts',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_reply_count'
|
||||
);
|
||||
|
||||
// Forum total topic count (Includes unpublished topics, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'threads',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_topic_count'
|
||||
);
|
||||
|
||||
// Forum total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'posts',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_reply_count'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'description',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'displayorder',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Category = 'group', Forum = 'forum' or 'sub', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'type',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'callback_method' => 'callback_forum_type'
|
||||
);
|
||||
|
||||
// Forum status (Set a default value 'open', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'default' => 'open'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
/** Topic Section *****************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'tid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'replies',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'replies',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_total_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'fid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
// Note: We join the 'members' table because 'threads' table does not have numerical author id.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'uid',
|
||||
'join_tablename' => 'threads',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON threads.author = members.username',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic author name (Stored in postmeta as _bbp_anonymous_name)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'author',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_author_name_id'
|
||||
);
|
||||
|
||||
// Is the topic anonymous (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'uid',
|
||||
'join_tablename' => 'threads',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON threads.author = members.username WHERE posts.subject = ""',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_is_topic_anonymous_id',
|
||||
'callback_method' => 'callback_check_anonymous'
|
||||
);
|
||||
|
||||
// Topic Author ip (Stored in postmeta)
|
||||
// Note: We join the 'posts' table because 'threads' table does not have author ip.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'useip',
|
||||
'join_tablename' => 'threads',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (tid) WHERE posts.subject != ""',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
// Note: We join the 'posts' table because 'threads' table does not have content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'message',
|
||||
'join_tablename' => 'threads',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (tid) WHERE posts.subject != ""',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'subject',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'subject',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'fid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic status (Open or Closed, XMB v1.9.11.13 ''=open & 'yes'=closed)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'closed',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_topic_status'
|
||||
);
|
||||
|
||||
// Sticky status (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'threads',
|
||||
'from_fieldname' => 'topped',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_sticky_status_id',
|
||||
'callback_method' => 'callback_sticky_status'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
// Note: We join the 'posts' table because 'threads' table does not include dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'dateline',
|
||||
'join_tablename' => 'threads',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (tid) WHERE posts.subject != ""',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'dateline',
|
||||
'join_tablename' => 'threads',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (tid) WHERE posts.subject != ""',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'dateline',
|
||||
'join_tablename' => 'threads',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (tid) WHERE posts.subject != ""',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'dateline',
|
||||
'join_tablename' => 'threads',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (tid) WHERE posts.subject != ""',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'dateline',
|
||||
'join_tablename' => 'threads',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (tid) WHERE posts.subject != ""',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
/**
|
||||
* XMB v1.9.11.13 Forums do not support topic tags out of the box
|
||||
*/
|
||||
|
||||
/** Reply Section *****************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'pid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'fid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_topicid_to_forumid'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'tid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'useip',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
// Note: We join the 'members' table because 'posts' table does not have numerical author id.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'uid',
|
||||
'join_tablename' => 'posts',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON posts.author = members.username WHERE posts.subject = ""',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply author name (Stored in postmeta as _bbp_anonymous_name)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'author',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_author_name_id'
|
||||
);
|
||||
|
||||
// Is the reply anonymous (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'uid',
|
||||
'join_tablename' => 'posts',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON posts.author = members.username WHERE posts.subject = ""',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_is_reply_anonymous_id',
|
||||
'callback_method' => 'callback_check_anonymous'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'message',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'tid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'uid',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old User password (Stored in usermeta serialized with salt)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'password',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password',
|
||||
'callback_method' => 'callback_savepass'
|
||||
);
|
||||
|
||||
// Store old User Salt (This is only used for the SELECT row info for the above password save)
|
||||
// $this->field_map[] = array(
|
||||
// 'from_tablename' => 'members',
|
||||
// 'from_fieldname' => 'salt',
|
||||
// 'to_type' => 'user',
|
||||
// 'to_fieldname' => ''
|
||||
// );
|
||||
|
||||
// User password verify class (Stored in usermeta for verifying password)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'members',
|
||||
'to_fieldname' => '_bbp_class',
|
||||
'default' => 'XMB'
|
||||
);
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User nice name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_nicename'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'email',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User homepage.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'site',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_url'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'regdate',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// User AIM (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'aim',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_xmb_user_aim'
|
||||
);
|
||||
|
||||
// User Yahoo (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'yahoo',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_xmb_user_yim'
|
||||
);
|
||||
|
||||
// Store ICQ (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'icq',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_xmb_user_icq'
|
||||
);
|
||||
|
||||
// Store MSN (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'msn',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_xmb_user_msn'
|
||||
);
|
||||
|
||||
// Store Signature (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'sig',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_xmb_user_sig',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Store Bio (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'bio',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_xmb_user_bio',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Store Location (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'location',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_xmb_user_location'
|
||||
);
|
||||
|
||||
// Store Avatar (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'avatar',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_xmb_user_avatar'
|
||||
);
|
||||
|
||||
// Store Mood (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'members',
|
||||
'from_fieldname' => 'mood',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_xmb_user_mood'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass( $field, $row ) {
|
||||
$pass_array = array( 'hash' => $field, 'salt' => $row['salt'] );
|
||||
return $pass_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*/
|
||||
public function authenticate_pass( $password, $serialized_pass ) {
|
||||
$pass_array = unserialize( $serialized_pass );
|
||||
return ( $pass_array['hash'] == md5( md5( $password ). $pass_array['salt'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the forum type from XMB v1.9.11.13 Capitalised case to WordPress's non-capatilise case strings.
|
||||
*
|
||||
* @param int $status XMB v1.9.11.13 numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_forum_type( $status = 1 ) {
|
||||
switch ( $status ) {
|
||||
case 'group' :
|
||||
$status = 'category';
|
||||
break;
|
||||
|
||||
case 'sub' :
|
||||
$status = 'forum';
|
||||
break;
|
||||
|
||||
case 'forum' :
|
||||
default :
|
||||
$status = 'forum';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the post status from XMB v1.9.11.13 numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status XMB v1.9.11.13 numeric topic status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_status( $status = '' ) {
|
||||
switch ( $status ) {
|
||||
case 'yes' :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case '' :
|
||||
default :
|
||||
$status = 'publish';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the topic sticky status type from XMB v1.9.11.13 numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status XMB v1.9.11.13 numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_sticky_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'sticky'; // XMB Sticky 'topped = 1'
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'normal'; // XMB Normal Topic 'topped = 0'
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the topic/reply count.
|
||||
*
|
||||
* @param int $count XMB v1.9.11.13 topic/reply counts
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_reply_count( $count = 1 ) {
|
||||
$count = absint( (int) $count - 1 );
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
850
wp-content/plugins/bbpress/includes/admin/converters/XenForo.php
Normal file
850
wp-content/plugins/bbpress/includes/admin/converters/XenForo.php
Normal file
@@ -0,0 +1,850 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress XenForo Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of XenForo converter.
|
||||
*
|
||||
* @since 2.5.0 bbPress (r5145)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/xenforo
|
||||
*/
|
||||
class XenForo extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
// Setup smiley URL & path
|
||||
$this->bbcode_parser_properties = array(
|
||||
'smiley_url' => false,
|
||||
'smiley_dir' => false
|
||||
);
|
||||
|
||||
/** Forum Section *****************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'node',
|
||||
'from_fieldname' => 'node_id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum parent id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'node',
|
||||
'from_fieldname' => 'parent_node_id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_parent_id'
|
||||
);
|
||||
|
||||
// Forum topic count (Stored in postmeta)
|
||||
// Note: We join the 'forum' table because 'node' does not include topic counts.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'discussion_count',
|
||||
'join_tablename' => 'node',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'USING (node_id) WHERE node.node_type_id = "Category" OR node.node_type_id = "Forum" ',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_topic_count'
|
||||
);
|
||||
|
||||
// Forum reply count (Stored in postmeta)
|
||||
// Note: We join the 'forum' table because 'node' does not include reply counts.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'message_count',
|
||||
'join_tablename' => 'node',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'USING (node_id) WHERE node.node_type_id = "Category" OR node.node_type_id = "Forum" ',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_reply_count'
|
||||
);
|
||||
|
||||
// Forum total topic count (Includes unpublished topics, Stored in postmeta)
|
||||
// Note: We join the 'forum' table because 'node' does not include topic counts.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'discussion_count',
|
||||
'join_tablename' => 'node',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'USING (node_id) WHERE node.node_type_id = "Category" OR node.node_type_id = "Forum" ',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_topic_count'
|
||||
);
|
||||
|
||||
// Forum total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
// Note: We join the 'forum' table because 'node' does not include reply counts.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'message_count',
|
||||
'join_tablename' => 'node',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'USING (node_id) WHERE node.node_type_id = "Category" OR node.node_type_id = "Forum" ',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_reply_count'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'node',
|
||||
'from_fieldname' => 'title',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid confilcts)
|
||||
// 'node_name' only has slug for explictly named forums
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'node',
|
||||
'from_fieldname' => 'node_name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'node',
|
||||
'from_fieldname' => 'description',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'node',
|
||||
'from_fieldname' => 'display_order',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Category = Category or Forum = Forum, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'node',
|
||||
'from_fieldname' => 'node_type_id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'callback_method' => 'callback_forum_type'
|
||||
);
|
||||
|
||||
// Forum status (Unlocked = 1 or Locked = 0, Stored in postmeta)
|
||||
// Note: We join the 'forum' table because 'node' does not include forum status.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'allow_posting',
|
||||
'join_tablename' => 'node',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'USING (node_id) WHERE node.node_type_id = "Category" OR node.node_type_id = "Forum" ',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'callback_method' => 'callback_forum_status'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
/** Forum Subscriptions Section ***************************************/
|
||||
|
||||
// Subscribed forum ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_watch',
|
||||
'from_fieldname' => 'node_id',
|
||||
'to_type' => 'forum_subscriptions',
|
||||
'to_fieldname' => '_bbp_forum_subscriptions'
|
||||
);
|
||||
|
||||
// Subscribed user ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_watch',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'forum_subscriptions',
|
||||
'to_fieldname' => 'user_id',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
/** Topic Section *****************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'thread_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'reply_count',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'reply_count',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_total_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'node_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic author name (Stored in postmeta as _bbp_anonymous_name)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_author_name_id'
|
||||
);
|
||||
|
||||
// Is the topic anonymous (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_is_topic_anonymous_id',
|
||||
'callback_method' => 'callback_check_anonymous'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'title',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'title',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
// Note: We join the 'post' table because 'thread' table does not include content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'message',
|
||||
'join_tablename' => 'thread',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'ON thread.first_post_id = post.post_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic status (Visible or Deleted)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'discussion_state',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_status',
|
||||
'callback_method' => 'callback_status'
|
||||
);
|
||||
|
||||
// Topic status (Open = 1 or Closed = 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'discussion_open',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_topic_status'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'node_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Sticky status (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'sticky',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_sticky_status_id',
|
||||
'callback_method' => 'callback_sticky_status'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'post_date',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'post_date',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'last_post_date',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'last_post_date',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'last_post_date',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
/**
|
||||
* XenForo Forums do not support topic tags out of the box
|
||||
*/
|
||||
|
||||
/** Topic Subscriptions Section ***************************************/
|
||||
|
||||
// Subscribed topic ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread_watch',
|
||||
'from_fieldname' => 'thread_id',
|
||||
'to_type' => 'topic_subscriptions',
|
||||
'to_fieldname' => '_bbp_subscriptions'
|
||||
);
|
||||
|
||||
// Subscribed user ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread_watch',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'topic_subscriptions',
|
||||
'to_fieldname' => 'user_id',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
/** Reply Section *****************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'post_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Join the 'thread' table to exclude topics from being imported as replies
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'thread_id',
|
||||
'join_tablename' => 'post',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'USING (thread_id) WHERE thread.first_post_id != post.post_id',
|
||||
'to_type' => 'reply'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'thread_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_topicid_to_forumid'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'thread_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply status (Visible or Deleted)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'message_state',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_status',
|
||||
'callback_method' => 'callback_status'
|
||||
);
|
||||
|
||||
// Reply author name (Stored in postmeta as _bbp_anonymous_name)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_author_name_id'
|
||||
);
|
||||
|
||||
// Is the reply anonymous (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_is_reply_anonymous_id',
|
||||
'callback_method' => 'callback_check_anonymous'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'message',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'thread_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'post_date',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'post_date',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'post_date',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'post_date',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
/* // User password.
|
||||
// Note: We join the 'user_authenticate' table because 'user' does not include password.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user_authenticate',
|
||||
'from_fieldname' => 'data',
|
||||
'join_tablename' => 'user',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'USING (user_id)',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_converter_password'
|
||||
);
|
||||
|
||||
// Store old User password (Stored in usermeta serialized with salt)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'password',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password',
|
||||
'callback_method' => 'callback_savepass'
|
||||
);
|
||||
|
||||
// Store old User Salt (This is only used for the SELECT row info for the above password save)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'salt',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => ''
|
||||
);
|
||||
*/
|
||||
// User password verify class (Stored in usermeta for verifying password)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_class',
|
||||
'default' => 'XenForo'
|
||||
);
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'email',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User homepage.
|
||||
// Note: We join the 'user_profile' table because 'user' does not include user homepage.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user_profile',
|
||||
'from_fieldname' => 'homepage',
|
||||
'join_tablename' => 'user',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'USING (user_id)',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_url'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'register_date',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// User display name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'display_name'
|
||||
);
|
||||
|
||||
// Store Custom Title (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'custom_title',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_xenforo_user_custom_title'
|
||||
);
|
||||
|
||||
// Store Status (Stored in usermeta)
|
||||
// Note: We join the 'user_profile' table because 'user' does not include user custom XenForo field user status.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user_profile',
|
||||
'from_fieldname' => 'status',
|
||||
'join_tablename' => 'user',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'USING (user_id)',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_xenforo_user_status'
|
||||
);
|
||||
|
||||
// Store Signature (Stored in usermeta)
|
||||
// Note: We join the 'user_profile' table because 'user' does not include user custom XenForo field user signature.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user_profile',
|
||||
'from_fieldname' => 'signature',
|
||||
'join_tablename' => 'user',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'USING (user_id)',
|
||||
'to_fieldname' => '_bbp_xenforo_user_sig',
|
||||
'to_type' => 'user',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Store Location (Stored in usermeta)
|
||||
// Note: We join the 'user_profile' table because 'user' does not include user custom XenForo field user location.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user_profile',
|
||||
'from_fieldname' => 'location',
|
||||
'join_tablename' => 'user',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'USING (user_id)',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_xenforo_user_location'
|
||||
);
|
||||
|
||||
// Store Occupation (Stored in usermeta)
|
||||
// Note: We join the 'user_profile' table because 'user' does not include user custom XenForo field user occupation.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user_profile',
|
||||
'from_fieldname' => 'occupation',
|
||||
'join_tablename' => 'user',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'USING (user_id)',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_xenforo_user_occupation'
|
||||
);
|
||||
|
||||
// Store About (Stored in usermeta)
|
||||
// Note: We join the 'user_profile' table because 'user' does not include user custom XenForo field user about.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user_profile',
|
||||
'from_fieldname' => 'about',
|
||||
'join_tablename' => 'user',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'USING (user_id)',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_xenforo_user_about',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function translate_savepass( $field, $row ) {
|
||||
$pass_array = array( 'hash' => $field, 'salt' => $row['salt'] );
|
||||
return $pass_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*/
|
||||
public function authenticate_pass( $password, $serialized_pass ) {
|
||||
$pass_array = unserialize( $serialized_pass );
|
||||
switch( $pass_array['hashFunc'] ) {
|
||||
case 'sha256':
|
||||
return ( $pass_array['hash'] == hash( 'sha256', hash( 'sha256', $password ) . $pass_array['salt'] ) );
|
||||
case 'sha1':
|
||||
return ( $pass_array['hash'] == sha1( sha1( $password ) . $pass_array['salt'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the forum type from XenForo Capitalised case to WordPress's non-capatilise case strings.
|
||||
*
|
||||
* @param int $status XenForo numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_forum_type( $status = 1 ) {
|
||||
switch ( $status ) {
|
||||
case 'Category' :
|
||||
$status = 'category';
|
||||
break;
|
||||
|
||||
case 'Forum' :
|
||||
default :
|
||||
$status = 'forum';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the forum status from XenForo numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status XenForo numeric forum status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_forum_status( $status = 1 ) {
|
||||
switch ( $status ) {
|
||||
case 0 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
default :
|
||||
$status = 'open';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the post status from XenForo to WordPress' strings.
|
||||
*
|
||||
* @param int $status XenForo post status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_status( $status = 1 ) {
|
||||
switch ( $status ) {
|
||||
case 'deleted' :
|
||||
$status = 'pending'; // bbp_get_pending_status_id()
|
||||
break;
|
||||
|
||||
case 'visible' :
|
||||
default :
|
||||
$status = 'publish'; // bbp_get_public_status_id()
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the topic status from XenForo numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status XenForo numeric topic status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_status( $status = 1 ) {
|
||||
switch ( $status ) {
|
||||
case 0 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
default :
|
||||
$status = 'publish';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the topic sticky status type from XenForo numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status XenForo numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_sticky_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'sticky'; // XenForo Sticky 'sticky = 1'
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'normal'; // XenForo Normal Topic 'sticky = 0'
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the topic reply count.
|
||||
*
|
||||
* @param int $count XenForo reply count
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_reply_count( $count = 1 ) {
|
||||
$count = absint( (int) $count - 1 );
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* This callback processes any custom parser.php attributes and custom code with preg_replace
|
||||
*/
|
||||
protected function callback_html( $field ) {
|
||||
|
||||
// Strips Xenforo custom HTML first from $field before parsing $field to parser.php
|
||||
$xenforo_markup = $field;
|
||||
$xenforo_markup = html_entity_decode( $xenforo_markup );
|
||||
|
||||
// Replace '[QUOTE]' with '<blockquote>'
|
||||
$xenforo_markup = preg_replace( '/\[QUOTE\]/', '<blockquote>', $xenforo_markup );
|
||||
// Replace '[/QUOTE]' with '</blockquote>'
|
||||
$xenforo_markup = preg_replace( '/\[\/QUOTE\]/', '</blockquote>', $xenforo_markup );
|
||||
// Replace '[QUOTE=User Name($1)]' with '<em>@$1 wrote:</em><blockquote>"
|
||||
$xenforo_markup = preg_replace( '/\[quote=\"(.*?)\,\spost\:\s(.*?)\,\s\member\:\s(.*?)\"\](.*?)\[\/quote\]/', '<em>@$1 wrote:</em><blockquote>', $xenforo_markup );
|
||||
// Replace '[/quote]' with '</blockquote>'
|
||||
$xenforo_markup = preg_replace( '/\[\/quote\]/', '</blockquote>', $xenforo_markup );
|
||||
|
||||
// Replace '[media=youtube]$1[/media]' with '$1"
|
||||
$xenforo_markup = preg_replace( '/\[media\=youtube\](.*?)\[\/media\]/', 'https://youtu.be/$1', $xenforo_markup );
|
||||
// Replace '[media=dailymotion]$1[/media]' with '$1"
|
||||
$xenforo_markup = preg_replace( '/\[media\=dailymotion\](.*?)\[\/media\]/', 'https://www.dailymotion.com/video/$1', $xenforo_markup );
|
||||
// Replace '[media=vimeo]$1[/media]' with '$1"
|
||||
$xenforo_markup = preg_replace( '/\[media\=vimeo\](.*?)\[\/media\]/', 'https://vimeo.com/$1', $xenforo_markup );
|
||||
|
||||
// Now that Xenforo custom HTML has been stripped put the cleaned HTML back in $field
|
||||
$field = $xenforo_markup;
|
||||
|
||||
// Parse out any bbCodes in $field with the BBCode 'parser.php'
|
||||
return parent::callback_html( $field );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,759 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress 1.x Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* bbPress 1.1 Converter
|
||||
*
|
||||
* @since 2.1.0 bbPress (r3816)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/bbpress-1-x-buddypress-group-forums
|
||||
*/
|
||||
class bbPress1 extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
// Setup smiley URL & path
|
||||
$this->bbcode_parser_properties = array(
|
||||
'smiley_url' => false,
|
||||
'smiley_dir' => false
|
||||
);
|
||||
|
||||
/** Forum Section *****************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum parent id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'forum_parent',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_parent_id'
|
||||
);
|
||||
|
||||
// Forum topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'topics',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_topic_count'
|
||||
);
|
||||
|
||||
// Forum reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'posts',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_reply_count'
|
||||
);
|
||||
|
||||
// Forum total topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'topics',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_topic_count'
|
||||
);
|
||||
|
||||
// Forum total reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'posts',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_reply_count'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'forum_name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid confilcts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'forum_slug',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'forum_desc',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forums',
|
||||
'from_fieldname' => 'forum_order',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (bbPress v1.x Forum > 0 or Category = 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'meta',
|
||||
'from_fieldname' => 'meta_value',
|
||||
'join_tablename' => 'forums',
|
||||
'join_type' => 'LEFT',
|
||||
'join_expression' => 'ON meta.object_id = forums.forum_id AND meta.meta_key = "forum_is_category"',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'callback_method' => 'callback_forum_type'
|
||||
);
|
||||
|
||||
// Forum status (Set a default value 'open', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'default' => 'open'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
/** Forum Subscriptions Section ***************************************/
|
||||
|
||||
/**
|
||||
* bbPress 1.x Forums do not support forum subscriptions
|
||||
*/
|
||||
|
||||
/** Topic Section *****************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'topic_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'topic_posts',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'topic_posts',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_total_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'topic_poster',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'topic_title',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'topic_slug',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
// Note: We join the 'posts' table because 'topics' table does not include content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'post_text',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (topic_id) WHERE posts.post_position IN (0,1)',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic status (Spam, Trash or Publish, bbPress v1.x publish = 0, trash = 1 & spam = 2)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'post_status',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (topic_id) WHERE posts.post_position IN (0,1)',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_status',
|
||||
'callback_method' => 'callback_status'
|
||||
);
|
||||
|
||||
// Topic status (Publish or Closed to new replies)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'topic_open',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_topic_status'
|
||||
);
|
||||
|
||||
// Topic author ip (Stored in postmeta)
|
||||
// Note: We join the 'posts' table because 'topics' table does not include author ip.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'poster_ip',
|
||||
'join_tablename' => 'topics',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (topic_id) WHERE posts.post_position IN (0,1)',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Sticky status (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'topic_sticky',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_sticky_status_id',
|
||||
'callback_method' => 'callback_sticky_status'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'topic_start_time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'topic_start_time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'topic_time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'topic_time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'topic_time',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
// Topic id.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'term_relationships',
|
||||
'from_fieldname' => 'object_id',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'objectid',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Taxonomy ID.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'term_taxonomy',
|
||||
'from_fieldname' => 'term_taxonomy_id',
|
||||
'join_tablename' => 'term_relationships',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (term_taxonomy_id)',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'taxonomy'
|
||||
);
|
||||
|
||||
// Term description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'term_taxonomy',
|
||||
'from_fieldname' => 'description',
|
||||
'join_tablename' => 'term_relationships',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (term_taxonomy_id)',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'description',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Term text.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'terms',
|
||||
'from_fieldname' => 'name',
|
||||
'join_tablename' => 'term_taxonomy',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (term_id) WHERE term_taxonomy.taxonomy = "bb_topic_tag"',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'name'
|
||||
);
|
||||
|
||||
// Term slug.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'terms',
|
||||
'from_fieldname' => 'slug',
|
||||
'join_tablename' => 'term_taxonomy',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (term_id) WHERE term_taxonomy.taxonomy = "bb_topic_tag"',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'slug',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
/** Topic Subscriptions Section ***************************************/
|
||||
|
||||
// Subscribed user ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'term_relationships',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'topic_subscriptions',
|
||||
'to_fieldname' => 'user_id',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Join the 'term_taxonomy' table to link 'terms' 'term_relationships' tables
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'term_taxonomy',
|
||||
'from_fieldname' => 'term_taxonomy_id',
|
||||
'join_tablename' => 'term_relationships',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (term_taxonomy_id)',
|
||||
'to_type' => 'topic_subscriptions'
|
||||
);
|
||||
|
||||
// Subscribed topic ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'terms',
|
||||
'from_fieldname' => 'name',
|
||||
'join_tablename' => 'term_taxonomy',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (term_id) WHERE term_taxonomy.taxonomy = "bb_subscribe"',
|
||||
'to_type' => 'topic_subscriptions',
|
||||
'to_fieldname' => '_bbp_subscriptions',
|
||||
'callback_method' => 'callback_topic_subscriptions'
|
||||
);
|
||||
|
||||
/** Favorites Section *************************************************/
|
||||
|
||||
// Favorited topic ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'usermeta',
|
||||
'from_fieldname' => 'meta_value',
|
||||
'from_expression' => 'WHERE usermeta.meta_key = "bb_favorites"',
|
||||
'to_type' => 'favorites',
|
||||
'to_fieldname' => '_bbp_favorites'
|
||||
);
|
||||
|
||||
// Favorited user ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'usermeta',
|
||||
'from_fieldname' => 'user_id',
|
||||
'from_expression' => 'WHERE usermeta.meta_key = "bb_favorites"',
|
||||
'to_type' => 'favorites',
|
||||
'to_fieldname' => 'user_id',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
/** Reply Section *****************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'post_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0. Stored in postmeta)
|
||||
// Note: We join the 'topics' table to limit the replies section to only import replies
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'topics',
|
||||
'from_fieldname' => 'topic_id',
|
||||
'join_tablename' => 'posts',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (topic_id) WHERE posts.post_position NOT IN (0,1)',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Reply author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'poster_ip',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'poster_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply status (Spam, Trash or Publish, bbPress v1.x publish = 0, trash = 1 & spam = 2)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'post_status',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_status',
|
||||
'callback_method' => 'callback_status'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'post_text',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply order.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'post_position',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'topic_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'post_time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'post_time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'post_time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'posts',
|
||||
'from_fieldname' => 'post_time',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'ID',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old user password (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_pass',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password'
|
||||
);
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_login',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User nice name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_nicename',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_nicename'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_email',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User homepage.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_url',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_url'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_registered',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered'
|
||||
);
|
||||
|
||||
// User status.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'user_status',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_status'
|
||||
);
|
||||
|
||||
// User display name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'users',
|
||||
'from_fieldname' => 'display_name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'display_name'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the post status from bbPress 1's numerics to WordPress's
|
||||
* strings.
|
||||
*
|
||||
* @param int $status bbPress 1.x numeric post status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 2 :
|
||||
$status = 'spam'; // bbp_get_spam_status_id()
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
$status = 'trash'; // bbp_get_trash_status_id()
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'publish'; // bbp_get_public_status_id()
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the forum type from bbPress 1.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status bbPress 1.x numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_forum_type( $status = 0 ) {
|
||||
if ( $status == 1 ) {
|
||||
$status = 'category';
|
||||
} else {
|
||||
$status = 'forum';
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the topic status from bbPress 1's numerics to WordPress's
|
||||
* strings.
|
||||
*
|
||||
* @param int $topic_status bbPress 1.x numeric status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_status( $topic_status = 1 ) {
|
||||
switch ( $topic_status ) {
|
||||
case 0 :
|
||||
$topic_status = 'closed'; // bbp_get_closed_status_id()
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
default :
|
||||
$topic_status = 'publish'; // bbp_get_public_status_id()
|
||||
break;
|
||||
}
|
||||
return $topic_status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the topic sticky status type from bbPress 1.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status bbPress 1.x numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_sticky_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 2 :
|
||||
$status = 'super-sticky'; // bbPress Super Sticky 'topic_sticky = 2'
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
$status = 'sticky'; // bbPress Sticky 'topic_sticky = 1'
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'normal'; // bbPress Normal Topic 'topic_sticky = 0'
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the topic reply count.
|
||||
*
|
||||
* @param int $count bbPress 1.x topic and reply counts
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_reply_count( $count = 1 ) {
|
||||
$count = absint( (int) $count - 1 );
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass( $field, $row ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*/
|
||||
public function authenticate_pass( $password, $serialized_pass ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This callback strips `topic-` from topic subscriptions taxonomy
|
||||
*
|
||||
* @since 2.6.0 bbPress (r5572)
|
||||
*
|
||||
* @param string $field Topic ID
|
||||
* @return integer WordPress safe
|
||||
*/
|
||||
protected function callback_topic_subscriptions( $field ) {
|
||||
|
||||
// Replace 'topic-' with '' so that only the original topic ID remains
|
||||
$field = absint( (int) preg_replace( '/(topic-)(\d+)/', '$2', $field ) );
|
||||
return $field;
|
||||
}
|
||||
}
|
||||
637
wp-content/plugins/bbpress/includes/admin/converters/e107v1.php
Normal file
637
wp-content/plugins/bbpress/includes/admin/converters/e107v1.php
Normal file
@@ -0,0 +1,637 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress e107 1.x Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of e107 v1.x Forum converter.
|
||||
*
|
||||
* @since 2.6.0 bbPress (r5352)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/e107
|
||||
*/
|
||||
class e107v1 extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main Constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
// Setup smiley URL & path
|
||||
$this->bbcode_parser_properties = array(
|
||||
'smiley_url' => false,
|
||||
'smiley_dir' => false
|
||||
);
|
||||
|
||||
/** Forum Section *****************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'forum_id',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum parent id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'forum_parent',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_parent_id'
|
||||
);
|
||||
|
||||
// Forum topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'forum_threads',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_topic_count'
|
||||
);
|
||||
|
||||
// Forum reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'forum_replies',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_reply_count'
|
||||
);
|
||||
|
||||
// Forum total topic count (Includes unpublished topics, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'forum_threads',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_topic_count'
|
||||
);
|
||||
|
||||
// Forum total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'forum_replies',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_reply_count'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'forum_name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'forum_name',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'forum_description',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'forum_order',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Category = 0 or Forum > 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'forum_parent',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'callback_method' => 'callback_forum_type'
|
||||
);
|
||||
|
||||
// Forum status (Set a default value 'open', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'default' => 'open'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
/** Topic Section *****************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_id',
|
||||
'from_expression' => 'WHERE thread_parent = 0',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_total_replies',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_total_replies',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_total_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_forum_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
// Note: Uses a custom callback to transform user id from '1.Administrator e107v1' to numeric user id.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_user',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_e107v1_userid'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_thread',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_name',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_name',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic status (Open or Closed, e107 v1.x open = 1 & closed = 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_active',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_topic_status'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_forum_id',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Sticky status (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_s',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_sticky_status_id',
|
||||
'callback_method' => 'callback_sticky_status'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_datestamp',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_datestamp',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_datestamp',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_datestamp',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_datestamp',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
/**
|
||||
* e107 v1.x Forums do not support topic tags out of the box
|
||||
*/
|
||||
|
||||
/** Reply Section *****************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_id',
|
||||
'from_expression' => 'WHERE thread_parent != 0',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_forum_id',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_topicid_to_forumid'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_parent',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
// Note: Uses a custom callback to transform user id from '1.Administrator e107v1' to numeric user id.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_user',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_e107v1_userid'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_thread',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_parent',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_datestamp',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_datestamp',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_datestamp',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum_t',
|
||||
'from_fieldname' => 'thread_datestamp',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'user_id',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old user password (Stored in usermeta serialized with salt)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'user_password',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password',
|
||||
'callback_method' => 'callback_savepass'
|
||||
);
|
||||
|
||||
// User password verify class (Stored in usermeta for verifying password)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_class',
|
||||
'default' => 'e107v1'
|
||||
);
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'user_loginname',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User nice name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'user_loginname',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_nicename'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'user_email',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'user_join',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// User display name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'user_name',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'display_name'
|
||||
);
|
||||
|
||||
// Store Signature (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'user_signature',
|
||||
'to_fieldname' => '_bbp_e107v1_user_sig',
|
||||
'to_type' => 'user',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass( $field, $row ) {
|
||||
$pass_array = array( 'hash' => $field, 'salt' => $row['salt'] );
|
||||
return $pass_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*/
|
||||
public function authenticate_pass( $password, $serialized_pass ) {
|
||||
$pass_array = unserialize( $serialized_pass );
|
||||
return ( $pass_array['hash'] == md5( md5( $password ). $pass_array['salt'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the forum type from e107 v1.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status e107 v1.x numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_forum_type( $status = 0 ) {
|
||||
if ( $status == 0 ) {
|
||||
$status = 'category';
|
||||
} else {
|
||||
$status = 'forum';
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the post status from e107 v1.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status e107 v1.x numeric topic status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_status( $status = 1 ) {
|
||||
switch ( $status ) {
|
||||
case 0 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
default :
|
||||
$status = 'publish';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the topic sticky status type from e107 v1.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status e107 v1.x numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_sticky_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 2 :
|
||||
$status = 'super-sticky'; // e107 Announcement Sticky 'thread_s = 2'
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
$status = 'sticky'; // e107 Sticky 'thread_s = 1'
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'normal'; // e107 normal topic 'thread_s = 0'
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the topic/reply count.
|
||||
*
|
||||
* @param int $count e107 v1.x topic/reply counts
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_reply_count( $count = 1 ) {
|
||||
$count = absint( (int) $count - 1 );
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the `callback_user` function in 'converter.php' for custom e107v1 imports
|
||||
*
|
||||
* A mini cache system to reduce database calls to user ID's
|
||||
*
|
||||
* @param string $field
|
||||
* @return string
|
||||
*/
|
||||
protected function callback_e107v1_userid( $field ) {
|
||||
|
||||
// Strip only the user id from the topic and reply authors
|
||||
$field = preg_replace( '/(\d+?)+\.[\S\s]+/', '$1', $field );
|
||||
|
||||
if ( ! isset( $this->map_userid[ $field ] ) ) {
|
||||
if ( ! empty( $this->sync_table ) ) {
|
||||
$row = $this->wpdb->get_row( $this->wpdb->prepare( "SELECT value_id, meta_value FROM {$this->sync_table_name} WHERE meta_key = %s AND meta_value = %s LIMIT 1", '_bbp_old_user_id', $field ) );
|
||||
} else {
|
||||
$row = $this->wpdb->get_row( $this->wpdb->prepare( "SELECT user_id AS value_id FROM {$this->wpdb->usermeta} WHERE meta_key = %s AND meta_value = %s LIMIT 1", '_bbp_old_user_id', $field ) );
|
||||
}
|
||||
|
||||
if ( ! is_null( $row ) ) {
|
||||
$this->map_userid[ $field ] = $row->value_id;
|
||||
} else {
|
||||
if ( true === $this->convert_users ) {
|
||||
$this->map_userid[ $field ] = 0;
|
||||
} else {
|
||||
$this->map_userid[ $field ] = $field;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->map_userid[ $field ];
|
||||
}
|
||||
|
||||
/**
|
||||
* This callback processes any custom parser.php attributes and custom code with preg_replace
|
||||
*/
|
||||
protected function callback_html( $field ) {
|
||||
|
||||
// Strips custom e107v1 'magic_url' and 'bbcode_uid' first from $field before parsing $field to parser.php
|
||||
$e107v1_markup = $field;
|
||||
$e107v1_markup = html_entity_decode( $e107v1_markup );
|
||||
|
||||
// Replace '[blockquote]' with '<blockquote>'
|
||||
$e107v1_markup = preg_replace( '/\[blockquote\]/', '<blockquote>', $e107v1_markup );
|
||||
// Replace '[/blockquote]' with '</blockquote>'
|
||||
$e107v1_markup = preg_replace( '/\[\/blockquote\]/', '</blockquote>', $e107v1_markup );
|
||||
|
||||
// Replace '[quote$1=$2]' with '<em>$2 wrote:</em><blockquote>"
|
||||
$e107v1_markup = preg_replace( '/\[quote(.*?)=(.*?)\]/', '<em>@$2 wrote:</em><blockquote>', $e107v1_markup );
|
||||
// Replace '[/quote$1]' with '</blockquote>"
|
||||
$e107v1_markup = preg_replace( '/\[\/quote(.*?)\]/' , '</blockquote>', $e107v1_markup );
|
||||
|
||||
// Remove '[justify]'
|
||||
$e107v1_markup = preg_replace( '/\[justify\]/', '', $e107v1_markup );
|
||||
// Remove '[/justify]'
|
||||
$e107v1_markup = preg_replace( '/\[\/justify\]/', '', $e107v1_markup );
|
||||
|
||||
// Replace '[link=(https|http)://$2]$3[/link]' with '<a href="$1://$2">$3</a>'
|
||||
$e107v1_markup = preg_replace( '/\[link\=(https|http)\:\/\/(.*?)\](.*?)\[\/link\]/i', '<a href="$1://$2">$3</a>', $e107v1_markup );
|
||||
|
||||
// Replace '[list=(decimal|lower-roman|upper-roman|lower-alpha|upper-alpha)]' with '[list]'
|
||||
$e107v1_markup = preg_replace( '/\[list\=(decimal|lower-roman|upper-roman|lower-alpha|upper-alpha)\]/i', '[list]', $e107v1_markup );
|
||||
|
||||
// Replace '[youtube]$1[/youtube]' with '$1"
|
||||
$e107v1_markup = preg_replace( '/\[youtube\](.*?)\[\/youtube\]/', 'https://youtu.be/$1', $e107v1_markup );
|
||||
|
||||
// Now that e107v1 custom HTML has been stripped put the cleaned HTML back in $field
|
||||
$field = $e107v1_markup;
|
||||
|
||||
// Parse out any bbCodes in $field with the BBCode 'parser.php'
|
||||
return parent::callback_html( $field );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Do not modify the files in this folder.
|
||||
*/
|
||||
1027
wp-content/plugins/bbpress/includes/admin/converters/phpBB.php
Normal file
1027
wp-content/plugins/bbpress/includes/admin/converters/phpBB.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,756 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress vBulletin 4.x Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of vBulletin v4.x Converter.
|
||||
*
|
||||
* @since 2.3.0 bbPress (r4724)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/vbulletin
|
||||
*/
|
||||
class vBulletin extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
// Setup smiley URL & path
|
||||
$this->bbcode_parser_properties = array(
|
||||
'smiley_url' => false,
|
||||
'smiley_dir' => false
|
||||
);
|
||||
|
||||
/** Forum Section *****************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'forumid',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum parent id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'parentid',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_parent_id'
|
||||
);
|
||||
|
||||
// Forum topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'threadcount',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_topic_count'
|
||||
);
|
||||
|
||||
// Forum reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'replycount',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_reply_count'
|
||||
);
|
||||
|
||||
// Forum total topic count (Includes unpublished topics, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'threadcount',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_topic_count'
|
||||
);
|
||||
|
||||
// Forum total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'replycount',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_reply_count'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'title',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid confilcts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'title_clean',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'description',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'displayorder',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Category = -1 or Forum > 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'parentid',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'callback_method' => 'callback_forum_type'
|
||||
);
|
||||
|
||||
// Forum status (Set a default value 'open', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'default' => 'open'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date( 'Y-m-d H:i:s' )
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date( 'Y-m-d H:i:s' )
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date( 'Y-m-d H:i:s' )
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date( 'Y-m-d H:i:s' )
|
||||
);
|
||||
|
||||
/** Forum Subscriptions Section ***************************************/
|
||||
|
||||
// Subscribed forum ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'subscribeforum',
|
||||
'from_fieldname' => 'forumid',
|
||||
'to_type' => 'forum_subscriptions',
|
||||
'to_fieldname' => '_bbp_forum_subscriptions'
|
||||
);
|
||||
|
||||
// Subscribed user ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'subscribeforum',
|
||||
'from_fieldname' => 'userid',
|
||||
'to_type' => 'forum_subscriptions',
|
||||
'to_fieldname' => 'user_id',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
/** Topic Section *****************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'threadid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'forumid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'replycount',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'replycount',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_total_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'postuserid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic author name (Stored in postmeta as _bbp_anonymous_name)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'postusername',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_author_name_id'
|
||||
);
|
||||
|
||||
// Is the topic anonymous (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'postuserid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_is_topic_anonymous_id',
|
||||
'callback_method' => 'callback_check_anonymous'
|
||||
);
|
||||
|
||||
// Topic Author ip (Stored in postmeta)
|
||||
// Note: We join the 'post' table because 'thread' table does not include topic content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'ipaddress',
|
||||
'join_tablename' => 'thread',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (threadid) WHERE post.parentid = 0',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'title',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'title',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'forumid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
// Note: We join the 'post' table because 'thread' table does not include topic content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'pagetext',
|
||||
'join_tablename' => 'thread',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (threadid) WHERE post.parentid = 0',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic status (Open or Closed)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'open',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_topic_status'
|
||||
);
|
||||
|
||||
// Sticky status (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'sticky',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_sticky_status_id',
|
||||
'callback_method' => 'callback_sticky_status'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'lastpost',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
// Topic id.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'tagcontent',
|
||||
'from_fieldname' => 'contentid',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'objectid',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Taxonomy ID.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'tagcontent',
|
||||
'from_fieldname' => 'tagid',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'taxonomy'
|
||||
);
|
||||
|
||||
// Term text.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'tag',
|
||||
'from_fieldname' => 'tagtext',
|
||||
'join_tablename' => 'tagcontent',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (tagid)',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'name'
|
||||
);
|
||||
|
||||
// Term slug.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'tag',
|
||||
'from_fieldname' => 'tagtext',
|
||||
'join_tablename' => 'tagcontent',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (tagid)',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'slug',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
/** Topic Subscriptions Section ***************************************/
|
||||
|
||||
// Subscribed topic ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'subscribethread',
|
||||
'from_fieldname' => 'threadid',
|
||||
'to_type' => 'topic_subscriptions',
|
||||
'to_fieldname' => '_bbp_subscriptions'
|
||||
);
|
||||
|
||||
// Subscribed user ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'subscribethread',
|
||||
'from_fieldname' => 'userid',
|
||||
'to_type' => 'topic_subscriptions',
|
||||
'to_fieldname' => 'user_id',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
/** Reply Section *****************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'postid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'threadid',
|
||||
'from_expression' => 'WHERE parentid != 0',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_topicid_to_forumid'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'threadid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'ipaddress',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'userid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply author name (Stored in postmeta as _bbp_anonymous_name)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_author_name_id'
|
||||
);
|
||||
|
||||
// Is the reply anonymous (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'userid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_is_reply_anonymous_id',
|
||||
'callback_method' => 'callback_check_anonymous'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'pagetext',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'threadid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'userid',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old user password (Stored in usermeta serialized with salt)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'password',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password',
|
||||
'callback_method' => 'callback_savepass'
|
||||
);
|
||||
|
||||
// Store old user salt (This is only used for the SELECT row info for the above password save)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'salt',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_salt'
|
||||
);
|
||||
|
||||
// User password verify class (Stored in usermeta for verifying password)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_class',
|
||||
'default' => 'vBulletin'
|
||||
);
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'email',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User homepage.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'homepage',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_url'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'joindate',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// User AIM (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'aim',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_vbulletin_user_aim'
|
||||
);
|
||||
|
||||
// User Yahoo (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'yahoo',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_vbulletin_user_yim'
|
||||
);
|
||||
|
||||
// User ICQ (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'icq',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_vbulletin_user_icq'
|
||||
);
|
||||
|
||||
// User MSN (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'msn',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_vbulletin_user_msn'
|
||||
);
|
||||
|
||||
// User Skype (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'skype',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_vbulletin_user_skype'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass( $field, $row ) {
|
||||
$pass_array = array( 'hash' => $field, 'salt' => $row['salt'] );
|
||||
return $pass_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*
|
||||
*/
|
||||
public function authenticate_pass( $password, $serialized_pass ) {
|
||||
$pass_array = unserialize( $serialized_pass );
|
||||
return ( $pass_array['hash'] == md5( md5( $password ) . $pass_array['salt'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the forum type from vBulletin v4.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status vBulletin v4.x numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_forum_type( $status = 0 ) {
|
||||
if ( $status == -1 ) {
|
||||
$status = 'category';
|
||||
} else {
|
||||
$status = 'forum';
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the topic sticky status type from vBulletin v4.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status vBulletin v4.x numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_sticky_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 2 :
|
||||
$status = 'super-sticky'; // vBulletin Super Sticky 'sticky = 2'
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
$status = 'sticky'; // vBulletin Sticky 'sticky = 1'
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'normal'; // vBulletin Normal Topic 'sticky = 0'
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the topic reply count.
|
||||
*
|
||||
* @param int $count vBulletin v4.x reply count
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_reply_count( $count = 1 ) {
|
||||
$count = absint( (int) $count - 1 );
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the post status from vBulletin numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status vBulletin v4.x numeric topic status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_status( $status = 1 ) {
|
||||
switch ( $status ) {
|
||||
case 0 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
default :
|
||||
$status = 'publish';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* This callback processes any custom parser.php attributes and custom code with preg_replace
|
||||
*/
|
||||
protected function callback_html( $field ) {
|
||||
|
||||
// Strips vBulletin custom HTML first from $field before parsing $field to parser.php
|
||||
$vbulletin_markup = $field;
|
||||
$vbulletin_markup = html_entity_decode( $vbulletin_markup );
|
||||
|
||||
// Replace '[QUOTE]' with '<blockquote>'
|
||||
$vbulletin_markup = preg_replace( '/\[QUOTE\]/', '<blockquote>', $vbulletin_markup );
|
||||
// Replace '[QUOTE=User Name($1);PostID($2)]' with '<em>@$1 $2 wrote:</em><blockquote>"
|
||||
$vbulletin_markup = preg_replace( '/\[QUOTE=(.*?);(.*?)\]/', '<em>@$1 $2 wrote:</em><blockquote>', $vbulletin_markup );
|
||||
// Replace '[/QUOTE]' with '</blockquote>'
|
||||
$vbulletin_markup = preg_replace( '/\[\/QUOTE\]/', '</blockquote>', $vbulletin_markup );
|
||||
// Replace '[MENTION=###($1)]User Name($2)[/MENTION]' with '@$2"
|
||||
$vbulletin_markup = preg_replace( '/\[MENTION=(.*?)\](.*?)\[\/MENTION\]/', '@$2', $vbulletin_markup );
|
||||
|
||||
// Replace '[video=youtube;$1]$2[/video]' with '$2"
|
||||
$vbulletin_markup = preg_replace( '/\[video\=youtube;(.*?)\](.*?)\[\/video\]/', '$2', $vbulletin_markup );
|
||||
// Replace '[video=youtube_share;$1]$2[/video]' with '$2"
|
||||
$vbulletin_markup = preg_replace( '/\[video\=youtube_share;(.*?)\](.*?)\[\/video\]/', '$2', $vbulletin_markup );
|
||||
|
||||
// Now that vBulletin custom HTML has been stripped put the cleaned HTML back in $field
|
||||
$field = $vbulletin_markup;
|
||||
|
||||
// Parse out any bbCodes in $field with the BBCode 'parser.php'
|
||||
return parent::callback_html( $field );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,754 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* bbPress vBulletin 3.x Converter
|
||||
*
|
||||
* @package bbPress
|
||||
* @subpackage Converters
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of vBulletin v3.x Converter.
|
||||
*
|
||||
* @since 2.5.0 bbPress (r5151)
|
||||
*
|
||||
* @link Codex Docs https://codex.bbpress.org/import-forums/vbulletin
|
||||
*/
|
||||
class vBulletin3 extends BBP_Converter_Base {
|
||||
|
||||
/**
|
||||
* Main constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the field mappings
|
||||
*/
|
||||
public function setup_globals() {
|
||||
|
||||
// Setup smiley URL & path
|
||||
$this->bbcode_parser_properties = array(
|
||||
'smiley_url' => false,
|
||||
'smiley_dir' => false
|
||||
);
|
||||
|
||||
/** Forum Section *****************************************************/
|
||||
|
||||
// Old forum id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'forumid',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_id'
|
||||
);
|
||||
|
||||
// Forum parent id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'parentid',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_old_forum_parent_id'
|
||||
);
|
||||
|
||||
// Forum topic count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'threadcount',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_topic_count'
|
||||
);
|
||||
|
||||
// Forum reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'replycount',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_reply_count'
|
||||
);
|
||||
|
||||
// Forum total topic count (Includes unpublished topics, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'threadcount',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_topic_count'
|
||||
);
|
||||
|
||||
// Forum total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'replycount',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_total_reply_count'
|
||||
);
|
||||
|
||||
// Forum title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'title',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Forum slug (Clean name to avoid confilcts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'title_clean',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Forum description.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'description',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_null'
|
||||
);
|
||||
|
||||
// Forum display order (Starts from 1)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'displayorder',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'menu_order'
|
||||
);
|
||||
|
||||
// Forum type (Category = -1 or Forum > 0, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'forum',
|
||||
'from_fieldname' => 'parentid',
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_forum_type',
|
||||
'callback_method' => 'callback_forum_type'
|
||||
);
|
||||
|
||||
// Forum status (Set a default value 'open', Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => '_bbp_status',
|
||||
'default' => 'open'
|
||||
);
|
||||
|
||||
// Forum dates.
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date',
|
||||
'default' => date( 'Y-m-d H:i:s' )
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'default' => date( 'Y-m-d H:i:s' )
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'default' => date( 'Y-m-d H:i:s' )
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'forum',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'default' => date( 'Y-m-d H:i:s' )
|
||||
);
|
||||
|
||||
/** Forum Subscriptions Section ***************************************/
|
||||
|
||||
// Subscribed forum ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'subscribeforum',
|
||||
'from_fieldname' => 'forumid',
|
||||
'to_type' => 'forum_subscriptions',
|
||||
'to_fieldname' => '_bbp_forum_subscriptions'
|
||||
);
|
||||
|
||||
// Subscribed user ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'subscribeforum',
|
||||
'from_fieldname' => 'userid',
|
||||
'to_type' => 'forum_subscriptions',
|
||||
'to_fieldname' => 'user_id',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
/** Topic Section *****************************************************/
|
||||
|
||||
// Old topic id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'threadid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_id'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'forumid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic reply count (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'replycount',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic total reply count (Includes unpublished replies, Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'replycount',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_total_reply_count',
|
||||
'callback_method' => 'callback_topic_reply_count'
|
||||
);
|
||||
|
||||
// Topic author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'postuserid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Topic author name (Stored in postmeta as _bbp_anonymous_name)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'postusername',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_topic_author_name_id'
|
||||
);
|
||||
|
||||
// Is the topic anonymous (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'postuserid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_is_topic_anonymous_id',
|
||||
'callback_method' => 'callback_check_anonymous'
|
||||
);
|
||||
|
||||
// Topic Author ip (Stored in postmeta)
|
||||
// Note: We join the 'post' table because 'thread' table does not include topic content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'ipaddress',
|
||||
'join_tablename' => 'thread',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (threadid) WHERE post.parentid = 0',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Topic title.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'title',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_title'
|
||||
);
|
||||
|
||||
// Topic slug (Clean name to avoid conflicts)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'title',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_name',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
// Topic parent forum id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'forumid',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_forumid'
|
||||
);
|
||||
|
||||
// Topic content.
|
||||
// Note: We join the 'post' table because 'thread' table does not include topic content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'pagetext',
|
||||
'join_tablename' => 'thread',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (threadid) WHERE post.parentid = 0',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Topic status (Open or Closed)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'open',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_closed_status_id',
|
||||
'callback_method' => 'callback_topic_status'
|
||||
);
|
||||
|
||||
// Sticky status (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'sticky',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_old_sticky_status_id',
|
||||
'callback_method' => 'callback_sticky_status'
|
||||
);
|
||||
|
||||
// Topic dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'thread',
|
||||
'from_fieldname' => 'lastpost',
|
||||
'to_type' => 'topic',
|
||||
'to_fieldname' => '_bbp_last_active_time',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** Tags Section ******************************************************/
|
||||
|
||||
// Topic id.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'tagthread',
|
||||
'from_fieldname' => 'threadid',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'objectid',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Taxonomy ID.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'tagthread',
|
||||
'from_fieldname' => 'tagid',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'taxonomy'
|
||||
);
|
||||
|
||||
// Term text.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'tag',
|
||||
'from_fieldname' => 'tagtext',
|
||||
'join_tablename' => 'tagthread',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (tagid)',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'name'
|
||||
);
|
||||
|
||||
// Term slug.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'tag',
|
||||
'from_fieldname' => 'tagtext',
|
||||
'join_tablename' => 'tagthread',
|
||||
'join_type' => 'INNER',
|
||||
'join_expression' => 'USING (tagid)',
|
||||
'to_type' => 'tags',
|
||||
'to_fieldname' => 'slug',
|
||||
'callback_method' => 'callback_slug'
|
||||
);
|
||||
|
||||
/** Topic Subscriptions Section ***************************************/
|
||||
|
||||
// Subscribed topic ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'subscribethread',
|
||||
'from_fieldname' => 'threadid',
|
||||
'to_type' => 'topic_subscriptions',
|
||||
'to_fieldname' => '_bbp_subscriptions'
|
||||
);
|
||||
|
||||
// Subscribed user ID (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'subscribethread',
|
||||
'from_fieldname' => 'userid',
|
||||
'to_type' => 'topic_subscriptions',
|
||||
'to_fieldname' => 'user_id',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
/** Reply Section *****************************************************/
|
||||
|
||||
// Old reply id (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'postid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_id'
|
||||
);
|
||||
|
||||
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'threadid',
|
||||
'from_expression' => 'WHERE parentid != 0',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_forum_id',
|
||||
'callback_method' => 'callback_topicid_to_forumid'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0. Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'threadid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_topic_id',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply author ip (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'ipaddress',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_author_ip'
|
||||
);
|
||||
|
||||
// Reply author.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'userid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_author',
|
||||
'callback_method' => 'callback_userid'
|
||||
);
|
||||
|
||||
// Reply author name (Stored in postmeta as _bbp_anonymous_name)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_reply_author_name_id'
|
||||
);
|
||||
|
||||
// Is the reply anonymous (Stored in postmeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'userid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => '_bbp_old_is_reply_anonymous_id',
|
||||
'callback_method' => 'callback_check_anonymous'
|
||||
);
|
||||
|
||||
// Reply content.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'pagetext',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_content',
|
||||
'callback_method' => 'callback_html'
|
||||
);
|
||||
|
||||
// Reply parent topic id (If no parent, then 0)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'threadid',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_parent',
|
||||
'callback_method' => 'callback_topicid'
|
||||
);
|
||||
|
||||
// Reply dates.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_date_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'post',
|
||||
'from_fieldname' => 'dateline',
|
||||
'to_type' => 'reply',
|
||||
'to_fieldname' => 'post_modified_gmt',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
/** User Section ******************************************************/
|
||||
|
||||
// Store old user id (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'userid',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_old_user_id'
|
||||
);
|
||||
|
||||
// Store old user password (Stored in usermeta serialized with salt)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'password',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_password',
|
||||
'callback_method' => 'callback_savepass'
|
||||
);
|
||||
|
||||
// Store old user salt (This is only used for the SELECT row info for the above password save)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'salt',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => ''
|
||||
);
|
||||
|
||||
// User password verify class (Stored in usermeta for verifying password)
|
||||
$this->field_map[] = array(
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_class',
|
||||
'default' => 'vBulletin3'
|
||||
);
|
||||
|
||||
// User name.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'username',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_login'
|
||||
);
|
||||
|
||||
// User email.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'email',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_email'
|
||||
);
|
||||
|
||||
// User homepage.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'homepage',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_url'
|
||||
);
|
||||
|
||||
// User registered.
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'joindate',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => 'user_registered',
|
||||
'callback_method' => 'callback_datetime'
|
||||
);
|
||||
|
||||
// User AIM (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'aim',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_vbulletin3_user_aim'
|
||||
);
|
||||
|
||||
// User Yahoo (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'yahoo',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_vbulletin3_user_yim'
|
||||
);
|
||||
|
||||
// User ICQ (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'icq',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_vbulletin3_user_icq'
|
||||
);
|
||||
|
||||
// User MSN (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'msn',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_vbulletin3_user_msn'
|
||||
);
|
||||
|
||||
// User Skype (Stored in usermeta)
|
||||
$this->field_map[] = array(
|
||||
'from_tablename' => 'user',
|
||||
'from_fieldname' => 'skype',
|
||||
'to_type' => 'user',
|
||||
'to_fieldname' => '_bbp_vbulletin3_user_skype'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to indicates what is or is not converted for each
|
||||
* converter.
|
||||
*/
|
||||
public function info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is to save the salt and password together. That
|
||||
* way when we authenticate it we can get it out of the database
|
||||
* as one value. Array values are auto sanitized by WordPress.
|
||||
*/
|
||||
public function callback_savepass( $field, $row ) {
|
||||
$pass_array = array( 'hash' => $field, 'salt' => $row['salt'] );
|
||||
return $pass_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to take the pass out of the database and compare
|
||||
* to a pass the user has typed in.
|
||||
*
|
||||
* vBulletin passwords do not work. Maybe use the below plugin's approach?
|
||||
*
|
||||
* @link https://wordpress.org/extend/plugins/vb-user-copy/
|
||||
* @link https://plugins.trac.wordpress.org/browser/vb-user-copy/trunk/vb_user_copy.php
|
||||
*/
|
||||
public function authenticate_pass( $password, $serialized_pass ) {
|
||||
$pass_array = unserialize( $serialized_pass );
|
||||
return ( $pass_array['hash'] == md5( md5( $password ) . $pass_array['salt'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the forum type from vBulletin v3.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status vBulletin v3.x numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_forum_type( $status = 0 ) {
|
||||
if ( $status == -1 ) {
|
||||
$status = 'category';
|
||||
} else {
|
||||
$status = 'forum';
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the topic sticky status type from vBulletin v3.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status vBulletin v3.x numeric forum type
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_sticky_status( $status = 0 ) {
|
||||
switch ( $status ) {
|
||||
case 1 :
|
||||
$status = 'sticky'; // vBulletin Sticky 'topic_sticky = 1'
|
||||
break;
|
||||
|
||||
case 0 :
|
||||
default :
|
||||
$status = 'normal'; // vBulletin Normal Topic 'topic_sticky = 0'
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the topic reply count.
|
||||
*
|
||||
* @param int $count vBulletin v3.x reply count
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_reply_count( $count = 1 ) {
|
||||
$count = absint( (int) $count - 1 );
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the post status from vBulletin v3.x numerics to WordPress's strings.
|
||||
*
|
||||
* @param int $status vBulletin v3.x numeric topic status
|
||||
* @return string WordPress safe
|
||||
*/
|
||||
public function callback_topic_status( $status = 1 ) {
|
||||
switch ( $status ) {
|
||||
case 0 :
|
||||
$status = 'closed';
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
default :
|
||||
$status = 'publish';
|
||||
break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* This callback processes any custom parser.php attributes and custom code with preg_replace
|
||||
*/
|
||||
protected function callback_html( $field ) {
|
||||
|
||||
// Strips vBulletin custom HTML first from $field before parsing $field to parser.php
|
||||
$vbulletin_markup = $field;
|
||||
$vbulletin_markup = html_entity_decode( $vbulletin_markup );
|
||||
|
||||
// Replace '[QUOTE]' with '<blockquote>'
|
||||
$vbulletin_markup = preg_replace( '/\[QUOTE\]/', '<blockquote>', $vbulletin_markup );
|
||||
// Replace '[QUOTE=User Name($1);PostID($2)]' with '<em>@$1 $2 wrote:</em><blockquote>"
|
||||
$vbulletin_markup = preg_replace( '/\[QUOTE=(.*?);(.*?)\]/' , '<em>@$1 $2 wrote:</em><blockquote>', $vbulletin_markup );
|
||||
// Replace '[/QUOTE]' with '</blockquote>'
|
||||
$vbulletin_markup = preg_replace( '/\[\/QUOTE\]/', '</blockquote>', $vbulletin_markup );
|
||||
// Replace '[MENTION=###($1)]User Name($2)[/MENTION]' with '@$2"
|
||||
$vbulletin_markup = preg_replace( '/\[MENTION=(.*?)\](.*?)\[\/MENTION\]/', '@$2', $vbulletin_markup );
|
||||
|
||||
// Replace '[video=youtube;$1]$2[/video]' with '$2"
|
||||
$vbulletin_markup = preg_replace( '/\[video\=youtube;(.*?)\](.*?)\[\/video\]/', '$2', $vbulletin_markup );
|
||||
|
||||
// Now that vBulletin custom HTML has been stripped put the cleaned HTML back in $field
|
||||
$field = $vbulletin_markup;
|
||||
|
||||
// Parse out any bbCodes in $field with the BBCode 'parser.php'
|
||||
return parent::callback_html( $field );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user