Passed
Push — Comments ( 870b9e...c71663 )
by Stone
02:05
created
App/Controllers/Ajax/PostVerification.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,9 +44,11 @@
 block discarded – undo
44 44
 
45 45
         $data = $postModel->isPostSlugUnique(/** @scrutinizer ignore-type */$postSlug); //we have checked that slug is valid so no type error
46 46
 
47
-        if ($data === false) //slug is not unique, but could be from the same post
47
+        if ($data === false) {
48
+            //slug is not unique, but could be from the same post
48 49
         {
49 50
             $slugOfId = $postModel->getPostSlugFromId($postId);
51
+        }
50 52
             if ($slugOfId === $postSlug) {
51 53
                 //it's the same post, return true
52 54
                 $data = true;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
         $this->onlyPost();
33 33
 
34 34
         $postSlug = $this->request->getData("postSlug");
35
-        $postId = (int)$this->request->getData("postId");
35
+        $postId = (int) $this->request->getData("postId");
36 36
 
37 37
         $data = false;
38 38
         if (!$this->slug->isSlugValid($postSlug) || !$this->isInt($postId)) {
Please login to merge, or discard this patch.
App/Controllers/Admin/Home.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         $this->session->remove("registrationErrors");
52 52
 
53 53
         $userId = $this->session->get("userId");
54
-        if($userId === null)
54
+        if ($userId === null)
55 55
         {
56 56
             //this should never happen but scrutinizer thows an alert
57 57
             throw new \Exception("Session error, no ID");
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
         $this->onlyUser();
103 103
         $this->onlyPost();
104 104
 
105
-        $user = (object)$this->request->getDataFull();
105
+        $user = (object) $this->request->getDataFull();
106 106
         $redirectUrl = "/admin";
107 107
 
108 108
         if ($user->userId !== $this->session->get("userId") || isset($user->userRoleSelector) || isset($user->locked_out)) {
109 109
             //an admin is trying to update a user or form tampered with
110 110
             $this->onlyAdmin();
111
-            $redirectUrl = "/admin/home/view-user/" . $user->userId;
112
-        } else {
111
+            $redirectUrl = "/admin/home/view-user/".$user->userId;
112
+        }else {
113 113
             //set the role to the original state for update
114 114
             $beforeUser = $this->userModel->getUserDetailsById($user->userId);
115 115
             $user->userRoleSelector = $beforeUser->roles_idroles;
@@ -123,13 +123,13 @@  discard block
 block discarded – undo
123 123
         $error = false;
124 124
         $registerErrors = new \stdClass();
125 125
 
126
-        if($userId == 1 && $user->userLockedOut == 1)
126
+        if ($userId == 1 && $user->userLockedOut == 1)
127 127
         {
128 128
             $error = true;
129 129
             $this->alertBox->setAlert("Original admin may not be deactivated", "error");
130 130
         }
131 131
 
132
-        if($userId == 1 && $user->userRoleSelector != 2)
132
+        if ($userId == 1 && $user->userRoleSelector != 2)
133 133
         {
134 134
             $error = true;
135 135
             $this->alertBox->setAlert("Original admin must stay admin", "error");
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
             throw new \Exception("Error in passed ID");
217 217
         }
218 218
 
219
-        if($userId === 1)
219
+        if ($userId === 1)
220 220
         {
221 221
             $this->alertBox->setAlert('Original Admin can not be deleted', "error");
222 222
             $this->response->redirect("/admin/home/list-users");
Please login to merge, or discard this patch.
App/Controllers/Password.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -45,27 +45,27 @@  discard block
 block discarded – undo
45 45
     public function reset($get)
46 46
     {
47 47
         //only get messages here
48
-        if(!$this->startsWith(strtolower($get),"get"))
48
+        if (!$this->startsWith(strtolower($get), "get"))
49 49
         {
50 50
             throw new \Exception("invalid call");
51 51
         }
52 52
 
53 53
         //grab the token and ID
54 54
         $token = $this->request->getData("token");
55
-        $userId = (int)$this->request->getData("userId");
55
+        $userId = (int) $this->request->getData("userId");
56 56
 
57
-        if($token === null)
57
+        if ($token === null)
58 58
         {
59 59
             throw new \Exception("Null Token");
60 60
         }
61 61
 
62 62
         //verify if token is valid
63
-        if(!$this->isHexa($token)|| !$this->isInt($userId))
63
+        if (!$this->isHexa($token) || !$this->isInt($userId))
64 64
         {
65 65
             $this->alertBox->setAlert('Badly formatted Token', 'error');
66 66
             $this->response->redirect();
67 67
         }
68
-        if(!$this->userModel->getUserDetailsByToken($token, $userId))
68
+        if (!$this->userModel->getUserDetailsByToken($token, $userId))
69 69
         {
70 70
             $this->alertBox->setAlert('Invalid reset token, please request a new password', 'error');
71 71
             $this->response->redirect();
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
         $token = $request["token"];
89 89
         $userId = $request["userId"];
90 90
 
91
-        if(!$this->isHexa($token) || !$this->isInt($userId) )
91
+        if (!$this->isHexa($token) || !$this->isInt($userId))
92 92
         {
93 93
             throw new \Exception("Bad Token or ID request");
94 94
         }
95 95
 
96 96
         $error = false;
97 97
         $registerErrors = new \stdClass();
98
-        if($password !== $confirm)
98
+        if ($password !== $confirm)
99 99
         {
100 100
             $error = true;
101 101
             $registerErrors->forgotPassword = "password and confirmation do not match";
Please login to merge, or discard this patch.
App/Controllers/Login.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     private function populateUserFromId(int $userId)
75 75
     {
76 76
         $result = $this->userModel->getUserDetailsById($userId);
77
-        $this->populateUser((array)$result);
77
+        $this->populateUser((array) $result);
78 78
     }
79 79
 
80 80
     /**
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
         //we are authenticated here
198 198
 
199 199
         //populate the user object with returned data
200
-        $this->populateUser((array)$authUser->user);
200
+        $this->populateUser((array) $authUser->user);
201 201
 
202 202
         //if the user wanted to be remembered
203 203
         if ($rememberMe) {
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -282,9 +282,11 @@
 block discarded – undo
282 282
         //all set, redirect and set message
283 283
         $redirectUrl = "";
284 284
         $refererUrl = $this->request->getReferer();
285
-        if ($refererUrl != "")//getReferer can return null if client isn't configured
285
+        if ($refererUrl != "") {
286
+            //getReferer can return null if client isn't configured
286 287
         {
287 288
             $baseUrl = $this->request->getBaseUrl();
289
+        }
288 290
             $redirectUrl = $this->removeFromBeginning($refererUrl, $baseUrl);
289 291
         }
290 292
 
Please login to merge, or discard this patch.
App/Controllers/Ajax/User.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 use Core\JsonException;
9 9
 use Core\Traits\StringFunctions;
10 10
 
11
-class User  extends AjaxController{
11
+class User  extends AjaxController {
12 12
 
13 13
     use StringFunctions;
14 14
 
@@ -25,12 +25,12 @@  discard block
 block discarded – undo
25 25
         //the router needs a parameter with get functions else throsw a wobbly
26 26
         //we pass a get variable and call the /controller/function/get?bla
27 27
         //for better use and security, we must pass "get" as the parameter
28
-        if(!$this->startsWith(strtolower($get),"get"))
28
+        if (!$this->startsWith(strtolower($get), "get"))
29 29
         {
30 30
             throw new JsonException("invalid call");
31 31
         }
32 32
         $email = $this->request->getData("email");
33
-        if($email === null)
33
+        if ($email === null)
34 34
         {
35 35
             throw new JsonException("Empty email");
36 36
         }
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
     {
52 52
         $this->onlyAdmin();
53 53
         $this->onlyPost();
54
-        $state = (bool)($this->request->getData("state") === 'true');
55
-        $userId = (int)$this->request->getData("userId");
54
+        $state = (bool) ($this->request->getData("state") === 'true');
55
+        $userId = (int) $this->request->getData("userId");
56 56
 
57 57
         $result = array();
58 58
         $result["success"] = false;
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         $result["userId"] = $userId;
61 61
 
62 62
         // we can not update the Original Admin activation state
63
-        if($userId !== 1)
63
+        if ($userId !== 1)
64 64
         {
65 65
             $result["success"] = $this->userModel->activateUser(!$state, $userId);
66 66
             $result["state"] = !$state;
Please login to merge, or discard this patch.
App/Controllers/Post.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
         $this->onlyUser();
84 84
 
85 85
         //get the session userId
86
-        $userId = (int)$this->session->get("userId");
87
-        $comment = (string)$this->request->getData("newComment");
88
-        $postId = (int)$this->request->getData("postId");
86
+        $userId = (int) $this->session->get("userId");
87
+        $comment = (string) $this->request->getData("newComment");
88
+        $postId = (int) $this->request->getData("postId");
89 89
 
90 90
         //check if we are admin, Admins do not need moderation
91 91
         $admin = $this->session->get('user_role_level') >= Constant::ADMIN_LEVEL;
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
             $post = $this->postModel->getSinglePost($postId);
98 98
             $baseUrl = $this->request->getBaseUrl();
99 99
 
100
-            $emailMessage = "<h1>New comment on post " . $post->title . "</a></h1>";
101
-            $emailMessage .= "<p>Check it out <a href='" . $baseUrl . "admin/comments/moderate-comment/" . $commentId . "'>here</a> </p>";
100
+            $emailMessage = "<h1>New comment on post ".$post->title."</a></h1>";
101
+            $emailMessage .= "<p>Check it out <a href='".$baseUrl."admin/comments/moderate-comment/".$commentId."'>here</a> </p>";
102 102
 
103 103
             $this->sendMail->send($siteConfig["admin_email_address"], "New comment added", $emailMessage);
104 104
 
@@ -107,6 +107,6 @@  discard block
 block discarded – undo
107 107
 
108 108
         $postSlug = $this->postModel->getPostSlugFromId($postId);
109 109
 
110
-        $this->response->redirect("/post/view-post/" . $postSlug);
110
+        $this->response->redirect("/post/view-post/".$postSlug);
111 111
     }
112 112
 }
113 113
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -91,9 +91,11 @@
 block discarded – undo
91 91
         $admin = $this->session->get('user_role_level') >= Constant::ADMIN_LEVEL;
92 92
         $commentId = $this->commentModel->addComment($postId, $userId, $comment, $admin);
93 93
 
94
-        if (!$admin) //if we are not an admin, send an email to alert and add an alertBox
94
+        if (!$admin) {
95
+            //if we are not an admin, send an email to alert and add an alertBox
95 96
         {
96 97
             $siteConfig = $this->siteConfig->getSiteConfig();
98
+        }
97 99
             $post = $this->postModel->getSinglePost($postId);
98 100
             $baseUrl = $this->request->getBaseUrl();
99 101
 
Please login to merge, or discard this patch.
App/Controllers/Admin/Comments.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 use Core\Container;
10 10
 use Core\Traits\StringFunctions;
11 11
 
12
-class Comments extends AdminController{
12
+class Comments extends AdminController {
13 13
 
14 14
     use StringFunctions;
15 15
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
         }
122 122
 
123 123
         $refererUrl = $this->request->getReferer();
124
-        if($refererUrl === "") //referer can return null, set default
124
+        if ($refererUrl === "") //referer can return null, set default
125 125
         {
126 126
             $refererUrl = "admin/comments/view-comments";
127 127
         }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
         }
153 153
 
154 154
         //update comment
155
-        if($this->commentModel->update($commentId, $comment["commentTextArea"], $comment["commentApproved"]))
155
+        if ($this->commentModel->update($commentId, $comment["commentTextArea"], $comment["commentApproved"]))
156 156
         {
157 157
             $this->alertBox->setAlert("Comment updated");
158 158
         }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -121,10 +121,12 @@
 block discarded – undo
121 121
         }
122 122
 
123 123
         $refererUrl = $this->request->getReferer();
124
-        if($refererUrl === "") //referer can return null, set default
124
+        if($refererUrl === "") {
125
+            //referer can return null, set default
125 126
         {
126 127
             $refererUrl = "admin/comments/view-comments";
127 128
         }
129
+        }
128 130
         $baseUrl = $this->request->getBaseUrl();
129 131
         $redirectUrl = $this->removeFromBeginning($refererUrl, $baseUrl);
130 132
 
Please login to merge, or discard this patch.
App/Controllers/Ajax/Comment.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
     {
25 25
         $this->onlyAdmin();
26 26
         $this->onlyPost();
27
-        $state = (bool)($this->request->getData("state") === 'true');
28
-        $commentId = (int)$this->request->getData("commentId");
27
+        $state = (bool) ($this->request->getData("state") === 'true');
28
+        $commentId = (int) $this->request->getData("commentId");
29 29
 
30 30
         $result = array();
31 31
         $result["success"] = $this->commentModel->setApproved(!$state, $commentId);
@@ -36,17 +36,17 @@  discard block
 block discarded – undo
36 36
 
37 37
     public function loadComments()
38 38
     {
39
-        $commentOffset = (int)$this->request->getData("commentOffset");
40
-        $postId = (int)$this->request->getData("postId");
39
+        $commentOffset = (int) $this->request->getData("commentOffset");
40
+        $postId = (int) $this->request->getData("postId");
41 41
 
42 42
         $result = array();
43
-        $result["success"]=false;
43
+        $result["success"] = false;
44 44
         $data = array();
45 45
 
46 46
         $data["comments"] = $this->commentModel->getCommentsListOnPost($postId, $commentOffset);
47
-        if($data["comments"] !== false)
47
+        if ($data["comments"] !== false)
48 48
         {
49
-            $result["success"]=true;
49
+            $result["success"] = true;
50 50
             $twig = $this->container->getTemplate();
51 51
             $html = $twig->render('Includes/LoadComments.twig', $data);
52 52
 
Please login to merge, or discard this patch.