-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.php
80 lines (74 loc) · 2.85 KB
/
user.php
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?
require 'init.php';
$user_id = $_GET['id'];
if (!get_username_by_user_id($user_id)) {
display_not_found_page();
}
$followers = get_followers($user_id);
$page_url = APP_URL . '/user.php?id=' . $user_id;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['follow'])) {
follow_user($user_id, get_current_user_id());
redirect($page_url);
} else if (isset($_POST['unfollow'])) {
unfollow_user($user_id, get_current_user_id());
redirect($page_url);
}
}
$follower_count = get_follower_count($user_id);
?>
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Tubogram</title>
<? echo js_and_css() ?>
</head>
<?
if (get_current_user_id()) {
page_header('logged');
} else {
page_header('not_logged');
}
?>
<div class="container">
<div class="page-header">
<h1>
<? echo ucfirst(get_username_by_user_id($user_id)) ?>
<? if (get_current_user_id() && get_current_user_id() != $user_id): ?>
<? if (is_following(get_current_user_id(), $user_id)): ?>
<form class="inline btn-group" method="POST" action="<? echo escape_html($page_url) ?>">
<button class="btn btn-danger" type="submit" name="unfollow">
<span class="glyphicon glyphicon-minus"></span>
Відписатися
</button>
<button class="btn btn-default followers" style="background: transparent" data-content="<? echo escape_html(links_for_users($followers)) ?>">
<? echo $follower_count ?>
</button>
</form>
<? else: ?>
<form class="inline btn-group" method="POST" action="<? echo escape_html($page_url) ?>">
<button class="btn btn-primary" type="submit" name="follow">
<span class="glyphicon glyphicon-plus"></span>
Підписатися
</button>
<button class="btn btn-default followers" style="background: transparent" data-content="<? echo escape_html(links_for_users($followers)) ?>">
<? echo $follower_count ?>
</button>
</form>
<? endif ?>
<? else: ?>
<button class="btn btn-default followers" style="background: transparent" data-content="<? echo escape_html(links_for_users($followers)) ?>">
<? echo $follower_count ?> підписників
</button>
<? endif ?>
</h1>
</div>
<? post_list(get_user_posts_by_user_id($user_id)) ?>
</div>
<? page_footer() ?>
<script>
$('.followers').hoverablePopover({
placement: 'right',
html: true
});
</script>