PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.4.2
Forumax – AI Powered Advanced Community Forum Plugin v2.4.2
2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 2.0.0 2.1.0 All 29 releases
bbp-core / lib / bbpress / includes / admin / converters / XMB.php

XMB.php in Forumax – AI Powered Advanced Community Forum Plugin 2.4.2, at lib/bbpress/includes/admin/converters/XMB.php

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