BxBaseModConnectAlerts.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup BaseConnect Base classes for OAuth connect modules
  7. * @ingroup TridentModules
  8. *
  9. * @{
  10. */
  11. class BxBaseModConnectAlerts extends BxDolAlertsResponse
  12. {
  13. protected $oModule;
  14. public function response($o)
  15. {
  16. if ($o->sUnit == 'profile') {
  17. switch ($o->sAction) {
  18. case 'delete':
  19. // remove remote account
  20. $this->oModule->_oDb->deleteRemoteAccount($o->iObject);
  21. break;
  22. case 'add':
  23. // add remote account and local profile association
  24. $oProfile = BxDolProfile::getInstance($o->iObject);
  25. if ($oProfile && 'system' != $oProfile->getModule()) {
  26. bx_import('BxDolSession');
  27. $oSession = BxDolSession::getInstance();
  28. $iRemoteProfileId = $oSession->getValue($this->oModule->_oConfig->sSessionUid);
  29. if ($iRemoteProfileId) {
  30. $oSession->unsetValue($this->oModule->_oConfig->sSessionUid);
  31. $this->oModule->_oDb->saveRemoteId($o->iObject, $iRemoteProfileId);
  32. }
  33. }
  34. break;
  35. }
  36. }
  37. }
  38. }
  39. /** @} */