blob: acec9c00bc1eb2e0bce8700d94cef95fc0483928 (
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
<?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;
}
$following = FALSE;
$followed = FALSE;
$follow_id = NULL;
if ($this->main->session) {
$sid = $this->main->user()['id'];
$res = $this->db->select('f.value, f.id')
->from('xssbook.follow f')
->where('f.follower_id')
->eq($sid)
->where('f.followee_id')
->eq($uid)
->row();
$following = $res ? $res['value'] : FALSE;
$follow_id = $res ? $res['id'] : NULL;
$res = $this->db->select('f.value')
->from('xssbook.follow f')
->where('f.follower_id')
->eq($uid)
->where('f.followee_id')
->eq($sid)
->row();
$followed = $res ? $res['value'] : FALSE;
}
$data = parent::get_data();
$data['user'] = $user;
$data['following'] = $following;
$data['followed'] = $followed;
$data['follow_id'] = $follow_id;
$data['title'] = ucfirst(lang('title', sub: [$user['first_name']]));
return $data;
}
}
|