BxAclGridLevels.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 PaidLevels Paid Levels
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxAclGridLevels extends BxTemplGrid
  12. {
  13. protected $MODULE;
  14. protected $_oModule;
  15. protected $_aPeriodUnits;
  16. public function __construct ($aOptions, $oTemplate = false)
  17. {
  18. $this->MODULE = 'bx_acl';
  19. $this->_oModule = BxDolModule::getInstance($this->MODULE);
  20. parent::__construct ($aOptions, $oTemplate);
  21. $CNF = $this->_oModule->_oConfig->CNF;
  22. $this->_aPeriodUnits = BxDolForm::getDataItems($CNF['OBJECT_FORM_PRELISTS_PERIOD_UNITS']);
  23. }
  24. protected function _getCellLevelName($mixedValue, $sKey, $aField, $aRow)
  25. {
  26. if(($sKey = $aRow['caption']) && ($_sKey = _t($sKey)) && strcmp($sKey, $_sKey) != 0)
  27. $mixedValue = $_sKey;
  28. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  29. }
  30. protected function _getCellPeriod($mixedValue, $sKey, $aField, $aRow)
  31. {
  32. if(!$this->_bIsApi) {
  33. if((int)$mixedValue == 0)
  34. $mixedValue = _t('_bx_acl_txt_lifetime');
  35. else
  36. $mixedValue = _t('_bx_acl_txt_n_unit', $mixedValue, _t($this->_aPeriodUnits[$aRow['period_unit']]));
  37. }
  38. else
  39. $mixedValue = ['period' => $mixedValue, 'unit' => $aRow['period_unit']];
  40. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  41. }
  42. protected function _getCellPrice($mixedValue, $sKey, $aField, $aRow)
  43. {
  44. $aCurrency = $this->_oModule->_oConfig->getCurrency();
  45. if(!$this->_bIsApi) {
  46. if((float)$mixedValue != 0)
  47. $mixedValue = _t('_bx_acl_grid_column_price_value', html_entity_decode($aCurrency['sign']), $mixedValue);
  48. else
  49. $mixedValue = _t('_bx_acl_txt_free');
  50. }
  51. else
  52. $mixedValue = ['value' => $mixedValue, 'currency' => $aCurrency['code']];
  53. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  54. }
  55. protected function _getCellTrial($mixedValue, $sKey, $aField, $aRow)
  56. {
  57. $mixedValue = (int)$mixedValue != 0 ? _t('_bx_acl_txt_n_unit', $mixedValue, _t($this->_aPeriodUnits['day'])) : _t('_bx_acl_txt_none');
  58. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  59. }
  60. protected function _getIds()
  61. {
  62. $aIds = bx_get('ids');
  63. if(!$aIds || !is_array($aIds)) {
  64. $iId = (int)bx_get('id');
  65. if(!$iId)
  66. return false;
  67. $aIds = array($iId);
  68. }
  69. return $aIds;
  70. }
  71. }
  72. /** @} */