mirror of
https://github.com/silverstripe/silverstripe-spamprotection.git
synced 2024-10-22 14:05:59 +02:00
40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
/**
|
|
* This class acts as a template for spam protecting form field, for instance MollomField.
|
|
* It provides a number of properties for mapping fields of the form which this object belongs to
|
|
* to spam checking service fields.
|
|
*
|
|
* In order to further process the form values or take any action according the status of spam checking,
|
|
* markAsSpam() and markAsHam should be called in validate() after the status of the spam checking has
|
|
* been obtained.
|
|
*
|
|
*/
|
|
class SpamProtecterField extends FormField {
|
|
|
|
protected $spanControlCallbackObj = null;
|
|
|
|
function setCallbackObject($callbackObject) {
|
|
$this->spanControlCallbackObj = $callbackObject;
|
|
}
|
|
|
|
/**
|
|
* Tell the callback object the submission is spam
|
|
*/
|
|
protected function markAsSpam() {
|
|
if ($this->spanControlCallbackObj && $this->spanControlCallbackObj instanceof Spamable) {
|
|
$this->spanControlCallbackObj->markAsSpam($this->getForm());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Tell the callback object the submission is ham
|
|
*/
|
|
protected function markAsHam() {
|
|
if ($this->spanControlCallbackObj && $this->spanControlCallbackObj instanceof Spamable) {
|
|
$this->spanControlCallbackObj->markAsHam($this->getForm());
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
?>
|