Skip to:
Content

bbPress.org

Changeset 4055


Ignore:
Timestamp:
07/04/2012 03:28:57 AM (10 years ago)
Author:
johnjamesjacoby
Message:

Converter:

  • Update verbiage of clean and restart checkboxes.
  • Audit usage of sync_table(), and make sure table is created correctly.
  • When deleting posts, check correct array items.
Location:
branches/plugin/bbp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-admin/bbp-converter.php

    r4053 r4055  
    126126        register_setting  ( 'bbpress_converter_opt',        '_bbp_converter_convert_users',     'intval' );
    127127
     128        // Restart
     129        add_settings_field( '_bbp_converter_restart',       __( 'Start Over',        'bbpress' ), 'bbp_converter_setting_callback_restart', 'bbpress_converter', 'bbpress_converter_opt' );
     130        register_setting  ( 'bbpress_converter_opt',        '_bbp_converter_restart',           'intval' );
     131
    128132        // Clean
    129         add_settings_field( '_bbp_converter_clean',         __( 'Clean',            'bbpress' ), 'bbp_converter_setting_callback_clean', 'bbpress_converter', 'bbpress_converter_opt' );
     133        add_settings_field( '_bbp_converter_clean',         __( 'Purge Previous Import', 'bbpress' ), 'bbp_converter_setting_callback_clean', 'bbpress_converter', 'bbpress_converter_opt' );
    130134        register_setting  ( 'bbpress_converter_opt',        '_bbp_converter_clean',             'intval' );
    131 
    132         // Restart
    133         add_settings_field( '_bbp_converter_restart',       __( 'Restart',           'bbpress' ), 'bbp_converter_setting_callback_restart', 'bbpress_converter', 'bbpress_converter_opt' );
    134         register_setting  ( 'bbpress_converter_opt',        '_bbp_converter_restart',           'intval' );
    135135    }
    136136
     
    337337                        update_option( '_bbp_converter_step',  $step + 1 );
    338338                        update_option( '_bbp_converter_start', 0         );
    339                         $this->sync_table();
     339                        $this->sync_table( true );
    340340                        if ( empty( $start ) ) {
    341341                            $this->converter_output( __( 'No data to clean', 'bbpress' ) );
     
    510510
    511511        $table_name = $wpdb->prefix . 'bbp_converter_translator';
    512         if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) == $table_name ) {
     512        if ( ! empty( $drop ) && $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) == $table_name )
    513513            $wpdb->query( "DROP TABLE {$table_name}" );
    514         }
    515 
    516         if ( empty( $drop ) ) {
    517             require_once( ABSPATH . '/wp-admin/includes/upgrade.php' );
    518 
    519             if ( !empty( $wpdb->charset ) ) {
    520                 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    521             }
    522 
    523             if ( !empty( $wpdb->collate ) ) {
    524                 $charset_collate .= " COLLATE $wpdb->collate";
    525             }
    526 
    527             /** Translator ****************************************************/
    528 
    529             $sql = "CREATE TABLE {$table_name} (
    530                         meta_id mediumint(8) unsigned not null auto_increment,
    531                         value_type varchar(25) null,
    532                         value_id bigint(20) unsigned not null default '0',
    533                         meta_key varchar(25) null,
    534                         meta_value varchar(25) null,
    535                     PRIMARY KEY  (meta_id),
    536                         KEY value_id (value_id),
    537                         KEY meta_join (meta_key, meta_value) ) {$charset_collate};";
    538 
    539             dbDelta( $sql );
    540         }
     514
     515        require_once( ABSPATH . '/wp-admin/includes/upgrade.php' );
     516
     517        if ( !empty( $wpdb->charset ) ) {
     518            $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
     519        }
     520
     521        if ( !empty( $wpdb->collate ) ) {
     522            $charset_collate .= " COLLATE $wpdb->collate";
     523        }
     524
     525        /** Translator ****************************************************/
     526
     527        $sql = "CREATE TABLE {$table_name} (
     528                    meta_id mediumint(8) unsigned not null auto_increment,
     529                    value_type varchar(25) null,
     530                    value_id bigint(20) unsigned not null default '0',
     531                    meta_key varchar(25) null,
     532                    meta_value varchar(25) null,
     533                PRIMARY KEY  (meta_id),
     534                    KEY value_id (value_id),
     535                    KEY meta_join (meta_key, meta_value) ) {$charset_collate};";
     536
     537        dbDelta( $sql );
    541538    }
    542539}
     
    10401037        $posts = $this->wpdb->get_results( $query, ARRAY_A );
    10411038
    1042         if ( !empty( $posts ) ) {
     1039        if ( isset( $posts[0] ) && ! empty( $posts[0]['value_id'] ) ) {
    10431040            foreach ( (array) $posts as $value ) {
    10441041                wp_delete_post( $value['value_id'], true );
  • branches/plugin/bbp-admin/bbp-settings.php

    r4053 r4055  
    11231123
    11241124/**
     1125 * Edit Restart setting field
     1126 *
     1127 * @since bbPress (r3813)
     1128 */
     1129function bbp_converter_setting_callback_restart() {
     1130?>
     1131
     1132    <input id="_bbp_converter_restart" name="_bbp_converter_restart" type="checkbox" id="_bbp_converter_restart" value="1" <?php checked( get_option( '_bbp_converter_restart', false ) ); ?> />
     1133    <label for="_bbp_converter_restart"><?php _e( 'Start a fresh conversion from the beginning', 'bbpress' ); ?></label>
     1134    <p class="description"><?php _e( 'You should clean old conversion information before starting over.', 'bbpress' ); ?></p>
     1135
     1136<?php
     1137}
     1138
     1139/**
    11251140 * Edit Clean setting field
    11261141 *
     
    11321147    <input id="_bbp_converter_clean" name="_bbp_converter_clean" type="checkbox" id="_bbp_converter_clean" value="1" <?php checked( get_option( '_bbp_converter_clean', false ) ); ?> />
    11331148    <label for="_bbp_converter_clean"><?php _e( 'Purge all information from a previously attempted import', 'bbpress' ); ?></label>
    1134     <p class="description"><?php _e( 'Use this if an import failed and you want to start over from scratch.', 'bbpress' ); ?></p>
    1135 
    1136 <?php
    1137 }
    1138 
    1139 /**
    1140  * Edit Restart setting field
    1141  *
    1142  * @since bbPress (r3813)
    1143  */
    1144 function bbp_converter_setting_callback_restart() {
    1145 ?>
    1146 
    1147     <input id="_bbp_converter_restart" name="_bbp_converter_restart" type="checkbox" id="_bbp_converter_restart" value="1" <?php checked( get_option( '_bbp_converter_restart', false ) ); ?> />
    1148     <label for="_bbp_converter_restart"><?php _e( 'Restart conversion from the beginning', 'bbpress' ); ?></label>
    1149     <p class="description"><?php _e( 'The importer keeps track of where it left off in the event of failure.', 'bbpress' ); ?></p>
     1149    <p class="description"><?php _e( 'Use this if an import failed and you want to remove that incomplete data.', 'bbpress' ); ?></p>
    11501150
    11511151<?php
Note: See TracChangeset for help on using the changeset viewer.