Skip to content

Instantly share code, notes, and snippets.

@ntwb

ntwb/DeluxeBB.php

Created Oct 6, 2014
Embed
What would you like to do?
DeluxeBB Importer for bbPress
<?php
/**
* Implementation of DeluxeBB v1.x Converter.
*
* @since bbPress (rXXXX)
*
* @link Codex Docs http://codex.bbpress.org/import-forums/deluxebb
*/
class deluxeBB extends BBP_Converter_Base {
/**
* Main Constructor
*
* @uses deluxeBB::setup_globals()
*/
function __construct() {
parent::__construct();
$this->setup_globals();
}
/**
* 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' => 'cid',
'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' => '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' => 'forums',
'from_fieldname' => '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' => 'replies',
'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' => 'ordered',
'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')
);
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment