diff --git a/Changelog.md b/Changelog.md index 2e6094a..3230b34 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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 diff --git a/modules/feature-comments.php b/modules/feature-comments.php index 85d8742..703b64f 100644 --- a/modules/feature-comments.php +++ b/modules/feature-comments.php @@ -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", "

Your comment couldn't be posted because you're not logged in. You can login here. Here's the comment you tried to post:

")); @@ -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); } } diff --git a/peppermint.guiconfig.json b/peppermint.guiconfig.json index 9344603..1c1c3f7 100644 --- a/peppermint.guiconfig.json +++ b/peppermint.guiconfig.json @@ -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": "🕗" },