From ca8c02b531a5f773aad9224ce1301de13d0480d4 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Wed, 11 Mar 2009 04:42:21 +0000 Subject: [PATCH] APICHANGE: added SpamProtector interface for spam protectors; MINOR: Fixed instructions --- INSTALL | 2 +- code/SpamProtecterManager.php | 16 +++++++++------- code/SpamProtector.php | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 code/SpamProtector.php diff --git a/INSTALL b/INSTALL index 7211eda..85e2b12 100644 --- a/INSTALL +++ b/INSTALL @@ -41,7 +41,7 @@ This following code should appear after the form creation. <<<< CODE STARTS >>>> -$protector = SpamProtecterManager::update_form($form, 'Message', $callbackObj); +$protector = SpamProtecterManager::update_form($form, 'Message'); <<<< CODE ENDS >>>> diff --git a/code/SpamProtecterManager.php b/code/SpamProtecterManager.php index 6c87b95..b7aabf7 100644 --- a/code/SpamProtecterManager.php +++ b/code/SpamProtecterManager.php @@ -19,7 +19,6 @@ class SpamProtecterManager { * Add the spam protecter field to a form * @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 object an object that implements Spamable * @param array an associative array * 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. @@ -28,12 +27,12 @@ class SpamProtecterManager { * @return SpamProtector object on success or null if the spamprotecter class is not found * 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; $protecter = new self::$spam_protecter(); try { - $check = $protecter->updateForm($form, $before, $callbackObject, $fieldsToSpamServiceMapping); + $check = $protecter->updateForm($form, $before, $fieldsToSpamServiceMapping); } catch (Exception $e) { $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(); - return $protecter->markAsSpam($object); + return $protecter->sendFeedback($object, $feedback); } } ?> \ No newline at end of file diff --git a/code/SpamProtector.php b/code/SpamProtector.php new file mode 100644 index 0000000..0e08c62 --- /dev/null +++ b/code/SpamProtector.php @@ -0,0 +1,19 @@ + \ No newline at end of file