silverstripe-spamprotection/code/SpamProtectorField.php

45 lines
1.2 KiB
PHP
Raw Normal View History

2009-02-03 22:29:55 +01:00
<?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.
*
2009-09-14 05:14:58 +02:00
* @package spamprotection
2009-02-03 22:29:55 +01:00
*/
class SpamProtectorField extends FormField {
2009-02-03 22:29:55 +01:00
protected $spanControlCallbackObj = null;
2009-09-14 05:14:58 +02:00
/**
* Set the Callback Object
*/
2009-02-03 22:29:55 +01:00
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());
}
}
}
?>