BxOrgsAlertsResponse.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 Organizations Organizations
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxOrgsAlertsResponse extends BxBaseModGroupsAlertsResponse
  12. {
  13. public function __construct()
  14. {
  15. $this->MODULE = 'bx_organizations';
  16. parent::__construct();
  17. }
  18. public function response($oAlert)
  19. {
  20. parent::response($oAlert);
  21. $sMethod = 'process' . bx_gen_method_name($oAlert->sUnit . '_' . $oAlert->sAction);
  22. if(method_exists($this, $sMethod))
  23. $this->$sMethod($oAlert);
  24. }
  25. protected function processAccountCheckSwitchContext(&$oAlert)
  26. {
  27. if ($oAlert->aExtras['override_result'])
  28. return;
  29. $iProfile = (int)$oAlert->aExtras['switch_to_profile'];
  30. $oProfile = BxDolProfile::getInstance($iProfile);
  31. if(!$oProfile || $oProfile->getModule() != $this->_oModule->_oConfig->getName())
  32. return;
  33. $aDataEntry = $this->_oModule->_oDb->getContentInfoById($oProfile->getContentId());
  34. if(empty($aDataEntry) || !is_array($aDataEntry))
  35. return;
  36. $oAlert->aExtras['override_result'] = $oAlert->iObject == $oAlert->aExtras['viewer_account'] || $this->_oModule->isAllowedActionByRole(BX_ORGANIZATIONS_ACTION_SWITCH_TO_PROFILE, $aDataEntry, $iProfile, $oAlert->iSender);
  37. }
  38. }
  39. /** @} */