XenForo

Implementation of XenForo converter.

Defined (1)

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

/includes/admin/converters/XenForo.php  
  1. class XenForo extends BBP_Converter_Base { 
  2.  
  3. /** 
  4. * Main constructor 
  5. * @uses XenForo::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' => 'node',  
  21. 'from_fieldname' => 'node_id',  
  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' => 'node',  
  29. 'from_fieldname' => 'parent_node_id',  
  30. 'to_type' => 'forum',  
  31. 'to_fieldname' => '_bbp_forum_parent_id' 
  32. ); 
  33.  
  34. // Forum topic count (Stored in postmeta) 
  35. // Note: We join the 'forum' table because 'node' does not include topic counts. 
  36. $this->field_map[] = array( 
  37. 'from_tablename' => 'forum',  
  38. 'from_fieldname' => 'discussion_count',  
  39. 'join_tablename' => 'node',  
  40. 'join_type' => 'LEFT',  
  41. 'join_expression' => 'USING (node_id) WHERE node.node_type_id = "Category" OR node.node_type_id = "Forum" ',  
  42. 'to_type' => 'forum',  
  43. 'to_fieldname' => '_bbp_topic_count' 
  44. ); 
  45.  
  46. // Forum reply count (Stored in postmeta) 
  47. // Note: We join the 'forum' table because 'node' does not include reply counts. 
  48. $this->field_map[] = array( 
  49. 'from_tablename' => 'forum',  
  50. 'from_fieldname' => 'message_count',  
  51. 'join_tablename' => 'node',  
  52. 'join_type' => 'LEFT',  
  53. 'join_expression' => 'USING (node_id) WHERE node.node_type_id = "Category" OR node.node_type_id = "Forum" ',  
  54. 'to_type' => 'forum',  
  55. 'to_fieldname' => '_bbp_reply_count' 
  56. ); 
  57.  
  58. // Forum total topic count (Includes unpublished topics, Stored in postmeta) 
  59. // Note: We join the 'forum' table because 'node' does not include topic counts. 
  60. $this->field_map[] = array( 
  61. 'from_tablename' => 'forum',  
  62. 'from_fieldname' => 'discussion_count',  
  63. 'join_tablename' => 'node',  
  64. 'join_type' => 'LEFT',  
  65. 'join_expression' => 'USING (node_id) WHERE node.node_type_id = "Category" OR node.node_type_id = "Forum" ',  
  66. 'to_type' => 'forum',  
  67. 'to_fieldname' => '_bbp_total_topic_count' 
  68. ); 
  69.  
  70. // Forum total reply count (Includes unpublished replies, Stored in postmeta) 
  71. // Note: We join the 'forum' table because 'node' does not include reply counts. 
  72. $this->field_map[] = array( 
  73. 'from_tablename' => 'forum',  
  74. 'from_fieldname' => 'message_count',  
  75. 'join_tablename' => 'node',  
  76. 'join_type' => 'LEFT',  
  77. 'join_expression' => 'USING (node_id) WHERE node.node_type_id = "Category" OR node.node_type_id = "Forum" ',  
  78. 'to_type' => 'forum',  
  79. 'to_fieldname' => '_bbp_total_reply_count' 
  80. ); 
  81.  
  82. // Forum title. 
  83. $this->field_map[] = array( 
  84. 'from_tablename' => 'node',  
  85. 'from_fieldname' => 'title',  
  86. 'to_type' => 'forum',  
  87. 'to_fieldname' => 'post_title' 
  88. ); 
  89.  
  90. // Forum slug (Clean name to avoid confilcts) 
  91. // 'node_name' only has slug for explictly named forums 
  92. $this->field_map[] = array( 
  93. 'from_tablename' => 'node',  
  94. 'from_fieldname' => 'node_name',  
  95. 'to_type' => 'forum',  
  96. 'to_fieldname' => 'post_name',  
  97. 'callback_method' => 'callback_slug' 
  98. ); 
  99.  
  100. // Forum description. 
  101. $this->field_map[] = array( 
  102. 'from_tablename' => 'node',  
  103. 'from_fieldname' => 'description',  
  104. 'to_type' => 'forum',  
  105. 'to_fieldname' => 'post_content',  
  106. 'callback_method' => 'callback_null' 
  107. ); 
  108.  
  109. // Forum display order (Starts from 1) 
  110. $this->field_map[] = array( 
  111. 'from_tablename' => 'node',  
  112. 'from_fieldname' => 'display_order',  
  113. 'to_type' => 'forum',  
  114. 'to_fieldname' => 'menu_order' 
  115. ); 
  116.  
  117. // Forum type (Category = Category or Forum = Forum, Stored in postmeta) 
  118. $this->field_map[] = array( 
  119. 'from_tablename' => 'node',  
  120. 'from_fieldname' => 'node_type_id',  
  121. 'to_type' => 'forum',  
  122. 'to_fieldname' => '_bbp_forum_type',  
  123. 'callback_method' => 'callback_forum_type' 
  124. ); 
  125.  
  126. // Forum status (Unlocked = 1 or Locked = 0, Stored in postmeta) 
  127. // Note: We join the 'forum' table because 'node' does not include forum status. 
  128. $this->field_map[] = array( 
  129. 'from_tablename' => 'forum',  
  130. 'from_fieldname' => 'allow_posting',  
  131. 'join_tablename' => 'node',  
  132. 'join_type' => 'LEFT',  
  133. 'join_expression' => 'USING (node_id) WHERE node.node_type_id = "Category" OR node.node_type_id = "Forum" ',  
  134. 'to_type' => 'forum',  
  135. 'to_fieldname' => '_bbp_status',  
  136. 'callback_method' => 'callback_forum_status' 
  137. ); 
  138.  
  139. // Forum dates. 
  140. $this->field_map[] = array( 
  141. 'to_type' => 'forum',  
  142. 'to_fieldname' => 'post_date',  
  143. 'default' => date('Y-m-d H:i:s') 
  144. ); 
  145. $this->field_map[] = array( 
  146. 'to_type' => 'forum',  
  147. 'to_fieldname' => 'post_date_gmt',  
  148. 'default' => date('Y-m-d H:i:s') 
  149. ); 
  150. $this->field_map[] = array( 
  151. 'to_type' => 'forum',  
  152. 'to_fieldname' => 'post_modified',  
  153. 'default' => date('Y-m-d H:i:s') 
  154. ); 
  155. $this->field_map[] = array( 
  156. 'to_type' => 'forum',  
  157. 'to_fieldname' => 'post_modified_gmt',  
  158. 'default' => date('Y-m-d H:i:s') 
  159. ); 
  160.  
  161. /** Topic Section *****************************************************/ 
  162.  
  163. // Topic id (Stored in postmeta) 
  164. $this->field_map[] = array( 
  165. 'from_tablename' => 'thread',  
  166. 'from_fieldname' => 'thread_id',  
  167. 'to_type' => 'topic',  
  168. 'to_fieldname' => '_bbp_topic_id' 
  169. ); 
  170.  
  171. // Topic reply count (Stored in postmeta) 
  172. $this->field_map[] = array( 
  173. 'from_tablename' => 'thread',  
  174. 'from_fieldname' => 'reply_count',  
  175. 'to_type' => 'topic',  
  176. 'to_fieldname' => '_bbp_reply_count',  
  177. 'callback_method' => 'callback_topic_reply_count' 
  178. ); 
  179.  
  180. // Topic total reply count (Includes unpublished replies, Stored in postmeta) 
  181. $this->field_map[] = array( 
  182. 'from_tablename' => 'thread',  
  183. 'from_fieldname' => 'reply_count',  
  184. 'to_type' => 'topic',  
  185. 'to_fieldname' => '_bbp_total_reply_count',  
  186. 'callback_method' => 'callback_topic_reply_count' 
  187. ); 
  188.  
  189. // Topic parent forum id (If no parent, then 0. Stored in postmeta) 
  190. $this->field_map[] = array( 
  191. 'from_tablename' => 'thread',  
  192. 'from_fieldname' => 'node_id',  
  193. 'to_type' => 'topic',  
  194. 'to_fieldname' => '_bbp_forum_id',  
  195. 'callback_method' => 'callback_forumid' 
  196. ); 
  197.  
  198. // Topic author. 
  199. $this->field_map[] = array( 
  200. 'from_tablename' => 'thread',  
  201. 'from_fieldname' => 'user_id',  
  202. 'to_type' => 'topic',  
  203. 'to_fieldname' => 'post_author',  
  204. 'callback_method' => 'callback_userid' 
  205. ); 
  206.  
  207. // Topic title. 
  208. $this->field_map[] = array( 
  209. 'from_tablename' => 'thread',  
  210. 'from_fieldname' => 'title',  
  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' => 'thread',  
  218. 'from_fieldname' => 'title',  
  219. 'to_type' => 'topic',  
  220. 'to_fieldname' => 'post_name',  
  221. 'callback_method' => 'callback_slug' 
  222. ); 
  223.  
  224. // Topic content. 
  225. // Note: We join the 'post' table because 'thread' table does not include content. 
  226. $this->field_map[] = array( 
  227. 'from_tablename' => 'post',  
  228. 'from_fieldname' => 'message',  
  229. 'join_tablename' => 'thread',  
  230. 'join_type' => 'INNER',  
  231. 'join_expression' => 'ON thread.first_post_id = post.post_id',  
  232. 'to_type' => 'topic',  
  233. 'to_fieldname' => 'post_content',  
  234. 'callback_method' => 'callback_html' 
  235. ); 
  236.  
  237. // Topic status (Open = 1 or Closed = 0) 
  238. $this->field_map[] = array( 
  239. 'from_tablename' => 'thread',  
  240. 'from_fieldname' => 'discussion_open',  
  241. 'to_type' => 'topic',  
  242. 'to_fieldname' => 'post_status',  
  243. 'callback_method' => 'callback_topic_status' 
  244. ); 
  245.  
  246. // Topic parent forum id (If no parent, then 0) 
  247. $this->field_map[] = array( 
  248. 'from_tablename' => 'thread',  
  249. 'from_fieldname' => 'node_id',  
  250. 'to_type' => 'topic',  
  251. 'to_fieldname' => 'post_parent',  
  252. 'callback_method' => 'callback_forumid' 
  253. ); 
  254.  
  255. // Sticky status (Stored in postmeta)) 
  256. $this->field_map[] = array( 
  257. 'from_tablename' => 'thread',  
  258. 'from_fieldname' => 'sticky',  
  259. 'to_type' => 'topic',  
  260. 'to_fieldname' => '_bbp_old_sticky_status',  
  261. 'callback_method' => 'callback_sticky_status' 
  262. ); 
  263.  
  264. // Topic dates. 
  265. $this->field_map[] = array( 
  266. 'from_tablename' => 'thread',  
  267. 'from_fieldname' => 'post_date',  
  268. 'to_type' => 'topic',  
  269. 'to_fieldname' => 'post_date',  
  270. 'callback_method' => 'callback_datetime' 
  271. ); 
  272. $this->field_map[] = array( 
  273. 'from_tablename' => 'thread',  
  274. 'from_fieldname' => 'post_date',  
  275. 'to_type' => 'topic',  
  276. 'to_fieldname' => 'post_date_gmt',  
  277. 'callback_method' => 'callback_datetime' 
  278. ); 
  279. $this->field_map[] = array( 
  280. 'from_tablename' => 'thread',  
  281. 'from_fieldname' => 'last_post_date',  
  282. 'to_type' => 'topic',  
  283. 'to_fieldname' => 'post_modified',  
  284. 'callback_method' => 'callback_datetime' 
  285. ); 
  286. $this->field_map[] = array( 
  287. 'from_tablename' => 'thread',  
  288. 'from_fieldname' => 'last_post_date',  
  289. 'to_type' => 'topic',  
  290. 'to_fieldname' => 'post_modified_gmt',  
  291. 'callback_method' => 'callback_datetime' 
  292. ); 
  293. $this->field_map[] = array( 
  294. 'from_tablename' => 'thread',  
  295. 'from_fieldname' => 'last_post_date',  
  296. 'to_type' => 'topic',  
  297. 'to_fieldname' => '_bbp_last_active_time',  
  298. 'callback_method' => 'callback_datetime' 
  299. ); 
  300.  
  301. /** Tags Section ******************************************************/ 
  302.  
  303. /** 
  304. * XenForo Forums do not support topic tags out of the box 
  305. */ 
  306.  
  307. /** Reply Section *****************************************************/ 
  308.  
  309. // Reply id (Stored in postmeta) 
  310. $this->field_map[] = array( 
  311. 'from_tablename' => 'post',  
  312. 'from_fieldname' => 'post_id',  
  313. 'to_type' => 'reply',  
  314. 'to_fieldname' => '_bbp_post_id' 
  315. ); 
  316.  
  317. // Reply parent forum id (If no parent, then 0. Stored in postmeta) 
  318. $this->field_map[] = array( 
  319. 'from_tablename' => 'post',  
  320. 'from_fieldname' => 'thread_id',  
  321. 'to_type' => 'reply',  
  322. 'to_fieldname' => '_bbp_forum_id',  
  323. 'callback_method' => 'callback_topicid_to_forumid' 
  324. ); 
  325.  
  326. // Reply parent topic id (If no parent, then 0. Stored in postmeta) 
  327. $this->field_map[] = array( 
  328. 'from_tablename' => 'post',  
  329. 'from_fieldname' => 'thread_id',  
  330. 'to_type' => 'reply',  
  331. 'to_fieldname' => '_bbp_topic_id',  
  332. 'callback_method' => 'callback_topicid' 
  333. ); 
  334.  
  335. // Reply author. 
  336. $this->field_map[] = array( 
  337. 'from_tablename' => 'post',  
  338. 'from_fieldname' => 'user_id',  
  339. 'to_type' => 'reply',  
  340. 'to_fieldname' => 'post_author',  
  341. 'callback_method' => 'callback_userid' 
  342. ); 
  343.  
  344. // Reply title. 
  345. // Note: We join the 'thread' table because 'post' do not have titles. 
  346. $this->field_map[] = array( 
  347. 'from_tablename' => 'thread',  
  348. 'from_fieldname' => 'title',  
  349. 'join_tablename' => 'post',  
  350. 'join_type' => 'LEFT',  
  351. 'join_expression' => 'USING (thread_id) WHERE thread.first_post_id != post.post_id',  
  352. 'to_type' => 'reply',  
  353. 'to_fieldname' => 'post_title',  
  354. 'callback_method' => 'callback_reply_title' 
  355. ); 
  356.  
  357. // Reply slug (Clean name to avoid conflicts) 
  358. // Note: We join the 'thread' table because 'post' do not have titles. 
  359. $this->field_map[] = array( 
  360. 'from_tablename' => 'thread',  
  361. 'from_fieldname' => 'title',  
  362. 'join_tablename' => 'post',  
  363. 'join_type' => 'LEFT',  
  364. 'join_expression' => 'USING (thread_id) WHERE thread.first_post_id != post.post_id',  
  365. 'to_fieldname' => 'post_name',  
  366. 'callback_method' => 'callback_slug' 
  367. ); 
  368.  
  369. // Reply content. 
  370. $this->field_map[] = array( 
  371. 'from_tablename' => 'post',  
  372. 'from_fieldname' => 'message',  
  373. 'to_type' => 'reply',  
  374. 'to_fieldname' => 'post_content',  
  375. 'callback_method' => 'callback_html' 
  376. ); 
  377.  
  378. // Reply parent topic id (If no parent, then 0) 
  379. $this->field_map[] = array( 
  380. 'from_tablename' => 'post',  
  381. 'from_fieldname' => 'thread_id',  
  382. 'to_type' => 'reply',  
  383. 'to_fieldname' => 'post_parent',  
  384. 'callback_method' => 'callback_topicid' 
  385. ); 
  386.  
  387. // Reply dates. 
  388. $this->field_map[] = array( 
  389. 'from_tablename' => 'post',  
  390. 'from_fieldname' => 'post_date',  
  391. 'to_type' => 'reply',  
  392. 'to_fieldname' => 'post_date',  
  393. 'callback_method' => 'callback_datetime' 
  394. ); 
  395. $this->field_map[] = array( 
  396. 'from_tablename' => 'post',  
  397. 'from_fieldname' => 'post_date',  
  398. 'to_type' => 'reply',  
  399. 'to_fieldname' => 'post_date_gmt',  
  400. 'callback_method' => 'callback_datetime' 
  401. ); 
  402. $this->field_map[] = array( 
  403. 'from_tablename' => 'post',  
  404. 'from_fieldname' => 'post_date',  
  405. 'to_type' => 'reply',  
  406. 'to_fieldname' => 'post_modified',  
  407. 'callback_method' => 'callback_datetime' 
  408. ); 
  409. $this->field_map[] = array( 
  410. 'from_tablename' => 'post',  
  411. 'from_fieldname' => 'post_date',  
  412. 'to_type' => 'reply',  
  413. 'to_fieldname' => 'post_modified_gmt',  
  414. 'callback_method' => 'callback_datetime' 
  415. ); 
  416.  
  417. /** User Section ******************************************************/ 
  418.  
  419. // Store old User id (Stored in usermeta) 
  420. $this->field_map[] = array( 
  421. 'from_tablename' => 'user',  
  422. 'from_fieldname' => 'user_id',  
  423. 'to_type' => 'user',  
  424. 'to_fieldname' => '_bbp_user_id' 
  425. ); 
  426.  
  427. /** // User password. 
  428. // Note: We join the 'user_authenticate' table because 'user' does not include password. 
  429. $this->field_map[] = array( 
  430. 'from_tablename' => 'user_authenticate',  
  431. 'from_fieldname' => 'data',  
  432. 'join_tablename' => 'user',  
  433. 'join_type' => 'LEFT',  
  434. 'join_expression' => 'USING (user_id)',  
  435. 'to_type' => 'user',  
  436. 'to_fieldname' => '_bbp_converter_password' 
  437. ); 
  438.   
  439. // Store old User password (Stored in usermeta serialized with salt) 
  440. $this->field_map[] = array( 
  441. 'from_tablename' => 'user',  
  442. 'from_fieldname' => 'password',  
  443. 'to_type' => 'user',  
  444. 'to_fieldname' => '_bbp_password',  
  445. 'callback_method' => 'callback_savepass' 
  446. ); 
  447.   
  448. // Store old User Salt (This is only used for the SELECT row info for the above password save) 
  449. $this->field_map[] = array( 
  450. 'from_tablename' => 'user',  
  451. 'from_fieldname' => 'salt',  
  452. 'to_type' => 'user',  
  453. 'to_fieldname' => '' 
  454. ); 
  455. */ 
  456. // User password verify class (Stored in usermeta for verifying password) 
  457. $this->field_map[] = array( 
  458. 'to_type' => 'user',  
  459. 'to_fieldname' => '_bbp_class',  
  460. 'default' => 'XenForo' 
  461. ); 
  462.  
  463. // User name. 
  464. $this->field_map[] = array( 
  465. 'from_tablename' => 'user',  
  466. 'from_fieldname' => 'username',  
  467. 'to_type' => 'user',  
  468. 'to_fieldname' => 'user_login' 
  469. ); 
  470.  
  471. // User email. 
  472. $this->field_map[] = array( 
  473. 'from_tablename' => 'user',  
  474. 'from_fieldname' => 'email',  
  475. 'to_type' => 'user',  
  476. 'to_fieldname' => 'user_email' 
  477. ); 
  478.  
  479. // User homepage. 
  480. // Note: We join the 'user_profile' table because 'user' does not include user homepage. 
  481. $this->field_map[] = array( 
  482. 'from_tablename' => 'user_profile',  
  483. 'from_fieldname' => 'homepage',  
  484. 'join_tablename' => 'user',  
  485. 'join_type' => 'LEFT',  
  486. 'join_expression' => 'USING (user_id)',  
  487. 'to_type' => 'user',  
  488. 'to_fieldname' => 'user_url' 
  489. ); 
  490.  
  491. // User registered. 
  492. $this->field_map[] = array( 
  493. 'from_tablename' => 'user',  
  494. 'from_fieldname' => 'register_date',  
  495. 'to_type' => 'user',  
  496. 'to_fieldname' => 'user_registered',  
  497. 'callback_method' => 'callback_datetime' 
  498. ); 
  499.  
  500. // User display name. 
  501. $this->field_map[] = array( 
  502. 'from_tablename' => 'user',  
  503. 'from_fieldname' => 'username',  
  504. 'to_type' => 'user',  
  505. 'to_fieldname' => 'display_name' 
  506. ); 
  507.  
  508. // Store Custom Title (Stored in usermeta) 
  509. $this->field_map[] = array( 
  510. 'from_tablename' => 'user',  
  511. 'from_fieldname' => 'custom_title',  
  512. 'to_type' => 'user',  
  513. 'to_fieldname' => '_bbp_xenforo_user_custom_title' 
  514. ); 
  515.  
  516. // Store Status (Stored in usermeta) 
  517. // Note: We join the 'user_profile' table because 'user' does not include user custom XenForo field user status. 
  518. $this->field_map[] = array( 
  519. 'from_tablename' => 'user_profile',  
  520. 'from_fieldname' => 'status',  
  521. 'join_tablename' => 'user',  
  522. 'join_type' => 'LEFT',  
  523. 'join_expression' => 'USING (user_id)',  
  524. 'to_type' => 'user',  
  525. 'to_fieldname' => '_bbp_xenforo_user_status' 
  526. ); 
  527.  
  528. // Store Signature (Stored in usermeta) 
  529. // Note: We join the 'user_profile' table because 'user' does not include user custom XenForo field user signature. 
  530. $this->field_map[] = array( 
  531. 'from_tablename' => 'user_profile',  
  532. 'from_fieldname' => 'signature',  
  533. 'join_tablename' => 'user',  
  534. 'join_type' => 'LEFT',  
  535. 'join_expression' => 'USING (user_id)',  
  536. 'to_fieldname' => '_bbp_xenforo_user_sig',  
  537. 'to_type' => 'user',  
  538. 'callback_method' => 'callback_html' 
  539. ); 
  540.  
  541. // Store Location (Stored in usermeta) 
  542. // Note: We join the 'user_profile' table because 'user' does not include user custom XenForo field user location. 
  543. $this->field_map[] = array( 
  544. 'from_tablename' => 'user_profile',  
  545. 'from_fieldname' => 'location',  
  546. 'join_tablename' => 'user',  
  547. 'join_type' => 'LEFT',  
  548. 'join_expression' => 'USING (user_id)',  
  549. 'to_type' => 'user',  
  550. 'to_fieldname' => '_bbp_xenforo_user_location' 
  551. ); 
  552.  
  553. // Store Occupation (Stored in usermeta) 
  554. // Note: We join the 'user_profile' table because 'user' does not include user custom XenForo field user occupation. 
  555. $this->field_map[] = array( 
  556. 'from_tablename' => 'user_profile',  
  557. 'from_fieldname' => 'occupation',  
  558. 'join_tablename' => 'user',  
  559. 'join_type' => 'LEFT',  
  560. 'join_expression' => 'USING (user_id)',  
  561. 'to_type' => 'user',  
  562. 'to_fieldname' => '_bbp_xenforo_user_occupation' 
  563. ); 
  564.  
  565. // Store About (Stored in usermeta) 
  566. // Note: We join the 'user_profile' table because 'user' does not include user custom XenForo field user about. 
  567. $this->field_map[] = array( 
  568. 'from_tablename' => 'user_profile',  
  569. 'from_fieldname' => 'about',  
  570. 'join_tablename' => 'user',  
  571. 'join_type' => 'LEFT',  
  572. 'join_expression' => 'USING (user_id)',  
  573. 'to_type' => 'user',  
  574. 'to_fieldname' => '_bbp_xenforo_user_about',  
  575. 'callback_method' => 'callback_html' 
  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 translate_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. switch( $pass_array['hashFunc'] ) 
  601. case 'sha256': 
  602. return ( $pass_array['hash'] == hash( 'sha256', hash( 'sha256', $password ) . $pass_array['salt'] ) ); 
  603. case 'sha1': 
  604. return ( $pass_array['hash'] == sha1( sha1( $password ) . $pass_array['salt'] ) ); 
  605.  
  606. /** 
  607. * Translate the forum type from XenForo Capitalised case to WordPress's non-capatilise case strings. 
  608. * @param int $status XenForo numeric forum type 
  609. * @return string WordPress safe 
  610. */ 
  611. public function callback_forum_type( $status = 1 ) { 
  612. switch ( $status ) { 
  613. case 'Category' : 
  614. $status = 'category'; 
  615. break; 
  616.  
  617. case 'Forum' : 
  618. default : 
  619. $status = 'forum'; 
  620. break; 
  621. return $status; 
  622.  
  623. /** 
  624. * Translate the forum status from XenForo numeric's to WordPress's strings. 
  625. * @param int $status XenForo numeric forum status 
  626. * @return string WordPress safe 
  627. */ 
  628. public function callback_forum_status( $status = 1 ) { 
  629. switch ( $status ) { 
  630. case 0 : 
  631. $status = 'closed'; 
  632. break; 
  633.  
  634. case 1 : 
  635. default : 
  636. $status = 'open'; 
  637. break; 
  638. return $status; 
  639.  
  640. /** 
  641. * Translate the topic status from XenForo numeric's to WordPress's strings. 
  642. * @param int $status XenForo numeric topic status 
  643. * @return string WordPress safe 
  644. */ 
  645. public function callback_topic_status( $status = 1 ) { 
  646. switch ( $status ) { 
  647. case 0 : 
  648. $status = 'closed'; 
  649. break; 
  650.  
  651. case 1 : 
  652. default : 
  653. $status = 'publish'; 
  654. break; 
  655. return $status; 
  656.  
  657. /** 
  658. * Translate the topic sticky status type from XenForo numeric's to WordPress's strings. 
  659. * @param int $status XenForo numeric forum type 
  660. * @return string WordPress safe 
  661. */ 
  662. public function callback_sticky_status( $status = 0 ) { 
  663. switch ( $status ) { 
  664. case 1 : 
  665. $status = 'sticky'; // XenForo Sticky 'sticky = 1' 
  666. break; 
  667.  
  668. case 0 : 
  669. default : 
  670. $status = 'normal'; // XenForo Normal Topic 'sticky = 0' 
  671. break; 
  672. return $status; 
  673.  
  674. /** 
  675. * Verify the topic reply count. 
  676. * @param int $count XenForo reply count 
  677. * @return string WordPress safe 
  678. */ 
  679. public function callback_topic_reply_count( $count = 1 ) { 
  680. $count = absint( (int) $count - 1 ); 
  681. return $count; 
  682.  
  683. /** 
  684. * Set the reply title 
  685. * @param string $title XenForo topic title of this reply 
  686. * @return string Prefixed topic title, or empty string 
  687. */ 
  688. public function callback_reply_title( $title = '' ) { 
  689. $title = !empty( $title ) ? __( 'Re: ', 'bbpress' ) . html_entity_decode( $title ) : ''; 
  690. return $title;