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