BxInvConfig.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. 'URL_REQUESTS' => 'page.php?i=invites-requests',
  30. 'URL_INVITES' => 'page.php?i=invites-invites',
  31. 'TABLE_REQUESTS' => $aModule['db_prefix'] . 'requests',
  32. 'TABLE_INVITES' => $aModule['db_prefix'] . 'invites',
  33. 'TABLE_ENTRIES' => $aModule['db_prefix'] . 'invites',
  34. 'FIELD_ADDED' => 'date'
  35. );
  36. $this->_aObjects = array(
  37. 'alert' => $this->_sName,
  38. 'grid_requests' => $this->_sName . '_requests',
  39. 'grid_invites' => $this->_sName . '_invites',
  40. 'form_invite' => $this->_sName . '_invite',
  41. 'form_request' => $this->_sName . '_request',
  42. 'form_display_invite_send' => $this->_sName . '_invite_send',
  43. 'form_display_request_send' => $this->_sName . '_request_send',
  44. );
  45. $this->_aPrefixes = array(
  46. 'style' => 'bx-inv',
  47. 'option' => 'bx_invites_',
  48. );
  49. $this->_iCountPerUser = 0;
  50. $this->_sKeyCode = 'icode';
  51. $this->_iKeyLifetime = 86400;
  52. $this->_bRequestInvite = true;
  53. $this->_sRequestsEmail = '';
  54. $this->_bRegistrationByInvitation = true;
  55. $this->_aJsClasses = array(
  56. 'main' => 'BxInvMain',
  57. );
  58. $this->_aJsObjects = array(
  59. 'main' => 'oInvMain',
  60. );
  61. $sHtmlPrefix = str_replace('_', '-', $this->_sName);
  62. $this->_aHtmlIds = array(
  63. 'link_popup' => $sHtmlPrefix . '-link-popup',
  64. 'link_input' => $sHtmlPrefix . '-link-input',
  65. );
  66. }
  67. public function init(&$oDb)
  68. {
  69. $this->_oDb = &$oDb;
  70. $sOptionPrefix = $this->getPrefix('option');
  71. $this->_iCountPerUser = (int)getParam($sOptionPrefix . 'count_per_user');
  72. $this->_iKeyLifetime = 86400 * (int)getParam($sOptionPrefix . 'key_lifetime');
  73. $this->_bRequestInvite = getParam($sOptionPrefix . 'enable_request_invite') == 'on';
  74. $this->_sRequestsEmail = getParam($sOptionPrefix . 'requests_email');
  75. $this->_bRegistrationByInvitation = getParam($sOptionPrefix . 'enable_reg_by_inv') == 'on';
  76. }
  77. public function getCountPerUser()
  78. {
  79. return $this->_iCountPerUser;
  80. }
  81. public function getKeyCode()
  82. {
  83. return $this->_sKeyCode;
  84. }
  85. public function getKeyLifetime()
  86. {
  87. return $this->_iKeyLifetime;
  88. }
  89. public function isRequestInvite()
  90. {
  91. return $this->_bRequestInvite;
  92. }
  93. public function getRequestsEmail()
  94. {
  95. return $this->_sRequestsEmail;
  96. }
  97. public function isRegistrationByInvitation()
  98. {
  99. return $this->_bRegistrationByInvitation;
  100. }
  101. public function getHtmlIds($sKey = '')
  102. {
  103. if(empty($sKey))
  104. return $this->_aHtmlIds;
  105. return isset($this->_aHtmlIds[$sKey]) ? $this->_aHtmlIds[$sKey] : '';
  106. }
  107. }
  108. /** @} */