| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* bbPress XMB Converter |
| 5 |
* |
| 6 |
* @package bbPress |
| 7 |
* @subpackage Converters |
| 8 |
*/ |
| 9 |
|
| 10 |
/** |
| 11 |
* Implementation of XMB Forum converter. |
| 12 |
* |
| 13 |
* @since 2.5.0 bbPress (r5143) |
| 14 |
* |
| 15 |
* @link Codex Docs https://codex.bbpress.org/import-forums/xmb |
| 16 |
*/ |
| 17 |
class XMB extends BBP_Converter_Base { |
| 18 |
|
| 19 |
/** |
| 20 |
* Sets up the field mappings |
| 21 |
*/ |
| 22 |
public function setup_globals() { |
| 23 |
|
| 24 |
/** Forum Section *****************************************************/ |
| 25 |
|
| 26 |
// Old forum id (Stored in postmeta) |
| 27 |
$this->field_map[] = array( |
| 28 |
'from_tablename' => 'forums', |
| 29 |
'from_fieldname' => 'fid', |
| 30 |
'to_type' => 'forum', |
| 31 |
'to_fieldname' => '_bbp_old_forum_id' |
| 32 |
); |
| 33 |
|
| 34 |
// Forum parent id (If no parent, then 0, Stored in postmeta) |
| 35 |
$this->field_map[] = array( |
| 36 |
'from_tablename' => 'forums', |
| 37 |
'from_fieldname' => 'fup', |
| 38 |
'to_type' => 'forum', |
| 39 |
'to_fieldname' => '_bbp_old_forum_parent_id' |
| 40 |
); |
| 41 |
|
| 42 |
// Forum topic count (Stored in postmeta) |
| 43 |
$this->field_map[] = array( |
| 44 |
'from_tablename' => 'forums', |
| 45 |
'from_fieldname' => 'threads', |
| 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' => 'posts', |
| 54 |
'to_type' => 'forum', |
| 55 |
'to_fieldname' => '_bbp_reply_count' |
| 56 |
); |
| 57 |
|
| 58 |
// Forum total topic count (Includes unpublished topics, Stored in postmeta) |
| 59 |
$this->field_map[] = array( |
| 60 |
'from_tablename' => 'forums', |
| 61 |
'from_fieldname' => 'threads', |
| 62 |
'to_type' => 'forum', |
| 63 |
'to_fieldname' => '_bbp_total_topic_count' |
| 64 |
); |
| 65 |
|
| 66 |
// Forum total reply count (Includes unpublished replies, Stored in postmeta) |
| 67 |
$this->field_map[] = array( |
| 68 |
'from_tablename' => 'forums', |
| 69 |
'from_fieldname' => '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' => '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' => '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' => 'description', |
| 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' => 'displayorder', |
| 104 |
'to_type' => 'forum', |
| 105 |
'to_fieldname' => 'menu_order' |
| 106 |
); |
| 107 |
|
| 108 |
// Forum type (Category = 'group', Forum = 'forum' or 'sub', Stored in postmeta) |
| 109 |
$this->field_map[] = array( |
| 110 |
'from_tablename' => 'forums', |
| 111 |
'from_fieldname' => 'type', |
| 112 |
'to_type' => 'forum', |
| 113 |
'to_fieldname' => '_bbp_forum_type', |
| 114 |
'callback_method' => 'callback_forum_type' |
| 115 |
); |
| 116 |
|
| 117 |
// Forum status (Set a default value 'open', Stored in postmeta) |
| 118 |
$this->field_map[] = array( |
| 119 |
'to_type' => 'forum', |
| 120 |
'to_fieldname' => '_bbp_status', |
| 121 |
'default' => 'open' |
| 122 |
); |
| 123 |
|
| 124 |
// Forum dates. |
| 125 |
$this->field_map[] = array( |
| 126 |
'to_type' => 'forum', |
| 127 |
'to_fieldname' => 'post_date', |
| 128 |
'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore |
| 129 |
); |
| 130 |
$this->field_map[] = array( |
| 131 |
'to_type' => 'forum', |
| 132 |
'to_fieldname' => 'post_date_gmt', |
| 133 |
'default' => gmdate( 'Y-m-d H:i:s' ) |
| 134 |
); |
| 135 |
$this->field_map[] = array( |
| 136 |
'to_type' => 'forum', |
| 137 |
'to_fieldname' => 'post_modified', |
| 138 |
'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore |
| 139 |
); |
| 140 |
$this->field_map[] = array( |
| 141 |
'to_type' => 'forum', |
| 142 |
'to_fieldname' => 'post_modified_gmt', |
| 143 |
'default' => gmdate( 'Y-m-d H:i:s' ) |
| 144 |
); |
| 145 |
|
| 146 |
/** Topic Section *****************************************************/ |
| 147 |
|
| 148 |
// Old topic id (Stored in postmeta) |
| 149 |
$this->field_map[] = array( |
| 150 |
'from_tablename' => 'threads', |
| 151 |
'from_fieldname' => 'tid', |
| 152 |
'to_type' => 'topic', |
| 153 |
'to_fieldname' => '_bbp_old_topic_id' |
| 154 |
); |
| 155 |
|
| 156 |
// Topic reply count (Stored in postmeta) |
| 157 |
$this->field_map[] = array( |
| 158 |
'from_tablename' => 'threads', |
| 159 |
'from_fieldname' => 'replies', |
| 160 |
'to_type' => 'topic', |
| 161 |
'to_fieldname' => '_bbp_reply_count', |
| 162 |
'callback_method' => 'callback_topic_reply_count' |
| 163 |
); |
| 164 |
|
| 165 |
// Topic total reply count (Includes unpublished replies, Stored in postmeta) |
| 166 |
$this->field_map[] = array( |
| 167 |
'from_tablename' => 'threads', |
| 168 |
'from_fieldname' => 'replies', |
| 169 |
'to_type' => 'topic', |
| 170 |
'to_fieldname' => '_bbp_total_reply_count', |
| 171 |
'callback_method' => 'callback_topic_reply_count' |
| 172 |
); |
| 173 |
|
| 174 |
// Topic parent forum id (If no parent, then 0. Stored in postmeta) |
| 175 |
$this->field_map[] = array( |
| 176 |
'from_tablename' => 'threads', |
| 177 |
'from_fieldname' => 'fid', |
| 178 |
'to_type' => 'topic', |
| 179 |
'to_fieldname' => '_bbp_forum_id', |
| 180 |
'callback_method' => 'callback_forumid' |
| 181 |
); |
| 182 |
|
| 183 |
// Topic author. |
| 184 |
// Note: We join the 'members' table because 'threads' table does not have numerical author id. |
| 185 |
$this->field_map[] = array( |
| 186 |
'from_tablename' => 'members', |
| 187 |
'from_fieldname' => 'uid', |
| 188 |
'join_tablename' => 'threads', |
| 189 |
'join_type' => 'LEFT', |
| 190 |
'join_expression' => 'ON threads.author = members.username', |
| 191 |
'to_type' => 'topic', |
| 192 |
'to_fieldname' => 'post_author', |
| 193 |
'callback_method' => 'callback_userid' |
| 194 |
); |
| 195 |
|
| 196 |
// Topic author name (Stored in postmeta as _bbp_anonymous_name) |
| 197 |
$this->field_map[] = array( |
| 198 |
'from_tablename' => 'threads', |
| 199 |
'from_fieldname' => 'author', |
| 200 |
'to_type' => 'topic', |
| 201 |
'to_fieldname' => '_bbp_old_topic_author_name_id' |
| 202 |
); |
| 203 |
|
| 204 |
// Is the topic anonymous (Stored in postmeta) |
| 205 |
$this->field_map[] = array( |
| 206 |
'from_tablename' => 'members', |
| 207 |
'from_fieldname' => 'uid', |
| 208 |
'join_tablename' => 'threads', |
| 209 |
'join_type' => 'LEFT', |
| 210 |
'join_expression' => 'ON threads.author = members.username WHERE posts.subject = ""', |
| 211 |
'to_type' => 'topic', |
| 212 |
'to_fieldname' => '_bbp_old_is_topic_anonymous_id', |
| 213 |
'callback_method' => 'callback_check_anonymous' |
| 214 |
); |
| 215 |
|
| 216 |
// Topic Author ip (Stored in postmeta) |
| 217 |
// Note: We join the 'posts' table because 'threads' table does not have author ip. |
| 218 |
$this->field_map[] = array( |
| 219 |
'from_tablename' => 'posts', |
| 220 |
'from_fieldname' => 'useip', |
| 221 |
'join_tablename' => 'threads', |
| 222 |
'join_type' => 'INNER', |
| 223 |
'join_expression' => 'USING (tid) WHERE posts.subject != ""', |
| 224 |
'to_type' => 'topic', |
| 225 |
'to_fieldname' => '_bbp_author_ip' |
| 226 |
); |
| 227 |
|
| 228 |
// Topic content. |
| 229 |
// Note: We join the 'posts' table because 'threads' table does not have content. |
| 230 |
$this->field_map[] = array( |
| 231 |
'from_tablename' => 'posts', |
| 232 |
'from_fieldname' => 'message', |
| 233 |
'join_tablename' => 'threads', |
| 234 |
'join_type' => 'INNER', |
| 235 |
'join_expression' => 'USING (tid) WHERE posts.subject != ""', |
| 236 |
'to_type' => 'topic', |
| 237 |
'to_fieldname' => 'post_content', |
| 238 |
'callback_method' => 'callback_html' |
| 239 |
); |
| 240 |
|
| 241 |
// Topic title. |
| 242 |
$this->field_map[] = array( |
| 243 |
'from_tablename' => 'threads', |
| 244 |
'from_fieldname' => 'subject', |
| 245 |
'to_type' => 'topic', |
| 246 |
'to_fieldname' => 'post_title' |
| 247 |
); |
| 248 |
|
| 249 |
// Topic slug (Clean name to avoid conflicts) |
| 250 |
$this->field_map[] = array( |
| 251 |
'from_tablename' => 'threads', |
| 252 |
'from_fieldname' => 'subject', |
| 253 |
'to_type' => 'topic', |
| 254 |
'to_fieldname' => 'post_name', |
| 255 |
'callback_method' => 'callback_slug' |
| 256 |
); |
| 257 |
|
| 258 |
// Topic parent forum id (If no parent, then 0) |
| 259 |
$this->field_map[] = array( |
| 260 |
'from_tablename' => 'threads', |
| 261 |
'from_fieldname' => 'fid', |
| 262 |
'to_type' => 'topic', |
| 263 |
'to_fieldname' => 'post_parent', |
| 264 |
'callback_method' => 'callback_forumid' |
| 265 |
); |
| 266 |
|
| 267 |
// Topic status (Open or Closed, XMB v1.9.11.13 ''=open & 'yes'=closed) |
| 268 |
$this->field_map[] = array( |
| 269 |
'from_tablename' => 'threads', |
| 270 |
'from_fieldname' => 'closed', |
| 271 |
'to_type' => 'topic', |
| 272 |
'to_fieldname' => '_bbp_old_closed_status_id', |
| 273 |
'callback_method' => 'callback_topic_status' |
| 274 |
); |
| 275 |
|
| 276 |
// Sticky status (Stored in postmeta) |
| 277 |
$this->field_map[] = array( |
| 278 |
'from_tablename' => 'threads', |
| 279 |
'from_fieldname' => 'topped', |
| 280 |
'to_type' => 'topic', |
| 281 |
'to_fieldname' => '_bbp_old_sticky_status_id', |
| 282 |
'callback_method' => 'callback_sticky_status' |
| 283 |
); |
| 284 |
|
| 285 |
// Topic dates. |
| 286 |
// Note: We join the 'posts' table because 'threads' table does not include dates. |
| 287 |
$this->field_map[] = array( |
| 288 |
'from_tablename' => 'posts', |
| 289 |
'from_fieldname' => 'dateline', |
| 290 |
'join_tablename' => 'threads', |
| 291 |
'join_type' => 'INNER', |
| 292 |
'join_expression' => 'USING (tid) WHERE posts.subject != ""', |
| 293 |
'to_type' => 'topic', |
| 294 |
'to_fieldname' => 'post_date', |
| 295 |
'callback_method' => 'callback_datetime' |
| 296 |
); |
| 297 |
$this->field_map[] = array( |
| 298 |
'from_tablename' => 'posts', |
| 299 |
'from_fieldname' => 'dateline', |
| 300 |
'join_tablename' => 'threads', |
| 301 |
'join_type' => 'INNER', |
| 302 |
'join_expression' => 'USING (tid) WHERE posts.subject != ""', |
| 303 |
'to_type' => 'topic', |
| 304 |
'to_fieldname' => 'post_date_gmt', |
| 305 |
'callback_method' => 'callback_datetime' |
| 306 |
); |
| 307 |
$this->field_map[] = array( |
| 308 |
'from_tablename' => 'posts', |
| 309 |
'from_fieldname' => 'dateline', |
| 310 |
'join_tablename' => 'threads', |
| 311 |
'join_type' => 'INNER', |
| 312 |
'join_expression' => 'USING (tid) WHERE posts.subject != ""', |
| 313 |
'to_type' => 'topic', |
| 314 |
'to_fieldname' => 'post_modified', |
| 315 |
'callback_method' => 'callback_datetime' |
| 316 |
); |
| 317 |
$this->field_map[] = array( |
| 318 |
'from_tablename' => 'posts', |
| 319 |
'from_fieldname' => 'dateline', |
| 320 |
'join_tablename' => 'threads', |
| 321 |
'join_type' => 'INNER', |
| 322 |
'join_expression' => 'USING (tid) WHERE posts.subject != ""', |
| 323 |
'to_type' => 'topic', |
| 324 |
'to_fieldname' => 'post_modified_gmt', |
| 325 |
'callback_method' => 'callback_datetime' |
| 326 |
); |
| 327 |
$this->field_map[] = array( |
| 328 |
'from_tablename' => 'posts', |
| 329 |
'from_fieldname' => 'dateline', |
| 330 |
'join_tablename' => 'threads', |
| 331 |
'join_type' => 'INNER', |
| 332 |
'join_expression' => 'USING (tid) WHERE posts.subject != ""', |
| 333 |
'to_type' => 'topic', |
| 334 |
'to_fieldname' => '_bbp_last_active_time', |
| 335 |
'callback_method' => 'callback_datetime' |
| 336 |
); |
| 337 |
|
| 338 |
/** Tags Section ******************************************************/ |
| 339 |
|
| 340 |
/** |
| 341 |
* XMB v1.9.11.13 Forums do not support topic tags out of the box |
| 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' => 'pid', |
| 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' => 'fid', |
| 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' => 'tid', |
| 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' => 'useip', |
| 376 |
'to_type' => 'reply', |
| 377 |
'to_fieldname' => '_bbp_author_ip' |
| 378 |
); |
| 379 |
|
| 380 |
// Reply author. |
| 381 |
// Note: We join the 'members' table because 'posts' table does not have numerical author id. |
| 382 |
$this->field_map[] = array( |
| 383 |
'from_tablename' => 'members', |
| 384 |
'from_fieldname' => 'uid', |
| 385 |
'join_tablename' => 'posts', |
| 386 |
'join_type' => 'LEFT', |
| 387 |
'join_expression' => 'ON posts.author = members.username WHERE posts.subject = ""', |
| 388 |
'to_type' => 'reply', |
| 389 |
'to_fieldname' => 'post_author', |
| 390 |
'callback_method' => 'callback_userid' |
| 391 |
); |
| 392 |
|
| 393 |
// Reply author name (Stored in postmeta as _bbp_anonymous_name) |
| 394 |
$this->field_map[] = array( |
| 395 |
'from_tablename' => 'posts', |
| 396 |
'from_fieldname' => 'author', |
| 397 |
'to_type' => 'reply', |
| 398 |
'to_fieldname' => '_bbp_old_reply_author_name_id' |
| 399 |
); |
| 400 |
|
| 401 |
// Is the reply anonymous (Stored in postmeta) |
| 402 |
$this->field_map[] = array( |
| 403 |
'from_tablename' => 'members', |
| 404 |
'from_fieldname' => 'uid', |
| 405 |
'join_tablename' => 'posts', |
| 406 |
'join_type' => 'LEFT', |
| 407 |
'join_expression' => 'ON posts.author = members.username WHERE posts.subject = ""', |
| 408 |
'to_type' => 'reply', |
| 409 |
'to_fieldname' => '_bbp_old_is_reply_anonymous_id', |
| 410 |
'callback_method' => 'callback_check_anonymous' |
| 411 |
); |
| 412 |
|
| 413 |
// Reply content. |
| 414 |
$this->field_map[] = array( |
| 415 |
'from_tablename' => 'posts', |
| 416 |
'from_fieldname' => 'message', |
| 417 |
'to_type' => 'reply', |
| 418 |
'to_fieldname' => 'post_content', |
| 419 |
'callback_method' => 'callback_html' |
| 420 |
); |
| 421 |
|
| 422 |
// Reply parent topic id (If no parent, then 0) |
| 423 |
$this->field_map[] = array( |
| 424 |
'from_tablename' => 'posts', |
| 425 |
'from_fieldname' => 'tid', |
| 426 |
'to_type' => 'reply', |
| 427 |
'to_fieldname' => 'post_parent', |
| 428 |
'callback_method' => 'callback_topicid' |
| 429 |
); |
| 430 |
|
| 431 |
// Reply dates. |
| 432 |
$this->field_map[] = array( |
| 433 |
'from_tablename' => 'posts', |
| 434 |
'from_fieldname' => 'dateline', |
| 435 |
'to_type' => 'reply', |
| 436 |
'to_fieldname' => 'post_date', |
| 437 |
'callback_method' => 'callback_datetime' |
| 438 |
); |
| 439 |
$this->field_map[] = array( |
| 440 |
'from_tablename' => 'posts', |
| 441 |
'from_fieldname' => 'dateline', |
| 442 |
'to_type' => 'reply', |
| 443 |
'to_fieldname' => 'post_date_gmt', |
| 444 |
'callback_method' => 'callback_datetime' |
| 445 |
); |
| 446 |
$this->field_map[] = array( |
| 447 |
'from_tablename' => 'posts', |
| 448 |
'from_fieldname' => 'dateline', |
| 449 |
'to_type' => 'reply', |
| 450 |
'to_fieldname' => 'post_modified', |
| 451 |
'callback_method' => 'callback_datetime' |
| 452 |
); |
| 453 |
$this->field_map[] = array( |
| 454 |
'from_tablename' => 'posts', |
| 455 |
'from_fieldname' => 'dateline', |
| 456 |
'to_type' => 'reply', |
| 457 |
'to_fieldname' => 'post_modified_gmt', |
| 458 |
'callback_method' => 'callback_datetime' |
| 459 |
); |
| 460 |
|
| 461 |
/** User Section ******************************************************/ |
| 462 |
|
| 463 |
// Store old user id (Stored in usermeta) |
| 464 |
$this->field_map[] = array( |
| 465 |
'from_tablename' => 'members', |
| 466 |
'from_fieldname' => 'uid', |
| 467 |
'to_type' => 'user', |
| 468 |
'to_fieldname' => '_bbp_old_user_id' |
| 469 |
); |
| 470 |
|
| 471 |
// Store old User password (Stored in usermeta serialized with salt) |
| 472 |
$this->field_map[] = array( |
| 473 |
'from_tablename' => 'members', |
| 474 |
'from_fieldname' => 'password', |
| 475 |
'to_type' => 'user', |
| 476 |
'to_fieldname' => '_bbp_password', |
| 477 |
'callback_method' => 'callback_savepass' |
| 478 |
); |
| 479 |
|
| 480 |
// Store old User Salt (This is only used for the SELECT row info for the above password save) |
| 481 |
/* |
| 482 |
$this->field_map[] = array( |
| 483 |
'from_tablename' => 'members', |
| 484 |
'from_fieldname' => 'salt', |
| 485 |
'to_type' => 'user', |
| 486 |
'to_fieldname' => '' |
| 487 |
); |
| 488 |
*/ |
| 489 |
|
| 490 |
// User password verify class (Stored in usermeta for verifying password) |
| 491 |
$this->field_map[] = array( |
| 492 |
'to_type' => 'members', |
| 493 |
'to_fieldname' => '_bbp_class', |
| 494 |
'default' => 'XMB' |
| 495 |
); |
| 496 |
|
| 497 |
// User name. |
| 498 |
$this->field_map[] = array( |
| 499 |
'from_tablename' => 'members', |
| 500 |
'from_fieldname' => 'username', |
| 501 |
'to_type' => 'user', |
| 502 |
'to_fieldname' => 'user_login' |
| 503 |
); |
| 504 |
|
| 505 |
// User nice name. |
| 506 |
$this->field_map[] = array( |
| 507 |
'from_tablename' => 'members', |
| 508 |
'from_fieldname' => 'username', |
| 509 |
'to_type' => 'user', |
| 510 |
'to_fieldname' => 'user_nicename' |
| 511 |
); |
| 512 |
|
| 513 |
// User email. |
| 514 |
$this->field_map[] = array( |
| 515 |
'from_tablename' => 'members', |
| 516 |
'from_fieldname' => 'email', |
| 517 |
'to_type' => 'user', |
| 518 |
'to_fieldname' => 'user_email' |
| 519 |
); |
| 520 |
|
| 521 |
// User homepage. |
| 522 |
$this->field_map[] = array( |
| 523 |
'from_tablename' => 'members', |
| 524 |
'from_fieldname' => 'site', |
| 525 |
'to_type' => 'user', |
| 526 |
'to_fieldname' => 'user_url' |
| 527 |
); |
| 528 |
|
| 529 |
// User registered. |
| 530 |
$this->field_map[] = array( |
| 531 |
'from_tablename' => 'members', |
| 532 |
'from_fieldname' => 'regdate', |
| 533 |
'to_type' => 'user', |
| 534 |
'to_fieldname' => 'user_registered', |
| 535 |
'callback_method' => 'callback_datetime' |
| 536 |
); |
| 537 |
|
| 538 |
// User AIM (Stored in usermeta) |
| 539 |
$this->field_map[] = array( |
| 540 |
'from_tablename' => 'members', |
| 541 |
'from_fieldname' => 'aim', |
| 542 |
'to_type' => 'user', |
| 543 |
'to_fieldname' => '_bbp_xmb_user_aim' |
| 544 |
); |
| 545 |
|
| 546 |
// User Yahoo (Stored in usermeta) |
| 547 |
$this->field_map[] = array( |
| 548 |
'from_tablename' => 'members', |
| 549 |
'from_fieldname' => 'yahoo', |
| 550 |
'to_type' => 'user', |
| 551 |
'to_fieldname' => '_bbp_xmb_user_yim' |
| 552 |
); |
| 553 |
|
| 554 |
// Store ICQ (Stored in usermeta) |
| 555 |
$this->field_map[] = array( |
| 556 |
'from_tablename' => 'members', |
| 557 |
'from_fieldname' => 'icq', |
| 558 |
'to_type' => 'user', |
| 559 |
'to_fieldname' => '_bbp_xmb_user_icq' |
| 560 |
); |
| 561 |
|
| 562 |
// Store MSN (Stored in usermeta) |
| 563 |
$this->field_map[] = array( |
| 564 |
'from_tablename' => 'members', |
| 565 |
'from_fieldname' => 'msn', |
| 566 |
'to_type' => 'user', |
| 567 |
'to_fieldname' => '_bbp_xmb_user_msn' |
| 568 |
); |
| 569 |
|
| 570 |
// Store Signature (Stored in usermeta) |
| 571 |
$this->field_map[] = array( |
| 572 |
'from_tablename' => 'members', |
| 573 |
'from_fieldname' => 'sig', |
| 574 |
'to_type' => 'user', |
| 575 |
'to_fieldname' => '_bbp_xmb_user_sig', |
| 576 |
'callback_method' => 'callback_html' |
| 577 |
); |
| 578 |
|
| 579 |
// Store Bio (Stored in usermeta) |
| 580 |
$this->field_map[] = array( |
| 581 |
'from_tablename' => 'members', |
| 582 |
'from_fieldname' => 'bio', |
| 583 |
'to_type' => 'user', |
| 584 |
'to_fieldname' => '_bbp_xmb_user_bio', |
| 585 |
'callback_method' => 'callback_html' |
| 586 |
); |
| 587 |
|
| 588 |
// Store Location (Stored in usermeta) |
| 589 |
$this->field_map[] = array( |
| 590 |
'from_tablename' => 'members', |
| 591 |
'from_fieldname' => 'location', |
| 592 |
'to_type' => 'user', |
| 593 |
'to_fieldname' => '_bbp_xmb_user_location' |
| 594 |
); |
| 595 |
|
| 596 |
// Store Avatar (Stored in usermeta) |
| 597 |
$this->field_map[] = array( |
| 598 |
'from_tablename' => 'members', |
| 599 |
'from_fieldname' => 'avatar', |
| 600 |
'to_type' => 'user', |
| 601 |
'to_fieldname' => '_bbp_xmb_user_avatar' |
| 602 |
); |
| 603 |
|
| 604 |
// Store Mood (Stored in usermeta) |
| 605 |
$this->field_map[] = array( |
| 606 |
'from_tablename' => 'members', |
| 607 |
'from_fieldname' => 'mood', |
| 608 |
'to_type' => 'user', |
| 609 |
'to_fieldname' => '_bbp_xmb_user_mood' |
| 610 |
); |
| 611 |
} |
| 612 |
|
| 613 |
/** |
| 614 |
* This method allows us to indicates what is or is not converted for each |
| 615 |
* converter. |
| 616 |
*/ |
| 617 |
public function info() { |
| 618 |
return ''; |
| 619 |
} |
| 620 |
|
| 621 |
/** |
| 622 |
* This method is to save the salt and password together. That |
| 623 |
* way when we authenticate it we can get it out of the database |
| 624 |
* as one value. Array values are auto sanitized by WordPress. |
| 625 |
*/ |
| 626 |
public function callback_savepass( $field, $row ) { |
| 627 |
$pass_array = array( |
| 628 |
'hash' => $field, |
| 629 |
'salt' => $row['salt'] |
| 630 |
); |
| 631 |
|
| 632 |
return $pass_array; |
| 633 |
} |
| 634 |
|
| 635 |
/** |
| 636 |
* This method is to take the pass out of the database and compare |
| 637 |
* to a pass the user has typed in. |
| 638 |
*/ |
| 639 |
public function authenticate_pass( $password, $serialized_pass ) { |
| 640 |
|
| 641 |
// Unserialize the password, with safeguards |
| 642 |
$pass_array = unserialize( |
| 643 |
$serialized_pass, |
| 644 |
array( |
| 645 |
'allowed_classes' => false, |
| 646 |
'max_depth' => 1, |
| 647 |
) |
| 648 |
); |
| 649 |
|
| 650 |
// Bail if missing values |
| 651 |
if ( ! is_array( $pass_array ) || ! isset( $pass_array['hash'], $pass_array['salt'] ) ) { |
| 652 |
return false; |
| 653 |
} |
| 654 |
|
| 655 |
// Return comparison |
| 656 |
return hash_equals( |
| 657 |
$pass_array['hash'], |
| 658 |
md5( md5( $password ) . $pass_array['salt'] ) |
| 659 |
); |
| 660 |
} |
| 661 |
|
| 662 |
/** |
| 663 |
* Translate the forum type from XMB v1.9.11.13 Capitalised case to WordPress's non-capatilise case strings. |
| 664 |
* |
| 665 |
* @param int $status XMB v1.9.11.13 numeric forum type |
| 666 |
* @return string WordPress safe |
| 667 |
*/ |
| 668 |
public function callback_forum_type( $status = 1 ) { |
| 669 |
switch ( $status ) { |
| 670 |
case 'group' : |
| 671 |
$status = 'category'; |
| 672 |
break; |
| 673 |
|
| 674 |
case 'sub' : |
| 675 |
$status = 'forum'; |
| 676 |
break; |
| 677 |
|
| 678 |
case 'forum' : |
| 679 |
default : |
| 680 |
$status = 'forum'; |
| 681 |
break; |
| 682 |
} |
| 683 |
return $status; |
| 684 |
} |
| 685 |
|
| 686 |
/** |
| 687 |
* Translate the post status from XMB v1.9.11.13 numerics to WordPress's strings. |
| 688 |
* |
| 689 |
* @param int $status XMB v1.9.11.13 numeric topic status |
| 690 |
* @return string WordPress safe |
| 691 |
*/ |
| 692 |
public function callback_topic_status( $status = '' ) { |
| 693 |
switch ( $status ) { |
| 694 |
case 'yes' : |
| 695 |
$status = 'closed'; |
| 696 |
break; |
| 697 |
|
| 698 |
case '' : |
| 699 |
default : |
| 700 |
$status = 'publish'; |
| 701 |
break; |
| 702 |
} |
| 703 |
return $status; |
| 704 |
} |
| 705 |
|
| 706 |
/** |
| 707 |
* Translate the topic sticky status type from XMB v1.9.11.13 numerics to WordPress's strings. |
| 708 |
* |
| 709 |
* @param int $status XMB v1.9.11.13 numeric forum type |
| 710 |
* @return string WordPress safe |
| 711 |
*/ |
| 712 |
public function callback_sticky_status( $status = 0 ) { |
| 713 |
switch ( $status ) { |
| 714 |
case 1 : |
| 715 |
$status = 'sticky'; // XMB Sticky 'topped = 1' |
| 716 |
break; |
| 717 |
|
| 718 |
case 0 : |
| 719 |
default : |
| 720 |
$status = 'normal'; // XMB Normal Topic 'topped = 0' |
| 721 |
break; |
| 722 |
} |
| 723 |
return $status; |
| 724 |
} |
| 725 |
|
| 726 |
/** |
| 727 |
* Verify the topic/reply count. |
| 728 |
* |
| 729 |
* @param int $count XMB v1.9.11.13 topic/reply counts |
| 730 |
* @return string WordPress safe |
| 731 |
*/ |
| 732 |
public function callback_topic_reply_count( $count = 1 ) { |
| 733 |
$count = absint( (int) $count - 1 ); |
| 734 |
return $count; |
| 735 |
} |
| 736 |
} |
| 737 |
|