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 @@
+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);
+ }
+
+}
+
+?>
diff --git a/src/web/_model/apps/auth.php b/src/web/_model/apps/auth.php
index a1802de..8a359d5 100644
--- a/src/web/_model/apps/auth.php
+++ b/src/web/_model/apps/auth.php
@@ -5,7 +5,7 @@ class Auth_model extends Model {
parent::__construct($load);
}
- public function get_data(): array {
+ public function get_data(): ?array {
$data = parent::get_data();
$data['title'] = lang('login');
return $data;
diff --git a/src/web/_model/apps/error.php b/src/web/_model/apps/error.php
index 58e3346..4118c62 100644
--- a/src/web/_model/apps/error.php
+++ b/src/web/_model/apps/error.php
@@ -22,7 +22,7 @@ class Error_model extends Model {
}
}
- public function get_data(): array {
+ public function get_data(): ?array {
$data = parent::get_data();
$this->get_msg($data);
return $data;
diff --git a/src/web/_model/apps/home.php b/src/web/_model/apps/home.php
index 82fbf26..caa254f 100644
--- a/src/web/_model/apps/home.php
+++ b/src/web/_model/apps/home.php
@@ -13,7 +13,7 @@ class Home_model extends Model {
->rows();
}
- public function get_data(): array {
+ public function get_data(): ?array {
$data = parent::get_data();
$data['title'] = lang('title');
$data['posts'] = $this->get_posts();
diff --git a/src/web/_model/apps/people.php b/src/web/_model/apps/people.php
index 4b6bab4..1bb110f 100644
--- a/src/web/_model/apps/people.php
+++ b/src/web/_model/apps/people.php
@@ -80,7 +80,7 @@ class People_model extends Model {
);
}
- public function get_data(): array {
+ public function get_data(): ?array {
$data = parent::get_data();
$data['title'] = lang('title');
return $data;
diff --git a/src/web/_model/apps/profile.php b/src/web/_model/apps/profile.php
new file mode 100644
index 0000000..592fbcb
--- /dev/null
+++ b/src/web/_model/apps/profile.php
@@ -0,0 +1,37 @@
+request_model = $this->load->model('request');
+ }
+
+ public function get_data(): ?array {
+ $uid = $this->request_model->get_int('id', FALSE);
+ if ($uid === FALSE) {
+ if ($this->main->session) {
+ $uid = $this->main->user()['id'];
+ } else {
+ return NULL;
+ }
+ }
+
+ $user = $this->db
+ ->select('*')
+ ->from('api.user u')
+ ->where('u.id')
+ ->eq($uid)
+ ->row();
+
+ if (!$user) {
+ return NULL;
+ }
+
+ $data = parent::get_data();
+ $data['user'] = $user;
+ $data['title'] = lang('title', sub: [$user['first_name']]);
+ return $data;
+ }
+}
diff --git a/src/web/_views/apps/auth/login.php b/src/web/_views/apps/auth/login.php
index d7f326b..231e12e 100644
--- a/src/web/_views/apps/auth/login.php
+++ b/src/web/_views/apps/auth/login.php
@@ -49,7 +49,7 @@
diff --git a/src/web/_views/modal/new_post.php b/src/web/_views/modal/new_post.php
index 50b9b84..66cb8c8 100644
--- a/src/web/_views/modal/new_post.php
+++ b/src/web/_views/modal/new_post.php
@@ -31,18 +31,18 @@