| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* bbPress Example Converter |
| 5 |
* |
| 6 |
* @package bbPress |
| 7 |
* @subpackage Converters |
| 8 |
*/ |
| 9 |
|
| 10 |
/** |
| 11 |
* Example converter base impoprter template for bbPress |
| 12 |
* |
| 13 |
* @since 2.3.0 bbPress (r4689) |
| 14 |
* |
| 15 |
* @link Codex Docs https://codex.bbpress.org/import-forums/custom-import |
| 16 |
*/ |
| 17 |
class Example 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 |
// Setup table joins for the forum section at the base of this section |
| 34 |
|
| 35 |
// Old forum id (Stored in postmeta) |
| 36 |
$this->field_map[] = array( |
| 37 |
'from_tablename' => 'forums_table', |
| 38 |
'from_fieldname' => 'the_forum_id', |
| 39 |
'to_type' => 'forum', |
| 40 |
'to_fieldname' => '_bbp_old_forum_id' |
| 41 |
); |
| 42 |
|
| 43 |
// Forum parent id (If no parent, then 0. Stored in postmeta) |
| 44 |
$this->field_map[] = array( |
| 45 |
'from_tablename' => 'forums_table', |
| 46 |
'from_fieldname' => 'the_parent_id', |
| 47 |
'to_type' => 'forum', |
| 48 |
'to_fieldname' => '_bbp_old_forum_parent_id' |
| 49 |
); |
| 50 |
|
| 51 |
// Forum topic count (Stored in postmeta) |
| 52 |
$this->field_map[] = array( |
| 53 |
'from_tablename' => 'forums_table', |
| 54 |
'from_fieldname' => 'the_topic_count', |
| 55 |
'to_type' => 'forum', |
| 56 |
'to_fieldname' => '_bbp_topic_count' |
| 57 |
); |
| 58 |
|
| 59 |
// Forum reply count (Stored in postmeta) |
| 60 |
$this->field_map[] = array( |
| 61 |
'from_tablename' => 'forums_table', |
| 62 |
'from_fieldname' => 'the_reply_count', |
| 63 |
'to_type' => 'forum', |
| 64 |
'to_fieldname' => '_bbp_reply_count' |
| 65 |
); |
| 66 |
|
| 67 |
// Forum total topic count (Stored in postmeta) |
| 68 |
$this->field_map[] = array( |
| 69 |
'from_tablename' => 'forums_table', |
| 70 |
'from_fieldname' => 'the_total_topic_count', |
| 71 |
'to_type' => 'forum', |
| 72 |
'to_fieldname' => '_bbp_total_topic_count' |
| 73 |
); |
| 74 |
|
| 75 |
// Forum total reply count (Stored in postmeta) |
| 76 |
$this->field_map[] = array( |
| 77 |
'from_tablename' => 'forums_table', |
| 78 |
'from_fieldname' => 'the_total_reply_count', |
| 79 |
'to_type' => 'forum', |
| 80 |
'to_fieldname' => '_bbp_total_reply_count' |
| 81 |
); |
| 82 |
|
| 83 |
// Forum title. |
| 84 |
$this->field_map[] = array( |
| 85 |
'from_tablename' => 'forums_table', |
| 86 |
'from_fieldname' => 'the_forum_title', |
| 87 |
'to_type' => 'forum', |
| 88 |
'to_fieldname' => 'post_title' |
| 89 |
); |
| 90 |
|
| 91 |
// Forum slug (Clean name to avoid confilcts) |
| 92 |
$this->field_map[] = array( |
| 93 |
'from_tablename' => 'forums_table', |
| 94 |
'from_fieldname' => 'the_forum_slug', |
| 95 |
'to_type' => 'forum', |
| 96 |
'to_fieldname' => 'post_name', |
| 97 |
'callback_method' => 'callback_slug' |
| 98 |
); |
| 99 |
|
| 100 |
// Forum description. |
| 101 |
$this->field_map[] = array( |
| 102 |
'from_tablename' => 'forums_table', |
| 103 |
'from_fieldname' => 'the_forum_description', |
| 104 |
'to_type' => 'forum', |
| 105 |
'to_fieldname' => 'post_content', |
| 106 |
'callback_method' => 'callback_null' |
| 107 |
); |
| 108 |
|
| 109 |
// Forum display order (Starts from 1) |
| 110 |
$this->field_map[] = array( |
| 111 |
'from_tablename' => 'forums_table', |
| 112 |
'from_fieldname' => 'the_forum_order', |
| 113 |
'to_type' => 'forum', |
| 114 |
'to_fieldname' => 'menu_order' |
| 115 |
); |
| 116 |
|
| 117 |
// Forum type (Category = 0 or Forum = 1, Stored in postmeta) |
| 118 |
$this->field_map[] = array( |
| 119 |
'from_tablename' => 'forums_table', |
| 120 |
'from_fieldname' => 'the_forum_type', |
| 121 |
'to_type' => 'forum', |
| 122 |
'to_fieldname' => '_bbp_forum_type', |
| 123 |
'callback_method' => 'callback_forum_type' |
| 124 |
); |
| 125 |
|
| 126 |
// Forum status (Unlocked = 0 or Locked = 1, Stored in postmeta) |
| 127 |
$this->field_map[] = array( |
| 128 |
'from_tablename' => 'forums_table', |
| 129 |
'from_fieldname' => 'the_forum_status', |
| 130 |
'to_type' => 'forum', |
| 131 |
'to_fieldname' => '_bbp_status', |
| 132 |
'callback_method' => 'callback_forum_status' |
| 133 |
); |
| 134 |
|
| 135 |
// Forum dates. |
| 136 |
$this->field_map[] = array( |
| 137 |
'to_type' => 'forum', |
| 138 |
'to_fieldname' => 'post_date', |
| 139 |
'default' => date('Y-m-d H:i:s') |
| 140 |
); |
| 141 |
$this->field_map[] = array( |
| 142 |
'to_type' => 'forum', |
| 143 |
'to_fieldname' => 'post_date_gmt', |
| 144 |
'default' => date('Y-m-d H:i:s') |
| 145 |
); |
| 146 |
$this->field_map[] = array( |
| 147 |
'to_type' => 'forum', |
| 148 |
'to_fieldname' => 'post_modified', |
| 149 |
'default' => date('Y-m-d H:i:s') |
| 150 |
); |
| 151 |
$this->field_map[] = array( |
| 152 |
'to_type' => 'forum', |
| 153 |
'to_fieldname' => 'post_modified_gmt', |
| 154 |
'default' => date('Y-m-d H:i:s') |
| 155 |
); |
| 156 |
|
| 157 |
// Setup the table joins for the forum section |
| 158 |
$this->field_map[] = array( |
| 159 |
'from_tablename' => 'groups_table', |
| 160 |
'from_fieldname' => 'forum_id', |
| 161 |
'join_tablename' => 'forums_table', |
| 162 |
'join_type' => 'INNER', |
| 163 |
'join_expression' => 'USING groups_table.forum_id = forums_table.forum_id', |
| 164 |
// 'from_expression' => 'WHERE forums_table.forum_id != 1', |
| 165 |
'to_type' => 'forum' |
| 166 |
); |
| 167 |
|
| 168 |
/** Forum Subscriptions Section ***************************************/ |
| 169 |
|
| 170 |
// Subscribed forum ID (Stored in usermeta) |
| 171 |
$this->field_map[] = array( |
| 172 |
'from_tablename' => 'forum_subscriptions_table', |
| 173 |
'from_fieldname' => 'the_forum_id', |
| 174 |
'to_type' => 'forum_subscriptions', |
| 175 |
'to_fieldname' => '_bbp_forum_subscriptions' |
| 176 |
); |
| 177 |
|
| 178 |
// Subscribed user ID (Stored in usermeta) |
| 179 |
$this->field_map[] = array( |
| 180 |
'from_tablename' => 'forum_subscriptions_table', |
| 181 |
'from_fieldname' => 'the_user_id', |
| 182 |
'to_type' => 'forum_subscriptions', |
| 183 |
'to_fieldname' => 'user_id', |
| 184 |
'callback_method' => 'callback_userid' |
| 185 |
); |
| 186 |
|
| 187 |
/** Topic Section *****************************************************/ |
| 188 |
|
| 189 |
// Setup table joins for the topic section at the base of this section |
| 190 |
|
| 191 |
// Old topic id (Stored in postmeta) |
| 192 |
$this->field_map[] = array( |
| 193 |
'from_tablename' => 'topics_table', |
| 194 |
'from_fieldname' => 'the_topic_id', |
| 195 |
'to_type' => 'topic', |
| 196 |
'to_fieldname' => '_bbp_old_topic_id' |
| 197 |
); |
| 198 |
|
| 199 |
// Topic reply count (Stored in postmeta) |
| 200 |
$this->field_map[] = array( |
| 201 |
'from_tablename' => 'topics_table', |
| 202 |
'from_fieldname' => 'the_topic_reply_count', |
| 203 |
'to_type' => 'topic', |
| 204 |
'to_fieldname' => '_bbp_reply_count', |
| 205 |
'callback_method' => 'callback_topic_reply_count' |
| 206 |
); |
| 207 |
|
| 208 |
// Topic total reply count (Stored in postmeta) |
| 209 |
$this->field_map[] = array( |
| 210 |
'from_tablename' => 'topics_table', |
| 211 |
'from_fieldname' => 'the_total_topic_reply_count', |
| 212 |
'to_type' => 'topic', |
| 213 |
'to_fieldname' => '_bbp_total_reply_count', |
| 214 |
'callback_method' => 'callback_topic_reply_count' |
| 215 |
); |
| 216 |
|
| 217 |
// Topic parent forum id (If no parent, then 0. Stored in postmeta) |
| 218 |
$this->field_map[] = array( |
| 219 |
'from_tablename' => 'topics_table', |
| 220 |
'from_fieldname' => 'the_topic_parent_forum_id', |
| 221 |
'to_type' => 'topic', |
| 222 |
'to_fieldname' => '_bbp_forum_id', |
| 223 |
'callback_method' => 'callback_forumid' |
| 224 |
); |
| 225 |
|
| 226 |
// Topic author. |
| 227 |
$this->field_map[] = array( |
| 228 |
'from_tablename' => 'topics_table', |
| 229 |
'from_fieldname' => 'the_topic_author_id', |
| 230 |
'to_type' => 'topic', |
| 231 |
'to_fieldname' => 'post_author', |
| 232 |
'callback_method' => 'callback_userid' |
| 233 |
); |
| 234 |
|
| 235 |
// Topic author ip (Stored in postmeta) |
| 236 |
$this->field_map[] = array( |
| 237 |
'from_tablename' => 'topics_table', |
| 238 |
'from_fieldname' => 'the_topic_author_ip_address', |
| 239 |
'to_type' => 'topic', |
| 240 |
'to_fieldname' => '_bbp_author_ip' |
| 241 |
); |
| 242 |
|
| 243 |
// Topic content. |
| 244 |
$this->field_map[] = array( |
| 245 |
'from_tablename' => 'topics_table', |
| 246 |
'from_fieldname' => 'the_topic_content', |
| 247 |
'to_type' => 'topic', |
| 248 |
'to_fieldname' => 'post_content', |
| 249 |
'callback_method' => 'callback_html' |
| 250 |
); |
| 251 |
|
| 252 |
// Topic title. |
| 253 |
$this->field_map[] = array( |
| 254 |
'from_tablename' => 'topics_table', |
| 255 |
'from_fieldname' => 'the_topic_title', |
| 256 |
'to_type' => 'topic', |
| 257 |
'to_fieldname' => 'post_title' |
| 258 |
); |
| 259 |
|
| 260 |
// Topic slug (Clean name to avoid conflicts) |
| 261 |
$this->field_map[] = array( |
| 262 |
'from_tablename' => 'topics_table', |
| 263 |
'from_fieldname' => 'the_topic_slug', |
| 264 |
'to_type' => 'topic', |
| 265 |
'to_fieldname' => 'post_name', |
| 266 |
'callback_method' => 'callback_slug' |
| 267 |
); |
| 268 |
|
| 269 |
// Topic status (Open or Closed) |
| 270 |
$this->field_map[] = array( |
| 271 |
'from_tablename' => 'topics_table', |
| 272 |
'from_fieldname' => 'the_topic_status', |
| 273 |
'to_type' => 'topic', |
| 274 |
'to_fieldname' => '_bbp_old_closed_status_id', |
| 275 |
'callback_method' => 'callback_topic_status' |
| 276 |
); |
| 277 |
|
| 278 |
// Topic parent forum id (If no parent, then 0) |
| 279 |
$this->field_map[] = array( |
| 280 |
'from_tablename' => 'topics_table', |
| 281 |
'from_fieldname' => 'the_topic_parent_forum_id', |
| 282 |
'to_type' => 'topic', |
| 283 |
'to_fieldname' => 'post_parent', |
| 284 |
'callback_method' => 'callback_forumid' |
| 285 |
); |
| 286 |
|
| 287 |
// Sticky status (Stored in postmeta) |
| 288 |
$this->field_map[] = array( |
| 289 |
'from_tablename' => 'topics_table', |
| 290 |
'from_fieldname' => 'the_topic_sticky_status', |
| 291 |
'to_type' => 'topic', |
| 292 |
'to_fieldname' => '_bbp_old_sticky_status_id', |
| 293 |
'callback_method' => 'callback_sticky_status' |
| 294 |
); |
| 295 |
|
| 296 |
// Topic dates. |
| 297 |
$this->field_map[] = array( |
| 298 |
'from_tablename' => 'topics_table', |
| 299 |
'from_fieldname' => 'the_topic_creation_date', |
| 300 |
'to_type' => 'topic', |
| 301 |
'to_fieldname' => 'post_date', |
| 302 |
'callback_method' => 'callback_datetime' |
| 303 |
); |
| 304 |
$this->field_map[] = array( |
| 305 |
'from_tablename' => 'topics_table', |
| 306 |
'from_fieldname' => 'the_topic_creation_date', |
| 307 |
'to_type' => 'topic', |
| 308 |
'to_fieldname' => 'post_date_gmt', |
| 309 |
'callback_method' => 'callback_datetime' |
| 310 |
); |
| 311 |
$this->field_map[] = array( |
| 312 |
'from_tablename' => 'topics_table', |
| 313 |
'from_fieldname' => 'the_topic_modified_date', |
| 314 |
'to_type' => 'topic', |
| 315 |
'to_fieldname' => 'post_modified', |
| 316 |
'callback_method' => 'callback_datetime' |
| 317 |
); |
| 318 |
$this->field_map[] = array( |
| 319 |
'from_tablename' => 'topics_table', |
| 320 |
'from_fieldname' => 'the_topic_modified_date', |
| 321 |
'to_type' => 'topic', |
| 322 |
'to_fieldname' => 'post_modified_gmt', |
| 323 |
'callback_method' => 'callback_datetime' |
| 324 |
); |
| 325 |
$this->field_map[] = array( |
| 326 |
'from_tablename' => 'topics_table', |
| 327 |
'from_fieldname' => 'the_topic_modified_date', |
| 328 |
'to_type' => 'topic', |
| 329 |
'to_fieldname' => '_bbp_last_active_time', |
| 330 |
'callback_method' => 'callback_datetime' |
| 331 |
); |
| 332 |
|
| 333 |
// Setup any table joins needed for the topic section |
| 334 |
$this->field_map[] = array( |
| 335 |
'from_tablename' => 'replies_table', |
| 336 |
'from_fieldname' => 'the_topic_id', |
| 337 |
'join_tablename' => 'topics_table', |
| 338 |
'join_type' => 'INNER', |
| 339 |
'join_expression' => 'USING replies_table.the_topic_id = topics_table.the_topic_id', |
| 340 |
'from_expression' => 'WHERE forums_table.the_topic_id = 0', |
| 341 |
'to_type' => 'topic' |
| 342 |
); |
| 343 |
|
| 344 |
/** Tags Section ******************************************************/ |
| 345 |
|
| 346 |
// Setup table joins for the tag section at the base of this section |
| 347 |
// Setup any table joins needed for the tags section |
| 348 |
$this->field_map[] = array( |
| 349 |
'from_tablename' => 'tag_table', |
| 350 |
'from_fieldname' => 'the_topic_id', |
| 351 |
'join_tablename' => 'tagcontent_table', |
| 352 |
'join_type' => 'INNER', |
| 353 |
'join_expression' => 'USING tagcontent_table.tag_id = tags_table.tag_id', |
| 354 |
'from_expression' => 'WHERE tagcontent_table.tag_id = tag_table.tag_id', |
| 355 |
'to_type' => 'tags' |
| 356 |
); |
| 357 |
|
| 358 |
// Topic id. |
| 359 |
$this->field_map[] = array( |
| 360 |
'from_tablename' => 'tagcontent_table', |
| 361 |
'from_fieldname' => 'contentid', |
| 362 |
'to_type' => 'tags', |
| 363 |
'to_fieldname' => 'objectid', |
| 364 |
'callback_method' => 'callback_topicid' |
| 365 |
); |
| 366 |
|
| 367 |
// Taxonomy ID. |
| 368 |
$this->field_map[] = array( |
| 369 |
'from_tablename' => 'tagcontent_table', |
| 370 |
'from_fieldname' => 'tagid', |
| 371 |
'to_type' => 'tags', |
| 372 |
'to_fieldname' => 'taxonomy' |
| 373 |
); |
| 374 |
|
| 375 |
// Term text. |
| 376 |
$this->field_map[] = array( |
| 377 |
'from_tablename' => 'tag_table', |
| 378 |
'from_fieldname' => 'tagtext', |
| 379 |
'to_type' => 'tags', |
| 380 |
'to_fieldname' => 'name' |
| 381 |
); |
| 382 |
|
| 383 |
// Term slug. |
| 384 |
$this->field_map[] = array( |
| 385 |
'from_tablename' => 'tag_table', |
| 386 |
'from_fieldname' => 'tagslug', |
| 387 |
'to_type' => 'tags', |
| 388 |
'to_fieldname' => 'slug', |
| 389 |
'callback_method' => 'callback_slug' |
| 390 |
); |
| 391 |
|
| 392 |
// Term description. |
| 393 |
$this->field_map[] = array( |
| 394 |
'from_tablename' => 'tag_table', |
| 395 |
'from_fieldname' => 'tagdescription', |
| 396 |
'to_type' => 'tags', |
| 397 |
'to_fieldname' => 'description' |
| 398 |
); |
| 399 |
|
| 400 |
/** Topic Subscriptions Section ***************************************/ |
| 401 |
|
| 402 |
// Subscribed topic ID (Stored in usermeta) |
| 403 |
$this->field_map[] = array( |
| 404 |
'from_tablename' => 'topic_subscriptions_table', |
| 405 |
'from_fieldname' => 'the_topic_id', |
| 406 |
'to_type' => 'topic_subscriptions', |
| 407 |
'to_fieldname' => '_bbp_subscriptions' |
| 408 |
); |
| 409 |
|
| 410 |
// Subscribed user ID (Stored in usermeta) |
| 411 |
$this->field_map[] = array( |
| 412 |
'from_tablename' => 'topic_subscriptions_table', |
| 413 |
'from_fieldname' => 'the_user_id', |
| 414 |
'to_type' => 'topic_subscriptions', |
| 415 |
'to_fieldname' => 'user_id', |
| 416 |
'callback_method' => 'callback_userid' |
| 417 |
); |
| 418 |
|
| 419 |
/** Favorites Section *************************************************/ |
| 420 |
|
| 421 |
// Favorited topic ID (Stored in usermeta) |
| 422 |
$this->field_map[] = array( |
| 423 |
'from_tablename' => 'favorites_table', |
| 424 |
'from_fieldname' => 'the_favorite_topic_id', |
| 425 |
'to_type' => 'favorites', |
| 426 |
'to_fieldname' => '_bbp_favorites' |
| 427 |
); |
| 428 |
|
| 429 |
// Favorited user ID (Stored in usermeta) |
| 430 |
$this->field_map[] = array( |
| 431 |
'from_tablename' => 'favorites_table', |
| 432 |
'from_fieldname' => 'the_user_id', |
| 433 |
'to_type' => 'favorites', |
| 434 |
'to_fieldname' => 'user_id', |
| 435 |
'callback_method' => 'callback_userid' |
| 436 |
); |
| 437 |
|
| 438 |
/** Reply Section *****************************************************/ |
| 439 |
|
| 440 |
// Setup table joins for the reply section at the base of this section |
| 441 |
|
| 442 |
// Old reply id (Stored in postmeta) |
| 443 |
$this->field_map[] = array( |
| 444 |
'from_tablename' => 'replies_table', |
| 445 |
'from_fieldname' => 'the_reply_id', |
| 446 |
'to_type' => 'reply', |
| 447 |
'to_fieldname' => '_bbp_old_reply_id' |
| 448 |
); |
| 449 |
|
| 450 |
// Reply parent forum id (If no parent, then 0. Stored in postmeta) |
| 451 |
$this->field_map[] = array( |
| 452 |
'from_tablename' => 'replies_table', |
| 453 |
'from_fieldname' => 'the_reply_parent_forum_id', |
| 454 |
'to_type' => 'reply', |
| 455 |
'to_fieldname' => '_bbp_forum_id', |
| 456 |
'callback_method' => 'callback_forumid' |
| 457 |
); |
| 458 |
|
| 459 |
// Reply parent topic id (If no parent, then 0. Stored in postmeta) |
| 460 |
$this->field_map[] = array( |
| 461 |
'from_tablename' => 'replies_table', |
| 462 |
'from_fieldname' => 'the_reply_parent_topic_id', |
| 463 |
'to_type' => 'reply', |
| 464 |
'to_fieldname' => '_bbp_topic_id', |
| 465 |
'callback_method' => 'callback_topicid' |
| 466 |
); |
| 467 |
|
| 468 |
// Reply author ip (Stored in postmeta) |
| 469 |
$this->field_map[] = array( |
| 470 |
'from_tablename' => 'replies_table', |
| 471 |
'from_fieldname' => 'the_reply_author_ip_address', |
| 472 |
'to_type' => 'reply', |
| 473 |
'to_fieldname' => '_bbp_author_ip' |
| 474 |
); |
| 475 |
|
| 476 |
// Reply author. |
| 477 |
$this->field_map[] = array( |
| 478 |
'from_tablename' => 'replies_table', |
| 479 |
'from_fieldname' => 'the_reply_author_id', |
| 480 |
'to_type' => 'reply', |
| 481 |
'to_fieldname' => 'post_author', |
| 482 |
'callback_method' => 'callback_userid' |
| 483 |
); |
| 484 |
|
| 485 |
// Reply title and reply slugs |
| 486 |
// Note: We don't actually want either a reply title or a reply slug as |
| 487 |
// we want single replies to use their ID as the permalink. |
| 488 |
|
| 489 |
// Reply content. |
| 490 |
$this->field_map[] = array( |
| 491 |
'from_tablename' => 'replies_table', |
| 492 |
'from_fieldname' => 'the_reply_content', |
| 493 |
'to_type' => 'reply', |
| 494 |
'to_fieldname' => 'post_content', |
| 495 |
'callback_method' => 'callback_html' |
| 496 |
); |
| 497 |
|
| 498 |
// Reply order. |
| 499 |
$this->field_map[] = array( |
| 500 |
'from_tablename' => 'replies_table', |
| 501 |
'from_fieldname' => 'the_reply_order', |
| 502 |
'to_type' => 'reply', |
| 503 |
'to_fieldname' => 'menu_order' |
| 504 |
); |
| 505 |
|
| 506 |
// Reply parent topic id (If no parent, then 0) |
| 507 |
$this->field_map[] = array( |
| 508 |
'from_tablename' => 'replies_table', |
| 509 |
'from_fieldname' => 'the_reply_parent_topic_id', |
| 510 |
'to_type' => 'reply', |
| 511 |
'to_fieldname' => 'post_parent', |
| 512 |
'callback_method' => 'callback_topicid' |
| 513 |
); |
| 514 |
|
| 515 |
// Reply dates. |
| 516 |
$this->field_map[] = array( |
| 517 |
'from_tablename' => 'replies_table', |
| 518 |
'from_fieldname' => 'the_reply_creation_date', |
| 519 |
'to_type' => 'reply', |
| 520 |
'to_fieldname' => 'post_date', |
| 521 |
'callback_method' => 'callback_datetime' |
| 522 |
); |
| 523 |
$this->field_map[] = array( |
| 524 |
'from_tablename' => 'replies_table', |
| 525 |
'from_fieldname' => 'the_reply_creation_date', |
| 526 |
'to_type' => 'reply', |
| 527 |
'to_fieldname' => 'post_date_gmt', |
| 528 |
'callback_method' => 'callback_datetime' |
| 529 |
); |
| 530 |
$this->field_map[] = array( |
| 531 |
'from_tablename' => 'replies_table', |
| 532 |
'from_fieldname' => 'the_reply_modified_date', |
| 533 |
'to_type' => 'reply', |
| 534 |
'to_fieldname' => 'post_modified', |
| 535 |
'callback_method' => 'callback_datetime' |
| 536 |
); |
| 537 |
$this->field_map[] = array( |
| 538 |
'from_tablename' => 'replies_table', |
| 539 |
'from_fieldname' => 'the_reply_modified_date', |
| 540 |
'to_type' => 'reply', |
| 541 |
'to_fieldname' => 'post_modified_gmt', |
| 542 |
'callback_method' => 'callback_datetime' |
| 543 |
); |
| 544 |
|
| 545 |
// Setup any table joins needed for the reply section |
| 546 |
$this->field_map[] = array( |
| 547 |
'from_tablename' => 'topics_table', |
| 548 |
'from_fieldname' => 'the_topic_id', |
| 549 |
'join_tablename' => 'replies_table', |
| 550 |
'join_type' => 'INNER', |
| 551 |
'join_expression' => 'USING topics_table.the_topic_id = replies_table.the_topic_id', |
| 552 |
'from_expression' => 'WHERE topics_table.first_post != 0', |
| 553 |
'to_type' => 'reply' |
| 554 |
); |
| 555 |
|
| 556 |
/** User Section ******************************************************/ |
| 557 |
|
| 558 |
// Setup table joins for the user section at the base of this section |
| 559 |
|
| 560 |
// Store old user id (Stored in usermeta) |
| 561 |
$this->field_map[] = array( |
| 562 |
'from_tablename' => 'users_table', |
| 563 |
'from_fieldname' => 'the_users_id', |
| 564 |
'to_type' => 'user', |
| 565 |
'to_fieldname' => '_bbp_old_user_id' |
| 566 |
); |
| 567 |
|
| 568 |
// Store old user password (Stored in usermeta serialized with salt) |
| 569 |
$this->field_map[] = array( |
| 570 |
'from_tablename' => 'users_table', |
| 571 |
'from_fieldname' => 'the_users_password', |
| 572 |
'to_type' => 'user', |
| 573 |
'to_fieldname' => '_bbp_password', |
| 574 |
'callback_method' => 'callback_savepass' |
| 575 |
); |
| 576 |
|
| 577 |
// Store old user salt (This is only used for the SELECT row info for the above password save) |
| 578 |
$this->field_map[] = array( |
| 579 |
'from_tablename' => 'users_table', |
| 580 |
'from_fieldname' => 'the_users_password_salt', |
| 581 |
'to_type' => 'user', |
| 582 |
'to_fieldname' => '' |
| 583 |
); |
| 584 |
|
| 585 |
// User password verify class (Stored in usermeta for verifying password) |
| 586 |
$this->field_map[] = array( |
| 587 |
'to_type' => 'user', |
| 588 |
'to_fieldname' => '_bbp_class', |
| 589 |
'default' => 'Example' |
| 590 |
); |
| 591 |
|
| 592 |
// User name. |
| 593 |
$this->field_map[] = array( |
| 594 |
'from_tablename' => 'users_table', |
| 595 |
'from_fieldname' => 'the_users_username', |
| 596 |
'to_type' => 'user', |
| 597 |
'to_fieldname' => 'user_login' |
| 598 |
); |
| 599 |
|
| 600 |
// User nice name. |
| 601 |
$this->field_map[] = array( |
| 602 |
'from_tablename' => 'users_table', |
| 603 |
'from_fieldname' => 'the_users_nicename', |
| 604 |
'to_type' => 'user', |
| 605 |
'to_fieldname' => 'user_nicename' |
| 606 |
); |
| 607 |
|
| 608 |
// User email. |
| 609 |
$this->field_map[] = array( |
| 610 |
'from_tablename' => 'users_table', |
| 611 |
'from_fieldname' => 'the_users_email_address', |
| 612 |
'to_type' => 'user', |
| 613 |
'to_fieldname' => 'user_email' |
| 614 |
); |
| 615 |
|
| 616 |
// User homepage. |
| 617 |
$this->field_map[] = array( |
| 618 |
'from_tablename' => 'users_table', |
| 619 |
'from_fieldname' => 'the_users_homepage_url', |
| 620 |
'to_type' => 'user', |
| 621 |
'to_fieldname' => 'user_url' |
| 622 |
); |
| 623 |
|
| 624 |
// User registered. |
| 625 |
$this->field_map[] = array( |
| 626 |
'from_tablename' => 'users_table', |
| 627 |
'from_fieldname' => 'the_users_registration_date', |
| 628 |
'to_type' => 'user', |
| 629 |
'to_fieldname' => 'user_registered', |
| 630 |
'callback_method' => 'callback_datetime' |
| 631 |
); |
| 632 |
|
| 633 |
// User status. |
| 634 |
$this->field_map[] = array( |
| 635 |
'from_tablename' => 'users_table', |
| 636 |
'from_fieldname' => 'the_users_status', |
| 637 |
'to_type' => 'user', |
| 638 |
'to_fieldname' => 'user_status' |
| 639 |
); |
| 640 |
|
| 641 |
// User display name. |
| 642 |
$this->field_map[] = array( |
| 643 |
'from_tablename' => 'users_table', |
| 644 |
'from_fieldname' => 'the_users_display_name', |
| 645 |
'to_type' => 'user', |
| 646 |
'to_fieldname' => 'display_name' |
| 647 |
); |
| 648 |
|
| 649 |
// User Profile Field 1 (Stored in usermeta) |
| 650 |
$this->field_map[] = array( |
| 651 |
'from_tablename' => 'users_table', |
| 652 |
'from_fieldname' => 'the_users_custom_profile_field_1', |
| 653 |
'to_type' => 'user', |
| 654 |
'to_fieldname' => '_bbp_example_profile_field_1' |
| 655 |
); |
| 656 |
|
| 657 |
// User Profile Field 2 (Stored in usermeta) |
| 658 |
$this->field_map[] = array( |
| 659 |
'from_tablename' => 'users_table', |
| 660 |
'from_fieldname' => 'the_users_custom_profile_field_2', |
| 661 |
'to_type' => 'user', |
| 662 |
'to_fieldname' => '_bbp_example_profile_field_2' |
| 663 |
); |
| 664 |
|
| 665 |
// User Profile Field 3 (Stored in usermeta) |
| 666 |
$this->field_map[] = array( |
| 667 |
'from_tablename' => 'users_table', |
| 668 |
'from_fieldname' => 'the_users_custom_profile_field_3', |
| 669 |
'to_type' => 'user', |
| 670 |
'to_fieldname' => '_bbp_example_profile_field_3' |
| 671 |
); |
| 672 |
|
| 673 |
// Setup any table joins needed for the user section |
| 674 |
$this->field_map[] = array( |
| 675 |
'from_tablename' => 'users_profile_table', |
| 676 |
'from_fieldname' => 'the_users_id', |
| 677 |
'join_tablename' => 'users_table', |
| 678 |
'join_type' => 'INNER', |
| 679 |
'join_expression' => 'USING users_profile_table.the_user_id = users_table.the_user_id', |
| 680 |
'from_expression' => 'WHERE users_table.the_user_id != -1', |
| 681 |
'to_type' => 'user' |
| 682 |
); |
| 683 |
} |
| 684 |
|
| 685 |
/** |
| 686 |
* This method allows us to indicates what is or is not converted for each |
| 687 |
* converter. |
| 688 |
*/ |
| 689 |
public function info() { |
| 690 |
return ''; |
| 691 |
} |
| 692 |
|
| 693 |
/** |
| 694 |
* This method is to save the salt and password together. That |
| 695 |
* way when we authenticate it we can get it out of the database |
| 696 |
* as one value. Array values are auto sanitized by WordPress. |
| 697 |
*/ |
| 698 |
public function callback_savepass( $field, $row ) { |
| 699 |
$pass_array = array( 'hash' => $field, 'salt' => $row['salt'] ); |
| 700 |
return $pass_array; |
| 701 |
} |
| 702 |
|
| 703 |
/** |
| 704 |
* This method is to take the pass out of the database and compare |
| 705 |
* to a pass the user has typed in. |
| 706 |
*/ |
| 707 |
public function authenticate_pass( $password, $serialized_pass ) { |
| 708 |
$pass_array = unserialize( $serialized_pass ); |
| 709 |
return ( $pass_array['hash'] == md5( md5( $password ). $pass_array['salt'] ) ); |
| 710 |
} |
| 711 |
} |
| 712 |
|