Skip to content

Instantly share code, notes, and snippets.

Created November 1, 2013 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/7267096 to your computer and use it in GitHub Desktop.
Save anonymous/7267096 to your computer and use it in GitHub Desktop.
DotNetNuke to bbPress conversion
localhost - rhcrm_dnnforum
forum_forums
Column Type Null Default Comments
ForumID int(1) Yes NULL
GroupID int(1) Yes NULL
IsActive varchar(4) Yes NULL
ParentID int(1) Yes NULL
Name varchar(20) Yes NULL
Description varchar(94) Yes NULL
CreatedDate varchar(29) Yes NULL
CreatedByUser int(3) Yes NULL
UpdatedByUser int(3) Yes NULL
UpdatedDate varchar(29) Yes NULL
IsModerated varchar(5) Yes NULL
SortOrder int(1) Yes NULL
TotalPosts int(3) Yes NULL
TotalThreads int(3) Yes NULL
MostRecentPostID int(4) Yes NULL
PostsToModerate int(2) Yes NULL
ForumType int(1) Yes NULL
PublicView varchar(4) Yes NULL
PublicPosting varchar(4) Yes NULL
EnableForumsThreadStatus varchar(4) Yes NULL
EnableForumsRating varchar(4) Yes NULL
ForumLink varchar(10) Yes NULL
ForumBehavior int(1) Yes NULL
AllowPolls varchar(5) Yes NULL
EnableRSS varchar(4) Yes NULL
EmailAddress varchar(10) Yes NULL
EmailFriendlyFrom varchar(10) Yes NULL
NotifyByDefault varchar(5) Yes NULL
EmailStatusChange varchar(5) Yes NULL
EmailServer varchar(10) Yes NULL
EmailUser varchar(10) Yes NULL
EmailPass varchar(10) Yes NULL
EmailEnableSSL varchar(5) Yes NULL
EmailAuth int(1) Yes NULL
EmailPort varchar(3) Yes NULL
EnableSitemap varchar(4) Yes NULL
SitemapPriority decimal(2,1) Yes NULL
forum_posts
Column Type Null Default Comments
PostID int(4) Yes NULL
ParentPostID int(4) Yes NULL
UserID int(3) Yes NULL
RemoteAddr varchar(15) Yes NULL
Subject varchar(100) Yes NULL
Body varchar(8000) Yes NULL
CreatedDate varchar(396) Yes NULL
ThreadID varchar(29) Yes NULL
TreeSortOrder varchar(3) Yes NULL
FlatSortOrder varchar(1) Yes NULL
UpdatedDate varchar(29) Yes NULL
UpdatedByUser varchar(29) Yes NULL
IsApproved varchar(5) Yes NULL
IsLocked varchar(5) Yes NULL
IsClosed varchar(5) Yes NULL
DateApproved varchar(29) Yes NULL
PostReported varchar(29) Yes NULL
Addressed int(1) Yes NULL
ParseInfo int(1) Yes NULL
Replies int(2) Yes NULL
ForumID int(1) Yes NULL
NULL int(1) Yes NULL
users
Column Type Null Default Comments
UserID int(4) Yes NULL
Username varchar(25) Yes NULL
FirstName varchar(13) Yes NULL
LastName varchar(14) Yes NULL
IsSuperUser varchar(5) Yes NULL
AffiliateId varchar(2) Yes NULL
Email varchar(40) Yes NULL
DisplayName varchar(24) Yes NULL
UpdatePassword varchar(5) Yes NULL
LastIPAddress varchar(15) Yes NULL
IsDeleted varchar(5) Yes NULL
CreatedByUserID varchar(2) Yes NULL
CreatedOnDate varchar(7) Yes NULL
LastModifiedByUserID varchar(3) Yes NULL
LastModifiedOnDate varchar(7) Yes NULL
<?php
/**
* Implementation of Active Forums for DotNetNuke Converter
*
* @since bbPress (r4689)
*/
class DotNetNuke extends BBP_Converter_Base {
/**
* Main Constructor
*
* @uses ActiveForums::setup_globals()
*/
function __construct() {
parent::__construct();
$this->setup_globals();
}
/**
* Sets up the field mappings
*/
public function setup_globals() {
/** Forum Section ******************************************************/
// Forum id (Stored in postmeta)
$this->field_map[] = array(
'from_tablename' => 'forum_forums',
'from_fieldname' => 'ForumID',
'to_type' => 'forum',
'to_fieldname' => '_bbp_forum_id'
);
// Forum parent id (If no parent, then 0. Stored in postmeta)
$this->field_map[] = array(
'from_tablename' => 'forum_forums',
'from_fieldname' => 'ForumGroupID',
'to_type' => 'forum',
'to_fieldname' => '_bbp_forum_parent_id'
);
// Forum topic count (Stored in postmeta)
$this->field_map[] = array(
'from_tablename' => 'forum_forums',
'from_fieldname' => 'TotalThreads',
'to_type' => 'forum',
'to_fieldname' => '_bbp_topic_count'
);
// Forum reply count (Stored in postmeta)
$this->field_map[] = array(
'from_tablename' => 'forum_forums',
'from_fieldname' => 'TotalPosts',
'to_type' => 'forum',
'to_fieldname' => '_bbp_reply_count'
);
// Forum total topic count (Stored in postmeta)
$this->field_map[] = array(
'from_tablename' => 'forum_forums',
'from_fieldname' => 'TotalThreads',
'to_type' => 'forum',
'to_fieldname' => '_bbp_total_topic_count'
);
// Forum total reply count (Stored in postmeta)
$this->field_map[] = array(
'from_tablename' => 'forum_forums',
'from_fieldname' => 'TotalPosts',
'to_type' => 'forum',
'to_fieldname' => '_bbp_total_reply_count'
);
// 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' => 'SortOrder',
'to_type' => 'forum',
'to_fieldname' => 'menu_order'
);
// 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 ******************************************************/
// Topic id (Stored in postmeta)
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'from_fieldname' => 'PostID',
'from_expression'=> 'WHERE ParentPostID = 0',
'to_type' => 'topic',
'to_fieldname' => '_bbp_topic_id'
);
// Topic reply count (Stored in postmeta)
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'from_fieldname' => 'Replies',
'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' => 'forum_posts',
'from_fieldname' => 'ForumID',
'to_type' => 'topic',
'to_fieldname' => '_bbp_forum_id',
'callback_method' => 'callback_forumid'
);
// Topic author.
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'from_fieldname' => 'UserID',
'to_type' => 'topic',
'to_fieldname' => 'post_author',
'callback_method' => 'callback_userid'
);
// Topic title.
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'from_fieldname' => 'Subject',
'to_type' => 'topic',
'to_fieldname' => 'post_title'
);
// Topic slug (Clean name to avoid conflicts)
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'from_fieldname' => 'Subject',
'to_type' => 'topic',
'to_fieldname' => 'post_name',
'callback_method' => 'callback_slug'
);
// Topic content.
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'from_fieldname' => 'Body',
'to_type' => 'topic',
'to_fieldname' => 'post_content',
'callback_method' => 'callback_html'
);
// Topic parent forum id (If no parent, then 0)
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'from_fieldname' => 'ParentPostID',
'to_type' => 'topic',
'to_fieldname' => 'post_parent',
'callback_method' => 'callback_forumid'
);
// Topic dates.
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'from_fieldname' => 'CreatedDate',
'to_type' => 'topic',
'to_fieldname' => 'post_date'
);
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'from_fieldname' => 'CreatedDate',
'to_type' => 'topic',
'to_fieldname' => 'post_date_gmt'
);
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'from_fieldname' => 'UpdatedDate',
'to_type' => 'topic',
'to_fieldname' => 'post_modified'
);
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'from_fieldname' => 'UpdatedDate',
'to_type' => 'topic',
'to_fieldname' => 'post_modified_gmt',
);
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'from_fieldname' => 'UpdatedDate',
'to_type' => 'topic',
'to_fieldname' => '_bbp_last_active_time',
);
/** Tags Section ******************************************************/
/*
// Topic id.
$this->field_map[] = array(
'from_tablename' => 'tagcontent',
'from_fieldname' => 'contentid',
'to_type' => 'tags',
'to_fieldname' => 'objectid',
'callback_method' => 'callback_topicid'
);
// Tags 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'
);
*/
/** Reply Section ******************************************************/
// Reply id (Stored in postmeta)
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'from_fieldname' => 'PostID',
'from_expression'=> 'WHERE ParentPostID != 0',
'to_type' => 'reply',
'to_fieldname' => '_bbp_post_id'
);
// Reply parent forum id (If no parent, then 0. Stored in postmeta)
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'from_fieldname' => 'ForumID',
'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' => 'ParentPostID',
'to_type' => 'reply',
'to_fieldname' => '_bbp_topic_id',
'callback_method' => 'callback_topicid'
);
// Reply author.
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'from_fieldname' => 'UserID',
'to_type' => 'reply',
'to_fieldname' => 'post_author',
'callback_method' => 'callback_userid'
);
// Reply title.
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'from_fieldname' => 'Subject',
'to_type' => 'reply',
'to_fieldname' => 'post_title'
);
// Reply slug (Clean name to avoid conflicts)
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'from_fieldname' => 'Subject',
'to_type' => 'reply',
'to_fieldname' => 'post_name',
'callback_method' => 'callback_slug'
);
// Reply content.
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'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' => 'forum_posts',
'from_fieldname' => 'ParentPostID',
'to_type' => 'reply',
'to_fieldname' => 'post_parent',
'callback_method' => 'callback_topicid'
);
// Reply dates.
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'from_fieldname' => 'CreatedDate',
'to_type' => 'reply',
'to_fieldname' => 'post_date'
);
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'from_fieldname' => 'CreatedDate',
'to_type' => 'reply',
'to_fieldname' => 'post_date_gmt'
);
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'from_fieldname' => 'UpdatedDate',
'to_type' => 'reply',
'to_fieldname' => 'post_modified'
);
$this->field_map[] = array(
'from_tablename' => 'forum_posts',
'from_fieldname' => 'UpdatedDate',
'to_type' => 'reply',
'to_fieldname' => 'post_modified_gmt'
);
/** User Section ******************************************************/
// `forum_userdetails` user profile details
// 'aspnet_membership' - passwords
// Store old User id (Stored in usermeta)
$this->field_map[] = array(
'from_tablename' => 'users',
'from_fieldname' => 'UserID',
'to_type' => 'user',
'to_fieldname' => '_bbp_user_id'
);
// Store old User password (Stored in usermeta serialized with salt)
// $this->field_map[] = array(
// 'from_tablename' => 'aspnet_membership',
// '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' => 'aspnet_membership',
// 'from_fieldname' => 'PasswordSalt',
// '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' => 'ActiveForums'
// );
// 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 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' => 'forum_userdetails',
// 'from_fieldname' => 'DateAdded',
// 'to_type' => 'user',
// 'to_fieldname' => 'user_registered',
// 'callback_method' => 'callback_datetime'
// );
// User display name.
$this->field_map[] = array(
'from_tablename' => 'users',
'from_fieldname' => 'DisplayName',
'to_type' => 'user',
'to_fieldname' => 'display_name'
);
// User AIM (Stored in usermeta)
// $this->field_map[] = array(
// 'from_tablename' => 'user',
// 'from_fieldname' => 'aim',
// 'to_type' => 'user',
// 'to_fieldname' => 'aim'
// );
// User Yahoo (Stored in usermeta)
// $this->field_map[] = array(
// 'from_tablename' => 'user',
// 'from_fieldname' => 'yahoo',
// 'to_type' => 'user',
// 'to_fieldname' => 'yim'
// );
}
/**
* This method allows us to indicates what is or is not converted for each
* converter.
*/
public function info()
{
return '';
}
/**
* Verify the topic reply count.
*
* @param int $count ActiveForums 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 )
{
$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'] ) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment