Completed
Push — master ( 7721c2...c2fee6 )
by Gordon
02:30
created
code/admin/CommentAdmin.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,9 @@
 block discarded – undo
37 37
 	 * @return Form
38 38
 	 */
39 39
 	public function getEditForm($id = null, $fields = null) {
40
-		if(!$id) $id = $this->currentPageID();
40
+		if(!$id) {
41
+			$id = $this->currentPageID();
42
+		}
41 43
 
42 44
 		$form = parent::getEditForm($id);
43 45
 		$record = $this->getRecord($id);
Please login to merge, or discard this patch.
code/admin/CommentsGridFieldAction.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,9 @@
 block discarded – undo
37 37
 	 * {@inheritdoc}
38 38
 	 */
39 39
 	public function getColumnContent($gridField, $record, $columnName) {
40
-		if(!$record->canEdit()) return;
40
+		if(!$record->canEdit()) {
41
+			return;
42
+		}
41 43
 
42 44
 		$field = "";
43 45
 
Please login to merge, or discard this patch.
code/controllers/CommentingController.php 1 patch
Braces   +33 added lines, -11 removed lines patch added patch discarded remove patch
@@ -218,11 +218,15 @@  discard block
 block discarded – undo
218 218
 	 */
219 219
 	public function delete() {
220 220
 		$comment = $this->getComment();
221
-		if(!$comment) return $this->httpError(404);
221
+		if(!$comment) {
222
+			return $this->httpError(404);
223
+		}
222 224
 		if(!$comment->canDelete()) {
223 225
 			return Security::permissionFailure($this, 'You do not have permission to delete this comment');
224 226
 		}
225
-		if(!$comment->getSecurityToken()->checkRequest($this->request)) return $this->httpError(400);
227
+		if(!$comment->getSecurityToken()->checkRequest($this->request)) {
228
+			return $this->httpError(400);
229
+		}
226 230
 
227 231
 		$comment->delete();
228 232
 
@@ -236,11 +240,15 @@  discard block
 block discarded – undo
236 240
 	 */
237 241
 	public function spam() {
238 242
 		$comment = $this->getComment();
239
-		if(!$comment) return $this->httpError(404);
243
+		if(!$comment) {
244
+			return $this->httpError(404);
245
+		}
240 246
 		if(!$comment->canEdit()) {
241 247
 			return Security::permissionFailure($this, 'You do not have permission to edit this comment');
242 248
 		}
243
-		if(!$comment->getSecurityToken()->checkRequest($this->request)) return $this->httpError(400);
249
+		if(!$comment->getSecurityToken()->checkRequest($this->request)) {
250
+			return $this->httpError(400);
251
+		}
244 252
 		
245 253
 		$comment->markSpam();
246 254
 
@@ -254,11 +262,15 @@  discard block
 block discarded – undo
254 262
 	 */
255 263
 	public function ham() {
256 264
 		$comment = $this->getComment();
257
-		if(!$comment) return $this->httpError(404);
265
+		if(!$comment) {
266
+			return $this->httpError(404);
267
+		}
258 268
 		if(!$comment->canEdit()) {
259 269
 			return Security::permissionFailure($this, 'You do not have permission to edit this comment');
260 270
 		}
261
-		if(!$comment->getSecurityToken()->checkRequest($this->request)) return $this->httpError(400);
271
+		if(!$comment->getSecurityToken()->checkRequest($this->request)) {
272
+			return $this->httpError(400);
273
+		}
262 274
 
263 275
 		$comment->markApproved();
264 276
 
@@ -272,11 +284,15 @@  discard block
 block discarded – undo
272 284
 	 */
273 285
 	public function approve() {
274 286
 		$comment = $this->getComment();
275
-		if(!$comment) return $this->httpError(404);
287
+		if(!$comment) {
288
+			return $this->httpError(404);
289
+		}
276 290
 		if(!$comment->canEdit()) {
277 291
 			return Security::permissionFailure($this, 'You do not have permission to approve this comment');
278 292
 		}
279
-		if(!$comment->getSecurityToken()->checkRequest($this->request)) return $this->httpError(400);
293
+		if(!$comment->getSecurityToken()->checkRequest($this->request)) {
294
+			return $this->httpError(400);
295
+		}
280 296
 
281 297
 		$comment->markApproved();
282 298
 
@@ -491,7 +507,9 @@  discard block
 block discarded – undo
491 507
 		if(isset($data['ParentID']) && ($class = $this->getBaseClass())) {
492 508
 			$this->setOwnerRecord($class::get()->byID($data['ParentID']));
493 509
 		}
494
-		if(!$this->getOwnerRecord()) return $this->httpError(404);
510
+		if(!$this->getOwnerRecord()) {
511
+			return $this->httpError(404);
512
+		}
495 513
 		
496 514
 		// cache users data
497 515
 		Cookie::set("CommentsForm_UserData", Convert::raw2json($data));
@@ -606,8 +624,12 @@  discard block
 block discarded – undo
606 624
 			}
607 625
 		}
608 626
 
609
-		if(!$url) $url = $this->fallbackReturnURL;
610
-		if(!$url) $url = Director::baseURL();
627
+		if(!$url) {
628
+			$url = $this->fallbackReturnURL;
629
+		}
630
+		if(!$url) {
631
+			$url = Director::baseURL();
632
+		}
611 633
 
612 634
 		// absolute redirection URLs not located on this site may cause phishing
613 635
 		if(Director::is_site_url($url)) {
Please login to merge, or discard this patch.
code/Commenting.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,7 +31,9 @@  discard block
 block discarded – undo
31 31
 		Config::inst()->update($class, 'extensions', array('CommentsExtension'));
32 32
 
33 33
 		// Check if settings must be customised
34
-		if($settings === false) return;
34
+		if($settings === false) {
35
+			return;
36
+		}
35 37
 		if(!is_array($settings)) {
36 38
 			throw new InvalidArgumentException('$settings needs to be an array or null');
37 39
 		}
@@ -76,7 +78,9 @@  discard block
 block discarded – undo
76 78
 	 */
77 79
 	public static function set_config_value($class, $key, $value = false) {
78 80
 		Deprecation::notice('2.0', 'Commenting::set_config_value is deprecated. Use the config api instead');
79
-		if($class === "all") $class = 'CommentsExtension';
81
+		if($class === "all") {
82
+			$class = 'CommentsExtension';
83
+		}
80 84
 		Config::inst()->update($class, 'comments', array($key => $value));
81 85
 	}
82 86
 
@@ -120,7 +124,9 @@  discard block
 block discarded – undo
120 124
 	 */
121 125
 	public static function config_value_equals($class, $key, $value) {
122 126
 		$check = self::get_config_value($class, $key);
123
-		if($check && ($check == $value)) return true;
127
+		if($check && ($check == $value)) {
128
+			return true;
129
+		}
124 130
 	}
125 131
 
126 132
 	/**
@@ -137,7 +143,9 @@  discard block
 block discarded – undo
137 143
 
138 144
 		// Check permission
139 145
 		$permission = self::get_config_value($class, 'required_permission');
140
-		if($permission && !Permission::check($permission)) return false;
146
+		if($permission && !Permission::check($permission)) {
147
+			return false;
148
+		}
141 149
 
142 150
 		// Check login required
143 151
 		$requireLogin = self::get_config_value($class, 'require_login');
Please login to merge, or discard this patch.
code/extensions/CommentsExtension.php 1 patch
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -291,7 +291,9 @@  discard block
 block discarded – undo
291 291
 	 */
292 292
 	public function getCommentsEnabled() {
293 293
 		// Don't display comments form for pseudo-pages (such as the login form)
294
-		if(!$this->owner->exists()) return false;
294
+		if(!$this->owner->exists()) {
295
+			return false;
296
+		}
295 297
 		
296 298
 		// Determine which flag should be used to determine if this is enabled
297 299
 		if($this->owner->getCommentsOption('enabled_cms')) {
@@ -341,19 +343,27 @@  discard block
 block discarded – undo
341 343
 	 */
342 344
 	public function canPostComment($member = null) {
343 345
 		// Deny if not enabled for this object
344
-		if(!$this->owner->CommentsEnabled) return false;
346
+		if(!$this->owner->CommentsEnabled) {
347
+			return false;
348
+		}
345 349
 
346 350
 		// Check if member is required
347 351
 		$requireLogin = $this->owner->CommentsRequireLogin;
348
-		if(!$requireLogin) return true;
352
+		if(!$requireLogin) {
353
+			return true;
354
+		}
349 355
 
350 356
 		// Check member is logged in
351 357
 		$member = $member ?: Member::currentUser();
352
-		if(!$member) return false;
358
+		if(!$member) {
359
+			return false;
360
+		}
353 361
 
354 362
 		// If member required check permissions
355 363
 		$requiredPermission = $this->owner->PostingRequiredPermission;
356
-		if($requiredPermission && !Permission::checkMember($member, $requiredPermission)) return false;
364
+		if($requiredPermission && !Permission::checkMember($member, $requiredPermission)) {
365
+			return false;
366
+		}
357 367
 
358 368
 		return true;
359 369
 	}
@@ -367,7 +377,9 @@  discard block
 block discarded – undo
367 377
 	 */
368 378
 	public function canModerateComments($member = null) {
369 379
 		// Deny if not enabled for this object
370
-		if(!$this->owner->CommentsEnabled) return false;
380
+		if(!$this->owner->CommentsEnabled) {
381
+			return false;
382
+		}
371 383
 
372 384
 		// Fallback to can-edit
373 385
 		return $this->owner->canEdit($member);
@@ -480,10 +492,14 @@  discard block
 block discarded – undo
480 492
 			? $this->owner->config()->comments
481 493
 			: Config::inst()->get(__CLASS__, 'comments');
482 494
 		$value = null;
483
-		if(isset($settings[$key])) $value = $settings[$key];
495
+		if(isset($settings[$key])) {
496
+			$value = $settings[$key];
497
+		}
484 498
 
485 499
 		// To allow other extensions to customise this option
486
-		if($this->owner) $this->owner->extend('updateCommentsOption', $key, $value);
500
+		if($this->owner) {
501
+			$this->owner->extend('updateCommentsOption', $key, $value);
502
+		}
487 503
 		return $value;
488 504
 	}
489 505
 
Please login to merge, or discard this patch.
code/model/CommentList.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,9 @@
 block discarded – undo
75 75
 		// Don't remove item with unrelated class key
76 76
 		$foreignClass = $this->getForeignClass();
77 77
 		$classNames = ClassInfo::subclassesFor($foreignClass);
78
-		if(!in_array($item->BaseClass, $classNames)) return;
78
+		if(!in_array($item->BaseClass, $classNames)) {
79
+			return;
80
+		}
79 81
 		
80 82
 		// Don't remove item which doesn't belong to this list
81 83
 		$foreignID = $this->getForeignID();
Please login to merge, or discard this patch.
code/model/Comment.php 1 patch
Braces   +16 added lines, -7 removed lines patch added patch discarded remove patch
@@ -135,7 +135,9 @@  discard block
 block discarded – undo
135 135
 					// set the variables which have changed
136 136
 					$comment->BaseClass = 'SiteTree';
137 137
 					$comment->URL = (isset($pageComment['CommenterURL'])) ? $pageComment['CommenterURL'] : '';
138
-					if((int) $pageComment['NeedsModeration'] == 0) $comment->Moderated = true;
138
+					if((int) $pageComment['NeedsModeration'] == 0) {
139
+						$comment->Moderated = true;
140
+					}
139 141
 
140 142
 					$comment->write();
141 143
 				}
@@ -206,8 +208,7 @@  discard block
 block discarded – undo
206 208
 		if(!$record && $this->BaseClass) {
207 209
 			// Otherwise a singleton of that record
208 210
 			$record = singleton($this->BaseClass);
209
-		}
210
-		else if(!$record) {
211
+		} else if(!$record) {
211 212
 			// Otherwise just use the default options
212 213
 			$record = singleton('CommentsExtension');
213 214
 		}
@@ -405,8 +406,12 @@  discard block
 block discarded – undo
405 406
 	 * @return string
406 407
 	 */
407 408
 	protected function actionLink($action, $member = null) {
408
-		if(!$member) $member = Member::currentUser();
409
-		if(!$member) return false;
409
+		if(!$member) {
410
+			$member = Member::currentUser();
411
+		}
412
+		if(!$member) {
413
+			return false;
414
+		}
410 415
 
411 416
 		$url = Controller::join_links(
412 417
 			Director::baseURL(),
@@ -855,7 +860,9 @@  discard block
 block discarded – undo
855 860
 	 */
856 861
 	public function checkRequest($request) {
857 862
 		$member = Member::currentUser();
858
-		if(!$member) return false;
863
+		if(!$member) {
864
+			return false;
865
+		}
859 866
 
860 867
 		$salt = $request->getVar('s');
861 868
 		$memberSalt = $this->memberSalt($salt, $member);
@@ -876,7 +883,9 @@  discard block
 block discarded – undo
876 883
 	protected function generate($length = null) {
877 884
 		$generator = new RandomGenerator();
878 885
 		$result = $generator->randomToken('sha256');
879
-		if($length !== null) return substr($result, 0, $length);
886
+		if($length !== null) {
887
+			return substr($result, 0, $length);
888
+		}
880 889
 		return $result;
881 890
 	}
882 891
 }
Please login to merge, or discard this patch.