This repository was archived by the owner on Apr 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.php
More file actions
86 lines (74 loc) · 2.5 KB
/
Copy pathuser.php
File metadata and controls
86 lines (74 loc) · 2.5 KB
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
86
<?php
require_once(dirname(__FILE__) . "/includes/common/only_allow_login.php");
require_once(dirname(__FILE__) . "/includes/common/check_request.php");
verifyAttributes($_GET, ["userId"]);
require_once(dirname(__FILE__) . "/classes/User.php");
//load the user
$user = new User();
if (!$user->load($_GET["userId"])) {
echo "User not found";
die();
}
//load page defaults
require_once(dirname(__FILE__) . "/includes/common/defaults.php");
$PAGE["title"] .= " : User " . htmlentities($user->username);
// $PAGE["styles"] = array_merge($PAGE["styles"], []]);
$PAGE["scripts"][] = "search.js";
require_once(dirname(__FILE__) . "/templates/common/header.php");
require_once(dirname(__FILE__) . "/includes/common/choose_navbar.php");
//load statistics
require_once(dirname(__FILE__) . "/classes/TodoList.php");
require_once(dirname(__FILE__) . "/classes/Project.php");
$projects = Project::getAllByUser($user->userId);
$todos = TodoList::getAllByUser($user->userId);
$countItems = 0;
$countIncompleteItems = 0;
$countArchived = 0;
foreach ($todos as $todo) {
$countItems += count($todo->items);
if ($todo->archived) $countArchived++;
foreach ($todo->items as $item)
if (!$item->completed)
$countIncompleteItems++;
}
$statistics = array(
"Projects" => count($projects),
"Todo Lists" => count($todos),
"Archived Todo Lists" => $countArchived,
"Completed Items" => $countItems - $countIncompleteItems,
"Incomplete Items" => $countIncompleteItems,
"Total Items" => $countItems
);
?>
<div class="container" id="userMainContainer" data-userId="<?= $user->userId ?>">
<div class="user">
<div class="photo">
<?php $base = "public/images/profile/";
$filename = $base . $user->userId . ".jpg";
if (!file_exists($filename)) $filename = $base . "default.png"
?>
<img alt="profile picture" class="center userImage" src="<?= $filename ?>"/>
</div>
<div class="data">
<?php
$data = array("username", "email");
foreach ($data as $parameter) :
?>
<div class="largeFont">
<span class="parameter name"><?= $parameter ?></span>
<span class="parameter specificData"><?= htmlentities($user->$parameter) ?></span>
</div>
<?php endforeach ?>
</div>
</div>
<h2 class="center strong">Statistics</h2>
<div class="statistics">
<?php foreach ($statistics as $name => $value) : ?>
<ul class="statistics list">
<li class="statistics value"><?= $value ?></li>
<li class="statistics name"><?= $name ?></li>
</ul>
<?php endforeach ?>
</div>
</div>
<?php require_once(dirname(__FILE__) . "/templates/common/footer.php"); ?>