BxBaseModProfileCmts.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 BaseProfile Base classes for profile modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxBaseModProfileCmts extends BxTemplCmts
  12. {
  13. protected $_sModule;
  14. protected $_oModule;
  15. function __construct($sSystem, $iId, $iInit = 1)
  16. {
  17. parent::__construct($sSystem, $iId, $iInit);
  18. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  19. }
  20. public function isPostAllowed ($isPerformAction = false)
  21. {
  22. $bCheckResult = $this->_isPostAllowed ($isPerformAction);
  23. /**
  24. * @hooks
  25. * @hookdef hook-bx_base_profile-comment_post_allowed '{module_name}', 'comment_post_allowed' - hook to override the result of checking whether comment posting action allowed or not
  26. * - $unit_name - module name
  27. * - $action - equals `comment_post_allowed`
  28. * - $object_id - content id
  29. * - $sender_id - not used
  30. * - $extra_params - array of additional params with the following array keys:
  31. * - `check_result` - [boolean] by ref, check action result, can be overridden in hook processing.
  32. * @hook @ref hook-bx_base_profile-comment_post_allowed
  33. */
  34. bx_alert($this->_sModule, 'comment_post_allowed', $this->getId(), false, [
  35. 'check_result' => &$bCheckResult
  36. ]);
  37. return $bCheckResult;
  38. }
  39. protected function _isPostAllowed ($isPerformAction = false)
  40. {
  41. $CNF = &$this->_oModule->_oConfig->CNF;
  42. $oProfileOwner = BxDolProfile::getInstanceByContentAndType($this->getId(), $this->_sModule);
  43. if($oProfileOwner !== false && $oProfileOwner->checkAllowedPostInProfile() !== CHECK_ACTION_RESULT_ALLOWED)
  44. return false;
  45. return parent::isPostAllowed($isPerformAction);
  46. }
  47. }
  48. /** @} */