BxDolGridQueues.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 UnaCore UNA Core
  7. * @{
  8. */
  9. class BxDolGridQueues extends BxTemplGrid
  10. {
  11. protected $_aSources = [
  12. "emails" => [
  13. 'id' => "emails",
  14. 'name' => "_sys_queue_emails",
  15. 'all' => "SELECT COUNT(*) FROM `sys_queue_email`",
  16. 'action' => "DELETE FROM `sys_queue_email`"],
  17. "push" => [
  18. 'id' => "push",
  19. 'name' => "_sys_queue_push",
  20. 'all' => "SELECT COUNT(*) FROM `sys_queue_push`",
  21. 'action' => "DELETE FROM `sys_queue_push`"],
  22. "transcoding" => [
  23. 'id' => "transcoding",
  24. 'name' => "_sys_queue_transcoding",
  25. 'all' => "SELECT COUNT(*) FROM `sys_transcoder_queue`",
  26. 'failed' => "SELECT COUNT(*) FROM `sys_transcoder_queue` WHERE `status` = 'failed'",
  27. 'action' => "DELETE FROM `sys_transcoder_queue` WHERE `status` != 'processing'"],
  28. "storage" => [
  29. 'id' => "storage",
  30. 'name' => "_sys_queue_storage",
  31. 'all' => "SELECT COUNT(*) FROM `sys_storage_deletions`"],
  32. ];
  33. protected function _getDataArray($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
  34. {
  35. $this->_aOptions['source'] = $this->_aSources;
  36. return parent::_getDataArray($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
  37. }
  38. public function __construct ($aOptions, $oTemplate = false)
  39. {
  40. parent::__construct ($aOptions, $oTemplate);
  41. }
  42. protected function _getCellFailed ($mixedValue, $sKey, $aField, $aRow)
  43. {
  44. return $this->_getCellCount ('failed', $sKey, $aField, $aRow);
  45. }
  46. protected function _getCellAll ($mixedValue, $sKey, $aField, $aRow)
  47. {
  48. return $this->_getCellCount ('all', $sKey, $aField, $aRow);
  49. }
  50. protected function _getCellCount ($sField, $sKey, $aField, $aRow)
  51. {
  52. if (empty($aRow[$sField]))
  53. $mixedValue = _t('_sys_not_available');
  54. else
  55. $mixedValue = BxDolDb::getInstance()->getOne($aRow[$sField]);
  56. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  57. }
  58. public function performActionClear()
  59. {
  60. $sAction = 'edit';
  61. $aIds = bx_get('ids');
  62. if(!$aIds || !is_array($aIds)) {
  63. $sId = bx_get('id');
  64. if(!$sId)
  65. return echoJson(array());
  66. $aIds = array($sId);
  67. }
  68. $sId = array_shift($aIds);
  69. if (empty($this->_aSources[$sId]) || empty($this->_aSources[$sId]['action'])) {
  70. $sRes = echoJson(array('msg' => _t('_error occured')));
  71. exit;
  72. }
  73. else {
  74. $sQuery = $this->_aSources[$sId]['action'];
  75. $i = BxDolDb::getInstance()->query($sQuery);
  76. echoJson(array('grid' => $this->getCode(false), 'blink' => $sId));
  77. }
  78. }
  79. protected function _isVisibleGrid ($a)
  80. {
  81. return isAdmin();
  82. }
  83. protected function _getActionClear($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
  84. {
  85. if(empty($aRow['action']))
  86. return '';
  87. return parent::_getActionDefault($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
  88. }
  89. }
  90. /** @} */