Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/23/2013 11:19:34 AM (12 years ago)
Author:
netweb
Message:

Include 'sticky' and 'super sticky' import capabilities for the following forum importers:

  • AEF, Drupal7, Example, FluxBB, Invision, Mingle, MyBB, phpBB, PHPFox, PunBB, SimplePress, vBulletin v4.x, vBulletin v3.x, Xenforo and XMB forum importers
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/admin/converter.php

    r5107 r5170  
    438438                break;
    439439
    440             // STEP 7. Convert tags.
     440            // STEP 7. Stick topics.
    441441            case 7 :
     442                if ( $converter->convert_topic_stickies( $start ) ) {
     443                    update_option( '_bbp_converter_step',  $step + 1 );
     444                    update_option( '_bbp_converter_start', 0         );
     445                    if ( empty( $start ) ) {
     446                        $this->converter_output( __( 'No stickies to stick', 'bbpress' ) );
     447                    }
     448                } else {
     449                    update_option( '_bbp_converter_start', $max + 1 );
     450                    $this->converter_output( sprintf( __( 'Calculating topic stickies (%1$s - %2$s)', 'bbpress' ), $min, $max ) );
     451                }
     452
     453                break;
     454
     455            // STEP 8. Stick to front topics (Super Sicky).
     456            case 8 :
     457                if ( $converter->convert_topic_super_stickies( $start ) ) {
     458                    update_option( '_bbp_converter_step',  $step + 1 );
     459                    update_option( '_bbp_converter_start', 0         );
     460                    if ( empty( $start ) ) {
     461                        $this->converter_output( __( 'No super stickies to stick', 'bbpress' ) );
     462                    }
     463                } else {
     464                    update_option( '_bbp_converter_start', $max + 1 );
     465                    $this->converter_output( sprintf( __( 'Calculating topic super stickies (%1$s - %2$s)', 'bbpress' ), $min, $max ) );
     466                }
     467
     468                break;
     469
     470            // STEP 9. Convert tags.
     471            case 9 :
    442472                if ( $converter->convert_tags( $start ) ) {
    443473                    update_option( '_bbp_converter_step',  $step + 1 );
     
    453483                break;
    454484
    455             // STEP 8. Convert replies.
    456             case 8 :
     485            // STEP 10. Convert replies.
     486            case 10 :
    457487                if ( $converter->convert_replies( $start ) ) {
    458488                    update_option( '_bbp_converter_step',  $step + 1 );
     
    468498                break;
    469499
    470             // STEP 9. Convert reply_to parents.
    471             case 9 :
     500            // STEP 11. Convert reply_to parents.
     501            case 11 :
    472502                if ( $converter->convert_reply_to_parents( $start ) ) {
    473503                    update_option( '_bbp_converter_step',  $step + 1 );
     
    10291059
    10301060    /**
     1061     * This method converts old topic stickies to new bbPress stickies.
     1062     *
     1063     * @since bbPress (r)
     1064     *
     1065     * @uses WPDB $wpdb
     1066     * @uses bbp_stick_topic() to set the imported topic as sticky
     1067     *
     1068     */
     1069    public function convert_topic_stickies( $start ) {
     1070
     1071        $has_update = false;
     1072
     1073        if ( !empty( $this->sync_table ) ) {
     1074            $query = 'SELECT value_id, meta_value FROM ' . $this->sync_table_name . ' WHERE meta_key = "_bbp_old_sticky_status" AND meta_value = "sticky" LIMIT ' . $start . ', ' . $this->max_rows;
     1075        } else {
     1076            $query = 'SELECT post_id AS value_id, meta_value FROM ' . $this->wpdb->postmeta . ' WHERE meta_key = "_bbp_old_sticky_status" AND meta_value = "sticky" LIMIT ' . $start . ', ' . $this->max_rows;
     1077        }
     1078
     1079        update_option( '_bbp_converter_query', $query );
     1080
     1081        $sticky_array = $this->wpdb->get_results( $query );
     1082
     1083        foreach ( (array) $sticky_array as $row ) {
     1084            bbp_stick_topic( $row->value_id );
     1085            $has_update = true;
     1086        }
     1087
     1088        return ! $has_update;
     1089    }
     1090
     1091    /**
     1092     * This method converts old topic super stickies to new bbPress super stickies.
     1093     *
     1094     * @since bbPress (r)
     1095     *
     1096     * @uses WPDB $wpdb
     1097     * @uses bbp_stick_topic() to set the imported topic as super sticky
     1098     *
     1099     */
     1100    public function convert_topic_super_stickies( $start ) {
     1101
     1102        $has_update = false;
     1103
     1104        if ( !empty( $this->sync_table ) ) {
     1105            $query = 'SELECT value_id, meta_value FROM ' . $this->sync_table_name . ' WHERE meta_key = "_bbp_old_sticky_status" AND meta_value = "super-sticky" LIMIT ' . $start . ', ' . $this->max_rows;
     1106        } else {
     1107            $query = 'SELECT post_id AS value_id, meta_value FROM ' . $this->wpdb->postmeta . ' WHERE meta_key = "_bbp_old_sticky_status" AND meta_value = "super-sticky" LIMIT ' . $start . ', ' . $this->max_rows;
     1108        }
     1109
     1110        update_option( '_bbp_converter_query', $query );
     1111
     1112        $sticky_array = $this->wpdb->get_results( $query );
     1113
     1114        foreach ( (array) $sticky_array as $row ) {
     1115            $super = true;
     1116            bbp_stick_topic( $row->value_id, $super );
     1117            $has_update = true;
     1118        }
     1119
     1120        return ! $has_update;
     1121    }
     1122
     1123    /**
    10311124     * This method converts old reply_to post id to new bbPress reply_to post id.
    10321125     */
Note: See TracChangeset for help on using the changeset viewer.