Changeset 5571 for trunk/src/includes/admin/converter.php
- Timestamp:
- 11/22/2014 11:23:49 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/admin/converter.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/admin/converter.php
r5544 r5571 37 37 // Converter is converting 38 38 case 'POST' : 39 if ( ( empty( $_POST['action'] ) || ( 'bbconverter_process' != $_POST['action'] ) ) ) {39 if ( ( empty( $_POST['action'] ) || ( 'bbconverter_process' != $_POST['action'] ) ) ) { 40 40 return; 41 41 } … … 45 45 // Some other admin page 46 46 case 'GET' : 47 if ( ( empty( $_GET['page'] ) || ( 'bbp-converter' != $_GET['page'] ) ) ) {47 if ( ( empty( $_GET['page'] ) || ( 'bbp-converter' != $_GET['page'] ) ) ) { 48 48 return; 49 49 } … … 428 428 break; 429 429 430 // STEP 6. Convert topics.430 // STEP 6. Convert forum subscriptions. 431 431 case 6 : 432 if ( $converter->convert_forum_subscriptions( $start ) ) { 433 update_option( '_bbp_converter_step', $step + 1 ); 434 update_option( '_bbp_converter_start', 0 ); 435 if ( empty( $start ) ) { 436 $this->converter_output( __( 'No forum subscriptions to convert', 'bbpress' ) ); 437 } 438 } else { 439 update_option( '_bbp_converter_start', $max + 1 ); 440 $this->converter_output( sprintf( __( 'Converting forum subscriptions (%1$s - %2$s)', 'bbpress' ), $min, $max ) ); 441 } 442 443 break; 444 445 // STEP 7. Convert topics. 446 case 7 : 432 447 if ( $converter->convert_topics( $start ) ) { 433 448 update_option( '_bbp_converter_step', $step + 1 ); … … 443 458 break; 444 459 445 // STEP 7. Convert anonymous topic authors.446 case 7:460 // STEP 8. Convert anonymous topic authors. 461 case 8 : 447 462 if ( $converter->convert_anonymous_topic_authors( $start ) ) { 448 463 update_option( '_bbp_converter_step', $step + 1 ); … … 458 473 break; 459 474 460 // STEP 8. Stick topics.461 case 8:475 // STEP 9. Stick topics. 476 case 9 : 462 477 if ( $converter->convert_topic_stickies( $start ) ) { 463 478 update_option( '_bbp_converter_step', $step + 1 ); … … 473 488 break; 474 489 475 // STEP 9. Stick to front topics (Super Sicky).476 case 9:490 // STEP 10. Stick to front topics (Super Sicky). 491 case 10 : 477 492 if ( $converter->convert_topic_super_stickies( $start ) ) { 478 493 update_option( '_bbp_converter_step', $step + 1 ); … … 488 503 break; 489 504 490 // STEP 1 0. Closed Topics.491 case 1 0:505 // STEP 11. Closed topics. 506 case 11 : 492 507 if ( $converter->convert_topic_closed_topics( $start ) ) { 493 508 update_option( '_bbp_converter_step', $step + 1 ); … … 503 518 break; 504 519 505 // STEP 1 1. Convert topic tags.506 case 1 1:520 // STEP 12. Convert topic tags. 521 case 12 : 507 522 if ( $converter->convert_tags( $start ) ) { 508 523 update_option( '_bbp_converter_step', $step + 1 ); … … 518 533 break; 519 534 520 // STEP 12. Convert replies. 521 case 12 : 535 // STEP 13. Convert topic subscriptions. 536 case 13 : 537 if ( $converter->convert_topic_subscriptions( $start ) ) { 538 update_option( '_bbp_converter_step', $step + 1 ); 539 update_option( '_bbp_converter_start', 0 ); 540 if ( empty( $start ) ) { 541 $this->converter_output( __( 'No topic subscriptions to convert', 'bbpress' ) ); 542 } 543 } else { 544 update_option( '_bbp_converter_start', $max + 1 ); 545 $this->converter_output( sprintf( __( 'Converting topic subscriptions (%1$s - %2$s)', 'bbpress' ), $min, $max ) ); 546 } 547 548 break; 549 550 // STEP 14. Convert topic favorites. 551 case 14 : 552 if ( $converter->convert_favorites( $start ) ) { 553 update_option( '_bbp_converter_step', $step + 1 ); 554 update_option( '_bbp_converter_start', 0 ); 555 if ( empty( $start ) ) { 556 $this->converter_output( __( 'No favorites to convert', 'bbpress' ) ); 557 } 558 } else { 559 update_option( '_bbp_converter_start', $max + 1 ); 560 $this->converter_output( sprintf( __( 'Converting favorites (%1$s - %2$s)', 'bbpress' ), $min, $max ) ); 561 } 562 563 break; 564 565 // STEP 15. Convert replies. 566 case 15 : 522 567 if ( $converter->convert_replies( $start ) ) { 523 568 update_option( '_bbp_converter_step', $step + 1 ); … … 533 578 break; 534 579 535 // STEP 1 3. Convert anonymous reply authors.536 case 1 3:580 // STEP 16. Convert anonymous reply authors. 581 case 16 : 537 582 if ( $converter->convert_anonymous_reply_authors( $start ) ) { 538 583 update_option( '_bbp_converter_step', $step + 1 ); … … 548 593 break; 549 594 550 // STEP 1 4. Convert threaded replies parents.551 case 1 4:595 // STEP 17. Convert threaded replies parents. 596 case 17 : 552 597 if ( $converter->convert_reply_to_parents( $start ) ) { 553 598 update_option( '_bbp_converter_step', $step + 1 ); … … 842 887 843 888 /** 889 * Convert Forum Subscriptions 890 */ 891 public function convert_forum_subscriptions( $start = 1 ) { 892 return $this->convert_table( 'forum_subscriptions', $start ); 893 } 894 895 /** 896 * Convert Topic Subscriptions 897 */ 898 public function convert_topic_subscriptions( $start = 1 ) { 899 return $this->convert_table( 'topic_subscriptions', $start ); 900 } 901 902 /** 903 * Convert Favorites 904 */ 905 public function convert_favorites( $start = 1 ) { 906 return $this->convert_table( 'favorites', $start ); 907 } 908 909 /** 844 910 * Convert Table 845 911 * … … 871 937 break; 872 938 939 case 'forum_subscriptions' : 940 $tablename = $this->wpdb->usermeta; 941 break; 942 943 case 'topic_subscriptions' : 944 $tablename = $this->wpdb->usermeta; 945 break; 946 947 case 'favorites' : 948 $tablename = $this->wpdb->usermeta; 949 break; 950 873 951 default : 874 952 $tablename = $this->wpdb->posts; … … 945 1023 foreach ( $this->field_map as $row ) { 946 1024 947 // Types match and to_fieldname is present. This means1025 // Types match and to_fieldname is present. This means 948 1026 // we have some work to do here. 949 1027 if ( ( $row['to_type'] == $to_type ) && ! is_null( $row['to_fieldname'] ) ) { … … 1038 1116 ) ); 1039 1117 } 1040 break; 1118 break; 1119 1120 /** Forum Subscriptions *********************************/ 1121 1122 case 'forum_subscriptions': 1123 $user_id = $insert_post['user_id']; 1124 if ( is_numeric( $user_id ) ) { 1125 foreach ($insert_postmeta as $key => $value) { 1126 1127 // Only extract values from the key _bbp_forum_subscriptions 1128 if ( '_bbp_forum_subscriptions' == $key ) { 1129 1130 // Get the new forum ID 1131 $forum_id = $this->callback_forumid( $value ); 1132 1133 // Add the topic ID to the users subscribed forums 1134 bbp_add_user_forum_subscription( $user_id, $forum_id ); 1135 } 1136 } 1137 } 1138 break; 1139 1140 /** Subscriptions *********************************/ 1141 1142 case 'topic_subscriptions': 1143 $user_id = $insert_post['user_id']; 1144 if ( is_numeric( $user_id ) ) { 1145 foreach ($insert_postmeta as $key => $value) { 1146 1147 // Only extract values from the key _bbp_subscriptions 1148 if ( '_bbp_subscriptions' == $key ) { 1149 1150 // Get the new topic ID 1151 $topic_id = $this->callback_topicid( $value ); 1152 1153 // Add the topic ID to the users subscribed topics 1154 bbp_add_user_topic_subscription( $user_id, $topic_id ); 1155 } 1156 } 1157 } 1158 break; 1159 1160 /** Favorites *********************************/ 1161 1162 case 'favorites': 1163 $user_id = $insert_post['user_id']; 1164 if ( is_numeric( $user_id ) ) { 1165 1166 // Loop through the array 1167 foreach ($insert_postmeta as $key => $value) { 1168 1169 // Only extract values from the key _bbp_favorites 1170 if ( '_bbp_favorites' == $key ) { 1171 1172 // Our array may contain comma delimited favorites so lets explode these 1173 $insert_postmeta = explode(",", $insert_postmeta['_bbp_favorites']); 1174 1175 // Loop through our updated exploded array 1176 foreach ($insert_postmeta as $key => $value) { 1177 1178 // Get the new topic ID 1179 $topic_id = $this->callback_topicid( $value ); 1180 1181 // Add the topic ID to the users favorites 1182 bbp_add_user_favorite( $user_id, $topic_id ); 1183 } 1184 } 1185 } 1186 } 1187 break; 1041 1188 1042 1189 /** Forum, Topic, Reply ***************************/
Note: See TracChangeset
for help on using the changeset viewer.