summaryrefslogtreecommitdiff
path: root/src/web/_controller
diff options
context:
space:
mode:
Diffstat (limited to 'src/web/_controller')
-rw-r--r--src/web/_controller/_util/post.php18
-rw-r--r--src/web/_controller/apps/profile.php35
2 files changed, 51 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
);
}
diff --git a/src/web/_controller/apps/profile.php b/src/web/_controller/apps/profile.php
new file mode 100644
index 0000000..aaed348
--- /dev/null
+++ b/src/web/_controller/apps/profile.php
@@ -0,0 +1,35 @@
+<?php /* Copyright (c) 2024 Freya Murphy */
+class Profile_controller extends Controller {
+
+ // the home model
+ private $profile_model;
+
+ // the format model
+ protected $format_model;
+
+ // the post model
+ protected $post_controller;
+
+ function __construct($load) {
+ parent::__construct($load);
+ $this->profile_model = $this->load->model('apps/profile');
+ $this->format_model = $this->load->model('format');
+ $this->post_controller = $this->load->controller('_util/post');
+ }
+
+ public function index(): void {
+ parent::index();
+ $data = $this->profile_model->get_data();
+
+ if (!$data) {
+ $this->error(404);
+ }
+
+ $this->view('header', $data);
+ $this->view('apps/profile/main', $data);
+ $this->view('footer', $data);
+ }
+
+}
+
+?>