Commit 9cde6b05 authored by Marcel Korpel's avatar Marcel Korpel Committed by Lukas Fleischer
Browse files

Show dateline when a comment is edited or deleted


Signed-off-by: default avatarMarcel Korpel <marcel.korpel@gmail.com>
Signed-off-by: Lukas Fleischer's avatarLukas Fleischer <lfleischer@archlinux.org>
parent e331ce27
...@@ -96,6 +96,11 @@ ...@@ -96,6 +96,11 @@
color: #999; color: #999;
} }
.edited {
font-size: 0.9em;
color: #999;
}
.delete-comment-form, .edit-comment { .delete-comment-form, .edit-comment {
float: right; float: right;
margin-left: 8px; margin-left: 8px;
......
...@@ -47,9 +47,12 @@ function pkgbase_comments($base_id, $limit, $include_deleted) { ...@@ -47,9 +47,12 @@ function pkgbase_comments($base_id, $limit, $include_deleted) {
} }
$dbh = DB::connect(); $dbh = DB::connect();
$q = "SELECT PackageComments.ID, UserName, UsersID, Comments, "; $q = "SELECT PackageComments.ID, A.UserName AS UserName, UsersID, Comments, ";
$q.= "CommentTS, DelUsersID FROM PackageComments LEFT JOIN Users "; $q.= "CommentTS, EditedTS, B.UserName AS EditUserName, ";
$q.= "ON PackageComments.UsersID = Users.ID "; $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 . " "; $q.= "WHERE PackageBaseID = " . $base_id . " ";
if (!$include_deleted) { if (!$include_deleted) {
$q.= "AND DelUsersID IS NULL "; $q.= "AND DelUsersID IS NULL ";
......
...@@ -16,19 +16,33 @@ $count = pkgbase_comments_count($base_id, $include_deleted); ...@@ -16,19 +16,33 @@ $count = pkgbase_comments_count($base_id, $include_deleted);
</h3> </h3>
<?php while (list($indx, $row) = each($comments)): ?> <?php while (list($indx, $row) = each($comments)): ?>
<?php if ($row['UserName'] && $SID): <?php
$row['UserName'] = "<a href=\"" . get_user_uri($row['UserName']) . "\">{$row['UserName']}</a>"; $date_fmtd = gmdate('Y-m-d H:i', $row['CommentTS']);
endif; ?> 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; ?>> <h4<?php if ($row['DelUsersID']): ?> class="comment-deleted"<?php endif; ?>>
<?php if ($row['UserName']): ?> <?= $heading ?>
<?= __('%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; ?>
<?php if (!$row['DelUsersID'] && can_delete_comment_array($row)): ?> <?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); ?>"> <form class="delete-comment-form" method="post" action="<?= htmlspecialchars(get_pkgbase_uri($pkgbase_name), ENT_QUOTES); ?>">
<fieldset style="display:inline;"> <fieldset style="display:inline;">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment