BxInvResponse.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 Invites Invites
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxInvResponse extends BxDolAlertsResponse
  12. {
  13. protected $_sModule;
  14. protected $_oModule;
  15. public function __construct()
  16. {
  17. parent::__construct();
  18. $this->_sModule = 'bx_invites';
  19. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  20. }
  21. /**
  22. * Overwtire the method of parent class.
  23. *
  24. * @param BxDolAlerts $oAlert an instance of alert.
  25. */
  26. public function response($oAlert)
  27. {
  28. $sMethod = '_process' . bx_gen_method_name($oAlert->sUnit . '_' . $oAlert->sAction);
  29. if(!method_exists($this, $sMethod))
  30. return;
  31. return $this->$sMethod($oAlert);
  32. }
  33. protected function _processAccountAddForm($oAlert)
  34. {
  35. $sCode = $this->_oModule->serviceAccountAddFormCheck();
  36. if($sCode)
  37. $oAlert->aExtras['form_code'] = $sCode;
  38. }
  39. protected function _processAccountAdded($oAlert)
  40. {
  41. if(!$this->_oModule->_oConfig->isRegistrationByInvitation())
  42. return;
  43. $sKeyCode = $this->_oModule->_oConfig->getKeyCode();
  44. $sKey = BxDolSession::getInstance()->getUnsetValue($sKeyCode);
  45. if($sKey === false)
  46. return;
  47. $this->_oModule->attachAccountIdToInvite($oAlert->iObject, $sKey);
  48. $oKeys = BxDolKey::getInstance();
  49. if($oKeys && $oKeys->isKeyExists($sKey))
  50. $oKeys->removeKey($sKey);
  51. return;
  52. }
  53. protected function _processProfileDelete($oAlert)
  54. {
  55. $this->_oModule->_oDb->deleteInvites(array('profile_id' => $oAlert->iObject));
  56. }
  57. }
  58. /** @} */