BxAntispamConfig.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. class BxAntispamConfig extends BxDolModuleConfig
  12. {
  13. /**
  14. * map system options to the local options names
  15. */
  16. protected $_aOptionsMap = array (
  17. 'antispam_block' => 'bx_antispam_block',
  18. 'antispam_report' => 'bx_antispam_report',
  19. 'dnsbl_enable' => 'bx_antispam_dnsbl_enable',
  20. 'uridnsbl_enable' => 'bx_antispam_uridnsbl_enable',
  21. 'dnsbl_behaviour_login' => 'bx_antispam_dnsbl_behaviour_login',
  22. 'dnsbl_behaviour_join' => 'bx_antispam_dnsbl_behaviour_join',
  23. 'akismet_enable' => 'bx_antispam_akismet_enable',
  24. 'disposable_email_domains_mode' => 'bx_antispam_disposable_email_domains_mode',
  25. 'disposable_email_domains_behaviour_join' => 'bx_antispam_disposable_email_domains_behaviour_join',
  26. 'profanity_enable' => 'bx_antispam_profanity_filter_enable',
  27. 'toxicity_enable' => 'bx_antispam_toxicity_filter_enable',
  28. 'toxicity_action' => 'bx_antispam_toxicity_filter_action',
  29. 'toxicity_report' => 'bx_antispam_toxicity_filter_report',
  30. 'lm_enable' => 'bx_antispam_lasso_moderation_enable',
  31. 'lm_api_key' => 'bx_antispam_lasso_moderation_api_key',
  32. 'lm_webhook_secret' => 'bx_antispam_lasso_moderation_webhook_secret',
  33. 'lm_action' => 'bx_antispam_lasso_moderation_action',
  34. 'lm_report' => 'bx_antispam_lasso_moderation_report',
  35. 'lm_thd_toxicity' => 'bx_antispam_lasso_moderation_threshold_toxicity',
  36. 'lm_thd_threat' => 'bx_antispam_lasso_moderation_threshold_threat',
  37. 'lm_thd_identity_attack' => 'bx_antispam_lasso_moderation_threshold_identity_attack',
  38. 'lm_thd_profanity' => 'bx_antispam_lasso_moderation_threshold_profanity',
  39. );
  40. /**
  41. * default local options, it is filled in with real system options in class contructor, @see restoreAntispamOptions
  42. */
  43. protected $_aOptions = array (
  44. 'antispam_block' => '',
  45. 'antispam_report' => '',
  46. 'dnsbl_enable' => '',
  47. 'uridnsbl_enable' => '',
  48. 'dnsbl_behaviour_login' => 'block',
  49. 'dnsbl_behaviour_join' => 'approval',
  50. 'akismet_enable' => '',
  51. 'profanity_enable' => '',
  52. 'toxicity_enable' => '',
  53. 'toxicity_action' => '',
  54. 'toxicity_report' => '',
  55. 'lm_enable' => '',
  56. 'lm_api_key' => '',
  57. 'lm_webhook_secret' => '',
  58. 'lm_action' => '',
  59. 'lm_report' => '',
  60. 'lm_thd_toxicity' => '',
  61. 'lm_thd_threat' => '',
  62. 'lm_thd_identity_attack' => '',
  63. 'lm_thd_profanity' => '',
  64. );
  65. public function __construct($aModule)
  66. {
  67. parent::__construct($aModule);
  68. $this->restoreAntispamOptions ();
  69. }
  70. /**
  71. * Set local option value, system value stays intact, useful for testing and debugging
  72. */
  73. public function setAntispamOption ($sOption, $mixedVal)
  74. {
  75. $this->_aOptions[$sOption] = $mixedVal;
  76. }
  77. /**
  78. * Get an option, local value
  79. */
  80. public function getAntispamOption ($sOption)
  81. {
  82. return $this->_aOptions[$sOption];
  83. }
  84. /**
  85. * set local options values from system options
  86. */
  87. public function restoreAntispamOptions ()
  88. {
  89. foreach ($this->_aOptionsMap as $sNameLocal => $sNameParam)
  90. $this->setAntispamOption($sNameLocal, getParam($sNameParam));
  91. }
  92. }
  93. /** @} */