summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Korpel <marcel.korpel@gmail.com>2015-07-10 18:47:33 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2015-08-08 12:59:24 +0200
commit9cde6b0566390002d167703fa900129bb90e07d8 (patch)
tree0363e9d33c2db381e7448ef6ddeffcdb6bfb7266
parente331ce273cab901726983e18249e0bb3455fc463 (diff)
downloadaurweb-9cde6b0566390002d167703fa900129bb90e07d8.tar.xz
Show dateline when a comment is edited or deleted
Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com> Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
-rw-r--r--web/html/css/aurweb.css5
-rw-r--r--web/lib/pkgbasefuncs.inc.php9
-rw-r--r--web/template/pkg_comments.php38
3 files changed, 37 insertions, 15 deletions
diff --git a/web/html/css/aurweb.css b/web/html/css/aurweb.css
index b5ca1f3..b33726c 100644
--- a/web/html/css/aurweb.css
+++ b/web/html/css/aurweb.css
@@ -96,6 +96,11 @@
color: #999;
}
+.edited {
+ font-size: 0.9em;
+ color: #999;
+}
+
.delete-comment-form, .edit-comment {
float: right;
margin-left: 8px;
diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php
index 1ae3166..6057d10 100644
--- a/web/lib/pkgbasefuncs.inc.php
+++ b/web/lib/pkgbasefuncs.inc.php
@@ -47,9 +47,12 @@ function pkgbase_comments($base_id, $limit, $include_deleted) {
}
$dbh = DB::connect();
- $q = "SELECT PackageComments.ID, UserName, UsersID, Comments, ";
- $q.= "CommentTS, DelUsersID FROM PackageComments LEFT JOIN Users ";
- $q.= "ON PackageComments.UsersID = Users.ID ";
+ $q = "SELECT PackageComments.ID, A.UserName AS UserName, UsersID, Comments, ";
+ $q.= "CommentTS, EditedTS, B.UserName AS EditUserName, ";
+ $q.= "DelUsersID, C.UserName AS DelUserName FROM PackageComments ";
+ $q.= "LEFT JOIN Users A ON PackageComments.UsersID = A.ID ";
+ $q.= "LEFT JOIN Users B ON PackageComments.EditedUsersID = B.ID ";
+ $q.= "LEFT JOIN Users C ON PackageComments.DelUsersID = C.ID ";
$q.= "WHERE PackageBaseID = " . $base_id . " ";
if (!$include_deleted) {
$q.= "AND DelUsersID IS NULL ";
diff --git a/web/template/pkg_comments.php b/web/template/pkg_comments.php
index 6cc9555..8650db2 100644
--- a/web/template/pkg_comments.php
+++ b/web/template/pkg_comments.php
@@ -16,19 +16,33 @@ $count = pkgbase_comments_count($base_id, $include_deleted);
</h3>
<?php while (list($indx, $row) = each($comments)): ?>
- <?php if ($row['UserName'] && $SID):
- $row['UserName'] = "<a href=\"" . get_user_uri($row['UserName']) . "\">{$row['UserName']}</a>";
- endif; ?>
+ <?php
+ $date_fmtd = gmdate('Y-m-d H:i', $row['CommentTS']);
+ if ($row['UserName']) {
+ $user_fmtd = html_format_username($row['UserName']);
+ $heading = __('%s commented on %s', $user_fmtd, $date_fmtd);
+ } else {
+ $heading = __('Anonymous comment on %s', $date_fmtd);
+ }
+
+ if ($row['EditedTS']) {
+ $date_fmtd = gmdate('Y-m-d H:i', $row['EditedTS']);
+ $heading .= ' <span class="edited">(';
+ if ($row['DelUsersID']) {
+ $user_fmtd = html_format_username($row['DelUserName']);
+ $heading .= __('deleted on %s by %s', $date_fmtd, $user_fmtd);
+ } else {
+ $user_fmtd = html_format_username($row['EditUserName']);
+ $heading .= __('last edited on %s by %s', $date_fmtd, $user_fmtd);
+ }
+ $heading .= ')</span>';
+ }
+
+ $row['DelUserName'] = html_format_username($row['DelUserName']);
+ $row['EditUserName'] = html_format_username($row['EditUserName']);
+ ?>
<h4<?php if ($row['DelUsersID']): ?> class="comment-deleted"<?php endif; ?>>
- <?php if ($row['UserName']): ?>
- <?= __('%s commented', $row['UserName']) ?>
- <?php else: ?>
- <?= __('Anonymous comment') ?>
- <?php endif; ?>
- <?= __('on %s', gmdate('Y-m-d H:i', $row['CommentTS'])) ?>
- <?php if ($row['DelUsersID']): ?>
- (<?= __('deleted') ?>)
- <?php endif; ?>
+ <?= $heading ?>
<?php if (!$row['DelUsersID'] && can_delete_comment_array($row)): ?>
<form class="delete-comment-form" method="post" action="<?= htmlspecialchars(get_pkgbase_uri($pkgbase_name), ENT_QUOTES); ?>">
<fieldset style="display:inline;">