BxAntispamConfig.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. );
  28. /**
  29. * default local options, it is filled in with real system options in class contructor, @see restoreAntispamOptions
  30. */
  31. protected $_aOptions = array (
  32. 'antispam_block' => '',
  33. 'antispam_report' => '',
  34. 'dnsbl_enable' => '',
  35. 'uridnsbl_enable' => '',
  36. 'dnsbl_behaviour_login' => 'block',
  37. 'dnsbl_behaviour_join' => 'approval',
  38. 'akismet_enable' => '',
  39. 'profanity_enable' => '',
  40. );
  41. public function __construct($aModule)
  42. {
  43. parent::__construct($aModule);
  44. $this->restoreAntispamOptions ();
  45. }
  46. /**
  47. * Set local option value, system value stays intact, useful for testing and debugging
  48. */
  49. public function setAntispamOption ($sOption, $mixedVal)
  50. {
  51. $this->_aOptions[$sOption] = $mixedVal;
  52. }
  53. /**
  54. * Get an option, local value
  55. */
  56. public function getAntispamOption ($sOption)
  57. {
  58. return $this->_aOptions[$sOption];
  59. }
  60. /**
  61. * set local options values from system options
  62. */
  63. public function restoreAntispamOptions ()
  64. {
  65. foreach ($this->_aOptionsMap as $sNameLocal => $sNameParam)
  66. $this->setAntispamOption($sNameLocal, getParam($sNameParam));
  67. }
  68. }
  69. /** @} */