| @@ 136-150 (lines=15) @@ | ||
| 133 | return $data; |
|
| 134 | } |
|
| 135 | ||
| 136 | public function lockPost(Request $request, $id) |
|
| 137 | { |
|
| 138 | if (!$this->canAdministrate() && !$this->canModerate()) { |
|
| 139 | return response('Unauthorised', 401); |
|
| 140 | } |
|
| 141 | ||
| 142 | $post = $this->postExists($id); |
|
| 143 | if (!$post) { |
|
| 144 | return response('Post not found', 404); |
|
| 145 | } |
|
| 146 | ||
| 147 | $post->locked = 1; |
|
| 148 | $post->save(); |
|
| 149 | return response('Post Locked', 200); |
|
| 150 | } |
|
| 151 | ||
| 152 | public function unlockPost(Request $request, $id) |
|
| 153 | { |
|
| @@ 152-166 (lines=15) @@ | ||
| 149 | return response('Post Locked', 200); |
|
| 150 | } |
|
| 151 | ||
| 152 | public function unlockPost(Request $request, $id) |
|
| 153 | { |
|
| 154 | if (!$this->canAdministrate() && !$this->canModerate()) { |
|
| 155 | return response('Unauthorised', 401); |
|
| 156 | } |
|
| 157 | ||
| 158 | $post = $this->postExists($id); |
|
| 159 | if (!$post) { |
|
| 160 | return response('Post not found', 404); |
|
| 161 | } |
|
| 162 | ||
| 163 | $post->locked = 0; |
|
| 164 | $post->save(); |
|
| 165 | return response('Post Unlocked', 200); |
|
| 166 | } |
|
| 167 | ||
| 168 | public function stickyPost(Request $request, $id) |
|
| 169 | { |
|
| @@ 168-182 (lines=15) @@ | ||
| 165 | return response('Post Unlocked', 200); |
|
| 166 | } |
|
| 167 | ||
| 168 | public function stickyPost(Request $request, $id) |
|
| 169 | { |
|
| 170 | if (!$this->canAdministrate() && !$this->canModerate()) { |
|
| 171 | return response('Unauthorised', 401); |
|
| 172 | } |
|
| 173 | ||
| 174 | $post = $this->postExists($id); |
|
| 175 | if (!$post) { |
|
| 176 | return response('Post not found', 404); |
|
| 177 | } |
|
| 178 | ||
| 179 | $post->sticky = 1; |
|
| 180 | $post->save(); |
|
| 181 | return response('Post Unlocked', 200); |
|
| 182 | } |
|
| 183 | ||
| 184 | public function unstickyPost(Request $request, $id) |
|
| 185 | { |
|
| @@ 184-198 (lines=15) @@ | ||
| 181 | return response('Post Unlocked', 200); |
|
| 182 | } |
|
| 183 | ||
| 184 | public function unstickyPost(Request $request, $id) |
|
| 185 | { |
|
| 186 | if (!$this->canAdministrate() && !$this->canModerate()) { |
|
| 187 | return response('Unauthorised', 401); |
|
| 188 | } |
|
| 189 | ||
| 190 | $post = $this->postExists($id); |
|
| 191 | if (!$post) { |
|
| 192 | return response('Post not found', 404); |
|
| 193 | } |
|
| 194 | ||
| 195 | $post->sticky = 0; |
|
| 196 | $post->save(); |
|
| 197 | return response('Post Unlocked', 200); |
|
| 198 | } |
|
| 199 | ||
| 200 | private function postExists($post_id) |
|
| 201 | { |
|
| @@ 210-223 (lines=14) @@ | ||
| 207 | } |
|
| 208 | } |
|
| 209 | ||
| 210 | public function postDelete($forum_id, $post_id) |
|
| 211 | { |
|
| 212 | if (!$this->canAdministrate() && !$this->canModerate()) { |
|
| 213 | return response('Unauthorised', 401); |
|
| 214 | } |
|
| 215 | ||
| 216 | $post = $this->postExists($post_id); |
|
| 217 | if (!$post) { |
|
| 218 | return response('Post not found', 404); |
|
| 219 | } |
|
| 220 | ||
| 221 | $post->delete(); |
|
| 222 | return response('Post Deleted', 200); |
|
| 223 | } |
|
| 224 | ||
| 225 | public function forumDelete(Request $request) |
|
| 226 | { |
|
| @@ 225-240 (lines=16) @@ | ||
| 222 | return response('Post Deleted', 200); |
|
| 223 | } |
|
| 224 | ||
| 225 | public function forumDelete(Request $request) |
|
| 226 | { |
|
| 227 | if (!$this->canAdministrate() && !$this->canModerate()) { |
|
| 228 | return response('Unauthorised', 401); |
|
| 229 | } |
|
| 230 | ||
| 231 | $forum_id = Request::input('forum_id'); |
|
| 232 | ||
| 233 | $forum = $this->forumExists($forum_id); |
|
| 234 | if (!$forum) { |
|
| 235 | return response('Forum not found', 404); |
|
| 236 | } |
|
| 237 | ||
| 238 | $forum->delete(); |
|
| 239 | return response('Forum Deleted', 200); |
|
| 240 | } |
|
| 241 | ||
| 242 | private function forumExists($id) |
|
| 243 | { |
|
| @@ 252-267 (lines=16) @@ | ||
| 249 | } |
|
| 250 | } |
|
| 251 | ||
| 252 | public function forumCategoryDelete(Request $request) |
|
| 253 | { |
|
| 254 | if (!$this->canAdministrate() && !$this->canModerate()) { |
|
| 255 | return response('Unauthorised', 401); |
|
| 256 | } |
|
| 257 | ||
| 258 | $cat_id = $request->input('category_id'); |
|
| 259 | ||
| 260 | $cat = $this->forumCategoryExists($cat_id); |
|
| 261 | if (!$cat) { |
|
| 262 | return response('Forum Category not found', 404); |
|
| 263 | } |
|
| 264 | ||
| 265 | $cat->delete(); |
|
| 266 | return response('Forum Category Deleted', 200); |
|
| 267 | } |
|
| 268 | ||
| 269 | private function forumCategoryExists(Request $request, $id) |
|
| 270 | { |
|