Skip to:
Content

bbPress.org

source: trunk/src/includes/admin/converters/Example.php

Last change on this file was 7378, checked in by johnjamesjacoby, 2 weeks ago

Tools - Code Improvement: stop ignoring these PHPCS sniffs:

  • Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
  • Generic.CodeAnalysis.EmptyStatement.DetectedElseif
  • Generic.CodeAnalysis.EmptyStatement.DetectedIf
  • Generic.CodeAnalysis.UselessOverridingMethod.Found
  • Generic.ControlStructures.InlineControlStructure.NotAllowed
  • Generic.Files.LineEndings.InvalidEOLChar
  • Generic.Formatting.DisallowMultipleStatements.SameLine
  • Generic.Formatting.SpaceAfterCast.TooMuchSpace
  • Generic.Functions.OpeningFunctionBraceKernighanRitchie.ContentAfterBrace
  • Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed
  • NormalizedArrays.Arrays.ArrayBraceSpacing.SpaceAfterArrayOpenerMultiLine
  • NormalizedArrays.Arrays.ArrayBraceSpacing.SpaceAfterArrayOpenerSingleLine
  • NormalizedArrays.Arrays.ArrayBraceSpacing.SpaceBeforeArrayCloserMultiLine
  • NormalizedArrays.Arrays.CommaAfterLast.MissingMultiLineCloserSameLine
  • PEAR.Functions.FunctionCallSignature.CloseBracketLine
  • PEAR.Functions.FunctionCallSignature.EmptyLine
  • PEAR.Functions.FunctionCallSignature.Indent
  • PEAR.Functions.FunctionCallSignature.MultipleArguments
  • PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
  • PHPCompatibility.Syntax.RemovedCurlyBraceArrayAccess.Found
  • PSR2.Classes.ClassDeclaration.CloseBraceAfterBody
  • PSR2.Classes.PropertyDeclaration.ScopeMissing
  • PSR2.Classes.PropertyDeclaration.Underscore
  • PSR2.Classes.PropertyDeclaration.VarUsed
  • PSR2.ControlStructures.ElseIfDeclaration.NotAllowed
  • PSR2.ControlStructures.SwitchDeclaration.BreakIndent
  • PSR2.Methods.MethodDeclaration.Underscore
  • Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace
  • Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterOpen
  • Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingBeforeClose
  • Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterBrace
  • Squiz.PHP.DisallowSizeFunctionsInLoops.Found
  • Squiz.Scope.MethodScope.Missing
  • Squiz.WhiteSpace.SuperfluousWhitespace.EndLine
  • Universal.NamingConventions.NoReservedKeywordParameterNames.arrayFound
  • Universal.NamingConventions.NoReservedKeywordParameterNames.echoFound
  • Universal.NamingConventions.NoReservedKeywordParameterNames.parentFound
  • Universal.Operators.DisallowStandalonePostIncrementDecrement.PostDecrementFound
  • Universal.Operators.DisallowStandalonePostIncrementDecrement.PostIncrementFound
  • Universal.Operators.StrictComparisons.LooseEqual
  • Universal.Operators.StrictComparisons.LooseNotEqual
  • WordPress.Arrays.ArrayKeySpacingRestrictions.TooMuchSpaceAfterKey
  • WordPress.DateTime.CurrentTimeTimestamp.Requested
  • WordPress.DateTime.RestrictedFunctions.date_date
  • WordPress.Files.FileName.NotHyphenatedLowercase
  • WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound
  • WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound
  • WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
  • WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
  • WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
  • WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
  • WordPress.PHP.IniSet.Risky
  • WordPress.PHP.PregQuoteDelimiter.Missing
  • WordPress.PHP.StrictInArray.MissingTrueStrict
  • WordPress.WP.AlternativeFunctions.parse_url_parse_url
  • WordPress.WP.AlternativeFunctions.rand_mt_rand
  • WordPress.WP.AlternativeFunctions.strip_tags_strip_tag
  • WordPress.WP.AlternativeFunctions.strip_tags_strip_tags
  • WordPress.WP.Capabilities.Unknown
  • WordPress.WP.DeprecatedParameters.Get_termsParam2Found
  • WordPress.WP.DeprecatedParameters.Wp_count_termsParam2Found
  • WordPress.WP.DiscouragedFunctions.query_posts_query_posts
  • WordPress.WP.DiscouragedFunctions.wp_reset_query_wp_reset_query
  • WordPress.WP.EnqueuedResourceParameters.NotInFooter
  • WordPress.WP.GlobalVariablesOverride.Prohibited
  • WordPress.WP.I18n.LowLevelTranslationFunction

