PluginProbe
bbPress / 2.1-rc4
bbPress v2.1-rc4
2.6.17 trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 2.2 2.2.1 All 72 releases
bbpress / bbp-admin / converters / vBulletin.php

vBulletin.php in bbPress 2.1-rc4, at bbp-admin/converters/vBulletin.php

341 lines 10.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Implementation of Vbulletin converter.
5 */
6 class Vbulletin extends BBP_Converter_Base
7 {
8 function __construct()
9 {
10 parent::__construct();
11 $this->setup_globals();
12 }
13
14 public function setup_globals()
15 {
16 /** Forum Section ******************************************************/
17
18 // Forum id. Stored in postmeta.
19 $this->field_map[] = array(
20 'from_tablename' => 'forum', 'from_fieldname' => 'forumid',
21 'to_type' => 'forum', 'to_fieldname' => '_bbp_forum_id'
22 );
23
24 // Forum parent id. If no parent, than 0. Stored in postmeta.
25 $this->field_map[] = array(
26 'from_tablename' => 'forum', 'from_fieldname' => 'parentid',
27 'to_type' => 'forum', 'to_fieldname' => '_bbp_parent_id'
28 );
29
30 // Forum title.
31 $this->field_map[] = array(
32 'from_tablename' => 'forum', 'from_fieldname' => 'title',
33 'to_type' => 'forum', 'to_fieldname' => 'post_title'
34 );
35
36 // Forum slug. Clean name.
37 $this->field_map[] = array(
38 'from_tablename' => 'forum', 'from_fieldname' => 'title_clean',
39 'to_type' => 'forum', 'to_fieldname' => 'post_name',
40 'callback_method' => 'callback_slug'
41 );
42
43 // Forum description.
44 $this->field_map[] = array(
45 'from_tablename' => 'forum', 'from_fieldname' => 'description',
46 'to_type' => 'forum', 'to_fieldname' => 'post_content',
47 'callback_method' => 'callback_null'
48 );
49
50 // Forum display order. Starts from 1.
51 $this->field_map[] = array(
52 'from_tablename' => 'forum', 'from_fieldname' => 'displayorder',
53 'to_type' => 'forum', 'to_fieldname' => 'menu_order'
54 );
55
56 // Forum date update.
57 $this->field_map[] = array(
58 'to_type' => 'forum', 'to_fieldname' => 'post_date',
59 'default' => date('Y-m-d H:i:s')
60 );
61 $this->field_map[] = array(
62 'to_type' => 'forum', 'to_fieldname' => 'post_date_gmt',
63 'default' => date('Y-m-d H:i:s')
64 );
65 $this->field_map[] = array(
66 'to_type' => 'forum', 'to_fieldname' => 'post_modified',
67 'default' => date('Y-m-d H:i:s')
68 );
69 $this->field_map[] = array(
70 'to_type' => 'forum', 'to_fieldname' => 'post_modified_gmt',
71 'default' => date('Y-m-d H:i:s')
72 );
73
74 /** Topic Section ******************************************************/
75
76 // Topic id. Stored in postmeta.
77 $this->field_map[] = array(
78 'from_tablename' => 'thread', 'from_fieldname' => 'threadid',
79 'to_type' => 'topic', 'to_fieldname' => '_bbp_topic_id'
80 );
81
82 // Forum id. Stored in postmeta.
83 $this->field_map[] = array(
84 'from_tablename' => 'thread', 'from_fieldname' => 'forumid',
85 'to_type' => 'topic', 'to_fieldname' => '_bbp_forum_id',
86 'callback_method' => 'callback_forumid'
87 );
88
89 // Topic author.
90 $this->field_map[] = array(
91 'from_tablename' => 'thread', 'from_fieldname' => 'postuserid',
92 'to_type' => 'topic', 'to_fieldname' => 'post_author',
93 'callback_method' => 'callback_userid'
94 );
95
96 // Topic content.
97 $this->field_map[] = array(
98 'from_tablename' => 'post', 'from_fieldname' => 'pagetext',
99 'join_tablename' => 'thread', 'join_type' => 'INNER', 'join_expression' => 'USING (threadid) WHERE post.parentid = 0',
100 'to_type' => 'topic', 'to_fieldname' => 'post_content',
101 'callback_method' => 'callback_html'
102 );
103
104 // Topic title.
105 $this->field_map[] = array(
106 'from_tablename' => 'thread', 'from_fieldname' => 'title',
107 'to_type' => 'topic', 'to_fieldname' => 'post_title'
108 );
109
110 // Topic slug. Clean name.
111 $this->field_map[] = array(
112 'from_tablename' => 'thread', 'from_fieldname' => 'title',
113 'to_type' => 'topic', 'to_fieldname' => 'post_name',
114 'callback_method' => 'callback_slug'
115 );
116
117 // Forum id. If no parent, than 0.
118 $this->field_map[] = array(
119 'from_tablename' => 'thread', 'from_fieldname' => 'forumid',
120 'to_type' => 'topic', 'to_fieldname' => 'post_parent',
121 'callback_method' => 'callback_forumid'
122 );
123
124 // Topic date update.
125 $this->field_map[] = array(
126 'from_tablename' => 'thread', 'from_fieldname' => 'dateline',
127 'to_type' => 'topic', 'to_fieldname' => 'post_date',
128 'callback_method' => 'callback_datetime'
129 );
130 $this->field_map[] = array(
131 'from_tablename' => 'thread', 'from_fieldname' => 'dateline',
132 'to_type' => 'topic', 'to_fieldname' => 'post_date_gmt',
133 'callback_method' => 'callback_datetime'
134 );
135 $this->field_map[] = array(
136 'from_tablename' => 'thread', 'from_fieldname' => 'dateline',
137 'to_type' => 'topic', 'to_fieldname' => 'post_modified',
138 'callback_method' => 'callback_datetime'
139 );
140 $this->field_map[] = array(
141 'from_tablename' => 'thread', 'from_fieldname' => 'dateline',
142 'to_type' => 'topic', 'to_fieldname' => 'post_modified_gmt',
143 'callback_method' => 'callback_datetime'
144 );
145
146 /** Tags Section ******************************************************/
147
148 // Topic id.
149 $this->field_map[] = array(
150 'from_tablename' => 'tagcontent', 'from_fieldname' => 'contentid',
151 'to_type' => 'tags', 'to_fieldname' => 'objectid',
152 'callback_method' => 'callback_topicid'
153 );
154
155 // Tags text.
156 $this->field_map[] = array(
157 'from_tablename' => 'tag', 'from_fieldname' => 'tagtext',
158 'join_tablename' => 'tagcontent', 'join_type' => 'INNER', 'join_expression' => 'USING (tagid)',
159 'to_type' => 'tags', 'to_fieldname' => 'name'
160 );
161
162 /** Post Section ******************************************************/
163
164 // Post id. Stores in postmeta.
165 $this->field_map[] = array(
166 'from_tablename' => 'post', 'from_fieldname' => 'postid', 'from_expression' => 'WHERE post.parentid != 0',
167 'to_type' => 'reply', 'to_fieldname' => '_bbp_post_id'
168 );
169
170 // Forum id. Stores in postmeta.
171 $this->field_map[] = array(
172 'from_tablename' => 'post', 'from_fieldname' => 'threadid',
173 'to_type' => 'reply', 'to_fieldname' => '_bbp_forum_id',
174 'callback_method' => 'callback_topicid_to_forumid'
175 );
176
177 // Topic id. Stores in postmeta.
178 $this->field_map[] = array(
179 'from_tablename' => 'post', 'from_fieldname' => 'threadid',
180 'to_type' => 'reply', 'to_fieldname' => '_bbp_topic_id',
181 'callback_method' => 'callback_topicid'
182 );
183
184 // Author ip.
185 $this->field_map[] = array(
186 'from_tablename' => 'post', 'from_fieldname' => 'ipaddress',
187 'to_type' => 'reply', 'to_fieldname' => '__bbp_author_ip'
188 );
189
190 // Post author.
191 $this->field_map[] = array(
192 'from_tablename' => 'post', 'from_fieldname' => 'userid',
193 'to_type' => 'reply', 'to_fieldname' => 'post_author',
194 'callback_method' => 'callback_userid'
195 );
196
197 // Topic title.
198 $this->field_map[] = array(
199 'from_tablename' => 'post', 'from_fieldname' => 'title',
200 'to_type' => 'reply', 'to_fieldname' => 'post_title'
201 );
202
203 // Topic slug. Clean name.
204 $this->field_map[] = array(
205 'from_tablename' => 'post', 'from_fieldname' => 'title',
206 'to_type' => 'reply', 'to_fieldname' => 'post_name',
207 'callback_method' => 'callback_slug'
208 );
209
210 // Post content.
211 $this->field_map[] = array(
212 'from_tablename' => 'post', 'from_fieldname' => 'pagetext',
213 'to_type' => 'reply', 'to_fieldname' => 'post_content',
214 'callback_method' => 'callback_html'
215 );
216
217 // Topic id. If no parent, than 0.
218 $this->field_map[] = array(
219 'from_tablename' => 'post', 'from_fieldname' => 'threadid',
220 'to_type' => 'reply', 'to_fieldname' => 'post_parent',
221 'callback_method' => 'callback_topicid'
222 );
223
224 // Topic date update.
225 $this->field_map[] = array(
226 'from_tablename' => 'post', 'from_fieldname' => 'dateline',
227 'to_type' => 'reply', 'to_fieldname' => 'post_date',
228 'callback_method' => 'callback_datetime'
229 );
230 $this->field_map[] = array(
231 'from_tablename' => 'post', 'from_fieldname' => 'dateline',
232 'to_type' => 'reply', 'to_fieldname' => 'post_date_gmt',
233 'callback_method' => 'callback_datetime'
234 );
235 $this->field_map[] = array(
236 'from_tablename' => 'post', 'from_fieldname' => 'dateline',
237 'to_type' => 'reply', 'to_fieldname' => 'post_modified',
238 'callback_method' => 'callback_datetime'
239 );
240 $this->field_map[] = array(
241 'from_tablename' => 'post', 'from_fieldname' => 'dateline',
242 'to_type' => 'reply', 'to_fieldname' => 'post_modified_gmt',
243 'callback_method' => 'callback_datetime'
244 );
245
246 /** User Section ******************************************************/
247
248 // Store old User id. Stores in usermeta.
249 $this->field_map[] = array(
250 'from_tablename' => 'user', 'from_fieldname' => 'userid',
251 'to_type' => 'user', 'to_fieldname' => '_bbp_user_id'
252 );
253
254 // Store old User password. Stores in usermeta serialized with salt.
255 $this->field_map[] = array(
256 'from_tablename' => 'user', 'from_fieldname' => 'password',
257 'to_type' => 'user', 'to_fieldname' => '_bbp_password',
258 'callback_method' => 'callback_savepass'
259 );
260
261 // Store old User Salt. This is only used for the SELECT row info for the above password save
262 $this->field_map[] = array(
263 'from_tablename' => 'user', 'from_fieldname' => 'salt',
264 'to_type' => 'user', 'to_fieldname' => ''
265 );
266
267 // User password verify class. Stores in usermeta for verifying password.
268 $this->field_map[] = array(
269 'to_type' => 'user', 'to_fieldname' => '_bbp_class',
270 'default' => 'Vbulletin'
271 );
272
273 // User name.
274 $this->field_map[] = array(
275 'from_tablename' => 'user', 'from_fieldname' => 'username',
276 'to_type' => 'user', 'to_fieldname' => 'user_login'
277 );
278
279 // User email.
280 $this->field_map[] = array(
281 'from_tablename' => 'user', 'from_fieldname' => 'email',
282 'to_type' => 'user', 'to_fieldname' => 'user_email'
283 );
284
285 // User homepage.
286 $this->field_map[] = array(
287 'from_tablename' => 'user', 'from_fieldname' => 'homepage',
288 'to_type' => 'user', 'to_fieldname' => 'user_url'
289 );
290
291 // User registered.
292 $this->field_map[] = array(
293 'from_tablename' => 'user', 'from_fieldname' => 'joindate',
294 'to_type' => 'user', 'to_fieldname' => 'user_registered',
295 'callback_method' => 'callback_datetime'
296 );
297
298 // User aim.
299 $this->field_map[] = array(
300 'from_tablename' => 'user', 'from_fieldname' => 'aim',
301 'to_type' => 'user', 'to_fieldname' => 'aim'
302 );
303
304 // User yahoo.
305 $this->field_map[] = array(
306 'from_tablename' => 'user', 'from_fieldname' => 'yahoo',
307 'to_type' => 'user', 'to_fieldname' => 'yim'
308 );
309 }
310
311 /**
312 * This method allows us to indicates what is or is not converted for each
313 * converter.
314 */
315 public function info()
316 {
317 return '';
318 }
319
320 /**
321 * This method is to save the salt and password together. That
322 * way when we authenticate it we can get it out of the database
323 * as one value. Array values are auto sanitized by wordpress.
324 */
325 public function callback_savepass( $field, $row )
326 {
327 $pass_array = array( 'hash' => $field, 'salt' => $row['salt'] );
328 return $pass_array;
329 }
330
331 /**
332 * This method is to take the pass out of the database and compare
333 * to a pass the user has typed in.
334 */
335 public function authenticate_pass( $password, $serialized_pass )
336 {
337 $pass_array = unserialize( $serialized_pass );
338 return ( $pass_array['hash'] == md5( md5( $password ). $pass_array['salt'] ) );
339 }
340 }
341