Skip to:
Content

bbPress.org

Changeset 5572


Ignore:
Timestamp:
11/22/2014 12:33:02 PM (11 years ago)
Author:
netweb
Message:

bbPress 1.x importer: Include Subscribed Topics and Favourite Topics
Props netweb. See #2668

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/admin/converters/bbPress1.php

    r5570 r5572  
    149149        );
    150150
     151        /** Forum Subscriptions Section ***************************************/
     152
     153        /**
     154         * bbPress 1.x Forums do not support forum subscriptions
     155         */
     156
    151157        /** Topic Section *****************************************************/
    152158
     
    363369            'to_fieldname'    => 'slug',
    364370            'callback_method' => 'callback_slug'
     371        );
     372
     373        /** Topic Subscriptions Section ***************************************/
     374
     375        // Subscribed user ID (Stored in usermeta)
     376        $this->field_map[] = array(
     377            'from_tablename'  => 'term_relationships',
     378            'from_fieldname'  => 'user_id',
     379            'to_type'         => 'topic_subscriptions',
     380            'to_fieldname'    => 'user_id',
     381            'callback_method' => 'callback_userid'
     382        );
     383
     384        // Join the 'term_taxonomy' table to link 'terms' 'term_relationships' tables
     385        $this->field_map[] = array(
     386            'from_tablename'  => 'term_taxonomy',
     387            'from_fieldname'  => 'term_taxonomy_id',
     388            'join_tablename'  => 'term_relationships',
     389            'join_type'       => 'INNER',
     390            'join_expression' => 'USING (term_taxonomy_id)',
     391            'to_type'         => 'topic_subscriptions'
     392        );
     393
     394        // Subscribed topic ID (Stored in usermeta)
     395        $this->field_map[] = array(
     396            'from_tablename'  => 'terms',
     397            'from_fieldname'  => 'name',
     398            'join_tablename'  => 'term_taxonomy',
     399            'join_type'       => 'INNER',
     400            'join_expression' => 'USING (term_id) WHERE term_taxonomy.taxonomy = "bb_subscribe"',
     401            'to_type'         => 'topic_subscriptions',
     402            'to_fieldname'    => '_bbp_subscriptions',
     403            'callback_method' => 'callback_topic_subscriptions'
     404        );
     405
     406        /** Favorites Section *************************************************/
     407
     408        // Favorited topic ID (Stored in usermeta)
     409        $this->field_map[] = array(
     410            'from_tablename'  => 'usermeta',
     411            'from_fieldname'  => 'meta_value',
     412            'from_expression' => 'WHERE usermeta.meta_key = "bb_favorites"',
     413            'to_type'         => 'favorites',
     414            'to_fieldname'    => '_bbp_favorites'
     415        );
     416
     417        // Favorited user ID (Stored in usermeta)
     418        $this->field_map[] = array(
     419            'from_tablename'  => 'usermeta',
     420            'from_fieldname'  => 'user_id',
     421            'from_expression' => 'WHERE usermeta.meta_key = "bb_favorites"',
     422            'to_type'         => 'favorites',
     423            'to_fieldname'    => 'user_id',
     424            'callback_method' => 'callback_userid'
    365425        );
    366426
     
    672732
    673733    /**
     734     * This callback strips `topic-` from topic subscriptions taxonomy
     735     *
     736     * @since (r5572)
     737     *
     738     * @param string $field Topic ID
     739     * @return integer WordPress safe
     740     */
     741    protected function callback_topic_subscriptions( $field ) {
     742
     743        // Replace 'topic-' with '' so that only the original topic ID remains
     744        $field = absint( (int) preg_replace( '/(topic-)(\d+)/', '$2', $field ) );
     745        return $field;
     746    }
     747
     748    /**
    674749     * This callback:
    675750     *
Note: See TracChangeset for help on using the changeset viewer.