diff options
author | Freya Murphy <freya@freyacat.org> | 2024-04-03 11:25:57 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2024-04-03 11:25:57 -0400 |
commit | 740df2706934231a91c5e2d5061198ea962c357c (patch) | |
tree | b3de8027238850d43c6841f834a88e75ba90ce75 /src/web/_controller/_util | |
parent | finish profile directory (mostly) (diff) | |
download | xssbook2-740df2706934231a91c5e2d5061198ea962c357c.tar.gz xssbook2-740df2706934231a91c5e2d5061198ea962c357c.tar.bz2 xssbook2-740df2706934231a91c5e2d5061198ea962c357c.zip |
profile page
Diffstat (limited to 'src/web/_controller/_util')
-rw-r--r-- | src/web/_controller/_util/post.php | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/web/_controller/_util/post.php b/src/web/_controller/_util/post.php index b48816d..4da2671 100644 --- a/src/web/_controller/_util/post.php +++ b/src/web/_controller/_util/post.php @@ -61,6 +61,7 @@ class Post_controller extends Controller { $page = $this->request_model->get_int('page', 0); $max = $this->request_model->get_int('max'); $offset = $page * $this->page_size; + $filter_uid = $this->request_model->get_int('user_id', FALSE); $user = $this->main->user(); $uid = isset($user) ? $user['id'] : NULL; @@ -78,6 +79,11 @@ class Post_controller extends Controller { ->where('p.id')->le($max); } + if ($uid) { + $query = $query + ->where('p.user_id')->eq($uid); + } + $posts = $query ->order_by('p.id', 'DESC') ->limit($this->page_size) @@ -96,9 +102,16 @@ class Post_controller extends Controller { $this->view('template/post', $data); } - $pc = $this->db + $query = $this->db ->select('COUNT(p.id) as pc') - ->from('api.post p') + ->from('api.post p'); + + if ($uid) { + $query = $query + ->where('p.user_id')->eq($uid); + } + + $pc = $query ->row()['pc']; return array( @@ -106,6 +119,7 @@ class Post_controller extends Controller { 'total' => $pc, 'page_size' => $this->page_size, 'max' => $max, + 'filter_uid' => $filter_uid ); } |