Code Duplication    Length = 21-21 lines in 2 locations

controller/main_controller.php 2 locations

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