This commit includes code formatting changes for the above sniffs.

See #3658.

File size: 21.4 KB
Line 
1<?php
2
3/**
4 * bbPress Example Converter
5 *
6 * @package bbPress
7 * @subpackage Converters
8 */
9
10/**
11 * Example converter base impoprter template for bbPress
12 *
13 * @since 2.3.0 bbPress (r4689)
14 *
15 * @link Codex Docs https://codex.bbpress.org/import-forums/custom-import
16 */
17class Example extends BBP_Converter_Base {
18
19        /**
20         * Sets up the field mappings
21         */
22        public function setup_globals() {
23
24                /** Forum Section *****************************************************/
25
26                // Setup table joins for the forum section at the base of this section
27
28                // Old forum id (Stored in postmeta)
29                $this->field_map[] = array(
30                        'from_tablename'  => 'forums_table',
31                        'from_fieldname'  => 'the_forum_id',
32                        'to_type'         => 'forum',
33                        'to_fieldname'    => '_bbp_old_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_table',
39                        'from_fieldname'  => 'the_parent_id',
40                        'to_type'         => 'forum',
41                        'to_fieldname'    => '_bbp_old_forum_parent_id'
42                );
43
44                // Forum topic count (Stored in postmeta)
45                $this->field_map[] = array(
46                        'from_tablename' => 'forums_table',
47                        'from_fieldname' => 'the_topic_count',
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_table',
55                        'from_fieldname' => 'the_reply_count',
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' => 'forums_table',
63                        'from_fieldname' => 'the_total_topic_count',
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' => 'forums_table',
71                        'from_fieldname' => 'the_total_reply_count',
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_table',
79                        'from_fieldname'  => 'the_forum_title',
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_table',
87                        'from_fieldname'  => 'the_forum_slug',
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_table',
96                        'from_fieldname'  => 'the_forum_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_table',
105                        'from_fieldname'  => 'the_forum_order',
106                        'to_type'         => 'forum',
107                        'to_fieldname'    => 'menu_order'
108                );
109
110                // Forum type (Category = 0 or Forum = 1, Stored in postmeta)
111                $this->field_map[] = array(
112                        'from_tablename'  => 'forums_table',
113                        'from_fieldname'  => 'the_forum_type',
114                        'to_type'         => 'forum',
115                        'to_fieldname'    => '_bbp_forum_type',
116                        'callback_method' => 'callback_forum_type'
117                );
118
119                // Forum status (Unlocked = 0 or Locked = 1, Stored in postmeta)
120                $this->field_map[] = array(
121                        'from_tablename'  => 'forums_table',
122                        'from_fieldname'  => 'the_forum_status',
123                        'to_type'         => 'forum',
124                        'to_fieldname'    => '_bbp_status',
125                        'callback_method' => 'callback_forum_status'
126                );
127
128                // Forum dates.
129                $this->field_map[] = array(
130                        'to_type'      => 'forum',
131                        'to_fieldname' => 'post_date',
132                        'default'      => date( 'Y-m-d H:i:s' ) // phpcs:ignore
133                );
134                $this->field_map[] = array(
135                        'to_type'      => 'forum',
136                        'to_fieldname' => 'post_date_gmt',
137                        'default'      => gmdate( 'Y-m-d H:i:s' )
138                );
139                $this->field_map[] = array(
140                        'to_type'      => 'forum',
141                        'to_fieldname' => 'post_modified',
142                        'default'      => date( 'Y-m-d H:i:s' ) // phpcs:ignore
143                );
144                $this->field_map[] = array(
145                        'to_type'      => 'forum',
146                        'to_fieldname' => 'post_modified_gmt',
147                        'default'      => gmdate( 'Y-m-d H:i:s' )
148                );
149
150                // Setup the table joins for the forum section
151                $this->field_map[] = array(
152                        'from_tablename'  => 'groups_table',
153                        'from_fieldname'  => 'forum_id',
154                        'join_tablename'  => 'forums_table',
155                        'join_type'       => 'INNER',
156                        'join_expression' => 'USING groups_table.forum_id = forums_table.forum_id',
157                        // 'from_expression' => 'WHERE forums_table.forum_id != 1',
158                        'to_type'         => 'forum'
159                );
160
161                /** Forum Subscriptions Section ***************************************/
162
163                // Subscribed forum ID (Stored in usermeta)
164                $this->field_map[] = array(
165                        'from_tablename'  => 'forum_subscriptions_table',
166                        'from_fieldname'  => 'the_forum_id',
167                        'to_type'         => 'forum_subscriptions',
168                        'to_fieldname'    => '_bbp_forum_subscriptions'
169                );
170
171                // Subscribed user ID (Stored in usermeta)
172                $this->field_map[] = array(
173                        'from_tablename'  => 'forum_subscriptions_table',
174                        'from_fieldname'  => 'the_user_id',
175                        'to_type'         => 'forum_subscriptions',
176                        'to_fieldname'    => 'user_id',
177                        'callback_method' => 'callback_userid'
178                );
179
180                /** Topic Section *****************************************************/
181
182                // Setup table joins for the topic section at the base of this section
183
184                // Old topic id (Stored in postmeta)
185                $this->field_map[] = array(
186                        'from_tablename'  => 'topics_table',
187                        'from_fieldname'  => 'the_topic_id',
188                        'to_type'         => 'topic',
189                        'to_fieldname'    => '_bbp_old_topic_id'
190                );
191
192                // Topic reply count (Stored in postmeta)
193                $this->field_map[] = array(
194                        'from_tablename'  => 'topics_table',
195                        'from_fieldname'  => 'the_topic_reply_count',
196                        'to_type'         => 'topic',
197                        'to_fieldname'    => '_bbp_reply_count',
198                        'callback_method' => 'callback_topic_reply_count'
199                );
200
201                // Topic total reply count (Stored in postmeta)
202                $this->field_map[] = array(
203                        'from_tablename'  => 'topics_table',
204                        'from_fieldname'  => 'the_total_topic_reply_count',
205                        'to_type'         => 'topic',
206                        'to_fieldname'    => '_bbp_total_reply_count',
207                        'callback_method' => 'callback_topic_reply_count'
208                );
209
210                // Topic parent forum id (If no parent, then 0. Stored in postmeta)
211                $this->field_map[] = array(
212                        'from_tablename'  => 'topics_table',
213                        'from_fieldname'  => 'the_topic_parent_forum_id',
214                        'to_type'         => 'topic',
215                        'to_fieldname'    => '_bbp_forum_id',
216                        'callback_method' => 'callback_forumid'
217                );
218
219                // Topic author.
220                $this->field_map[] = array(
221                        'from_tablename'  => 'topics_table',
222                        'from_fieldname'  => 'the_topic_author_id',
223                        'to_type'         => 'topic',
224                        'to_fieldname'    => 'post_author',
225                        'callback_method' => 'callback_userid'
226                );
227
228                // Topic author ip (Stored in postmeta)
229                $this->field_map[] = array(
230                        'from_tablename'  => 'topics_table',
231                        'from_fieldname'  => 'the_topic_author_ip_address',
232                        'to_type'         => 'topic',
233                        'to_fieldname'    => '_bbp_author_ip'
234                );
235
236                // Topic content.
237                $this->field_map[] = array(
238                        'from_tablename'  => 'topics_table',
239                        'from_fieldname'  => 'the_topic_content',
240                        'to_type'         => 'topic',
241                        'to_fieldname'    => 'post_content',
242                        'callback_method' => 'callback_html'
243                );
244
245                // Topic title.
246                $this->field_map[] = array(
247                        'from_tablename'  => 'topics_table',
248                        'from_fieldname'  => 'the_topic_title',
249                        'to_type'         => 'topic',
250                        'to_fieldname'    => 'post_title'
251                );
252
253                // Topic slug (Clean name to avoid conflicts)
254                $this->field_map[] = array(
255                        'from_tablename'  => 'topics_table',
256                        'from_fieldname'  => 'the_topic_slug',
257                        'to_type'         => 'topic',
258                        'to_fieldname'    => 'post_name',
259                        'callback_method' => 'callback_slug'
260                );
261
262                // Topic status (Open or Closed)
263                $this->field_map[] = array(
264                        'from_tablename'  => 'topics_table',
265                        'from_fieldname'  => 'the_topic_status',
266                        'to_type'         => 'topic',
267                        'to_fieldname'    => '_bbp_old_closed_status_id',
268                        'callback_method' => 'callback_topic_status'
269                );
270
271                // Topic parent forum id (If no parent, then 0)
272                $this->field_map[] = array(
273                        'from_tablename'  => 'topics_table',
274                        'from_fieldname'  => 'the_topic_parent_forum_id',
275                        'to_type'         => 'topic',
276                        'to_fieldname'    => 'post_parent',
277                        'callback_method' => 'callback_forumid'
278                );
279
280                // Sticky status (Stored in postmeta)
281                $this->field_map[] = array(
282                        'from_tablename'  => 'topics_table',
283                        'from_fieldname'  => 'the_topic_sticky_status',
284                        'to_type'         => 'topic',
285                        'to_fieldname'    => '_bbp_old_sticky_status_id',
286                        'callback_method' => 'callback_sticky_status'
287                );
288
289                // Topic dates.
290                $this->field_map[] = array(
291                        'from_tablename'  => 'topics_table',
292                        'from_fieldname'  => 'the_topic_creation_date',
293                        'to_type'         => 'topic',
294                        'to_fieldname'    => 'post_date',
295                        'callback_method' => 'callback_datetime'
296                );
297                $this->field_map[] = array(
298                        'from_tablename'  => 'topics_table',
299                        'from_fieldname'  => 'the_topic_creation_date',
300                        'to_type'         => 'topic',
301                        'to_fieldname'    => 'post_date_gmt',
302                        'callback_method' => 'callback_datetime'
303                );
304                $this->field_map[] = array(
305                        'from_tablename'  => 'topics_table',
306                        'from_fieldname'  => 'the_topic_modified_date',
307                        'to_type'         => 'topic',
308                        'to_fieldname'    => 'post_modified',
309                        'callback_method' => 'callback_datetime'
310                );
311                $this->field_map[] = array(
312                        'from_tablename'  => 'topics_table',
313                        'from_fieldname'  => 'the_topic_modified_date',
314                        'to_type'         => 'topic',
315                        'to_fieldname'    => 'post_modified_gmt',
316                        'callback_method' => 'callback_datetime'
317                );
318                $this->field_map[] = array(
319                        'from_tablename'  => 'topics_table',
320                        'from_fieldname'  => 'the_topic_modified_date',
321                        'to_type'         => 'topic',
322                        'to_fieldname'    => '_bbp_last_active_time',
323                        'callback_method' => 'callback_datetime'
324                );
325
326                // Setup any table joins needed for the topic section
327                $this->field_map[] = array(
328                        'from_tablename'  => 'replies_table',
329                        'from_fieldname'  => 'the_topic_id',
330                        'join_tablename'  => 'topics_table',
331                        'join_type'       => 'INNER',
332                        'join_expression' => 'USING replies_table.the_topic_id = topics_table.the_topic_id',
333                        'from_expression' => 'WHERE forums_table.the_topic_id = 0',
334                        'to_type'         => 'topic'
335                );
336
337                /** Tags Section ******************************************************/
338
339                // Setup table joins for the tag section at the base of this section
340                // Setup any table joins needed for the tags section
341                $this->field_map[] = array(
342                        'from_tablename'  => 'tag_table',
343                        'from_fieldname'  => 'the_topic_id',
344                        'join_tablename'  => 'tagcontent_table',
345                        'join_type'       => 'INNER',
346                        'join_expression' => 'USING tagcontent_table.tag_id = tags_table.tag_id',
347                        'from_expression' => 'WHERE tagcontent_table.tag_id = tag_table.tag_id',
348                        'to_type'         => 'tags'
349                );
350
351                // Topic id.
352                $this->field_map[] = array(
353                        'from_tablename'  => 'tagcontent_table',
354                        'from_fieldname'  => 'contentid',
355                        'to_type'         => 'tags',
356                        'to_fieldname'    => 'objectid',
357                        'callback_method' => 'callback_topicid'
358                );
359
360                // Taxonomy ID.
361                $this->field_map[] = array(
362                        'from_tablename'  => 'tagcontent_table',
363                        'from_fieldname'  => 'tagid',
364                        'to_type'         => 'tags',
365                        'to_fieldname'    => 'taxonomy'
366                );
367
368                // Term text.
369                $this->field_map[] = array(
370                        'from_tablename'  => 'tag_table',
371                        'from_fieldname'  => 'tagtext',
372                        'to_type'         => 'tags',
373                        'to_fieldname'    => 'name'
374                );
375
376                // Term slug.
377                $this->field_map[] = array(
378                        'from_tablename'  => 'tag_table',
379                        'from_fieldname'  => 'tagslug',
380                        'to_type'         => 'tags',
381                        'to_fieldname'    => 'slug',
382                        'callback_method' => 'callback_slug'
383                );
384
385                // Term description.
386                $this->field_map[] = array(
387                        'from_tablename'  => 'tag_table',
388                        'from_fieldname'  => 'tagdescription',
389                        'to_type'         => 'tags',
390                        'to_fieldname'    => 'description'
391                );
392
393                /** Topic Subscriptions Section ***************************************/
394
395                // Subscribed topic ID (Stored in usermeta)
396                $this->field_map[] = array(
397                        'from_tablename'  => 'topic_subscriptions_table',
398                        'from_fieldname'  => 'the_topic_id',
399                        'to_type'         => 'topic_subscriptions',
400                        'to_fieldname'    => '_bbp_subscriptions'
401                );
402
403                // Subscribed user ID (Stored in usermeta)
404                $this->field_map[] = array(
405                        'from_tablename'  => 'topic_subscriptions_table',
406                        'from_fieldname'  => 'the_user_id',
407                        'to_type'         => 'topic_subscriptions',
408                        'to_fieldname'    => 'user_id',
409                        'callback_method' => 'callback_userid'
410                );
411
412                /** Favorites Section *************************************************/
413
414                // Favorited topic ID (Stored in usermeta)
415                $this->field_map[] = array(
416                        'from_tablename'  => 'favorites_table',
417                        'from_fieldname'  => 'the_favorite_topic_id',
418                        'to_type'         => 'favorites',
419                        'to_fieldname'    => '_bbp_favorites'
420                );
421
422                // Favorited user ID (Stored in usermeta)
423                $this->field_map[] = array(
424                        'from_tablename'  => 'favorites_table',
425                        'from_fieldname'  => 'the_user_id',
426                        'to_type'         => 'favorites',
427                        'to_fieldname'    => 'user_id',
428                        'callback_method' => 'callback_userid'
429                );
430
431                /** Reply Section *****************************************************/
432
433                // Setup table joins for the reply section at the base of this section
434
435                // Old reply id (Stored in postmeta)
436                $this->field_map[] = array(
437                        'from_tablename'  => 'replies_table',
438                        'from_fieldname'  => 'the_reply_id',
439                        'to_type'         => 'reply',
440                        'to_fieldname'    => '_bbp_old_reply_id'
441                );
442
443                // Reply parent forum id (If no parent, then 0. Stored in postmeta)
444                $this->field_map[] = array(
445                        'from_tablename'  => 'replies_table',
446                        'from_fieldname'  => 'the_reply_parent_forum_id',
447                        'to_type'         => 'reply',
448                        'to_fieldname'    => '_bbp_forum_id',
449                        'callback_method' => 'callback_forumid'
450                );
451
452                // Reply parent topic id (If no parent, then 0. Stored in postmeta)
453                $this->field_map[] = array(
454                        'from_tablename'  => 'replies_table',
455                        'from_fieldname'  => 'the_reply_parent_topic_id',
456                        'to_type'         => 'reply',
457                        'to_fieldname'    => '_bbp_topic_id',
458                        'callback_method' => 'callback_topicid'
459                );
460
461                // Reply author ip (Stored in postmeta)
462                $this->field_map[] = array(
463                        'from_tablename'  => 'replies_table',
464                        'from_fieldname'  => 'the_reply_author_ip_address',
465                        'to_type'         => 'reply',
466                        'to_fieldname'    => '_bbp_author_ip'
467                );
468
469                // Reply author.
470                $this->field_map[] = array(
471                        'from_tablename'  => 'replies_table',
472                        'from_fieldname'  => 'the_reply_author_id',
473                        'to_type'         => 'reply',
474                        'to_fieldname'    => 'post_author',
475                        'callback_method' => 'callback_userid'
476                );
477
478                // Reply title and reply slugs
479                // Note: We don't actually want either a reply title or a reply slug as
480                //       we want single replies to use their ID as the permalink.
481
482                // Reply content.
483                $this->field_map[] = array(
484                        'from_tablename'  => 'replies_table',
485                        'from_fieldname'  => 'the_reply_content',
486                        'to_type'         => 'reply',
487                        'to_fieldname'    => 'post_content',
488                        'callback_method' => 'callback_html'
489                );
490
491                // Reply order.
492                $this->field_map[] = array(
493                        'from_tablename'  => 'replies_table',
494                        'from_fieldname'  => 'the_reply_order',
495                        'to_type'         => 'reply',
496                        'to_fieldname'    => 'menu_order'
497                );
498
499                // Reply parent topic id (If no parent, then 0)
500                $this->field_map[] = array(
501                        'from_tablename'  => 'replies_table',
502                        'from_fieldname'  => 'the_reply_parent_topic_id',
503                        'to_type'         => 'reply',
504                        'to_fieldname'    => 'post_parent',
505                        'callback_method' => 'callback_topicid'
506                );
507
508                // Reply dates.
509                $this->field_map[] = array(
510                        'from_tablename'  => 'replies_table',
511                        'from_fieldname'  => 'the_reply_creation_date',
512                        'to_type'         => 'reply',
513                        'to_fieldname'    => 'post_date',
514                        'callback_method' => 'callback_datetime'
515                );
516                $this->field_map[] = array(
517                        'from_tablename'  => 'replies_table',
518                        'from_fieldname'  => 'the_reply_creation_date',
519                        'to_type'         => 'reply',
520                        'to_fieldname'    => 'post_date_gmt',
521                        'callback_method' => 'callback_datetime'
522                );
523                $this->field_map[] = array(
524                        'from_tablename'  => 'replies_table',
525                        'from_fieldname'  => 'the_reply_modified_date',
526                        'to_type'         => 'reply',
527                        'to_fieldname'    => 'post_modified',
528                        'callback_method' => 'callback_datetime'
529                );
530                $this->field_map[] = array(
531                        'from_tablename'  => 'replies_table',
532                        'from_fieldname'  => 'the_reply_modified_date',
533                        'to_type'         => 'reply',
534                        'to_fieldname'    => 'post_modified_gmt',
535                        'callback_method' => 'callback_datetime'
536                );
537
538                // Setup any table joins needed for the reply section
539                $this->field_map[] = array(
540                        'from_tablename'  => 'topics_table',
541                        'from_fieldname'  => 'the_topic_id',
542                        'join_tablename'  => 'replies_table',
543                        'join_type'       => 'INNER',
544                        'join_expression' => 'USING topics_table.the_topic_id = replies_table.the_topic_id',
545                        'from_expression' => 'WHERE topics_table.first_post != 0',
546                        'to_type'         => 'reply'
547                );
548
549                /** User Section ******************************************************/
550
551                // Setup table joins for the user section at the base of this section
552
553                // Store old user id (Stored in usermeta)
554                $this->field_map[] = array(
555                        'from_tablename'  => 'users_table',
556                        'from_fieldname'  => 'the_users_id',
557                        'to_type'         => 'user',
558                        'to_fieldname'    => '_bbp_old_user_id'
559                );
560
561                // Store old user password (Stored in usermeta serialized with salt)
562                $this->field_map[] = array(
563                        'from_tablename'  => 'users_table',
564                        'from_fieldname'  => 'the_users_password',
565                        'to_type'         => 'user',
566                        'to_fieldname'    => '_bbp_password',
567                        'callback_method' => 'callback_savepass'
568                );
569
570                // Store old user salt (This is only used for the SELECT row info for the above password save)
571                $this->field_map[] = array(
572                        'from_tablename'  => 'users_table',
573                        'from_fieldname'  => 'the_users_password_salt',
574                        'to_type'         => 'user',
575                        'to_fieldname'    => ''
576                );
577
578                // User password verify class (Stored in usermeta for verifying password)
579                $this->field_map[] = array(
580                        'to_type'         => 'user',
581                        'to_fieldname'    => '_bbp_class',
582                        'default' => 'Example'
583                );
584
585                // User name.
586                $this->field_map[] = array(
587                        'from_tablename'  => 'users_table',
588                        'from_fieldname'  => 'the_users_username',
589                        'to_type'         => 'user',
590                        'to_fieldname'    => 'user_login'
591                );
592
593                // User nice name.
594                $this->field_map[] = array(
595                        'from_tablename' => 'users_table',
596                        'from_fieldname' => 'the_users_nicename',
597                        'to_type'        => 'user',
598                        'to_fieldname'   => 'user_nicename'
599                );
600
601                // User email.
602                $this->field_map[] = array(
603                        'from_tablename'  => 'users_table',
604                        'from_fieldname'  => 'the_users_email_address',
605                        'to_type'         => 'user',
606                        'to_fieldname'    => 'user_email'
607                );
608
609                // User homepage.
610                $this->field_map[] = array(
611                        'from_tablename'  => 'users_table',
612                        'from_fieldname'  => 'the_users_homepage_url',
613                        'to_type'         => 'user',
614                        'to_fieldname'    => 'user_url'
615                );
616
617                // User registered.
618                $this->field_map[] = array(
619                        'from_tablename'  => 'users_table',
620                        'from_fieldname'  => 'the_users_registration_date',
621                        'to_type'         => 'user',
622                        'to_fieldname'    => 'user_registered',
623                        'callback_method' => 'callback_datetime'
624                );
625
626                // User status.
627                $this->field_map[] = array(
628                        'from_tablename' => 'users_table',
629                        'from_fieldname' => 'the_users_status',
630                        'to_type'        => 'user',
631                        'to_fieldname'   => 'user_status'
632                );
633
634                // User display name.
635                $this->field_map[] = array(
636                        'from_tablename' => 'users_table',
637                        'from_fieldname' => 'the_users_display_name',
638                        'to_type'        => 'user',
639                        'to_fieldname'   => 'display_name'
640                );
641
642                // User Profile Field 1 (Stored in usermeta)
643                $this->field_map[] = array(
644                        'from_tablename'  => 'users_table',
645                        'from_fieldname'  => 'the_users_custom_profile_field_1',
646                        'to_type'         => 'user',
647                        'to_fieldname'    => '_bbp_example_profile_field_1'
648                );
649
650                // User Profile Field 2 (Stored in usermeta)
651                $this->field_map[] = array(
652                        'from_tablename'  => 'users_table',
653                        'from_fieldname'  => 'the_users_custom_profile_field_2',
654                        'to_type'         => 'user',
655                        'to_fieldname'    => '_bbp_example_profile_field_2'
656                );
657
658                // User Profile Field 3 (Stored in usermeta)
659                $this->field_map[] = array(
660                        'from_tablename' => 'users_table',
661                        'from_fieldname' => 'the_users_custom_profile_field_3',
662                        'to_type'        => 'user',
663                        'to_fieldname'   => '_bbp_example_profile_field_3'
664                );
665
666                // Setup any table joins needed for the user section
667                $this->field_map[] = array(
668                        'from_tablename'  => 'users_profile_table',
669                        'from_fieldname'  => 'the_users_id',
670                        'join_tablename'  => 'users_table',
671                        'join_type'       => 'INNER',
672                        'join_expression' => 'USING users_profile_table.the_user_id = users_table.the_user_id',
673                        'from_expression' => 'WHERE users_table.the_user_id != -1',
674                        'to_type'         => 'user'
675                );
676        }
677
678        /**
679         * This method allows us to indicates what is or is not converted for each
680         * converter.
681         */
682        public function info() {
683                return '';
684        }
685
686        /**
687         * This method is to save the salt and password together.  That
688         * way when we authenticate it we can get it out of the database
689         * as one value. Array values are auto sanitized by WordPress.
690         */
691        public function callback_savepass( $field, $row ) {
692                $pass_array = array(
693                        'hash' => $field,
694                        'salt' => $row['salt']
695                );
696
697                return $pass_array;
698        }
699
700        /**
701         * This method is to take the pass out of the database and compare
702         * to a pass the user has typed in.
703         */
704        public function authenticate_pass( $password, $serialized_pass ) {
705                $pass_array = unserialize( $serialized_pass );
706                return ( md5( md5( $password ). $pass_array['salt'] ) === $pass_array['hash'] );
707        }
708}
Note: See TracBrowser for help on using the repository browser.