BxInvResponse.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 Invites Invites
  7. * @ingroup DolphinModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxDolModule');
  12. bx_import('BxDolAlertsResponse');
  13. class BxInvResponse extends BxDolAlertsResponse
  14. {
  15. protected $_sModule;
  16. protected $_oModule;
  17. public function __construct()
  18. {
  19. parent::__construct();
  20. $this->_sModule = 'bx_invites';
  21. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  22. }
  23. /**
  24. * Overwtire the method of parent class.
  25. *
  26. * @param BxDolAlerts $oAlert an instance of alert.
  27. */
  28. public function response($oAlert)
  29. {
  30. if($oAlert->sUnit != 'account' || !in_array($oAlert->sAction, array('add_form', 'added')))
  31. return;
  32. $sMethod = '_process' . bx_gen_method_name($oAlert->sUnit . '_' . $oAlert->sAction);
  33. if(!method_exists($this, $sMethod))
  34. return;
  35. return $this->$sMethod($oAlert);
  36. }
  37. protected function _processAccountAddForm($oAlert)
  38. {
  39. bx_import('BxDolSession');
  40. $oSession = BxDolSession::getInstance();
  41. $sKeyCode = $this->_oModule->_oConfig->getKeyCode();
  42. if(bx_get($sKeyCode) !== false) {
  43. $sKey = bx_process_input(bx_get($sKeyCode));
  44. bx_import('BxDolKey');
  45. $oKeys = BxDolKey::getInstance();
  46. if($oKeys && $oKeys->isKeyExists($sKey))
  47. $oSession->setValue($sKeyCode, $sKey);
  48. }
  49. $sKey = $oSession->getValue($sKeyCode);
  50. if($sKey === false)
  51. $oAlert->aExtras['form_code'] = $this->_oModule->_oTemplate->getBlockRequest();
  52. return;
  53. }
  54. protected function _processAccountAdded($oAlert)
  55. {
  56. $sKeyCode = $this->_oModule->_oConfig->getKeyCode();
  57. bx_import('BxDolSession');
  58. $sKey = BxDolSession::getInstance()->getUnsetValue($sKeyCode);
  59. if($sKey === false)
  60. return;
  61. bx_import('BxDolKey');
  62. $oKeys = BxDolKey::getInstance();
  63. if($oKeys && $oKeys->isKeyExists($sKey))
  64. $oKeys->removeKey($sKey);
  65. return;
  66. }
  67. }
  68. /** @} */