BxDolMTransfers.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 DolphinMigration Dolphin Migration
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxDolMTransfers extends BxTemplGrid
  12. {
  13. public function __construct ($aOptions, $oTemplate = false)
  14. {
  15. $this -> MODULE = 'bx_dolphin_migration';
  16. $this -> _oModule = BxDolModule::getInstance('bx_dolphin_migration');
  17. $this -> _aConfirmMessages = array(
  18. 'run' => _t('_bx_dolphin_migration_start_transfer_confirmation'),
  19. 'clean' => _t('_bx_dolphin_migration_clean_confirmation'),
  20. 'remove' => _t('_bx_dolphin_migration_remove_content_confirmation'),
  21. 'remove_profiles' => _t('_bx_dolphin_migration_remove_profile_content_confirmation')
  22. );
  23. parent::__construct ($aOptions, $oTemplate);
  24. }
  25. protected function _getCellStatusText($mixedValue, $sKey, $aField, $aRow)
  26. {
  27. $sAttr = $this->_convertAttrs($aField, 'attr_cell', false, isset($aField['width']) ? 'width:' . $aField['width'] : false);
  28. if ($aRow['status'] != 'finished')
  29. $mixedValue = _t('_bx_dolphin_migration_status_' . $aRow['status']);
  30. return '<td ' . $sAttr . '><span class="' . ($aRow['status'] == 'finished' ? 'bx-migrate-not-finished' : ($aRow['status'] == 'error' ? 'bx-migrate-error' : '')) . '">' . $mixedValue . '</span></td>';
  31. }
  32. protected function _getCellModule($mixedValue, $sKey, $aField, $aRow)
  33. {
  34. $aNumber = explode(',', $aRow['number']);
  35. if (sizeof($aNumber) > 1)
  36. $sTitle = call_user_func_array('_t', array_merge(array('_bx_dolphin_migration_data_' . $mixedValue), $aNumber));
  37. else
  38. $sTitle = _t('_bx_dolphin_migration_data_' . $mixedValue);
  39. return '<td>' . $sTitle . '</td>';
  40. }
  41. public function performActionRun()
  42. {
  43. $aElements = bx_get('ids');
  44. echoJson(array(
  45. 'msg' => $this-> _oModule -> actionStartTransfer($aElements),
  46. 'grid' => $this -> getCode(false),
  47. 'blink' => $aElements
  48. ));
  49. }
  50. public function performActionFinished()
  51. {
  52. $aElements = explode(',', bx_get('modules'));
  53. if (!empty($aElements) && $this-> _oModule -> _oDb -> isFinished($aElements))
  54. echoJson(array(
  55. 'grid' => $this -> getCode(false),
  56. 'blink' => $aElements,
  57. 'eval' => 'clearInterval(glGrids.bx_dolphin_migration_transfers.iMigInterval);'
  58. ));
  59. }
  60. protected function _getFilterControls ()
  61. {
  62. return '';
  63. }
  64. public function performActionRemoveProfiles()
  65. {
  66. $this -> performActionRemove();
  67. }
  68. public function performActionRemove()
  69. {
  70. $sModule = bx_get('ids')[0];
  71. $iNumber = $this-> _oModule -> actionPerformAction($sModule, 'remove');
  72. echoJson(array(
  73. 'msg' => $iNumber ? _t('_bx_dolphin_migration_successfully_removed', $iNumber) : _t('_bx_dolphin_migration_nothing_removed'),
  74. 'grid' => $this -> getCode(false),
  75. 'blink' => $sModule,
  76. ));
  77. }
  78. protected function _getActionRemove ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
  79. {
  80. if ($aRow['module'] == 'profiles')
  81. $a['attr']['bx_grid_action_single'] = 'remove_profiles';
  82. return parent::_getActionDefault($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
  83. }
  84. public function performActionClean()
  85. {
  86. $sModule = bx_get('ids')[0];
  87. echoJson(array(
  88. 'msg' => $this-> _oModule -> actionPerformAction($sModule, 'clean') ? _t('_bx_dolphin_migration_successfully_cleaned') : _t('_bx_dolphin_migration_nothing_removed'),
  89. 'grid' => $this -> getCode(false),
  90. 'blink' => $sModule,
  91. ));
  92. }
  93. }
  94. /** @} */