Plugin Directory

Changeset 472197


Ignore:
Timestamp:
12/07/2011 09:36:25 PM (14 years ago)
Author:
anointed
Message:

1.2

  • Fixed Cleaning slow down.
  • Much Faster importing now if mysql table editing is available.
  • Fixed duplicate first post/reply on topics
  • Fixed Issue with Different charset from UTF-8
  • Added more info messages
Location:
bbconverter/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • bbconverter/trunk/bbc-convert/Example.php

    r444891 r472197  
    55Description: Convert Example forum software into bbpress.
    66Author: Adam Ellis
    7 Version: 1.1
     7Version: 1.2
    88Author URI: http://www.bbconverter.com/
    99*/
  • bbconverter/trunk/bbc-convert/Invision.php

    r444891 r472197  
    55Description: Convert Invision Power Board forum software into bbpress.
    66Author: Adam Ellis
    7 Version: 1.1
     7Version: 1.2
    88Author URI: http://www.bbconverter.com/
    99*/
     
    106106            'translate_method' => 'translate_userid'
    107107        );
     108           
     109        // Topic content.
     110        $this->field_map[] = array(
     111            'from_tablename' => 'posts', 'from_fieldname' => 'post',
     112            'join_tablename' => 'topics', 'join_type' => 'INNER', 'join_expression' => 'ON(topics.tid = posts.topic_id) WHERE posts.new_topic = 1',
     113            'to_type' => 'topic', 'to_fieldname' => 'post_content',
     114            'translate_method' => 'translate_html'
     115        ); 
    108116       
    109117        // Topic title.
     
    168176        // Post id. Stores in postmeta.
    169177        $this->field_map[] = array(
    170             'from_tablename' => 'posts', 'from_fieldname' => 'pid',
     178            'from_tablename' => 'posts', 'from_fieldname' => 'pid', 'from_expression' => 'WHERE posts.new_topic = 1',
    171179            'to_type' => 'reply', 'to_fieldname' => '_bbc_post_id'
    172180        );
  • bbconverter/trunk/bbc-convert/Standalonebbpress.php

    r444891 r472197  
    55Description: Convert bbPress Stand Alone forum software into bbpress plugin.
    66Author: Adam Ellis
    7 Version: 1.1
     7Version: 1.2
    88Author URI: http://www.bbconverter.com/
    99*/
     
    107107        );
    108108       
     109        // Topic content.
     110        $this->field_map[] = array(
     111            'from_tablename' => 'posts', 'from_fieldname' => 'post_text',
     112            'join_tablename' => 'topics', 'join_type' => 'INNER', 'join_expression' => 'USING (topic_id) WHERE posts.post_position = 1',
     113            'to_type' => 'topic', 'to_fieldname' => 'post_content',
     114            'translate_method' => 'translate_html'
     115        ); 
     116               
    109117        // Topic title.
    110118        $this->field_map[] = array(
     
    172180        // Post id. Stores in postmeta.
    173181        $this->field_map[] = array(
    174             'from_tablename' => 'posts', 'from_fieldname' => 'post_id',
     182            'from_tablename' => 'posts', 'from_fieldname' => 'post_id', 'from_expression' => 'WHERE posts.post_position != 1',
    175183            'to_type' => 'reply', 'to_fieldname' => '_bbc_post_id'
    176184        );
  • bbconverter/trunk/bbc-convert/Vbulletin.php

    r444891 r472197  
    55Description: Convert vBulletin forum software into bbpress.
    66Author: Adam Ellis
    7 Version: 1.1
     7Version: 1.2
    88Author URI: http://www.bbconverter.com/
    99*/
     
    106106            'translate_method' => 'translate_userid'
    107107        );
    108        
     108
     109        // Topic content.
     110        $this->field_map[] = array(
     111            'from_tablename' => 'post', 'from_fieldname' => 'pagetext',
     112            'join_tablename' => 'thread', 'join_type' => 'INNER', 'join_expression' => 'USING (threadid) WHERE post.parentid = 0',
     113            'to_type' => 'topic', 'to_fieldname' => 'post_content',
     114            'translate_method' => 'translate_html'
     115        ); 
     116
    109117        // Topic title.
    110118        $this->field_map[] = array(
     
    169177        // Post id. Stores in postmeta.
    170178        $this->field_map[] = array(
    171             'from_tablename' => 'post', 'from_fieldname' => 'postid',
     179            'from_tablename' => 'post', 'from_fieldname' => 'postid', 'from_expression' => 'WHERE post.parentid != 0',
    172180            'to_type' => 'reply', 'to_fieldname' => '_bbc_post_id'
    173181        );
  • bbconverter/trunk/bbc-includes/bbc-converter-class.php

    r444891 r472197  
    55Description: bbConverter Class
    66Author: Adam Ellis
    7 Version: 1.1
     7Version: 1.2
    88Author URI: http://www.bbconverter.com/
    99*/
     
    8787     */
    8888    private $map_userid = array();
    89        
     89
     90    /**
     91     * @var str This is the charset for your wp database.
     92     */
     93    public $charset;
     94   
     95    /**
     96     * @var boolean Sync table available.
     97     */
     98    public $sync_table = false;
     99
     100    /**
     101     * @var str Sync table name.
     102     */
     103    public $sync_table_name;   
     104   
    90105    /**
    91106     * This is the constructor and it connects to the platform databases.
     
    106121        $this->opdb = new wpdb( $_POST['_bbc_dbuser'], $_POST['_bbc_dbpass'], $_POST['_bbc_dbname'], $_POST['_bbc_dbserver'] );
    107122        $this->opdb->prefix = $_POST['_bbc_dbprefix'];
     123       
     124        /**
     125         * Error Reporting
     126         */
    108127        $this->wpdb->show_errors();
    109128        $this->opdb->show_errors();
    110 
     129       
     130        /**
     131         * Syncing
     132         */
     133        $this->sync_table_name = $this->wpdb->prefix . "bbconverter_translator";
     134        if( $this->wpdb->get_var( "SHOW TABLES LIKE '" . $this->sync_table_name . "'" ) == $this->sync_table_name )
     135        {
     136            $this->sync_table = true;
     137        }
     138        else
     139        {
     140            $this->sync_table = false;
     141        }   
     142           
     143        /**
     144         * Charset
     145         */
     146        if( empty( $this->wpdb->charset ) )
     147        {
     148            $this->charset = "UTF8";
     149        }
     150        else
     151        {
     152            $this->charset = $this->wpdb->charset;
     153        }
     154       
    111155        /**
    112156         * Default mapping.
     
    247291    public function convert_table( $to_type, $start )
    248292    {
     293        if( $this->wpdb->get_var( "SHOW TABLES LIKE '" . $this->sync_table_name . "'" ) == $this->sync_table_name )
     294        {
     295            $this->sync_table = true;
     296        }
     297        else
     298        {
     299            $this->sync_table = false;
     300        }
    249301        $has_insert = false;
    250302        $from_tablename = '';
     
    273325                    if( !in_array( $item['from_tablename'], $from_tables ) && in_array( $item['join_tablename'], $from_tables ) )
    274326                    {
    275                         $from_tablename .= ' ' . $item['join_type'] . ' JOIN ' . $this->opdb->prefix . $item['from_tablename'] . ' ' . $item['join_expression'];
     327                        $from_tablename .= ' ' . $item['join_type'] . ' JOIN ' . $this->opdb->prefix . $item['from_tablename'] . ' AS ' . $item['from_tablename'] . ' ' . $item['join_expression'];
    276328                    }
    277329                }
    278330                else
    279331                {
    280                     $from_tablename = $item['from_tablename'];
    281                 }
     332                    $from_tablename = $item['from_tablename'] . ' AS ' . $item['from_tablename'];
     333                }   
     334                if( $item['from_expression'] )
     335                {
     336                    if( stripos( $from_tablename, "WHERE" ) === FALSE )
     337                    {
     338                        $from_tablename .= ' ' . $item['from_expression'];
     339                    }
     340                    else
     341                    {
     342                        $from_tablename .= ' ' . str_replace( "WHERE", "AND", $item['from_expression'] );
     343                    }
     344                }   
    282345                $from_tables[] = $item['from_tablename'];
    283                 $field_list[] = 'convert(' . $item['from_fieldname'] . ' USING "UTF8") AS ' . $item['from_fieldname'];
     346                $field_list[] = 'convert(' . $item['from_tablename'] . '.' . $item['from_fieldname'] . ' USING "' . $this->charset . '") AS ' . $item['from_fieldname'];
    284347            }
    285348        }
     
    360423                                    foreach( $insert_postmeta as $key => $value )
    361424                                    {
    362                                         add_user_meta( $post_id, $key, $value, true );
     425                                        //add_user_meta( $post_id, $key, $value, true );   
     426                                        if( substr( $key, -3 ) == "_id" && $this->sync_table === true )
     427                                        {
     428                                            $this->wpdb->insert( $this->sync_table_name, array( 'value_type' => 'user', 'value_id' => $post_id, 'meta_key' => $key, 'meta_value' => $value ) );
     429                                        }
     430                                        else
     431                                        {
     432                                            add_user_meta( $post_id, $key, $value, true ); 
     433                                        }
    363434                                    }   
    364435                                }                                   
     
    373444                                    foreach( $insert_postmeta as $key => $value )
    374445                                    {
    375                                         add_post_meta( $post_id, $key, $value, true );
     446                                        //add_post_meta( $post_id, $key, $value, true );
     447                                        if( substr( $key, -3 ) == "_id" && $this->sync_table === true )
     448                                        {
     449                                            $this->wpdb->insert( $this->sync_table_name, array( 'value_type' => 'post', 'value_id' => $post_id, 'meta_key' => $key, 'meta_value' => $value ) );
     450                                        }
     451                                        else
     452                                        {
     453                                            add_post_meta( $post_id, $key, $value, true );
     454                                        }
    376455                                    }   
    377456                                }                                   
     
    384463        return !$has_insert;
    385464    }
    386 
     465   
    387466    public function convert_forum_parents( $start )
    388467    {
    389468        $has_update = false;
    390         $forum_array = $this->wpdb->get_results( 'SELECT post_id, meta_value FROM ' . $this->wpdb->postmeta .
    391             ' WHERE meta_key = "_bbc_parent_id" AND meta_value > 0 LIMIT ' . $start . ', ' . $this->max_rows );
     469        if( $this->sync_table )
     470        {
     471            $forum_array = $this->wpdb->get_results( 'SELECT value_id, meta_value FROM ' . $this->sync_table_name .
     472                ' WHERE meta_key = "_bbc_parent_id" AND meta_value > 0 LIMIT ' . $start . ', ' . $this->max_rows );
     473        }
     474        else
     475        {
     476            $forum_array = $this->wpdb->get_results( 'SELECT post_id AS value_id, meta_value FROM ' . $this->wpdb->postmeta .
     477                ' WHERE meta_key = "_bbc_parent_id" AND meta_value > 0 LIMIT ' . $start . ', ' . $this->max_rows );
     478        }
    392479        foreach( $forum_array as $row )
    393480        {
    394481            $parent_id = $this->translate_forumid( $row->meta_value );
    395482            $this->wpdb->query( 'UPDATE ' . $this->wpdb->posts . ' SET post_parent = "' .
    396                 $parent_id . '" WHERE ID = "' . $row->post_id . '" LIMIT 1' );
     483                $parent_id . '" WHERE ID = "' . $row->value_id . '" LIMIT 1' );
    397484            $has_update = true;
    398485        }
     
    409496        /** Delete bbconverter topics/forums/posts ****************************/
    410497       
    411         $bbconverter = $this->wpdb->get_results( 'SELECT post_id FROM ' . $this->wpdb->postmeta . ' WHERE meta_key LIKE "_bbc_%" GROUP BY post_id LIMIT ' . $this->max_rows, ARRAY_A );
     498        if( $this->sync_table === true )
     499        {
     500            $bbconverter = $this->wpdb->get_results( 'SELECT value_id FROM ' . $this->sync_table_name . ' INNER JOIN ' . $this->wpdb->posts . ' ON(value_id = ID)WHERE meta_key LIKE "_bbc_%" AND value_type = "post" GROUP BY value_id ORDER BY value_id DESC LIMIT ' . $this->max_rows, ARRAY_A );
     501        }
     502        else
     503        {
     504            $bbconverter = $this->wpdb->get_results( 'SELECT post_id as value_id FROM ' . $this->wpdb->postmeta . ' WHERE meta_key LIKE "_bbc_%" GROUP BY post_id ORDER BY post_id DESC LIMIT ' . $this->max_rows, ARRAY_A );
     505        }
     506       
    412507        if( $bbconverter )
    413508        {
    414509            foreach( $bbconverter as $value )
    415510            {
    416                 wp_delete_post( $value['post_id'], true );
     511                wp_delete_post( $value['value_id'], true );
    417512            }
    418513            $has_delete = true;
     
    420515       
    421516        /** Delete bbconverter users ******************************************/
    422 
    423         $bbconverter = $this->wpdb->get_results( 'SELECT user_id FROM ' . $this->wpdb->usermeta . ' WHERE meta_key = "_bbc_user_id" LIMIT ' . $this->max_rows, ARRAY_A );
     517       
     518        if( $this->sync_table === true )
     519        {
     520            $bbconverter = $this->wpdb->get_results( 'SELECT value_id FROM ' . $this->sync_table_name . ' INNER JOIN ' . $this->wpdb->users . ' ON(value_id = ID) WHERE meta_key = "_bbc_user_id" AND value_type = "user" LIMIT ' . $this->max_rows, ARRAY_A );
     521        }
     522        else
     523        {
     524            $bbconverter = $this->wpdb->get_results( 'SELECT user_id as value_id FROM ' . $this->wpdb->usermeta . ' WHERE meta_key = "_bbc_user_id" LIMIT ' . $this->max_rows, ARRAY_A );
     525        }
     526       
    424527        if( $bbconverter )
    425528        {
    426529            foreach( $bbconverter as $value )
    427530            {           
    428                 wp_delete_user( $value['user_id'] );
     531                wp_delete_user( $value['value_id'] );
    429532            }
    430533            $has_delete = true;
    431534        }
     535       
    432536        return !$has_delete;
    433537    }
     
    527631        if( !isset( $this->map_forumid[$field] ) ) //This is a mini cache system to reduce database calls.
    528632        {
    529             $row = $this->wpdb->get_row( 'SELECT post_id FROM ' . $this->wpdb->postmeta .
    530                 ' WHERE meta_key = "_bbc_forum_id" AND meta_value = "' . $field .
    531                 '" LIMIT 1' );
     633            if( $this->sync_table )
     634            {
     635                $row = $this->wpdb->get_row( 'SELECT value_id, meta_value FROM ' . $this->sync_table_name .
     636                    ' WHERE meta_key = "_bbc_forum_id" AND meta_value = "' . $field .
     637                    '" LIMIT 1' );
     638            }
     639            else
     640            {
     641                $row = $this->wpdb->get_row( 'SELECT post_id AS value_id FROM ' . $this->wpdb->postmeta .
     642                    ' WHERE meta_key = "_bbc_forum_id" AND meta_value = "' . $field .
     643                    '" LIMIT 1' );
     644            }           
    532645            if( !is_null( $row ) )
    533646            {
    534                 $this->map_forumid[$field] = $row->post_id;
     647                $this->map_forumid[$field] = $row->value_id;
    535648            }
    536649            else
     
    546659        if( !isset( $this->map_topicid[$field] ) ) //This is a mini cache system to reduce database calls.
    547660        {
    548             $row = $this->wpdb->get_row( 'SELECT post_id FROM ' . $this->wpdb->postmeta .
    549                 ' WHERE meta_key = "_bbc_topic_id" AND meta_value = "' . $field .
    550                 '" LIMIT 1' );
     661            if( $this->sync_table )
     662            {
     663                $row = $this->wpdb->get_row( 'SELECT value_id, meta_value FROM ' . $this->sync_table_name .
     664                    ' WHERE meta_key = "_bbc_topic_id" AND meta_value = "' . $field .
     665                    '" LIMIT 1' );
     666            }
     667            else
     668            {
     669                $row = $this->wpdb->get_row( 'SELECT post_id AS value_id FROM ' . $this->wpdb->postmeta .
     670                    ' WHERE meta_key = "_bbc_topic_id" AND meta_value = "' . $field .
     671                    '" LIMIT 1' );
     672            }                   
    551673            if( !is_null( $row ) )
    552674            {
    553                 $this->map_topicid[$field] = $row->post_id;
     675                $this->map_topicid[$field] = $row->value_id;
    554676            }
    555677            else
     
    565687        if( !isset( $this->map_userid[$field] ) ) //This is a mini cache system to reduce database calls.
    566688        {
    567             $row = $this->wpdb->get_row( 'SELECT user_id FROM ' . $this->wpdb->usermeta .
    568                 ' WHERE meta_key = "_bbc_user_id" AND meta_value = "' . $field .
    569                 '" LIMIT 1' );
     689            if( $this->sync_table )
     690            {
     691                $row = $this->wpdb->get_row( 'SELECT value_id, meta_value FROM ' . $this->sync_table_name .
     692                    ' WHERE meta_key = "_bbc_user_id" AND meta_value = "' . $field .
     693                    '" LIMIT 1' );
     694            }
     695            else
     696            {
     697                $row = $this->wpdb->get_row( 'SELECT user_id AS value_id FROM ' . $this->wpdb->usermeta .
     698                    ' WHERE meta_key = "_bbc_user_id" AND meta_value = "' . $field .
     699                    '" LIMIT 1' );
     700            }               
    570701            if( !is_null( $row ) )
    571702            {
    572                 $this->map_userid[$field] = $row->user_id;
     703                $this->map_userid[$field] = $row->value_id;
    573704            }
    574705            else
     
    590721    {
    591722        $topicid = $this->translate_topicid( $field );
    592         if( !isset( $this->map_topicid_to_forumid[$field] ) ) //This is a mini cache system to reduce database calls.
     723        if( $topicid == 0 )
     724        {
     725            $this->map_topicid_to_forumid[$topicid] = 0;
     726        }
     727        else if( !isset( $this->map_topicid_to_forumid[$topicid] ) ) //This is a mini cache system to reduce database calls.
    593728        {
    594729            $row = $this->wpdb->get_row(
     
    597732            if( !is_null( $row ) )
    598733            {
    599                 $this->map_topicid_to_forumid[$field] = $row->post_parent;
     734                $this->map_topicid_to_forumid[$topicid] = $row->post_parent;
    600735            }
    601736            else
    602737            {
    603                 $this->map_topicid_to_forumid[$field] = 0;
    604             }
    605         }
    606         return $this->map_topicid_to_forumid[$field];
     738                $this->map_topicid_to_forumid[$topicid] = 0;
     739            }
     740        }
     741        return $this->map_topicid_to_forumid[$topicid];
    607742    }
    608743
  • bbconverter/trunk/bbc-includes/bbc-settings.php

    r444891 r472197  
    55Description: bbConverter Admin Settings
    66Author: Adam Ellis
    7 Version: 1.1
     7Version: 1.2
    88Author URI: http://www.bbconverter.com/
    99*/
     
    233233            <div class="bbc-note">
    234234                <h3>Note:</h3>
     235                For NON bbpress 1x conversions:<br/>
    235236                It is not possible to convert passwords during the conversion process. You must leave the conversion plugin active to convert passwords as people log in. It will validate using their old password and convert to wordpress encryption.
    236237            </div>
  • bbconverter/trunk/bbconverter.php

    r444891 r472197  
    55Description: bbConverter is a system that allows you to convert from many different forum software into bbpress.
    66Author: Adam Ellis
    7 Version: 1.1
     7Version: 1.2
    88Author URI: http://www.bbconverter.com/
    99*/
     
    2323     * @public string bbConverter version
    2424     */
    25     public $version = '1.1';
     25    public $version = '1.2';
    2626   
    2727    /** Paths *****************************************************************/
     
    136136
    137137        // Add link to settings page
    138         add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 10, 2 );
     138        add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 10, 2 );   
    139139    }   
    140140
     
    427427                    update_option( '_bbc_step', $bbconverter_step + 1 );
    428428                    update_option( '_bbc_start', 0 );
     429                    $this->sync_table();
     430                   
    429431                    if( !$bbconverter_start )
    430432                    {
    431                         echo 'No data to clean';       
     433                        echo 'No data to clean';   
    432434                    }                       
    433435                }
     
    442444                update_option( '_bbc_step', $bbconverter_step + 1 );
    443445                update_option( '_bbc_start', 0 );
    444                 echo 'Not Cleaning Data';      
     446                echo 'Not Cleaning Data';   
    445447            }           
    446448        }
     
    624626        }
    625627    }
     628   
     629    /**
     630     * Create Tables for fast syncing
     631     */
     632    public function sync_table( $drop = false )
     633    {
     634        global $wpdb;
     635
     636        $table_name = $wpdb->prefix . "bbconverter_translator";
     637        if( $wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) == $table_name )
     638        {
     639             $wpdb->query("DROP TABLE $table_name");
     640        }
     641        if( !$drop )
     642        {
     643            require_once( ABSPATH . '/wp-admin/includes/upgrade.php' );
     644   
     645            if( !empty( $wpdb->charset ) )
     646            {
     647                $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
     648            }
     649            if( !empty( $wpdb->collate ) )
     650            {
     651                $charset_collate .= " COLLATE $wpdb->collate";
     652            }
     653           
     654            //------ Translator -----------------------------------------------
     655            $sql = "CREATE TABLE " . $table_name . " (
     656                meta_id mediumint(8) unsigned not null auto_increment,
     657                value_type varchar(25) null,
     658                value_id bigint(20) unsigned not null default '0',
     659                meta_key varchar(25) null,
     660                meta_value varchar(25) null,
     661                PRIMARY KEY  (meta_id),
     662                KEY value_id (value_id),
     663                KEY meta_join (meta_key, meta_value)
     664            ) $charset_collate;";
     665            dbDelta($sql);
     666        }
     667    }   
    626668}
    627669
  • bbconverter/trunk/readme.txt

    r444910 r472197  
    55Requires at least: 3.2.1
    66Tested up to: 3.2.1
    7 Stable tag: 1.1
     7Stable tag: 1.2
    88
    99bbConverter is used to convert other forums to the new bbPress 2x plugin.
     
    31315. Choose the platform you want to convert from and fill in the database information. Click start
    32326. Once the conversion has completed, visit the WordPress Admin 'Tools' section and click 'Recount'
    33 7. Do NOT deactivate the plugin once it is finished as it is needed for user password management.
     337. Do NOT deactivate the plugin once it is finished as it is needed for user password management unless your coming from bbpress 1x.
    3434
    3535== Frequently Asked Questions ==
     
    4949== Changelog ==
    5050
     51= 1.2 =
     52* Fixed Cleaning slow down.
     53* Much Faster importing now if mysql table editing is available.
     54* Fixed duplicate first post/reply on topics
     55* Fixed Issue with Different charset from UTF-8
     56* Added more info messages
     57
    5158= 1.1 =
    5259* VBulletin 3x and 4x support added.
     
    6067== Upgrade Notice ==
    6168
    62 = 1.1 =
    63 In addition to Vbulletin support, a number of changes have been made under the hood.
     69= 1.2 =
     70Much faster now highly recomend updating.
Note: See TracChangeset for help on using the changeset viewer.