Skip to:
Content

bbPress.org

Changeset 5153


Ignore:
Timestamp:
11/12/2013 08:08:30 AM (7 years ago)
Author:
netweb
Message:

vBulletin v4.x Importer Improvements. Props netweb. Fixes #2469

  • Added Forum total topic count
  • Added Forum total reply count
  • Added Forum/Category type field mapping & callback
  • Added Topic total reply count
  • Added Topic author ip
  • Added Store old user salt in usermeta
  • Added Reply slug
  • Improved inline docs
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/admin/converters/vBulletin.php

    r4824 r5153  
    5858        );
    5959
     60        // Forum total topic count (Includes unpublished topics, Stored in postmeta)
     61        $this->field_map[] = array(
     62            'from_tablename'  => 'forum',
     63            'from_fieldname'  => 'threadcount',
     64            'to_type'         => 'forum',
     65            'to_fieldname'    => '_bbp_total_topic_count'
     66        );
     67
     68        // Forum total reply count (Includes unpublished replies, Stored in postmeta)
     69        $this->field_map[] = array(
     70            'from_tablename'  => 'forum',
     71            'from_fieldname'  => 'replycount',
     72            'to_type'         => 'forum',
     73            'to_fieldname'    => '_bbp_total_reply_count'
     74        );
     75
    6076        // Forum title.
    6177        $this->field_map[] = array(
     
    92108        );
    93109
     110        // Forum type (Category = -1 or Forum > 0, Stored in postmeta)
     111        $this->field_map[] = array(
     112            'from_tablename'  => 'forum',
     113            'from_fieldname'  => 'parentid',
     114            'to_type'         => 'forum',
     115            'to_fieldname'    => '_bbp_forum_type',
     116            'callback_method' => 'callback_forum_type'
     117        );
     118
    94119        // Forum dates.
    95120        $this->field_map[] = array(
     
    142167        );
    143168
     169        // Topic total reply count (Includes unpublished replies, Stored in postmeta)
     170        $this->field_map[] = array(
     171            'from_tablename'  => 'thread',
     172            'from_fieldname'  => 'replycount',
     173            'to_type'         => 'topic',
     174            'to_fieldname'    => '_bbp_total_reply_count',
     175            'callback_method' => 'callback_topic_reply_count'
     176        );
     177
    144178        // Topic author.
    145179        $this->field_map[] = array(
     
    149183            'to_fieldname'    => 'post_author',
    150184            'callback_method' => 'callback_userid'
     185        );
     186
     187        // Topic Author ip (Stored in postmeta)
     188        // Note: We join the 'post' table because 'thread' table does not include topic content.
     189        $this->field_map[] = array(
     190            'from_tablename'  => 'post',
     191            'from_fieldname'  => 'ipaddress',
     192            'join_tablename'  => 'thread',
     193            'join_type'       => 'INNER',
     194            'join_expression' => 'USING (threadid) WHERE post.parentid = 0',
     195            'to_type'         => 'topic',
     196            'to_fieldname'    => '_bbp_author_ip'
    151197        );
    152198
     
    178224
    179225        // Topic content.
    180         // Note: We join the posts table because topics do not have content.
     226        // Note: We join the 'post' table because 'thread' table does not include topic content.
    181227        $this->field_map[] = array(
    182228            'from_tablename'  => 'post',
     
    277323
    278324        // Reply parent forum id (If no parent, then 0. Stored in postmeta)
     325        // Note: We join the 'thread' table because 'post' table does not include forum id.
    279326        $this->field_map[] = array(
    280327            'from_tablename'  => 'thread',
     
    288335        );
    289336
    290         // Reply parent topic id (If no parent, then 0. Stored in postmeta)
     337        // Reply parent topic id (If no parent, then 0, Stored in postmeta)
    291338        $this->field_map[] = array(
    292339            'from_tablename'  => 'post',
     
    315362
    316363        // Reply title.
    317         // Note: We join the thread table because post table does not include topic title.
     364        // Note: We join the 'thread' table because 'post' table does not include reply title.
    318365        $this->field_map[] = array(
    319366            'from_tablename'  => 'thread',
     
    326373            'callback_method' => 'callback_reply_title'
    327374        );
     375
     376        // Reply slug (Clean name to avoid conflicts)
     377        // Note: We join the 'thread' table because 'post' table does not include reply slug.
     378        $this->field_map[] = array(
     379            'from_tablename'  => 'thread',
     380            'from_fieldname'  => 'title',
     381            'join_tablename'  => 'post',
     382            'join_type'       => 'INNER',
     383            'join_expression' => 'USING (threadid) WHERE post.parentid != 0',
     384            'to_type'         => 'reply',
     385            'to_fieldname'    => 'post_name',
     386            'callback_method' => 'callback_slug'
     387        );
    328388
    329389        // Reply content.
     
    399459            'from_fieldname' => 'salt',
    400460            'to_type'        => 'user',
    401             'to_fieldname'   => ''
     461            'to_fieldname'   => '_bbp_salt'
    402462        );
    403463
     
    498558     */
    499559    public function callback_savepass( $field, $row ) {
    500         $pass_array = array( 'hash'  => $field, 'salt'  => $row['salt'] );
     560        $pass_array = array( 'hash' => $field, 'salt' => $row['salt'] );
    501561        return $pass_array;
    502562    }
     
    506566     * to a pass the user has typed in.
    507567     *
    508      * vBulletin passwords do not work. Maybe use the below plugin's approach?
    509      *
    510      * @link http://wordpress.org/extend/plugins/vb-user-copy/
    511      * @link http://plugins.trac.wordpress.org/browser/vb-user-copy/trunk/vb_user_copy.php
    512568     */
    513569    public function authenticate_pass( $password, $serialized_pass ) {
    514570        $pass_array = unserialize( $serialized_pass );
    515571        return ( $pass_array['hash'] == md5( md5( $password ) . $pass_array['salt'] ) );
     572    }
     573
     574    /**
     575     * Translate the forum type from vBulletin v4.x numeric's to WordPress's strings.
     576     *
     577     * @param int $status vBulletin v4.x numeric forum type
     578     * @return string WordPress safe
     579     */
     580    public function callback_forum_type( $status = 0 ) {
     581        if ( $status == -1 ) {
     582            $status = 'category';
     583        } else {
     584            $status = 'forum';
     585        }
     586        return $status;
    516587    }
    517588
Note: See TracChangeset for help on using the changeset viewer.