| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | /**
|
|---|
| 4 | * Implementation of vBulletin Connect v5.x Converter.
|
|---|
| 5 | *
|
|---|
| 6 | * @since bbPress (r4724)
|
|---|
| 7 | * @link Codex Docs http://codex.bbpress.org/import-forums/vbulletin
|
|---|
| 8 | */
|
|---|
| 9 | class vBulletin5 extends BBP_Converter_Base {
|
|---|
| 10 |
|
|---|
| 11 | /**
|
|---|
| 12 | * Main constructor
|
|---|
| 13 | *
|
|---|
| 14 | * @uses vBulletin5::setup_globals()
|
|---|
| 15 | */
|
|---|
| 16 | function __construct() {
|
|---|
| 17 | parent::__construct();
|
|---|
| 18 | $this->setup_globals();
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | /**
|
|---|
| 22 | * Sets up the field mappings
|
|---|
| 23 | */
|
|---|
| 24 | private function setup_globals() {
|
|---|
| 25 |
|
|---|
| 26 | /** Forum Section *****************************************************/
|
|---|
| 27 |
|
|---|
| 28 | // Forum id (Stored in postmeta)
|
|---|
| 29 | $this->field_map[] = array(
|
|---|
| 30 | 'from_tablename' => 'node',
|
|---|
| 31 | 'from_fieldname' => 'nodeid',
|
|---|
| 32 | 'from_expression' => 'WHERE node.contenttypeid = 23',
|
|---|
| 33 | 'to_type' => 'forum',
|
|---|
| 34 | 'to_fieldname' => '_bbp_forum_id'
|
|---|
| 35 | );
|
|---|
| 36 |
|
|---|
| 37 | // Forum parent id (If no parent, then 0. Stored in postmeta)
|
|---|
| 38 | $this->field_map[] = array(
|
|---|
| 39 | 'from_tablename' => 'node',
|
|---|
| 40 | 'from_fieldname' => 'parentid',
|
|---|
| 41 | 'to_type' => 'forum',
|
|---|
| 42 | 'to_fieldname' => '_bbp_forum_parent_id'
|
|---|
| 43 | );
|
|---|
| 44 |
|
|---|
| 45 | // Forum topic count (Stored in postmeta)
|
|---|
| 46 | $this->field_map[] = array(
|
|---|
| 47 | 'from_tablename' => 'node',
|
|---|
| 48 | 'from_fieldname' => 'textcount',
|
|---|
| 49 | 'to_type' => 'forum',
|
|---|
| 50 | 'to_fieldname' => '_bbp_topic_count'
|
|---|
| 51 | );
|
|---|
| 52 |
|
|---|
| 53 | // Forum reply count (Stored in postmeta)
|
|---|
| 54 | $this->field_map[] = array(
|
|---|
| 55 | 'from_tablename' => 'node',
|
|---|
| 56 | 'from_fieldname' => 'totalcount',
|
|---|
| 57 | 'to_type' => 'forum',
|
|---|
| 58 | 'to_fieldname' => '_bbp_reply_count'
|
|---|
| 59 | );
|
|---|
| 60 |
|
|---|
| 61 | // Forum total topic count (Stored in postmeta)
|
|---|
| 62 | $this->field_map[] = array(
|
|---|
| 63 | 'from_tablename' => 'node',
|
|---|
| 64 | 'from_fieldname' => 'textcount',
|
|---|
| 65 | 'to_type' => 'forum',
|
|---|
| 66 | 'to_fieldname' => '_bbp_total_topic_count'
|
|---|
| 67 | );
|
|---|
| 68 |
|
|---|
| 69 | // Forum total reply count (Stored in postmeta)
|
|---|
| 70 | $this->field_map[] = array(
|
|---|
| 71 | 'from_tablename' => 'node',
|
|---|
| 72 | 'from_fieldname' => 'totalcount',
|
|---|
| 73 | 'to_type' => 'forum',
|
|---|
| 74 | 'to_fieldname' => '_bbp_total_reply_count'
|
|---|
| 75 | );
|
|---|
| 76 |
|
|---|
| 77 | // Forum title.
|
|---|
| 78 | $this->field_map[] = array(
|
|---|
| 79 | 'from_tablename' => 'node',
|
|---|
| 80 | 'from_fieldname' => 'title',
|
|---|
| 81 | 'to_type' => 'forum',
|
|---|
| 82 | 'to_fieldname' => 'post_title'
|
|---|
| 83 | );
|
|---|
| 84 |
|
|---|
| 85 | // Forum slug (Clean name to avoid confilcts)
|
|---|
| 86 | $this->field_map[] = array(
|
|---|
| 87 | 'from_tablename' => 'node',
|
|---|
| 88 | 'from_fieldname' => 'urlident',
|
|---|
| 89 | 'to_type' => 'forum',
|
|---|
| 90 | 'to_fieldname' => 'post_name',
|
|---|
| 91 | 'callback_method' => 'callback_slug'
|
|---|
| 92 | );
|
|---|
| 93 |
|
|---|
| 94 | // Forum description.
|
|---|
| 95 | $this->field_map[] = array(
|
|---|
| 96 | 'from_tablename' => 'node',
|
|---|
| 97 | 'from_fieldname' => 'description',
|
|---|
| 98 | 'to_type' => 'forum',
|
|---|
| 99 | 'to_fieldname' => 'post_content',
|
|---|
| 100 | 'callback_method' => 'callback_null'
|
|---|
| 101 | );
|
|---|
| 102 |
|
|---|
| 103 | // Forum display order (Starts from 1)
|
|---|
| 104 | $this->field_map[] = array(
|
|---|
| 105 | 'from_tablename' => 'node',
|
|---|
| 106 | 'from_fieldname' => 'displayorder',
|
|---|
| 107 | 'to_type' => 'forum',
|
|---|
| 108 | 'to_fieldname' => 'menu_order'
|
|---|
| 109 | );
|
|---|
| 110 |
|
|---|
| 111 | // Forum dates.
|
|---|
| 112 | $this->field_map[] = array(
|
|---|
| 113 | 'to_type' => 'forum',
|
|---|
| 114 | 'to_fieldname' => 'post_date',
|
|---|
| 115 | 'default' => date( 'Y-m-d H:i:s' )
|
|---|
| 116 | );
|
|---|
| 117 | $this->field_map[] = array(
|
|---|
| 118 | 'to_type' => 'forum',
|
|---|
| 119 | 'to_fieldname' => 'post_date_gmt',
|
|---|
| 120 | 'default' => date( 'Y-m-d H:i:s' )
|
|---|
| 121 | );
|
|---|
| 122 | $this->field_map[] = array(
|
|---|
| 123 | 'to_type' => 'forum',
|
|---|
| 124 | 'to_fieldname' => 'post_modified',
|
|---|
| 125 | 'default' => date( 'Y-m-d H:i:s' )
|
|---|
| 126 | );
|
|---|
| 127 | $this->field_map[] = array(
|
|---|
| 128 | 'to_type' => 'forum',
|
|---|
| 129 | 'to_fieldname' => 'post_modified_gmt',
|
|---|
| 130 | 'default' => date( 'Y-m-d H:i:s' )
|
|---|
| 131 | );
|
|---|
| 132 |
|
|---|
| 133 | /** Topic Section *****************************************************/
|
|---|
| 134 |
|
|---|
| 135 | // Topic id (Stored in postmeta)
|
|---|
| 136 | $this->field_map[] = array(
|
|---|
| 137 | 'from_tablename' => 'node',
|
|---|
| 138 | 'from_fieldname' => 'nodeid',
|
|---|
| 139 | 'to_type' => 'topic',
|
|---|
| 140 | 'to_fieldname' => '_bbp_topic_id'
|
|---|
| 141 | );
|
|---|
| 142 |
|
|---|
| 143 | // Topic parent forum id (If no parent, then 0. Stored in postmeta)
|
|---|
| 144 | $this->field_map[] = array(
|
|---|
| 145 | 'from_tablename' => 'node',
|
|---|
| 146 | 'from_fieldname' => 'parentid',
|
|---|
| 147 | 'to_type' => 'topic',
|
|---|
| 148 | 'to_fieldname' => '_bbp_forum_id',
|
|---|
| 149 | 'callback_method' => 'callback_forumid'
|
|---|
| 150 | );
|
|---|
| 151 |
|
|---|
| 152 | // Topic reply count (Stored in postmeta)
|
|---|
| 153 | $this->field_map[] = array(
|
|---|
| 154 | 'from_tablename' => 'node',
|
|---|
| 155 | 'from_fieldname' => 'totalcount',
|
|---|
| 156 | 'to_type' => 'topic',
|
|---|
| 157 | 'to_fieldname' => '_bbp_reply_count',
|
|---|
| 158 | 'callback_method' => 'callback_topic_reply_count'
|
|---|
| 159 | );
|
|---|
| 160 |
|
|---|
| 161 | // Topic total reply count (Includes unpublished replies, Stored in postmeta)
|
|---|
| 162 | $this->field_map[] = array(
|
|---|
| 163 | 'from_tablename' => 'node',
|
|---|
| 164 | 'from_fieldname' => 'totalcount',
|
|---|
| 165 | 'to_type' => 'topic',
|
|---|
| 166 | 'to_fieldname' => '_bbp_total_reply_count',
|
|---|
| 167 | 'callback_method' => 'callback_topic_reply_count'
|
|---|
| 168 | );
|
|---|
| 169 |
|
|---|
| 170 | /* // Topic hidden count (Includes unpublished replies, Stored in postmeta)
|
|---|
| 171 | $this->field_map[] = array(
|
|---|
| 172 | 'from_tablename' => 'node',
|
|---|
| 173 | 'from_fieldname' => 'textunpubcount',
|
|---|
| 174 | 'to_type' => 'topic',
|
|---|
| 175 | 'to_fieldname' => '_bbp_total_count_hidden',
|
|---|
| 176 | 'callback_method' => 'callback_topic_reply_count'
|
|---|
| 177 | );
|
|---|
| 178 | */
|
|---|
| 179 | // Topic author.
|
|---|
| 180 | $this->field_map[] = array(
|
|---|
| 181 | 'from_tablename' => 'node',
|
|---|
| 182 | 'from_fieldname' => 'userid',
|
|---|
| 183 | 'to_type' => 'topic',
|
|---|
| 184 | 'to_fieldname' => 'post_author',
|
|---|
| 185 | 'callback_method' => 'callback_userid'
|
|---|
| 186 | );
|
|---|
| 187 |
|
|---|
| 188 | // Topic title.
|
|---|
| 189 | $this->field_map[] = array(
|
|---|
| 190 | 'from_tablename' => 'node',
|
|---|
| 191 | 'from_fieldname' => 'title',
|
|---|
| 192 | 'to_type' => 'topic',
|
|---|
| 193 | 'to_fieldname' => 'post_title'
|
|---|
| 194 | );
|
|---|
| 195 |
|
|---|
| 196 | // Topic slug (Clean name to avoid conflicts)
|
|---|
| 197 | $this->field_map[] = array(
|
|---|
| 198 | 'from_tablename' => 'node',
|
|---|
| 199 | 'from_fieldname' => 'urlident',
|
|---|
| 200 | 'to_type' => 'topic',
|
|---|
| 201 | 'to_fieldname' => 'post_name',
|
|---|
| 202 | 'callback_method' => 'callback_slug'
|
|---|
| 203 | );
|
|---|
| 204 |
|
|---|
| 205 | // Topic parent forum id (If no parent, then 0)
|
|---|
| 206 | $this->field_map[] = array(
|
|---|
| 207 | 'from_tablename' => 'node',
|
|---|
| 208 | 'from_fieldname' => 'parentid',
|
|---|
| 209 | 'to_type' => 'topic',
|
|---|
| 210 | 'to_fieldname' => 'post_parent',
|
|---|
| 211 | 'callback_method' => 'callback_forumid'
|
|---|
| 212 | );
|
|---|
| 213 |
|
|---|
| 214 | // Topic content.
|
|---|
| 215 | // Note: We join the 'text' table because 'node' table does not include topic content.
|
|---|
| 216 | $this->field_map[] = array(
|
|---|
| 217 | 'from_tablename' => 'text',
|
|---|
| 218 | 'from_fieldname' => 'rawtext',
|
|---|
| 219 | 'join_tablename' => 'node',
|
|---|
| 220 | 'join_type' => 'INNER',
|
|---|
| 221 | 'join_expression' => 'USING (nodeid) WHERE node.contenttypeid = 22 AND node.urlident IS NOT NULL',
|
|---|
| 222 | 'to_type' => 'topic',
|
|---|
| 223 | 'to_fieldname' => 'post_content',
|
|---|
| 224 | 'callback_method' => 'callback_html'
|
|---|
| 225 | );
|
|---|
| 226 |
|
|---|
| 227 | // Topic dates.
|
|---|
| 228 | $this->field_map[] = array(
|
|---|
| 229 | 'from_tablename' => 'node',
|
|---|
| 230 | 'from_fieldname' => 'publishdate',
|
|---|
| 231 | 'to_type' => 'topic',
|
|---|
| 232 | 'to_fieldname' => 'post_date',
|
|---|
| 233 | 'callback_method' => 'callback_datetime'
|
|---|
| 234 | );
|
|---|
| 235 | $this->field_map[] = array(
|
|---|
| 236 | 'from_tablename' => 'node',
|
|---|
| 237 | 'from_fieldname' => 'publishdate',
|
|---|
| 238 | 'to_type' => 'topic',
|
|---|
| 239 | 'to_fieldname' => 'post_date_gmt',
|
|---|
| 240 | 'callback_method' => 'callback_datetime'
|
|---|
| 241 | );
|
|---|
| 242 | $this->field_map[] = array(
|
|---|
| 243 | 'from_tablename' => 'node',
|
|---|
| 244 | 'from_fieldname' => 'publishdate',
|
|---|
| 245 | 'to_type' => 'topic',
|
|---|
| 246 | 'to_fieldname' => 'post_modified',
|
|---|
| 247 | 'callback_method' => 'callback_datetime'
|
|---|
| 248 | );
|
|---|
| 249 | $this->field_map[] = array(
|
|---|
| 250 | 'from_tablename' => 'node',
|
|---|
| 251 | 'from_fieldname' => 'publishdate',
|
|---|
| 252 | 'to_type' => 'topic',
|
|---|
| 253 | 'to_fieldname' => 'post_modified_gmt',
|
|---|
| 254 | 'callback_method' => 'callback_datetime'
|
|---|
| 255 | );
|
|---|
| 256 | $this->field_map[] = array(
|
|---|
| 257 | 'from_tablename' => 'node',
|
|---|
| 258 | 'from_fieldname' => 'lastcontent',
|
|---|
| 259 | 'to_type' => 'topic',
|
|---|
| 260 | 'to_fieldname' => '_bbp_last_active_time',
|
|---|
| 261 | 'callback_method' => 'callback_datetime'
|
|---|
| 262 | );
|
|---|
| 263 |
|
|---|
| 264 | // Topic status (Open or Closed)
|
|---|
| 265 | $this->field_map[] = array(
|
|---|
| 266 | 'from_tablename' => 'node',
|
|---|
| 267 | 'from_fieldname' => 'open',
|
|---|
| 268 | 'to_type' => 'topic',
|
|---|
| 269 | 'to_fieldname' => 'post_status',
|
|---|
| 270 | 'callback_method' => 'callback_topic_status'
|
|---|
| 271 | );
|
|---|
| 272 |
|
|---|
| 273 | /** Tags Section ******************************************************/
|
|---|
| 274 |
|
|---|
| 275 | // Topic id.
|
|---|
| 276 | $this->field_map[] = array(
|
|---|
| 277 | 'from_tablename' => 'tagnode',
|
|---|
| 278 | 'from_fieldname' => 'nodeid',
|
|---|
| 279 | 'to_type' => 'tags',
|
|---|
| 280 | 'to_fieldname' => 'objectid',
|
|---|
| 281 | 'callback_method' => 'callback_topicid'
|
|---|
| 282 | );
|
|---|
| 283 |
|
|---|
| 284 | // Taxonomy ID.
|
|---|
| 285 | $this->field_map[] = array(
|
|---|
| 286 | 'from_tablename' => 'tagnode',
|
|---|
| 287 | 'from_fieldname' => 'tagid',
|
|---|
| 288 | 'to_type' => 'tags',
|
|---|
| 289 | 'to_fieldname' => 'taxonomy'
|
|---|
| 290 | );
|
|---|
| 291 |
|
|---|
| 292 | // Term text.
|
|---|
| 293 | $this->field_map[] = array(
|
|---|
| 294 | 'from_tablename' => 'tag',
|
|---|
| 295 | 'from_fieldname' => 'tagtext',
|
|---|
| 296 | 'join_tablename' => 'tagnode',
|
|---|
| 297 | 'join_type' => 'INNER',
|
|---|
| 298 | 'join_expression' => 'USING (tagid)',
|
|---|
| 299 | 'to_type' => 'tags',
|
|---|
| 300 | 'to_fieldname' => 'name'
|
|---|
| 301 | );
|
|---|
| 302 |
|
|---|
| 303 | /** Reply Section *****************************************************/
|
|---|
| 304 |
|
|---|
| 305 | // Reply id (Stored in postmeta)
|
|---|
| 306 | $this->field_map[] = array(
|
|---|
| 307 | 'from_tablename' => 'node',
|
|---|
| 308 | 'from_fieldname' => 'nodeid',
|
|---|
| 309 | 'to_type' => 'reply',
|
|---|
| 310 | 'to_fieldname' => '_bbp_vb5_reply_post_id'
|
|---|
| 311 | );
|
|---|
| 312 |
|
|---|
| 313 | // Reply id (Stored in postmeta)
|
|---|
| 314 | $this->field_map[] = array(
|
|---|
| 315 | 'from_tablename' => 'reply',
|
|---|
| 316 | 'from_fieldname' => 'nodeid',
|
|---|
| 317 | 'to_type' => 'reply',
|
|---|
| 318 | 'to_fieldname' => '_bbp_post_id'
|
|---|
| 319 | );
|
|---|
| 320 |
|
|---|
| 321 | // Reply parent forum id (If no parent, then 0. Stored in postmeta)
|
|---|
| 322 | $this->field_map[] = array(
|
|---|
| 323 | 'from_tablename' => 'topic',
|
|---|
| 324 | 'from_fieldname' => 'parentid',
|
|---|
| 325 | 'from_expression' => 'LEFT JOIN `node` AS `reply` ON reply.nodeid = node.nodeid
|
|---|
| 326 | LEFT JOIN `node` AS `topic` ON reply.parentid = topic.nodeid
|
|---|
| 327 | LEFT JOIN `node` AS `forum` ON topic.parentid = forum.nodeid',
|
|---|
| 328 | 'to_type' => 'reply',
|
|---|
| 329 | 'to_fieldname' => '_bbp_forum_id',
|
|---|
| 330 | 'callback_method' => 'callback_topicid_to_forumid'
|
|---|
| 331 | );
|
|---|
| 332 |
|
|---|
| 333 | // Reply parent topic id (If no parent, then 0. Stored in postmeta)
|
|---|
| 334 | $this->field_map[] = array(
|
|---|
| 335 | 'from_tablename' => 'topic',
|
|---|
| 336 | 'from_fieldname' => 'starter',
|
|---|
| 337 | 'to_type' => 'reply',
|
|---|
| 338 | 'to_fieldname' => '_bbp_topic_id',
|
|---|
| 339 | 'callback_method' => 'callback_topicid'
|
|---|
| 340 | );
|
|---|
| 341 |
|
|---|
| 342 | // Reply author ip (Stored in postmeta)
|
|---|
| 343 | $this->field_map[] = array(
|
|---|
| 344 | 'from_tablename' => 'reply',
|
|---|
| 345 | 'from_fieldname' => 'ipaddress',
|
|---|
| 346 | 'to_type' => 'reply',
|
|---|
| 347 | 'to_fieldname' => '_bbp_author_ip'
|
|---|
| 348 | );
|
|---|
| 349 |
|
|---|
| 350 | // Reply author.
|
|---|
| 351 | $this->field_map[] = array(
|
|---|
| 352 | 'from_tablename' => 'reply',
|
|---|
| 353 | 'from_fieldname' => 'userid',
|
|---|
| 354 | 'to_type' => 'reply',
|
|---|
| 355 | 'to_fieldname' => 'post_author',
|
|---|
| 356 | 'callback_method' => 'callback_userid'
|
|---|
| 357 | );
|
|---|
| 358 |
|
|---|
| 359 | // Reply title.
|
|---|
| 360 | $this->field_map[] = array(
|
|---|
| 361 | 'from_tablename' => 'topic',
|
|---|
| 362 | 'from_fieldname' => 'title',
|
|---|
| 363 | 'to_type' => 'reply',
|
|---|
| 364 | 'to_fieldname' => 'post_title',
|
|---|
| 365 | 'callback_method' => 'callback_reply_title'
|
|---|
| 366 | );
|
|---|
| 367 |
|
|---|
| 368 | // Reply slug (Clean name to avoid conflicts)
|
|---|
| 369 | $this->field_map[] = array(
|
|---|
| 370 | 'from_tablename' => 'topic',
|
|---|
| 371 | 'from_fieldname' => 'urlident',
|
|---|
| 372 | 'to_type' => 'reply',
|
|---|
| 373 | 'to_fieldname' => 'post_title',
|
|---|
| 374 | 'callback_method' => 'callback_slug'
|
|---|
| 375 | );
|
|---|
| 376 |
|
|---|
| 377 | // Reply content.
|
|---|
| 378 | // Note: We join the 'text' table because 'node' table does not include reply content.
|
|---|
| 379 | $this->field_map[] = array(
|
|---|
| 380 | 'from_tablename' => 'text',
|
|---|
| 381 | 'from_fieldname' => 'rawtext',
|
|---|
| 382 | 'join_tablename' => 'node',
|
|---|
| 383 | 'join_type' => 'INNER',
|
|---|
| 384 | 'join_expression' => 'ON text.nodeid = reply.nodeid
|
|---|
| 385 | WHERE reply.contenttypeid =22
|
|---|
| 386 | AND reply.urlident IS NULL
|
|---|
| 387 | AND reply.title IS NOT NULL',
|
|---|
| 388 | 'to_type' => 'reply',
|
|---|
| 389 | 'to_fieldname' => 'post_content',
|
|---|
| 390 | 'callback_method' => 'callback_html'
|
|---|
| 391 | );
|
|---|
| 392 |
|
|---|
| 393 | // Reply parent topic id (If no parent, then 0)
|
|---|
| 394 | $this->field_map[] = array(
|
|---|
| 395 | 'from_tablename' => 'topic',
|
|---|
| 396 | 'from_fieldname' => 'starter',
|
|---|
| 397 | 'to_type' => 'reply',
|
|---|
| 398 | 'to_fieldname' => 'post_parent',
|
|---|
| 399 | 'callback_method' => 'callback_topicid'
|
|---|
| 400 | );
|
|---|
| 401 |
|
|---|
| 402 | // Reply dates.
|
|---|
| 403 | $this->field_map[] = array(
|
|---|
| 404 | 'from_tablename' => 'reply',
|
|---|
| 405 | 'from_fieldname' => 'publishdate',
|
|---|
| 406 | 'to_type' => 'reply',
|
|---|
| 407 | 'to_fieldname' => 'post_date',
|
|---|
| 408 | 'callback_method' => 'callback_datetime'
|
|---|
| 409 | );
|
|---|
| 410 | $this->field_map[] = array(
|
|---|
| 411 | 'from_tablename' => 'reply',
|
|---|
| 412 | 'from_fieldname' => 'publishdate',
|
|---|
| 413 | 'to_type' => 'reply',
|
|---|
| 414 | 'to_fieldname' => 'post_date_gmt',
|
|---|
| 415 | 'callback_method' => 'callback_datetime'
|
|---|
| 416 | );
|
|---|
| 417 | $this->field_map[] = array(
|
|---|
| 418 | 'from_tablename' => 'reply',
|
|---|
| 419 | 'from_fieldname' => 'publishdate',
|
|---|
| 420 | 'to_type' => 'reply',
|
|---|
| 421 | 'to_fieldname' => 'post_modified',
|
|---|
| 422 | 'callback_method' => 'callback_datetime'
|
|---|
| 423 | );
|
|---|
| 424 | $this->field_map[] = array(
|
|---|
| 425 | 'from_tablename' => 'reply',
|
|---|
| 426 | 'from_fieldname' => 'publishdate',
|
|---|
| 427 | 'to_type' => 'reply',
|
|---|
| 428 | 'to_fieldname' => 'post_modified_gmt',
|
|---|
| 429 | 'callback_method' => 'callback_datetime'
|
|---|
| 430 | );
|
|---|
| 431 |
|
|---|
| 432 | /** Comment Section *****************************************************/
|
|---|
| 433 |
|
|---|
| 434 | // Comment id (Stored in postmeta)
|
|---|
| 435 | $this->field_map[] = array(
|
|---|
| 436 | 'from_tablename' => 'node',
|
|---|
| 437 | 'from_fieldname' => 'nodeid',
|
|---|
| 438 | 'to_type' => 'comment',
|
|---|
| 439 | 'to_fieldname' => '_bbp_vb5_comment_post_id'
|
|---|
| 440 | );
|
|---|
| 441 |
|
|---|
| 442 | // Comment id (Stored in postmeta)
|
|---|
| 443 | $this->field_map[] = array(
|
|---|
| 444 | 'from_tablename' => 'reply',
|
|---|
| 445 | 'from_fieldname' => 'nodeid',
|
|---|
| 446 | 'to_type' => 'comment',
|
|---|
| 447 | 'to_fieldname' => '_bbp_post_id'
|
|---|
| 448 | );
|
|---|
| 449 |
|
|---|
| 450 | // Comment parent forum id (If no parent, then 0. Stored in postmeta)
|
|---|
| 451 | $this->field_map[] = array(
|
|---|
| 452 | 'from_tablename' => 'forum',
|
|---|
| 453 | 'from_fieldname' => 'parentid',
|
|---|
| 454 | 'from_expression' => 'LEFT JOIN `node` AS `reply` ON reply.nodeid = node.nodeid
|
|---|
| 455 | LEFT JOIN `node` AS `topic` ON reply.parentid = topic.nodeid
|
|---|
| 456 | LEFT JOIN `node` AS `forum` ON topic.parentid = forum.nodeid',
|
|---|
| 457 | 'to_type' => 'comment',
|
|---|
| 458 | 'to_fieldname' => '_bbp_forum_id',
|
|---|
| 459 | 'callback_method' => 'callback_forumid'
|
|---|
| 460 | );
|
|---|
| 461 |
|
|---|
| 462 | // Comment parent topic id (If no parent, then 0. Stored in postmeta)
|
|---|
| 463 | $this->field_map[] = array(
|
|---|
| 464 | 'from_tablename' => 'topic',
|
|---|
| 465 | 'from_fieldname' => 'starter',
|
|---|
| 466 | 'to_type' => 'comment',
|
|---|
| 467 | 'to_fieldname' => '_bbp_topic_id',
|
|---|
| 468 | 'callback_method' => 'callback_topicid'
|
|---|
| 469 | );
|
|---|
| 470 |
|
|---|
| 471 | // Comment parent reply id (If no parent, then 0. Stored in postmeta)
|
|---|
| 472 | $this->field_map[] = array(
|
|---|
| 473 | 'from_tablename' => 'reply',
|
|---|
| 474 | 'from_fieldname' => 'parentid',
|
|---|
| 475 | 'to_type' => 'comment',
|
|---|
| 476 | 'to_fieldname' => '_bbp_reply_to'
|
|---|
| 477 | );
|
|---|
| 478 |
|
|---|
| 479 | // Comment author ip (Stored in postmeta)
|
|---|
| 480 | $this->field_map[] = array(
|
|---|
| 481 | 'from_tablename' => 'reply',
|
|---|
| 482 | 'from_fieldname' => 'ipaddress',
|
|---|
| 483 | 'to_type' => 'comment',
|
|---|
| 484 | 'to_fieldname' => '_bbp_author_ip'
|
|---|
| 485 | );
|
|---|
| 486 |
|
|---|
| 487 | // Comment author.
|
|---|
| 488 | $this->field_map[] = array(
|
|---|
| 489 | 'from_tablename' => 'reply',
|
|---|
| 490 | 'from_fieldname' => 'userid',
|
|---|
| 491 | 'to_type' => 'comment',
|
|---|
| 492 | 'to_fieldname' => 'post_author',
|
|---|
| 493 | 'callback_method' => 'callback_userid'
|
|---|
| 494 | );
|
|---|
| 495 |
|
|---|
| 496 | // Comment title.
|
|---|
| 497 | $this->field_map[] = array(
|
|---|
| 498 | 'from_tablename' => 'forum',
|
|---|
| 499 | 'from_fieldname' => 'title',
|
|---|
| 500 | 'to_type' => 'comment',
|
|---|
| 501 | 'to_fieldname' => 'post_title',
|
|---|
| 502 | 'callback_method' => 'callback_reply_title'
|
|---|
| 503 | );
|
|---|
| 504 |
|
|---|
| 505 | // Comment slug (Clean name to avoid conflicts)
|
|---|
| 506 | $this->field_map[] = array(
|
|---|
| 507 | 'from_tablename' => 'forum',
|
|---|
| 508 | 'from_fieldname' => 'urlident',
|
|---|
| 509 | 'to_type' => 'comment',
|
|---|
| 510 | 'to_fieldname' => 'post_title',
|
|---|
| 511 | 'callback_method' => 'callback_slug'
|
|---|
| 512 | );
|
|---|
| 513 |
|
|---|
| 514 | // Comment content.
|
|---|
| 515 | // Note: We join the 'text' table because 'node' table does not include reply content.
|
|---|
| 516 | $this->field_map[] = array(
|
|---|
| 517 | 'from_tablename' => 'text',
|
|---|
| 518 | 'from_fieldname' => 'rawtext',
|
|---|
| 519 | 'join_tablename' => 'node',
|
|---|
| 520 | 'join_type' => 'INNER',
|
|---|
| 521 | 'join_expression' => 'ON text.nodeid = reply.nodeid
|
|---|
| 522 | WHERE reply.contenttypeid =22
|
|---|
| 523 | AND reply.urlident IS NULL
|
|---|
| 524 | AND reply.title IS NULL',
|
|---|
| 525 | 'to_type' => 'comment',
|
|---|
| 526 | 'to_fieldname' => 'post_content',
|
|---|
| 527 | 'callback_method' => 'callback_html'
|
|---|
| 528 | );
|
|---|
| 529 |
|
|---|
| 530 | // Comment parent topic id (If no parent, then 0)
|
|---|
| 531 | $this->field_map[] = array(
|
|---|
| 532 | 'from_tablename' => 'topic',
|
|---|
| 533 | 'from_fieldname' => 'starter',
|
|---|
| 534 | 'to_type' => 'comment',
|
|---|
| 535 | 'to_fieldname' => 'post_parent',
|
|---|
| 536 | 'callback_method' => 'callback_topicid'
|
|---|
| 537 | );
|
|---|
| 538 |
|
|---|
| 539 | // Comment dates.
|
|---|
| 540 | $this->field_map[] = array(
|
|---|
| 541 | 'from_tablename' => 'reply',
|
|---|
| 542 | 'from_fieldname' => 'publishdate',
|
|---|
| 543 | 'to_type' => 'comment',
|
|---|
| 544 | 'to_fieldname' => 'post_date',
|
|---|
| 545 | 'callback_method' => 'callback_datetime'
|
|---|
| 546 | );
|
|---|
| 547 | $this->field_map[] = array(
|
|---|
| 548 | 'from_tablename' => 'reply',
|
|---|
| 549 | 'from_fieldname' => 'publishdate',
|
|---|
| 550 | 'to_type' => 'comment',
|
|---|
| 551 | 'to_fieldname' => 'post_date_gmt',
|
|---|
| 552 | 'callback_method' => 'callback_datetime'
|
|---|
| 553 | );
|
|---|
| 554 | $this->field_map[] = array(
|
|---|
| 555 | 'from_tablename' => 'reply',
|
|---|
| 556 | 'from_fieldname' => 'publishdate',
|
|---|
| 557 | 'to_type' => 'comment',
|
|---|
| 558 | 'to_fieldname' => 'post_modified',
|
|---|
| 559 | 'callback_method' => 'callback_datetime'
|
|---|
| 560 | );
|
|---|
| 561 | $this->field_map[] = array(
|
|---|
| 562 | 'from_tablename' => 'reply',
|
|---|
| 563 | 'from_fieldname' => 'publishdate',
|
|---|
| 564 | 'to_type' => 'comment',
|
|---|
| 565 | 'to_fieldname' => 'post_modified_gmt',
|
|---|
| 566 | 'callback_method' => 'callback_datetime'
|
|---|
| 567 | );
|
|---|
| 568 |
|
|---|
| 569 | /** User Section ******************************************************/
|
|---|
| 570 |
|
|---|
| 571 | // Store old User id (Stored in usermeta)
|
|---|
| 572 | $this->field_map[] = array(
|
|---|
| 573 | 'from_tablename' => 'user',
|
|---|
| 574 | 'from_fieldname' => 'userid',
|
|---|
| 575 | 'to_type' => 'user',
|
|---|
| 576 | 'to_fieldname' => '_bbp_user_id'
|
|---|
| 577 | );
|
|---|
| 578 |
|
|---|
| 579 | // Store old User password (Stored in usermeta serialized with salt)
|
|---|
| 580 | $this->field_map[] = array(
|
|---|
| 581 | 'from_tablename' => 'user',
|
|---|
| 582 | 'from_fieldname' => 'password',
|
|---|
| 583 | 'to_type' => 'user',
|
|---|
| 584 | 'to_fieldname' => '_bbp_password',
|
|---|
| 585 | 'callback_method' => 'callback_savepass'
|
|---|
| 586 | );
|
|---|
| 587 |
|
|---|
| 588 | // Store old User Salt (This is only used for the SELECT row info for the above password save)
|
|---|
| 589 | $this->field_map[] = array(
|
|---|
| 590 | 'from_tablename' => 'user',
|
|---|
| 591 | 'from_fieldname' => 'salt',
|
|---|
| 592 | 'to_type' => 'user',
|
|---|
| 593 | 'to_fieldname' => ''
|
|---|
| 594 | );
|
|---|
| 595 |
|
|---|
| 596 | // User password verify class (Stored in usermeta for verifying password)
|
|---|
| 597 | $this->field_map[] = array(
|
|---|
| 598 | 'to_type' => 'user',
|
|---|
| 599 | 'to_fieldname' => '_bbp_class',
|
|---|
| 600 | 'default' => 'vBulletin5'
|
|---|
| 601 | );
|
|---|
| 602 |
|
|---|
| 603 | // User name.
|
|---|
| 604 | $this->field_map[] = array(
|
|---|
| 605 | 'from_tablename' => 'user',
|
|---|
| 606 | 'from_fieldname' => 'username',
|
|---|
| 607 | 'to_type' => 'user',
|
|---|
| 608 | 'to_fieldname' => 'user_login'
|
|---|
| 609 | );
|
|---|
| 610 |
|
|---|
| 611 | // User email.
|
|---|
| 612 | $this->field_map[] = array(
|
|---|
| 613 | 'from_tablename' => 'user',
|
|---|
| 614 | 'from_fieldname' => 'email',
|
|---|
| 615 | 'to_type' => 'user',
|
|---|
| 616 | 'to_fieldname' => 'user_email'
|
|---|
| 617 | );
|
|---|
| 618 |
|
|---|
| 619 | // User homepage.
|
|---|
| 620 | $this->field_map[] = array(
|
|---|
| 621 | 'from_tablename' => 'user',
|
|---|
| 622 | 'from_fieldname' => 'homepage',
|
|---|
| 623 | 'to_type' => 'user',
|
|---|
| 624 | 'to_fieldname' => 'user_url'
|
|---|
| 625 | );
|
|---|
| 626 |
|
|---|
| 627 | // User registered.
|
|---|
| 628 | $this->field_map[] = array(
|
|---|
| 629 | 'from_tablename' => 'user',
|
|---|
| 630 | 'from_fieldname' => 'joindate',
|
|---|
| 631 | 'to_type' => 'user',
|
|---|
| 632 | 'to_fieldname' => 'user_registered',
|
|---|
| 633 | 'callback_method' => 'callback_datetime'
|
|---|
| 634 | );
|
|---|
| 635 |
|
|---|
| 636 | // User AIM (Stored in usermeta)
|
|---|
| 637 | $this->field_map[] = array(
|
|---|
| 638 | 'from_tablename' => 'user',
|
|---|
| 639 | 'from_fieldname' => 'aim',
|
|---|
| 640 | 'to_type' => 'user',
|
|---|
| 641 | 'to_fieldname' => 'aim'
|
|---|
| 642 | );
|
|---|
| 643 |
|
|---|
| 644 | // User Yahoo (Stored in usermeta)
|
|---|
| 645 | $this->field_map[] = array(
|
|---|
| 646 | 'from_tablename' => 'user',
|
|---|
| 647 | 'from_fieldname' => 'yahoo',
|
|---|
| 648 | 'to_type' => 'user',
|
|---|
| 649 | 'to_fieldname' => 'yim'
|
|---|
| 650 | );
|
|---|
| 651 |
|
|---|
| 652 | // User ICQ (Stored in usermeta)
|
|---|
| 653 | $this->field_map[] = array(
|
|---|
| 654 | 'from_tablename' => 'user',
|
|---|
| 655 | 'from_fieldname' => 'icq',
|
|---|
| 656 | 'to_type' => 'user',
|
|---|
| 657 | 'to_fieldname' => '_bbp_vbulletin5_user_icq'
|
|---|
| 658 | );
|
|---|
| 659 |
|
|---|
| 660 | // User MSN (Stored in usermeta)
|
|---|
| 661 | $this->field_map[] = array(
|
|---|
| 662 | 'from_tablename' => 'user',
|
|---|
| 663 | 'from_fieldname' => 'msn',
|
|---|
| 664 | 'to_type' => 'user',
|
|---|
| 665 | 'to_fieldname' => '_bbp_vbulletin5_user_msn'
|
|---|
| 666 | );
|
|---|
| 667 |
|
|---|
| 668 | // User Skype (Stored in usermeta)
|
|---|
| 669 | $this->field_map[] = array(
|
|---|
| 670 | 'from_tablename' => 'user',
|
|---|
| 671 | 'from_fieldname' => 'skype',
|
|---|
| 672 | 'to_type' => 'user',
|
|---|
| 673 | 'to_fieldname' => '_bbp_vbulletin5_user_skype'
|
|---|
| 674 | );
|
|---|
| 675 | }
|
|---|
| 676 |
|
|---|
| 677 | /**
|
|---|
| 678 | * This method allows us to indicates what is or is not converted for each
|
|---|
| 679 | * converter.
|
|---|
| 680 | */
|
|---|
| 681 | public function info() {
|
|---|
| 682 | return '';
|
|---|
| 683 | }
|
|---|
| 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( 'hash' => $field, 'salt' => $row['salt'] );
|
|---|
| 693 | return $pass_array;
|
|---|
| 694 | }
|
|---|
| 695 |
|
|---|
| 696 | /**
|
|---|
| 697 | * This method is to take the pass out of the database and compare
|
|---|
| 698 | * to a pass the user has typed in.
|
|---|
| 699 | *
|
|---|
| 700 | * vBulletin v5.x passwords do not work. Maybe use the below plugin's approach?
|
|---|
| 701 | *
|
|---|
| 702 | * @link http://wordpress.org/extend/plugins/vb-user-copy/
|
|---|
| 703 | * @link http://plugins.trac.wordpress.org/browser/vb-user-copy/trunk/vb_user_copy.php
|
|---|
| 704 | */
|
|---|
| 705 | public function authenticate_pass( $password, $serialized_pass ) {
|
|---|
| 706 | $pass_array = unserialize( $serialized_pass );
|
|---|
| 707 | return ( $pass_array['hash'] == md5( md5( $password ) . $pass_array['salt'] ) );
|
|---|
| 708 | }
|
|---|
| 709 |
|
|---|
| 710 | /**
|
|---|
| 711 | * Verify the topic reply count.
|
|---|
| 712 | *
|
|---|
| 713 | * @param int $count vBulletin v5.x reply count
|
|---|
| 714 | * @return string WordPress safe
|
|---|
| 715 | */
|
|---|
| 716 | public function callback_topic_reply_count( $count = 1 ) {
|
|---|
| 717 | $count = absint( (int) $count - 1 );
|
|---|
| 718 | return $count;
|
|---|
| 719 | }
|
|---|
| 720 |
|
|---|
| 721 | /**
|
|---|
| 722 | * Set the reply title
|
|---|
| 723 | *
|
|---|
| 724 | * @param string $title PHPFox v3.5.x topic title of this reply
|
|---|
| 725 | * @return string Prefixed topic title, or empty string
|
|---|
| 726 | */
|
|---|
| 727 | public function callback_reply_title( $title = '' ) {
|
|---|
| 728 | $title = !empty( $title ) ? __( 'Re: ', 'bbpress' ) . html_entity_decode( $title ) : '';
|
|---|
| 729 | return $title;
|
|---|
| 730 | }
|
|---|
| 731 |
|
|---|
| 732 | /**
|
|---|
| 733 | * Translate the post status from vBulletin v5.x numeric's to WordPress's strings.
|
|---|
| 734 | *
|
|---|
| 735 | * @param int $status vBulletin v5.x numeric topic status
|
|---|
| 736 | * @return string WordPress safe
|
|---|
| 737 | */
|
|---|
| 738 | public function callback_topic_status( $status = 1 ) {
|
|---|
| 739 | switch ( $status ) {
|
|---|
| 740 | case 0 :
|
|---|
| 741 | $status = 'closed';
|
|---|
| 742 | break;
|
|---|
| 743 |
|
|---|
| 744 | case 1 :
|
|---|
| 745 | default :
|
|---|
| 746 | $status = 'publish';
|
|---|
| 747 | break;
|
|---|
| 748 | }
|
|---|
| 749 | return $status;
|
|---|
| 750 | }
|
|---|
| 751 |
|
|---|
| 752 | /**
|
|---|
| 753 | * This callback processes any custom parser.php attributes and custom code with preg_replace
|
|---|
| 754 | */
|
|---|
| 755 | protected function callback_html( $field ) {
|
|---|
| 756 |
|
|---|
| 757 | // Strips vBulletin v5.x custom HTML first from $field before parsing $field to parser.php
|
|---|
| 758 | $vbulletin_markup = $field;
|
|---|
| 759 | $vbulletin_markup = html_entity_decode( $vbulletin_markup );
|
|---|
| 760 |
|
|---|
| 761 | // Replace '[QUOTE]' with '<blockquote>'
|
|---|
| 762 | $vbulletin_markup = preg_replace( '/\[QUOTE\]/', '<blockquote>', $vbulletin_markup );
|
|---|
| 763 | // Replace '[QUOTE=User Name($1);PostID($2)]' with '<em>@$1 $2 wrote:</em><blockquote>"
|
|---|
| 764 | $vbulletin_markup = preg_replace( '/\[QUOTE=(.*?);(.*?)\]/' , '<em>@$1 $2 wrote:</em><blockquote>', $vbulletin_markup );
|
|---|
| 765 | // Replace '[/QUOTE]' with '</blockquote>'
|
|---|
| 766 | $vbulletin_markup = preg_replace( '/\[\/QUOTE\]/', '</blockquote>', $vbulletin_markup );
|
|---|
| 767 | // Replace '[MENTION=###($1)]User Name($2)[/MENTION]' with '@$2"
|
|---|
| 768 | $vbulletin_markup = preg_replace( '/\[MENTION=(.*?)\](.*?)\[\/MENTION\]/', '@$2', $vbulletin_markup );
|
|---|
| 769 |
|
|---|
| 770 | // Replace '[video=youtube;$1]$2[/video]' with '$2"
|
|---|
| 771 | $vbulletin_markup = preg_replace( '/\[video\=youtube;(.*?)\](.*?)\[\/video\]/', '$2', $vbulletin_markup );
|
|---|
| 772 |
|
|---|
| 773 | // Now that vBulletin v5.x custom HTML has been stripped put the cleaned HTML back in $field
|
|---|
| 774 | $field = $vbulletin_markup;
|
|---|
| 775 |
|
|---|
| 776 | // Parse out any bbCodes in $field with the BBCode 'parser.php'
|
|---|
| 777 | require_once( bbpress()->admin->admin_dir . 'parser.php' );
|
|---|
| 778 | $bbcode = BBCode::getInstance();
|
|---|
| 779 | $bbcode->enable_smileys = false;
|
|---|
| 780 | $bbcode->smiley_regex = false;
|
|---|
| 781 | return html_entity_decode( $bbcode->Parse( $field ) );
|
|---|
| 782 | }
|
|---|
| 783 |
|
|---|
| 784 | }
|
|---|