mirror of
https://github.com/silverstripe/silverstripe-spamprotection.git
synced 2024-10-22 14:05:59 +02:00
APICHANGE: added SpamProtector interface for spam protectors;
MINOR: Fixed instructions
This commit is contained in:
parent
c2be8dbee5
commit
ca8c02b531
2
INSTALL
2
INSTALL
@ -41,7 +41,7 @@ This following code should appear after the form creation.
|
|||||||
|
|
||||||
<<<< CODE STARTS >>>>
|
<<<< CODE STARTS >>>>
|
||||||
|
|
||||||
$protector = SpamProtecterManager::update_form($form, 'Message', $callbackObj);
|
$protector = SpamProtecterManager::update_form($form, 'Message');
|
||||||
|
|
||||||
<<<< CODE ENDS >>>>
|
<<<< CODE ENDS >>>>
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ class SpamProtecterManager {
|
|||||||
* Add the spam protecter field to a form
|
* Add the spam protecter field to a form
|
||||||
* @param Form the form that the protecter field added into
|
* @param Form the form that the protecter field added into
|
||||||
* @param string the name of the field that the protecter field will be added in front of
|
* @param string the name of the field that the protecter field will be added in front of
|
||||||
* @param object an object that implements Spamable
|
|
||||||
* @param array an associative array
|
* @param array an associative array
|
||||||
* with the name of the spam web service's field, for example post_title, post_body, author_name
|
* with the name of the spam web service's field, for example post_title, post_body, author_name
|
||||||
* and a string of field names (seperated by comma) as a value.
|
* and a string of field names (seperated by comma) as a value.
|
||||||
@ -28,12 +27,12 @@ class SpamProtecterManager {
|
|||||||
* @return SpamProtector object on success or null if the spamprotecter class is not found
|
* @return SpamProtector object on success or null if the spamprotecter class is not found
|
||||||
* also null if spamprotecterfield creation fails.
|
* also null if spamprotecterfield creation fails.
|
||||||
*/
|
*/
|
||||||
static function update_form($form, $before=null, $callbackObject=null, $fieldsToSpamServiceMapping=null) {
|
static function update_form($form, $before=null, $fieldsToSpamServiceMapping=null) {
|
||||||
if (!class_exists(self::$spam_protecter)) return null;
|
if (!class_exists(self::$spam_protecter)) return null;
|
||||||
|
|
||||||
$protecter = new self::$spam_protecter();
|
$protecter = new self::$spam_protecter();
|
||||||
try {
|
try {
|
||||||
$check = $protecter->updateForm($form, $before, $callbackObject, $fieldsToSpamServiceMapping);
|
$check = $protecter->updateForm($form, $before, $fieldsToSpamServiceMapping);
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
$form->setMessage(
|
$form->setMessage(
|
||||||
@ -49,13 +48,16 @@ class SpamProtecterManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark a DataObject as spam
|
* Send Feedback to the Spam Protection. The level of feedback
|
||||||
|
* will depend on the Protector class.
|
||||||
*
|
*
|
||||||
* @param DataObject
|
* @param DataObject The Object which you want to send feedback about. Must have a
|
||||||
|
* SessionID field.
|
||||||
|
* @param String Feedback on the $object usually 'spam' or 'ham' for non spam entries
|
||||||
*/
|
*/
|
||||||
static function mark_spam($object) {
|
static function send_feedback($object, $feedback) {
|
||||||
$protecter = new self::$spam_protecter();
|
$protecter = new self::$spam_protecter();
|
||||||
return $protecter->markAsSpam($object);
|
return $protecter->sendFeedback($object, $feedback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
19
code/SpamProtector.php
Normal file
19
code/SpamProtector.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spam Protector base interface. All Protectors should implement this interface
|
||||||
|
* to ensure that they contain all the correct methods and we do not get too many
|
||||||
|
* odd missing function errors
|
||||||
|
*
|
||||||
|
* @package SpamProtection
|
||||||
|
*/
|
||||||
|
|
||||||
|
interface SpamProtector {
|
||||||
|
|
||||||
|
public function sendFeedback($object = null, $feedback = "");
|
||||||
|
|
||||||
|
public function updateForm($form, $before = null, $fieldsToSpamServiceMapping = null);
|
||||||
|
|
||||||
|
public function setFieldMapping($fieldToPostTitle, $fieldsToPostBody = null, $fieldToAuthorName = null, $fieldToAuthorUrl = null, $fieldToAuthorEmail = null, $fieldToAuthorOpenId = null);
|
||||||
|
}
|
||||||
|
?>
|
Loading…
Reference in New Issue
Block a user