-
Notifications
You must be signed in to change notification settings - Fork 0
/
explorationSingle-Conversations.php
executable file
·293 lines (241 loc) · 9.33 KB
/
explorationSingle-Conversations.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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
<?php
require "lib/site.php";
ob_start();
$exploration;
if(isset($_GET['id'])) {
$id = $_GET['id'];
if($id == 0) {
$id = 1;
}
if(!is_numeric($id)) {
$id = 1;
}
$exploration = $explorations->get($id);
$stops = $exploration->getStops();
}
?>
<?php
$pagename = $exploration->getName();
include('includes/head.php');
include('includes/header.php');
?>
<!--===============================
Landing Image
================================-->
<div id='landing' class="placeSub" style="background: url('<?php
echo $source.$exploration->getHeaderPath();
?>') center center;
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
position: absolute;
overflow: hidden;
width: 100%;">
<div id='landing-overlay-blend' class="placeSub"></div>
</div>
<!--===============================
Place NavBar
================================-->
<div class="placeNavBar">
<a class="back" href="explorationSingle.php?id=<?php echo $id;?>"><img class="backArrow" src="assets/svgs/arrow.svg"/><p class="backTitle"><?php echo $exploration->getName();?>
<div class="right">
<a href="explorationSingle-Map.php?id=<?php echo $id;?>">Map</a>
<a class="active" href="explorationSingle-Conversations.php?id=<?php echo $id;?>">Conversations</a></div>
</div>
<!--===============================
Conversations
================================-->
<!--<div class="placeSingleSubTitle"><h4>Conversations</h4></div>
<section id='conversations'>
<div class="conversationCard">
<div class="userDate">
<p class="userName">User Name</p>
<div class="tooltip"><span class="tooltiptext">Citizen Expert</span><img src="assets/svgs/citizenExpert.svg" /></div>
<div class="tooltip"><span class="tooltiptext">Project Expert</span><img src="assets/svgs/projectExpert.svg"/></div>
<div class="tooltip"><span class="tooltiptext">Project Person</span><img src="assets/svgs/projectPerson.svg"/></div>
<p class="date">7.15.16</p></div>
<div class="conversationPreview">
<p>From which we spring. Venture from which we spring Vangelis Orion's sword, prime number Tunguska event not a sunrise but a galaxyrise galaxies? Preserve and cherish that pale blue dot as a patch of light. Shores of the cosmic ocean, colonies? Globular star cluster venture cosmic fugue corpus callosum, great turbulent clouds, birth rich in heavy atoms white dwarf, extraplanetary made in the interiors of collapsing stars, star stuff harvesting star light, stirred by starlight?</p></div>
<div class="viewConversation">
<p>3 Particpants</p>
<a href="explorationSingle-Conversation.php">VIEW CONVERSATION <img src="assets/svgs/arrowBlue.svg"/></a>
</div>
</div>-->
<!--Print all convos-->
<?php
$id = $id;
$titleName = $exploration->getName();
$type_php = 'explorationSingle.php';
$sql =<<<SQL
SELECT id, user_id, exploration_id, replyTo, isPending, UNIX_TIMESTAMP(created_at), deleted, comment from mbira_exploration_comments
where exploration_id=?
SQL;
$pdo = new PDO("mysql:dbname=$dbname;host=$dbhost;charset=utf8", $dbuser, $dbpass);
$statement = $pdo->prepare($sql);
$statement->execute(array($id));
if($statement->rowCount() === 0) {
}
$comments = array();
$sql2 =<<<SQL
SELECT firstName, lastName, email, id, username from mbira_users
SQL;
$statement2 = $pdo->prepare($sql2);
$statement2->execute();
$userData = $statement2->fetchAll();
function checkIfHasReply($i, $idToCheck, $data) {
global $comments;
for ($j = 0; $j < count($data); $j++) {
if ($idToCheck == $data[$j]['replyTo']) {
$name = idToUser($data[$j]);
$tempObj = array(
"comment_id" => $data[$j]['id'],
"user" => $name,
"date" => $data[$j]['UNIX_TIMESTAMP(created_at)'],
"comment" => $data[$j]['comment'],
"replies" => array() ,
"pending" => $data[$j]['isPending'],
"deleted" => $data[$j]['deleted']
);
array_push($comments[$i]['replies'], $tempObj);
}
}
}
function idToUser($commentData) {
global $userData;
for ($q = 0; $q < count($userData); $q++) {
if ($userData[$q]['id'] === $commentData['user_id']) {
return $userData[$q]['firstName'] . " " . $userData[$q]['lastName'];
}
}
}
function loadComments($data) {
global $comments;
$comments = array();
usort($data, function ($x, $y) {
if ($x['replyTo'] - $y['replyTo'] === 0) {
return $y['UNIX_TIMESTAMP(created_at)'] - $x['UNIX_TIMESTAMP(created_at)'];
}
else {
return $y['replyTo'] - $x['replyTo'];
}
});
for ($i = 0; $i < count($data); $i++) {
if ($data[$i]['replyTo'] == 0 || $data[$i]['replyTo'] == null) {
$name = idToUser($data[$i]);
$tempObj = array(
"comment_id" => $data[$i]['id'],
"user" => $name,
"date" => $data[$i]['UNIX_TIMESTAMP(created_at)'],
"comment" => $data[$i]['comment'],
"replies" => array() ,
"pending" => $data[$i]['isPending'],
"deleted" => $data[$i]['deleted']
);
array_push($comments, $tempObj);
}
}
for ($i = 0; $i < count($comments); $i++) {
checkIfHasReply($i, $comments[$i]['comment_id'], $data);
}
}
$data = $statement->fetchAll();
loadComments($data);
?>
<div class="placeSingleSubTitle"><h4>Conversations</h4></div>
<section id='conversations'>
<?php for ($i=0; $i < count($comments); $i++) {
if ($comments[$i]['pending'] != 'yes') {
?>
<div class="conversationCard">
<div class="userDate">
<p class="userName"><?php echo $comments[$i]['user'] ?></p>
<div class="tooltip"><span class="tooltiptext">Citizen Expert</span><img src="assets/svgs/citizenExpert.svg" /></div>
<div class="tooltip"><span class="tooltiptext">Project Expert</span><img src="assets/svgs/projectExpert.svg"/></div>
<div class="tooltip"><span class="tooltiptext">Project Person</span><img src="assets/svgs/projectPerson.svg"/></div>
<p class="date"><?php echo date("m.d.y", $comments[$i]['date']);?></p>
</div>
<div class="conversationPreview">
<p>
<?php echo $comments[$i]['comment'];?>
</p>
</div>
<div class="viewConversation">
<?php
$replies_ct = 0;
for ($j=0; $j < count($comments[$i]['replies']); $j++) {
if ($comments[$i]['replies'][$j]['pending'] != 'yes') {
$replies_ct++;
}
}
?>
<p><?php echo $replies_ct?> Particpants</p>
<a href="explorationSingle-Conversation.php?id=<?php echo $id?>&convo=<?php echo $comments[$i]['comment_id']; ?>">VIEW CONVERSATION <img src="assets/svgs/arrowBlue.svg"/></a>
</div>
</div>
<?php
}
}
?>
<?php
if(count($comments) == 0) {
echo "No Comments Yet.";
}
?>
<!--- End print all convos -->
</section>
<a href="" class="bottomButton openModalStartConversation">Start Conversation</a>
<!--===============================
Modals Include
================================-->
<?php
$params = "";
$redirectLocation = "";
if(isset($_GET['s']) && isset($_GET['t']) && isset($_GET['expid'])) {
$params = "&s=".$step."&t=".$total."&expid=".$expid;
}
/*$redirectLocation = "placeSingle-Conversations.php?id=".$id."&type=".$_GET['type'].$params;*/
/*$redirectLocation = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];*/
$redirectLocation = $_SERVER['REQUEST_URI'];
$pgType = 'exp';
if(isset($_SESSION['user'])){
include('includes/modalStartConversation.php');
}
else{
include('includes/modalLogInPrompt.php');
}
?>
<?php if(!isset($_SESSION['user'])){?>
<script>
$('.openModalStartConversation').click(function() {
$('#modalLogInExpPrompt').addClass('displayModal');
$('body').addClass('modal-open');
return false;
});
$('.closeModalLogInPrompt').click(function() {
$('#modalLogInExpPrompt').removeClass('displayModal');
$('body').removeClass('modal-open');
});
</script>
<?php } ?>
<?php if(isset($_SESSION['user'])){ ?>
<script>
$('.openModalStartConversation').click(function() {
$('#modalStartExpConversation').addClass('displayModal');
$('body').addClass('modal-open');
return false;
});
$('.closeModalStartConversation').click(function() {
$('#modalStartExpConversation').removeClass('displayModal');
$('body').removeClass('modal-open');
});
</script>
<?php } ?>
<!--===============================
Scripts & Footer
================================-->
<script src='js/index.js'></script>
<script src='js/modals.js'></script>
<?php
include('includes/footer.php');
?>
<div class="footerSpacer"></div>