2017 © Pedro Peláez
 

silverstripe-vendormodule spamprotection

Spam protection module for SilverStripe.

image

silverstripe/spamprotection

Spam protection module for SilverStripe.

  • Monday, June 18, 2018
  • by tractorcow
  • Repository
  • 15 Watchers
  • 40 Stars
  • 162,304 Installations
  • PHP
  • 24 Dependents
  • 0 Suggesters
  • 35 Forks
  • 9 Open issues
  • 19 Versions
  • 8 % Grown

The README.md

SpamProtection Module

Build Status Scrutinizer Code Quality SilverStripe supported module Code Coverage, (*1)

Maintainer Contact

  • Saophalkun Ponlu , (*2)

  • Will Rossiter , (*3)

Requirements

SilverStripe 4.0+, (*4)

Note: For SilverStripe 3.x, please use the 2.x release line., (*5)

Install

To install run composer require silverstripe/spamprotection., (*6)

Documentation

This module provides a generic, consistent API for adding spam protection to your SilverStripe Forms. This does not provide any spam protection out of the box. For that, you must also download one of the spam protection implementations. Currently available options are:, (*7)

As a developer you can also provide your own protector by creating a class which implements the \SilverStripe\SpamProtection\SpamProtector interface. More on that below., (*8)

Configuring

After installing this module and a protector of your choice (i.e mollom) you'll need to rebuild your database through dev/build and set the default protector via SilverStripe's config system. This will update any Form instances that have spam protection hooks with that protector., (*9)

mysite/_config/spamprotection.yml, (*10)

---
name: mycustomspamprotection
---
SilverStripe\SpamProtection\Extension\FormSpamProtectionExtension:
  default_spam_protector: MollomSpamProtector

To add spam protection to your form instance call enableSpamProtection., (*11)

// your existing form code
$form = new Form(/* .. */);
$form->enableSpamProtection();

The logic to perform the actual spam validation is controlled by each of the individual SpamProtector implementations since they each require a different implementation client side or server side., (*12)

Options

enableSpamProtection takes a hash of optional configuration values., (*13)

$form->enableSpamProtection(array(
    'protector' => MathSpamProtector::class,
    'name' => 'Captcha'
));

Options to configure are:, (*14)

  • protector: a class name string or class instance which implements \SilverStripe\SpamProtection\SpamProtector. Defaults to your SilverStripe\SpamProtection\Extension\FormSpamProtectionExtension.default_spam_protector value., (*15)

  • name: the form field name argument for the Captcha. Defaults to Captcha., (*16)

  • title: title of the Captcha form field. Defaults to ''
  • insertBefore: name of existing field to insert the spam protection field prior to
  • mapping: an array mapping of the Form fields to the standardised list of field names. The list of standardised fields to pass to the spam protector are:
title
body
contextUrl
contextTitle
authorName
authorMail
authorUrl
authorIp
authorId

Defining your own SpamProtector

Any class that implements \SilverStripe\SpamProtection\SpamProtector and the getFormField() method can be set as the spam protector. The getFormField() method returns the FormField to be inserted into the Form. The FormField returned should be in charge of the validation process., (*17)

<?php

use CaptchaField;
use SilverStripe\SpamProtection\SpamProtector;

class CustomSpamProtector implements SpamProtector
{
    public function getFormField($name = null, $title = null, $value = null)
    {
        // CaptchaField is an imagined class which has some functionality.
        // See silverstripe-mollom module for an example.
        return new CaptchaField($name, $title, $value);
    }
}

Using Spam Protection with User Forms

This module provides an EditableSpamProtectionField wrapper which you can add to your UserForm instances. After installing this module and running /dev/build to rebuild the database, your Form Builder interface will have an option for Spam Protection Field. The type of spam protection used will be based on your currently selected SpamProtector instance., (*18)

Releasing code with Spam Protection support

Spam protection is useful to provide but in some cases we do not want to require the developer to use spam protection. In that case, modules can provide the following pattern:, (*19)

use SilverStripe\Forms\Form;
use SilverStripe\SpamProtection\Extension\FormSpamProtectionExtension;

$form = new Form(/* .. */);

if ($form->hasExtension(FormSpamProtectionExtension::class)) {
    $form->enableSpamProtection();
}

The Versions

18/06 2018

dev-master

9999999-dev

Spam protection module for SilverStripe.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Saophalkun Ponlu

silverstripe spamprotection

11/06 2018

3.0.x-dev

3.0.9999999.9999999-dev

Spam protection module for SilverStripe.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Saophalkun Ponlu

silverstripe spamprotection

12/01 2018

3.0.0

3.0.0.0

Spam protection module for SilverStripe.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Saophalkun Ponlu

silverstripe spamprotection

20/12 2017

3.0.0-beta1

3.0.0.0-beta1

Spam protection module for SilverStripe.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Saophalkun Ponlu

silverstripe spamprotection

19/12 2017

2.x-dev

2.9999999.9999999.9999999-dev

Spam protection module for SilverStripe.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Saophalkun Ponlu

silverstripe spamprotection

19/12 2017

2.0.x-dev

2.0.9999999.9999999-dev

Spam protection module for SilverStripe.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Saophalkun Ponlu

silverstripe spamprotection

19/07 2017

2.0.8

2.0.8.0

Spam protection module for SilverStripe.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Saophalkun Ponlu

silverstripe spamprotection

08/02 2017

2.0.7

2.0.7.0

Spam protection module for SilverStripe.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Saophalkun Ponlu

silverstripe spamprotection

31/01 2017

1.1.x-dev

1.1.9999999.9999999-dev

Spam protection module for SilverStripe.

  Sources   Download

The Requires

 

by Saophalkun Ponlu

silverstripe spamprotection

31/01 2017

1.0.x-dev

1.0.9999999.9999999-dev

Spam protection module for SilverStripe.

  Sources   Download

The Requires

 

by Saophalkun Ponlu

silverstripe spamprotection

31/01 2017

0.4.x-dev

0.4.9999999.9999999-dev

Spam protection module for SilverStripe.

  Sources   Download

The Requires

 

by Saophalkun Ponlu

silverstripe spamprotection

17/11 2016

2.0.6

2.0.6.0

Spam protection module for SilverStripe.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Saophalkun Ponlu

silverstripe spamprotection

17/08 2016

2.0.5

2.0.5.0

Spam protection module for SilverStripe.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Saophalkun Ponlu

silverstripe spamprotection

19/05 2016

2.0.4

2.0.4.0

Spam protection module for SilverStripe.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Saophalkun Ponlu

silverstripe spamprotection

04/02 2016

2.0.3

2.0.3.0

Spam protection module for SilverStripe.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Saophalkun Ponlu

silverstripe spamprotection

19/11 2015

2.0.2

2.0.2.0

Spam protection module for SilverStripe.

  Sources   Download

The Requires

 

The Development Requires

by Saophalkun Ponlu

silverstripe spamprotection

20/08 2015

2.0.1

2.0.1.0

Spam protection module for SilverStripe.

  Sources   Download

The Requires

 

The Development Requires

by Saophalkun Ponlu

silverstripe spamprotection

26/05 2015

2.0.0

2.0.0.0

Spam protection module for SilverStripe.

  Sources   Download

The Requires

 

The Development Requires

by Saophalkun Ponlu

silverstripe spamprotection

07/03 2014

1.2.0

1.2.0.0

Spam protection module for SilverStripe.

  Sources   Download

The Requires

 

by Saophalkun Ponlu

silverstripe spamprotection