Changeset 5829 for trunk/src/includes/admin/converter.php
- Timestamp:
- 07/14/2015 12:46:38 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/admin/converter.php (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/admin/converter.php
r5827 r5829 320 320 321 321 // Save step and count so that it can be restarted. 322 if ( ! get_option( '_bbp_converter_step' ) || ( ! empty( $_POST['_bbp_converter_restart'] ) ) ) {322 if ( ! get_option( '_bbp_converter_step' ) || ( ! empty( $_POST['_bbp_converter_restart'] ) ) ) { 323 323 update_option( '_bbp_converter_step', 1 ); 324 324 update_option( '_bbp_converter_start', 0 ); … … 332 332 333 333 // Bail if platform did not get saved 334 $platform = ! empty( $_POST['_bbp_converter_platform' ] ) ? $_POST['_bbp_converter_platform' ] : get_option( '_bbp_converter_platform' );334 $platform = ! empty( $_POST['_bbp_converter_platform' ] ) ? $_POST['_bbp_converter_platform' ] : get_option( '_bbp_converter_platform' ); 335 335 if ( empty( $platform ) ) { 336 336 return; … … 344 344 // STEP 1. Clean all tables. 345 345 case 1 : 346 if ( ! empty( $_POST['_bbp_converter_clean'] ) ) {346 if ( ! empty( $_POST['_bbp_converter_clean'] ) ) { 347 347 if ( $converter->clean( $start ) ) { 348 348 update_option( '_bbp_converter_step', $step + 1 ); … … 365 365 // STEP 2. Convert users. 366 366 case 2 : 367 if ( ! empty( $_POST['_bbp_converter_convert_users'] ) ) {367 if ( ! empty( $_POST['_bbp_converter_convert_users'] ) ) { 368 368 if ( $converter->convert_users( $start ) ) { 369 369 update_option( '_bbp_converter_step', $step + 1 ); … … 385 385 // STEP 3. Clean passwords. 386 386 case 3 : 387 if ( ! empty( $_POST['_bbp_converter_convert_users'] ) ) {387 if ( ! empty( $_POST['_bbp_converter_convert_users'] ) ) { 388 388 if ( $converter->clean_passwords( $start ) ) { 389 389 update_option( '_bbp_converter_step', $step + 1 ); … … 639 639 require_once( ABSPATH . '/wp-admin/includes/upgrade.php' ); 640 640 641 if ( ! empty( $bbp_db->charset ) ) {641 if ( ! empty( $bbp_db->charset ) ) { 642 642 $charset_collate = "DEFAULT CHARACTER SET $bbp_db->charset"; 643 643 } 644 644 645 if ( ! empty( $bbp_db->collate ) ) {645 if ( ! empty( $bbp_db->collate ) ) { 646 646 $charset_collate .= " COLLATE $bbp_db->collate"; 647 647 } … … 958 958 959 959 // Get the fields from the destination table 960 if ( ! empty( $tablename ) ) {960 if ( ! empty( $tablename ) ) { 961 961 $tablefield_array = $this->get_fields( $tablename ); 962 962 } … … 968 968 969 969 // Yay a match, and we have a from table, too 970 if ( ( $item['to_type'] == $to_type ) && ! empty( $item['from_tablename'] ) ) {970 if ( ( $item['to_type'] == $to_type ) && ! empty( $item['from_tablename'] ) ) { 971 971 972 972 // $from_tablename was set from a previous loop iteration … … 974 974 975 975 // Doing some joining 976 if ( ! in_array( $item['from_tablename'], $from_tables ) && in_array( $item['join_tablename'], $from_tables ) ) {976 if ( ! in_array( $item['from_tablename'], $from_tables ) && in_array( $item['join_tablename'], $from_tables ) ) { 977 977 $from_tablename .= ' ' . $item['join_type'] . ' JOIN ' . $this->opdb->prefix . $item['from_tablename'] . ' AS ' . $item['from_tablename'] . ' ' . $item['join_expression']; 978 978 } … … 984 984 985 985 // Specific FROM expression data used 986 if ( ! empty( $item['from_expression'] ) ) {986 if ( ! empty( $item['from_expression'] ) ) { 987 987 988 988 // No 'WHERE' in expression … … 1005 1005 1006 1006 // We have a $from_tablename, so we want to get some data to convert 1007 if ( ! empty( $from_tablename ) ) {1007 if ( ! empty( $from_tablename ) ) { 1008 1008 1009 1009 // Get some data from the old forums … … 1016 1016 1017 1017 // Query returned some results 1018 if ( ! empty( $forum_array ) ) {1018 if ( ! empty( $forum_array ) ) { 1019 1019 1020 1020 // Loop through results … … 1054 1054 // Destination field is not empty, so we might need 1055 1055 // to do some extra work or set a default. 1056 } elseif ( ! empty( $row['to_fieldname'] ) ) {1056 } elseif ( ! empty( $row['to_fieldname'] ) ) { 1057 1057 1058 1058 // Allows us to set default fields. … … 1252 1252 $has_update = false; 1253 1253 1254 if ( ! empty( $this->sync_table ) ) {1254 if ( ! empty( $this->sync_table ) ) { 1255 1255 $query = 'SELECT value_id, meta_value FROM ' . $this->sync_table_name . ' WHERE meta_key = "_bbp_old_forum_parent_id" AND meta_value > 0 LIMIT ' . $start . ', ' . $this->max_rows; 1256 1256 } else { … … 1284 1284 $has_update = false; 1285 1285 1286 if ( ! empty( $this->sync_table ) ) {1286 if ( ! empty( $this->sync_table ) ) { 1287 1287 $query = 'SELECT value_id, meta_value FROM ' . $this->sync_table_name . ' WHERE meta_key = "_bbp_old_sticky_status_id" AND meta_value = "sticky" LIMIT ' . $start . ', ' . $this->max_rows; 1288 1288 } else { … … 1315 1315 $has_update = false; 1316 1316 1317 if ( ! empty( $this->sync_table ) ) {1317 if ( ! empty( $this->sync_table ) ) { 1318 1318 $query = 'SELECT value_id, meta_value FROM ' . $this->sync_table_name . ' WHERE meta_key = "_bbp_old_sticky_status_id" AND meta_value = "super-sticky" LIMIT ' . $start . ', ' . $this->max_rows; 1319 1319 } else { … … 1346 1346 $has_update = false; 1347 1347 1348 if ( ! empty( $this->sync_table ) ) {1348 if ( ! empty( $this->sync_table ) ) { 1349 1349 $query = 'SELECT value_id, meta_value FROM ' . $this->sync_table_name . ' WHERE meta_key = "_bbp_old_closed_status_id" AND meta_value = "closed" LIMIT ' . $start . ', ' . $this->max_rows; 1350 1350 } else { … … 1373 1373 $has_update = false; 1374 1374 1375 if ( ! empty( $this->sync_table ) ) {1375 if ( ! empty( $this->sync_table ) ) { 1376 1376 $query = 'SELECT value_id, meta_value FROM ' . $this->sync_table_name . ' WHERE meta_key = "_bbp_old_reply_to_id" AND meta_value > 0 LIMIT ' . $start . ', ' . $this->max_rows; 1377 1377 } else { … … 1403 1403 $has_update = false; 1404 1404 1405 if ( ! empty( $this->sync_table ) ) {1405 if ( ! empty( $this->sync_table ) ) { 1406 1406 $query = 'SELECT sync_table1.value_id AS topic_id, sync_table1.meta_value AS topic_is_anonymous, sync_table2.meta_value AS topic_author 1407 1407 FROM ' . $this->sync_table_name . ' AS sync_table1 … … 1449 1449 $has_update = false; 1450 1450 1451 if ( ! empty( $this->sync_table ) ) {1451 if ( ! empty( $this->sync_table ) ) { 1452 1452 $query = 'SELECT sync_table1.value_id AS reply_id, sync_table1.meta_value AS reply_is_anonymous, sync_table2.meta_value AS reply_author 1453 1453 FROM ' . $this->sync_table_name . ' AS sync_table1 … … 1523 1523 $users = $this->wpdb->get_results( $query, ARRAY_A ); 1524 1524 1525 if ( ! empty( $users ) ) {1525 if ( ! empty( $users ) ) { 1526 1526 foreach ( $users as $value ) { 1527 1527 wp_delete_user( $value['value_id'] ); … … 1552 1552 $bbconverter = $this->wpdb->get_results( $query, ARRAY_A ); 1553 1553 1554 if ( ! empty( $bbconverter ) ) {1554 if ( ! empty( $bbconverter ) ) { 1555 1555 1556 1556 foreach ( $bbconverter as $value ) { … … 1612 1612 public function callback_pass( $username, $password ) { 1613 1613 $user = $this->wpdb->get_row( $this->wpdb->prepare( 'SELECT * FROM ' . $this->wpdb->users . ' WHERE user_login = "%s" AND user_pass = "" LIMIT 1', $username ) ); 1614 if ( ! empty( $user ) ) {1614 if ( ! empty( $user ) ) { 1615 1615 $usermeta = $this->wpdb->get_row( 'SELECT * FROM ' . $this->wpdb->usermeta . ' WHERE meta_key = "_bbp_password" AND user_id = "' . $user->ID . '" LIMIT 1' ); 1616 1616 1617 if ( ! empty( $usermeta ) ) {1617 if ( ! empty( $usermeta ) ) { 1618 1618 if ( $this->authenticate_pass( $password, $usermeta->meta_value ) ) { 1619 1619 $this->wpdb->query( 'UPDATE ' . $this->wpdb->users . ' ' . 'SET user_pass = "' . wp_hash_password( $password ) . '" ' . 'WHERE ID = "' . $user->ID . '"' ); … … 1631 1631 */ 1632 1632 private function callback_forumid( $field ) { 1633 if ( ! isset( $this->map_forumid[$field] ) ) {1634 if ( ! empty( $this->sync_table ) ) {1633 if ( ! isset( $this->map_forumid[$field] ) ) { 1634 if ( ! empty( $this->sync_table ) ) { 1635 1635 $row = $this->wpdb->get_row( $this->wpdb->prepare( 'SELECT value_id, meta_value FROM ' . $this->sync_table_name . ' WHERE meta_key = "_bbp_old_forum_id" AND meta_value = "%s" LIMIT 1', $field ) ); 1636 1636 } else { … … 1654 1654 */ 1655 1655 private function callback_topicid( $field ) { 1656 if ( ! isset( $this->map_topicid[$field] ) ) {1657 if ( ! empty( $this->sync_table ) ) {1656 if ( ! isset( $this->map_topicid[$field] ) ) { 1657 if ( ! empty( $this->sync_table ) ) { 1658 1658 $row = $this->wpdb->get_row( $this->wpdb->prepare( 'SELECT value_id, meta_value FROM ' . $this->sync_table_name . ' WHERE meta_key = "_bbp_old_topic_id" AND meta_value = "%s" LIMIT 1', $field ) ); 1659 1659 } else { … … 1679 1679 */ 1680 1680 private function callback_reply_to( $field ) { 1681 if ( ! isset( $this->map_reply_to[$field] ) ) {1682 if ( ! empty( $this->sync_table ) ) {1681 if ( ! isset( $this->map_reply_to[$field] ) ) { 1682 if ( ! empty( $this->sync_table ) ) { 1683 1683 $row = $this->wpdb->get_row( $this->wpdb->prepare( 'SELECT value_id, meta_value FROM ' . $this->sync_table_name . ' WHERE meta_key = "_bbp_old_reply_id" AND meta_value = "%s" LIMIT 1', $field ) ); 1684 1684 } else { … … 1702 1702 */ 1703 1703 private function callback_userid( $field ) { 1704 if ( ! isset( $this->map_userid[$field] ) ) {1705 if ( ! empty( $this->sync_table ) ) {1704 if ( ! isset( $this->map_userid[$field] ) ) { 1705 if ( ! empty( $this->sync_table ) ) { 1706 1706 $row = $this->wpdb->get_row( $this->wpdb->prepare( 'SELECT value_id, meta_value FROM ' . $this->sync_table_name . ' WHERE meta_key = "_bbp_old_user_id" AND meta_value = "%s" LIMIT 1', $field ) ); 1707 1707 } else { … … 1712 1712 $this->map_userid[$field] = $row->value_id; 1713 1713 } else { 1714 if ( ! empty( $_POST['_bbp_converter_convert_users'] ) && ( $_POST['_bbp_converter_convert_users'] == 1 ) ) {1714 if ( ! empty( $_POST['_bbp_converter_convert_users'] ) && ( $_POST['_bbp_converter_convert_users'] == 1 ) ) { 1715 1715 $this->map_userid[$field] = 0; 1716 1716 } else {
Note: See TracChangeset
for help on using the changeset viewer.