BxAclConfig.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 BxAclConfig extends BxBaseModGeneralConfig
  12. {
  13. protected $_oDb;
  14. protected $_aHtmlIds;
  15. protected $_aCurrency;
  16. protected $_iOwner;
  17. protected $_iExpireNotificationDays;
  18. protected $_bExpireNotifyOnce;
  19. protected $_iRemoveExpiredFor;
  20. /**
  21. * Constructor
  22. */
  23. public function __construct($aModule)
  24. {
  25. parent::__construct($aModule);
  26. $this->CNF = array (
  27. // database tables
  28. 'TABLE_PRICES' => $aModule['db_prefix'] . 'level_prices',
  29. // database fields
  30. 'FIELD_ID' => 'id',
  31. 'FIELD_LEVEL_ID' => 'level_id',
  32. 'FIELD_NAME' => 'name',
  33. // page URIs
  34. 'URL_ADMINISTRATION' => 'page.php?i=acl-administration',
  35. 'URL_VIEW' => 'page.php?i=acl-view',
  36. // some params
  37. 'PARAM_RECURRING_RESERVE' => 'bx_acl_recurring_reserve',
  38. 'PARAM_RECURRING_PRIORITIZE' => 'bx_acl_recurring_prioritize',
  39. // objects
  40. 'OBJECT_GRID_ADMINISTRATION' => 'bx_acl_administration',
  41. 'OBJECT_GRID_VIEW' => 'bx_acl_view',
  42. 'OBJECT_FORM_PRICE' => 'bx_acl_price',
  43. 'OBJECT_FORM_PRICE_DISPLAY_ADD' => 'bx_acl_price_add',
  44. 'OBJECT_FORM_PRICE_DISPLAY_EDIT' => 'bx_acl_price_edit',
  45. 'OBJECT_FORM_PRELISTS_PERIOD_UNITS' => 'bx_acl_period_units',
  46. );
  47. $this->_aGridObjects = array(
  48. 'administration' => $this->CNF['OBJECT_GRID_ADMINISTRATION'],
  49. 'view' => $this->CNF['OBJECT_GRID_VIEW'],
  50. );
  51. $this->_aPrefixes = array(
  52. 'style' => 'bx-acl',
  53. 'option' => 'bx_acl_',
  54. );
  55. $this->_aJsClasses = array(
  56. 'main' => 'BxAclMain',
  57. 'form' => 'BxAclForm',
  58. 'administration' => 'BxAclAdministration',
  59. );
  60. $this->_aJsObjects = array(
  61. 'main' => 'oAclMain',
  62. 'form' => 'oAclForm',
  63. 'administration' => 'oAclAdministration',
  64. );
  65. $sHtmlPrefix = str_replace('_', '-', $this->_sName);
  66. $this->_aHtmlIds = array(
  67. 'popup_price' => $sHtmlPrefix . '-popup-price'
  68. );
  69. $oPayments = BxDolPayments::getInstance();
  70. $this->_iOwner = (int)$oPayments->getOption('site_admin');
  71. $this->_aCurrency = array(
  72. 'code' => $oPayments->getOption('default_currency_code'),
  73. 'sign' => $oPayments->getOption('default_currency_sign')
  74. );
  75. $this->_bExpireNotifyOnce = true;
  76. $this->_iExpireNotificationDays = 1;
  77. $this->_iRemoveExpiredFor = 30;
  78. }
  79. public function init(&$oDb)
  80. {
  81. $this->_oDb = &$oDb;
  82. $sOptionPrefix = $this->getPrefix('option');
  83. $this->_iExpireNotificationDays = (int)getParam($sOptionPrefix . 'expire_notification_days');
  84. $this->_bExpireNotifyOnce = getParam($sOptionPrefix . 'expire_notify_once') == 'on';
  85. $this->_iRemoveExpiredFor = (int)getParam($sOptionPrefix . 'remove_expired_for');
  86. }
  87. public function getExpireNotificationDays()
  88. {
  89. return $this->_iExpireNotificationDays;
  90. }
  91. public function isExpireNotifyOnce()
  92. {
  93. return $this->_bExpireNotifyOnce;
  94. }
  95. public function getRemoveExpiredFor()
  96. {
  97. return $this->_iRemoveExpiredFor;
  98. }
  99. public function getHtmlIds($sKey = '')
  100. {
  101. if(empty($sKey))
  102. return $this->_aHtmlIds;
  103. return isset($this->_aHtmlIds[$sKey]) ? $this->_aHtmlIds[$sKey] : '';
  104. }
  105. public function getOwner()
  106. {
  107. return $this->_iOwner;
  108. }
  109. public function getCurrency()
  110. {
  111. return $this->_aCurrency;
  112. }
  113. public function getPriceName($sName)
  114. {
  115. return uriGenerate($sName, $this->CNF['TABLE_PRICES'], $this->CNF['FIELD_NAME']);
  116. }
  117. }
  118. /** @} */