BxInvConfig.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 Invites Invites
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxInvConfig extends BxBaseModGeneralConfig
  12. {
  13. protected $_oDb;
  14. protected $_iCountPerUser;
  15. protected $_sKeyCode;
  16. protected $_iKeyLifetime;
  17. protected $_bRequestInvite;
  18. protected $_sRequestsEmail;
  19. protected $_bRegistrationByInvitation;
  20. /**
  21. * Constructor
  22. */
  23. public function __construct($aModule)
  24. {
  25. parent::__construct($aModule);
  26. $this->CNF = array (
  27. 'URL_INVITE' => 'page.php?i=invites-invite',
  28. 'URL_REQUEST' => 'page.php?i=invites-request',
  29. );
  30. $this->_aObjects = array(
  31. 'alert' => $this->_sName,
  32. 'grid_requests' => $this->_sName . '_requests',
  33. 'form_invite' => $this->_sName . '_invite',
  34. 'form_request' => $this->_sName . '_request',
  35. 'form_display_invite_send' => $this->_sName . '_invite_send',
  36. 'form_display_request_send' => $this->_sName . '_request_send',
  37. );
  38. $this->_aPrefixes = array(
  39. 'style' => 'bx-inv',
  40. 'option' => 'bx_invites_',
  41. );
  42. $this->_iCountPerUser = 0;
  43. $this->_sKeyCode = 'icode';
  44. $this->_iKeyLifetime = 86400;
  45. $this->_bRequestInvite = true;
  46. $this->_sRequestsEmail = '';
  47. $this->_bRegistrationByInvitation = true;
  48. $this->_aJsClasses = array(
  49. 'main' => 'BxInvMain',
  50. );
  51. $this->_aJsObjects = array(
  52. 'main' => 'oInvMain',
  53. );
  54. $sHtmlPrefix = str_replace('_', '-', $this->_sName);
  55. $this->_aHtmlIds = array(
  56. 'link_popup' => $sHtmlPrefix . '-link-popup',
  57. 'link_input' => $sHtmlPrefix . '-link-input',
  58. );
  59. }
  60. public function init(&$oDb)
  61. {
  62. $this->_oDb = &$oDb;
  63. $sOptionPrefix = $this->getPrefix('option');
  64. $this->_iCountPerUser = (int)getParam($sOptionPrefix . 'count_per_user');
  65. $this->_iKeyLifetime = 86400 * (int)getParam($sOptionPrefix . 'key_lifetime');
  66. $this->_bRequestInvite = getParam($sOptionPrefix . 'enable_request_invite') == 'on';
  67. $this->_sRequestsEmail = getParam($sOptionPrefix . 'requests_email');
  68. $this->_bRegistrationByInvitation = getParam($sOptionPrefix . 'enable_reg_by_inv') == 'on';
  69. }
  70. public function getCountPerUser()
  71. {
  72. return $this->_iCountPerUser;
  73. }
  74. public function getKeyCode()
  75. {
  76. return $this->_sKeyCode;
  77. }
  78. public function getKeyLifetime()
  79. {
  80. return $this->_iKeyLifetime;
  81. }
  82. public function isRequestInvite()
  83. {
  84. return $this->_bRequestInvite;
  85. }
  86. public function getRequestsEmail()
  87. {
  88. return $this->_sRequestsEmail;
  89. }
  90. public function isRegistrationByInvitation()
  91. {
  92. return $this->_bRegistrationByInvitation;
  93. }
  94. public function getHtmlIds($sKey = '')
  95. {
  96. if(empty($sKey))
  97. return $this->_aHtmlIds;
  98. return isset($this->_aHtmlIds[$sKey]) ? $this->_aHtmlIds[$sKey] : '';
  99. }
  100. }
  101. /** @} */