BxAntispamAlertsResponse.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 Antispam Antispam
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * alerts handler
  13. */
  14. class BxAntispamAlertsResponse extends BxDolAlertsResponse
  15. {
  16. public function response($oAlert)
  17. {
  18. if ('account' == $oAlert->sUnit) {
  19. switch ($oAlert->sAction) {
  20. case 'check_login':
  21. $oAlert->aExtras['error_msg'] = BxDolService::call('bx_antispam', 'check_login');
  22. break;
  23. case 'check_join':
  24. $oAlert->aExtras['error_msg'] = BxDolService::call('bx_antispam', 'check_join', array($oAlert->aExtras['email'], &$oAlert->aExtras['approve']));
  25. break;
  26. }
  27. } elseif ('system' == $oAlert->sUnit) {
  28. switch ($oAlert->sAction) {
  29. case 'check_spam_url':
  30. $oAlert->aExtras['is_spam'] = BxDolService::call('bx_antispam', 'is_spam_url', array(&$oAlert->aExtras['content']));
  31. break;
  32. case 'check_spam':
  33. $oAlert->aExtras['content'] = BxDolService::call('bx_antispam', 'filter_spam', array($oAlert->aExtras['content']));
  34. if ((!isset($oAlert->aExtras['type']) || 'textarea' == $oAlert->aExtras['type']) && is_string($oAlert->aExtras['content']))
  35. $oAlert->aExtras['is_spam'] = BxDolService::call('bx_antispam', 'is_spam', array(&$oAlert->aExtras['content']));
  36. break;
  37. case 'form_check':
  38. BxDolService::call('bx_antispam', 'check_form_for_toxicity', array(&$oAlert->aExtras['object']));
  39. break;
  40. case 'form_submitted':
  41. BxDolService::call('bx_antispam', 'on_form_submitted', array($oAlert->aExtras['module'], $oAlert->aExtras['entry_id'], $oAlert->aExtras['action'], &$oAlert->aExtras['form_object']));
  42. break;
  43. }
  44. } elseif ('comment' == $oAlert->sUnit && BxDolService::call('bx_antispam', 'is_last_form_submitted_toxic', array())) {
  45. BxDolService::call('bx_antispam', 'set_comment_as_pending', array($oAlert->iObject));
  46. }
  47. }
  48. }
  49. /** @} */