ENHANCEMENT:update_form returns null if the spam protection field create fails

This commit is contained in:
Saophalkun Ponlu 2009-02-17 09:03:59 +00:00
parent d77104a7dc
commit cbe2fa3171
2 changed files with 9 additions and 4 deletions

View File

@ -40,7 +40,7 @@ This following code should appear after the form creation.
<<<< CODE STARTS >>>>
$protectorField = SpamProtecterManager::update_form('MollomField', 'Captcha', $form, 'Message', $callbackObj);
$protector = SpamProtecterManager::update_form('MollomField', 'Captcha', $form, 'Message', $callbackObj);
<<<< CODE ENDS >>>>

View File

@ -27,12 +27,17 @@ class SpamProtecterManager {
* 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.
* *** 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) {
if (!class_exists(self::$spam_protecter)) return null;
$protecter = new self::$spam_protecter();
$protecter->updateForm($form, $before, $callbackObject, $fieldsToSpamServiceMapping);
$check = $protecter->updateForm($form, $before, $callbackObject, $fieldsToSpamServiceMapping);
if (!$check) return null;
return $protecter;
}