Skip to:
Content
Pages
Categories
Search
Top
Bottom

Documented import from snitz access database


  • Robin W
    Moderator

    @robin-w

    Converting a Snitz access database forum to BBpress

    This documents how I transferred from a website using Snitz and an access database to a new site with BBress using Mysql.

    This briefing assumes knowledge of
    • FTP programmes and uploading/downloading files
    • A way to access your wordpress database eg myphpadmin
    • A way to see your access database

    Introduction

    BBpress has a conversion tool that lets you import data from several other forum packages. However two things are needed for this to work.
    1. The data in a MySQL database format
    2. A convertor programme that understands the structure of the source (in this case Snitz) forum.

    If you already have a MySQL verison of Snitz (Snitz supports Access, MS SQL, and MySQL), then you’ll still need to fix the date, and run a specific Snitz converter, but don’t need the upload to MySql in step 2.

    Plan

    The plan therefore is to
    1. Fix date format (it is different between the two forums)
    2. Convert the data to sql format
    3. Run a snitz converter
    4. Run repair to fix the links

    Execution

    I can only describe how I achieved this, I suspect there are lots of ways, but this one worked.

    I had an access database on site x with hosting company a, and needed to transfer to a Mysql database on site y with hosting company b (basically I was taking over running someone else’s website management)

    Step 1 fixing the data format

    Snitz stores dates in the format yyyymmddhhmmss
    BBpress stores dates in the format yyyy-mm-dd hh:mm:ss

    You can fix this
    • before you transfer the data to sql,
    • after you have transferred it
    • or during conversion,

    this will depend on where you knowledge lies. But you will need to fix it. If you don’t fix this, all the entries you import will show as posted 2014 years ago (basically year 0)

    I converted before transferring to sql, as I an old and used to working with flat files! If you are more capable in sql, you could no doubt write a small programme to change the data format after you’ve uploaded to sql, and if more capable in php you could do it within the converter programme (see later)

    The Snitz database has two tables with dates in that need changing. These are :

    FORUM_TOPICS
    FORUM_REPLY

    This is how they showed in my Snitz database, but the prefix may be different with yours.

    In FORUM_TOPICS you need to change
    T_DATE
    T_LAST_POST

    In FORUM_REPLY you need to change
    T_REPLY

    I downloaded the access database from the old site to my PC. I then exported the two tables to an excel spreadsheet (in Access go to external data, and look for export to Excel. You’ll need to have created a blank spreadsheet with the name you want to use first) and ran the formula

    =CONCATENATE(MID(N2,1,4),"-",MID(N2,5,2),"-",MID(N2,7,2)," “,MID(N2,9,2),":",MID(N2,11,2),":",MID(N2,13,2))

    Where column N contained the old date.

    I then prefixed the original heading with OLD (eg heading T_DATE became OLDT_DATE) and headed the new column with the heading of the old one (eg T_DATE). I did this to a) preserve the original columns just in case, and b) to use for the clean slug in the conversion (see later).

    I then deleted the old table in access, and imported the two excel ones back into Access (as before external data, then import).

    I then had the same access database, but with the correct date formulas and a couple of extra columns with the old date format in them.

    Step 2 – Convert access database to MySql database

    The first thing you’ll need is a MySql database to upload to.

    You can use the one you presumably already have with WordPress/BBpress. However you’ll just need to check that none of the names co-incide. Since my Snitz database used capitals (I don’t know if they all Snitz databases do), and BBpress uses lower case, I suspect that there is no risk in doing this, but one for you to consider.

    I took the safety of creating a fresh blank database (my hosting package allows the creation of databases and manages them through phpMyadmin).
    There are numerous programmes on the web that do access to Mysql conversion, but for no particular reason I chose Bullzip http://www.bullzip.com/.

    However this needs a 32bit ODBC driver to work, so unless you already have Mysql on your local PC, you’ll need to download the driver from http://www.mysql.com/downloads/connector/odbc/ – choose the 32 bit one.

    Once installed it is a doddle to do the conversion.
    You’ll need :
    The access database on your pc
    The host address of your MySql database
    The database name
    The username
    The password.

    Run the wizard, and it’ll upload in minutes.

    Finally if you’re going to do the date conversion discussed in Step 1 at this stage, now’s the time to do it.

    Step 3 – Importing/converting the data

    This is easy once you’ve got your head around it, but initially it can be very frustrating.

    In essence you need to translate what one forum calls something to what the other needs.

    For Snitz, I used the following translation

    
    Forum section FORUM_FORUM forum
    Forum id	FORUM_ID	_bbp_forum_id
    Forum parent id	CAT_ID	_bbp_parent_id
    Forum title	F_SUBJECT	post_title
    Forum Slug  (see note 1)	FORUM_ID	post_name
    Forum description	F_DESCRIPTION	post_content
    Forum Display Order	F_ORDER	Menu_order
    Forum Date Update		Post_date
    		
    Topic section	FORUM_TOPICS	topic
    Topic id	TOPIC_ID	_bbp_topic_id
    Forum id 	FORUM_ID	_bbp_forum_id
    Topic author	T_AUTHOR	post_author
    Topic title	T_SUBJECT	post_title
    Topic Slug (see note 1)	T_DATE	post_name
    Forum id (if no parent 0) 	FORUM_ID	post_parent
    Topic date update 	T_DATE	post_date
    	T_DATE	post_date_gmt
    	T_LAST_POST_DATE	post_modified
    	T_LAST_POST_DATE	post_modified_gmt
    		
    Tags section		
    Ignored		
    		
    		
    Post section	FORUM_REPLY	reply
    Post id	REPLY_ID	_bbp_post_id
    Forum id	FORUM_ID	_bbp_forum_id
    Topic  id	TOPIC_ID	_bbp_topic_id
    Author ip	R_IP	_bbp_author_ip
    Post author	R_AUTHOR	post_author
    Topic slug	R_DATE	post_name
    Post Content	R_MESSAGE	post_content
    Topic id	TOPIC_ID	post_parent
    Topic date	R_DATE	post_date
    		
    User Section	FORUM_MEMBERS	user
    Store old user id	MEMBER_ID	_bbp_user_id
    	M_NAME	user_login
    	M_PASSWORD	_bbp_password
    	M_EMAIL	user_email
    	M_HOMEPAGE	user_url
    	M_AIM	aim
    	M_YAHOO	yim
    		
    

    [NOTE if you copy this and post in a word doc, you should be able to get a nice tabbed table]
    Note 1

    I used OLDR_DATE & OLDT_DATE from the step 1 as my clean slugs. A slug is what BBpress uses for a URL to reference a post. It needs to be clean – ie not have formatting, odd characters like spaces etc. in it. I did debate using the topic ID, but was unsure if this was unique for BBpress – it may well be fine. So I used the references above as I was pretty sure that with our forum being not that busy, that no two people would have posted in the same second. If you choose to use some other field, such as topic ID, you’ll need to change the field in the converter document – see below.

    This is then used against the example converter that BBpress supplies.

    Whilst initially looking daunting, this is fairly easy to change to get it to work.

    Step 3.1 Creating a Snitz.php

    Firstly go to your site. Using FTP go to web/wp-content/plugins/bbpress/includes/admin/converters and locate example.php. FTP this to your PC and using an editor (notepad ++ is good – download it from http://notepad-plus-plus.org/) you need to change the default “froms” to those above

    But first save it locally as “snitz.php”, and change the first couple of lines to read

    
    /**
     * Implementation of snitz converter.
     */
    class snitz extends BBP_Converter_Base
    

    If you don’t do this, the converter won’t recognise it.

    Then you need to work through each of the lines of code changing the “default” source database tables and names to the correct ones.

    So looking at you new snitz.php, you’ll see for instance the first conversion is :

    
    // Forum id. Stored in postmeta.
    $this->field_map[] = array(
    'from_tablename' => 'forum', 'from_fieldname' => 'forumid',
    'to_type' => 'forum', 'to_fieldname' => '_bbp_forum_id'
    

    So to get this to work for Snitz you need to change the source table from ‘forum’ to “FORUM_FORUM” and the from field needs changing from ‘forumd’ to’ _bbp_forum_id’

    Making the lines now read :

    
    // Forum id. Stored in postmeta.
    $this->field_map[] = array(
    'from_tablename' => 'FORUM_FORUM', 'from_fieldname' => 'FORUM_ID',
    'to_type' => 'forum', 'to_fieldname' => '_bbp_forum_id'
    

    Using the translation table above you work through each of the lines, doing the substitution.

    I commented out the tags section, as I couldn’t see that Snitz had tags. I also commented out the “
    Store old user salt” and “User password verify class” sections as passwords won’t come across – see later on this.

    CRITICALLY I also added the following as the example doesn’t had a bit that brings the actual topic content across !

    
    // Topic content.
    		// Note: We join the posts table because topics do not have content.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_MESSAGE',
    			'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'
    

    Once all that is done, save the file locally.

    Then using FTP upload it to the same directory that example came from
    Viz : web/wp-content/plugins/bbpress/includes/admin/converters
    Now you’re ready to run the conversion!

    You’ll need the following info
    Database server (localhost if your using you local Mysql database)
    Database name
    Database User
    Database password

    Then in Dashboard, go to tools>forums>import forums

    Select “snitz” from the converter list, and fill in the database info from above.

    Click to select users, presuming that you want to bring these across.

    Then click start, and sit back and watch. If you’ve got everything right, you’ll see a steady stream of lines such as “converting topics 1-100”

    If Fails :

    If it falls over, then you’ll need to work out which part of the snitz converter it doesn’t like (it’ll give you a line number). Usually you’ve got punctuations wrong, or called something by a wrong name. Remember snitz (in my case anyway) uses capitals, and bbpress needs lowercase, so ensure that’s all ok.

    If nothing comes through (it usually says “starting conversion…conversion complete”), then you have got the connection wrong, as it’s not finding the database and tables.

    If Success :

    Then you’ll need to repair the links (Dashboard>tools>forums>repair forums). Otherwise in my case the forum listings came through, but with no topics listed against them.

    Do as the tool suggests – I ran several at the same time, and wrote most of this document whilst waiting !

    Finally – users

    If you successfully imported your users, they’ll have accounts, but their passwords won’t work – Bbpress can’t bring these across.

    The easiest way is to tell them to click “lost password” and enter their email address and then they can reset their own.

    And that’s how it’s done !

Viewing 25 replies - 26 through 50 (of 57 total)

  • Sziban
    Participant

    @sziban

    Thank you Stephen!

    Thank you for detailed answer. Only one more question: It is very important for me that the forum must be very stable and perfect to use by our visitors. Isn’t it hazardous to use the bbPress 2.6-alpha version instead of the stable bbPress 2.5.8 version?

    Hi,
    v2.6 is very mature and close to release. But of course it’s your decision.
    Pascal.

    2.6 is incredibly stable, its nearing, and has been, pretty close to being ready for release for quite some time, bbpress.org and wordpress.org are using 2.6 perfectly if that helps.


    Sziban
    Participant

    @sziban

    Thank you!
    Very convincing arguments.
    I am going to give a try and I’ll tell you my experiences.

    Sziban


    Sziban
    Participant

    @sziban

    Well, I installed the v2.6, modified the converter.php, imported the data and now everything works perfectly.
    Thank you gentlemen for this great help!

    Awesome 🙂


    Sziban
    Participant

    @sziban

    Hello again,

    For a while seemed everything fine, but I had to notice there is something wrong with the users.
    I can find them in the new database, everything in the right field, but I cannot use them.
    If I send the forgot password email, choose a new pass and trying to login, the system does nothing, I can see only a big white screen.
    I run the forum repair more than once, but two of them (sync-all-reply-positions and user-role-map) interrupts all the time and I have to see the big white screen again.
    Do you have any suggestion?
    Thanks!

    I’m guessing the sync-all-reply-positions fails because of some incorrect meta for the replies, theres also a few known issues with this tool timing out when used on sites with lots of replies.

    The user-role-map repair tool should work fine, no known issues with this one.

    What happens if you create a new user, just a new WordPress user, can that user login, create topics and replies etc? What happens if you now remove all the imported users and run this repair tool again, theoretically it would only be running on “native” WordPress users and not any imported users, (i.e. “admin” and “test user” only), does the repair tool still fail?


    Sziban
    Participant

    @sziban

    Registering and using a new user after the import is works fine as well as using an old user, registered before the import.
    I tried with the bbpress v2.5.8, but I was unable to run the user-role-map repair tool either, I got the white screen there too.
    Tried to turn off all the other plugins, increasing the memory, but nothing changed.
    How do you think to delete all the users? Only the users or users and their posts too?
    (How can I easily remove 30k users?)


    Sziban
    Participant

    @sziban

    As I checked the converter again, I found that during the test period I changed the default value to “special” in this part below.
    // User password verify class (Stored in usermeta for verifying password)
    $this->field_map[] = array(
    ‘to_type’ => ‘user’,
    ‘to_fieldname’ => ‘_bbp_class’,
    ‘default’ => ‘special’
    );
    Is this could cause the error?

    I changed the default value to “special” in this part below.

    I don’t think this would cause that error, the fact that I’ve no idea what is causing that error “could” be in fact the cause of the error.

    The “Reset Forums” tool includes the ability to delete all bbPress forum content and imported users, run this and that should get rid of your ~30k imported users.

    After that, try changing that “special” back to “Snitz” (I think thats what it was) and se what happens.


    Sziban
    Participant

    @sziban

    Thanks!
    In the original Exmple.php the ‘default’ => ‘Example’, but the phpbb sample the ‘default’ => ‘phpBB’ and the SMF sample the ‘default’ => ‘SMF’ was. This is why I thought I can change to any text.
    Anyway I am going to change the value and see what happens.

    I’ve just pushed a new 2.6-alpha that includes a fix for deleting imported users, it wasn’t behaving as it should.

    https://downloads.wordpress.org/plugin/bbpress.zip


    Sziban
    Participant

    @sziban

    Thanks!


    stefyonweb
    Participant

    @stefyonweb

    Hi everyone, although 4 years have passed, I hope someone can help me 🙂
    I’m trying to import a snitz database following these instructions, but I can only import users and “reply” table.
    Analyzing forum table configuration I noticed, comparing the snitz.php file with the other files, that

    ‘to_fieldname’ => ‘_bbp_forum_id’

    whereas in all the other files it’s

    ‘to_fieldname’ => ‘_bbp_old_forum_id’

    I tried changing the value but had no success, though.

    Maybe it depends on the fact that new bbPress version uses “post” and “postmeta” tables instead of custom bbPress tables?

    I searched for ad updated snitz.php file but didn’t find any.

    Thanks in advance 🙂


    Robin W
    Moderator

    @robin-w

    My original import instructions are from v2 bbpress 7years ago.


    Robin W
    Moderator

    @robin-w

    but yes, looks like the way conversion works is different, so use the new ‘to’ and just out your snitz from.

    I think this might be your problem

    CRITICALLY I also added the following as the example doesn’t had a bit that brings the actual topic content across !

    in the first post above.

    If you are starting again then make sure you blank the forums in wordpress first, so it does the whole job again

    dashboard>forums>reset forums.


    Robin W
    Moderator

    @robin-w

    come back if you need further help


    stefyonweb
    Participant

    @stefyonweb

    Thank you for your time, Robin 🙂
    I tried making a new snitz.php file following the given example. I also added the lines you suggested. Again the importer only imports users and reply table. I really can’t figure out the problem.
    I’m going to give up and ask for some company to do the job for me 🙁


    Robin W
    Moderator

    @robin-w

    do you want to post a copy of the convertor here, and I’ll take a quick look


    stefyonweb
    Participant

    @stefyonweb

    Thank you Robin, here’s the code:

    <?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 snitz 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'  => 'FORUM_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_FORUM',
    			'from_fieldname'  => 'CAT_ID',
    			'to_type'         => 'forum',
    			'to_fieldname'    => '_bbp_old_forum_parent_id'
    		);
    
    		// Forum topic count (Stored in postmeta)
    		$this->field_map[] = array(
    			'from_tablename' => 'FORUM_FORUM',
    			'from_fieldname' => 'F_TOPICS',
    			'to_type'        => 'forum',
    			'to_fieldname'   => '_bbp_topic_count'
    		);
    
    		// Forum reply count (Stored in postmeta)
    		$this->field_map[] = array(
    			'from_tablename' => 'FORUM_FORUM',
    			'from_fieldname' => 'F_COUNT',
    			'to_type'        => 'forum',
    			'to_fieldname'   => '_bbp_reply_count'
    		);
    
    		// Forum total topic count (Stored in postmeta)
    		$this->field_map[] = array(
    			'from_tablename' => 'FORUM_FORUM',
    			'from_fieldname' => 'F_TOPICS',
    			'to_type'        => 'forum',
    			'to_fieldname'   => '_bbp_total_topic_count'
    		);
    
    		// Forum total reply count (Stored in postmeta)
    		$this->field_map[] = array(
    			'from_tablename' => 'FORUM_FORUM',
    			'from_fieldname' => 'F_COUNT',
    			'to_type'        => 'forum',
    			'to_fieldname'   => '_bbp_total_reply_count'
    		);
    
    		// Forum title.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_FORUM',
    			'from_fieldname'  => 'F_SUBJECT',
    			'to_type'         => 'forum',
    			'to_fieldname'    => 'post_title'
    		);
    
    		// Forum slug (Clean name to avoid confilcts)
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_FORUM',
    			'from_fieldname'  => 'F_SUBJECT',
    			'to_type'         => 'forum',
    			'to_fieldname'    => 'post_name',
    			'callback_method' => 'callback_slug'
    		);
    
    		// Forum description.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_FORUM',
    			'from_fieldname'  => 'F_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_FORUM',
    			'from_fieldname'  => 'F_ORDER',
    			'to_type'         => 'forum',
    			'to_fieldname'    => 'menu_order'
    		);
    
    		// Forum type (Category = 0 or Forum = 1, Stored in postmeta)
    		$this->field_map[] = array(
    	//		'from_tablename'  => 'FORUM_FORUM',
    	//		'from_fieldname'  => 'the_forum_type',
    			'to_type'         => 'forum',
    			'to_fieldname'    => '_bbp_forum_type',
    		//	'callback_method' => 'callback_forum_type'
           'default'      => 'forum'
    		);
    
    		// Forum status (Unlocked = 0 or Locked = 1, Stored in postmeta)
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_FORUM',
    			'from_fieldname'  => 'F_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'  => 'FORUM_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'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_REPLIES',
    			'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'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_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_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'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_AUTHOR',
    			'to_type'         => 'topic',
    			'to_fieldname'    => 'post_author',
    			'callback_method' => 'callback_userid'
    		);
    
    		// Topic author ip (Stored in postmeta)
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_IP',
    			'to_type'         => 'topic',
    			'to_fieldname'    => '_bbp_author_ip'
    		);
    
    		// Topic content.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_MESSAGE',
    			'to_type'         => 'topic',
    			'to_fieldname'    => 'post_content',
    			'callback_method' => 'callback_html'
    		);
    
    		// Topic title.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_SUBJECT',
    			'to_type'         => 'topic',
    			'to_fieldname'    => 'post_title'
    		);
    
    		// Topic slug (Clean name to avoid conflicts)
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_SUBJECT',
    			'to_type'         => 'topic',
    			'to_fieldname'    => 'post_name',
    			'callback_method' => 'callback_slug'
    		);
    
    		// Topic status (Open or Closed)
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_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'  => 'FORUM_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'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_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_TOPICS',
    			'from_fieldname'  => 'T_DATE',
    			'to_type'         => 'topic',
    			'to_fieldname'    => 'post_date',
    			'callback_method' => 'callback_datetime'
    		);
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_DATE',
    			'to_type'         => 'topic',
    			'to_fieldname'    => 'post_date_gmt',
    			'callback_method' => 'callback_datetime'
    		);
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_LAST_POST_DATE',
    			'to_type'         => 'topic',
    			'to_fieldname'    => 'post_modified',
    			'callback_method' => 'callback_datetime'
    		);
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_LAST_POST_DATE',
    			'to_type'         => 'topic',
    			'to_fieldname'    => 'post_modified_gmt',
    			'callback_method' => 'callback_datetime'
    		);
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_LAST_POST',
    			'to_type'         => 'topic',
    			'to_fieldname'    => '_bbp_last_active_time',
    			'callback_method' => 'callback_datetime'
    		);
    
        $this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_MESSAGE',
    			'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'
       );
        
    		// Setup any table joins needed for the topic section
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_REPLY',
    			'from_fieldname'  => 'TOPIC_ID',
    			'join_tablename'  => 'FORUM_TOPICS',
    			'join_type'       => 'INNER',
    			'join_expression' => 'USING FORUM_REPLY.TOPIC_ID = FORUM_TOPICS.TOPIC_ID',
    			'from_expression' => 'WHERE FORUM_FORUM.TOPIC_ID = 0',
    			'to_type'         => 'topic'
    		);
    
    		/** Tags Section ******************************************************/
    
    		
    
    		/** Topic Subscriptions Section ***************************************/
    
    		/** Favorites Section *************************************************/
    
    		// Favorited topic ID (Stored in usermeta)
    
    		/** 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'  => 'FORUM_REPLY',
    			'from_fieldname'  => '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'  => 'FORUM_REPLY',
    			'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'  => 'FORUM_REPLY',
    			'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'  => 'FORUM_REPLY',
    			'from_fieldname'  => 'R_IP',
    			'to_type'         => 'reply',
    			'to_fieldname'    => '_bbp_author_ip'
    		);
    
    		// Reply author.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_REPLY',
    			'from_fieldname'  => 'R_AUTHOR',
    			'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'  => 'FORUM_REPLY',
    			'from_fieldname'  => 'R_MESSAGE',
    			'to_type'         => 'reply',
    			'to_fieldname'    => 'post_content',
    			'callback_method' => 'callback_html'
    		);
    
    	/* Snizt doesnt use reply order
    		// Reply order.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_REPLY',
    			'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'  => 'FORUM_REPLY',
    			'from_fieldname'  => 'TOPIC_ID',
    			'to_type'         => 'reply',
    			'to_fieldname'    => 'post_parent',
    			'callback_method' => 'callback_topicid'
    		);
    
    		// Reply dates.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_REPLY',
    			'from_fieldname'  => 'R_DATE',
    			'to_type'         => 'reply',
    			'to_fieldname'    => 'post_date',
    			'callback_method' => 'callback_datetime'
    		);
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_REPLY',
    			'from_fieldname'  => 'R_DATE',
    			'to_type'         => 'reply',
    			'to_fieldname'    => 'post_date_gmt',
    			'callback_method' => 'callback_datetime'
    		);
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_REPLY',
    			'from_fieldname'  => 'R_DATE',
    			'to_type'         => 'reply',
    			'to_fieldname'    => 'post_modified',
    			'callback_method' => 'callback_datetime'
    		);
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_REPLY',
    			'from_fieldname'  => 'R_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'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'TOPIC_ID',
    			'join_tablename'  => 'FORUM_REPLY',
    			'join_type'       => 'INNER',
    			'join_expression' => 'USING FORUM_TOPICS.TOPIC_ID = FORUM_REPLY.TOPIC_ID',
    			'from_expression' => 'WHERE FORUM_TOPICS.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'  => 'FORUM_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'  => 'FORUM_MEMBERS',
    			'from_fieldname'  => 'M_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'  => 'FORUM_MEMBERS',
    			'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'  => 'FORUM_MEMBERS',
    			'from_fieldname'  => 'M_NAME',
    			'to_type'         => 'user',
    			'to_fieldname'    => 'user_login'
    		);
    
    		// User nice name.
    		$this->field_map[] = array(
    			'from_tablename' => 'FORUM_MEMBERS',
    			'from_fieldname' => 'M_NAME',
    			'to_type'        => 'user',
    			'to_fieldname'   => 'user_nicename'
    		);
    
    		// User email.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_MEMBERS',
    			'from_fieldname'  => 'M_EMAIL',
    			'to_type'         => 'user',
    			'to_fieldname'    => 'user_email'
    		);
    
    		// User homepage.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_MEMBERS',
    			'from_fieldname'  => 'M_HOMEPAGE',
    			'to_type'         => 'user',
    			'to_fieldname'    => 'user_url'
    		);
    
    		/* Snitz doesn't use user registered
    		// User registered.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_MEMBERS',
    			'from_fieldname'  => 'the_users_registration_date',
    			'to_type'         => 'user',
    			'to_fieldname'    => 'user_registered',
    			'callback_method' => 'callback_datetime'
    		);
    */
    /* Snitz doesn't use user status
    		// User status.
    		$this->field_map[] = array(
    			'from_tablename' => 'FORUM_MEMBERS',
    			'from_fieldname' => 'the_users_status',
    			'to_type'        => 'user',
    			'to_fieldname'   => 'user_status'
    		);
    */
    
    		// User display name.
    		$this->field_map[] = array(
    			'from_tablename' => 'FORUM_MEMBERS',
    			'from_fieldname' => 'M_NAME',
    			'to_type'        => 'user',
    			'to_fieldname'   => 'display_name'
    		);
    
    		// User Profile Field 1 (Stored in usermeta)
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_MEMBERS',
    			'from_fieldname'  => 'M_AIM',
    			'to_type'         => 'user',
    			'to_fieldname'    => 'aim'
    		);
    
    		// User Profile Field 2 (Stored in usermeta)
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_MEMBERS',
    			'from_fieldname'  => 'M_YAHOO',
    			'to_type'         => 'user',
    			'to_fieldname'    => 'yim'
    		);
    
    		// User Profile Field 3 (Stored in usermeta)
    		$this->field_map[] = array(
    			'from_tablename' => 'FORUM_MEMBERS',
    			'from_fieldname' => 'M_SIG',
    			'to_type'        => 'user',
    			'to_fieldname'   => '_bbp_snitz_user_sig'
    		);
    
    		// 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'  => 'FORUM_MEMBERS',
    			'join_type'       => 'INNER',
    			'join_expression' => 'USING users_profile_table.MEMBER_ID = FORUM_MEMBERS.MEMBER_ID',
    			'from_expression' => 'WHERE FORUM_MEMBERS.MEMBER_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'] ) );
    	}
      
      
    	/**
    	 * Translate the forum status from Snitz v3.x numeric's to WordPress's strings.
    	 *
    	 * @param int $status Snitz v3.x numeric forum status
    	 * @return string WordPress safe
    	 */
    	public function callback_forum_status( $status = 1 ) {
    		switch ( $status ) {
    			case 0 :
    				$status = 'closed';     // Snitz forum status closed 'F_STATUS = 0'
    				break;
    
    			case 1 :
    			default :
    				$status = 'open';       // Snitz forum status open 'F_STATUS = 1'
    				break;
    		}
    		return $status;
    	}
    
    	/**
    	 * Translate the topic status from Snitz v3.x numeric's to WordPress's strings.
    	 *
    	 * @param int $status Snitz v3.x numeric topic status
    	 * @return string WordPress safe
    	 */
    	public function callback_topic_status( $status = 1 ) {
    		switch ( $status ) {
    			case 0 :
    				$status = 'closed';     // Snitz topic status closed 'T_STATUS = 0'
    				break;
    
    			case 1 :
    			default :
    				$status = 'publish';    // Snitz topic status open 'T_STATUS = 1'
    				break;
    		}
    		return $status;
    	}
    
    	/**
    	 * Translate the topic sticky status type from Snitz 3.x numeric's to WordPress's strings.
    	 *
    	 * @param int $status Snitz 3.x numeric forum type
    	 * @return string WordPress safe
    	 */
    	public function callback_sticky_status( $status = 0 ) {
    		switch ( $status ) {
    			case 1 :
    				$status = 'sticky';       // Snitz Sticky 'T_STICKY = 1'
    				break;
    
    			case 0  :
    			default :
    				$status = 'normal';       // Snitz normal topic 'T_STICKY = 0'
    				break;
    		}
    		return $status;
    	}
    }
    
    

    Robin W
    Moderator

    @robin-w

    ok cabn you try it, but taking out

    // Setup any table joins needed for the topic section
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_REPLY',
    			'from_fieldname'  => 'TOPIC_ID',
    			'join_tablename'  => 'FORUM_TOPICS',
    			'join_type'       => 'INNER',
    			'join_expression' => 'USING FORUM_REPLY.TOPIC_ID = FORUM_TOPICS.TOPIC_ID',
    			'from_expression' => 'WHERE FORUM_FORUM.TOPIC_ID = 0',
    			'to_type'         => 'topic'
    		);

    stefyonweb
    Participant

    @stefyonweb

    Hi Robin, thanks for your efforts.
    It seems the problem with forum table was a field: “FORUM_ORDER” instead of “F_ORDER”.
    Now forum table is ok, I’m going to check out every single field.
    I’ll keep you updated 🙂


    Robin W
    Moderator

    @robin-w

    thanks, please do keep us updated, and we’ll add a final working version to this thread if/when you suceed!

    Unfortunately I didn’t keep a copy of mine when I did it.


    stefyonweb
    Participant

    @stefyonweb

    Hi again, it seems I managed to import the database, but I get a weird error message in front end: [Incorrect DATETIME value: ‘0’]
    SELECT p.ID FROM wp_posts AS p WHERE p.post_date > ‘0’ AND p.post_type = ‘forum’ AND ( p.post_status = ‘publish’ OR p.post_status = ‘private’ OR p.post_status = ‘hidden’ ) ORDER BY p.post_date ASC LIMIT 1

    Apparently import was ok. Here’s the code.

    <?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 snitz 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'  => 'FORUM_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_FORUM',
    			'from_fieldname'  => 'CAT_ID',
    			'to_type'         => 'forum',
    			'to_fieldname'    => '_bbp_old_forum_parent_id'
    		);
    
    		// Forum topic count (Stored in postmeta)
    		$this->field_map[] = array(
    			'from_tablename' => 'FORUM_FORUM',
    			'from_fieldname' => 'F_TOPICS',
    			'to_type'        => 'forum',
    			'to_fieldname'   => '_bbp_topic_count'
    		);
    
    		// Forum reply count (Stored in postmeta)
    		$this->field_map[] = array(
    			'from_tablename' => 'FORUM_FORUM',
    			'from_fieldname' => 'F_COUNT',
    			'to_type'        => 'forum',
    			'to_fieldname'   => '_bbp_reply_count'
    		);
    
    		// Forum total topic count (Stored in postmeta)
    		$this->field_map[] = array(
    			'from_tablename' => 'FORUM_FORUM',
    			'from_fieldname' => 'F_TOPICS',
    			'to_type'        => 'forum',
    			'to_fieldname'   => '_bbp_total_topic_count'
    		);
    
    		// Forum total reply count (Stored in postmeta)
    		$this->field_map[] = array(
    			'from_tablename' => 'FORUM_FORUM',
    			'from_fieldname' => 'F_COUNT',
    			'to_type'        => 'forum',
    			'to_fieldname'   => '_bbp_total_reply_count'
    		);
    
    		// Forum title.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_FORUM',
    			'from_fieldname'  => 'F_SUBJECT',
    			'to_type'         => 'forum',
    			'to_fieldname'    => 'post_title'
    		);
    
    		// Forum slug (Clean name to avoid confilcts)
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_FORUM',
    			'from_fieldname'  => 'F_SUBJECT',
    			'to_type'         => 'forum',
    			'to_fieldname'    => 'post_name',
    			'callback_method' => 'callback_slug'
    		);
    
    		// Forum description.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_FORUM',
    			'from_fieldname'  => 'F_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_FORUM',
    			'from_fieldname'  => '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'  => 'FORUM_FORUM',
    	//		'from_fieldname'  => 'the_forum_type',
    			'to_type'         => 'forum',
    			'to_fieldname'    => '_bbp_forum_type',
    		//	'callback_method' => 'callback_forum_type'
           'default'      => 'forum'
    		);
    
    		// Forum status (Unlocked = 0 or Locked = 1, Stored in postmeta)
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_FORUM',
    			'from_fieldname'  => 'F_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'  => 'FORUM_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'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_REPLIES',
    			'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'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_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_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'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_AUTHOR',
    			'to_type'         => 'topic',
    			'to_fieldname'    => 'post_author',
    			'callback_method' => 'callback_userid'
    		);
    
    		// Topic author ip (Stored in postmeta)
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_IP',
    			'to_type'         => 'topic',
    			'to_fieldname'    => '_bbp_author_ip'
    		);
    
    		// Topic content.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_MESSAGE',
    			'to_type'         => 'topic',
    			'to_fieldname'    => 'post_content',
    			'callback_method' => 'callback_html'
    		);
    
    		// Topic title.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_SUBJECT',
    			'to_type'         => 'topic',
    			'to_fieldname'    => 'post_title'
    		);
    
    		// Topic slug (Clean name to avoid conflicts)
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_SUBJECT',
    			'to_type'         => 'topic',
    			'to_fieldname'    => 'post_name',
    			'callback_method' => 'callback_slug'
    		);
    
    		// Topic status (Open or Closed)
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_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'  => 'FORUM_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'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_STICKY',
    			'to_type'         => 'topic',
    			'to_fieldname'    => '_bbp_old_sticky_status_id',
    			'callback_method' => 'callback_sticky_status'
    		);*/
        $this->field_map[] = array(
    	//		'from_tablename'  => 'FORUM_FORUM',
    	//		'from_fieldname'  => 'the_forum_type',
    			'to_type'         => 'topic',
    			'to_fieldname'    => '_bbp_old_sticky_status_id',
    		//	'callback_method' => 'callback_forum_type'
           'default'      => 'normal'
    		);
    
    		// Topic dates.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_DATE',
    			'to_type'         => 'topic',
    			'to_fieldname'    => 'post_date',
    			'callback_method' => 'callback_datetime'
    		);
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_DATE',
    			'to_type'         => 'topic',
    			'to_fieldname'    => 'post_date_gmt',
    			'callback_method' => 'callback_datetime'
    		);
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_LAST_POST',
    			'to_type'         => 'topic',
    			'to_fieldname'    => 'post_modified',
    			'callback_method' => 'callback_datetime'
    		);
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_LAST_POST',
    			'to_type'         => 'topic',
    			'to_fieldname'    => 'post_modified_gmt',
    			'callback_method' => 'callback_datetime'
    		);
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_LAST_POST',
    			'to_type'         => 'topic',
    			'to_fieldname'    => '_bbp_last_active_time',
    			'callback_method' => 'callback_datetime'
    		);
    
        $this->field_map[] = array(
    			'from_tablename'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'T_MESSAGE',
    			'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'
       );
        
    		// Setup any table joins needed for the topic section
    	/*	$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_REPLY',
    			'from_fieldname'  => 'TOPIC_ID',
    			'join_tablename'  => 'FORUM_TOPICS',
    			'join_type'       => 'INNER',
    			'join_expression' => 'USING FORUM_REPLY.TOPIC_ID = FORUM_TOPICS.TOPIC_ID',
    			'from_expression' => 'WHERE FORUM_FORUM.TOPIC_ID = 0',
    			'to_type'         => 'topic'
    		);*/
        
        
    
    		/** Tags Section ******************************************************/
    
    		
    
    		/** Topic Subscriptions Section ***************************************/
    
    		/** Favorites Section *************************************************/
    
    		// Favorited topic ID (Stored in usermeta)
    
    		/** 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'  => 'FORUM_REPLY',
    			'from_fieldname'  => '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'  => 'FORUM_REPLY',
    			'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'  => 'FORUM_REPLY',
    			'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'  => 'FORUM_REPLY',
    			'from_fieldname'  => 'R_IP',
    			'to_type'         => 'reply',
    			'to_fieldname'    => '_bbp_author_ip'
    		);
    
    		// Reply author.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_REPLY',
    			'from_fieldname'  => 'R_AUTHOR',
    			'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'  => 'FORUM_REPLY',
    			'from_fieldname'  => 'R_MESSAGE',
    			'to_type'         => 'reply',
    			'to_fieldname'    => 'post_content',
    			'callback_method' => 'callback_html'
    		);
    
    	/* Snizt doesnt use reply order
    		// Reply order.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_REPLY',
    			'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'  => 'FORUM_REPLY',
    			'from_fieldname'  => 'TOPIC_ID',
    			'to_type'         => 'reply',
    			'to_fieldname'    => 'post_parent',
    			'callback_method' => 'callback_topicid'
    		);
    
    		// Reply dates.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_REPLY',
    			'from_fieldname'  => 'R_DATE',
    			'to_type'         => 'reply',
    			'to_fieldname'    => 'post_date',
    			'callback_method' => 'callback_datetime'
    		);
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_REPLY',
    			'from_fieldname'  => 'R_DATE',
    			'to_type'         => 'reply',
    			'to_fieldname'    => 'post_date_gmt',
    			'callback_method' => 'callback_datetime'
    		);
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_REPLY',
    			'from_fieldname'  => 'R_DATE',
    			'to_type'         => 'reply',
    			'to_fieldname'    => 'post_modified',
    			'callback_method' => 'callback_datetime'
    		);
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_REPLY',
    			'from_fieldname'  => 'R_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'  => 'FORUM_TOPICS',
    			'from_fieldname'  => 'TOPIC_ID',
    			'join_tablename'  => 'FORUM_REPLY',
    			'join_type'       => 'INNER',
    			'join_expression' => 'USING FORUM_TOPICS.TOPIC_ID = FORUM_REPLY.TOPIC_ID',
    			'from_expression' => 'WHERE FORUM_TOPICS.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'  => 'FORUM_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'  => 'FORUM_MEMBERS',
    			'from_fieldname'  => 'M_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'  => 'FORUM_MEMBERS',
    			'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'  => 'FORUM_MEMBERS',
    			'from_fieldname'  => 'M_NAME',
    			'to_type'         => 'user',
    			'to_fieldname'    => 'user_login'
    		);
    
    		// User nice name.
    		$this->field_map[] = array(
    			'from_tablename' => 'FORUM_MEMBERS',
    			'from_fieldname' => 'M_NAME',
    			'to_type'        => 'user',
    			'to_fieldname'   => 'user_nicename'
    		);
    
    		// User email.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_MEMBERS',
    			'from_fieldname'  => 'M_EMAIL',
    			'to_type'         => 'user',
    			'to_fieldname'    => 'user_email'
    		);
    
    		// User homepage.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_MEMBERS',
    			'from_fieldname'  => 'M_HOMEPAGE',
    			'to_type'         => 'user',
    			'to_fieldname'    => 'user_url'
    		);
    
    		/* Snitz doesn't use user registered
    		// User registered.
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_MEMBERS',
    			'from_fieldname'  => 'the_users_registration_date',
    			'to_type'         => 'user',
    			'to_fieldname'    => 'user_registered',
    			'callback_method' => 'callback_datetime'
    		);
    */
    /* Snitz doesn't use user status
    		// User status.
    		$this->field_map[] = array(
    			'from_tablename' => 'FORUM_MEMBERS',
    			'from_fieldname' => 'the_users_status',
    			'to_type'        => 'user',
    			'to_fieldname'   => 'user_status'
    		);
    */
    
    		// User display name.
    		$this->field_map[] = array(
    			'from_tablename' => 'FORUM_MEMBERS',
    			'from_fieldname' => 'M_NAME',
    			'to_type'        => 'user',
    			'to_fieldname'   => 'display_name'
    		);
    
    		// User Profile Field 1 (Stored in usermeta)
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_MEMBERS',
    			'from_fieldname'  => 'M_AIM',
    			'to_type'         => 'user',
    			'to_fieldname'    => 'aim'
    		);
    
    		// User Profile Field 2 (Stored in usermeta)
    		$this->field_map[] = array(
    			'from_tablename'  => 'FORUM_MEMBERS',
    			'from_fieldname'  => 'M_YAHOO',
    			'to_type'         => 'user',
    			'to_fieldname'    => 'yim'
    		);
    
    		// User Profile Field 3 (Stored in usermeta)
    		$this->field_map[] = array(
    			'from_tablename' => 'FORUM_MEMBERS',
    			'from_fieldname' => 'M_SIG',
    			'to_type'        => 'user',
    			'to_fieldname'   => '_bbp_snitz_user_sig'
    		);
    
    		// 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'  => 'FORUM_MEMBERS',
    			'join_type'       => 'INNER',
    			'join_expression' => 'USING users_profile_table.MEMBER_ID = FORUM_MEMBERS.MEMBER_ID',
    			'from_expression' => 'WHERE FORUM_MEMBERS.MEMBER_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'] ) );
    	}
      
      
    	/**
    	 * Translate the forum status from Snitz v3.x numeric's to WordPress's strings.
    	 *
    	 * @param int $status Snitz v3.x numeric forum status
    	 * @return string WordPress safe
    	 */
    	public function callback_forum_status( $status = 1 ) {
    		switch ( $status ) {
    			case 0 :
    				$status = 'closed';     // Snitz forum status closed 'F_STATUS = 0'
    				break;
    
    			case 1 :
    			default :
    				$status = 'open';       // Snitz forum status open 'F_STATUS = 1'
    				break;
    		}
    		return $status;
    	}
    
    	/**
    	 * Translate the topic status from Snitz v3.x numeric's to WordPress's strings.
    	 *
    	 * @param int $status Snitz v3.x numeric topic status
    	 * @return string WordPress safe
    	 */
    	public function callback_topic_status( $status = 1 ) {
    		switch ( $status ) {
    			case 0 :
    				$status = 'closed';     // Snitz topic status closed 'T_STATUS = 0'
    				break;
    
    			case 1 :
    			default :
    				$status = 'publish';    // Snitz topic status open 'T_STATUS = 1'
    				break;
    		}
    		return $status;
    	}
    
    	/**
    	 * Translate the topic sticky status type from Snitz 3.x numeric's to WordPress's strings.
    	 *
    	 * @param int $status Snitz 3.x numeric forum type
    	 * @return string WordPress safe
    	 */
    	public function callback_sticky_status( $status = 0 ) {
    		switch ( $status ) {
    			case 1 :
    				$status = 'sticky';       // Snitz Sticky 'T_STICKY = 1'
    				break;
    
    			case 0  :
    			default :
    				$status = 'normal';       // Snitz normal topic 'T_STICKY = 0'
    				break;
    		}
    		return $status;
    	}
    }
    
    
Viewing 25 replies - 26 through 50 (of 57 total)
  • You must be logged in to reply to this topic.
Skip to toolbar