1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-12-25 14:45:02 +00:00

Wipe username when deleting comments + delete entriely if no replies are detected

This commit is contained in:
Starbeamrainbowlabs 2017-11-19 12:44:58 +00:00
parent d1cc747a75
commit 55d27a84b4
4 changed files with 14 additions and 4 deletions

View file

@ -11,6 +11,7 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
- Added new "« Parent Page" to subpages so that you can easily visit their parent pages
- Users can now delete their own comments, and users logged in as a moderator or better can delete anyone's comments.
- Added new `comment-delete` action
- Comments are deleted entirely if they have no replies - otherwise the username & message are wiped
- The `history` action now supports `format=json` and `format=csv`
- Added tags next to the names of pages in the search results
- Added new `random_page_exclude` setting that allows you to exclude pages from the random action with a (PHP) regular expression

View file

@ -2853,6 +2853,7 @@ function delete_comment(&$comment_data, $target_id)
for($i = 0; $i < $comment_count; $i++) {
if($comment_data[$i]->id == $target_id) {
unset($comment_data[$i]->username);
$comment_data[$i]->message = "_[Deleted]_";
return true;
}
@ -2923,7 +2924,7 @@ function render_comments($comments_data, $depth = 0)
$comment = $comments_data[$i];
$result .= "\t<div class='comment' id='comment-$comment->id' data-comment-id='$comment->id'>\n";
$result .= "\t<p class='comment-header'><span class='name'>" . page_renderer::render_username($comment->username) . "</span> said:</p>";
$result .= "\t<p class='comment-header'><span class='name'>" . page_renderer::render_username($comment->username ?? "<em>Unknown</em>") . "</span> said:</p>";
$result .= "\t<div class='comment-body'>\n";
$result .= "\t\t" . parse_page_source($comment->message);
$result .= "\t</div>\n";

View file

@ -59,7 +59,7 @@
"author": "Starbeamrainbowlabs",
"description": "Adds threaded comments to the bottom of every page.",
"id": "feature-comments",
"lastupdate": 1511092311,
"lastupdate": 1511092595,
"optional": false
},
{

View file

@ -338,7 +338,15 @@ function delete_comment(&$comment_data, $target_id)
for($i = 0; $i < $comment_count; $i++) {
if($comment_data[$i]->id == $target_id) {
$comment_data[$i]->message = "_[Deleted]_";
if(count($comment_data[$i]->replies) == 0) {
unset($comment_data[$i]);
// Reindex the comment list before returning
$comment_data = array_values($comment_data);
}
else {
unset($comment_data[$i]->username);
$comment_data[$i]->message = "_[Deleted]_";
}
return true;
}
if(count($comment_data[$i]->replies) > 0 &&
@ -408,7 +416,7 @@ function render_comments($comments_data, $depth = 0)
$comment = $comments_data[$i];
$result .= "\t<div class='comment' id='comment-$comment->id' data-comment-id='$comment->id'>\n";
$result .= "\t<p class='comment-header'><span class='name'>" . page_renderer::render_username($comment->username) . "</span> said:</p>";
$result .= "\t<p class='comment-header'><span class='name'>" . page_renderer::render_username($comment->username ?? "<em>Unknown</em>") . "</span> said:</p>";
$result .= "\t<div class='comment-body'>\n";
$result .= "\t\t" . parse_page_source($comment->message);
$result .= "\t</div>\n";