| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /** |
|---|
| 4 | * Implementation of MyBB Forum converter. |
|---|
| 5 | * |
|---|
| 6 | * @since bbPress (r5057) |
|---|
| 7 | * @link Codex Docs http://codex.bbpress.org/import-forums/mybb |
|---|
| 8 | */ |
|---|
| 9 | class MyBB extends BBP_Converter_Base { |
|---|
| 10 | |
|---|
| 11 | /** |
|---|
| 12 | * Main Constructor |
|---|
| 13 | * |
|---|
| 14 | * @uses MyBB::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' => 'pid', |
|---|
| 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 title. |
|---|
| 61 | $this->field_map[] = array( |
|---|
| 62 | 'from_tablename' => 'forums', |
|---|
| 63 | 'from_fieldname' => 'name', |
|---|
| 64 | 'to_type' => 'forum', |
|---|
| 65 | 'to_fieldname' => 'post_title' |
|---|
| 66 | ); |
|---|
| 67 | |
|---|
| 68 | // Forum slug (Clean name to avoid conflicts) |
|---|
| 69 | $this->field_map[] = array( |
|---|
| 70 | 'from_tablename' => 'forums', |
|---|
| 71 | 'from_fieldname' => 'name', |
|---|
| 72 | 'to_type' => 'forum', |
|---|
| 73 | 'to_fieldname' => 'post_name', |
|---|
| 74 | 'callback_method' => 'callback_slug' |
|---|
| 75 | ); |
|---|
| 76 | |
|---|
| 77 | // Forum description. |
|---|
| 78 | $this->field_map[] = array( |
|---|
| 79 | 'from_tablename' => 'forums', |
|---|
| 80 | 'from_fieldname' => 'description', |
|---|
| 81 | 'to_type' => 'forum', |
|---|
| 82 | 'to_fieldname' => 'post_content', |
|---|
| 83 | 'callback_method' => 'callback_null' |
|---|
| 84 | ); |
|---|
| 85 | |
|---|
| 86 | // Forum display order (Starts from 1) |
|---|
| 87 | $this->field_map[] = array( |
|---|
| 88 | 'from_tablename' => 'forums', |
|---|
| 89 | 'from_fieldname' => 'disporder', |
|---|
| 90 | 'to_type' => 'forum', |
|---|
| 91 | 'to_fieldname' => 'menu_order' |
|---|
| 92 | ); |
|---|
| 93 | |
|---|
| 94 | // Forum dates. |
|---|
| 95 | $this->field_map[] = array( |
|---|
| 96 | 'to_type' => 'forum', |
|---|
| 97 | 'to_fieldname' => 'post_date', |
|---|
| 98 | 'default' => date('Y-m-d H:i:s') |
|---|
| 99 | ); |
|---|
| 100 | $this->field_map[] = array( |
|---|
| 101 | 'to_type' => 'forum', |
|---|
| 102 | 'to_fieldname' => 'post_date_gmt', |
|---|
| 103 | 'default' => date('Y-m-d H:i:s') |
|---|
| 104 | ); |
|---|
| 105 | $this->field_map[] = array( |
|---|
| 106 | 'to_type' => 'forum', |
|---|
| 107 | 'to_fieldname' => 'post_modified', |
|---|
| 108 | 'default' => date('Y-m-d H:i:s') |
|---|
| 109 | ); |
|---|
| 110 | $this->field_map[] = array( |
|---|
| 111 | 'to_type' => 'forum', |
|---|
| 112 | 'to_fieldname' => 'post_modified_gmt', |
|---|
| 113 | 'default' => date('Y-m-d H:i:s') |
|---|
| 114 | ); |
|---|
| 115 | |
|---|
| 116 | /** Topic Section ******************************************************/ |
|---|
| 117 | |
|---|
| 118 | // Topic id (Stored in postmeta) |
|---|
| 119 | $this->field_map[] = array( |
|---|
| 120 | 'from_tablename' => 'threads', |
|---|
| 121 | 'from_fieldname' => 'tid', |
|---|
| 122 | 'to_type' => 'topic', |
|---|
| 123 | 'to_fieldname' => '_bbp_topic_id' |
|---|
| 124 | ); |
|---|
| 125 | |
|---|
| 126 | // Topic reply count (Stored in postmeta) |
|---|
| 127 | $this->field_map[] = array( |
|---|
| 128 | 'from_tablename' => 'threads', |
|---|
| 129 | 'from_fieldname' => 'replies', |
|---|
| 130 | 'to_type' => 'topic', |
|---|
| 131 | 'to_fieldname' => '_bbp_reply_count', |
|---|
| 132 | 'callback_method' => 'callback_topic_reply_count' |
|---|
| 133 | ); |
|---|
| 134 | |
|---|
| 135 | // Topic total reply count (Includes unpublished replies, Stored in postmeta) |
|---|
| 136 | $this->field_map[] = array( |
|---|
| 137 | 'from_tablename' => 'threads', |
|---|
| 138 | 'from_fieldname' => 'replies', |
|---|
| 139 | 'to_type' => 'topic', |
|---|
| 140 | 'to_fieldname' => '_bbp_total_reply_count', |
|---|
| 141 | 'callback_method' => 'callback_topic_reply_count' |
|---|
| 142 | ); |
|---|
| 143 | |
|---|
| 144 | // Topic parent forum id (If no parent, then 0. Stored in postmeta) |
|---|
| 145 | $this->field_map[] = array( |
|---|
| 146 | 'from_tablename' => 'threads', |
|---|
| 147 | 'from_fieldname' => 'fid', |
|---|
| 148 | 'to_type' => 'topic', |
|---|
| 149 | 'to_fieldname' => '_bbp_forum_id', |
|---|
| 150 | 'callback_method' => 'callback_forumid' |
|---|
| 151 | ); |
|---|
| 152 | |
|---|
| 153 | // Topic author. |
|---|
| 154 | $this->field_map[] = array( |
|---|
| 155 | 'from_tablename' => 'threads', |
|---|
| 156 | 'from_fieldname' => 'uid', |
|---|
| 157 | 'to_type' => 'topic', |
|---|
| 158 | 'to_fieldname' => 'post_author', |
|---|
| 159 | 'callback_method' => 'callback_userid' |
|---|
| 160 | ); |
|---|
| 161 | |
|---|
| 162 | // Topic Author ip (Stored in postmeta) |
|---|
| 163 | $this->field_map[] = array( |
|---|
| 164 | 'from_tablename' => 'posts', |
|---|
| 165 | 'from_fieldname' => 'ipaddress', |
|---|
| 166 | 'join_tablename' => 'threads', |
|---|
| 167 | 'join_type' => 'INNER', |
|---|
| 168 | 'join_expression' => 'USING (tid) WHERE replyto = 0', |
|---|
| 169 | 'to_type' => 'topic', |
|---|
| 170 | 'to_fieldname' => '_bbp_author_ip' |
|---|
| 171 | ); |
|---|
| 172 | |
|---|
| 173 | // Topic content. |
|---|
| 174 | // Note: We join the 'posts' table because 'threads' table does not have content. |
|---|
| 175 | $this->field_map[] = array( |
|---|
| 176 | 'from_tablename' => 'posts', |
|---|
| 177 | 'from_fieldname' => 'message', |
|---|
| 178 | 'join_tablename' => 'threads', |
|---|
| 179 | 'join_type' => 'INNER', |
|---|
| 180 | 'join_expression' => 'USING (tid) WHERE replyto = 0', |
|---|
| 181 | 'to_type' => 'topic', |
|---|
| 182 | 'to_fieldname' => 'post_content', |
|---|
| 183 | 'callback_method' => 'callback_html' |
|---|
| 184 | ); |
|---|
| 185 | |
|---|
| 186 | // Topic title. |
|---|
| 187 | $this->field_map[] = array( |
|---|
| 188 | 'from_tablename' => 'threads', |
|---|
| 189 | 'from_fieldname' => 'subject', |
|---|
| 190 | 'to_type' => 'topic', |
|---|
| 191 | 'to_fieldname' => 'post_title' |
|---|
| 192 | ); |
|---|
| 193 | |
|---|
| 194 | // Topic slug (Clean name to avoid conflicts) |
|---|
| 195 | $this->field_map[] = array( |
|---|
| 196 | 'from_tablename' => 'threads', |
|---|
| 197 | 'from_fieldname' => 'subject', |
|---|
| 198 | 'to_type' => 'topic', |
|---|
| 199 | 'to_fieldname' => 'post_name', |
|---|
| 200 | 'callback_method' => 'callback_slug' |
|---|
| 201 | ); |
|---|
| 202 | |
|---|
| 203 | // Topic parent forum id (If no parent, then 0) |
|---|
| 204 | $this->field_map[] = array( |
|---|
| 205 | 'from_tablename' => 'threads', |
|---|
| 206 | 'from_fieldname' => 'fid', |
|---|
| 207 | 'to_type' => 'topic', |
|---|
| 208 | 'to_fieldname' => 'post_parent', |
|---|
| 209 | 'callback_method' => 'callback_forumid' |
|---|
| 210 | ); |
|---|
| 211 | |
|---|
| 212 | // Topic dates. |
|---|
| 213 | $this->field_map[] = array( |
|---|
| 214 | 'from_tablename' => 'threads', |
|---|
| 215 | 'from_fieldname' => 'dateline', |
|---|
| 216 | 'to_type' => 'topic', |
|---|
| 217 | 'to_fieldname' => 'post_date', |
|---|
| 218 | 'callback_method' => 'callback_datetime' |
|---|
| 219 | ); |
|---|
| 220 | $this->field_map[] = array( |
|---|
| 221 | 'from_tablename' => 'threads', |
|---|
| 222 | 'from_fieldname' => 'dateline', |
|---|
| 223 | 'to_type' => 'topic', |
|---|
| 224 | 'to_fieldname' => 'post_date_gmt', |
|---|
| 225 | 'callback_method' => 'callback_datetime' |
|---|
| 226 | ); |
|---|
| 227 | $this->field_map[] = array( |
|---|
| 228 | 'from_tablename' => 'threads', |
|---|
| 229 | 'from_fieldname' => 'lastpost', |
|---|
| 230 | 'to_type' => 'topic', |
|---|
| 231 | 'to_fieldname' => 'post_modified', |
|---|
| 232 | 'callback_method' => 'callback_datetime' |
|---|
| 233 | ); |
|---|
| 234 | $this->field_map[] = array( |
|---|
| 235 | 'from_tablename' => 'threads', |
|---|
| 236 | 'from_fieldname' => 'lastpost', |
|---|
| 237 | 'to_type' => 'topic', |
|---|
| 238 | 'to_fieldname' => 'post_modified_gmt', |
|---|
| 239 | 'callback_method' => 'callback_datetime' |
|---|
| 240 | ); |
|---|
| 241 | $this->field_map[] = array( |
|---|
| 242 | 'from_tablename' => 'threads', |
|---|
| 243 | 'from_fieldname' => 'lastpost', |
|---|
| 244 | 'to_type' => 'topic', |
|---|
| 245 | 'to_fieldname' => '_bbp_last_active_time', |
|---|
| 246 | 'callback_method' => 'callback_datetime' |
|---|
| 247 | ); |
|---|
| 248 | |
|---|
| 249 | // Topic status (Open or Closed, MyBB v1.6.10 null=no & 1=closed) |
|---|
| 250 | $this->field_map[] = array( |
|---|
| 251 | 'from_tablename' => 'threads', |
|---|
| 252 | 'from_fieldname' => 'closed', |
|---|
| 253 | 'to_type' => 'topic', |
|---|
| 254 | 'to_fieldname' => 'post_status', |
|---|
| 255 | 'callback_method' => 'callback_topic_status' |
|---|
| 256 | ); |
|---|
| 257 | |
|---|
| 258 | /** Tags Section ******************************************************/ |
|---|
| 259 | |
|---|
| 260 | /** |
|---|
| 261 | * MyBB v1.6.10 Forums do not support topic tags out of the box |
|---|
| 262 | */ |
|---|
| 263 | |
|---|
| 264 | /** Reply Section ******************************************************/ |
|---|
| 265 | |
|---|
| 266 | // Reply id (Stored in postmeta) |
|---|
| 267 | $this->field_map[] = array( |
|---|
| 268 | 'from_tablename' => 'posts', |
|---|
| 269 | 'from_fieldname' => 'pid', |
|---|
| 270 | 'from_expression' => 'WHERE replyto != 0', |
|---|
| 271 | 'to_type' => 'reply', |
|---|
| 272 | 'to_fieldname' => '_bbp_post_id' |
|---|
| 273 | ); |
|---|
| 274 | |
|---|
| 275 | // Reply parent forum id (If no parent, then 0. Stored in postmeta) |
|---|
| 276 | $this->field_map[] = array( |
|---|
| 277 | 'from_tablename' => 'posts', |
|---|
| 278 | 'from_fieldname' => 'fid', |
|---|
| 279 | 'to_type' => 'reply', |
|---|
| 280 | 'to_fieldname' => '_bbp_forum_id', |
|---|
| 281 | 'callback_method' => 'callback_topicid_to_forumid' |
|---|
| 282 | ); |
|---|
| 283 | |
|---|
| 284 | // Reply parent topic id (If no parent, then 0. Stored in postmeta) |
|---|
| 285 | $this->field_map[] = array( |
|---|
| 286 | 'from_tablename' => 'posts', |
|---|
| 287 | 'from_fieldname' => 'tid', |
|---|
| 288 | 'to_type' => 'reply', |
|---|
| 289 | 'to_fieldname' => '_bbp_topic_id', |
|---|
| 290 | 'callback_method' => 'callback_topicid' |
|---|
| 291 | ); |
|---|
| 292 | |
|---|
| 293 | // Reply author ip (Stored in postmeta) |
|---|
| 294 | $this->field_map[] = array( |
|---|
| 295 | 'from_tablename' => 'posts', |
|---|
| 296 | 'from_fieldname' => 'ipaddress', |
|---|
| 297 | 'to_type' => 'reply', |
|---|
| 298 | 'to_fieldname' => '_bbp_author_ip' |
|---|
| 299 | ); |
|---|
| 300 | |
|---|
| 301 | // Reply author. |
|---|
| 302 | $this->field_map[] = array( |
|---|
| 303 | 'from_tablename' => 'posts', |
|---|
| 304 | 'from_fieldname' => 'uid', |
|---|
| 305 | 'to_type' => 'reply', |
|---|
| 306 | 'to_fieldname' => 'post_author', |
|---|
| 307 | 'callback_method' => 'callback_userid' |
|---|
| 308 | ); |
|---|
| 309 | |
|---|
| 310 | // Reply title. |
|---|
| 311 | $this->field_map[] = array( |
|---|
| 312 | 'from_tablename' => 'posts', |
|---|
| 313 | 'from_fieldname' => 'subject', |
|---|
| 314 | 'to_type' => 'reply', |
|---|
| 315 | 'to_fieldname' => 'post_title' |
|---|
| 316 | ); |
|---|
| 317 | |
|---|
| 318 | // Reply slug (Clean name to avoid conflicts) |
|---|
| 319 | $this->field_map[] = array( |
|---|
| 320 | 'from_tablename' => 'posts', |
|---|
| 321 | 'from_fieldname' => 'subject', |
|---|
| 322 | 'to_type' => 'reply', |
|---|
| 323 | 'to_fieldname' => 'post_name', |
|---|
| 324 | 'callback_method' => 'callback_slug' |
|---|
| 325 | ); |
|---|
| 326 | |
|---|
| 327 | // Reply content. |
|---|
| 328 | $this->field_map[] = array( |
|---|
| 329 | 'from_tablename' => 'posts', |
|---|
| 330 | 'from_fieldname' => 'message', |
|---|
| 331 | 'to_type' => 'reply', |
|---|
| 332 | 'to_fieldname' => 'post_content', |
|---|
| 333 | 'callback_method' => 'callback_html' |
|---|
| 334 | ); |
|---|
| 335 | |
|---|
| 336 | // Reply parent topic id (If no parent, then 0) |
|---|
| 337 | $this->field_map[] = array( |
|---|
| 338 | 'from_tablename' => 'posts', |
|---|
| 339 | 'from_fieldname' => 'tid', |
|---|
| 340 | 'to_type' => 'reply', |
|---|
| 341 | 'to_fieldname' => 'post_parent', |
|---|
| 342 | 'callback_method' => 'callback_topicid' |
|---|
| 343 | ); |
|---|
| 344 | |
|---|
| 345 | // Reply dates. |
|---|
| 346 | $this->field_map[] = array( |
|---|
| 347 | 'from_tablename' => 'posts', |
|---|
| 348 | 'from_fieldname' => 'dateline', |
|---|
| 349 | 'to_type' => 'reply', |
|---|
| 350 | 'to_fieldname' => 'post_date', |
|---|
| 351 | 'callback_method' => 'callback_datetime' |
|---|
| 352 | ); |
|---|
| 353 | $this->field_map[] = array( |
|---|
| 354 | 'from_tablename' => 'posts', |
|---|
| 355 | 'from_fieldname' => 'dateline', |
|---|
| 356 | 'to_type' => 'reply', |
|---|
| 357 | 'to_fieldname' => 'post_date_gmt', |
|---|
| 358 | 'callback_method' => 'callback_datetime' |
|---|
| 359 | ); |
|---|
| 360 | $this->field_map[] = array( |
|---|
| 361 | 'from_tablename' => 'posts', |
|---|
| 362 | 'from_fieldname' => 'edittime', |
|---|
| 363 | 'to_type' => 'reply', |
|---|
| 364 | 'to_fieldname' => 'post_modified', |
|---|
| 365 | 'callback_method' => 'callback_datetime' |
|---|
| 366 | ); |
|---|
| 367 | $this->field_map[] = array( |
|---|
| 368 | 'from_tablename' => 'posts', |
|---|
| 369 | 'from_fieldname' => 'edittime', |
|---|
| 370 | 'to_type' => 'reply', |
|---|
| 371 | 'to_fieldname' => 'post_modified_gmt', |
|---|
| 372 | 'callback_method' => 'callback_datetime' |
|---|
| 373 | ); |
|---|
| 374 | |
|---|
| 375 | /** User Section ******************************************************/ |
|---|
| 376 | |
|---|
| 377 | // Store old User id (Stored in usermeta) |
|---|
| 378 | $this->field_map[] = array( |
|---|
| 379 | 'from_tablename' => 'users', |
|---|
| 380 | 'from_fieldname' => 'uid', |
|---|
| 381 | 'to_type' => 'user', |
|---|
| 382 | 'to_fieldname' => '_bbp_user_id' |
|---|
| 383 | ); |
|---|
| 384 | |
|---|
| 385 | // Store old User password (Stored in usermeta serialized with salt) |
|---|
| 386 | $this->field_map[] = array( |
|---|
| 387 | 'from_tablename' => 'users', |
|---|
| 388 | 'from_fieldname' => 'password', |
|---|
| 389 | 'to_type' => 'user', |
|---|
| 390 | 'to_fieldname' => '_bbp_password', |
|---|
| 391 | 'callback_method' => 'callback_savepass' |
|---|
| 392 | ); |
|---|
| 393 | |
|---|
| 394 | // Store old User Salt (This is only used for the SELECT row info for the above password save) |
|---|
| 395 | $this->field_map[] = array( |
|---|
| 396 | 'from_tablename' => 'users', |
|---|
| 397 | 'from_fieldname' => 'salt', |
|---|
| 398 | 'to_type' => 'user', |
|---|
| 399 | 'to_fieldname' => '' |
|---|
| 400 | ); |
|---|
| 401 | |
|---|
| 402 | // User password verify class (Stored in usermeta for verifying password) |
|---|
| 403 | $this->field_map[] = array( |
|---|
| 404 | 'to_type' => 'users', |
|---|
| 405 | 'to_fieldname' => '_bbp_class', |
|---|
| 406 | 'default' => 'MyBB' |
|---|
| 407 | ); |
|---|
| 408 | |
|---|
| 409 | // User name. |
|---|
| 410 | $this->field_map[] = array( |
|---|
| 411 | 'from_tablename' => 'users', |
|---|
| 412 | 'from_fieldname' => 'username', |
|---|
| 413 | 'to_type' => 'user', |
|---|
| 414 | 'to_fieldname' => 'user_login' |
|---|
| 415 | ); |
|---|
| 416 | |
|---|
| 417 | // User nice name. |
|---|
| 418 | $this->field_map[] = array( |
|---|
| 419 | 'from_tablename' => 'users', |
|---|
| 420 | 'from_fieldname' => 'username', |
|---|
| 421 | 'to_type' => 'user', |
|---|
| 422 | 'to_fieldname' => 'user_nicename' |
|---|
| 423 | ); |
|---|
| 424 | |
|---|
| 425 | // User email. |
|---|
| 426 | $this->field_map[] = array( |
|---|
| 427 | 'from_tablename' => 'users', |
|---|
| 428 | 'from_fieldname' => 'email', |
|---|
| 429 | 'to_type' => 'user', |
|---|
| 430 | 'to_fieldname' => 'user_email' |
|---|
| 431 | ); |
|---|
| 432 | |
|---|
| 433 | // User homepage. |
|---|
| 434 | $this->field_map[] = array( |
|---|
| 435 | 'from_tablename' => 'users', |
|---|
| 436 | 'from_fieldname' => 'website', |
|---|
| 437 | 'to_type' => 'user', |
|---|
| 438 | 'to_fieldname' => 'user_url' |
|---|
| 439 | ); |
|---|
| 440 | |
|---|
| 441 | // User registered. |
|---|
| 442 | $this->field_map[] = array( |
|---|
| 443 | 'from_tablename' => 'users', |
|---|
| 444 | 'from_fieldname' => 'regdate', |
|---|
| 445 | 'to_type' => 'user', |
|---|
| 446 | 'to_fieldname' => 'user_registered', |
|---|
| 447 | 'callback_method' => 'callback_datetime' |
|---|
| 448 | ); |
|---|
| 449 | |
|---|
| 450 | // User display name. |
|---|
| 451 | $this->field_map[] = array( |
|---|
| 452 | 'from_tablename' => 'users', |
|---|
| 453 | 'from_fieldname' => 'usertitle', |
|---|
| 454 | 'to_type' => 'user', |
|---|
| 455 | 'to_fieldname' => 'display_name' |
|---|
| 456 | ); |
|---|
| 457 | |
|---|
| 458 | // User AIM (Stored in usermeta) |
|---|
| 459 | $this->field_map[] = array( |
|---|
| 460 | 'from_tablename' => 'users', |
|---|
| 461 | 'from_fieldname' => 'aim', |
|---|
| 462 | 'to_type' => 'user', |
|---|
| 463 | 'to_fieldname' => 'aim' |
|---|
| 464 | ); |
|---|
| 465 | |
|---|
| 466 | // User Yahoo (Stored in usermeta) |
|---|
| 467 | $this->field_map[] = array( |
|---|
| 468 | 'from_tablename' => 'users', |
|---|
| 469 | 'from_fieldname' => 'yahoo', |
|---|
| 470 | 'to_type' => 'user', |
|---|
| 471 | 'to_fieldname' => 'yim' |
|---|
| 472 | ); |
|---|
| 473 | |
|---|
| 474 | // Store ICQ (Stored in usermeta) |
|---|
| 475 | $this->field_map[] = array( |
|---|
| 476 | 'from_tablename' => 'users', |
|---|
| 477 | 'from_fieldname' => 'icq', |
|---|
| 478 | 'to_type' => 'user', |
|---|
| 479 | 'to_fieldname' => '_bbp_mybb_user_icq' |
|---|
| 480 | ); |
|---|
| 481 | |
|---|
| 482 | // Store MSN (Stored in usermeta) |
|---|
| 483 | $this->field_map[] = array( |
|---|
| 484 | 'from_tablename' => 'users', |
|---|
| 485 | 'from_fieldname' => 'msn', |
|---|
| 486 | 'to_type' => 'user', |
|---|
| 487 | 'to_fieldname' => '_bbp_mybb_user_msn' |
|---|
| 488 | ); |
|---|
| 489 | |
|---|
| 490 | // Store Signature (Stored in usermeta) |
|---|
| 491 | $this->field_map[] = array( |
|---|
| 492 | 'from_tablename' => 'users', |
|---|
| 493 | 'from_fieldname' => 'signature', |
|---|
| 494 | 'to_type' => 'user', |
|---|
| 495 | 'to_fieldname' => '_bbp_mybb_user_sig', |
|---|
| 496 | 'callback_method' => 'callback_html' |
|---|
| 497 | ); |
|---|
| 498 | |
|---|
| 499 | } |
|---|
| 500 | |
|---|
| 501 | /** |
|---|
| 502 | * This method allows us to indicates what is or is not converted for each |
|---|
| 503 | * converter. |
|---|
| 504 | */ |
|---|
| 505 | public function info() |
|---|
| 506 | { |
|---|
| 507 | return ''; |
|---|
| 508 | } |
|---|
| 509 | |
|---|
| 510 | /** |
|---|
| 511 | * This method is to save the salt and password together. That |
|---|
| 512 | * way when we authenticate it we can get it out of the database |
|---|
| 513 | * as one value. Array values are auto sanitized by WordPress. |
|---|
| 514 | */ |
|---|
| 515 | public function callback_savepass( $field, $row ) |
|---|
| 516 | { |
|---|
| 517 | $pass_array = array( 'hash' => $field, 'salt' => $row['salt'] ); |
|---|
| 518 | return $pass_array; |
|---|
| 519 | } |
|---|
| 520 | |
|---|
| 521 | /** |
|---|
| 522 | * This method is to take the pass out of the database and compare |
|---|
| 523 | * to a pass the user has typed in. |
|---|
| 524 | */ |
|---|
| 525 | public function authenticate_pass( $password, $serialized_pass ) |
|---|
| 526 | { |
|---|
| 527 | $pass_array = unserialize( $serialized_pass ); |
|---|
| 528 | return ( $pass_array['hash'] == md5( md5( $password ). $pass_array['salt'] ) ); |
|---|
| 529 | } |
|---|
| 530 | |
|---|
| 531 | /** |
|---|
| 532 | * Translate the post status from MyBB v1.6.10 numeric's to WordPress's strings. |
|---|
| 533 | * |
|---|
| 534 | * @param int $status MyBB v1.6.10 numeric topic status |
|---|
| 535 | * @return string WordPress safe |
|---|
| 536 | */ |
|---|
| 537 | public function callback_topic_status( $status = 0 ) { |
|---|
| 538 | switch ( $status ) { |
|---|
| 539 | case 1 : |
|---|
| 540 | $status = 'closed'; |
|---|
| 541 | break; |
|---|
| 542 | |
|---|
| 543 | case 0 : |
|---|
| 544 | default : |
|---|
| 545 | $status = 'publish'; |
|---|
| 546 | break; |
|---|
| 547 | } |
|---|
| 548 | return $status; |
|---|
| 549 | } |
|---|
| 550 | |
|---|
| 551 | /** |
|---|
| 552 | * Verify the topic/reply count. |
|---|
| 553 | * |
|---|
| 554 | * @param int $count MyBB v1.6.10 topic/reply counts |
|---|
| 555 | * @return string WordPress safe |
|---|
| 556 | */ |
|---|
| 557 | public function callback_topic_reply_count( $count = 1 ) { |
|---|
| 558 | $count = absint( (int) $count - 1 ); |
|---|
| 559 | return $count; |
|---|
| 560 | } |
|---|
| 561 | |
|---|
| 562 | } |
|---|