BxAntispamConfig.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 Antispam Antispam
  7. * @ingroup DolphinModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxDolModuleConfig');
  12. class BxAntispamConfig extends BxDolModuleConfig
  13. {
  14. /**
  15. * map system options to the local options names
  16. */
  17. protected $_aOptionsMap = array (
  18. 'antispam_block' => 'bx_antispam_block',
  19. 'antispam_report' => 'bx_antispam_report',
  20. 'dnsbl_enable' => 'bx_antispam_dnsbl_enable',
  21. 'uridnsbl_enable' => 'bx_antispam_uridnsbl_enable',
  22. 'dnsbl_behaviour' => 'bx_antispam_dnsbl_behaviour',
  23. 'akismet_enable' => 'bx_antispam_akismet_enable',
  24. );
  25. /**
  26. * default local options, it is filled in with real system options in class contructor, @see restoreAntispamOptions
  27. */
  28. protected $_aOptions = array (
  29. 'antispam_block' => '',
  30. 'antispam_report' => '',
  31. 'dnsbl_enable' => '',
  32. 'uridnsbl_enable' => '',
  33. 'dnsbl_behaviour' => 'approval',
  34. 'akismet_enable' => '',
  35. );
  36. public function __construct($aModule)
  37. {
  38. parent::__construct($aModule);
  39. $this->restoreAntispamOptions ();
  40. }
  41. /**
  42. * Set local option value, system value stays intact, useful for testing and debugging
  43. */
  44. public function setAntispamOption ($sOption, $mixedVal)
  45. {
  46. $this->_aOptions[$sOption] = $mixedVal;
  47. }
  48. /**
  49. * Get an option, local value
  50. */
  51. public function getAntispamOption ($sOption)
  52. {
  53. return $this->_aOptions[$sOption];
  54. }
  55. /**
  56. * set local options values from system options
  57. */
  58. public function restoreAntispamOptions ()
  59. {
  60. foreach ($this->_aOptionsMap as $sNameLocal => $sNameParam)
  61. $this->setAntispamOption($sNameLocal, getParam($sNameParam));
  62. }
  63. }
  64. /** @} */