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 pathproject.php
More file actions
139 lines (119 loc) · 4.7 KB
/
Copy pathproject.php
File metadata and controls
139 lines (119 loc) · 4.7 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
require_once(dirname(__FILE__) . "/includes/common/only_allow_login.php");
require_once(dirname(__FILE__) . "/includes/common/check_request.php");
verifyAttributes($_GET, ["projectId"]);
require_once(dirname(__FILE__) . "/classes/Project.php");
require_once(dirname(__FILE__) . "/classes/Member.php");
//load the project
$project = new Project();
if (!$project->load($_GET["projectId"])) {
echo "Project not found";
die();
}
//check if the user is a member of the project
if (!$project->verifyOwnership($_SESSION["userId"])) {
echo "No permission for you.";
die();
}
//load page defaults
require_once(dirname(__FILE__) . "/includes/common/defaults.php");
$PAGE["title"] .= " : Project " . htmlentities($project->title);
$PAGE["styles"] = array_merge($PAGE["styles"], ["card_form.css", "project.css"]);
$PAGE["scripts"] = array_merge($PAGE["scripts"], array("editableOnClick.js", "search.js", "project.js", "ajax.js"));
$PAGE["includeCSRF"] = true;
$PAGE["bodyClasses"][] = $project->colour;
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");
$todos = TodoList::getAllByProject($project->projectId);
$countArchived = 0;
$countItems = 0;
$countIncompleteItems = 0;
foreach ($todos as $todo) {
if ($todo->archived) $countArchived++;
$countItems += count($todo->items);
foreach ($todo->items as $item)
if (!$item->completed)
$countIncompleteItems++;
}
$statistics = array(
"Members" => Member::countByProject($project->projectId),
"Todo Lists" => count($todos),
"Archived Todo Lists" => $countArchived,
"Completed Items" => $countItems - $countIncompleteItems,
"Incomplete Items" => $countIncompleteItems,
"Total Items" => $countItems
);
//load members
require_once(dirname(__FILE__) . "/classes/User.php");
$members = User::getAllByProject($project->projectId);
?>
<div class="container" id="projectMainContainer" data-projectId="<?= $project->projectId ?>">
<h1 class="center"><span class="strong"><?= htmlentities($project->title) ?></span></h1>
<h2 class="strong">Description</h2>
<div class="description">
<?= htmlentities($project->description) ?>
</div>
<h2 class="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>
<form id="projectForm" action="actions/project/edit_project.php" method="post">
<?php insertCsrfToken(); ?>
<div class="cardForm">
<div class="formHeader">
<h3 class="formTitle">Edit Project</h3>
</div>
<div class="formBody">
<input type="hidden" name="projectId" value="<?= $project->projectId ?>">
<div>
<input type="text" name="title" placeholder="Project title" value="<?= htmlentities($project->title) ?>" required>
</div>
<div>
<textarea id="editProjDesc" name="description" rows="5" placeholder="Project Description"><?= htmlentities($project->description) ?></textarea>
</div>
<div>
<select name="colour">
<?php
$colours = array("white", "red", "orange", "yellow", "green", "teal", "blue", "purple", "pink", "brown");
foreach ($colours as $colour) : ?>
<option class="<?= $colour ?>" value="<?= $colour ?>" <?= $project->colour == $colour ? "selected" : "" ?>><?= ucfirst($colour) ?></option>
<?php endforeach ?>
</select>
</div>
</div>
<footer class="formFooter">
<input type="submit" value="Save">
</footer>
<div class="errors"></div>
</div>
</form>
<hr/>
<h2 class="center strong">Members</h2>
<div class="members">
<div class="errors"></div>
<?php foreach ($members as $member) :
$base = "public/images/profile/";
$filename = $base . $member->userId . ".jpg";
if (!file_exists($filename)) $filename = $base . "default.png" ?>
<div class="memberContainer">
<a class="memberLink" href="user.php?userId=<?= $member->userId ?>" title="User: <?= htmlentities($member->username) ?>"><img alt="profile picture" class="member" src="<?= $filename ?>"/></a>
<h2 class="center"> <?= htmlentities($member->username); ?></h2>
<hr/>
<a class="removeMember" data-userId="<?= $member->userId ?>" title="remove member"><i class="material-icons">delete</i></a>
</div>
<?php endforeach ?>
<br/>
<a id="addMember"><i class="material-icons">add</i> Add member</a>
</div>
<hr/>
<h1 class="center strong" id="actions">Actions</h1>
<h1 class="strong"><a id="deleteProject"><i class="material-icons">delete</i> Delete Project</a></h1>
</div>
<?php require_once(dirname(__FILE__) . "/templates/common/footer.php"); ?>