1
0

BxBaseModGroupsConnectionFans.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 Groups Groups
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxBaseModGroupsConnectionFans extends BxTemplConnection
  12. {
  13. protected $_sModule;
  14. protected $_oModule;
  15. public function __construct($aObject)
  16. {
  17. parent::__construct($aObject);
  18. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  19. }
  20. protected function _checkAllowedConnectInitiator ($oInitiator, $isPerformAction = false)
  21. {
  22. if(!bx_srv($oInitiator->getModule(), 'act_as_profile'))
  23. return CHECK_ACTION_RESULT_ALLOWED;
  24. return parent::_checkAllowedConnectInitiator($oInitiator, $isPerformAction);
  25. }
  26. public function _checkAllowedConnectContent ($oContent)
  27. {
  28. $CNF = &$this->_oModule->_oConfig->CNF;
  29. if(bx_srv($oContent->getModule(), 'act_as_profile'))
  30. return CHECK_ACTION_RESULT_ALLOWED;
  31. if(!empty($CNF['OBJECT_PRIVACY_VIEW']) && ($oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW'])) !== false) {
  32. $iContentId = $oContent->getContentId();
  33. $aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);
  34. if(in_array($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']], array_merge($oPrivacy->getPartiallyVisiblePrivacyGroups(), ['s'])))
  35. return CHECK_ACTION_RESULT_ALLOWED;
  36. }
  37. return parent::_checkAllowedConnectContent($oContent);
  38. }
  39. }
  40. /** @} */