summaryrefslogtreecommitdiff
path: root/src/web/_controller/apps/profile.php
blob: 9e9fca6ff03009879d27274fcae982ae054a2f6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?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 controller
	protected $post_controller;

	// the people controller
	protected $people_controller;

	function __construct($load) {
		parent::__construct($load);
		$this->profile_model = $this->load->model('apps/profile');
		$this->people_controller = $this->load->controller('apps/people');
		$this->format_model = $this->load->model('format');
		$this->post_controller = $this->load->controller('_util/post');
	}

	public function index(): void {

		if ($this->main->user() && !isset($_GET['id'])) {
			$this->redirect('/profile?id=' . $this->main->user()['id']);
		}

		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);
	}

}

?>