blob: ef888c7144bbbfcd9d1a4910512bfd8538d45d43 (
plain) (
blame)
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
81
82
83
84
85
|
<?php
$user = null;
$loggedin = null;
try {
$user = Database\User::fromDB($username);
$loggedin = Database\Cookie::fromDB($TOKEN);
}
catch(Exception $e) {}
?>
<?php if ($user !== null): ?>
<section id="user-main">
<span class="user-icon"><?php $user->icon(); ?></span>
<h1 class="username"><?= $user->Username ?></h1>
<section id="user-buttons" hidden>
<?php if ($user !== null && $loggedin !== null && $user->UID === $loggedin->UID): ?>
<form action="/list/new" method="GET">
<button title="Create a new list" class="standalone-button"><?php include $VIEWS_DIR . '/img/list-add.svg' ?></button>
</form>
<form action="/user/settings" method="GET">
<button title="Account settings" class="standalone-button"><?php include $VIEWS_DIR . '/img/settings.svg' ?></button>
</form>
<?php if ($user->Role === 'Admin'): ?>
<form action="/admin" method="GET">
<button title="Global settings" class="standalone-button"><?php include $VIEWS_DIR . '/img/global-settings.svg' ?></button>
</form>
<?php endif; ?>
<?php endif; ?>
</section>
<script type="text/javascript">
function showUserButtons() {
document.getElementById('user-buttons').hidden = false;
}
authenticated(showUserButtons);
</script>
</section>
<div class="user-blank-afterspace"></div>
<nav id="user-nav">
<button id="openArchives" onclick="openArchives()">Archives</button>
<button id="openLists" onclick="openLists()" class="not-selected">Lists</button>
</nav>
<section id="userArchives">
<?php
foreach ($user->archives() as $page) {
include $VIEWS_DIR . '/archive/item.php';
}
include_once $VIEWS_DIR . '/archive/item_show.php';
?>
</section>
<section id="userLists" hidden>
<?php
foreach ($user->archiveLists() as $list) {
include $VIEWS_DIR . '/list/item.php';
}
include_once $VIEWS_DIR . '/list/item_show.php';
?>
</section>
<script type="text/javascript">
const elemOpenArchives = document.getElementById('openArchives');
const elemOpenLists = document.getElementById('openLists');
const userArchives = document.getElementById('userArchives');
const userLists = document.getElementById('userLists');
function openArchives() {
elemOpenArchives.classList.remove('not-selected');
elemOpenLists.classList.add('not-selected');
userArchives.hidden = false;
userLists.hidden = true;
}
function openLists() {
elemOpenArchives.classList.add('not-selected');
elemOpenLists.classList.remove('not-selected');
userArchives.hidden = true;
userLists.hidden = false;
}
</script>
<?php else: ?>
<h2>User "<?= $username ?>" doesn't exist!</h2>
<?php endif; ?>
|