mirror of
https://github.com/silverstripe/silverstripe-spamprotection.git
synced 2024-10-22 14:05:59 +02:00
ENHANCEMENT:update_form returns null if the spam protection field create fails
This commit is contained in:
parent
d77104a7dc
commit
cbe2fa3171
2
INSTALL
2
INSTALL
@ -40,7 +40,7 @@ This following code should appear after the form creation.
|
|||||||
|
|
||||||
<<<< CODE STARTS >>>>
|
<<<< CODE STARTS >>>>
|
||||||
|
|
||||||
$protectorField = SpamProtecterManager::update_form('MollomField', 'Captcha', $form, 'Message', $callbackObj);
|
$protector = SpamProtecterManager::update_form('MollomField', 'Captcha', $form, 'Message', $callbackObj);
|
||||||
|
|
||||||
<<<< CODE ENDS >>>>
|
<<<< CODE ENDS >>>>
|
||||||
|
|
||||||
|
@ -27,12 +27,17 @@ class SpamProtecterManager {
|
|||||||
* and a string of field names (seperated by comma) as a value.
|
* and a string of field names (seperated by comma) as a value.
|
||||||
* The naming of the fields is based on the implementation of the subclass of SpamProtecterField.
|
* The naming of the fields is based on the implementation of the subclass of SpamProtecterField.
|
||||||
* *** Most of the web service doesn't require this.
|
* *** Most of the web service doesn't require this.
|
||||||
* @return SpamProtector object
|
* @return SpamProtector object or return null if the spamprotecter class is not found
|
||||||
|
* or spamprotecterfield creation fails.
|
||||||
*/
|
*/
|
||||||
static function update_form($form, $before=null, $callbackObject=null, $fieldsToSpamServiceMapping=null) {
|
static function update_form($form, $before=null, $callbackObject=null, $fieldsToSpamServiceMapping=null) {
|
||||||
|
if (!class_exists(self::$spam_protecter)) return null;
|
||||||
|
|
||||||
$protecter = new self::$spam_protecter();
|
$protecter = new self::$spam_protecter();
|
||||||
|
$check = $protecter->updateForm($form, $before, $callbackObject, $fieldsToSpamServiceMapping);
|
||||||
$protecter->updateForm($form, $before, $callbackObject, $fieldsToSpamServiceMapping);
|
|
||||||
|
if (!$check) return null;
|
||||||
|
|
||||||
return $protecter;
|
return $protecter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user