vBulletin3

Implementation of vBulletin v3.x Converter.

Defined (1)

The class is defined in the following location(s).

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