[ Index ] |
PHP Cross Reference of BBPress |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * bbPress FluxBB Converter 5 * 6 * @package bbPress 7 * @subpackage Converters 8 */ 9 10 /** 11 * Implementation of FluxBB Forum converter. 12 * 13 * @since 2.5.0 bbPress (r5138) 14 * 15 * @link Codex Docs https://codex.bbpress.org/import-forums/fluxbb 16 */ 17 class FluxBB extends BBP_Converter_Base { 18 19 /** 20 * Main Constructor 21 * 22 */ 23 public function __construct() { 24 parent::__construct(); 25 } 26 27 /** 28 * Sets up the field mappings 29 */ 30 public function setup_globals() { 31 32 /** Forum Section *****************************************************/ 33 34 // Old forum id (Stored in postmeta) 35 $this->field_map[] = array( 36 'from_tablename' => 'forums', 37 'from_fieldname' => 'id', 38 'to_type' => 'forum', 39 'to_fieldname' => '_bbp_old_forum_id' 40 ); 41 42 // Forum topic count (Stored in postmeta) 43 $this->field_map[] = array( 44 'from_tablename' => 'forums', 45 'from_fieldname' => 'num_topics', 46 'to_type' => 'forum', 47 'to_fieldname' => '_bbp_topic_count' 48 ); 49 50 // Forum reply count (Stored in postmeta) 51 $this->field_map[] = array( 52 'from_tablename' => 'forums', 53 'from_fieldname' => 'num_posts', 54 'to_type' => 'forum', 55 'to_fieldname' => '_bbp_reply_count' 56 ); 57 58 // Forum total topic count (Stored in postmeta) 59 $this->field_map[] = array( 60 'from_tablename' => 'forums', 61 'from_fieldname' => 'num_topics', 62 'to_type' => 'forum', 63 'to_fieldname' => '_bbp_total_topic_count' 64 ); 65 66 // Forum total reply count (Stored in postmeta) 67 $this->field_map[] = array( 68 'from_tablename' => 'forums', 69 'from_fieldname' => 'num_posts', 70 'to_type' => 'forum', 71 'to_fieldname' => '_bbp_total_reply_count' 72 ); 73 74 // Forum title. 75 $this->field_map[] = array( 76 'from_tablename' => 'forums', 77 'from_fieldname' => 'forum_name', 78 'to_type' => 'forum', 79 'to_fieldname' => 'post_title' 80 ); 81 82 // Forum slug (Clean name to avoid conflicts) 83 $this->field_map[] = array( 84 'from_tablename' => 'forums', 85 'from_fieldname' => 'forum_name', 86 'to_type' => 'forum', 87 'to_fieldname' => 'post_name', 88 'callback_method' => 'callback_slug' 89 ); 90 91 // Forum description. 92 $this->field_map[] = array( 93 'from_tablename' => 'forums', 94 'from_fieldname' => 'forum_desc', 95 'to_type' => 'forum', 96 'to_fieldname' => 'post_content', 97 'callback_method' => 'callback_null' 98 ); 99 100 // Forum display order (Starts from 1) 101 $this->field_map[] = array( 102 'from_tablename' => 'forums', 103 'from_fieldname' => 'disp_position', 104 'to_type' => 'forum', 105 'to_fieldname' => 'menu_order' 106 ); 107 108 // Forum type (Set a default value 'forum', Stored in postmeta) 109 $this->field_map[] = array( 110 'to_type' => 'forum', 111 'to_fieldname' => '_bbp_forum_type', 112 'default' => 'forum' 113 ); 114 115 // Forum status (Set a default value 'open', Stored in postmeta) 116 $this->field_map[] = array( 117 'to_type' => 'forum', 118 'to_fieldname' => '_bbp_status', 119 'default' => 'open' 120 ); 121 122 // Forum dates. 123 $this->field_map[] = array( 124 'to_type' => 'forum', 125 'to_fieldname' => 'post_date', 126 'default' => date('Y-m-d H:i:s') 127 ); 128 $this->field_map[] = array( 129 'to_type' => 'forum', 130 'to_fieldname' => 'post_date_gmt', 131 'default' => date('Y-m-d H:i:s') 132 ); 133 $this->field_map[] = array( 134 'to_type' => 'forum', 135 'to_fieldname' => 'post_modified', 136 'default' => date('Y-m-d H:i:s') 137 ); 138 $this->field_map[] = array( 139 'to_type' => 'forum', 140 'to_fieldname' => 'post_modified_gmt', 141 'default' => date('Y-m-d H:i:s') 142 ); 143 144 /** Forum Subscriptions Section ***************************************/ 145 146 // Subscribed forum ID (Stored in usermeta) 147 $this->field_map[] = array( 148 'from_tablename' => 'forum_subscriptions', 149 'from_fieldname' => 'forum_id', 150 'to_type' => 'forum_subscriptions', 151 'to_fieldname' => '_bbp_forum_subscriptions' 152 ); 153 154 // Subscribed user ID (Stored in usermeta) 155 $this->field_map[] = array( 156 'from_tablename' => 'forum_subscriptions', 157 'from_fieldname' => 'user_id', 158 'to_type' => 'forum_subscriptions', 159 'to_fieldname' => 'user_id', 160 'callback_method' => 'callback_userid' 161 ); 162 163 /** Topic Section *****************************************************/ 164 165 // Old topic id (Stored in postmeta) 166 $this->field_map[] = array( 167 'from_tablename' => 'topics', 168 'from_fieldname' => 'id', 169 'to_type' => 'topic', 170 'to_fieldname' => '_bbp_old_topic_id' 171 ); 172 173 // Topic reply count (Stored in postmeta) 174 $this->field_map[] = array( 175 'from_tablename' => 'topics', 176 'from_fieldname' => 'num_replies', 177 'to_type' => 'topic', 178 'to_fieldname' => '_bbp_reply_count', 179 'callback_method' => 'callback_topic_reply_count' 180 ); 181 182 // Topic total reply count (Includes unpublished replies, Stored in postmeta) 183 $this->field_map[] = array( 184 'from_tablename' => 'topics', 185 'from_fieldname' => 'num_replies', 186 'to_type' => 'topic', 187 'to_fieldname' => '_bbp_total_reply_count', 188 'callback_method' => 'callback_topic_reply_count' 189 ); 190 191 // Topic parent forum id (If no parent, then 0, Stored in postmeta) 192 $this->field_map[] = array( 193 'from_tablename' => 'topics', 194 'from_fieldname' => 'forum_id', 195 'to_type' => 'topic', 196 'to_fieldname' => '_bbp_forum_id', 197 'callback_method' => 'callback_forumid' 198 ); 199 200 // Topic author. 201 // Note: We join the 'posts' table because 'topics' table does include numeric user id. 202 $this->field_map[] = array( 203 'from_tablename' => 'posts', 204 'from_fieldname' => 'poster_id', 205 'join_tablename' => 'topics', 206 'join_type' => 'INNER', 207 'join_expression' => 'ON topics.first_post_id = posts.id', 208 'to_type' => 'topic', 209 'to_fieldname' => 'post_author', 210 'callback_method' => 'callback_userid' 211 ); 212 213 // Topic Author ip (Stored in postmeta) 214 // Note: We join the 'posts' table because 'topics' table does not include author IP addresses. 215 $this->field_map[] = array( 216 'from_tablename' => 'posts', 217 'from_fieldname' => 'poster_ip', 218 'join_tablename' => 'topics', 219 'join_type' => 'INNER', 220 'join_expression' => 'ON topics.first_post_id = posts.id', 221 'to_type' => 'topic', 222 'to_fieldname' => '_bbp_author_ip' 223 ); 224 225 // Topic content. 226 // Note: We join the 'posts' table because 'topics' table does not include topic content. 227 $this->field_map[] = array( 228 'from_tablename' => 'posts', 229 'from_fieldname' => 'message', 230 'join_tablename' => 'topics', 231 'join_type' => 'INNER', 232 'join_expression' => 'ON topics.first_post_id = posts.id', 233 'to_type' => 'topic', 234 'to_fieldname' => 'post_content', 235 'callback_method' => 'callback_html' 236 ); 237 238 // Topic title. 239 $this->field_map[] = array( 240 'from_tablename' => 'topics', 241 'from_fieldname' => 'subject', 242 'to_type' => 'topic', 243 'to_fieldname' => 'post_title' 244 ); 245 246 // Topic slug (Clean name to avoid conflicts) 247 $this->field_map[] = array( 248 'from_tablename' => 'topics', 249 'from_fieldname' => 'subject', 250 'to_type' => 'topic', 251 'to_fieldname' => 'post_name', 252 'callback_method' => 'callback_slug' 253 ); 254 255 // Topic parent forum id (If no parent, then 0) 256 $this->field_map[] = array( 257 'from_tablename' => 'topics', 258 'from_fieldname' => 'forum_id', 259 'to_type' => 'topic', 260 'to_fieldname' => 'post_parent', 261 'callback_method' => 'callback_forumid' 262 ); 263 264 // Sticky status (Stored in postmeta) 265 $this->field_map[] = array( 266 'from_tablename' => 'topics', 267 'from_fieldname' => 'sticky', 268 'to_type' => 'topic', 269 'to_fieldname' => '_bbp_old_sticky_status_id', 270 'callback_method' => 'callback_sticky_status' 271 ); 272 273 // Topic dates. 274 $this->field_map[] = array( 275 'from_tablename' => 'topics', 276 'from_fieldname' => 'posted', 277 'to_type' => 'topic', 278 'to_fieldname' => 'post_date', 279 'callback_method' => 'callback_datetime' 280 ); 281 $this->field_map[] = array( 282 'from_tablename' => 'topics', 283 'from_fieldname' => 'posted', 284 'to_type' => 'topic', 285 'to_fieldname' => 'post_date_gmt', 286 'callback_method' => 'callback_datetime' 287 ); 288 $this->field_map[] = array( 289 'from_tablename' => 'topics', 290 'from_fieldname' => 'posted', 291 'to_type' => 'topic', 292 'to_fieldname' => 'post_modified', 293 'callback_method' => 'callback_datetime' 294 ); 295 $this->field_map[] = array( 296 'from_tablename' => 'topics', 297 'from_fieldname' => 'posted', 298 'to_type' => 'topic', 299 'to_fieldname' => 'post_modified_gmt', 300 'callback_method' => 'callback_datetime' 301 ); 302 $this->field_map[] = array( 303 'from_tablename' => 'topics', 304 'from_fieldname' => 'posted', 305 'to_type' => 'topic', 306 'to_fieldname' => '_bbp_last_active_time', 307 'callback_method' => 'callback_datetime' 308 ); 309 310 // Topic status (Open = 0 or Closed = 1, FluxBB v1.5.3) 311 $this->field_map[] = array( 312 'from_tablename' => 'topics', 313 'from_fieldname' => 'closed', 314 'to_type' => 'topic', 315 'to_fieldname' => '_bbp_old_closed_status_id', 316 'callback_method' => 'callback_topic_status' 317 ); 318 319 /** Tags Section ******************************************************/ 320 321 /** 322 * FluxBB v1.5.3 Forums do not support topic tags out of the box 323 */ 324 325 /** Topic Subscriptions Section ***************************************/ 326 327 // Subscribed topic ID (Stored in usermeta) 328 $this->field_map[] = array( 329 'from_tablename' => 'topic_subscriptions', 330 'from_fieldname' => 'topic_id', 331 'to_type' => 'topic_subscriptions', 332 'to_fieldname' => '_bbp_subscriptions' 333 ); 334 335 // Subscribed user ID (Stored in usermeta) 336 $this->field_map[] = array( 337 'from_tablename' => 'topic_subscriptions', 338 'from_fieldname' => 'user_id', 339 'to_type' => 'topic_subscriptions', 340 'to_fieldname' => 'user_id', 341 'callback_method' => 'callback_userid' 342 ); 343 344 /** Reply Section *****************************************************/ 345 346 // Old reply id (Stored in postmeta) 347 $this->field_map[] = array( 348 'from_tablename' => 'posts', 349 'from_fieldname' => 'id', 350 'to_type' => 'reply', 351 'to_fieldname' => '_bbp_old_reply_id' 352 ); 353 354 // Reply parent forum id (If no parent, then 0, Stored in postmeta) 355 $this->field_map[] = array( 356 'from_tablename' => 'posts', 357 'from_fieldname' => 'topic_id', 358 'to_type' => 'reply', 359 'to_fieldname' => '_bbp_forum_id', 360 'callback_method' => 'callback_topicid_to_forumid' 361 ); 362 363 // Reply parent topic id (If no parent, then 0, Stored in postmeta) 364 $this->field_map[] = array( 365 'from_tablename' => 'posts', 366 'from_fieldname' => 'topic_id', 367 'to_type' => 'reply', 368 'to_fieldname' => '_bbp_topic_id', 369 'callback_method' => 'callback_topicid' 370 ); 371 372 // Reply author ip (Stored in postmeta) 373 $this->field_map[] = array( 374 'from_tablename' => 'posts', 375 'from_fieldname' => 'poster_ip', 376 'to_type' => 'reply', 377 'to_fieldname' => '_bbp_author_ip' 378 ); 379 380 // Reply author. 381 $this->field_map[] = array( 382 'from_tablename' => 'posts', 383 'from_fieldname' => 'poster_id', 384 'to_type' => 'reply', 385 'to_fieldname' => 'post_author', 386 'callback_method' => 'callback_userid' 387 ); 388 389 // Reply content. 390 $this->field_map[] = array( 391 'from_tablename' => 'posts', 392 'from_fieldname' => 'message', 393 'to_type' => 'reply', 394 'to_fieldname' => 'post_content', 395 'callback_method' => 'callback_html' 396 ); 397 398 // Reply parent topic id (If no parent, then 0) 399 $this->field_map[] = array( 400 'from_tablename' => 'posts', 401 'from_fieldname' => 'topic_id', 402 'to_type' => 'reply', 403 'to_fieldname' => 'post_parent', 404 'callback_method' => 'callback_topicid' 405 ); 406 407 // Reply dates. 408 $this->field_map[] = array( 409 'from_tablename' => 'posts', 410 'from_fieldname' => 'posted', 411 'to_type' => 'reply', 412 'to_fieldname' => 'post_date', 413 'callback_method' => 'callback_datetime' 414 ); 415 $this->field_map[] = array( 416 'from_tablename' => 'posts', 417 'from_fieldname' => 'posted', 418 'to_type' => 'reply', 419 'to_fieldname' => 'post_date_gmt', 420 'callback_method' => 'callback_datetime' 421 ); 422 $this->field_map[] = array( 423 'from_tablename' => 'posts', 424 'from_fieldname' => 'posted', 425 'to_type' => 'reply', 426 'to_fieldname' => 'post_modified', 427 'callback_method' => 'callback_datetime' 428 ); 429 $this->field_map[] = array( 430 'from_tablename' => 'posts', 431 'from_fieldname' => 'posted', 432 'to_type' => 'reply', 433 'to_fieldname' => 'post_modified_gmt', 434 'callback_method' => 'callback_datetime' 435 ); 436 437 /** User Section ******************************************************/ 438 439 // Store old user id (Stored in usermeta) 440 $this->field_map[] = array( 441 'from_tablename' => 'users', 442 'from_fieldname' => 'id', 443 'to_type' => 'user', 444 'to_fieldname' => '_bbp_old_user_id' 445 ); 446 447 // Store old user password (Stored in usermeta serialized with salt) 448 $this->field_map[] = array( 449 'from_tablename' => 'users', 450 'from_fieldname' => 'password', 451 'to_type' => 'user', 452 'to_fieldname' => '_bbp_password', 453 'callback_method' => 'callback_savepass' 454 ); 455 456 // Store old user salt (This is only used for the SELECT row info for the above password save) 457 // $this->field_map[] = array( 458 // 'from_tablename' => 'users', 459 // 'from_fieldname' => 'salt', 460 // 'to_type' => 'user', 461 // 'to_fieldname' => '' 462 // ); 463 464 // User password verify class (Stored in usermeta for verifying password) 465 $this->field_map[] = array( 466 'to_type' => 'users', 467 'to_fieldname' => '_bbp_class', 468 'default' => 'FluxBB' 469 ); 470 471 // User name. 472 $this->field_map[] = array( 473 'from_tablename' => 'users', 474 'from_fieldname' => 'username', 475 'to_type' => 'user', 476 'to_fieldname' => 'user_login' 477 ); 478 479 // User nice name. 480 $this->field_map[] = array( 481 'from_tablename' => 'users', 482 'from_fieldname' => 'username', 483 'to_type' => 'user', 484 'to_fieldname' => 'user_nicename' 485 ); 486 487 // User email. 488 $this->field_map[] = array( 489 'from_tablename' => 'users', 490 'from_fieldname' => 'email', 491 'to_type' => 'user', 492 'to_fieldname' => 'user_email' 493 ); 494 495 // User homepage. 496 $this->field_map[] = array( 497 'from_tablename' => 'users', 498 'from_fieldname' => 'url', 499 'to_type' => 'user', 500 'to_fieldname' => 'user_url' 501 ); 502 503 // User registered. 504 $this->field_map[] = array( 505 'from_tablename' => 'users', 506 'from_fieldname' => 'registered', 507 'to_type' => 'user', 508 'to_fieldname' => 'user_registered', 509 'callback_method' => 'callback_datetime' 510 ); 511 512 // User display name. 513 $this->field_map[] = array( 514 'from_tablename' => 'users', 515 'from_fieldname' => 'realname', 516 'to_type' => 'user', 517 'to_fieldname' => 'display_name' 518 ); 519 520 // User AIM (Stored in usermeta) 521 $this->field_map[] = array( 522 'from_tablename' => 'users', 523 'from_fieldname' => 'aim', 524 'to_type' => 'user', 525 'to_fieldname' => '_bbp_fluxbb_user_aim' 526 ); 527 528 // User Yahoo (Stored in usermeta) 529 $this->field_map[] = array( 530 'from_tablename' => 'users', 531 'from_fieldname' => 'yahoo', 532 'to_type' => 'user', 533 'to_fieldname' => '_bbp_fluxbb_user_yim' 534 ); 535 536 // Store Jabber 537 $this->field_map[] = array( 538 'from_tablename' => 'users', 539 'from_fieldname' => 'jabber', 540 'to_type' => 'user', 541 'to_fieldname' => '_bbp_fluxbb_user_jabber' 542 ); 543 544 // Store ICQ (Stored in usermeta) 545 $this->field_map[] = array( 546 'from_tablename' => 'users', 547 'from_fieldname' => 'icq', 548 'to_type' => 'user', 549 'to_fieldname' => '_bbp_fluxbb_user_icq' 550 ); 551 552 // Store MSN (Stored in usermeta) 553 $this->field_map[] = array( 554 'from_tablename' => 'users', 555 'from_fieldname' => 'msn', 556 'to_type' => 'user', 557 'to_fieldname' => '_bbp_fluxbb_user_msn' 558 ); 559 560 // Store Location (Stored in usermeta) 561 $this->field_map[] = array( 562 'from_tablename' => 'users', 563 'from_fieldname' => 'location', 564 'to_type' => 'user', 565 'to_fieldname' => '_bbp_fluxbb_user_location' 566 ); 567 568 // Store Signature (Stored in usermeta) 569 $this->field_map[] = array( 570 'from_tablename' => 'users', 571 'from_fieldname' => 'signature', 572 'to_type' => 'user', 573 'to_fieldname' => '_bbp_fluxbb_user_sig', 574 'callback_method' => 'callback_html' 575 ); 576 577 // Store Admin Note (Stored in usermeta) 578 $this->field_map[] = array( 579 'from_tablename' => 'users', 580 'from_fieldname' => 'admin_note', 581 'to_type' => 'user', 582 'to_fieldname' => '_bbp_fluxbb_user_admin_note' 583 ); 584 585 } 586 587 /** 588 * This method allows us to indicates what is or is not converted for each 589 * converter. 590 */ 591 public function info() { 592 return ''; 593 } 594 595 /** 596 * This method is to save the salt and password together. That 597 * way when we authenticate it we can get it out of the database 598 * as one value. Array values are auto sanitized by WordPress. 599 */ 600 public function callback_savepass( $field, $row ) { 601 $pass_array = array( 'hash' => $field, 'salt' => $row['salt'] ); 602 return $pass_array; 603 } 604 605 /** 606 * This method is to take the pass out of the database and compare 607 * to a pass the user has typed in. 608 */ 609 public function authenticate_pass( $password, $serialized_pass ) { 610 $pass_array = unserialize( $serialized_pass ); 611 return ( $pass_array['hash'] == md5( md5( $password ). $pass_array['salt'] ) ); 612 } 613 614 /** 615 * Translate the post status from FluxBB v1.5.3 numerics to WordPress's strings. 616 * 617 * @param int $status FluxBB v1.5.3 numeric topic status 618 * @return string WordPress safe 619 */ 620 public function callback_topic_status( $status = 0 ) { 621 switch ( $status ) { 622 case 1 : 623 $status = 'closed'; 624 break; 625 626 case 0 : 627 default : 628 $status = 'publish'; 629 break; 630 } 631 return $status; 632 } 633 634 /** 635 * Translate the topic sticky status type from FluxBB v1.5.3 numerics to WordPress's strings. 636 * 637 * @param int $status FluxBB v1.5.3 numeric forum type 638 * @return string WordPress safe 639 */ 640 public function callback_sticky_status( $status = 0 ) { 641 switch ( $status ) { 642 case 1 : 643 $status = 'sticky'; // FluxBB Sticky 'sticky = 1' 644 break; 645 646 case 0 : 647 default : 648 $status = 'normal'; // FluxBB Normal Topic 'sticky = 0' 649 break; 650 } 651 return $status; 652 } 653 654 /** 655 * Verify the topic/reply count. 656 * 657 * @param int $count FluxBB v1.5.3 topic/reply counts 658 * @return string WordPress safe 659 */ 660 public function callback_topic_reply_count( $count = 1 ) { 661 $count = absint( (int) $count - 1 ); 662 return $count; 663 } 664 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Oct 3 01:00:49 2024 | Cross-referenced by PHPXref 0.7.1 |