diff --git a/INSTALL b/INSTALL index b8fe335..790f5d8 100644 --- a/INSTALL +++ b/INSTALL @@ -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 >>>> diff --git a/code/SpamProtecterManager.php b/code/SpamProtecterManager.php index 8ae8b23..49d5988 100644 --- a/code/SpamProtecterManager.php +++ b/code/SpamProtecterManager.php @@ -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; }