@@ 243-263 (lines=21) @@ | ||
240 | * |
|
241 | * @return \Symfony\Component\HttpFoundation\JsonResponse |
|
242 | */ |
|
243 | public function getAfter($id) |
|
244 | { |
|
245 | if (!$this->auth->acl_get('u_shoutbox_view')) |
|
246 | { |
|
247 | return $this->error('AJAX_SHOUTBOX_ERROR', 'AJAX_SHOUTBOX_NO_PERMISSION', 403); |
|
248 | } |
|
249 | ||
250 | $sql = 'SELECT c.*, u.username, u.user_colour FROM |
|
251 | ' . $this->table . ' c, |
|
252 | ' . $this->usertable . ' u |
|
253 | WHERE post_time >= ( |
|
254 | SELECT post_time FROM ' . $this->table . ' |
|
255 | WHERE shout_id = ' . (int) $id . ' |
|
256 | ) |
|
257 | AND c.shout_id != ' . (int) $id . ' |
|
258 | AND u.user_id = c.user_id |
|
259 | ORDER BY post_time DESC, shout_id DESC'; |
|
260 | $result = $this->db->sql_query($sql); |
|
261 | ||
262 | return $this->returnPosts($result); |
|
263 | } |
|
264 | ||
265 | /** |
|
266 | * Get 10 shouts before the current shout ID. |
|
@@ 272-292 (lines=21) @@ | ||
269 | * |
|
270 | * @return \Symfony\Component\HttpFoundation\JsonResponse |
|
271 | */ |
|
272 | public function getBefore($id) |
|
273 | { |
|
274 | if (!$this->auth->acl_get('u_shoutbox_view')) |
|
275 | { |
|
276 | return $this->error('AJAX_SHOUTBOX_ERROR', 'AJAX_SHOUTBOX_NO_PERMISSION', 403); |
|
277 | } |
|
278 | ||
279 | $sql = 'SELECT c.*, u.username, u.user_colour FROM |
|
280 | ' . $this->table . ' c, |
|
281 | ' . $this->usertable . ' u |
|
282 | WHERE post_time <= ( |
|
283 | SELECT post_time FROM ' . $this->table . ' |
|
284 | WHERE shout_id = ' . (int) $id . ' |
|
285 | ) |
|
286 | AND c.shout_id != ' . (int) $id . ' |
|
287 | AND u.user_id = c.user_id |
|
288 | ORDER BY post_time DESC, shout_id ASC'; |
|
289 | $result = $this->db->sql_query_limit($sql, 10); |
|
290 | ||
291 | return $this->returnPosts($result, false); |
|
292 | } |
|
293 | ||
294 | /** |
|
295 | * Loop over a SQL result set, and generate a JSON array based on the post data. |