PunBB

Implementation of PunBB v1.4.2 Forum converter.

Defined (1)

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

/includes/admin/converters/PunBB.php  
  1. class PunBB extends BBP_Converter_Base { 
  2.  
  3. /** 
  4. * Main Constructor 
  5. * @uses PunBB::setup_globals() 
  6. */ 
  7. function __construct() { 
  8. parent::__construct(); 
  9. $this->setup_globals(); 
  10.  
  11. /** 
  12. * Sets up the field mappings 
  13. */ 
  14. public function setup_globals() { 
  15.  
  16. /** Forum Section *****************************************************/ 
  17.  
  18. // Forum id (Stored in postmeta) 
  19. $this->field_map[] = array( 
  20. 'from_tablename' => 'forums',  
  21. 'from_fieldname' => 'id',  
  22. 'to_type' => 'forum',  
  23. 'to_fieldname' => '_bbp_forum_id' 
  24. ); 
  25.  
  26. // Forum topic count (Stored in postmeta) 
  27. $this->field_map[] = array( 
  28. 'from_tablename' => 'forums',  
  29. 'from_fieldname' => 'num_topics',  
  30. 'to_type' => 'forum',  
  31. 'to_fieldname' => '_bbp_topic_count' 
  32. ); 
  33.  
  34. // Forum reply count (Stored in postmeta) 
  35. $this->field_map[] = array( 
  36. 'from_tablename' => 'forums',  
  37. 'from_fieldname' => 'num_posts',  
  38. 'to_type' => 'forum',  
  39. 'to_fieldname' => '_bbp_reply_count' 
  40. ); 
  41.  
  42. // Forum total topic count (Includes unpublished topics, Stored in postmeta) 
  43. $this->field_map[] = array( 
  44. 'from_tablename' => 'forums',  
  45. 'from_fieldname' => 'num_topics',  
  46. 'to_type' => 'forum',  
  47. 'to_fieldname' => '_bbp_total_topic_count' 
  48. ); 
  49.  
  50. // Forum total reply count (Includes unpublished replies, Stored in postmeta) 
  51. $this->field_map[] = array( 
  52. 'from_tablename' => 'forums',  
  53. 'from_fieldname' => 'num_posts',  
  54. 'to_type' => 'forum',  
  55. 'to_fieldname' => '_bbp_total_reply_count' 
  56. ); 
  57.  
  58. // Forum title. 
  59. $this->field_map[] = array( 
  60. 'from_tablename' => 'forums',  
  61. 'from_fieldname' => 'forum_name',  
  62. 'to_type' => 'forum',  
  63. 'to_fieldname' => 'post_title' 
  64. ); 
  65.  
  66. // Forum slug (Clean name to avoid conflicts) 
  67. $this->field_map[] = array( 
  68. 'from_tablename' => 'forums',  
  69. 'from_fieldname' => 'forum_name',  
  70. 'to_type' => 'forum',  
  71. 'to_fieldname' => 'post_name',  
  72. 'callback_method' => 'callback_slug' 
  73. ); 
  74.  
  75. // Forum description. 
  76. $this->field_map[] = array( 
  77. 'from_tablename' => 'forums',  
  78. 'from_fieldname' => 'forum_desc',  
  79. 'to_type' => 'forum',  
  80. 'to_fieldname' => 'post_content',  
  81. 'callback_method' => 'callback_null' 
  82. ); 
  83.  
  84. // Forum display order (Starts from 1) 
  85. $this->field_map[] = array( 
  86. 'from_tablename' => 'forums',  
  87. 'from_fieldname' => 'disp_position',  
  88. 'to_type' => 'forum',  
  89. 'to_fieldname' => 'menu_order' 
  90. ); 
  91.  
  92. // Forum dates. 
  93. $this->field_map[] = array( 
  94. 'to_type' => 'forum',  
  95. 'to_fieldname' => 'post_date',  
  96. 'default' => date('Y-m-d H:i:s') 
  97. ); 
  98. $this->field_map[] = array( 
  99. 'to_type' => 'forum',  
  100. 'to_fieldname' => 'post_date_gmt',  
  101. 'default' => date('Y-m-d H:i:s') 
  102. ); 
  103. $this->field_map[] = array( 
  104. 'to_type' => 'forum',  
  105. 'to_fieldname' => 'post_modified',  
  106. 'default' => date('Y-m-d H:i:s') 
  107. ); 
  108. $this->field_map[] = array( 
  109. 'to_type' => 'forum',  
  110. 'to_fieldname' => 'post_modified_gmt',  
  111. 'default' => date('Y-m-d H:i:s') 
  112. ); 
  113.  
  114. /** Topic Section *****************************************************/ 
  115.  
  116. // Topic id (Stored in postmeta) 
  117. $this->field_map[] = array( 
  118. 'from_tablename' => 'topics',  
  119. 'from_fieldname' => 'id',  
  120. 'to_type' => 'topic',  
  121. 'to_fieldname' => '_bbp_topic_id' 
  122. ); 
  123.  
  124. // Topic reply count (Stored in postmeta) 
  125. $this->field_map[] = array( 
  126. 'from_tablename' => 'topics',  
  127. 'from_fieldname' => 'num_replies',  
  128. 'to_type' => 'topic',  
  129. 'to_fieldname' => '_bbp_reply_count',  
  130. 'callback_method' => 'callback_topic_reply_count' 
  131. ); 
  132.  
  133. // Topic total reply count (Includes unpublished replies, Stored in postmeta) 
  134. $this->field_map[] = array( 
  135. 'from_tablename' => 'topics',  
  136. 'from_fieldname' => 'num_replies',  
  137. 'to_type' => 'topic',  
  138. 'to_fieldname' => '_bbp_total_reply_count',  
  139. 'callback_method' => 'callback_topic_reply_count' 
  140. ); 
  141.  
  142. // Topic parent forum id (If no parent, then 0. Stored in postmeta) 
  143. $this->field_map[] = array( 
  144. 'from_tablename' => 'topics',  
  145. 'from_fieldname' => 'forum_id',  
  146. 'to_type' => 'topic',  
  147. 'to_fieldname' => '_bbp_forum_id',  
  148. 'callback_method' => 'callback_forumid' 
  149. ); 
  150.  
  151. // Topic author. 
  152. // Note: We join the 'posts' table because 'topics' table does not have user id's. 
  153. $this->field_map[] = array( 
  154. 'from_tablename' => 'posts',  
  155. 'from_fieldname' => 'poster_id',  
  156. 'join_tablename' => 'topics',  
  157. 'join_type' => 'LEFT',  
  158. 'join_expression' => 'ON topics.first_post_id = posts.id',  
  159. 'to_type' => 'topic',  
  160. 'to_fieldname' => 'post_author',  
  161. 'callback_method' => 'callback_userid' 
  162. ); 
  163.  
  164. // Topic Author ip (Stored in postmeta) 
  165. // Note: We join the 'posts' table because 'topics' table does not have author ip. 
  166. $this->field_map[] = array( 
  167. 'from_tablename' => 'posts',  
  168. 'from_fieldname' => 'poster_ip',  
  169. 'join_tablename' => 'topics',  
  170. 'join_type' => 'LEFT',  
  171. 'join_expression' => 'ON topics.first_post_id = posts.id',  
  172. 'to_type' => 'topic',  
  173. 'to_fieldname' => '_bbp_author_ip' 
  174. ); 
  175.  
  176. // Topic content. 
  177. // Note: We join the 'posts' table because 'topics' table does not have content. 
  178. $this->field_map[] = array( 
  179. 'from_tablename' => 'posts',  
  180. 'from_fieldname' => 'message',  
  181. 'join_tablename' => 'topics',  
  182. 'join_type' => 'LEFT',  
  183. 'join_expression' => 'ON topics.first_post_id = posts.id',  
  184. 'to_type' => 'topic',  
  185. 'to_fieldname' => 'post_content',  
  186. 'callback_method' => 'callback_html' 
  187. ); 
  188.  
  189. // Topic title. 
  190. $this->field_map[] = array( 
  191. 'from_tablename' => 'topics',  
  192. 'from_fieldname' => 'subject',  
  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' => 'topics',  
  200. 'from_fieldname' => 'subject',  
  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' => 'topics',  
  209. 'from_fieldname' => 'forum_id',  
  210. 'to_type' => 'topic',  
  211. 'to_fieldname' => 'post_parent',  
  212. 'callback_method' => 'callback_forumid' 
  213. ); 
  214.  
  215. // Topic status (Open or Closed, PunBB v1.4.2 0=open & 1=closed) 
  216. $this->field_map[] = array( 
  217. 'from_tablename' => 'topics',  
  218. 'from_fieldname' => 'closed',  
  219. 'to_type' => 'topic',  
  220. 'to_fieldname' => 'post_status',  
  221. 'callback_method' => 'callback_topic_status' 
  222. ); 
  223.  
  224. // Sticky status (Stored in postmeta)) 
  225. $this->field_map[] = array( 
  226. 'from_tablename' => 'topics',  
  227. 'from_fieldname' => 'sticky',  
  228. 'to_type' => 'topic',  
  229. 'to_fieldname' => '_bbp_old_sticky_status',  
  230. 'callback_method' => 'callback_sticky_status' 
  231. ); 
  232. // Topic dates. 
  233. $this->field_map[] = array( 
  234. 'from_tablename' => 'topics',  
  235. 'from_fieldname' => 'posted',  
  236. 'to_type' => 'topic',  
  237. 'to_fieldname' => 'post_date',  
  238. 'callback_method' => 'callback_datetime' 
  239. ); 
  240. $this->field_map[] = array( 
  241. 'from_tablename' => 'topics',  
  242. 'from_fieldname' => 'posted',  
  243. 'to_type' => 'topic',  
  244. 'to_fieldname' => 'post_date_gmt',  
  245. 'callback_method' => 'callback_datetime' 
  246. ); 
  247. $this->field_map[] = array( 
  248. 'from_tablename' => 'topics',  
  249. 'from_fieldname' => 'last_post',  
  250. 'to_type' => 'topic',  
  251. 'to_fieldname' => 'post_modified',  
  252. 'callback_method' => 'callback_datetime' 
  253. ); 
  254. $this->field_map[] = array( 
  255. 'from_tablename' => 'topics',  
  256. 'from_fieldname' => 'last_post',  
  257. 'to_type' => 'topic',  
  258. 'to_fieldname' => 'post_modified_gmt',  
  259. 'callback_method' => 'callback_datetime' 
  260. ); 
  261. $this->field_map[] = array( 
  262. 'from_tablename' => 'topics',  
  263. 'from_fieldname' => 'last_post',  
  264. 'to_type' => 'topic',  
  265. 'to_fieldname' => '_bbp_last_active_time',  
  266. 'callback_method' => 'callback_datetime' 
  267. ); 
  268.  
  269. /** Tags Section ******************************************************/ 
  270.  
  271. /** 
  272. * PunBB v1.4.2 Forums do not support topic tags out of the box 
  273. */ 
  274.  
  275. /** Reply Section *****************************************************/ 
  276.  
  277. // Reply id (Stored in postmeta) 
  278. $this->field_map[] = array( 
  279. 'from_tablename' => 'posts',  
  280. 'from_fieldname' => 'id',  
  281. 'to_type' => 'reply',  
  282. 'to_fieldname' => '_bbp_post_id' 
  283. ); 
  284.  
  285. // Reply parent forum id (If no parent, then 0. Stored in postmeta) 
  286. // Note: We join the 'topics' table because 'posts' table does not have parent forum id's. 
  287. $this->field_map[] = array( 
  288. 'from_tablename' => 'topics',  
  289. 'from_fieldname' => 'forum_id',  
  290. 'join_tablename' => 'posts',  
  291. 'join_type' => 'LEFT',  
  292. 'join_expression' => 'ON topics.id = posts.topic_id WHERE topics.first_post_id != posts.id',  
  293. 'to_type' => 'reply',  
  294. 'to_fieldname' => '_bbp_forum_id',  
  295. 'callback_method' => 'callback_topicid_to_forumid' 
  296. ); 
  297.  
  298. // Reply parent topic id (If no parent, then 0. Stored in postmeta) 
  299. $this->field_map[] = array( 
  300. 'from_tablename' => 'posts',  
  301. 'from_fieldname' => 'topic_id',  
  302. 'to_type' => 'reply',  
  303. 'to_fieldname' => '_bbp_topic_id',  
  304. 'callback_method' => 'callback_topicid' 
  305. ); 
  306.  
  307. // Reply author ip (Stored in postmeta) 
  308. $this->field_map[] = array( 
  309. 'from_tablename' => 'posts',  
  310. 'from_fieldname' => 'poster_ip',  
  311. 'to_type' => 'reply',  
  312. 'to_fieldname' => '_bbp_author_ip' 
  313. ); 
  314.  
  315. // Reply author. 
  316. $this->field_map[] = array( 
  317. 'from_tablename' => 'posts',  
  318. 'from_fieldname' => 'poster_id',  
  319. 'to_type' => 'reply',  
  320. 'to_fieldname' => 'post_author',  
  321. 'callback_method' => 'callback_userid' 
  322. ); 
  323.  
  324. // Reply title. 
  325. // Note: We join the 'topics' table because 'posts' table does not have topic subject. 
  326. $this->field_map[] = array( 
  327. 'from_tablename' => 'topics',  
  328. 'from_fieldname' => 'subject',  
  329. 'join_tablename' => 'posts',  
  330. 'join_type' => 'LEFT',  
  331. 'join_expression' => 'ON topics.id = posts.topic_id WHERE topics.first_post_id != posts.id',  
  332. 'to_type' => 'reply',  
  333. 'to_fieldname' => 'post_title',  
  334. 'callback_method' => 'callback_reply_title' 
  335. ); 
  336.  
  337. // Reply slug (Clean name to avoid conflicts) 
  338. // Note: We join the 'topics' table because 'posts' table does not have topic subject. 
  339. $this->field_map[] = array( 
  340. 'from_tablename' => 'topics',  
  341. 'from_fieldname' => 'subject',  
  342. 'join_tablename' => 'posts',  
  343. 'join_type' => 'LEFT',  
  344. 'join_expression' => 'ON topics.id = posts.topic_id WHERE topics.first_post_id != posts.id',  
  345. 'to_type' => 'reply',  
  346. 'to_fieldname' => 'post_name',  
  347. 'callback_method' => 'callback_slug' 
  348. ); 
  349.  
  350. // Reply content. 
  351. $this->field_map[] = array( 
  352. 'from_tablename' => 'posts',  
  353. 'from_fieldname' => 'message',  
  354. 'to_type' => 'reply',  
  355. 'to_fieldname' => 'post_content',  
  356. 'callback_method' => 'callback_html' 
  357. ); 
  358.  
  359. // Reply parent topic id (If no parent, then 0) 
  360. $this->field_map[] = array( 
  361. 'from_tablename' => 'posts',  
  362. 'from_fieldname' => 'topic_id',  
  363. 'to_type' => 'reply',  
  364. 'to_fieldname' => 'post_parent',  
  365. 'callback_method' => 'callback_topicid' 
  366. ); 
  367.  
  368. // Reply dates. 
  369. $this->field_map[] = array( 
  370. 'from_tablename' => 'posts',  
  371. 'from_fieldname' => 'posted',  
  372. 'to_type' => 'reply',  
  373. 'to_fieldname' => 'post_date',  
  374. 'callback_method' => 'callback_datetime' 
  375. ); 
  376. $this->field_map[] = array( 
  377. 'from_tablename' => 'posts',  
  378. 'from_fieldname' => 'posted',  
  379. 'to_type' => 'reply',  
  380. 'to_fieldname' => 'post_date_gmt',  
  381. 'callback_method' => 'callback_datetime' 
  382. ); 
  383. $this->field_map[] = array( 
  384. 'from_tablename' => 'posts',  
  385. 'from_fieldname' => 'edited',  
  386. 'to_type' => 'reply',  
  387. 'to_fieldname' => 'post_modified',  
  388. 'callback_method' => 'callback_datetime' 
  389. ); 
  390. $this->field_map[] = array( 
  391. 'from_tablename' => 'posts',  
  392. 'from_fieldname' => 'edited',  
  393. 'to_type' => 'reply',  
  394. 'to_fieldname' => 'post_modified_gmt',  
  395. 'callback_method' => 'callback_datetime' 
  396. ); 
  397.  
  398. /** User Section ******************************************************/ 
  399.  
  400. // Store old User id (Stored in usermeta) 
  401. $this->field_map[] = array( 
  402. 'from_tablename' => 'users',  
  403. 'from_fieldname' => 'id',  
  404. 'to_type' => 'user',  
  405. 'to_fieldname' => '_bbp_user_id' 
  406. ); 
  407.  
  408. // Store old User password (Stored in usermeta serialized with salt) 
  409. $this->field_map[] = array( 
  410. 'from_tablename' => 'users',  
  411. 'from_fieldname' => 'password',  
  412. 'to_type' => 'user',  
  413. 'to_fieldname' => '_bbp_password',  
  414. 'callback_method' => 'callback_savepass' 
  415. ); 
  416.  
  417. // Store old User Salt (This is only used for the SELECT row info for the above password save) 
  418. $this->field_map[] = array( 
  419. 'from_tablename' => 'users',  
  420. 'from_fieldname' => 'salt',  
  421. 'to_type' => 'user',  
  422. 'to_fieldname' => '' 
  423. ); 
  424.  
  425. // User password verify class (Stored in usermeta for verifying password) 
  426. $this->field_map[] = array( 
  427. 'to_type' => 'users',  
  428. 'to_fieldname' => '_bbp_class',  
  429. 'default' => 'PunBB' 
  430. ); 
  431.  
  432. // User name. 
  433. $this->field_map[] = array( 
  434. 'from_tablename' => 'users',  
  435. 'from_fieldname' => 'username',  
  436. 'to_type' => 'user',  
  437. 'to_fieldname' => 'user_login' 
  438. ); 
  439.  
  440. // User nice name. 
  441. $this->field_map[] = array( 
  442. 'from_tablename' => 'users',  
  443. 'from_fieldname' => 'username',  
  444. 'to_type' => 'user',  
  445. 'to_fieldname' => 'user_nicename' 
  446. ); 
  447.  
  448. // User email. 
  449. $this->field_map[] = array( 
  450. 'from_tablename' => 'users',  
  451. 'from_fieldname' => 'email',  
  452. 'to_type' => 'user',  
  453. 'to_fieldname' => 'user_email' 
  454. ); 
  455.  
  456. // User homepage. 
  457. $this->field_map[] = array( 
  458. 'from_tablename' => 'users',  
  459. 'from_fieldname' => 'url',  
  460. 'to_type' => 'user',  
  461. 'to_fieldname' => 'user_url' 
  462. ); 
  463.  
  464. // User registered. 
  465. $this->field_map[] = array( 
  466. 'from_tablename' => 'users',  
  467. 'from_fieldname' => 'registered',  
  468. 'to_type' => 'user',  
  469. 'to_fieldname' => 'user_registered',  
  470. 'callback_method' => 'callback_datetime' 
  471. ); 
  472.  
  473. // User display name. 
  474. $this->field_map[] = array( 
  475. 'from_tablename' => 'users',  
  476. 'from_fieldname' => 'realname',  
  477. 'to_type' => 'user',  
  478. 'to_fieldname' => 'display_name' 
  479. ); 
  480.  
  481. // User AIM (Stored in usermeta) 
  482. $this->field_map[] = array( 
  483. 'from_tablename' => 'users',  
  484. 'from_fieldname' => 'aim',  
  485. 'to_type' => 'user',  
  486. 'to_fieldname' => 'aim' 
  487. ); 
  488.  
  489. // User Yahoo (Stored in usermeta) 
  490. $this->field_map[] = array( 
  491. 'from_tablename' => 'users',  
  492. 'from_fieldname' => 'yahoo',  
  493. 'to_type' => 'user',  
  494. 'to_fieldname' => 'yim' 
  495. ); 
  496.  
  497. // Store Jabber 
  498. $this->field_map[] = array( 
  499. 'from_tablename' => 'users',  
  500. 'from_fieldname' => 'jabber',  
  501. 'to_type' => 'user',  
  502. 'to_fieldname' => 'jabber' 
  503. ); 
  504.  
  505. // Store ICQ (Stored in usermeta) 
  506. $this->field_map[] = array( 
  507. 'from_tablename' => 'users',  
  508. 'from_fieldname' => 'icq',  
  509. 'to_type' => 'user',  
  510. 'to_fieldname' => '_bbp_punbb_user_icq' 
  511. ); 
  512.  
  513. // Store MSN (Stored in usermeta) 
  514. $this->field_map[] = array( 
  515. 'from_tablename' => 'users',  
  516. 'from_fieldname' => 'msn',  
  517. 'to_type' => 'user',  
  518. 'to_fieldname' => '_bbp_punbb_user_msn' 
  519. ); 
  520.  
  521. // Store Facebook (Stored in usermeta) 
  522. $this->field_map[] = array( 
  523. 'from_tablename' => 'users',  
  524. 'from_fieldname' => 'facebook',  
  525. 'to_type' => 'user',  
  526. 'to_fieldname' => '_bbp_punbb_user_facebook' 
  527. ); 
  528.  
  529. // Store Twitter (Stored in usermeta) 
  530. $this->field_map[] = array( 
  531. 'from_tablename' => 'users',  
  532. 'from_fieldname' => 'twitter',  
  533. 'to_type' => 'user',  
  534. 'to_fieldname' => '_bbp_punbb_user_twitter' 
  535. ); 
  536.  
  537. // Store LinkedIn (Stored in usermeta) 
  538. $this->field_map[] = array( 
  539. 'from_tablename' => 'users',  
  540. 'from_fieldname' => 'linkedin',  
  541. 'to_type' => 'user',  
  542. 'to_fieldname' => '_bbp_punbb_user_linkedin' 
  543. ); 
  544.  
  545. // Store Skype (Stored in usermeta) 
  546. $this->field_map[] = array( 
  547. 'from_tablename' => 'users',  
  548. 'from_fieldname' => 'skype',  
  549. 'to_type' => 'user',  
  550. 'to_fieldname' => '_bbp_punbb_user_skype' 
  551. ); 
  552.  
  553. // Store Signature (Stored in usermeta) 
  554. $this->field_map[] = array( 
  555. 'from_tablename' => 'users',  
  556. 'from_fieldname' => 'signature',  
  557. 'to_type' => 'user',  
  558. 'to_fieldname' => '_bbp_punbb_user_sig',  
  559. 'callback_method' => 'callback_html' 
  560. ); 
  561.  
  562. // Store Location (Stored in usermeta) 
  563. $this->field_map[] = array( 
  564. 'from_tablename' => 'users',  
  565. 'from_fieldname' => 'location',  
  566. 'to_type' => 'user',  
  567. 'to_fieldname' => '_bbp_punbb_user_from' 
  568. ); 
  569.  
  570. // Store Admin Note (Stored in usermeta) 
  571. $this->field_map[] = array( 
  572. 'from_tablename' => 'users',  
  573. 'from_fieldname' => 'admin_note',  
  574. 'to_type' => 'user',  
  575. 'to_fieldname' => '_bbp_punbb_user_admin_note' 
  576. ); 
  577.  
  578. /** 
  579. * This method allows us to indicates what is or is not converted for each 
  580. * converter. 
  581. */ 
  582. public function info() 
  583. return ''; 
  584.  
  585. /** 
  586. * This method is to save the salt and password together. That 
  587. * way when we authenticate it we can get it out of the database 
  588. * as one value. Array values are auto sanitized by WordPress. 
  589. */ 
  590. public function callback_savepass( $field, $row ) 
  591. $pass_array = array( 'hash' => $field, 'salt' => $row['salt'] ); 
  592. return $pass_array; 
  593.  
  594. /** 
  595. * This method is to take the pass out of the database and compare 
  596. * to a pass the user has typed in. 
  597. */ 
  598. public function authenticate_pass( $password, $serialized_pass ) 
  599. $pass_array = unserialize( $serialized_pass ); 
  600. return ( $pass_array['hash'] == md5( md5( $password ). $pass_array['salt'] ) ); 
  601.  
  602. /** 
  603. * Translate the post status from PunBB v1.4.2 numeric's to WordPress's strings. 
  604. * @param int $status PunBB v1.4.2 numeric topic status 
  605. * @return string WordPress safe 
  606. */ 
  607. public function callback_topic_status( $status = 0 ) { 
  608. switch ( $status ) { 
  609. case 1 : 
  610. $status = 'closed'; 
  611. break; 
  612.  
  613. case 0 : 
  614. default : 
  615. $status = 'publish'; 
  616. break; 
  617. return $status; 
  618.  
  619. /** 
  620. * Translate the topic sticky status type from PunBB v1.4.2 numeric's to WordPress's strings. 
  621. * @param int $status PunBB v1.4.2 numeric forum type 
  622. * @return string WordPress safe 
  623. */ 
  624. public function callback_sticky_status( $status = 0 ) { 
  625. switch ( $status ) { 
  626. case 1 : 
  627. $status = 'sticky'; // PunBB Sticky 'topic_sticky = 1' 
  628. break; 
  629.  
  630. case 0 : 
  631. default : 
  632. $status = 'normal'; // PunBB Normal Topic 'topic_sticky = 0' 
  633. break; 
  634. return $status; 
  635.  
  636. /** 
  637. * Verify the topic/reply count. 
  638. * @param int $count PunBB v1.4.2 topic/reply counts 
  639. * @return string WordPress safe 
  640. */ 
  641. public function callback_topic_reply_count( $count = 1 ) { 
  642. $count = absint( (int) $count - 1 ); 
  643. return $count; 
  644.  
  645. /** 
  646. * Set the reply title 
  647. * @param string $title PunBB v1.4.2 topic title of this reply 
  648. * @return string Prefixed topic title, or empty string 
  649. */ 
  650. public function callback_reply_title( $title = '' ) { 
  651. $title = !empty( $title ) ? __( 'Re: ', 'bbpress' ) . html_entity_decode( $title ) : ''; 
  652. return $title;