@@ -24,8 +24,8 @@ discard block |
||
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 |
||
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"]) |
|
47 | + if ($data["comments"]) |
|
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 |
@@ -44,9 +44,11 @@ |
||
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; |
@@ -9,7 +9,7 @@ discard block |
||
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 |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | $refererUrl = $this->request->getReferer(); |
124 | - if($refererUrl === null) //referer can return null, set default |
|
124 | + if ($refererUrl === null) //referer can return null, set default |
|
125 | 125 | { |
126 | 126 | $refererUrl = "admin/comments/view-comments"; |
127 | 127 | } |
@@ -152,7 +152,7 @@ discard block |
||
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 | } |
@@ -121,10 +121,12 @@ |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | $refererUrl = $this->request->getReferer(); |
124 | - if($refererUrl === null) //referer can return null, set default |
|
124 | + if($refererUrl === null) { |
|
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 |
@@ -51,7 +51,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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"); |