BxInvTemplate.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 BxInvTemplate extends BxBaseModGeneralTemplate
  12. {
  13. function __construct(&$oConfig, &$oDb)
  14. {
  15. parent::__construct($oConfig, $oDb);
  16. }
  17. public function getCssJs()
  18. {
  19. $this->addCss(array(
  20. 'main.css',
  21. ));
  22. $this->addJs(array(
  23. 'clipboard.min.js',
  24. 'main.js'
  25. ));
  26. }
  27. public function getBlockRequestText($aRequest)
  28. {
  29. return $this->parseHtmlByName('request_text.html', array(
  30. 'style_prefix' => $this->_oConfig->getPrefix('style'),
  31. 'text' => bx_process_output(nl2br($aRequest['text']), BX_DATA_TEXT_MULTILINE),
  32. ));
  33. }
  34. public function getBlockInvite($iAccountId, $iProfileId)
  35. {
  36. $sInvitesRemain = '';
  37. if(!isAdmin($iAccountId)) {
  38. $iInvites = $this->_oConfig->getCountPerUser();
  39. $iInvited = $this->_oDb->getInvites(array('type' => 'count_by_account', 'value' => $iAccountId));
  40. $sInvitesRemain = $iInvites - $iInvited;
  41. }
  42. else
  43. $sInvitesRemain = _t('_bx_invites_txt_unlimited');
  44. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($this->_oConfig->CNF['URL_INVITE']);
  45. $this->getCssJs();
  46. return $this->parseHtmlByName('block_invite.html', array(
  47. 'style_prefix' => $this->_oConfig->getPrefix('style'),
  48. 'js_object' => $this->_oConfig->getJsObject('main'),
  49. 'text' => _t('_bx_invites_txt_invite_block_text', $sInvitesRemain),
  50. 'url' => $sUrl,
  51. 'js_code' => $this->getJsCode('main')
  52. ));
  53. }
  54. public function getBlockRequest()
  55. {
  56. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($this->_oConfig->CNF['URL_REQUEST']);
  57. $this->getCssJs();
  58. return $this->parseHtmlByName('block_request.html', array(
  59. 'style_prefix' => $this->_oConfig->getPrefix('style'),
  60. 'text' => _t('_bx_invites_txt_request_block_text'),
  61. 'bx_if:show_button_request' => array(
  62. 'condition' => $this->_oConfig->isRequestInvite(),
  63. 'content' => array(
  64. 'url' => $sUrl
  65. )
  66. )
  67. ));
  68. }
  69. public function getLinkPopup($sLink)
  70. {
  71. $sId = $this->_oConfig->getHtmlIds('link_popup');
  72. $sTitle = _t('_bx_invites_txt_link_popup_title');
  73. $sContent = $this->parseHtmlByName('popup_link.html', array(
  74. 'style_prefix' => $this->_oConfig->getPrefix('style'),
  75. 'html_id_link' => $this->_oConfig->getHtmlIds('link_input'),
  76. 'link' => $sLink
  77. ));
  78. return BxTemplFunctions::getInstance()->popupBox($sId, $sTitle, $sContent, true);
  79. }
  80. public function getJsCode($sType, $aParams = array(), $bWrap = true)
  81. {
  82. $aParams = array_merge(array(
  83. 'aHtmlIds' => $this->_oConfig->getHtmlIds()
  84. ), $aParams);
  85. return parent::getJsCode($sType, $aParams, $bWrap);
  86. }
  87. }
  88. /** @} */