BxDataMigrationForum.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. require_once 'BxDataMigrationOrcaForum.php';
  3. class BxDataMigrationForum extends BxDataMigrationOrcaForum
  4. {
  5. /**
  6. * Class constructor;
  7. *
  8. * @param : $oMigrationModule (object) - object instance of migration class;
  9. * @param : $rOldDb (resourse) - connect to old dolphin's database;
  10. * @param : $oDolModule (object);
  11. * @return : void;
  12. */
  13. function BxDataMigrationForum(&$oMigrationModule, &$rOldDb, $oDolModule = '')
  14. {
  15. parent::BxDataMigrationOrcaForum($oMigrationModule, $rOldDb, $oDolModule);
  16. }
  17. /**
  18. * Function migrate polls data;
  19. *
  20. * @return : (integer) operation result;
  21. */
  22. function getMigration()
  23. {
  24. mysql_query('SET NAMES utf8', $this->rOldDb);
  25. // sample cat and forum is created in clean instllation, detele it before migration
  26. $this->emptyDatabase ();
  27. // transfer categories;
  28. $this -> setResultStatus('transfer categories');
  29. $sError = $this -> _transferCategories();
  30. if($sError) {
  31. $this -> setResultStatus($sError);
  32. return MIGRATION_FAILED;
  33. }
  34. //transfer forums;
  35. $this -> setResultStatus('transfer forums');
  36. $sError = $this -> _transferForums();
  37. if($sError) {
  38. $this -> setResultStatus($sError);
  39. return MIGRATION_FAILED;
  40. }
  41. //transfer flags;
  42. $this -> setResultStatus('transfer forum\'s flags');
  43. $sError = $this -> _transferFlags();
  44. if($sError) {
  45. $this -> setResultStatus($sError);
  46. return MIGRATION_FAILED;
  47. }
  48. //transfer forum's posts;
  49. $this -> setResultStatus('transfer forum\'s posts');
  50. $sError = $this -> _transferPosts();
  51. if($sError) {
  52. $this -> setResultStatus($sError);
  53. return MIGRATION_FAILED;
  54. }
  55. //transfer forum's topics;
  56. $this -> setResultStatus('transfer forum\'s topics');
  57. $sError = $this -> _transferTopics();
  58. if($sError) {
  59. $this -> setResultStatus($sError);
  60. return MIGRATION_FAILED;
  61. }
  62. //transfer forum's users;
  63. $this -> setResultStatus('transfer forum\'s users');
  64. $sError = $this -> _transferUsers();
  65. if($sError) {
  66. $this -> setResultStatus($sError);
  67. return MIGRATION_FAILED;
  68. }
  69. //transfer forum's users activity;
  70. $this -> setResultStatus('transfer forum\'s users activity');
  71. $sError = $this -> _transferUsersActivity();
  72. if($sError) {
  73. $this -> setResultStatus($sError);
  74. return MIGRATION_FAILED;
  75. }
  76. //transfer forum's users stat;
  77. $this -> setResultStatus('transfer forum\'s users stat');
  78. $sError = $this -> _transferUsersStat();
  79. if($sError) {
  80. $this -> setResultStatus($sError);
  81. return MIGRATION_FAILED;
  82. }
  83. //transfer forum's users vote;
  84. $this -> setResultStatus('transfer forum\'s users vote');
  85. $sError = $this -> _transferUsersVote();
  86. if($sError) {
  87. $this -> setResultStatus($sError);
  88. return MIGRATION_FAILED;
  89. }
  90. // set as finished;
  91. $this -> setResultStatus('Forums were transferred');
  92. return MIGRATION_SUCCESSFUL;
  93. }
  94. /**
  95. * sample cat and forum is created in clean instllation, detele it before migration
  96. */
  97. function emptyDatabase () {
  98. $sQuery = "DELETE FROM `{$this -> sNewTablePrefix}forum_cat` WHERE `cat_uri` = 'General'";
  99. $this -> oMigrationModule -> _oDb -> query($sQuery);
  100. $sQuery = "DELETE FROM `{$this -> sNewTablePrefix}forum` WHERE `forum_uri` = 'General-discussions'";
  101. $this -> oMigrationModule -> _oDb -> query($sQuery);
  102. }
  103. }