[aur-dev] [PATCH 0/6] Add comment edit functionality
Implements FS#34690. Marcel Korpel (6): Add comment edit icon and form Edit a comment in the backend Show dateline when a comment is edited or deleted Only autofocus search field on the package search page Add IDs to comments Jump to comment after editing schema/aur-schema.sql | 2 ++ web/html/commentedit.php | 21 +++++++++++++ web/html/css/aurweb.css | 19 ++++++++++-- web/html/images/pencil.min.svg | 3 ++ web/html/images/pencil.svg | 55 ++++++++++++++++++++++++++++++++++ web/html/index.php | 4 +++ web/html/pkgbase.php | 14 +++++---- web/lib/credentials.inc.php | 2 ++ web/lib/pkgbasefuncs.inc.php | 62 ++++++++++++++++++++++++++++++++++++--- web/lib/pkgfuncs.inc.php | 40 +++++++++++++++++++++++++ web/template/pkg_comment_form.php | 10 +++++-- web/template/pkg_comments.php | 32 +++++++++++++++++--- web/template/pkg_search_form.php | 2 +- 13 files changed, 246 insertions(+), 20 deletions(-) create mode 100644 web/html/commentedit.php create mode 100644 web/html/images/pencil.min.svg create mode 100644 web/html/images/pencil.svg -- 2.4.5
Shows an icon next to the comment deletion icon, which leads to a
comment edit form.
Signed-off-by: Marcel Korpel
On Fri, 10 Jul 2015 at 16:24:03, Marcel Korpel wrote:
[...] +function pkgbase_get_comment($comment_id) {
Should this function really be called pkgbase_get_comment()? It does not expect a package base ID parameter which is an indication that this should rather be called comment_by_id() or similar.
+ $dbh = DB::connect(); + $q = "SELECT Comments FROM PackageComments "; + $q.= "WHERE ID = " . $comment_id; [...]
Please explicitly cast into an integer here (even if the called already does that). Looks good otherwise, thanks!
In the backend I created two new actions, do_AddComment and
do_EditComment. When editing or deleting a comment, a timestamp is
added.
Signed-off-by: Marcel Korpel
Also, in pkg_comments.php, always use htmlspecialchars when outputting
user names.
Signed-off-by: Marcel Korpel
<?php if ($row['UserName']): ?>
<?= __('%s commented', $row['UserName']) ?>
@@ -47,6 +59,15 @@ $count = pkgbase_comments_count($base_id, $include_deleted);
<p>
<?= parse_comment($row['Comments']) ?>
</p>
+ <?php if ($row['EditedTS']): ?>
+ <p class="edited">
+ <?php if ($row['DelUsersID']) {
+ echo __('Deleted %s by %s', gmdate('Y-m-d H:i', $row['EditedTS']), $row['DelUserName']);
+ } else {
+ echo __('Last edited %s by %s', gmdate('Y-m-d H:i', $row['EditedTS']), $row['EditUserName']);
+ }?>
+ </p>
+ <?php endif; ?>
</div>
<?php endwhile; ?>
</div>
--
2.4.5
On Fri, 10 Jul 2015 at 16:24:05, Marcel Korpel wrote:
[...] - <?php if ($row['UserName'] && $SID): - $row['UserName'] = "<a href=\"" . get_user_uri($row['UserName']) . "\">{$row['UserName']}</a>"; - endif; ?> + <?php if ($row['UserName'] && $SID) { + $row['UserName'] = '<a href="' . get_user_uri($row['UserName']) . '">' . htmlspecialchars($row['UserName']) . '</a>'; + } else { + $row['UserName'] = htmlspecialchars($row['UserName']); + } + if ($row['DelUserName'] && $SID) { + $row['DelUserName'] = '<a href="' . get_user_uri($row['DelUserName']) . '">' . htmlspecialchars($row['DelUserName']) . '</a>'; + } else { + $row['DelUserName'] = htmlspecialchars($row['DelUserName']); + } + if ($row['EditUserName'] && $SID) { + $row['EditUserName'] = '<a href="' . get_user_uri($row['EditUserName']) . '">' . htmlspecialchars($row['EditUserName']) . '</a>'; + } else { + $row['EditUserName'] = htmlspecialchars($row['EditUserName']); + } ?> [...]
Can we use html_format_username() or a similar helper function here?
This needs to be disabled on package pages to be able to add a URL
fragment after comment editing.
Signed-off-by: Marcel Korpel
On Fri, 10 Jul 2015 at 16:24:06, Marcel Korpel wrote:
This needs to be disabled on package pages to be able to add a URL fragment after comment editing.
Signed-off-by: Marcel Korpel
--- web/template/pkg_search_form.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/template/pkg_search_form.php b/web/template/pkg_search_form.php index 2d03cfa..404d16e 100644 --- a/web/template/pkg_search_form.php +++ b/web/template/pkg_search_form.php @@ -57,7 +57,7 @@ $per_page = array(50, 100, 250); </div> <div> <label for="id_q"><?= __("Keywords"); ?></label> - +
Huh? Doesn't this disable the autofocus on the package search page as well?
</div> <div> <label for="id_out_of_date"><?= __('Out of Date'); ?></label> -- 2.4.5
* Lukas Fleischer
Huh? Doesn't this disable the autofocus on the package search page as well?
No: $tokens[0] will contain 'packages' and $tokens[1] will be empty, even if there are query parameters specified, e.g.: http://aur:8888/packages/?K=invented&SeB=m $tokens[1] will only be set if there is a package page opened. Best, Marcel
Signed-off-by: Marcel Korpel
+
<?php if ($row['UserName']): ?>
<?= __('%s commented', $row['UserName']) ?>
<?php else: ?>
--
2.4.5
Signed-off-by: Marcel Korpel
participants (2)
-
Lukas Fleischer
-
Marcel Korpel