| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /** |
|---|
| 4 | * Implementation of FluxBB Forum converter. |
|---|
| 5 | * |
|---|
| 6 | * @since bbPress (r5057) |
|---|
| 7 | * @link Codex Docs http://codex.bbpress.org/import-forums/fluxbb |
|---|
| 8 | */ |
|---|
| 9 | class FluxBB extends BBP_Converter_Base { |
|---|
| 10 | |
|---|
| 11 | /** |
|---|
| 12 | * Main Constructor |
|---|
| 13 | * |
|---|
| 14 | * @uses FluxBB::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' => 'id', |
|---|
| 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' => 'cat_id', |
|---|
| 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' => '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' => 'forums', |
|---|
| 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' => 'forums', |
|---|
| 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' => 'forums', |
|---|
| 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' => 'forums', |
|---|
| 79 | 'from_fieldname' => 'forum_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' => 'forums', |
|---|
| 87 | 'from_fieldname' => 'forum_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' => 'forums', |
|---|
| 96 | 'from_fieldname' => 'forum_desc', |
|---|
| 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', |
|---|
| 105 | 'from_fieldname' => 'disp_position', |
|---|
| 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', |
|---|
| 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' => 'forum_id', |
|---|
| 164 | 'to_type' => 'topic', |
|---|
| 165 | 'to_fieldname' => '_bbp_forum_id', |
|---|
| 166 | 'callback_method' => 'callback_forumid' |
|---|
| 167 | ); |
|---|
| 168 | |
|---|
| 169 | // Topic author. |
|---|
| 170 | // Note: We join the 'posts' table because 'topics' table does include numeric user id. |
|---|
| 171 | $this->field_map[] = array( |
|---|
| 172 | 'from_tablename' => 'posts', |
|---|
| 173 | 'from_fieldname' => 'poster_id', |
|---|
| 174 | 'join_tablename' => 'topics', |
|---|
| 175 | 'join_type' => 'INNER', |
|---|
| 176 | 'join_expression' => 'ON topics.first_post_id = posts.id', |
|---|
| 177 | 'to_type' => 'topic', |
|---|
| 178 | 'to_fieldname' => 'post_author', |
|---|
| 179 | 'callback_method' => 'callback_userid' |
|---|
| 180 | ); |
|---|
| 181 | |
|---|
| 182 | // Topic Author ip (Stored in postmeta) |
|---|
| 183 | // Note: We join the 'posts' table because 'topics' table does not include author IP addresses. |
|---|
| 184 | $this->field_map[] = array( |
|---|
| 185 | 'from_tablename' => 'posts', |
|---|
| 186 | 'from_fieldname' => 'poster_ip', |
|---|
| 187 | 'join_tablename' => 'topics', |
|---|
| 188 | 'join_type' => 'INNER', |
|---|
| 189 | 'join_expression' => 'ON topics.first_post_id = posts.id', |
|---|
| 190 | 'to_type' => 'topic', |
|---|
| 191 | 'to_fieldname' => '_bbp_author_ip' |
|---|
| 192 | ); |
|---|
| 193 | |
|---|
| 194 | // Topic content. |
|---|
| 195 | // Note: We join the 'posts' table because 'topics' table does not include topic content. |
|---|
| 196 | $this->field_map[] = array( |
|---|
| 197 | 'from_tablename' => 'posts', |
|---|
| 198 | 'from_fieldname' => 'message', |
|---|
| 199 | 'join_tablename' => 'topics', |
|---|
| 200 | 'join_type' => 'INNER', |
|---|
| 201 | 'join_expression' => 'ON topics.first_post_id = posts.id', |
|---|
| 202 | 'to_type' => 'topic', |
|---|
| 203 | 'to_fieldname' => 'post_content', |
|---|
| 204 | 'callback_method' => 'callback_html' |
|---|
| 205 | ); |
|---|
| 206 | |
|---|
| 207 | // Topic title. |
|---|
| 208 | $this->field_map[] = array( |
|---|
| 209 | 'from_tablename' => 'topics', |
|---|
| 210 | 'from_fieldname' => 'subject', |
|---|
| 211 | 'to_type' => 'topic', |
|---|
| 212 | 'to_fieldname' => 'post_title' |
|---|
| 213 | ); |
|---|
| 214 | |
|---|
| 215 | // Topic slug (Clean name to avoid conflicts) |
|---|
| 216 | $this->field_map[] = array( |
|---|
| 217 | 'from_tablename' => 'topics', |
|---|
| 218 | 'from_fieldname' => 'subject', |
|---|
| 219 | 'to_type' => 'topic', |
|---|
| 220 | 'to_fieldname' => 'post_name', |
|---|
| 221 | 'callback_method' => 'callback_slug' |
|---|
| 222 | ); |
|---|
| 223 | |
|---|
| 224 | // Topic parent forum id (If no parent, then 0) |
|---|
| 225 | $this->field_map[] = array( |
|---|
| 226 | 'from_tablename' => 'topics', |
|---|
| 227 | 'from_fieldname' => 'forum_id', |
|---|
| 228 | 'to_type' => 'topic', |
|---|
| 229 | 'to_fieldname' => 'post_parent', |
|---|
| 230 | 'callback_method' => 'callback_forumid' |
|---|
| 231 | ); |
|---|
| 232 | |
|---|
| 233 | // Topic dates. |
|---|
| 234 | $this->field_map[] = array( |
|---|
| 235 | 'from_tablename' => 'topics', |
|---|
| 236 | 'from_fieldname' => 'posted', |
|---|
| 237 | 'to_type' => 'topic', |
|---|
| 238 | 'to_fieldname' => 'post_date', |
|---|
| 239 | 'callback_method' => 'callback_datetime' |
|---|
| 240 | ); |
|---|
| 241 | $this->field_map[] = array( |
|---|
| 242 | 'from_tablename' => 'topics', |
|---|
| 243 | 'from_fieldname' => 'posted', |
|---|
| 244 | 'to_type' => 'topic', |
|---|
| 245 | 'to_fieldname' => 'post_date_gmt', |
|---|
| 246 | 'callback_method' => 'callback_datetime' |
|---|
| 247 | ); |
|---|
| 248 | $this->field_map[] = array( |
|---|
| 249 | 'from_tablename' => 'topics', |
|---|
| 250 | 'from_fieldname' => 'posted', |
|---|
| 251 | 'to_type' => 'topic', |
|---|
| 252 | 'to_fieldname' => 'post_modified', |
|---|
| 253 | 'callback_method' => 'callback_datetime' |
|---|
| 254 | ); |
|---|
| 255 | $this->field_map[] = array( |
|---|
| 256 | 'from_tablename' => 'topics', |
|---|
| 257 | 'from_fieldname' => 'posted', |
|---|
| 258 | 'to_type' => 'topic', |
|---|
| 259 | 'to_fieldname' => 'post_modified_gmt', |
|---|
| 260 | 'callback_method' => 'callback_datetime' |
|---|
| 261 | ); |
|---|
| 262 | $this->field_map[] = array( |
|---|
| 263 | 'from_tablename' => 'topics', |
|---|
| 264 | 'from_fieldname' => 'posted', |
|---|
| 265 | 'to_type' => 'topic', |
|---|
| 266 | 'to_fieldname' => '_bbp_last_active_time', |
|---|
| 267 | 'callback_method' => 'callback_datetime' |
|---|
| 268 | ); |
|---|
| 269 | |
|---|
| 270 | // Topic status (Open = 0 or Closed = 1, FluxBB v1.5.3) |
|---|
| 271 | $this->field_map[] = array( |
|---|
| 272 | 'from_tablename' => 'topics', |
|---|
| 273 | 'from_fieldname' => 'closed', |
|---|
| 274 | 'to_type' => 'topic', |
|---|
| 275 | 'to_fieldname' => 'post_status', |
|---|
| 276 | 'callback_method' => 'callback_topic_status' |
|---|
| 277 | ); |
|---|
| 278 | |
|---|
| 279 | /** Tags Section ******************************************************/ |
|---|
| 280 | |
|---|
| 281 | /** |
|---|
| 282 | * FluxBB v1.5.3 Forums do not support topic tags out of the box |
|---|
| 283 | */ |
|---|
| 284 | |
|---|
| 285 | /** Reply Section *****************************************************/ |
|---|
| 286 | |
|---|
| 287 | // Reply id (Stored in postmeta) |
|---|
| 288 | $this->field_map[] = array( |
|---|
| 289 | 'from_tablename' => 'posts', |
|---|
| 290 | 'from_fieldname' => 'id', |
|---|
| 291 | 'to_type' => 'reply', |
|---|
| 292 | 'to_fieldname' => '_bbp_post_id' |
|---|
| 293 | ); |
|---|
| 294 | |
|---|
| 295 | // Reply parent forum id (If no parent, then 0, Stored in postmeta) |
|---|
| 296 | $this->field_map[] = array( |
|---|
| 297 | 'from_tablename' => 'topics', |
|---|
| 298 | 'from_fieldname' => 'topic_id', |
|---|
| 299 | 'to_type' => 'reply', |
|---|
| 300 | 'to_fieldname' => '_bbp_forum_id', |
|---|
| 301 | 'callback_method' => 'callback_topicid_to_forumid' |
|---|
| 302 | ); |
|---|
| 303 | |
|---|
| 304 | // Reply parent topic id (If no parent, then 0, Stored in postmeta) |
|---|
| 305 | $this->field_map[] = array( |
|---|
| 306 | 'from_tablename' => 'posts', |
|---|
| 307 | 'from_fieldname' => 'topic_id', |
|---|
| 308 | 'to_type' => 'reply', |
|---|
| 309 | 'to_fieldname' => '_bbp_topic_id', |
|---|
| 310 | 'callback_method' => 'callback_topicid' |
|---|
| 311 | ); |
|---|
| 312 | |
|---|
| 313 | // Reply author ip (Stored in postmeta) |
|---|
| 314 | $this->field_map[] = array( |
|---|
| 315 | 'from_tablename' => 'posts', |
|---|
| 316 | 'from_fieldname' => 'poster_ip', |
|---|
| 317 | 'to_type' => 'reply', |
|---|
| 318 | 'to_fieldname' => '_bbp_author_ip' |
|---|
| 319 | ); |
|---|
| 320 | |
|---|
| 321 | // Reply author. |
|---|
| 322 | $this->field_map[] = array( |
|---|
| 323 | 'from_tablename' => 'posts', |
|---|
| 324 | 'from_fieldname' => 'poster_id', |
|---|
| 325 | 'to_type' => 'reply', |
|---|
| 326 | 'to_fieldname' => 'post_author', |
|---|
| 327 | 'callback_method' => 'callback_userid' |
|---|
| 328 | ); |
|---|
| 329 | |
|---|
| 330 | // Reply title. |
|---|
| 331 | // Note: We join the 'topics' table because 'posts' table does not include reply title. |
|---|
| 332 | $this->field_map[] = array( |
|---|
| 333 | 'from_tablename' => 'topics', |
|---|
| 334 | 'from_fieldname' => 'subject', |
|---|
| 335 | 'join_tablename' => 'posts', |
|---|
| 336 | 'join_type' => 'INNER', |
|---|
| 337 | 'join_expression' => 'ON topics.id = posts.topic_id WHERE topics.first_post_id != posts.id', |
|---|
| 338 | 'to_type' => 'reply', |
|---|
| 339 | 'to_fieldname' => 'post_title', |
|---|
| 340 | 'callback_method' => 'callback_reply_title' |
|---|
| 341 | ); |
|---|
| 342 | |
|---|
| 343 | // Reply slug (Clean name to avoid conflicts) |
|---|
| 344 | // Note: We join the 'topics' table because 'posts' table does not include slug title. |
|---|
| 345 | $this->field_map[] = array( |
|---|
| 346 | 'from_tablename' => 'topics', |
|---|
| 347 | 'from_fieldname' => 'subject', |
|---|
| 348 | 'join_tablename' => 'posts', |
|---|
| 349 | 'join_type' => 'INNER', |
|---|
| 350 | 'join_expression' => 'ON topics.id = posts.topic_id WHERE topics.first_post_id != posts.id', |
|---|
| 351 | 'to_type' => 'reply', |
|---|
| 352 | 'to_fieldname' => 'post_name', |
|---|
| 353 | 'callback_method' => 'callback_slug' |
|---|
| 354 | ); |
|---|
| 355 | |
|---|
| 356 | // Reply content. |
|---|
| 357 | $this->field_map[] = array( |
|---|
| 358 | 'from_tablename' => 'posts', |
|---|
| 359 | 'from_fieldname' => 'message', |
|---|
| 360 | 'to_type' => 'reply', |
|---|
| 361 | 'to_fieldname' => 'post_content', |
|---|
| 362 | 'callback_method' => 'callback_html' |
|---|
| 363 | ); |
|---|
| 364 | |
|---|
| 365 | // Reply parent topic id (If no parent, then 0) |
|---|
| 366 | $this->field_map[] = array( |
|---|
| 367 | 'from_tablename' => 'posts', |
|---|
| 368 | 'from_fieldname' => 'topic_id', |
|---|
| 369 | 'to_type' => 'reply', |
|---|
| 370 | 'to_fieldname' => 'post_parent', |
|---|
| 371 | 'callback_method' => 'callback_topicid' |
|---|
| 372 | ); |
|---|
| 373 | |
|---|
| 374 | // Reply dates. |
|---|
| 375 | $this->field_map[] = array( |
|---|
| 376 | 'from_tablename' => 'posts', |
|---|
| 377 | 'from_fieldname' => 'posted', |
|---|
| 378 | 'to_type' => 'reply', |
|---|
| 379 | 'to_fieldname' => 'post_date', |
|---|
| 380 | 'callback_method' => 'callback_datetime' |
|---|
| 381 | ); |
|---|
| 382 | $this->field_map[] = array( |
|---|
| 383 | 'from_tablename' => 'posts', |
|---|
| 384 | 'from_fieldname' => 'posted', |
|---|
| 385 | 'to_type' => 'reply', |
|---|
| 386 | 'to_fieldname' => 'post_date_gmt', |
|---|
| 387 | 'callback_method' => 'callback_datetime' |
|---|
| 388 | ); |
|---|
| 389 | $this->field_map[] = array( |
|---|
| 390 | 'from_tablename' => 'posts', |
|---|
| 391 | 'from_fieldname' => 'posted', |
|---|
| 392 | 'to_type' => 'reply', |
|---|
| 393 | 'to_fieldname' => 'post_modified', |
|---|
| 394 | 'callback_method' => 'callback_datetime' |
|---|
| 395 | ); |
|---|
| 396 | $this->field_map[] = array( |
|---|
| 397 | 'from_tablename' => 'posts', |
|---|
| 398 | 'from_fieldname' => 'posted', |
|---|
| 399 | 'to_type' => 'reply', |
|---|
| 400 | 'to_fieldname' => 'post_modified_gmt', |
|---|
| 401 | 'callback_method' => 'callback_datetime' |
|---|
| 402 | ); |
|---|
| 403 | |
|---|
| 404 | /** User Section ******************************************************/ |
|---|
| 405 | |
|---|
| 406 | // Store old User id (Stored in usermeta) |
|---|
| 407 | $this->field_map[] = array( |
|---|
| 408 | 'from_tablename' => 'users', |
|---|
| 409 | 'from_fieldname' => 'id', |
|---|
| 410 | 'to_type' => 'user', |
|---|
| 411 | 'to_fieldname' => '_bbp_user_id' |
|---|
| 412 | ); |
|---|
| 413 | |
|---|
| 414 | // Store old User password (Stored in usermeta serialized with salt) |
|---|
| 415 | $this->field_map[] = array( |
|---|
| 416 | 'from_tablename' => 'users', |
|---|
| 417 | 'from_fieldname' => 'password', |
|---|
| 418 | 'to_type' => 'user', |
|---|
| 419 | 'to_fieldname' => '_bbp_password', |
|---|
| 420 | 'callback_method' => 'callback_savepass' |
|---|
| 421 | ); |
|---|
| 422 | |
|---|
| 423 | // Store old User Salt (This is only used for the SELECT row info for the above password save) |
|---|
| 424 | // $this->field_map[] = array( |
|---|
| 425 | // 'from_tablename' => 'users', |
|---|
| 426 | // 'from_fieldname' => 'salt', |
|---|
| 427 | // 'to_type' => 'user', |
|---|
| 428 | // 'to_fieldname' => '' |
|---|
| 429 | // ); |
|---|
| 430 | |
|---|
| 431 | // User password verify class (Stored in usermeta for verifying password) |
|---|
| 432 | $this->field_map[] = array( |
|---|
| 433 | 'to_type' => 'users', |
|---|
| 434 | 'to_fieldname' => '_bbp_class', |
|---|
| 435 | 'default' => 'FluxBB' |
|---|
| 436 | ); |
|---|
| 437 | |
|---|
| 438 | // User name. |
|---|
| 439 | $this->field_map[] = array( |
|---|
| 440 | 'from_tablename' => 'users', |
|---|
| 441 | 'from_fieldname' => 'username', |
|---|
| 442 | 'to_type' => 'user', |
|---|
| 443 | 'to_fieldname' => 'user_login' |
|---|
| 444 | ); |
|---|
| 445 | |
|---|
| 446 | // User nice name. |
|---|
| 447 | $this->field_map[] = array( |
|---|
| 448 | 'from_tablename' => 'users', |
|---|
| 449 | 'from_fieldname' => 'username', |
|---|
| 450 | 'to_type' => 'user', |
|---|
| 451 | 'to_fieldname' => 'user_nicename' |
|---|
| 452 | ); |
|---|
| 453 | |
|---|
| 454 | // User email. |
|---|
| 455 | $this->field_map[] = array( |
|---|
| 456 | 'from_tablename' => 'users', |
|---|
| 457 | 'from_fieldname' => 'email', |
|---|
| 458 | 'to_type' => 'user', |
|---|
| 459 | 'to_fieldname' => 'user_email' |
|---|
| 460 | ); |
|---|
| 461 | |
|---|
| 462 | // User homepage. |
|---|
| 463 | $this->field_map[] = array( |
|---|
| 464 | 'from_tablename' => 'users', |
|---|
| 465 | 'from_fieldname' => 'url', |
|---|
| 466 | 'to_type' => 'user', |
|---|
| 467 | 'to_fieldname' => 'user_url' |
|---|
| 468 | ); |
|---|
| 469 | |
|---|
| 470 | // User registered. |
|---|
| 471 | $this->field_map[] = array( |
|---|
| 472 | 'from_tablename' => 'users', |
|---|
| 473 | 'from_fieldname' => 'registered', |
|---|
| 474 | 'to_type' => 'user', |
|---|
| 475 | 'to_fieldname' => 'user_registered', |
|---|
| 476 | 'callback_method' => 'callback_datetime' |
|---|
| 477 | ); |
|---|
| 478 | |
|---|
| 479 | // User display name. |
|---|
| 480 | $this->field_map[] = array( |
|---|
| 481 | 'from_tablename' => 'users', |
|---|
| 482 | 'from_fieldname' => 'realname', |
|---|
| 483 | 'to_type' => 'user', |
|---|
| 484 | 'to_fieldname' => 'display_name' |
|---|
| 485 | ); |
|---|
| 486 | |
|---|
| 487 | // User AIM (Stored in usermeta) |
|---|
| 488 | $this->field_map[] = array( |
|---|
| 489 | 'from_tablename' => 'users', |
|---|
| 490 | 'from_fieldname' => 'aim', |
|---|
| 491 | 'to_type' => 'user', |
|---|
| 492 | 'to_fieldname' => 'aim' |
|---|
| 493 | ); |
|---|
| 494 | |
|---|
| 495 | // User Yahoo (Stored in usermeta) |
|---|
| 496 | $this->field_map[] = array( |
|---|
| 497 | 'from_tablename' => 'users', |
|---|
| 498 | 'from_fieldname' => 'yahoo', |
|---|
| 499 | 'to_type' => 'user', |
|---|
| 500 | 'to_fieldname' => 'yim' |
|---|
| 501 | ); |
|---|
| 502 | |
|---|
| 503 | // Store Jabber |
|---|
| 504 | $this->field_map[] = array( |
|---|
| 505 | 'from_tablename' => 'users', |
|---|
| 506 | 'from_fieldname' => 'jabber', |
|---|
| 507 | 'to_type' => 'user', |
|---|
| 508 | 'to_fieldname' => 'jabber' |
|---|
| 509 | ); |
|---|
| 510 | |
|---|
| 511 | // Store ICQ (Stored in usermeta) |
|---|
| 512 | $this->field_map[] = array( |
|---|
| 513 | 'from_tablename' => 'users', |
|---|
| 514 | 'from_fieldname' => 'icq', |
|---|
| 515 | 'to_type' => 'user', |
|---|
| 516 | 'to_fieldname' => '_bbp_fluxbb_user_icq' |
|---|
| 517 | ); |
|---|
| 518 | |
|---|
| 519 | // Store MSN (Stored in usermeta) |
|---|
| 520 | $this->field_map[] = array( |
|---|
| 521 | 'from_tablename' => 'users', |
|---|
| 522 | 'from_fieldname' => 'msn', |
|---|
| 523 | 'to_type' => 'user', |
|---|
| 524 | 'to_fieldname' => '_bbp_fluxbb_user_msn' |
|---|
| 525 | ); |
|---|
| 526 | |
|---|
| 527 | // Store Location (Stored in usermeta) |
|---|
| 528 | $this->field_map[] = array( |
|---|
| 529 | 'from_tablename' => 'users', |
|---|
| 530 | 'from_fieldname' => 'location', |
|---|
| 531 | 'to_type' => 'user', |
|---|
| 532 | 'to_fieldname' => '_bbp_fluxbb_user_location' |
|---|
| 533 | ); |
|---|
| 534 | |
|---|
| 535 | // Store Signature (Stored in usermeta) |
|---|
| 536 | $this->field_map[] = array( |
|---|
| 537 | 'from_tablename' => 'users', |
|---|
| 538 | 'from_fieldname' => 'signature', |
|---|
| 539 | 'to_type' => 'user', |
|---|
| 540 | 'to_fieldname' => '_bbp_fluxbb_user_sig', |
|---|
| 541 | 'callback_method' => 'callback_html' |
|---|
| 542 | ); |
|---|
| 543 | |
|---|
| 544 | // Store Admin Note (Stored in usermeta) |
|---|
| 545 | $this->field_map[] = array( |
|---|
| 546 | 'from_tablename' => 'users', |
|---|
| 547 | 'from_fieldname' => 'admin_note', |
|---|
| 548 | 'to_type' => 'user', |
|---|
| 549 | 'to_fieldname' => '_bbp_fluxbb_user_admin_note' |
|---|
| 550 | ); |
|---|
| 551 | |
|---|
| 552 | } |
|---|
| 553 | |
|---|
| 554 | /** |
|---|
| 555 | * This method allows us to indicates what is or is not converted for each |
|---|
| 556 | * converter. |
|---|
| 557 | */ |
|---|
| 558 | public function info() |
|---|
| 559 | { |
|---|
| 560 | return ''; |
|---|
| 561 | } |
|---|
| 562 | |
|---|
| 563 | /** |
|---|
| 564 | * This method is to save the salt and password together. That |
|---|
| 565 | * way when we authenticate it we can get it out of the database |
|---|
| 566 | * as one value. Array values are auto sanitized by WordPress. |
|---|
| 567 | */ |
|---|
| 568 | public function callback_savepass( $field, $row ) |
|---|
| 569 | { |
|---|
| 570 | $pass_array = array( 'hash' => $field, 'salt' => $row['salt'] ); |
|---|
| 571 | return $pass_array; |
|---|
| 572 | } |
|---|
| 573 | |
|---|
| 574 | /** |
|---|
| 575 | * This method is to take the pass out of the database and compare |
|---|
| 576 | * to a pass the user has typed in. |
|---|
| 577 | */ |
|---|
| 578 | public function authenticate_pass( $password, $serialized_pass ) |
|---|
| 579 | { |
|---|
| 580 | $pass_array = unserialize( $serialized_pass ); |
|---|
| 581 | return ( $pass_array['hash'] == md5( md5( $password ). $pass_array['salt'] ) ); |
|---|
| 582 | } |
|---|
| 583 | |
|---|
| 584 | /** |
|---|
| 585 | * Translate the post status from FluxBB v1.5.3 numeric's to WordPress's strings. |
|---|
| 586 | * |
|---|
| 587 | * @param int $status FluxBB v1.5.3 numeric topic status |
|---|
| 588 | * @return string WordPress safe |
|---|
| 589 | */ |
|---|
| 590 | public function callback_topic_status( $status = 0 ) { |
|---|
| 591 | switch ( $status ) { |
|---|
| 592 | case 1 : |
|---|
| 593 | $status = 'closed'; |
|---|
| 594 | break; |
|---|
| 595 | |
|---|
| 596 | case 0 : |
|---|
| 597 | default : |
|---|
| 598 | $status = 'publish'; |
|---|
| 599 | break; |
|---|
| 600 | } |
|---|
| 601 | return $status; |
|---|
| 602 | } |
|---|
| 603 | |
|---|
| 604 | /** |
|---|
| 605 | * Verify the topic/reply count. |
|---|
| 606 | * |
|---|
| 607 | * @param int $count FluxBB v1.5.3 topic/reply counts |
|---|
| 608 | * @return string WordPress safe |
|---|
| 609 | */ |
|---|
| 610 | public function callback_topic_reply_count( $count = 1 ) { |
|---|
| 611 | $count = absint( (int) $count - 1 ); |
|---|
| 612 | return $count; |
|---|
| 613 | } |
|---|
| 614 | |
|---|
| 615 | /** |
|---|
| 616 | * Set the reply title |
|---|
| 617 | * |
|---|
| 618 | * @param string $title FluxBB v1.5.3 topic title of this reply |
|---|
| 619 | * @return string Prefixed topic title, or empty string |
|---|
| 620 | */ |
|---|
| 621 | public function callback_reply_title( $title = '' ) { |
|---|
| 622 | $title = !empty( $title ) ? __( 'Re: ', 'bbpress' ) . html_entity_decode( $title ) : ''; |
|---|
| 623 | return $title; |
|---|
| 624 | } |
|---|
| 625 | } |
|---|