Add new anoncomments setting

This commit is contained in:
Starbeamrainbowlabs 2020-04-18 13:23:18 +01:00
parent ad8d05a3eb
commit 0e0ccd9e00
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
3 changed files with 4 additions and 1 deletions

View File

@ -20,6 +20,7 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
- Get in touch if you experience performance issues with fetching tag lists from your wiki
- A command-line interface!
- Wiki administrators with terminal/console access can now make use of a brand-new CLI by executing `php ./index.php` (warning: strange things will happen if the current working directory is not the directory that contains index.php and peppermint.json)
- Added new `anoncomments` setting to control whether anonymous users are allowed to make comments (disabled by default) - thanks to @SeanFromIT for suggesting it in #181
### Fixed
- Fixed weighted word support on search query analysis debug page

View File

@ -35,7 +35,7 @@ register_module([
$reply_to = $_POST["replyto"] ?? null;
$message = $_POST["message"] ?? "";
if(!$env->is_logged_in) {
if(!$env->is_logged_in && !$settings->anoncomments) {
http_response_code(401);
exit(page_renderer::render_main("Error posting comment - $settings->sitename", "<p>Your comment couldn't be posted because you're not logged in. You can login <a href='?action=index'>here</a>. Here's the comment you tried to post:</p>
<textarea readonly>".htmlentities($message)."</textarea>"));
@ -102,6 +102,7 @@ register_module([
"$thread_comment->message\n" .
"\n";
// If the user is anonymous, this will fail and return false (it accounts for non-existent users automatically)
email_user($thread_comment->username, $email_subject, $email_body);
}
}

View File

@ -192,6 +192,7 @@
"index.php?action=help"
]
]},
"anoncomments": { "type": "checkbox", "description": "Whether to allow anonymous user to make comments. Note that anonymous users are not able to delete their own comments (since they are not logged in, there's no way to know if they were the original poster or not)", "default": false },
"comment_max_length": { "type": "number", "description": "The maximum allowed length, in characters, for comments", "default": 5000 },
"comment_min_length": { "type": "number", "description": "The minimum allowed length, in characters, for comments", "default": 10 },
"comment_time_icon": { "type": "text", "description": "The icon to show next to the time that a comment was posted.", "default": "&#x1f557;" },