PluginProbe
bbPress / 2.6.19
bbPress v2.6.19
2.6.19 2.6.18 2.6.17 trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 All 74 releases
bbpress / includes / admin / converters / Kunena3.php

Kunena3.php in bbPress 2.6.19, at includes/admin/converters/Kunena3.php

815 lines 24.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * bbPress Kunena 3.x Converter
5 *
6 * @package bbPress
7 * @subpackage Converters
8 */
9
10 /**
11 * Implementation of Kunena v3.x Forums for Joomla Forum converter.
12 *
13 * @since 2.5.0 bbPress (r5145)
14 *
15 * @link Codex Docs https://codex.bbpress.org/import-forums/kunena/
16 */
17 class Kunena3 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_id',
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' => 'alias',
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_id',
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' ) // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
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' ) // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
144 );
145 $this->field_map[] = array(
146 'to_type' => 'forum',
147 'to_fieldname' => 'post_modified',
148 'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
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' ) // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
154 );
155
156 /** Topic Section *****************************************************/
157
158 // Old topic id (Stored in postmeta)
159 $this->field_map[] = array(
160 'from_tablename' => 'kunena_topics',
161 'from_fieldname' => 'id',
162 'to_type' => 'topic',
163 'to_fieldname' => '_bbp_old_topic_id'
164 );
165
166 // Topic reply count (Stored in postmeta)
167 $this->field_map[] = array(
168 'from_tablename' => 'kunena_topics',
169 'from_fieldname' => 'posts',
170 'to_type' => 'topic',
171 'to_fieldname' => '_bbp_reply_count',
172 'callback_method' => 'callback_topic_reply_count'
173 );
174
175 // Topic total reply count (Includes unpublished replies, Stored in postmeta)
176 $this->field_map[] = array(
177 'from_tablename' => 'kunena_topics',
178 'from_fieldname' => 'posts',
179 'to_type' => 'topic',
180 'to_fieldname' => '_bbp_total_reply_count',
181 'callback_method' => 'callback_topic_reply_count'
182 );
183
184 // Topic parent forum id (If no parent, then 0. Stored in postmeta)
185 $this->field_map[] = array(
186 'from_tablename' => 'kunena_topics',
187 'from_fieldname' => 'category_id',
188 'to_type' => 'topic',
189 'to_fieldname' => '_bbp_forum_id',
190 'callback_method' => 'callback_forumid'
191 );
192
193 // Topic author.
194 $this->field_map[] = array(
195 'from_tablename' => 'kunena_topics',
196 'from_fieldname' => 'first_post_userid',
197 'to_type' => 'topic',
198 'to_fieldname' => 'post_author',
199 'callback_method' => 'callback_userid'
200 );
201
202 // Topic Author ip (Stored in postmeta)
203 // Note: We join the 'kunena_messages' table because 'kunena_topics' table does not include author ip.
204 $this->field_map[] = array(
205 'from_tablename' => 'kunena_messages',
206 'from_fieldname' => 'ip',
207 'join_tablename' => 'kunena_topics',
208 'join_type' => 'LEFT',
209 'join_expression' => 'USING (id)',
210 'to_type' => 'topic',
211 'to_fieldname' => '_bbp_author_ip'
212 );
213
214 // Topic content.
215 $this->field_map[] = array(
216 'from_tablename' => 'kunena_topics',
217 'from_fieldname' => 'first_post_message',
218 'to_type' => 'topic',
219 'to_fieldname' => 'post_content',
220 'callback_method' => 'callback_html'
221 );
222
223 // Topic title.
224 $this->field_map[] = array(
225 'from_tablename' => 'kunena_topics',
226 'from_fieldname' => 'subject',
227 'to_type' => 'topic',
228 'to_fieldname' => 'post_title'
229 );
230
231 // Topic slug (Clean name to avoid conflicts)
232 $this->field_map[] = array(
233 'from_tablename' => 'kunena_topics',
234 'from_fieldname' => 'subject',
235 'to_type' => 'topic',
236 'to_fieldname' => 'post_name',
237 'callback_method' => 'callback_slug'
238 );
239
240 // Topic parent forum id (If no parent, then 0)
241 $this->field_map[] = array(
242 'from_tablename' => 'kunena_topics',
243 'from_fieldname' => 'category_id',
244 'to_type' => 'topic',
245 'to_fieldname' => 'post_parent',
246 'callback_method' => 'callback_forumid'
247 );
248
249 // Topic dates.
250 $this->field_map[] = array(
251 'from_tablename' => 'kunena_topics',
252 'from_fieldname' => 'first_post_time',
253 'to_type' => 'topic',
254 'to_fieldname' => 'post_date',
255 'callback_method' => 'callback_datetime'
256 );
257 $this->field_map[] = array(
258 'from_tablename' => 'kunena_topics',
259 'from_fieldname' => 'first_post_time',
260 'to_type' => 'topic',
261 'to_fieldname' => 'post_date_gmt',
262 'callback_method' => 'callback_datetime'
263 );
264 $this->field_map[] = array(
265 'from_tablename' => 'kunena_topics',
266 'from_fieldname' => 'last_post_time',
267 'to_type' => 'topic',
268 'to_fieldname' => 'post_modified',
269 'callback_method' => 'callback_datetime'
270 );
271 $this->field_map[] = array(
272 'from_tablename' => 'kunena_topics',
273 'from_fieldname' => 'last_post_time',
274 'to_type' => 'topic',
275 'to_fieldname' => 'post_modified_gmt',
276 'callback_method' => 'callback_datetime'
277 );
278 $this->field_map[] = array(
279 'from_tablename' => 'kunena_topics',
280 'from_fieldname' => 'last_post_time',
281 'to_type' => 'topic',
282 'to_fieldname' => '_bbp_last_active_time',
283 'callback_method' => 'callback_datetime'
284 );
285
286 // Topic status (Open or Closed, Kunena v3.x 0=open & 1=closed)
287 $this->field_map[] = array(
288 'from_tablename' => 'kunena_topics',
289 'from_fieldname' => 'locked',
290 'to_type' => 'topic',
291 'to_fieldname' => '_bbp_old_closed_status_id',
292 'callback_method' => 'callback_topic_status'
293 );
294
295 /** Tags Section ******************************************************/
296
297 /**
298 * Kunena v3.x Forums do not support topic tags out of the box
299 */
300
301 /** Reply Section ******************************************************/
302
303 // Old reply id (Stored in postmeta)
304 $this->field_map[] = array(
305 'from_tablename' => 'kunena_messages',
306 'from_fieldname' => 'id',
307 'to_type' => 'reply',
308 'to_fieldname' => '_bbp_old_reply_id'
309 );
310
311 // Reply parent forum id (If no parent, then 0. Stored in postmeta)
312 $this->field_map[] = array(
313 'from_tablename' => 'kunena_messages',
314 'from_fieldname' => 'catid',
315 'to_type' => 'reply',
316 'to_fieldname' => '_bbp_forum_id',
317 'callback_method' => 'callback_topicid_to_forumid'
318 );
319
320 // Reply parent topic id (If no parent, then 0. Stored in postmeta)
321 $this->field_map[] = array(
322 'from_tablename' => 'kunena_messages',
323 'from_fieldname' => 'thread',
324 'to_type' => 'reply',
325 'to_fieldname' => '_bbp_topic_id',
326 'callback_method' => 'callback_topicid'
327 );
328
329 // Reply author ip (Stored in postmeta)
330 $this->field_map[] = array(
331 'from_tablename' => 'kunena_messages',
332 'from_fieldname' => 'ip',
333 'to_type' => 'reply',
334 'to_fieldname' => '_bbp_author_ip'
335 );
336
337 // Reply author.
338 $this->field_map[] = array(
339 'from_tablename' => 'kunena_messages',
340 'from_fieldname' => 'userid',
341 'to_type' => 'reply',
342 'to_fieldname' => 'post_author',
343 'callback_method' => 'callback_userid'
344 );
345
346 // Reply content.
347 // Note: We join the 'kunena_messages_text' table because 'kunena_messages' table does not include reply content.
348 $this->field_map[] = array(
349 'from_tablename' => 'kunena_messages_text',
350 'from_fieldname' => 'message',
351 'join_tablename' => 'kunena_messages',
352 'join_type' => 'LEFT',
353 'join_expression' => 'ON kunena_messages_text.mesid = kunena_messages.id LEFT JOIN jos_kunena_topics AS kunena_topics ON kunena_messages.thread = kunena_topics.id WHERE kunena_messages.parent != 0',
354 'to_type' => 'reply',
355 'to_fieldname' => 'post_content',
356 'callback_method' => 'callback_html'
357 );
358
359 // Reply parent topic id (If no parent, then 0)
360 $this->field_map[] = array(
361 'from_tablename' => 'kunena_messages',
362 'from_fieldname' => 'thread',
363 'to_type' => 'reply',
364 'to_fieldname' => 'post_parent',
365 'callback_method' => 'callback_topicid'
366 );
367
368 // Reply dates.
369 $this->field_map[] = array(
370 'from_tablename' => 'kunena_messages',
371 'from_fieldname' => 'time',
372 'to_type' => 'reply',
373 'to_fieldname' => 'post_date',
374 'callback_method' => 'callback_datetime'
375 );
376 $this->field_map[] = array(
377 'from_tablename' => 'kunena_messages',
378 'from_fieldname' => 'time',
379 'to_type' => 'reply',
380 'to_fieldname' => 'post_date_gmt',
381 'callback_method' => 'callback_datetime'
382 );
383 $this->field_map[] = array(
384 'from_tablename' => 'kunena_messages',
385 'from_fieldname' => 'time',
386 'to_type' => 'reply',
387 'to_fieldname' => 'post_modified',
388 'callback_method' => 'callback_datetime'
389 );
390 $this->field_map[] = array(
391 'from_tablename' => 'kunena_messages',
392 'from_fieldname' => 'time',
393 'to_type' => 'reply',
394 'to_fieldname' => 'post_modified_gmt',
395 'callback_method' => 'callback_datetime'
396 );
397
398 /** User Section ******************************************************/
399
400 //Note: We are importing the Joomla User details and the Kunena v3.x user profile details.
401
402 // Store old user id (Stored in usermeta)
403 $this->field_map[] = array(
404 'from_tablename' => 'users',
405 'from_fieldname' => 'id',
406 'to_type' => 'user',
407 'to_fieldname' => '_bbp_old_user_id'
408 );
409
410 // Store old user password (Stored in serialized usermeta)
411 $this->field_map[] = array(
412 'from_tablename' => 'users',
413 'from_fieldname' => 'password',
414 'to_type' => 'user',
415 'to_fieldname' => '_bbp_password',
416 'callback_method' => 'callback_savepass'
417 );
418
419 // User password verify class (Stored in usermeta for verifying password)
420 $this->field_map[] = array(
421 'to_type' => 'user',
422 'to_fieldname' => '_bbp_class',
423 'default' => 'Kunena3'
424 );
425
426 // User name.
427 $this->field_map[] = array(
428 'from_tablename' => 'users',
429 'from_fieldname' => 'username',
430 'to_type' => 'user',
431 'to_fieldname' => 'user_login'
432 );
433
434 // User nice name.
435 $this->field_map[] = array(
436 'from_tablename' => 'users',
437 'from_fieldname' => 'username',
438 'to_type' => 'user',
439 'to_fieldname' => 'user_nicename'
440 );
441
442 // User email.
443 $this->field_map[] = array(
444 'from_tablename' => 'users',
445 'from_fieldname' => 'email',
446 'to_type' => 'user',
447 'to_fieldname' => 'user_email'
448 );
449
450 // User homepage.
451 $this->field_map[] = array(
452 'from_tablename' => 'kunena_users',
453 'from_fieldname' => 'websiteurl',
454 'join_tablename' => 'users',
455 'join_type' => 'LEFT',
456 'join_expression' => 'ON kunena_users.userid = users.id',
457 'to_type' => 'user',
458 'to_fieldname' => 'user_url'
459 );
460
461 // User registered.
462 $this->field_map[] = array(
463 'from_tablename' => 'users',
464 'from_fieldname' => 'registerDate',
465 'to_type' => 'user',
466 'to_fieldname' => 'user_registered',
467 'callback_method' => 'callback_datetime'
468 );
469
470 // User display name.
471 $this->field_map[] = array(
472 'from_tablename' => 'users',
473 'from_fieldname' => 'name',
474 'to_type' => 'user',
475 'to_fieldname' => 'display_name'
476 );
477
478 // User AIM (Stored in usermeta)
479 $this->field_map[] = array(
480 'from_tablename' => 'kunena_users',
481 'from_fieldname' => 'aim',
482 'join_tablename' => 'users',
483 'join_type' => 'LEFT',
484 'join_expression' => 'ON kunena_users.userid = users.id',
485 'to_type' => 'user',
486 'to_fieldname' => '_bbp_kunena3_user_aim'
487 );
488
489 // User Yahoo (Stored in usermeta)
490 $this->field_map[] = array(
491 'from_tablename' => 'kunena_users',
492 'from_fieldname' => 'yim',
493 'join_tablename' => 'users',
494 'join_type' => 'LEFT',
495 'join_expression' => 'ON kunena_users.userid = users.id',
496 'to_type' => 'user',
497 'to_fieldname' => '_bbp_kunena3_user_yim'
498 );
499
500 // Store Google Tak (Stored in usermeta)
501 $this->field_map[] = array(
502 'from_tablename' => 'kunena_users',
503 'from_fieldname' => 'gtalk',
504 'join_tablename' => 'users',
505 'join_type' => 'LEFT',
506 'join_expression' => 'ON kunena_users.userid = users.id',
507 'to_type' => 'user',
508 'to_fieldname' => '_bbp_kunena3_user_jabber'
509 );
510
511 // Store ICQ (Stored in usermeta)
512 $this->field_map[] = array(
513 'from_tablename' => 'kunena_users',
514 'from_fieldname' => 'icq',
515 'join_tablename' => 'users',
516 'join_type' => 'LEFT',
517 'join_expression' => 'ON kunena_users.userid = users.id',
518 'to_type' => 'user',
519 'to_fieldname' => '_bbp_kunena3_user_icq'
520 );
521
522 // Store MSN (Stored in usermeta)
523 $this->field_map[] = array(
524 'from_tablename' => 'kunena_users',
525 'from_fieldname' => 'msn',
526 'join_tablename' => 'users',
527 'join_type' => 'LEFT',
528 'join_expression' => 'ON kunena_users.userid = users.id',
529 'to_type' => 'user',
530 'to_fieldname' => '_bbp_kunena3_user_msn'
531 );
532
533 // Store Skype (Stored in usermeta)
534 $this->field_map[] = array(
535 'from_tablename' => 'kunena_users',
536 'from_fieldname' => 'skype',
537 'join_tablename' => 'users',
538 'join_type' => 'LEFT',
539 'join_expression' => 'ON kunena_users.userid = users.id',
540 'to_type' => 'user',
541 'to_fieldname' => '_bbp_kunena3_user_skype'
542 );
543
544 // Store Twitter (Stored in usermeta)
545 $this->field_map[] = array(
546 'from_tablename' => 'kunena_users',
547 'from_fieldname' => 'twitter',
548 'join_tablename' => 'users',
549 'join_type' => 'LEFT',
550 'join_expression' => 'ON kunena_users.userid = users.id',
551 'to_type' => 'user',
552 'to_fieldname' => '_bbp_kunena3_user_twitter'
553 );
554
555 // Store Facebook (Stored in usermeta)
556 $this->field_map[] = array(
557 'from_tablename' => 'kunena_users',
558 'from_fieldname' => 'facebook',
559 'join_tablename' => 'users',
560 'join_type' => 'LEFT',
561 'join_expression' => 'ON kunena_users.userid = users.id',
562 'to_type' => 'user',
563 'to_fieldname' => '_bbp_kunena3_user_facebook'
564 );
565
566 // Store myspace (Stored in usermeta)
567 $this->field_map[] = array(
568 'from_tablename' => 'kunena_users',
569 'from_fieldname' => 'myspace',
570 'join_tablename' => 'users',
571 'join_type' => 'LEFT',
572 'join_expression' => 'ON kunena_users.userid = users.id',
573 'to_type' => 'user',
574 'to_fieldname' => '_bbp_kunena3_user_myspace'
575 );
576
577 // Store linkedin (Stored in usermeta)
578 $this->field_map[] = array(
579 'from_tablename' => 'kunena_users',
580 'from_fieldname' => 'linkedin',
581 'join_tablename' => 'users',
582 'join_type' => 'LEFT',
583 'join_expression' => 'ON kunena_users.userid = users.id',
584 'to_type' => 'user',
585 'to_fieldname' => '_bbp_kunena3_user_linkedin'
586 );
587
588 // Store delicious (Stored in usermeta)
589 $this->field_map[] = array(
590 'from_tablename' => 'kunena_users',
591 'from_fieldname' => 'delicious',
592 'join_tablename' => 'users',
593 'join_type' => 'LEFT',
594 'join_expression' => 'ON kunena_users.userid = users.id',
595 'to_type' => 'user',
596 'to_fieldname' => '_bbp_kunena3_user_delicious'
597 );
598
599 // Store friendfeed (Stored in usermeta)
600 $this->field_map[] = array(
601 'from_tablename' => 'kunena_users',
602 'from_fieldname' => 'friendfeed',
603 'join_tablename' => 'users',
604 'join_type' => 'LEFT',
605 'join_expression' => 'ON kunena_users.userid = users.id',
606 'to_type' => 'user',
607 'to_fieldname' => '_bbp_kunena3_user_friendfeed'
608 );
609
610 // Store digg (Stored in usermeta)
611 $this->field_map[] = array(
612 'from_tablename' => 'kunena_users',
613 'from_fieldname' => 'digg',
614 'join_tablename' => 'users',
615 'join_type' => 'LEFT',
616 'join_expression' => 'ON kunena_users.userid = users.id',
617 'to_type' => 'user',
618 'to_fieldname' => '_bbp_kunena3_user_digg'
619 );
620
621 // Store blogspot (Stored in usermeta)
622 $this->field_map[] = array(
623 'from_tablename' => 'kunena_users',
624 'from_fieldname' => 'blogspot',
625 'join_tablename' => 'users',
626 'join_type' => 'LEFT',
627 'join_expression' => 'ON kunena_users.userid = users.id',
628 'to_type' => 'user',
629 'to_fieldname' => '_bbp_kunena3_user_blogspot'
630 );
631
632 // Store flickr (Stored in usermeta)
633 $this->field_map[] = array(
634 'from_tablename' => 'kunena_users',
635 'from_fieldname' => 'flickr',
636 'join_tablename' => 'users',
637 'join_type' => 'LEFT',
638 'join_expression' => 'ON kunena_users.userid = users.id',
639 'to_type' => 'user',
640 'to_fieldname' => '_bbp_kunena3_user_flickr'
641 );
642
643 // Store bebo (Stored in usermeta)
644 $this->field_map[] = array(
645 'from_tablename' => 'kunena_users',
646 'from_fieldname' => 'bebo',
647 'join_tablename' => 'users',
648 'join_type' => 'LEFT',
649 'join_expression' => 'ON kunena_users.userid = users.id',
650 'to_type' => 'user',
651 'to_fieldname' => '_bbp_kunena3_user_bebo'
652 );
653
654 // Store websitename (Stored in usermeta)
655 $this->field_map[] = array(
656 'from_tablename' => 'kunena_users',
657 'from_fieldname' => 'websitename',
658 'join_tablename' => 'users',
659 'join_type' => 'LEFT',
660 'join_expression' => 'ON kunena_users.userid = users.id',
661 'to_type' => 'user',
662 'to_fieldname' => '_bbp_kunena3_user_websitename'
663 );
664
665 // Store location (Stored in usermeta)
666 $this->field_map[] = array(
667 'from_tablename' => 'kunena_users',
668 'from_fieldname' => 'location',
669 'join_tablename' => 'users',
670 'join_type' => 'LEFT',
671 'join_expression' => 'ON kunena_users.userid = users.id',
672 'to_type' => 'user',
673 'to_fieldname' => '_bbp_kunena3_user_location'
674 );
675
676 // Store Signature (Stored in usermeta)
677 $this->field_map[] = array(
678 'from_tablename' => 'kunena_users',
679 'from_fieldname' => 'signature',
680 'join_tablename' => 'users',
681 'join_type' => 'LEFT',
682 'join_expression' => 'ON kunena_users.userid = users.id',
683 'to_type' => 'user',
684 'to_fieldname' => '_bbp_kunena3_user_sig',
685 'callback_method' => 'callback_html'
686 );
687 }
688
689 /**
690 * This method allows us to indicates what is or is not converted for each
691 * converter.
692 */
693 public function info() {
694 return '';
695 }
696
697 /**
698 * This method is to save the salt and password together. That
699 * way when we authenticate it we can get it out of the database
700 * as one value. Array values are auto sanitized by WordPress.
701 */
702 public function callback_savepass( $field, $row ) {
703 return array( 'hash' => $field );
704 }
705
706 /**
707 * This method is to take the pass out of the database and compare
708 * to a pass the user has typed in.
709 */
710 public function authenticate_pass( $password, $serialized_pass ) {
711
712 // Unserialize the password, with safeguards
713 $pass_array = $this->unserialize_pass( $serialized_pass );
714
715 // Bail if missing or invalid values
716 if ( ! is_string( $password ) || ! is_array( $pass_array ) || ! isset( $pass_array['hash'] ) || ! is_string( $pass_array['hash'] ) ) {
717 return false;
718 }
719
720 $hash = $pass_array['hash'];
721
722 // Modern Joomla password formats
723 if ( 0 === strpos( $hash, '$P$' ) ) {
724 return wp_check_password( $password, $hash );
725 } elseif ( 0 === strpos( $hash, '$2' ) || 0 === strpos( $hash, '$argon2i' ) || 0 === strpos( $hash, '$argon2id' ) ) {
726 return password_verify( $password, $hash );
727 }
728
729 // Legacy Joomla SHA-256 passwords
730 if ( 0 === strpos( $hash, '{SHA256}' ) ) {
731 $parts = explode( ':', substr( $hash, 8 ) );
732 $salt = isset( $parts[1] ) ? $parts[1] : '';
733
734 return hash_equals(
735 $hash,
736 '{SHA256}' . hash( 'sha256', $password . $salt ) . ( $salt ? ':' . $salt : '' )
737 );
738 }
739
740 // Legacy Joomla MD5 passwords
741 $parts = explode( ':', $hash );
742 $salt = isset( $parts[1] ) ? $parts[1] : '';
743
744 $test_hash = md5( $password . $salt ) . ( $salt ? ':' . $salt : ( false !== strpos( $hash, ':' ) ? ':' : '' ) );
745
746 return hash_equals( $hash, $test_hash );
747 }
748
749 /**
750 * Translate the forum type from Kunena v3.x numerics to WordPress's strings.
751 *
752 * @param int $status Kunena v3.x numeric forum type
753 * @return string WordPress safe
754 */
755 public function callback_forum_type( $status = 0 ) {
756 if ( empty( $status ) ) {
757 $status = 'category';
758 } else {
759 $status = 'forum';
760 }
761 return $status;
762 }
763
764 /**
765 * Translate the forum status from Kunena v3.x numerics to WordPress's strings.
766 *
767 * @param int $status Kunena v3.x numeric forum status
768 * @return string WordPress safe
769 */
770 public function callback_forum_status( $status = 0 ) {
771 switch ( $status ) {
772 case 1 :
773 $status = 'closed';
774 break;
775
776 case 0 :
777 default :
778 $status = 'open';
779 break;
780 }
781 return $status;
782 }
783
784 /**
785 * Translate the post status from Kunena v3.x numerics to WordPress's strings.
786 *
787 * @param int $status Kunena v3.x numeric topic status
788 * @return string WordPress safe
789 */
790 public function callback_topic_status( $status = 0 ) {
791 switch ( $status ) {
792 case 1 :
793 $status = 'closed';
794 break;
795
796 case 0 :
797 default :
798 $status = 'publish';
799 break;
800 }
801 return $status;
802 }
803
804 /**
805 * Verify the topic/reply count.
806 *
807 * @param int $count Kunena v3.x topic/reply counts
808 * @return string WordPress safe
809 */
810 public function callback_topic_reply_count( $count = 1 ) {
811 $count = absint( (int) $count - 1 );
812 return $count;
813 }
814 }
815