diff options
Diffstat (limited to '')
-rw-r--r-- | src/web/_controller/profile.php | 44 |
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); + } + +} + +?> |