BxSEMigStudioPage.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup SocialEngineMigration SocialEngine Migration
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. define('BX_SEMIG_STUDIO_TRANSFER', 'config');
  12. class BxSEMigStudioPage extends BxTemplStudioModule
  13. {
  14. protected $_oModule;
  15. function __construct($sModule, $mixedPageName, $sPage = "")
  16. {
  17. $this -> MODULE = 'bx_se_migration';
  18. parent::__construct($sModule, $mixedPageName, $sPage);
  19. $this -> _oModule = BxDolModule::getInstance($sModule);
  20. $this->aMenuItems = array(
  21. 'settings' => array('name' => 'settings', 'icon' => 'cogs', 'title' => '_bx_se_migration_cpt_settings'),
  22. 'config' => array('name' => 'config', 'icon' => 'exchange-alt', 'title' => '_bx_se_migration_cpt_transfer_data'),
  23. );
  24. $this -> _oModule -> _oTemplate -> addStudioJs(array('jquery-ui/jquery-ui.custom.min.js', 'transfer.js', 'BxDolGrid.js'));
  25. $this -> _oModule -> _oTemplate -> addStudioCss(array('main.css'));
  26. }
  27. public function saveData($sPath){
  28. $isDbDefined = false;
  29. if ( substr($sPath, strlen($sPath) - 1 ) != DIRECTORY_SEPARATOR ) {
  30. $sPath .= DIRECTORY_SEPARATOR;
  31. }
  32. // get all settings from social engine config file;
  33. if (file_exists($sPath . 'application' . DIRECTORY_SEPARATOR . 'settings' . DIRECTORY_SEPARATOR . 'database.php'))
  34. $aSEConfig = include $sPath . 'application' . DIRECTORY_SEPARATOR . 'settings' . DIRECTORY_SEPARATOR . 'database.php';
  35. else
  36. return MsgBox( _t('_bx_se_migration_error_config_file_was_not_found'));
  37. if( is_array($aSEConfig['params']) ) {
  38. foreach($aSEConfig['params'] as $sKey => $sParamName){
  39. $aConfig[$sKey] = $sParamName;
  40. $isDbDefined = true;
  41. }
  42. }
  43. // save social engine data and creates migration list
  44. if($isDbDefined) {
  45. $aConfig['root'] = $sPath;
  46. $this -> _oModule -> _oDb -> saveConfig($aConfig);
  47. if ($this -> _oModule -> initSEDb())
  48. $this -> _oModule -> createMigration();
  49. else
  50. return MsgBox( _t('_bx_se_migration_error_data_was_not_set'), 2);
  51. }
  52. else
  53. return MsgBox( _t('_bx_se_migration_error_data_was_not_set'), 2);
  54. return MsgBox( _t('_bx_se_migration_data_was_set'), 2);
  55. }
  56. public function getConfig(){
  57. bx_import('Transfers', 'bx_se_migration');
  58. $sMessage = '';
  59. if (bx_get('save') && bx_get('se_migration_location'))
  60. $sMessage = $this -> saveData(bx_get('se_migration_location'));
  61. $oGrid = BxDolGrid::getObjectInstance('bx_se_migration_transfers');
  62. if ($oGrid)
  63. return $sMessage . $oGrid -> getCode(); // print grid object
  64. return MsgBox(_t('_bx_se_migration_installation_problem'));
  65. }
  66. }
  67. /** @} */