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