Completed
Pull Request — master (#17)
by Helpful
03:10
created
code/AkismetField.php 1 patch
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,7 +27,9 @@  discard block
 block discarded – undo
27 27
 	protected function confirmationField() {
28 28
 		// Check if confirmation is required
29 29
 		$requireConfirmation = Config::inst()->get('AkismetSpamProtector', 'require_confirmation');
30
-		if(empty($requireConfirmation)) return null;
30
+		if(empty($requireConfirmation)) {
31
+			return null;
32
+		}
31 33
 		
32 34
 		// If confirmation is required then return a checkbox
33 35
 		return CheckboxField::create(
@@ -41,19 +43,25 @@  discard block
 block discarded – undo
41 43
 	
42 44
 	public function Field($properties = array()) {
43 45
 		$checkbox = $this->confirmationField();
44
-		if($checkbox) return $checkbox->Field($properties);
46
+		if($checkbox) {
47
+			return $checkbox->Field($properties);
48
+		}
45 49
 	}
46 50
 	
47 51
 	function FieldHolder($properties = array()) {
48 52
 		$checkbox = $this->confirmationField();
49
-		if($checkbox) return $checkbox->FieldHolder($properties);
53
+		if($checkbox) {
54
+			return $checkbox->FieldHolder($properties);
55
+		}
50 56
 	}
51 57
 	
52 58
 	/**
53 59
 	 * @return array
54 60
 	 */
55 61
 	public function getSpamMappedData() {
56
-		if(empty($this->fieldMapping)) return null;
62
+		if(empty($this->fieldMapping)) {
63
+			return null;
64
+		}
57 65
 		
58 66
 		$result = array();
59 67
 		$data = $this->form->getData();
@@ -93,7 +101,9 @@  discard block
 block discarded – undo
93 101
 		
94 102
 		// Check result
95 103
 		$isSpam = $this->getIsSpam();
96
-		if(!$isSpam) return true;
104
+		if(!$isSpam) {
105
+			return true;
106
+		}
97 107
 
98 108
 		// Save error message
99 109
 		$errorMessage = _t(
@@ -127,15 +137,21 @@  discard block
 block discarded – undo
127 137
 	 */
128 138
 	public function getIsSpam() {
129 139
 		// Prevent multiple API calls
130
-		if($this->isSpam !== null) return $this->isSpam;
140
+		if($this->isSpam !== null) {
141
+			return $this->isSpam;
142
+		}
131 143
 
132 144
 		// Check bypass permission
133 145
 		$permission = Config::inst()->get('AkismetSpamProtector', 'bypass_permission');
134
-		if($permission && Permission::check($permission)) return false;
146
+		if($permission && Permission::check($permission)) {
147
+			return false;
148
+		}
135 149
 
136 150
 		// if the user has logged and there's no force check on member
137 151
 		$bypassMember = Config::inst()->get('AkismetSpamProtector', 'bypass_members');
138
-		if($bypassMember && Member::currentUser()) return false;
152
+		if($bypassMember && Member::currentUser()) {
153
+			return false;
154
+		}
139 155
 
140 156
 		// Map input fields to spam fields
141 157
 		$mappedData = $this->getSpamMappedData();
Please login to merge, or discard this patch.
code/AkismetSpamProtector.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -79,14 +79,20 @@
 block discarded – undo
79 79
 	 * @return string
80 80
 	 */
81 81
 	protected static function get_api_key() {
82
-		if(self::$_api_key) return self::$_api_key;
82
+		if(self::$_api_key) {
83
+			return self::$_api_key;
84
+		}
83 85
 		
84 86
 		// Check config
85 87
 		$key = Config::inst()->get('AkismetSpamProtector', 'api_key');
86
-		if(!empty($key)) return $key;
88
+		if(!empty($key)) {
89
+			return $key;
90
+		}
87 91
 		
88 92
 		// Check environment
89
-		if(defined('SS_AKISMET_API_KEY')) return SS_AKISMET_API_KEY;
93
+		if(defined('SS_AKISMET_API_KEY')) {
94
+			return SS_AKISMET_API_KEY;
95
+		}
90 96
 	}
91 97
 	
92 98
 	/**
Please login to merge, or discard this patch.
code/service/AkismetService.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -6,34 +6,34 @@
 block discarded – undo
6 6
 interface AkismetService {
7 7
 	
8 8
 	/**
9
-     * Check if the comment is spam or not
10
-     * This is basically the core of everything. This call takes a number of
11
-     * arguments and characteristics about the submitted content and then
12
-     * returns a thumbs up or thumbs down.
13
-     * Almost everything is optional, but performance can drop dramatically if
14
-     * you exclude certain elements.
15
-     * REMARK: If you are having trouble triggering you can send
16
-     * "viagra-test-123" as the author and it will trigger a true response,
17
-     * always.
18
-     *
19
-     * @param string[optional] $content   The content that was submitted.
20
-     * @param string[optional] $author    The name.
21
-     * @param string[optional] $email     The email address.
22
-     * @param string[optional] $url       The URL.
23
-     * @param string[optional] $permalink The permanent location of the entry
24
-     *                                    the comment was submitted to.
25
-     * @param string[optional] $type The type, can be blank, comment,
26
-     *                                    trackback, pingback, or a made up
27
-     *                                    value like "registration".
28
-     * @return bool If the comment is spam true will be
29
-     *                                    returned, otherwise false.
30
-     */
31
-    public function isSpam(
32
-        $content,
33
-        $author = null,
34
-        $email = null,
35
-        $url = null,
36
-        $permalink = null,
37
-        $type = null
38
-    );
9
+	 * Check if the comment is spam or not
10
+	 * This is basically the core of everything. This call takes a number of
11
+	 * arguments and characteristics about the submitted content and then
12
+	 * returns a thumbs up or thumbs down.
13
+	 * Almost everything is optional, but performance can drop dramatically if
14
+	 * you exclude certain elements.
15
+	 * REMARK: If you are having trouble triggering you can send
16
+	 * "viagra-test-123" as the author and it will trigger a true response,
17
+	 * always.
18
+	 *
19
+	 * @param string[optional] $content   The content that was submitted.
20
+	 * @param string[optional] $author    The name.
21
+	 * @param string[optional] $email     The email address.
22
+	 * @param string[optional] $url       The URL.
23
+	 * @param string[optional] $permalink The permanent location of the entry
24
+	 *                                    the comment was submitted to.
25
+	 * @param string[optional] $type The type, can be blank, comment,
26
+	 *                                    trackback, pingback, or a made up
27
+	 *                                    value like "registration".
28
+	 * @return bool If the comment is spam true will be
29
+	 *                                    returned, otherwise false.
30
+	 */
31
+	public function isSpam(
32
+		$content,
33
+		$author = null,
34
+		$email = null,
35
+		$url = null,
36
+		$permalink = null,
37
+		$type = null
38
+	);
39 39
 }
Please login to merge, or discard this patch.