From 1a84fac4825101156e56d86ecf75ec630e17716a Mon Sep 17 00:00:00 2001 From: Saophalkun Ponlu Date: Tue, 3 Feb 2009 21:29:55 +0000 Subject: [PATCH] importing spam protection module --- _config.php | 3 ++ code/MollomProtecter_Backup.php | 80 +++++++++++++++++++++++++++++++++ code/SpamProctecterManager.php | 47 +++++++++++++++++++ code/SpamProtecterField.php | 40 +++++++++++++++++ code/Spamable.php | 12 +++++ 5 files changed, 182 insertions(+) create mode 100644 _config.php create mode 100644 code/MollomProtecter_Backup.php create mode 100644 code/SpamProctecterManager.php create mode 100644 code/SpamProtecterField.php create mode 100644 code/Spamable.php diff --git a/_config.php b/_config.php new file mode 100644 index 0000000..15c5adc --- /dev/null +++ b/_config.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/code/MollomProtecter_Backup.php b/code/MollomProtecter_Backup.php new file mode 100644 index 0000000..5842a72 --- /dev/null +++ b/code/MollomProtecter_Backup.php @@ -0,0 +1,80 @@ +spanControlCallbackObj = $callbackObject; + } + + /* Map fields (by name) to Spam service's fields for spam checking */ + protected $fieldToPostTitle = ""; + + // it can be more than one fields mapped to post content + protected $fieldsToPostBody = array(); + + protected $fieldToAuthorName = ""; + + protected $fieldToAuthorUrl = ""; + + protected $fieldToAuthorEmail = ""; + + protected $fieldToAuthorOpenId = ""; + + function setFieldToPostTitle($fieldName) { + $this->fieldToPostTitle = $fieldName; + } + + /** + * Map array of fields where their value will be used as a mollom post body + * @param array + */ + function setFieldsToPostBody($fieldNames) { + $this->fieldsToPostBody = $fieldNames; + } + + function setfieldToAuthorName($fieldName) { + $this->fieldToAuthorName = $fieldName; + } + + function setFieldToAuthorUrl($fieldName) { + $this->fieldToAuthorUrl = $fieldName; + } + + function setFieldToAuthorEmail($fieldName) { + $this->fieldToAuthorEmail = $fieldName; + } + + function setFieldToAuthorOpenId($fieldName) { + $this->fieldToAuthorOpenId = $fieldName; + } + + /** + * Tell the callback object the spam checking response status + */ + protected function markAsSpam() { + if ($this->spanControlCallbackObj && $this->spanControlCallbackObj instanceof Spamable) { + $this->spanControlCallbackObj->markAsSpam($this->getForm()); + } + } + + /** + * Tell the callback object the spam checking response status + */ + protected function markAsHam() { + if ($this->spanControlCallbackObj && $this->spanControlCallbackObj instanceof Spamable) { + $this->spanControlCallbackObj->markAsHam($this->getForm()); + } + } +} +?> \ No newline at end of file diff --git a/code/SpamProctecterManager.php b/code/SpamProctecterManager.php new file mode 100644 index 0000000..6edf95c --- /dev/null +++ b/code/SpamProctecterManager.php @@ -0,0 +1,47 @@ +setCallbackObject($callbackObject); + + if ($before && $fields->fieldByName($before)) { + $form->Fields()->insertBefore($protecterField, $before); + } + else { + $form->Fields()->push($protecterField); + } + + return $protecterField; + } +} +?> \ No newline at end of file diff --git a/code/SpamProtecterField.php b/code/SpamProtecterField.php new file mode 100644 index 0000000..dada587 --- /dev/null +++ b/code/SpamProtecterField.php @@ -0,0 +1,40 @@ +spanControlCallbackObj = $callbackObject; + } + + /** + * Tell the callback object the submission is spam + */ + protected function markAsSpam() { + if ($this->spanControlCallbackObj && $this->spanControlCallbackObj instanceof Spamable) { + $this->spanControlCallbackObj->markAsSpam($this->getForm()); + } + } + + /** + * Tell the callback object the submission is ham + */ + protected function markAsHam() { + if ($this->spanControlCallbackObj && $this->spanControlCallbackObj instanceof Spamable) { + $this->spanControlCallbackObj->markAsHam($this->getForm()); + } + } + + +} +?> \ No newline at end of file diff --git a/code/Spamable.php b/code/Spamable.php new file mode 100644 index 0000000..26711c8 --- /dev/null +++ b/code/Spamable.php @@ -0,0 +1,12 @@ + \ No newline at end of file