summaryrefslogtreecommitdiff
path: root/src/web/_model/apps/profile.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/web/_model/apps/profile.php')
-rw-r--r--src/web/_model/apps/profile.php37
1 files changed, 37 insertions, 0 deletions
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 @@
+<?php /* Copyright (c) 2024 Freya Murphy */
+class Profile_model extends Model {
+
+ private $request_model;
+
+ function __construct($load) {
+ parent::__construct($load);
+ $this->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;
+ }
+}