Skip to:
Content

bbPress.org

Changeset 5540


Ignore:
Timestamp:
09/30/2014 11:16:56 PM (10 years ago)
Author:
netweb
Message:

Drupal7: Add support for importing Drupal v7.x pending topics and replies. See #2645

File:
1 edited

Legend:

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

    r5536 r5540  
    205205        );
    206206
     207        // Topic status (Publish or Unpublished, Drupal v7.x publish = 1, pending = 0)
     208        $this->field_map[] = array(
     209            'from_tablename'  => 'node',
     210            'from_fieldname'  => 'status',
     211            'join_tablename'  => 'forum_index',
     212            'join_type'       => 'INNER',
     213            'join_expression' => 'ON node.nid = forum_index.nid',
     214            'to_type'         => 'topic',
     215            'to_fieldname'    => 'post_status',
     216            'callback_method' => 'callback_status'
     217        );
     218
    207219        // Sticky status (Stored in postmeta)
    208220        $this->field_map[] = array(
     
    369381        );
    370382
     383        // Reply status (Publish or Unpublished, Drupal v7.x publish = 1, pending = 0)
     384        $this->field_map[] = array(
     385            'from_tablename'  => 'comment',
     386            'from_fieldname'  => 'status',
     387            'to_type'         => 'reply',
     388            'to_fieldname'    => 'post_status',
     389            'callback_method' => 'callback_status'
     390        );
     391
    371392        // Reply content.
    372393        // Note: We join the 'field_data_comment_body' table because 'comment' table does not include reply content.
     
    528549        $pass_array = unserialize( $serialized_pass );
    529550        return ( $pass_array['hash'] == md5( md5( $password ). $pass_array['salt'] ) );
     551    }
     552
     553    /**
     554     * Translate the post status from Drupal v7.x numeric's to WordPress's
     555     * strings.
     556     *
     557     * @param int $status Drupal v7.x numeric post status
     558     * @return string WordPress safe
     559     */
     560    public function callback_status( $status = 1 ) {
     561        switch ( $status ) {
     562            case 0 :
     563                $status = 'pending'; // bbp_get_pending_status_id()
     564                break;
     565
     566            case 1  :
     567            default :
     568                $status = 'publish'; // bbp_get_public_status_id()
     569                break;
     570        }
     571        return $status;
    530572    }
    531573
Note: See TracChangeset for help on using the changeset viewer.