forked from mholt/ysaward
-
Notifications
You must be signed in to change notification settings - Fork 0
/
member.php
366 lines (304 loc) · 8.17 KB
/
member.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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
<?php
require_once "lib/init.php";
protectPage(0, true);
if (!isset($_GET['id']))
header("Location: /directory");
$mem = Member::Load($_GET['id']);
if (!$mem)
header("Location: /directory");
// No member with given ID number, or member is not in the same ward
$memInWard = $mem->WardID != $WARD->ID();
$memInLeaderStake = false;
if ($LEADER != null) {
$r = DB::Run("SELECT StakeID FROM Wards WHERE ID='{$mem->WardID}'");
$row = mysql_fetch_object($r);
if ($row->StakeID == $LEADER->StakeID) {
$memInLeaderStake = true;
}
}
if (!$memInWard && !$memInLeaderStake)
header("Location: /directory");
$isCurrent = $MEMBER && $MEMBER->ID() == $mem->ID();
// Get parts of the birth date
$bdate = strtotime($mem->Birthday);
$mm = date("F", $bdate);
$dd = date("j", $bdate);
$ordinal = date("S", $bdate);
// Load survey questions in order to get the answers
$r = DB::Run("SELECT ID FROM SurveyQuestions WHERE WardID='{$mem->WardID}' AND Visible='1'");
if (!$r)
die("ERROR > Can't render this page because of a database problem. Please report this: ".mysql_error());
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $mem->FirstName().' '.$mem->LastName; ?> — <?php echo $WARD ? $WARD->Name." Ward" : SITE_NAME; ?></title>
<?php include "includes/head.php"; ?>
<style>
.whitebg {
background: #FFF;
padding: 2em 0;
}
.member-name {
margin: 20px auto 20px;
font-size: 72px;
font-weight: 300;
line-height: 1em;
color: #000;
text-align: center;
}
.member-meta {
line-height: 2em;
text-align: center;
}
.member-meta .metafield {
display: inline-block;
margin-right: 25px;
white-space: nowrap;
font-size: 18px;
}
.member-meta .metafield:last-child {
margin-right: 0;
}
.member-meta .metafield a {
color: inherit;
}
.member-meta .metafield a:hover {
color: #000;
text-decoration: none;
}
.member-meta .home {
font-size: 22px;
color: #000;
text-align: center;
display: block;
font-weight: bold;
}
.misc {
font-size: 14px;
line-height: 1.75em;
}
.misc b {
display: block;
color: #000;
}
.chunk {
display: block;
margin-bottom: 2em;
}
.question,
.answer {
font-size: 16px;
}
.question {
margin-bottom: .25em;
border-bottom: 1px solid #AAA;
background: #F3F3F3;
padding: 5px;
font-weight: bold;
}
.answer {
margin-bottom: 2.5em;
}
.deletemem {
position: relative;
top: -1.5em;
font-size: 12px;
text-align: center;
}
.deletemem a {
text-decoration: none;
}
@media (max-width: 767px) {
.member-meta .metafield {
display: block;
text-align: left;
padding-left: 25%;
}
}
@media (max-width: 600px) {
.member-name {
margin: 10px auto 15px;
font-size: 42px;
}
.member-meta .metafield {
text-align: left;
padding-left: 5%;
}
.member-meta .home {
font-size: 20px;
}
mark {
font-size: 12px;
}
}
@media (max-width: 1024px) and (min-width: 768px) {
.chunk {
display: inline-block;
margin-right: 3em;
margin-bottom: 4em;
}
.misc {
text-align: center;
}
}
</style>
</head>
<body>
<?php include "includes/header.php"; ?>
<div class="whitebg">
<div class="grid-container">
<div class="grid-30 text-center">
<?php if ($mem->PictureFile): ?>
<a href="/uploads/<?php echo $mem->PictureFile; ?>" style="cursor: -moz-zoom-in; cursor: -webkit-zoom-in;" target="_blank"><?php echo $mem->ProfilePicImgTag(false, false); ?></a>
<?php else: ?>
<?php echo $mem->ProfilePicImgTag(false, false); ?>
<?php endif; ?>
<?php if ($isCurrent): ?>
<small>
<br>[<a href="/profile#pic">Change picture</a>]
</small>
<?php endif; ?>
</div>
<div class="grid-70">
<?php if ($isCurrent): ?>
<p class="text-center">
<mark>
This is you. <b><a href="/profile">Edit profile</a></b>
| <b><a href="/survey">Edit survey answers</a></b>
</mark>
</p>
<?php endif; ?>
<div class="member-name">
<?php echo $mem->FirstName().' '.$mem->LastName; ?>
</div>
<?php if ($MEMBER && $MEMBER->HasPrivilege(PRIV_DELETE_ACCTS) && $MEMBER->ID() != $mem->ID()): ?>
<div class="deletemem">
<a id="delmem" class="del" href="javascript:" title="Permanently delete this member's account"><i class="fa fa-times"></i> Delete Account</a>
</div>
<?php endif; ?>
<div class="member-meta">
<span class="home">
<i class="fa fa-home"></i>
<?php echo $mem->ResidenceString(); ?>
</span>
<hr>
<?php if (!$mem->HideEmail || $isCurrent || $LEADER): ?>
<span class="metafield">
<a href="mailto:<?php echo $mem->Email; ?>" target="_blank" title="Send email">
<i class="fa fa-envelope"></i>
<?php echo $mem->Email; ?>
</a>
</span>
<?php endif; ?>
<?php if ($mem->PhoneNumber && (!$mem->HidePhone || $isCurrent || $LEADER)): ?>
<span class="metafield">
<?php if (IS_MOBILE) echo '<a href="tel:'.$mem->PhoneNumber.'">'; ?>
<i class="fa fa-phone"></i>
<?php echo formatPhoneForDisplay($mem->PhoneNumber); ?>
<?php if (IS_MOBILE) echo '</a>'; ?>
</span>
<?php endif; ?>
<?php if (!$mem->HideBirthday || $isCurrent || $LEADER): ?>
<span class="metafield">
<i class="fa fa-gift"></i>
<?php echo "{$mm} {$dd}<sup>{$ordinal}</sup>"; ?>
</span>
<?php endif; ?>
</div>
</div>
<hr class="clear">
<br><br>
<div class="grid-25 mobile-grid-30 misc">
<div class="chunk">
<?php
$roommates = $mem->Roommates();
echo count($roommates) == 1 ? '<b>Roommate</b>' : '<b>Roommates</b>';
foreach ($roommates as $rm)
echo '<a href="/member?id='.$rm->ID().'">'.$rm->FirstName()." ".$rm->LastName."</a><br>";
?>
</div>
<div class="chunk">
<?php
$callings = $mem->Callings();
echo count($callings) == 1 ? '<b>Calling</b>' : '<b>Callings</b>';
foreach ($callings as $c)
echo $c->Name."<br>";
?>
</div>
<div class="chunk">
<b>FHE group</b>
<?php
$group = FheGroup::Load($mem->FheGroup);
if ($group)
echo $group->GroupName;
?>
</div>
<div class="chunk">
<b>Member since</b>
<?php echo date('F Y', strtotime($mem->RegistrationDate())); ?>
</div>
<div class="chunk">
<b>Profile updated</b>
<?php echo $mem->LastUpdated() > 0 ? date('j M Y', strtotime($mem->LastUpdated())) : "<i>Never</i>"; ?>
</div>
<br>
</div>
<div class="grid-75 mobile-grid-70">
<?php
if ($isCurrent):
while ($row = mysql_fetch_array($r)):
$qu = SurveyQuestion::Load($row['ID']);
if (!$qu)
continue;
$ans = $qu->Answers($mem->ID());
$readonlyAnswer = $ans && $ans->ReadonlyAnswer() ? $ans->ReadonlyAnswer() : '<i>no answer</i>';
?>
<div class="question">
<?php echo $qu->Question; ?>
</div>
<div class="answer">
<?php echo $readonlyAnswer; ?>
</div>
<?php
endwhile;
else:
// Get this person's answers to the survey, and display those which
// the current member is allowed to see.
$permissions = $USER->Permissions(true);
if (count($permissions) == 0)
echo "<i>None of {$mem->FirstName()}'s survey answers are available for you to view.</i>";
foreach ($permissions as $per):
$qu = SurveyQuestion::Load($per->QuestionID());
if (!$qu)
continue;
$ans = $qu->Answers($mem->ID());
$readonlyAnswer = $ans && $ans->ReadonlyAnswer() ? $ans->ReadonlyAnswer() : '<i>no answer</i>';
?>
<div class="question">
<?php echo $qu->Question; ?>
</div>
<div class="answer">
<?php echo $readonlyAnswer; ?>
</div>
<?php
endforeach;
endif;
?>
</div>
</div>
</div>
<?php include "includes/footer.php"; ?>
<?php include "includes/nav.php"; ?>
<script>
$('#delmem').click(function()
{
var conf = confirm("Everything about this person will be deleted permanently from this website. It CANNOT be undone. Are you sure you want to do this?");
if (conf == true)
window.location = '/manage/api/deletemem?id=<?php echo($mem->ID()); ?>';
else
return;
});
</script>
</body>
</html>