1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * Implementation of PunBB Forum converter. |
---|
5 | * |
---|
6 | * @since bbPress (r5057) |
---|
7 | * @link Codex Docs http://codex.bbpress.org/import-forums/punbb |
---|
8 | */ |
---|
9 | class PunBB extends BBP_Converter_Base { |
---|
10 | |
---|
11 | /** |
---|
12 | * Main Constructor |
---|
13 | * |
---|
14 | * @uses PunBB::setup_globals() |
---|
15 | */ |
---|
16 | function __construct() { |
---|
17 | parent::__construct(); |
---|
18 | $this->setup_globals(); |
---|
19 | } |
---|
20 | |
---|
21 | /** |
---|
22 | * Sets up the field mappings |
---|
23 | */ |
---|
24 | public function setup_globals() { |
---|
25 | |
---|
26 | /** Forum Section ******************************************************/ |
---|
27 | |
---|
28 | // Forum id (Stored in postmeta) |
---|
29 | $this->field_map[] = array( |
---|
30 | 'from_tablename' => 'forums', |
---|
31 | 'from_fieldname' => 'id', |
---|
32 | 'to_type' => 'forum', |
---|
33 | 'to_fieldname' => '_bbp_forum_id' |
---|
34 | ); |
---|
35 | |
---|
36 | // Forum parent id (If no parent, then 0, Stored in postmeta) |
---|
37 | // $this->field_map[] = array( |
---|
38 | // 'from_tablename' => 'forums', |
---|
39 | // 'from_fieldname' => 'cat_id', |
---|
40 | // 'to_type' => 'forum', |
---|
41 | // 'to_fieldname' => '_bbp_forum_parent_id' |
---|
42 | // ); |
---|
43 | |
---|
44 | // Forum title. |
---|
45 | $this->field_map[] = array( |
---|
46 | 'from_tablename' => 'forums', |
---|
47 | 'from_fieldname' => 'forum_name', |
---|
48 | 'to_type' => 'forum', |
---|
49 | 'to_fieldname' => 'post_title' |
---|
50 | ); |
---|
51 | |
---|
52 | // Forum slug (Clean name to avoid conflicts) |
---|
53 | $this->field_map[] = array( |
---|
54 | 'from_tablename' => 'forums', |
---|
55 | 'from_fieldname' => 'forum_name', |
---|
56 | 'to_type' => 'forum', |
---|
57 | 'to_fieldname' => 'post_name', |
---|
58 | 'callback_method' => 'callback_slug' |
---|
59 | ); |
---|
60 | |
---|
61 | // Forum description. |
---|
62 | $this->field_map[] = array( |
---|
63 | 'from_tablename' => 'forums', |
---|
64 | 'from_fieldname' => 'forum_desc', |
---|
65 | 'to_type' => 'forum', |
---|
66 | 'to_fieldname' => 'post_content', |
---|
67 | 'callback_method' => 'callback_null' |
---|
68 | ); |
---|
69 | |
---|
70 | // Forum display order (Starts from 1) |
---|
71 | $this->field_map[] = array( |
---|
72 | 'from_tablename' => 'forums', |
---|
73 | 'from_fieldname' => 'disp_position', |
---|
74 | 'to_type' => 'forum', |
---|
75 | 'to_fieldname' => 'menu_order' |
---|
76 | ); |
---|
77 | |
---|
78 | // Forum topic count (Stored in postmeta) |
---|
79 | $this->field_map[] = array( |
---|
80 | 'from_tablename' => 'forums', |
---|
81 | 'from_fieldname' => 'num_topics', |
---|
82 | 'to_type' => 'forum', |
---|
83 | 'to_fieldname' => '_bbp_topic_count' |
---|
84 | ); |
---|
85 | |
---|
86 | // Forum reply count (Stored in postmeta) |
---|
87 | $this->field_map[] = array( |
---|
88 | 'from_tablename' => 'forums', |
---|
89 | 'from_fieldname' => 'num_posts', |
---|
90 | 'to_type' => 'forum', |
---|
91 | 'to_fieldname' => '_bbp_reply_count' |
---|
92 | ); |
---|
93 | |
---|
94 | // Forum dates. |
---|
95 | $this->field_map[] = array( |
---|
96 | 'to_type' => 'forum', |
---|
97 | 'to_fieldname' => 'post_date', |
---|
98 | 'default' => date('Y-m-d H:i:s') |
---|
99 | ); |
---|
100 | $this->field_map[] = array( |
---|
101 | 'to_type' => 'forum', |
---|
102 | 'to_fieldname' => 'post_date_gmt', |
---|
103 | 'default' => date('Y-m-d H:i:s') |
---|
104 | ); |
---|
105 | $this->field_map[] = array( |
---|
106 | 'to_type' => 'forum', |
---|
107 | 'to_fieldname' => 'post_modified', |
---|
108 | 'default' => date('Y-m-d H:i:s') |
---|
109 | ); |
---|
110 | $this->field_map[] = array( |
---|
111 | 'to_type' => 'forum', |
---|
112 | 'to_fieldname' => 'post_modified_gmt', |
---|
113 | 'default' => date('Y-m-d H:i:s') |
---|
114 | ); |
---|
115 | |
---|
116 | /** Topic Section ******************************************************/ |
---|
117 | |
---|
118 | // Topic id (Stored in postmeta) |
---|
119 | $this->field_map[] = array( |
---|
120 | 'from_tablename' => 'topics', |
---|
121 | 'from_fieldname' => 'id', |
---|
122 | 'to_type' => 'topic', |
---|
123 | 'to_fieldname' => '_bbp_topic_id' |
---|
124 | ); |
---|
125 | |
---|
126 | // Topic reply count (Stored in postmeta) |
---|
127 | $this->field_map[] = array( |
---|
128 | 'from_tablename' => 'topics', |
---|
129 | 'from_fieldname' => 'num_replies', |
---|
130 | 'to_type' => 'topic', |
---|
131 | 'to_fieldname' => '_bbp_reply_count', |
---|
132 | 'callback_method' => 'callback_topic_reply_count' |
---|
133 | ); |
---|
134 | |
---|
135 | // Topic total reply count (Includes unpublished replies, Stored in postmeta) |
---|
136 | $this->field_map[] = array( |
---|
137 | 'from_tablename' => 'topics', |
---|
138 | 'from_fieldname' => 'num_replies', |
---|
139 | 'to_type' => 'topic', |
---|
140 | 'to_fieldname' => '_bbp_total_reply_count', |
---|
141 | 'callback_method' => 'callback_topic_reply_count' |
---|
142 | ); |
---|
143 | |
---|
144 | // Topic parent forum id (If no parent, then 0. Stored in postmeta) |
---|
145 | $this->field_map[] = array( |
---|
146 | 'from_tablename' => 'topics', |
---|
147 | 'from_fieldname' => 'forum_id', |
---|
148 | 'to_type' => 'topic', |
---|
149 | 'to_fieldname' => '_bbp_forum_id', |
---|
150 | 'callback_method' => 'callback_forumid' |
---|
151 | ); |
---|
152 | |
---|
153 | // Topic author. |
---|
154 | // Note: We join the 'posts' table because 'topics' table does not have user id's. |
---|
155 | $this->field_map[] = array( |
---|
156 | 'from_tablename' => 'posts', |
---|
157 | 'from_fieldname' => 'poster_id', |
---|
158 | 'join_tablename' => 'topics', |
---|
159 | 'join_type' => 'LEFT', |
---|
160 | 'join_expression' => 'ON topics.first_post_id = posts.id', |
---|
161 | 'to_type' => 'topic', |
---|
162 | 'to_fieldname' => 'post_author', |
---|
163 | 'callback_method' => 'callback_userid' |
---|
164 | ); |
---|
165 | |
---|
166 | // Topic Author ip (Stored in postmeta) |
---|
167 | // Note: We join the 'posts' table because 'topics' table does not have author ip. |
---|
168 | $this->field_map[] = array( |
---|
169 | 'from_tablename' => 'posts', |
---|
170 | 'from_fieldname' => 'poster_ip', |
---|
171 | 'join_tablename' => 'topics', |
---|
172 | 'join_type' => 'LEFT', |
---|
173 | 'join_expression' => 'ON topics.first_post_id = posts.id', |
---|
174 | 'to_type' => 'topic', |
---|
175 | 'to_fieldname' => '_bbp_author_ip' |
---|
176 | ); |
---|
177 | |
---|
178 | // Topic content. |
---|
179 | // Note: We join the 'posts' table because 'topics' table does not have content. |
---|
180 | $this->field_map[] = array( |
---|
181 | 'from_tablename' => 'posts', |
---|
182 | 'from_fieldname' => 'message', |
---|
183 | 'join_tablename' => 'topics', |
---|
184 | 'join_type' => 'LEFT', |
---|
185 | 'join_expression' => 'ON topics.first_post_id = posts.id', |
---|
186 | 'to_type' => 'topic', |
---|
187 | 'to_fieldname' => 'post_content', |
---|
188 | 'callback_method' => 'callback_html' |
---|
189 | ); |
---|
190 | |
---|
191 | // Topic title. |
---|
192 | $this->field_map[] = array( |
---|
193 | 'from_tablename' => 'topics', |
---|
194 | 'from_fieldname' => 'subject', |
---|
195 | 'to_type' => 'topic', |
---|
196 | 'to_fieldname' => 'post_title' |
---|
197 | ); |
---|
198 | |
---|
199 | // Topic slug (Clean name to avoid conflicts) |
---|
200 | $this->field_map[] = array( |
---|
201 | 'from_tablename' => 'topics', |
---|
202 | 'from_fieldname' => 'subject', |
---|
203 | 'to_type' => 'topic', |
---|
204 | 'to_fieldname' => 'post_name', |
---|
205 | 'callback_method' => 'callback_slug' |
---|
206 | ); |
---|
207 | |
---|
208 | // Topic parent forum id (If no parent, then 0) |
---|
209 | $this->field_map[] = array( |
---|
210 | 'from_tablename' => 'topics', |
---|
211 | 'from_fieldname' => 'forum_id', |
---|
212 | 'to_type' => 'topic', |
---|
213 | 'to_fieldname' => 'post_parent', |
---|
214 | 'callback_method' => 'callback_forumid' |
---|
215 | ); |
---|
216 | |
---|
217 | // Topic dates. |
---|
218 | $this->field_map[] = array( |
---|
219 | 'from_tablename' => 'topics', |
---|
220 | 'from_fieldname' => 'posted', |
---|
221 | 'to_type' => 'topic', |
---|
222 | 'to_fieldname' => 'post_date', |
---|
223 | 'callback_method' => 'callback_datetime' |
---|
224 | ); |
---|
225 | $this->field_map[] = array( |
---|
226 | 'from_tablename' => 'topics', |
---|
227 | 'from_fieldname' => 'posted', |
---|
228 | 'to_type' => 'topic', |
---|
229 | 'to_fieldname' => 'post_date_gmt', |
---|
230 | 'callback_method' => 'callback_datetime' |
---|
231 | ); |
---|
232 | $this->field_map[] = array( |
---|
233 | 'from_tablename' => 'topics', |
---|
234 | 'from_fieldname' => 'last_post', |
---|
235 | 'to_type' => 'topic', |
---|
236 | 'to_fieldname' => 'post_modified', |
---|
237 | 'callback_method' => 'callback_datetime' |
---|
238 | ); |
---|
239 | $this->field_map[] = array( |
---|
240 | 'from_tablename' => 'topics', |
---|
241 | 'from_fieldname' => 'last_post', |
---|
242 | 'to_type' => 'topic', |
---|
243 | 'to_fieldname' => 'post_modified_gmt', |
---|
244 | 'callback_method' => 'callback_datetime' |
---|
245 | ); |
---|
246 | $this->field_map[] = array( |
---|
247 | 'from_tablename' => 'topics', |
---|
248 | 'from_fieldname' => 'last_post', |
---|
249 | 'to_type' => 'topic', |
---|
250 | 'to_fieldname' => '_bbp_last_active_time', |
---|
251 | 'callback_method' => 'callback_datetime' |
---|
252 | ); |
---|
253 | |
---|
254 | // Topic status (Open or Closed, PunBB v1.4.2 0=open & 1=closed) |
---|
255 | $this->field_map[] = array( |
---|
256 | 'from_tablename' => 'topics', |
---|
257 | 'from_fieldname' => 'closed', |
---|
258 | 'to_type' => 'topic', |
---|
259 | 'to_fieldname' => 'post_status', |
---|
260 | 'callback_method' => 'callback_topic_status' |
---|
261 | ); |
---|
262 | |
---|
263 | /** Tags Section ******************************************************/ |
---|
264 | |
---|
265 | /** |
---|
266 | * PunBB v1.4.2 Forums do not support topic tags out of the box |
---|
267 | */ |
---|
268 | |
---|
269 | /** Reply Section ******************************************************/ |
---|
270 | |
---|
271 | // Reply id (Stored in postmeta) |
---|
272 | $this->field_map[] = array( |
---|
273 | 'from_tablename' => 'posts', |
---|
274 | 'from_fieldname' => 'id', |
---|
275 | 'to_type' => 'reply', |
---|
276 | 'to_fieldname' => '_bbp_post_id' |
---|
277 | ); |
---|
278 | |
---|
279 | // Reply parent forum id (If no parent, then 0. Stored in postmeta) |
---|
280 | // Note: We join the 'topics' table because 'posts' table does not have parent forum id's. |
---|
281 | $this->field_map[] = array( |
---|
282 | 'from_tablename' => 'topics', |
---|
283 | 'from_fieldname' => 'forum_id', |
---|
284 | 'join_tablename' => 'posts', |
---|
285 | 'join_type' => 'LEFT', |
---|
286 | 'join_expression' => 'ON topics.id = posts.topic_id WHERE topics.first_post_id != posts.id', |
---|
287 | 'to_type' => 'reply', |
---|
288 | 'to_fieldname' => '_bbp_forum_id', |
---|
289 | 'callback_method' => 'callback_topicid_to_forumid' |
---|
290 | ); |
---|
291 | |
---|
292 | // Reply parent topic id (If no parent, then 0. Stored in postmeta) |
---|
293 | $this->field_map[] = array( |
---|
294 | 'from_tablename' => 'posts', |
---|
295 | 'from_fieldname' => 'topic_id', |
---|
296 | 'to_type' => 'reply', |
---|
297 | 'to_fieldname' => '_bbp_topic_id', |
---|
298 | 'callback_method' => 'callback_topicid' |
---|
299 | ); |
---|
300 | |
---|
301 | // Reply author ip (Stored in postmeta) |
---|
302 | $this->field_map[] = array( |
---|
303 | 'from_tablename' => 'posts', |
---|
304 | 'from_fieldname' => 'poster_ip', |
---|
305 | 'to_type' => 'reply', |
---|
306 | 'to_fieldname' => '_bbp_author_ip' |
---|
307 | ); |
---|
308 | |
---|
309 | // Reply author. |
---|
310 | $this->field_map[] = array( |
---|
311 | 'from_tablename' => 'posts', |
---|
312 | 'from_fieldname' => 'poster_id', |
---|
313 | 'to_type' => 'reply', |
---|
314 | 'to_fieldname' => 'post_author', |
---|
315 | 'callback_method' => 'callback_userid' |
---|
316 | ); |
---|
317 | |
---|
318 | // Reply title. |
---|
319 | // Note: We join the 'topics' table because 'posts' table does not have topic subject. |
---|
320 | $this->field_map[] = array( |
---|
321 | 'from_tablename' => 'topics', |
---|
322 | 'from_fieldname' => 'subject', |
---|
323 | 'join_tablename' => 'posts', |
---|
324 | 'join_type' => 'LEFT', |
---|
325 | 'join_expression' => 'ON topics.id = posts.topic_id WHERE topics.first_post_id != posts.id', |
---|
326 | 'to_type' => 'reply', |
---|
327 | 'to_fieldname' => 'post_title' |
---|
328 | ); |
---|
329 | |
---|
330 | // Reply slug (Clean name to avoid conflicts) |
---|
331 | // Note: We join the 'topics' table because 'posts' table does not have topic subject. |
---|
332 | $this->field_map[] = array( |
---|
333 | 'from_tablename' => 'topics', |
---|
334 | 'from_fieldname' => 'subject', |
---|
335 | 'join_tablename' => 'posts', |
---|
336 | 'join_type' => 'LEFT', |
---|
337 | 'join_expression' => 'ON topics.id = posts.topic_id WHERE topics.first_post_id != posts.id', |
---|
338 | 'to_type' => 'reply', |
---|
339 | 'to_fieldname' => 'post_name', |
---|
340 | 'callback_method' => 'callback_slug' |
---|
341 | ); |
---|
342 | |
---|
343 | // Reply content. |
---|
344 | $this->field_map[] = array( |
---|
345 | 'from_tablename' => 'posts', |
---|
346 | 'from_fieldname' => 'message', |
---|
347 | 'to_type' => 'reply', |
---|
348 | 'to_fieldname' => 'post_content', |
---|
349 | 'callback_method' => 'callback_html' |
---|
350 | ); |
---|
351 | |
---|
352 | // Reply parent topic id (If no parent, then 0) |
---|
353 | $this->field_map[] = array( |
---|
354 | 'from_tablename' => 'posts', |
---|
355 | 'from_fieldname' => 'topic_id', |
---|
356 | 'to_type' => 'reply', |
---|
357 | 'to_fieldname' => 'post_parent', |
---|
358 | 'callback_method' => 'callback_topicid' |
---|
359 | ); |
---|
360 | |
---|
361 | // Reply dates. |
---|
362 | $this->field_map[] = array( |
---|
363 | 'from_tablename' => 'posts', |
---|
364 | 'from_fieldname' => 'posted', |
---|
365 | 'to_type' => 'reply', |
---|
366 | 'to_fieldname' => 'post_date', |
---|
367 | 'callback_method' => 'callback_datetime' |
---|
368 | ); |
---|
369 | $this->field_map[] = array( |
---|
370 | 'from_tablename' => 'posts', |
---|
371 | 'from_fieldname' => 'posted', |
---|
372 | 'to_type' => 'reply', |
---|
373 | 'to_fieldname' => 'post_date_gmt', |
---|
374 | 'callback_method' => 'callback_datetime' |
---|
375 | ); |
---|
376 | $this->field_map[] = array( |
---|
377 | 'from_tablename' => 'posts', |
---|
378 | 'from_fieldname' => 'edited', |
---|
379 | 'to_type' => 'reply', |
---|
380 | 'to_fieldname' => 'post_modified', |
---|
381 | 'callback_method' => 'callback_datetime' |
---|
382 | ); |
---|
383 | $this->field_map[] = array( |
---|
384 | 'from_tablename' => 'posts', |
---|
385 | 'from_fieldname' => 'edited', |
---|
386 | 'to_type' => 'reply', |
---|
387 | 'to_fieldname' => 'post_modified_gmt', |
---|
388 | 'callback_method' => 'callback_datetime' |
---|
389 | ); |
---|
390 | |
---|
391 | /** User Section ******************************************************/ |
---|
392 | |
---|
393 | // Store old User id (Stored in usermeta) |
---|
394 | $this->field_map[] = array( |
---|
395 | 'from_tablename' => 'users', |
---|
396 | 'from_fieldname' => 'id', |
---|
397 | 'to_type' => 'user', |
---|
398 | 'to_fieldname' => '_bbp_user_id' |
---|
399 | ); |
---|
400 | |
---|
401 | // Store old User password (Stored in usermeta serialized with salt) |
---|
402 | $this->field_map[] = array( |
---|
403 | 'from_tablename' => 'users', |
---|
404 | 'from_fieldname' => 'password', |
---|
405 | 'to_type' => 'user', |
---|
406 | 'to_fieldname' => '_bbp_password', |
---|
407 | 'callback_method' => 'callback_savepass' |
---|
408 | ); |
---|
409 | |
---|
410 | // Store old User Salt (This is only used for the SELECT row info for the above password save) |
---|
411 | $this->field_map[] = array( |
---|
412 | 'from_tablename' => 'users', |
---|
413 | 'from_fieldname' => 'salt', |
---|
414 | 'to_type' => 'user', |
---|
415 | 'to_fieldname' => '' |
---|
416 | ); |
---|
417 | |
---|
418 | // User password verify class (Stored in usermeta for verifying password) |
---|
419 | $this->field_map[] = array( |
---|
420 | 'to_type' => 'users', |
---|
421 | 'to_fieldname' => '_bbp_class', |
---|
422 | 'default' => 'PunBB' |
---|
423 | ); |
---|
424 | |
---|
425 | // User name. |
---|
426 | $this->field_map[] = array( |
---|
427 | 'from_tablename' => 'users', |
---|
428 | 'from_fieldname' => 'username', |
---|
429 | 'to_type' => 'user', |
---|
430 | 'to_fieldname' => 'user_login' |
---|
431 | ); |
---|
432 | |
---|
433 | // User nice name. |
---|
434 | $this->field_map[] = array( |
---|
435 | 'from_tablename' => 'users', |
---|
436 | 'from_fieldname' => 'username', |
---|
437 | 'to_type' => 'user', |
---|
438 | 'to_fieldname' => 'user_nicename' |
---|
439 | ); |
---|
440 | |
---|
441 | // User email. |
---|
442 | $this->field_map[] = array( |
---|
443 | 'from_tablename' => 'users', |
---|
444 | 'from_fieldname' => 'email', |
---|
445 | 'to_type' => 'user', |
---|
446 | 'to_fieldname' => 'user_email' |
---|
447 | ); |
---|
448 | |
---|
449 | // User homepage. |
---|
450 | $this->field_map[] = array( |
---|
451 | 'from_tablename' => 'users', |
---|
452 | 'from_fieldname' => 'url', |
---|
453 | 'to_type' => 'user', |
---|
454 | 'to_fieldname' => 'user_url' |
---|
455 | ); |
---|
456 | |
---|
457 | // User registered. |
---|
458 | $this->field_map[] = array( |
---|
459 | 'from_tablename' => 'users', |
---|
460 | 'from_fieldname' => 'registered', |
---|
461 | 'to_type' => 'user', |
---|
462 | 'to_fieldname' => 'user_registered', |
---|
463 | 'callback_method' => 'callback_datetime' |
---|
464 | ); |
---|
465 | |
---|
466 | // User display name. |
---|
467 | $this->field_map[] = array( |
---|
468 | 'from_tablename' => 'users', |
---|
469 | 'from_fieldname' => 'realname', |
---|
470 | 'to_type' => 'user', |
---|
471 | 'to_fieldname' => 'display_name' |
---|
472 | ); |
---|
473 | |
---|
474 | // User AIM (Stored in usermeta) |
---|
475 | $this->field_map[] = array( |
---|
476 | 'from_tablename' => 'users', |
---|
477 | 'from_fieldname' => 'aim', |
---|
478 | 'to_type' => 'user', |
---|
479 | 'to_fieldname' => 'aim' |
---|
480 | ); |
---|
481 | |
---|
482 | // User Yahoo (Stored in usermeta) |
---|
483 | $this->field_map[] = array( |
---|
484 | 'from_tablename' => 'users', |
---|
485 | 'from_fieldname' => 'yahoo', |
---|
486 | 'to_type' => 'user', |
---|
487 | 'to_fieldname' => 'yim' |
---|
488 | ); |
---|
489 | |
---|
490 | // Store Jabber |
---|
491 | $this->field_map[] = array( |
---|
492 | 'from_tablename' => 'users', |
---|
493 | 'from_fieldname' => 'jabber', |
---|
494 | 'to_type' => 'user', |
---|
495 | 'to_fieldname' => 'jabber' |
---|
496 | ); |
---|
497 | |
---|
498 | // Store ICQ (Stored in usermeta) |
---|
499 | $this->field_map[] = array( |
---|
500 | 'from_tablename' => 'users', |
---|
501 | 'from_fieldname' => 'icq', |
---|
502 | 'to_type' => 'user', |
---|
503 | 'to_fieldname' => '_bbp_punbb_user_icq' |
---|
504 | ); |
---|
505 | |
---|
506 | // Store MSN (Stored in usermeta) |
---|
507 | $this->field_map[] = array( |
---|
508 | 'from_tablename' => 'users', |
---|
509 | 'from_fieldname' => 'msn', |
---|
510 | 'to_type' => 'user', |
---|
511 | 'to_fieldname' => '_bbp_punbb_user_msn' |
---|
512 | ); |
---|
513 | |
---|
514 | // Store Facebook (Stored in usermeta) |
---|
515 | $this->field_map[] = array( |
---|
516 | 'from_tablename' => 'users', |
---|
517 | 'from_fieldname' => 'facebook', |
---|
518 | 'to_type' => 'user', |
---|
519 | 'to_fieldname' => '_bbp_punbb_user_facebook' |
---|
520 | ); |
---|
521 | |
---|
522 | // Store Twitter (Stored in usermeta) |
---|
523 | $this->field_map[] = array( |
---|
524 | 'from_tablename' => 'users', |
---|
525 | 'from_fieldname' => 'twitter', |
---|
526 | 'to_type' => 'user', |
---|
527 | 'to_fieldname' => '_bbp_punbb_user_twitter' |
---|
528 | ); |
---|
529 | |
---|
530 | // Store LinkedIn (Stored in usermeta) |
---|
531 | $this->field_map[] = array( |
---|
532 | 'from_tablename' => 'users', |
---|
533 | 'from_fieldname' => 'linkedin', |
---|
534 | 'to_type' => 'user', |
---|
535 | 'to_fieldname' => '_bbp_punbb_user_linkedin' |
---|
536 | ); |
---|
537 | |
---|
538 | // Store Skype (Stored in usermeta) |
---|
539 | $this->field_map[] = array( |
---|
540 | 'from_tablename' => 'users', |
---|
541 | 'from_fieldname' => 'skype', |
---|
542 | 'to_type' => 'user', |
---|
543 | 'to_fieldname' => '_bbp_punbb_user_skype' |
---|
544 | ); |
---|
545 | |
---|
546 | // Store Signature (Stored in usermeta) |
---|
547 | $this->field_map[] = array( |
---|
548 | 'from_tablename' => 'users', |
---|
549 | 'from_fieldname' => 'signature', |
---|
550 | 'to_type' => 'user', |
---|
551 | 'to_fieldname' => '_bbp_punbb_user_sig', |
---|
552 | 'callback_method' => 'callback_html' |
---|
553 | ); |
---|
554 | |
---|
555 | // Store Location (Stored in usermeta) |
---|
556 | $this->field_map[] = array( |
---|
557 | 'from_tablename' => 'users', |
---|
558 | 'from_fieldname' => 'location', |
---|
559 | 'to_type' => 'user', |
---|
560 | 'to_fieldname' => '_bbp_punbb_user_from' |
---|
561 | ); |
---|
562 | |
---|
563 | // Store Admin Note (Stored in usermeta) |
---|
564 | $this->field_map[] = array( |
---|
565 | 'from_tablename' => 'users', |
---|
566 | 'from_fieldname' => 'admin_note', |
---|
567 | 'to_type' => 'user', |
---|
568 | 'to_fieldname' => '_bbp_punbb_user_admin_note' |
---|
569 | ); |
---|
570 | } |
---|
571 | |
---|
572 | /** |
---|
573 | * This method allows us to indicates what is or is not converted for each |
---|
574 | * converter. |
---|
575 | */ |
---|
576 | public function info() |
---|
577 | { |
---|
578 | return ''; |
---|
579 | } |
---|
580 | |
---|
581 | /** |
---|
582 | * This method is to save the salt and password together. That |
---|
583 | * way when we authenticate it we can get it out of the database |
---|
584 | * as one value. Array values are auto sanitized by WordPress. |
---|
585 | */ |
---|
586 | public function callback_savepass( $field, $row ) |
---|
587 | { |
---|
588 | $pass_array = array( 'hash' => $field, 'salt' => $row['salt'] ); |
---|
589 | return $pass_array; |
---|
590 | } |
---|
591 | |
---|
592 | /** |
---|
593 | * This method is to take the pass out of the database and compare |
---|
594 | * to a pass the user has typed in. |
---|
595 | */ |
---|
596 | public function authenticate_pass( $password, $serialized_pass ) |
---|
597 | { |
---|
598 | $pass_array = unserialize( $serialized_pass ); |
---|
599 | return ( $pass_array['hash'] == md5( md5( $password ). $pass_array['salt'] ) ); |
---|
600 | } |
---|
601 | |
---|
602 | /** |
---|
603 | * Translate the post status from PunBB v1.4.2 numeric's to WordPress's strings. |
---|
604 | * |
---|
605 | * @param int $status PunBB v1.4.2 numeric topic status |
---|
606 | * @return string WordPress safe |
---|
607 | */ |
---|
608 | public function callback_topic_status( $status = 0 ) { |
---|
609 | switch ( $status ) { |
---|
610 | case 1 : |
---|
611 | $status = 'closed'; |
---|
612 | break; |
---|
613 | |
---|
614 | case 0 : |
---|
615 | default : |
---|
616 | $status = 'publish'; |
---|
617 | break; |
---|
618 | } |
---|
619 | return $status; |
---|
620 | } |
---|
621 | |
---|
622 | /** |
---|
623 | * Verify the topic/reply count. |
---|
624 | * |
---|
625 | * @param int $count PunBB v1.4.2 topic/reply counts |
---|
626 | * @return string WordPress safe |
---|
627 | */ |
---|
628 | public function callback_topic_reply_count( $count = 1 ) { |
---|
629 | $count = absint( (int) $count - 1 ); |
---|
630 | return $count; |
---|
631 | } |
---|
632 | |
---|
633 | } |
---|