1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * Implementation of SMF Forum converter. |
---|
5 | * |
---|
6 | * @since bbPress (r5057) |
---|
7 | * @link Codex Docs http://codex.bbpress.org/import-forums/smf |
---|
8 | */ |
---|
9 | class SMF extends BBP_Converter_Base { |
---|
10 | |
---|
11 | /** |
---|
12 | * Main Constructor |
---|
13 | * |
---|
14 | * @uses SMF::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' => 'boards', |
---|
31 | 'from_fieldname' => 'id_board', |
---|
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' => 'boards', |
---|
39 | 'from_fieldname' => 'id_parent', |
---|
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' => 'boards', |
---|
47 | 'from_fieldname' => 'num_topics', |
---|
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' => 'boards', |
---|
55 | 'from_fieldname' => 'num_posts', |
---|
56 | 'to_type' => 'forum', |
---|
57 | 'to_fieldname' => '_bbp_reply_count' |
---|
58 | ); |
---|
59 | |
---|
60 | // Forum total topic count (Stored in postmeta) |
---|
61 | $this->field_map[] = array( |
---|
62 | 'from_tablename' => 'boards', |
---|
63 | 'from_fieldname' => 'num_topics', |
---|
64 | 'to_type' => 'forum', |
---|
65 | 'to_fieldname' => '_bbp_total_topic_count' |
---|
66 | ); |
---|
67 | |
---|
68 | // Forum total reply count (Stored in postmeta) |
---|
69 | $this->field_map[] = array( |
---|
70 | 'from_tablename' => 'boards', |
---|
71 | 'from_fieldname' => 'num_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' => 'boards', |
---|
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' => 'boards', |
---|
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' => 'boards', |
---|
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' => 'boards', |
---|
105 | 'from_fieldname' => 'board_order', |
---|
106 | 'to_type' => 'forum', |
---|
107 | 'to_fieldname' => 'menu_order' |
---|
108 | ); |
---|
109 | |
---|
110 | // Forum dates. |
---|
111 | $this->field_map[] = array( |
---|
112 | 'to_type' => 'forum', |
---|
113 | 'to_fieldname' => 'post_date', |
---|
114 | 'default' => date('Y-m-d H:i:s') |
---|
115 | ); |
---|
116 | $this->field_map[] = array( |
---|
117 | 'to_type' => 'forum', |
---|
118 | 'to_fieldname' => 'post_date_gmt', |
---|
119 | 'default' => date('Y-m-d H:i:s') |
---|
120 | ); |
---|
121 | $this->field_map[] = array( |
---|
122 | 'to_type' => 'forum', |
---|
123 | 'to_fieldname' => 'post_modified', |
---|
124 | 'default' => date('Y-m-d H:i:s') |
---|
125 | ); |
---|
126 | $this->field_map[] = array( |
---|
127 | 'to_type' => 'forum', |
---|
128 | 'to_fieldname' => 'post_modified_gmt', |
---|
129 | 'default' => date('Y-m-d H:i:s') |
---|
130 | ); |
---|
131 | |
---|
132 | /** Topic Section ******************************************************/ |
---|
133 | |
---|
134 | // Topic id (Stored in postmeta) |
---|
135 | $this->field_map[] = array( |
---|
136 | 'from_tablename' => 'topics', |
---|
137 | 'from_fieldname' => 'id_topic', |
---|
138 | 'to_type' => 'topic', |
---|
139 | 'to_fieldname' => '_bbp_topic_id' |
---|
140 | ); |
---|
141 | |
---|
142 | // Topic reply count (Stored in postmeta) |
---|
143 | $this->field_map[] = array( |
---|
144 | 'from_tablename' => 'topics', |
---|
145 | 'from_fieldname' => 'num_replies', |
---|
146 | 'to_type' => 'topic', |
---|
147 | 'to_fieldname' => '_bbp_reply_count', |
---|
148 | 'callback_method' => 'callback_topic_reply_count' |
---|
149 | ); |
---|
150 | |
---|
151 | // Topic total reply count (Includes unpublished replies, Stored in postmeta) |
---|
152 | $this->field_map[] = array( |
---|
153 | 'from_tablename' => 'topics', |
---|
154 | 'from_fieldname' => 'num_replies', |
---|
155 | 'to_type' => 'topic', |
---|
156 | 'to_fieldname' => '_bbp_total_reply_count', |
---|
157 | 'callback_method' => 'callback_topic_reply_count' |
---|
158 | ); |
---|
159 | |
---|
160 | // Topic parent forum id (If no parent, then 0. Stored in postmeta) |
---|
161 | $this->field_map[] = array( |
---|
162 | 'from_tablename' => 'topics', |
---|
163 | 'from_fieldname' => 'id_board', |
---|
164 | 'to_type' => 'topic', |
---|
165 | 'to_fieldname' => '_bbp_forum_id', |
---|
166 | 'callback_method' => 'callback_forumid' |
---|
167 | ); |
---|
168 | |
---|
169 | // Topic author. |
---|
170 | $this->field_map[] = array( |
---|
171 | 'from_tablename' => 'topics', |
---|
172 | 'from_fieldname' => 'id_member_started', |
---|
173 | 'to_type' => 'topic', |
---|
174 | 'to_fieldname' => 'post_author', |
---|
175 | 'callback_method' => 'callback_userid' |
---|
176 | ); |
---|
177 | |
---|
178 | // Topic Author ip (Stored in postmeta) |
---|
179 | $this->field_map[] = array( |
---|
180 | 'from_tablename' => 'messages', |
---|
181 | 'from_fieldname' => 'poster_ip', |
---|
182 | 'join_tablename' => 'topics', |
---|
183 | 'join_type' => 'LEFT', |
---|
184 | 'join_expression' => 'ON topics.id_first_msg = messages.id_msg', |
---|
185 | 'to_type' => 'topic', |
---|
186 | 'to_fieldname' => '_bbp_author_ip' |
---|
187 | ); |
---|
188 | |
---|
189 | // Topic content. |
---|
190 | // Note: We join the 'messages' table because 'topics' table does not have content. |
---|
191 | $this->field_map[] = array( |
---|
192 | 'from_tablename' => 'messages', |
---|
193 | 'from_fieldname' => 'body', |
---|
194 | 'join_tablename' => 'topics', |
---|
195 | 'join_type' => 'LEFT', |
---|
196 | 'join_expression' => 'ON topics.id_first_msg = messages.id_msg', |
---|
197 | 'to_type' => 'topic', |
---|
198 | 'to_fieldname' => 'post_content', |
---|
199 | 'callback_method' => 'callback_html' |
---|
200 | ); |
---|
201 | |
---|
202 | // Topic title. |
---|
203 | $this->field_map[] = array( |
---|
204 | 'from_tablename' => 'messages', |
---|
205 | 'from_fieldname' => 'subject', |
---|
206 | 'join_tablename' => 'topics', |
---|
207 | 'join_type' => 'LEFT', |
---|
208 | 'join_expression' => 'ON topics.id_first_msg = messages.id_msg', |
---|
209 | 'to_type' => 'topic', |
---|
210 | 'to_fieldname' => 'post_title' |
---|
211 | ); |
---|
212 | |
---|
213 | // Topic slug (Clean name to avoid conflicts) |
---|
214 | $this->field_map[] = array( |
---|
215 | 'from_tablename' => 'messages', |
---|
216 | 'from_fieldname' => 'subject', |
---|
217 | 'join_tablename' => 'topics', |
---|
218 | 'join_type' => 'LEFT', |
---|
219 | 'join_expression' => 'ON topics.id_first_msg = messages.id_msg', |
---|
220 | 'to_type' => 'topic', |
---|
221 | 'to_fieldname' => 'post_name', |
---|
222 | 'callback_method' => 'callback_slug' |
---|
223 | ); |
---|
224 | |
---|
225 | // Topic parent forum id (If no parent, then 0) |
---|
226 | $this->field_map[] = array( |
---|
227 | 'from_tablename' => 'topics', |
---|
228 | 'from_fieldname' => 'id_board', |
---|
229 | 'to_type' => 'topic', |
---|
230 | 'to_fieldname' => 'post_parent', |
---|
231 | 'callback_method' => 'callback_forumid' |
---|
232 | ); |
---|
233 | |
---|
234 | // Topic dates. |
---|
235 | $this->field_map[] = array( |
---|
236 | 'from_tablename' => 'messages', |
---|
237 | 'from_fieldname' => 'poster_time', |
---|
238 | 'join_tablename' => 'topics', |
---|
239 | 'join_type' => 'LEFT', |
---|
240 | 'join_expression' => 'ON topics.id_first_msg = messages.id_msg', |
---|
241 | 'to_type' => 'topic', |
---|
242 | 'to_fieldname' => 'post_date', |
---|
243 | 'callback_method' => 'callback_datetime' |
---|
244 | ); |
---|
245 | $this->field_map[] = array( |
---|
246 | 'from_tablename' => 'messages', |
---|
247 | 'from_fieldname' => 'poster_time', |
---|
248 | 'join_tablename' => 'topics', |
---|
249 | 'join_type' => 'LEFT', |
---|
250 | 'join_expression' => 'ON topics.id_first_msg = messages.id_msg', |
---|
251 | 'to_type' => 'topic', |
---|
252 | 'to_fieldname' => 'post_date_gmt', |
---|
253 | 'callback_method' => 'callback_datetime' |
---|
254 | ); |
---|
255 | $this->field_map[] = array( |
---|
256 | 'from_tablename' => 'messages', |
---|
257 | 'from_fieldname' => 'poster_time', |
---|
258 | 'join_tablename' => 'topics', |
---|
259 | 'join_type' => 'LEFT', |
---|
260 | 'join_expression' => 'ON topics.id_first_msg = messages.id_msg', |
---|
261 | 'to_type' => 'topic', |
---|
262 | 'to_fieldname' => 'post_modified', |
---|
263 | 'callback_method' => 'callback_datetime' |
---|
264 | ); |
---|
265 | $this->field_map[] = array( |
---|
266 | 'from_tablename' => 'messages', |
---|
267 | 'from_fieldname' => 'poster_time', |
---|
268 | 'join_tablename' => 'topics', |
---|
269 | 'join_type' => 'LEFT', |
---|
270 | 'join_expression' => 'ON topics.id_first_msg = messages.id_msg', |
---|
271 | 'to_type' => 'topic', |
---|
272 | 'to_fieldname' => 'post_modified_gmt', |
---|
273 | 'callback_method' => 'callback_datetime' |
---|
274 | ); |
---|
275 | $this->field_map[] = array( |
---|
276 | 'from_tablename' => 'messages', |
---|
277 | 'from_fieldname' => 'poster_time', |
---|
278 | 'join_tablename' => 'topics', |
---|
279 | 'join_type' => 'LEFT', |
---|
280 | 'join_expression' => 'ON topics.id_first_msg = messages.id_msg', |
---|
281 | 'to_type' => 'topic', |
---|
282 | 'to_fieldname' => '_bbp_last_active_time', |
---|
283 | 'callback_method' => 'callback_datetime' |
---|
284 | ); |
---|
285 | |
---|
286 | // Topic status (Open or Closed, SMF v2.0.4 0=open & 1=closed) |
---|
287 | $this->field_map[] = array( |
---|
288 | 'from_tablename' => 'topics', |
---|
289 | 'from_fieldname' => 'locked', |
---|
290 | 'to_type' => 'topic', |
---|
291 | 'to_fieldname' => 'post_status', |
---|
292 | 'callback_method' => 'callback_topic_status' |
---|
293 | ); |
---|
294 | |
---|
295 | /** Tags Section ******************************************************/ |
---|
296 | |
---|
297 | /** |
---|
298 | * SMF v2.0.4 Forums do not support topic tags out of the box |
---|
299 | */ |
---|
300 | |
---|
301 | /** Reply Section ******************************************************/ |
---|
302 | |
---|
303 | // Reply id (Stored in postmeta) |
---|
304 | $this->field_map[] = array( |
---|
305 | 'from_tablename' => 'messages', |
---|
306 | 'from_fieldname' => 'id_msg', |
---|
307 | 'to_type' => 'reply', |
---|
308 | 'to_fieldname' => '_bbp_post_id' |
---|
309 | ); |
---|
310 | |
---|
311 | // Reply parent forum id (If no parent, then 0. Stored in postmeta) |
---|
312 | $this->field_map[] = array( |
---|
313 | 'from_tablename' => 'topics', |
---|
314 | 'from_fieldname' => 'id_board', |
---|
315 | 'join_tablename' => 'messages', |
---|
316 | 'join_type' => 'LEFT', |
---|
317 | 'join_expression' => 'USING (id_topic) WHERE topics.id_first_msg != messages.id_msg', |
---|
318 | 'to_type' => 'reply', |
---|
319 | 'to_fieldname' => '_bbp_forum_id', |
---|
320 | 'callback_method' => 'callback_topicid_to_forumid' |
---|
321 | ); |
---|
322 | |
---|
323 | // Reply parent topic id (If no parent, then 0. Stored in postmeta) |
---|
324 | $this->field_map[] = array( |
---|
325 | 'from_tablename' => 'messages', |
---|
326 | 'from_fieldname' => 'id_topic', |
---|
327 | 'to_type' => 'reply', |
---|
328 | 'to_fieldname' => '_bbp_topic_id', |
---|
329 | 'callback_method' => 'callback_topicid' |
---|
330 | ); |
---|
331 | |
---|
332 | // Reply author ip (Stored in postmeta) |
---|
333 | $this->field_map[] = array( |
---|
334 | 'from_tablename' => 'messages', |
---|
335 | 'from_fieldname' => 'poster_ip', |
---|
336 | 'to_type' => 'reply', |
---|
337 | 'to_fieldname' => '_bbp_author_ip' |
---|
338 | ); |
---|
339 | |
---|
340 | // Reply author. |
---|
341 | $this->field_map[] = array( |
---|
342 | 'from_tablename' => 'messages', |
---|
343 | 'from_fieldname' => 'id_member', |
---|
344 | 'to_type' => 'reply', |
---|
345 | 'to_fieldname' => 'post_author', |
---|
346 | 'callback_method' => 'callback_userid' |
---|
347 | ); |
---|
348 | |
---|
349 | // Reply title. |
---|
350 | $this->field_map[] = array( |
---|
351 | 'from_tablename' => 'messages', |
---|
352 | 'from_fieldname' => 'subject', |
---|
353 | 'to_type' => 'reply', |
---|
354 | 'to_fieldname' => 'post_title', |
---|
355 | 'callback_method' => 'callback_reply_title' |
---|
356 | ); |
---|
357 | |
---|
358 | // Reply slug (Clean name to avoid conflicts) |
---|
359 | $this->field_map[] = array( |
---|
360 | 'from_tablename' => 'messages', |
---|
361 | 'from_fieldname' => 'subject', |
---|
362 | 'to_type' => 'reply', |
---|
363 | 'to_fieldname' => 'post_name', |
---|
364 | 'callback_method' => 'callback_slug' |
---|
365 | ); |
---|
366 | |
---|
367 | // Reply content. |
---|
368 | $this->field_map[] = array( |
---|
369 | 'from_tablename' => 'messages', |
---|
370 | 'from_fieldname' => 'body', |
---|
371 | 'to_type' => 'reply', |
---|
372 | 'to_fieldname' => 'post_content', |
---|
373 | 'callback_method' => 'callback_html' |
---|
374 | ); |
---|
375 | |
---|
376 | // Reply parent topic id (If no parent, then 0) |
---|
377 | $this->field_map[] = array( |
---|
378 | 'from_tablename' => 'messages', |
---|
379 | 'from_fieldname' => 'id_topic', |
---|
380 | 'to_type' => 'reply', |
---|
381 | 'to_fieldname' => 'post_parent', |
---|
382 | 'callback_method' => 'callback_topicid' |
---|
383 | ); |
---|
384 | |
---|
385 | // Reply dates. |
---|
386 | $this->field_map[] = array( |
---|
387 | 'from_tablename' => 'messages', |
---|
388 | 'from_fieldname' => 'poster_time', |
---|
389 | 'to_type' => 'reply', |
---|
390 | 'to_fieldname' => 'post_date', |
---|
391 | 'callback_method' => 'callback_datetime' |
---|
392 | ); |
---|
393 | $this->field_map[] = array( |
---|
394 | 'from_tablename' => 'messages', |
---|
395 | 'from_fieldname' => 'poster_time', |
---|
396 | 'to_type' => 'reply', |
---|
397 | 'to_fieldname' => 'post_date_gmt', |
---|
398 | 'callback_method' => 'callback_datetime' |
---|
399 | ); |
---|
400 | $this->field_map[] = array( |
---|
401 | 'from_tablename' => 'messages', |
---|
402 | 'from_fieldname' => 'poster_time', |
---|
403 | 'to_type' => 'reply', |
---|
404 | 'to_fieldname' => 'post_modified', |
---|
405 | 'callback_method' => 'callback_datetime' |
---|
406 | ); |
---|
407 | $this->field_map[] = array( |
---|
408 | 'from_tablename' => 'messages', |
---|
409 | 'from_fieldname' => 'poster_time', |
---|
410 | 'to_type' => 'reply', |
---|
411 | 'to_fieldname' => 'post_modified_gmt', |
---|
412 | 'callback_method' => 'callback_datetime' |
---|
413 | ); |
---|
414 | |
---|
415 | /** User Section ******************************************************/ |
---|
416 | |
---|
417 | // Store old User id (Stored in usermeta) |
---|
418 | $this->field_map[] = array( |
---|
419 | 'from_tablename' => 'members', |
---|
420 | 'from_fieldname' => 'id_member', |
---|
421 | 'to_type' => 'user', |
---|
422 | 'to_fieldname' => '_bbp_user_id' |
---|
423 | ); |
---|
424 | |
---|
425 | // Store old User password (Stored in usermeta serialized with salt) |
---|
426 | $this->field_map[] = array( |
---|
427 | 'from_tablename' => 'members', |
---|
428 | 'from_fieldname' => 'passwd', |
---|
429 | 'to_type' => 'user', |
---|
430 | 'to_fieldname' => '_bbp_password', |
---|
431 | 'callback_method' => 'callback_savepass' |
---|
432 | ); |
---|
433 | |
---|
434 | // User password verify class (Stored in usermeta for verifying password) |
---|
435 | $this->field_map[] = array( |
---|
436 | 'to_type' => 'user', |
---|
437 | 'to_fieldname' => '_bbp_class', |
---|
438 | 'default' => 'SMF' |
---|
439 | ); |
---|
440 | |
---|
441 | // User name. |
---|
442 | $this->field_map[] = array( |
---|
443 | 'from_tablename' => 'members', |
---|
444 | 'from_fieldname' => 'member_name', |
---|
445 | 'to_type' => 'user', |
---|
446 | 'to_fieldname' => 'user_login' |
---|
447 | ); |
---|
448 | |
---|
449 | // User nice name. |
---|
450 | $this->field_map[] = array( |
---|
451 | 'from_tablename' => 'members', |
---|
452 | 'from_fieldname' => 'member_name', |
---|
453 | 'to_type' => 'user', |
---|
454 | 'to_fieldname' => 'user_nicename' |
---|
455 | ); |
---|
456 | |
---|
457 | // User email. |
---|
458 | $this->field_map[] = array( |
---|
459 | 'from_tablename' => 'members', |
---|
460 | 'from_fieldname' => 'email_address', |
---|
461 | 'to_type' => 'user', |
---|
462 | 'to_fieldname' => 'user_email' |
---|
463 | ); |
---|
464 | |
---|
465 | // User homepage. |
---|
466 | $this->field_map[] = array( |
---|
467 | 'from_tablename' => 'members', |
---|
468 | 'from_fieldname' => 'website_url', |
---|
469 | 'to_type' => 'user', |
---|
470 | 'to_fieldname' => 'user_url' |
---|
471 | ); |
---|
472 | |
---|
473 | // User registered. |
---|
474 | $this->field_map[] = array( |
---|
475 | 'from_tablename' => 'members', |
---|
476 | 'from_fieldname' => 'date_registered', |
---|
477 | 'to_type' => 'user', |
---|
478 | 'to_fieldname' => 'user_registered', |
---|
479 | 'callback_method' => 'callback_datetime' |
---|
480 | ); |
---|
481 | |
---|
482 | // User display name. |
---|
483 | $this->field_map[] = array( |
---|
484 | 'from_tablename' => 'members', |
---|
485 | 'from_fieldname' => 'real_name', |
---|
486 | 'to_type' => 'user', |
---|
487 | 'to_fieldname' => 'display_name' |
---|
488 | ); |
---|
489 | |
---|
490 | // User AIM (Stored in usermeta) |
---|
491 | $this->field_map[] = array( |
---|
492 | 'from_tablename' => 'members', |
---|
493 | 'from_fieldname' => 'aim', |
---|
494 | 'to_type' => 'user', |
---|
495 | 'to_fieldname' => 'aim' |
---|
496 | ); |
---|
497 | |
---|
498 | // User Yahoo (Stored in usermeta) |
---|
499 | $this->field_map[] = array( |
---|
500 | 'from_tablename' => 'members', |
---|
501 | 'from_fieldname' => 'yim', |
---|
502 | 'to_type' => 'user', |
---|
503 | 'to_fieldname' => 'yim' |
---|
504 | ); |
---|
505 | |
---|
506 | // Store ICQ (Stored in usermeta) |
---|
507 | $this->field_map[] = array( |
---|
508 | 'from_tablename' => 'members', |
---|
509 | 'from_fieldname' => 'icq', |
---|
510 | 'to_type' => 'user', |
---|
511 | 'to_fieldname' => '_bbp_smf_user_icq' |
---|
512 | ); |
---|
513 | |
---|
514 | // Store MSN (Stored in usermeta) |
---|
515 | $this->field_map[] = array( |
---|
516 | 'from_tablename' => 'members', |
---|
517 | 'from_fieldname' => 'msn', |
---|
518 | 'to_type' => 'user', |
---|
519 | 'to_fieldname' => '_bbp_smf_user_msn' |
---|
520 | ); |
---|
521 | |
---|
522 | // Store Signature (Stored in usermeta) |
---|
523 | $this->field_map[] = array( |
---|
524 | 'from_tablename' => 'members', |
---|
525 | 'from_fieldname' => 'signature', |
---|
526 | 'to_type' => 'user', |
---|
527 | 'to_fieldname' => '_bbp_smf_user_sig', |
---|
528 | 'callback_method' => 'callback_html' |
---|
529 | ); |
---|
530 | |
---|
531 | // Store Avatar (Stored in usermeta) |
---|
532 | $this->field_map[] = array( |
---|
533 | 'from_tablename' => 'members', |
---|
534 | 'from_fieldname' => 'avatar', |
---|
535 | 'to_type' => 'user', |
---|
536 | 'to_fieldname' => '_bbp_smf_user_avatar', |
---|
537 | 'callback_method' => 'callback_html' |
---|
538 | ); |
---|
539 | |
---|
540 | // Store Location (Stored in usermeta) |
---|
541 | $this->field_map[] = array( |
---|
542 | 'from_tablename' => 'members', |
---|
543 | 'from_fieldname' => 'location', |
---|
544 | 'to_type' => 'user', |
---|
545 | 'to_fieldname' => '_bbp_smf_user_location', |
---|
546 | 'callback_method' => 'callback_html' |
---|
547 | ); |
---|
548 | |
---|
549 | // Store Personal Text (Stored in usermeta) |
---|
550 | $this->field_map[] = array( |
---|
551 | 'from_tablename' => 'members', |
---|
552 | 'from_fieldname' => 'personal_text', |
---|
553 | 'to_type' => 'user', |
---|
554 | 'to_fieldname' => '_bbp_smf_user_personal_text', |
---|
555 | 'callback_method' => 'callback_html' |
---|
556 | ); |
---|
557 | } |
---|
558 | |
---|
559 | /** |
---|
560 | * This method allows us to indicates what is or is not converted for each |
---|
561 | * converter. |
---|
562 | */ |
---|
563 | public function info() |
---|
564 | { |
---|
565 | return ''; |
---|
566 | } |
---|
567 | |
---|
568 | /** |
---|
569 | * This method is to save the salt and password together. That |
---|
570 | * way when we authenticate it we can get it out of the database |
---|
571 | * as one value. Array values are auto sanitized by WordPress. |
---|
572 | */ |
---|
573 | public function callback_savepass( $field, $row ) |
---|
574 | { |
---|
575 | $pass_array = array( 'hash' => $field, 'username' => $row['member_name'] ); |
---|
576 | return $pass_array; |
---|
577 | } |
---|
578 | |
---|
579 | /** |
---|
580 | * This method is to take the pass out of the database and compare |
---|
581 | * to a pass the user has typed in. |
---|
582 | */ |
---|
583 | public function authenticate_pass( $password, $serialized_pass ) |
---|
584 | { |
---|
585 | $pass_array = unserialize( $serialized_pass ); |
---|
586 | return ( $pass_array['hash'] === sha1( strtolower( $pass_array['username'] ) . $password ) ? true : false ); |
---|
587 | } |
---|
588 | |
---|
589 | /** |
---|
590 | * Translate the post status from SMF v2.0.4 numeric's to WordPress's strings. |
---|
591 | * |
---|
592 | * @param int $status SMF v2.0.4 numeric topic status |
---|
593 | * @return string WordPress safe |
---|
594 | */ |
---|
595 | public function callback_topic_status( $status = 0 ) { |
---|
596 | switch ( $status ) { |
---|
597 | case 1 : |
---|
598 | $status = 'closed'; |
---|
599 | break; |
---|
600 | |
---|
601 | case 0 : |
---|
602 | default : |
---|
603 | $status = 'publish'; |
---|
604 | break; |
---|
605 | } |
---|
606 | return $status; |
---|
607 | } |
---|
608 | |
---|
609 | /** |
---|
610 | * Verify the topic/reply count. |
---|
611 | * |
---|
612 | * @param int $count SMF v2.0.4 topic/reply counts |
---|
613 | * @return string WordPress safe |
---|
614 | */ |
---|
615 | public function callback_topic_reply_count( $count = 1 ) { |
---|
616 | $count = absint( (int) $count - 1 ); |
---|
617 | return $count; |
---|
618 | } |
---|
619 | |
---|
620 | /** |
---|
621 | * Set the reply title |
---|
622 | * |
---|
623 | * @param string $title SMF v2.0.4 topic title of this reply |
---|
624 | * @return string Prefixed topic title, or empty string |
---|
625 | */ |
---|
626 | public function callback_reply_title( $title = '' ) { |
---|
627 | $title = !empty( $title ) ? __( 'Re: ', 'bbpress' ) . html_entity_decode( $title ) : ''; |
---|
628 | return $title; |
---|
629 | } |
---|
630 | |
---|
631 | /** |
---|
632 | * This callback processes any custom parser.php attributes and custom code with preg_replace |
---|
633 | */ |
---|
634 | protected function callback_html( $field ) { |
---|
635 | |
---|
636 | // Strips SMF custom HTML first from $field before parsing $field to parser.php |
---|
637 | $SMF_markup = $field; |
---|
638 | $SMF_markup = html_entity_decode( $SMF_markup ); |
---|
639 | |
---|
640 | // Replace '[quote]' with '<blockquote>' |
---|
641 | $SMF_markup = preg_replace( '/\[quote\]/', '<blockquote>', $SMF_markup ); |
---|
642 | // Replace '[quote ($1)]' with '<blockquote>" |
---|
643 | $SMF_markup = preg_replace( '/\[quote (.*?)\]/' , '<blockquote>', $SMF_markup ); |
---|
644 | // Replace '[/quote]' with '</blockquote>' |
---|
645 | $SMF_markup = preg_replace( '/\[\/quote\]/', '</blockquote>', $SMF_markup ); |
---|
646 | |
---|
647 | // Replace '[glow]' with '' |
---|
648 | $SMF_markup = preg_replace( '/\[glow\]/', '', $SMF_markup ); |
---|
649 | // Replace '[glow]' with '' |
---|
650 | $SMF_markup = preg_replace( '/\[glow=(.*?)\]/', '', $SMF_markup ); |
---|
651 | // Replace '[/glow]' with '' |
---|
652 | $SMF_markup = preg_replace( '/\[\/glow\]/', '', $SMF_markup ); |
---|
653 | |
---|
654 | // Replace '[shadow]' with '' |
---|
655 | $SMF_markup = preg_replace( '/\[shadow\]/', '', $SMF_markup ); |
---|
656 | // Replace '[shadow]' with '' |
---|
657 | $SMF_markup = preg_replace( '/\[shadow=(.*?)\]/', '', $SMF_markup ); |
---|
658 | // Replace '[/shadow]' with '' |
---|
659 | $SMF_markup = preg_replace( '/\[\/shadow\]/', '', $SMF_markup ); |
---|
660 | |
---|
661 | // Replace '[move]' with '' |
---|
662 | $SMF_markup = preg_replace( '/\[move\]/', '', $SMF_markup ); |
---|
663 | // Replace '[/move]' with '' |
---|
664 | $SMF_markup = preg_replace( '/\[\/move\]/', '', $SMF_markup ); |
---|
665 | |
---|
666 | // Replace '[table]' with '<table>' |
---|
667 | $SMF_markup = preg_replace( '/\[table\]/', '<table>', $SMF_markup ); |
---|
668 | // Replace '[/table]' with '</table>' |
---|
669 | $SMF_markup = preg_replace( '/\[\/table\]/', '</table>', $SMF_markup ); |
---|
670 | // Replace '[tr]' with '<tr>' |
---|
671 | $SMF_markup = preg_replace( '/\[tr\]/', '<tr>', $SMF_markup ); |
---|
672 | // Replace '[/tr]' with '</tr>' |
---|
673 | $SMF_markup = preg_replace( '/\[\/tr\]/', '</tr>', $SMF_markup ); |
---|
674 | // Replace '[td]' with '<td>' |
---|
675 | $SMF_markup = preg_replace( '/\[td\]/', '<td>', $SMF_markup ); |
---|
676 | // Replace '[/td]' with '</td>' |
---|
677 | $SMF_markup = preg_replace( '/\[\/td\]/', '</td>', $SMF_markup ); |
---|
678 | |
---|
679 | // Replace '[list]' with '<ul>' |
---|
680 | $phpbb_uid = preg_replace( '/\[list\]/', '<ul>', $phpbb_uid ); |
---|
681 | // Replace '[liist type=decimal]' with '<ol type="a">' |
---|
682 | $phpbb_uid = preg_replace( '/\[list\ type=decimal\]/', '<ol type="a">', $phpbb_uid ); |
---|
683 | // Replace '[li]' with '<li>' |
---|
684 | $SMF_markup = preg_replace( '/\[li\]/', '<li>', $SMF_markup ); |
---|
685 | // Replace '[/li]' with '</li>' |
---|
686 | $SMF_markup = preg_replace( '/\[\/li\]/', '</li>', $SMF_markup ); |
---|
687 | |
---|
688 | // Replace '[tt]' with '<tt>' |
---|
689 | $SMF_markup = preg_replace( '/\[tt\]/', '<tt>', $SMF_markup ); |
---|
690 | // Replace '[/tt]' with '</tt>' |
---|
691 | $SMF_markup = preg_replace( '/\[\/tt\]/', '</tt>', $SMF_markup ); |
---|
692 | |
---|
693 | // Replace '<br />' with '' |
---|
694 | $SMF_markup = preg_replace( '/\<br \/\>/', '<tt>', $SMF_markup ); |
---|
695 | |
---|
696 | // Replace '[size=$1]' with '<span style="font-size:$1%;">$3</span>' |
---|
697 | $SMF_markup = preg_replace( '/\[size=(.*?)\]/', '<span style="font-size:$1">', $SMF_markup ); |
---|
698 | // Replace '[/size]' with '</span>' |
---|
699 | $SMF_markup = preg_replace( '/\[\/size\]/', '</span>', $SMF_markup ); |
---|
700 | |
---|
701 | // Now that SMF custom HTML has been stripped put the cleaned HTML back in $field |
---|
702 | $field = $SMF_markup; |
---|
703 | |
---|
704 | // Parse out any bbCodes in $field with the BBCode 'parser.php' |
---|
705 | require_once( bbpress()->admin->admin_dir . 'parser.php' ); |
---|
706 | $bbcode = BBCode::getInstance(); |
---|
707 | $bbcode->enable_smileys = false; |
---|
708 | $bbcode->smiley_regex = false; |
---|
709 | return html_entity_decode( $bbcode->Parse( $field ) ); |
---|
710 | } |
---|
711 | } |
---|