-
Notifications
You must be signed in to change notification settings - Fork 1
/
comment.inc.php
77 lines (71 loc) · 3.3 KB
/
comment.inc.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
<?php
# First retrieve the needed parameters
isset($messageId) ? false : $messageId = $tplHelper->getParam('messageid');
isset($pageNr) ? false : $pageNr = $tplHelper->getParam('pagenr');
isset($perPage) ? false : $perPage = $tplHelper->getParam('perpage');
/*
* We retrieve the fullspot as well because we want to compare the spotterids.
* This operation is rather cheap because we already have the fullspot cached
* in the database
*/
isset($spot) ? false : $spot = $tplHelper->getFullSpot($messageId, true);
# is the user allowed to blacklist spotters?
$perm_allow_blackList = ($tplHelper->allowed(SpotSecurity::spotsec_blacklist_spotter, ''));
# Get the spot comments for each $perPage comments
$comments = $tplHelper->getSpotComments($messageId, ($pageNr * $perPage), $perPage);
$comments = $tplHelper->formatComments($comments);
# Does the user want to see avatars?
$show_avatars = $currentSession['user']['prefs']['show_avatars'];
foreach($comments as $comment) {
if ($comment['verified']) {
$commenterIsPoster = ($comment['spotterid'] == $spot['spotterid']);
$commentIsModerated = ($comment['moderated']);
$allow_blackList = (($perm_allow_blackList) && (!empty($comment['spotterid'])) && ($comment['idtype'] != 1));
if($comment['spotrating'] == 0) {
$rating = '';
} elseif($comment['spotrating'] > 0) {
$rating = '<span class="rating" title="' . sprintf(ngettext("%s gave this spot %d star", "%s gave this spot %d stars", $comment['spotrating']), $comment['fromhdr'], $comment['spotrating']) . '"><span style="width:' . $comment['spotrating'] * 4 . 'px;"></span></span>';
}
?>
<div class="comments effect">
<blockquote <?php if ($commenterIsPoster) { echo ' class="alert-info"'; } ?>>
<?php
if ($show_avatars) {
?>
<img class="commentavatar" src='<?php echo $tplHelper->makeCommenterImageUrl($comment); ?>'>
<?php
}
?>
<small>
<?php echo $rating; ?><?php echo sprintf(_('Posted by %s'), '<span class="user"><strong>' . $comment['fromhdr'] . '</strong></span>'); ?>
(<a class="spotterid" target = "_parent" href="<?php echo $tplHelper->makeSpotterIdUrl($comment); ?>" title='<?php echo sprintf(_('Find spots from %s'), $comment['fromhdr']); ?>'><?php echo $comment['spotterid']; ?></a>
<?php
if ($allow_blackList) {
?>
<div class="mask">
<div class="btn-group pull-right">
<a
class="btn btn-primary btn-xs delete blacklistuserlink_<?php echo htmlspecialchars($comment['spotterid']); ?>"
title="<?php echo _('Blacklist this sender'); ?>"
onclick="blacklistSpotterId('<?php echo htmlspecialchars($comment['spotterid']); ?>');">
<i class="fa fa-lock"></i>
</a>
</div>
</div>
<?php
}
?>
) @ <?php echo $tplHelper->formatDate($comment['stamp'], 'comment'); ?> </small>
<br />
<?php if ($commentIsModerated) { echo '<div class="well well-sm">' . _('This comment is moderated') . '</div>'; } ?>
<?php if (isset($comment['body_translated'])) {
echo nl2br($comment['body_translated']);
} else {
echo nl2br($comment['body']);
}
?>
</blockquote>
</div>
<?php
} # if
} # for