BxSitesConfig.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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 Sites Sites
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxSitesConfig extends BxDolModuleConfig
  12. {
  13. public static $FIELD_AUTHOR = 'owner_id';
  14. public static $FIELD_ADDED = 'created';
  15. protected $_oDb;
  16. //General
  17. protected $sDomainMask;
  18. protected $aJsClasses;
  19. protected $aJsObjects;
  20. protected $sAnimationEffect;
  21. protected $iAnimationSpeed;
  22. //PayPal payments integration
  23. protected $iTrialMaxNumber;
  24. protected $fTrialPrice;
  25. protected $sTrialPeriod;
  26. protected $iTrialFrequency;
  27. protected $iTrialBillingCycles;
  28. protected $fRegularPrice;
  29. protected $sRegularPeriod;
  30. protected $iRegularFrequency;
  31. protected $iRegularBillingCycles;
  32. protected $sEmailBusiness;
  33. protected $sEmailSandbox;
  34. protected $bDemoMode;
  35. protected $sCurrencyCode;
  36. protected $sCurrencySign;
  37. protected $aPeriodConverter;
  38. /**
  39. * Constructor
  40. */
  41. function __construct($aModule)
  42. {
  43. parent::__construct($aModule);
  44. $this->sDomainMask = '%s.online.me';
  45. $this->aJsClasses = array('main' => 'BxSitesMain');
  46. $this->aJsObjects = array('main' => 'oSitesMain');
  47. $this->sAnimationEffect = 'fade';
  48. $this->iAnimationSpeed = 'slow';
  49. $this->aPeriodConverter = array(
  50. 'Day' => 86400,
  51. 'Week' => 604800,
  52. 'SemiMonth' => 1296000,
  53. 'Month' => 2592000,
  54. 'Year' => 31536000
  55. );
  56. }
  57. function init(&$oDb)
  58. {
  59. $this->_oDb = $oDb;
  60. $this->iTrialMaxNumber = (int)getParam('bx_sites_payment_trial_max_number');
  61. $this->fTrialPrice = (float)getParam('bx_sites_payment_trial_price');
  62. $this->sTrialPeriod = getParam('bx_sites_payment_trial_period');
  63. $this->iTrialFrequency = (float)getParam('bx_sites_payment_trial_frequency');
  64. $this->iTrialBillingCycles = 1;
  65. $this->fRegularPrice = (float)getParam('bx_sites_payment_regular_price');
  66. $this->sRegularPeriod = getParam('bx_sites_payment_regular_period');
  67. $this->iRegularFrequency = (float)getParam('bx_sites_payment_regular_frequency');
  68. $this->iRegularBillingCycles = 0;
  69. $this->sEmailBusiness = getParam('bx_sites_payment_email_business');
  70. $this->sEmailSandbox = getParam('bx_sites_payment_email_sandbox');
  71. $this->bDemoMode = getParam('bx_sites_payment_demo_mode') == 'on';
  72. $this->sCurrencyCode = getParam('bx_sites_payment_currency_code');
  73. $this->sCurrencySign = getParam('bx_sites_payment_currency_sign');
  74. }
  75. function getDomainMask()
  76. {
  77. return $this->sDomainMask;
  78. }
  79. function getPaymentPrice($sType)
  80. {
  81. $fResult = 0;
  82. switch($sType) {
  83. case BX_SITES_PP_PERIOD_TRIAL:
  84. $fResult = $this->fTrialPrice;
  85. break;
  86. case BX_SITES_PP_PERIOD_REGULAR:
  87. $fResult = $this->fRegularPrice;
  88. break;
  89. }
  90. return $fResult;
  91. }
  92. function getPaymentPeriod($sType, $bInSeconds = false)
  93. {
  94. $sResult = 0;
  95. switch($sType) {
  96. case BX_SITES_PP_PERIOD_TRIAL:
  97. $sResult = $this->sTrialPeriod;
  98. break;
  99. case BX_SITES_PP_PERIOD_REGULAR:
  100. $sResult = $this->sRegularPeriod;
  101. break;
  102. }
  103. return $bInSeconds ? $this->aPeriodConverter[$sResult] : $sResult;
  104. }
  105. function getPaymentFrequency($sType)
  106. {
  107. $iResult = 0;
  108. switch($sType) {
  109. case BX_SITES_PP_PERIOD_TRIAL:
  110. $iResult = $this->iTrialFrequency;
  111. break;
  112. case BX_SITES_PP_PERIOD_REGULAR:
  113. $iResult = $this->iRegularFrequency;
  114. break;
  115. }
  116. return $iResult;
  117. }
  118. function getPaymentBillingCycles($sType)
  119. {
  120. $iResult = 0;
  121. switch($sType) {
  122. case BX_SITES_PP_PERIOD_TRIAL:
  123. $iResult = $this->iTrialBillingCycles;
  124. break;
  125. case BX_SITES_PP_PERIOD_REGULAR:
  126. $iResult = $this->iRegularBillingCycles;
  127. break;
  128. }
  129. return $iResult;
  130. }
  131. function isPaymentDemo()
  132. {
  133. return $this->bDemoMode;
  134. }
  135. function getPaymentEmail()
  136. {
  137. return $this->isPaymentDemo() ? $this->sEmailSandbox : $this->sEmailBusiness;
  138. }
  139. function getCurrencyCode()
  140. {
  141. return $this->sCurrencyCode;
  142. }
  143. function getCurrencySign()
  144. {
  145. return $this->sCurrencySign;
  146. }
  147. function getTrialDuration()
  148. {
  149. return $this->getPaymentPeriod(BX_SITES_PP_PERIOD_TRIAL, true) * $this->iTrialFrequency * $this->iTrialBillingCycles;
  150. }
  151. function getTrialMaxNumber()
  152. {
  153. return $this->iTrialMaxNumber;
  154. }
  155. function getJsClass($sType = 'main')
  156. {
  157. if(empty($sType))
  158. return $this->aJsClasses;
  159. return $this->aJsClasses[$sType];
  160. }
  161. function getJsObject($sType = 'main')
  162. {
  163. if(empty($sType))
  164. return $this->aJsObjects;
  165. return $this->aJsObjects[$sType];
  166. }
  167. function getAnimationEffect()
  168. {
  169. return $this->sAnimationEffect;
  170. }
  171. function getAnimationSpeed()
  172. {
  173. return $this->iAnimationSpeed;
  174. }
  175. }
  176. /** @} */