PluginProbe
bbPress / 2.1.1
bbPress v2.1.1
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 2.2.2 All 71 releases
bbpress / bbp-admin / converters / Example.php

Example.php in bbPress 2.1.1, at bbp-admin/converters/Example.php

333 lines 10.4 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 Example converter.
5 */
6 class Example_Converter 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 title.
97 $this->field_map[] = array(
98 'from_tablename' => 'thread', 'from_fieldname' => 'title',
99 'to_type' => 'topic', 'to_fieldname' => 'post_title'
100 );
101
102 // Topic slug. Clean name.
103 $this->field_map[] = array(
104 'from_tablename' => 'thread', 'from_fieldname' => 'title',
105 'to_type' => 'topic', 'to_fieldname' => 'post_name',
106 'callback_method' => 'callback_slug'
107 );
108
109 // Forum id. If no parent, than 0.
110 $this->field_map[] = array(
111 'from_tablename' => 'thread', 'from_fieldname' => 'forumid',
112 'to_type' => 'topic', 'to_fieldname' => 'post_parent',
113 'callback_method' => 'callback_forumid'
114 );
115
116 // Topic date update.
117 $this->field_map[] = array(
118 'from_tablename' => 'thread', 'from_fieldname' => 'dateline',
119 'to_type' => 'topic', 'to_fieldname' => 'post_date',
120 'callback_method' => 'callback_datetime'
121 );
122 $this->field_map[] = array(
123 'from_tablename' => 'thread', 'from_fieldname' => 'dateline',
124 'to_type' => 'topic', 'to_fieldname' => 'post_date_gmt',
125 'callback_method' => 'callback_datetime'
126 );
127 $this->field_map[] = array(
128 'from_tablename' => 'thread', 'from_fieldname' => 'dateline',
129 'to_type' => 'topic', 'to_fieldname' => 'post_modified',
130 'callback_method' => 'callback_datetime'
131 );
132 $this->field_map[] = array(
133 'from_tablename' => 'thread', 'from_fieldname' => 'dateline',
134 'to_type' => 'topic', 'to_fieldname' => 'post_modified_gmt',
135 'callback_method' => 'callback_datetime'
136 );
137
138 /** Tags Section ******************************************************/
139
140 // Topic id.
141 $this->field_map[] = array(
142 'from_tablename' => 'tagcontent', 'from_fieldname' => 'contentid',
143 'to_type' => 'tags', 'to_fieldname' => 'objectid',
144 'callback_method' => 'callback_topicid'
145 );
146
147 // Tags text.
148 $this->field_map[] = array(
149 'from_tablename' => 'tag', 'from_fieldname' => 'tagtext',
150 'join_tablename' => 'tagcontent', 'join_type' => 'INNER', 'join_expression' => 'USING (tagid)',
151 'to_type' => 'tags', 'to_fieldname' => 'name'
152 );
153
154 /** Post Section ******************************************************/
155
156 // Post id. Stores in postmeta.
157 $this->field_map[] = array(
158 'from_tablename' => 'post', 'from_fieldname' => 'postid',
159 'to_type' => 'reply', 'to_fieldname' => '_bbp_post_id'
160 );
161
162 // Forum id. Stores in postmeta.
163 $this->field_map[] = array(
164 'from_tablename' => 'post', 'from_fieldname' => 'threadid',
165 'to_type' => 'reply', 'to_fieldname' => '_bbp_forum_id',
166 'callback_method' => 'callback_topicid_to_forumid'
167 );
168
169 // Topic id. Stores in postmeta.
170 $this->field_map[] = array(
171 'from_tablename' => 'post', 'from_fieldname' => 'threadid',
172 'to_type' => 'reply', 'to_fieldname' => '_bbp_topic_id',
173 'callback_method' => 'callback_topicid'
174 );
175
176 // Author ip.
177 $this->field_map[] = array(
178 'from_tablename' => 'post', 'from_fieldname' => 'ipaddress',
179 'to_type' => 'reply', 'to_fieldname' => '__bbp_author_ip'
180 );
181
182 // Post author.
183 $this->field_map[] = array(
184 'from_tablename' => 'post', 'from_fieldname' => 'userid',
185 'to_type' => 'reply', 'to_fieldname' => 'post_author',
186 'callback_method' => 'callback_userid'
187 );
188
189 // Topic title.
190 $this->field_map[] = array(
191 'from_tablename' => 'post', 'from_fieldname' => 'title',
192 'to_type' => 'reply', 'to_fieldname' => 'post_title'
193 );
194
195 // Topic slug. Clean name.
196 $this->field_map[] = array(
197 'from_tablename' => 'post', 'from_fieldname' => 'title',
198 'to_type' => 'reply', 'to_fieldname' => 'post_name',
199 'callback_method' => 'callback_slug'
200 );
201
202 // Post content.
203 $this->field_map[] = array(
204 'from_tablename' => 'post', 'from_fieldname' => 'pagetext',
205 'to_type' => 'reply', 'to_fieldname' => 'post_content',
206 'callback_method' => 'callback_html'
207 );
208
209 // Topic id. If no parent, than 0.
210 $this->field_map[] = array(
211 'from_tablename' => 'post', 'from_fieldname' => 'threadid',
212 'to_type' => 'reply', 'to_fieldname' => 'post_parent',
213 'callback_method' => 'callback_topicid'
214 );
215
216 // Topic date update.
217 $this->field_map[] = array(
218 'from_tablename' => 'post', 'from_fieldname' => 'dateline',
219 'to_type' => 'reply', 'to_fieldname' => 'post_date',
220 'callback_method' => 'callback_datetime'
221 );
222 $this->field_map[] = array(
223 'from_tablename' => 'post', 'from_fieldname' => 'dateline',
224 'to_type' => 'reply', 'to_fieldname' => 'post_date_gmt',
225 'callback_method' => 'callback_datetime'
226 );
227 $this->field_map[] = array(
228 'from_tablename' => 'post', 'from_fieldname' => 'dateline',
229 'to_type' => 'reply', 'to_fieldname' => 'post_modified',
230 'callback_method' => 'callback_datetime'
231 );
232 $this->field_map[] = array(
233 'from_tablename' => 'post', 'from_fieldname' => 'dateline',
234 'to_type' => 'reply', 'to_fieldname' => 'post_modified_gmt',
235 'callback_method' => 'callback_datetime'
236 );
237
238 /** User Section ******************************************************/
239
240 // Store old User id. Stores in usermeta.
241 $this->field_map[] = array(
242 'from_tablename' => 'user', 'from_fieldname' => 'userid',
243 'to_type' => 'user', 'to_fieldname' => '_bbp_user_id'
244 );
245
246 // Store old User password. Stores in usermeta serialized with salt.
247 $this->field_map[] = array(
248 'from_tablename' => 'user', 'from_fieldname' => 'password',
249 'to_type' => 'user', 'to_fieldname' => '_bbp_password',
250 'callback_method' => 'callback_savepass'
251 );
252
253 // Store old User Salt. This is only used for the SELECT row info for the above password save
254 $this->field_map[] = array(
255 'from_tablename' => 'user', 'from_fieldname' => 'salt',
256 'to_type' => 'user', 'to_fieldname' => ''
257 );
258
259 // User password verify class. Stores in usermeta for verifying password.
260 $this->field_map[] = array(
261 'to_type' => 'user', 'to_fieldname' => '_bbp_class',
262 'default' => 'Vbulletin'
263 );
264
265 // User name.
266 $this->field_map[] = array(
267 'from_tablename' => 'user', 'from_fieldname' => 'username',
268 'to_type' => 'user', 'to_fieldname' => 'user_login'
269 );
270
271 // User email.
272 $this->field_map[] = array(
273 'from_tablename' => 'user', 'from_fieldname' => 'email',
274 'to_type' => 'user', 'to_fieldname' => 'user_email'
275 );
276
277 // User homepage.
278 $this->field_map[] = array(
279 'from_tablename' => 'user', 'from_fieldname' => 'homepage',
280 'to_type' => 'user', 'to_fieldname' => 'user_url'
281 );
282
283 // User registered.
284 $this->field_map[] = array(
285 'from_tablename' => 'user', 'from_fieldname' => 'joindate',
286 'to_type' => 'user', 'to_fieldname' => 'user_registered',
287 'callback_method' => 'callback_datetime'
288 );
289
290 // User aim.
291 $this->field_map[] = array(
292 'from_tablename' => 'user', 'from_fieldname' => 'aim',
293 'to_type' => 'user', 'to_fieldname' => 'aim'
294 );
295
296 // User yahoo.
297 $this->field_map[] = array(
298 'from_tablename' => 'user', 'from_fieldname' => 'yahoo',
299 'to_type' => 'user', 'to_fieldname' => 'yim'
300 );
301 }
302
303 /**
304 * This method allows us to indicates what is or is not converted for each
305 * converter.
306 */
307 public function info()
308 {
309 return '';
310 }
311
312 /**
313 * This method is to save the salt and password together. That
314 * way when we authenticate it we can get it out of the database
315 * as one value. Array values are auto sanitized by wordpress.
316 */
317 public function callback_savepass( $field, $row )
318 {
319 $pass_array = array( 'hash' => $field, 'salt' => $row['salt'] );
320 return $pass_array;
321 }
322
323 /**
324 * This method is to take the pass out of the database and compare
325 * to a pass the user has typed in.
326 */
327 public function authenticate_pass( $password, $serialized_pass )
328 {
329 $pass_array = unserialize( $serialized_pass );
330 return ( $pass_array['hash'] == md5( md5( $password ). $pass_array['salt'] ) );
331 }
332 }
333