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.