BxForumCmts.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 Forum Forum
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxForumCmts extends BxTemplCmts
  12. {
  13. protected $MODULE;
  14. protected $_oModule;
  15. public function __construct($sSystem, $iId, $iInit = 1)
  16. {
  17. $this->MODULE = 'bx_forum';
  18. $this->_oModule = BxDolModule::getInstance($this->MODULE);
  19. parent::__construct($sSystem, $iId, $iInit, $this->_oModule->_oTemplate);
  20. $this->setTableNameFiles('bx_forum_files');
  21. }
  22. public function isPostReplyAllowed($isPerformAction = false)
  23. {
  24. $aContentInfo = $this->_oModule->_oDb->getContentInfoById($this->_iId);
  25. if(!$aContentInfo || (int)$aContentInfo[$this->_oModule->_oConfig->CNF['FIELD_LOCK']] == 1)
  26. return false;
  27. return parent::isPostReplyAllowed($isPerformAction);
  28. }
  29. public function onPostAfter($iId)
  30. {
  31. $CNF = &$this->_oModule->_oConfig->CNF;
  32. if(!parent::onPostAfter($iId))
  33. return false;
  34. if(getParam($CNF['PARAM_AUTOSUBSCRIBE_REPLIED']) == 'on')
  35. BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTION_SUBSCRIBERS'])->actionAdd((int)$this->getId(), (int)$this->_getAuthorId());
  36. }
  37. public function getCommentsBlock($iParentId = 0, $iVParentId = 0, $bInDesignbox = true)
  38. {
  39. $mixedBlock = parent::getCommentsBlock($iParentId, $iVParentId, $bInDesignbox);
  40. if (is_array($mixedBlock) && isset($mixedBlock['title']))
  41. $mixedBlock['title'] = _t('_bx_forum_page_block_title_entry_comments', $this->getCommentsCount());
  42. return $mixedBlock;
  43. }
  44. public function getComment($mixedCmt, $aBp = array(), $aDp = array())
  45. {
  46. return parent::getComment($mixedCmt, $aBp, array_merge($aDp, array(
  47. 'class_comment' => ' bx-def-box bx-def-padding bx-def-round-corners bx-def-color-bg-box'
  48. )));
  49. }
  50. protected function _getFormObject($sAction = BX_CMT_ACTION_POST)
  51. {
  52. $CNF = &$this->_oModule->_oConfig->CNF;
  53. $oResult = parent::_getFormObject($sAction);
  54. if(!isset($oResult->aInputs['cmt_image']))
  55. return $oResult;
  56. $oResult->aInputs['cmt_image']['storage_object'] = $CNF['OBJECT_STORAGE_CMTS'];
  57. $oResult->aInputs['cmt_image']['images_transcoder'] = $CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW_CMTS'];
  58. $oResult->aInputs['cmt_image']['upload_buttons_titles'] = array('Simple' => 'paperclip');
  59. return $oResult;
  60. }
  61. protected function _getForm($sAction, $iId)
  62. {
  63. $oForm = parent::_getForm($sAction, $iId);
  64. if(isset($oForm->aInputs['cmt_text'])) {
  65. $oForm->aInputs['cmt_text']['html'] = 3;
  66. $oForm->aInputs['cmt_text']['db']['pass'] = 'XssHtml';
  67. }
  68. return $oForm;
  69. }
  70. }
  71. /** @} */