summaryrefslogtreecommitdiff
path: root/src/web/_controller/profile.php
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-12-23 11:13:27 -0500
committerFreya Murphy <freya@freyacat.org>2024-12-23 11:13:27 -0500
commit5a2ba9c2e7605bb788bc406184547d22c6436867 (patch)
treecbd988d534e8a8593a31d70571222443f80da0b3 /src/web/_controller/profile.php
parentfix about modal (diff)
downloadxssbook2-5a2ba9c2e7605bb788bc406184547d22c6436867.tar.gz
xssbook2-5a2ba9c2e7605bb788bc406184547d22c6436867.tar.bz2
xssbook2-5a2ba9c2e7605bb788bc406184547d22c6436867.zip
v2.1.0, refactor w/ crimson
Diffstat (limited to 'src/web/_controller/profile.php')
-rw-r--r--src/web/_controller/profile.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/web/_controller/profile.php b/src/web/_controller/profile.php
new file mode 100644
index 0000000..dd02ed2
--- /dev/null
+++ b/src/web/_controller/profile.php
@@ -0,0 +1,44 @@
+<?php /* Copyright (c) 2024 Freya Murphy */
+class Profile_controller extends XSS_Controller {
+
+ // the profile model
+ private $profile_model;
+
+ // the post controller
+ protected $post_controller;
+
+ // the people controller
+ protected $people_controller;
+
+ function __construct() {
+ parent::__construct();
+ $this->profile_model = $this->load_model('profile');
+ $this->people_controller = $this->load_controller('people');
+ $this->post_controller = $this->load_controller('_post');
+ $this->load_lang('profile');
+ }
+
+ public function index(): void {
+ $id = $this->get_int('id');
+
+ parent::index();
+ $data = $this->profile_model->get_data();
+
+ // profile does not exist
+ if (!$data) {
+ // not logged in and trying to access own profile
+ if (!$id)
+ $this->redirect('/auth/login');
+ // directly accessing unknown user id => 404
+ else
+ $this->error(404);
+ }
+
+ $this->view('header', $data);
+ $this->view('profile/main', $data);
+ $this->view('footer', $data);
+ }
+
+}
+
+?>