filter by following only
This commit is contained in:
parent
d368e58b46
commit
f7ed928738
1 changed files with 31 additions and 7 deletions
|
@ -5,6 +5,7 @@
|
||||||
global $username;
|
global $username;
|
||||||
global $db;
|
global $db;
|
||||||
$page = array_key_exists('page',$_GET) ? ($_GET['page']) : 0;
|
$page = array_key_exists('page',$_GET) ? ($_GET['page']) : 0;
|
||||||
|
$mode = array_key_exists('mode',$_GET) ? ($_GET['mode']) : 'all';
|
||||||
if ($username && !$disable) {
|
if ($username && !$disable) {
|
||||||
form("Broadcast your thoughts...", '', array(
|
form("Broadcast your thoughts...", '', array(
|
||||||
array('key' => 'Your message', 'type' => 'textarea', 'name' => 'post', 'default' => ''),
|
array('key' => 'Your message', 'type' => 'textarea', 'name' => 'post', 'default' => ''),
|
||||||
|
@ -27,6 +28,13 @@
|
||||||
$qs_next = http_build_query($qss);
|
$qs_next = http_build_query($qss);
|
||||||
$qss['page'] = $page - 1;
|
$qss['page'] = $page - 1;
|
||||||
$qs_prev = http_build_query($qss);
|
$qs_prev = http_build_query($qss);
|
||||||
|
$qss['page'] = $page;
|
||||||
|
|
||||||
|
$qss['mode'] = 'all';
|
||||||
|
$qs_1 = http_build_query($qss);
|
||||||
|
|
||||||
|
$qss['mode'] = 'followers';
|
||||||
|
$qs_2 = http_build_query($qss);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
@ -34,6 +42,11 @@
|
||||||
<a class="form-button" href="?<?php echo $qs_prev ?>">Previous</a>
|
<a class="form-button" href="?<?php echo $qs_prev ?>">Previous</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<a class="form-button" href="?<?php echo $qs_next ?>">Next</a>
|
<a class="form-button" href="?<?php echo $qs_next ?>">Next</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<a class="form-button" href="?<?php echo $qs_1 ?>">Everyone</a>
|
||||||
|
<a class="form-button" href="?<?php echo $qs_2 ?>">Following</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
@ -52,13 +65,24 @@
|
||||||
$posts = array_merge($posts1,$posts);
|
$posts = array_merge($posts1,$posts);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = $db->prepare("SELECT * FROM comment WHERE targetType = ? AND targetId = ? ORDER BY date DESC LIMIT ? OFFSET ?");
|
if ($mode == 'all') {
|
||||||
$stmt->execute([
|
$stmt = $db->prepare("SELECT * FROM comment WHERE targetType = ? AND targetId = ? ORDER BY date DESC LIMIT ? OFFSET ?");
|
||||||
$typer,
|
$stmt->execute([
|
||||||
$idr,
|
$typer,
|
||||||
10,
|
$idr,
|
||||||
$page * 10
|
10,
|
||||||
]);
|
$page * 10
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$stmt = $db->prepare("SELECT * FROM comment WHERE targetType = ? AND targetId = ? AND username IN (SELECT username FROM main.follow WHERE target = ?) ORDER BY date DESC LIMIT ? OFFSET ?");
|
||||||
|
$stmt->execute([
|
||||||
|
$typer,
|
||||||
|
$idr,
|
||||||
|
$username,
|
||||||
|
10,
|
||||||
|
$page * 10
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
$posts2 = $stmt->fetchAll(PDO::FETCH_DEFAULT);
|
$posts2 = $stmt->fetchAll(PDO::FETCH_DEFAULT);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue