[ Index ] |
PHP Cross Reference of BBPress |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * bbPress Kunena 1.x Converter 5 * 6 * @package bbPress 7 * @subpackage Converters 8 */ 9 10 /** 11 * Implementation of Kunena v1.x Forums for Joomla Forum converter. 12 * 13 * @since 2.5.0 bbPress (r5144) 14 * 15 * @link Codex Docs https://codex.bbpress.org/import-forums/kunena/ 16 */ 17 class Kunena1 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' => 'kunena_categories', 37 'from_fieldname' => 'id', 38 'to_type' => 'forum', 39 'to_fieldname' => '_bbp_old_forum_id' 40 ); 41 42 // Forum parent id (If no parent, then 0, Stored in postmeta) 43 $this->field_map[] = array( 44 'from_tablename' => 'kunena_categories', 45 'from_fieldname' => 'parent', 46 'to_type' => 'forum', 47 'to_fieldname' => '_bbp_old_forum_parent_id' 48 ); 49 50 // Forum topic count (Stored in postmeta) 51 $this->field_map[] = array( 52 'from_tablename' => 'kunena_categories', 53 'from_fieldname' => 'numTopics', 54 'to_type' => 'forum', 55 'to_fieldname' => '_bbp_topic_count' 56 ); 57 58 // Forum reply count (Stored in postmeta) 59 $this->field_map[] = array( 60 'from_tablename' => 'kunena_categories', 61 'from_fieldname' => 'numPosts', 62 'to_type' => 'forum', 63 'to_fieldname' => '_bbp_reply_count' 64 ); 65 66 // Forum total topic count (Includes unpublished topics, Stored in postmeta) 67 $this->field_map[] = array( 68 'from_tablename' => 'kunena_categories', 69 'from_fieldname' => 'numTopics', 70 'to_type' => 'forum', 71 'to_fieldname' => '_bbp_total_topic_count' 72 ); 73 74 // Forum total reply count (Includes unpublished replies, Stored in postmeta) 75 $this->field_map[] = array( 76 'from_tablename' => 'kunena_categories', 77 'from_fieldname' => 'numPosts', 78 'to_type' => 'forum', 79 'to_fieldname' => '_bbp_total_reply_count' 80 ); 81 82 // Forum title. 83 $this->field_map[] = array( 84 'from_tablename' => 'kunena_categories', 85 'from_fieldname' => 'name', 86 'to_type' => 'forum', 87 'to_fieldname' => 'post_title' 88 ); 89 90 // Forum slug (Clean name to avoid conflicts) 91 $this->field_map[] = array( 92 'from_tablename' => 'kunena_categories', 93 'from_fieldname' => 'name', 94 'to_type' => 'forum', 95 'to_fieldname' => 'post_name', 96 'callback_method' => 'callback_slug' 97 ); 98 99 // Forum description. 100 $this->field_map[] = array( 101 'from_tablename' => 'kunena_categories', 102 'from_fieldname' => 'description', 103 'to_type' => 'forum', 104 'to_fieldname' => 'post_content', 105 'callback_method' => 'callback_null' 106 ); 107 108 // Forum display order (Starts from 1) 109 $this->field_map[] = array( 110 'from_tablename' => 'kunena_categories', 111 'from_fieldname' => 'ordering', 112 'to_type' => 'forum', 113 'to_fieldname' => 'menu_order' 114 ); 115 116 // Forum type (Category = 0 or Forum > 0, Stored in postmeta) 117 $this->field_map[] = array( 118 'from_tablename' => 'kunena_categories', 119 'from_fieldname' => 'parent', 120 'to_type' => 'forum', 121 'to_fieldname' => '_bbp_forum_type', 122 'callback_method' => 'callback_forum_type' 123 ); 124 125 // Forum status (Open = 0 or Closed = 1, Stored in postmeta) 126 $this->field_map[] = array( 127 'from_tablename' => 'kunena_categories', 128 'from_fieldname' => 'locked', 129 'to_type' => 'forum', 130 'to_fieldname' => '_bbp_status', 131 'callback_method' => 'callback_forum_status' 132 ); 133 134 // Forum dates. 135 $this->field_map[] = array( 136 'to_type' => 'forum', 137 'to_fieldname' => 'post_date', 138 'default' => date('Y-m-d H:i:s') 139 ); 140 $this->field_map[] = array( 141 'to_type' => 'forum', 142 'to_fieldname' => 'post_date_gmt', 143 'default' => date('Y-m-d H:i:s') 144 ); 145 $this->field_map[] = array( 146 'to_type' => 'forum', 147 'to_fieldname' => 'post_modified', 148 'default' => date('Y-m-d H:i:s') 149 ); 150 $this->field_map[] = array( 151 'to_type' => 'forum', 152 'to_fieldname' => 'post_modified_gmt', 153 'default' => date('Y-m-d H:i:s') 154 ); 155 156 /** Topic Section *****************************************************/ 157 158 // Old topic id (Stored in postmeta) 159 $this->field_map[] = array( 160 'from_tablename' => 'kunena_messages', 161 'from_fieldname' => 'thread', 162 'to_type' => 'topic', 163 'to_fieldname' => '_bbp_old_topic_id' 164 ); 165 166 // Topic parent forum id (If no parent, then 0. Stored in postmeta) 167 $this->field_map[] = array( 168 'from_tablename' => 'kunena_messages', 169 'from_fieldname' => 'catid', 170 'to_type' => 'topic', 171 'to_fieldname' => '_bbp_forum_id', 172 'callback_method' => 'callback_forumid' 173 ); 174 175 // Topic author. 176 $this->field_map[] = array( 177 'from_tablename' => 'kunena_messages', 178 'from_fieldname' => 'userid', 179 'to_type' => 'topic', 180 'to_fieldname' => 'post_author', 181 'callback_method' => 'callback_userid' 182 ); 183 184 // Topic Author ip (Stored in postmeta) 185 $this->field_map[] = array( 186 'from_tablename' => 'kunena_messages', 187 'from_fieldname' => 'ip', 188 'to_type' => 'topic', 189 'to_fieldname' => '_bbp_author_ip' 190 ); 191 192 // Topic content. 193 // Note: We join the 'kunena_messages_text' table because 'kunena_messages' table does not include topic content. 194 $this->field_map[] = array( 195 'from_tablename' => 'kunena_messages_text', 196 'from_fieldname' => 'message', 197 'join_tablename' => 'kunena_messages', 198 'join_type' => 'INNER', 199 'join_expression' => 'ON kunena_messages_text.mesid = kunena_messages.id WHERE kunena_messages.parent = 0', 200 'to_type' => 'topic', 201 'to_fieldname' => 'post_content', 202 'callback_method' => 'callback_html' 203 ); 204 205 // Topic title. 206 $this->field_map[] = array( 207 'from_tablename' => 'kunena_messages', 208 'from_fieldname' => 'subject', 209 'to_type' => 'topic', 210 'to_fieldname' => 'post_title' 211 ); 212 213 // Topic slug (Clean name to avoid conflicts) 214 $this->field_map[] = array( 215 'from_tablename' => 'kunena_messages', 216 'from_fieldname' => 'subject', 217 'to_type' => 'topic', 218 'to_fieldname' => 'post_name', 219 'callback_method' => 'callback_slug' 220 ); 221 222 // Topic parent forum id (If no parent, then 0) 223 $this->field_map[] = array( 224 'from_tablename' => 'kunena_messages', 225 'from_fieldname' => 'catid', 226 'to_type' => 'topic', 227 'to_fieldname' => 'post_parent', 228 'callback_method' => 'callback_forumid' 229 ); 230 231 // Topic dates. 232 $this->field_map[] = array( 233 'from_tablename' => 'kunena_messages', 234 'from_fieldname' => 'time', 235 'to_type' => 'topic', 236 'to_fieldname' => 'post_date', 237 'callback_method' => 'callback_datetime' 238 ); 239 $this->field_map[] = array( 240 'from_tablename' => 'kunena_messages', 241 'from_fieldname' => 'time', 242 'to_type' => 'topic', 243 'to_fieldname' => 'post_date_gmt', 244 'callback_method' => 'callback_datetime' 245 ); 246 $this->field_map[] = array( 247 'from_tablename' => 'kunena_messages', 248 'from_fieldname' => 'time', 249 'to_type' => 'topic', 250 'to_fieldname' => 'post_modified', 251 'callback_method' => 'callback_datetime' 252 ); 253 $this->field_map[] = array( 254 'from_tablename' => 'kunena_messages', 255 'from_fieldname' => 'time', 256 'to_type' => 'topic', 257 'to_fieldname' => 'post_modified_gmt', 258 'callback_method' => 'callback_datetime' 259 ); 260 $this->field_map[] = array( 261 'from_tablename' => 'kunena_messages', 262 'from_fieldname' => 'time', 263 'to_type' => 'topic', 264 'to_fieldname' => '_bbp_last_active_time', 265 'callback_method' => 'callback_datetime' 266 ); 267 268 // Topic status (Open or Closed, Kunena v3.x 0=open & 1=closed) 269 $this->field_map[] = array( 270 'from_tablename' => 'kunena_messages', 271 'from_fieldname' => 'locked', 272 'to_type' => 'topic', 273 'to_fieldname' => '_bbp_old_closed_status_id', 274 'callback_method' => 'callback_topic_status' 275 ); 276 277 /** Tags Section ******************************************************/ 278 279 /** 280 * Kunena v1.x Forums do not support topic tags out of the box 281 */ 282 283 /** Reply Section *****************************************************/ 284 285 // Old reply id (Stored in postmeta) 286 $this->field_map[] = array( 287 'from_tablename' => 'kunena_messages', 288 'from_fieldname' => 'id', 289 'to_type' => 'reply', 290 'to_fieldname' => '_bbp_old_reply_id' 291 ); 292 293 // Reply parent forum id (If no parent, then 0. Stored in postmeta) 294 $this->field_map[] = array( 295 'from_tablename' => 'kunena_messages', 296 'from_fieldname' => 'catid', 297 'to_type' => 'reply', 298 'to_fieldname' => '_bbp_forum_id', 299 'callback_method' => 'callback_topicid_to_forumid' 300 ); 301 302 // Reply parent topic id (If no parent, then 0. Stored in postmeta) 303 $this->field_map[] = array( 304 'from_tablename' => 'kunena_messages', 305 'from_fieldname' => 'thread', 306 'to_type' => 'reply', 307 'to_fieldname' => '_bbp_topic_id', 308 'callback_method' => 'callback_topicid' 309 ); 310 311 // Reply author ip (Stored in postmeta) 312 $this->field_map[] = array( 313 'from_tablename' => 'kunena_messages', 314 'from_fieldname' => 'ip', 315 'to_type' => 'reply', 316 'to_fieldname' => '_bbp_author_ip' 317 ); 318 319 // Reply author. 320 $this->field_map[] = array( 321 'from_tablename' => 'kunena_messages', 322 'from_fieldname' => 'userid', 323 'to_type' => 'reply', 324 'to_fieldname' => 'post_author', 325 'callback_method' => 'callback_userid' 326 ); 327 328 // Reply content. 329 // Note: We join the 'kunena_messages_text' table because 'kunena_messages' table does not include reply content. 330 $this->field_map[] = array( 331 'from_tablename' => 'kunena_messages_text', 332 'from_fieldname' => 'message', 333 'join_tablename' => 'kunena_messages', 334 'join_type' => 'INNER', 335 'join_expression' => 'ON kunena_messages.id = kunena_messages_text.mesid WHERE kunena_messages.parent != 0', 336 'to_type' => 'reply', 337 'to_fieldname' => 'post_content', 338 'callback_method' => 'callback_html' 339 ); 340 341 // Reply parent topic id (If no parent, then 0) 342 $this->field_map[] = array( 343 'from_tablename' => 'kunena_messages', 344 'from_fieldname' => 'thread', 345 'to_type' => 'reply', 346 'to_fieldname' => 'post_parent', 347 'callback_method' => 'callback_topicid' 348 ); 349 350 // Reply dates. 351 $this->field_map[] = array( 352 'from_tablename' => 'kunena_messages', 353 'from_fieldname' => 'time', 354 'to_type' => 'reply', 355 'to_fieldname' => 'post_date', 356 'callback_method' => 'callback_datetime' 357 ); 358 $this->field_map[] = array( 359 'from_tablename' => 'kunena_messages', 360 'from_fieldname' => 'time', 361 'to_type' => 'reply', 362 'to_fieldname' => 'post_date_gmt', 363 'callback_method' => 'callback_datetime' 364 ); 365 $this->field_map[] = array( 366 'from_tablename' => 'kunena_messages', 367 'from_fieldname' => 'time', 368 'to_type' => 'reply', 369 'to_fieldname' => 'post_modified', 370 'callback_method' => 'callback_datetime' 371 ); 372 $this->field_map[] = array( 373 'from_tablename' => 'kunena_messages', 374 'from_fieldname' => 'time', 375 'to_type' => 'reply', 376 'to_fieldname' => 'post_modified_gmt', 377 'callback_method' => 'callback_datetime' 378 ); 379 380 /** User Section ******************************************************/ 381 382 //Note: We are importing the Joomla User details and the Kunena v1.x user profile details. 383 384 // Store old user id (Stored in usermeta) 385 $this->field_map[] = array( 386 'from_tablename' => 'users', 387 'from_fieldname' => 'id', 388 'to_type' => 'user', 389 'to_fieldname' => '_bbp_old_user_id' 390 ); 391 392 // Store old user password (Stored in usermeta serialized with salt) 393 $this->field_map[] = array( 394 'from_tablename' => 'users', 395 'from_fieldname' => 'password', 396 'to_type' => 'user', 397 'to_fieldname' => '_bbp_password', 398 'callback_method' => 'callback_savepass' 399 ); 400 401 // Store old user salt (This is only used for the SELECT row info for the above password save) 402 // $this->field_map[] = array( 403 // 'from_tablename' => 'user', 404 // 'from_fieldname' => 'salt', 405 // 'to_type' => 'user', 406 // 'to_fieldname' => '' 407 // ); 408 409 // User password verify class (Stored in usermeta for verifying password) 410 // $this->field_map[] = array( 411 // 'to_type' => 'user', 412 // 'to_fieldname' => '_bbp_class', 413 // 'default' => 'Kunena1' 414 // ); 415 416 // User name. 417 $this->field_map[] = array( 418 'from_tablename' => 'users', 419 'from_fieldname' => 'username', 420 'to_type' => 'user', 421 'to_fieldname' => 'user_login' 422 ); 423 424 // User email. 425 $this->field_map[] = array( 426 'from_tablename' => 'users', 427 'from_fieldname' => 'email', 428 'to_type' => 'user', 429 'to_fieldname' => 'user_email' 430 ); 431 432 // User registered. 433 $this->field_map[] = array( 434 'from_tablename' => 'users', 435 'from_fieldname' => 'registerDate', 436 'to_type' => 'user', 437 'to_fieldname' => 'user_registered', 438 'callback_method' => 'callback_datetime' 439 ); 440 } 441 442 /** 443 * This method allows us to indicates what is or is not converted for each 444 * converter. 445 */ 446 public function info() { 447 return ''; 448 } 449 450 /** 451 * This method is to save the salt and password together. That 452 * way when we authenticate it we can get it out of the database 453 * as one value. Array values are auto sanitized by WordPress. 454 */ 455 public function callback_savepass($field, $row) { 456 $pass_array = array('hash' => $field, 'salt' => $row['salt']); 457 return $pass_array; 458 } 459 460 /** 461 * This method is to take the pass out of the database and compare 462 * to a pass the user has typed in. 463 */ 464 public function authenticate_pass($password, $serialized_pass) { 465 $pass_array = unserialize($serialized_pass); 466 return ( $pass_array['hash'] == md5(md5($password) . $pass_array['salt']) ); 467 } 468 469 /** 470 * Translate the forum type from Kunena v1.x numerics to WordPress's strings. 471 * 472 * @param int $status Kunena v1.x numeric forum type 473 * @return string WordPress safe 474 */ 475 public function callback_forum_type( $status = 0 ) { 476 if ( $status == 0 ) { 477 $status = 'category'; 478 } else { 479 $status = 'forum'; 480 } 481 return $status; 482 } 483 484 /** 485 * Translate the forum status from Kunena v1.x numerics to WordPress's strings. 486 * 487 * @param int $status Kunena v1.x numeric forum status 488 * @return string WordPress safe 489 */ 490 public function callback_forum_status( $status = 0 ) { 491 switch ( $status ) { 492 case 1 : 493 $status = 'closed'; 494 break; 495 496 case 0 : 497 default : 498 $status = 'open'; 499 break; 500 } 501 return $status; 502 } 503 504 /** 505 * Translate the post status from Kunena v1.x numerics to WordPress's strings. 506 * 507 * @param int $status Kunena v1.x numeric topic status 508 * @return string WordPress safe 509 */ 510 public function callback_topic_status( $status = 0 ) { 511 switch ( $status ) { 512 case 1 : 513 $status = 'closed'; 514 break; 515 516 case 0 : 517 default : 518 $status = 'publish'; 519 break; 520 } 521 return $status; 522 } 523 }
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 |