[aur-dev] [PATCH v4 3/6] Show dateline when a comment is edited or deleted
Marcel Korpel
marcel.korpel at gmail.com
Fri Jul 10 16:47:33 UTC 2015
Signed-off-by: Marcel Korpel <marcel.korpel at gmail.com>
---
Change since v3:
* Show edit info in <h4> instead of on a separate line.
web/html/css/aurweb.css | 5 +++++
web/lib/pkgbasefuncs.inc.php | 9 ++++++---
web/template/pkg_comments.php | 14 ++++++++++----
3 files changed, 21 insertions(+), 7 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..91fdc26 100644
--- a/web/template/pkg_comments.php
+++ b/web/template/pkg_comments.php
@@ -16,9 +16,11 @@ $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
+ $row['UserName'] = html_format_username($row['UserName']);
+ $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']) ?>
@@ -26,8 +28,12 @@ $count = pkgbase_comments_count($base_id, $include_deleted);
<?= __('Anonymous comment') ?>
<?php endif; ?>
<?= __('on %s', gmdate('Y-m-d H:i', $row['CommentTS'])) ?>
+ <?php if ($row['EditedTS']): ?>
<?php if ($row['DelUsersID']): ?>
- (<?= __('deleted') ?>)
+ <span class="edited">(<?= __('deleted %s by %s', gmdate('Y-m-d H:i', $row['EditedTS']), $row['DelUserName']) ?>)</span>
+ <?php else: ?>
+ <span class="edited">(<?= __('last edited %s by %s', gmdate('Y-m-d H:i', $row['EditedTS']), $row['EditUserName']) ?>)</span>
+ <?php endif; ?>
<?php endif; ?>
<?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); ?>">
--
2.4.5
More information about the aur-dev
mailing list