mirror of
https://github.com/silverstripe/silverstripe-mathspamprotection
synced 2024-10-22 08:05:52 +02:00
Merge pull request #30 from Taitava/master
Create allow_numeric_answer option
This commit is contained in:
commit
76b563993c
@ -22,6 +22,13 @@ class MathSpamProtectorField extends TextField {
|
|||||||
*/
|
*/
|
||||||
private static $question_prefix;
|
private static $question_prefix;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @config
|
||||||
|
*
|
||||||
|
* @var bool $allow_numeric_answer
|
||||||
|
*/
|
||||||
|
private static $allow_numeric_answer = true;
|
||||||
|
|
||||||
public function Field($properties = array()) {
|
public function Field($properties = array()) {
|
||||||
if(Config::inst()->get('MathSpamProtectorField', 'enabled')) {
|
if(Config::inst()->get('MathSpamProtectorField', 'enabled')) {
|
||||||
return parent::Field($properties);
|
return parent::Field($properties);
|
||||||
@ -126,7 +133,7 @@ class MathSpamProtectorField extends TextField {
|
|||||||
|
|
||||||
$word = MathSpamProtectorField::digit_to_word($v1 + $v2);
|
$word = MathSpamProtectorField::digit_to_word($v1 + $v2);
|
||||||
|
|
||||||
return ($word == strtolower($answer) || ($v1 + $v2) == $answer);
|
return ($word == strtolower($answer) || (Config::inst()->get('MathSpamProtectorField', 'allow_numeric_answer') && (($v1 + $v2) == $answer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user