diff --git a/README.md b/README.md index df5eebe..07f02dc 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # Blog Extension -A blog extensions with a built-in comment system. \ No newline at end of file +A blog extensions with a built-in comment system. Small extension for a required checkbox in the comment section that it has to be agreed to the terms and conditions before able to post a comment. diff --git a/app/views/comments.js b/app/views/comments.js index cab53bb..67cc3c6 100644 --- a/app/views/comments.js +++ b/app/views/comments.js @@ -36,7 +36,6 @@ module.exports = { UIkit.Utils.scrollToElement(anchor); } }); - this.reply(); }); }, @@ -55,7 +54,6 @@ module.exports = { }).$mount().$appendTo(parent.$els.reply); } - }, components: { @@ -127,7 +125,8 @@ module.exports = { email: '', content: '', error: false, - form: false + form: false, + term: false }; }, diff --git a/composer.json b/composer.json index b83d871..7c4c74a 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "pagekit/blog", "type": "pagekit-extension", - "version": "1.0.5", + "version": "1.0.6", "title": "Blog", "description": "A blog extensions with a built-in comment system.", "license": "MIT", diff --git a/index.php b/index.php index eaa185c..63aeebd 100644 --- a/index.php +++ b/index.php @@ -129,6 +129,7 @@ 'replymail' => true, 'require_email' => true + ], 'posts' => [ diff --git a/languages/de_DE/messages.php b/languages/de_DE/messages.php index 654ba39..1a0dc9a 100644 --- a/languages/de_DE/messages.php +++ b/languages/de_DE/messages.php @@ -94,4 +94,5 @@ 'View' => 'Ansicht', 'Numeric' => 'Numerisch', 'Name' => 'Name', -); \ No newline at end of file + ' I agree to the terms and conditions.' => ' Ich stimme den Nutzungsbedinungen laut Datenschutzerklärung zu.' +); diff --git a/scripts.php b/scripts.php index d1f86d9..cbba5a5 100644 --- a/scripts.php +++ b/scripts.php @@ -95,5 +95,4 @@ } ] - -]; \ No newline at end of file +]; diff --git a/src/Controller/BlogController.php b/src/Controller/BlogController.php index 1cc0848..25909bb 100644 --- a/src/Controller/BlogController.php +++ b/src/Controller/BlogController.php @@ -56,7 +56,6 @@ public function editAction($id = 0) 'user_id' => App::user()->id, 'status' => Post::STATUS_DRAFT, 'date' => new \DateTime(), - 'comment_status' => (bool) $module->config('posts.comments_enabled') ]); $post->set('title', $module->config('posts.show_title')); @@ -124,7 +123,7 @@ public function commentAction($filter = [], $post = 0, $page = null) 'filter' => (object) $filter, 'page' => $page, 'post' => $post, - 'limit' => App::module('blog')->config('comments.comments_per_page') + 'limit' => App::module('blog')->config('comments.comments_per_page'), ] ] ]; diff --git a/src/Controller/CommentApiController.php b/src/Controller/CommentApiController.php index 8ca0762..827d10b 100644 --- a/src/Controller/CommentApiController.php +++ b/src/Controller/CommentApiController.php @@ -118,17 +118,16 @@ public function saveAction($data, $id = 0) { if (!$id) { - if (!$this->user->hasAccess('blog: post comments')) { + if (!$this->user->hasAccess('blog: post comments')){ App::abort(403, __('Insufficient User Rights.')); } - $comment = Comment::create(); if ($this->user->isAuthenticated()) { $data['author'] = $this->user->name; $data['email'] = $this->user->email; $data['url'] = $this->user->url; - } elseif ($this->blog->config('comments.require_email') && (!@$data['author'] || !@$data['email'])) { + } elseif ($this->blog->config('comments.require_email') && (!@$data['author'] || !@$data['email'])){ App::abort(400, __('Please provide valid name and email.')); } @@ -173,6 +172,7 @@ public function saveAction($data, $id = 0) App::abort(404, __('Post not found.')); } + $approved_once = (boolean) Comment::where(['user_id' => $this->user->id, 'status' => Comment::STATUS_APPROVED])->first(); $comment->status = $this->user->hasAccess('blog: skip comment approval') ? Comment::STATUS_APPROVED : $this->user->hasAccess('blog: comment approval required once') && $approved_once ? Comment::STATUS_APPROVED : Comment::STATUS_PENDING; diff --git a/src/Controller/SiteController.php b/src/Controller/SiteController.php index 0744961..a0eb2cc 100644 --- a/src/Controller/SiteController.php +++ b/src/Controller/SiteController.php @@ -147,6 +147,7 @@ public function postAction($id = 0) 'post' => $post->id, 'enabled' => $post->isCommentable(), 'requireinfo' => $this->blog->config('comments.require_email'), + 'requireterm' => $this->blog->config('posts.term_enabled'), 'max_depth' => $this->blog->config('comments.max_depth'), 'user' => [ 'name' => $user->name, diff --git a/views/admin/settings.php b/views/admin/settings.php index b55a1df..af71853 100755 --- a/views/admin/settings.php +++ b/views/admin/settings.php @@ -88,7 +88,11 @@
+
+ +
+ diff --git a/views/comments.php b/views/comments.php index 2430cc5..5f0e9c1 100644 --- a/views/comments.php +++ b/views/comments.php @@ -106,14 +106,24 @@{{ 'Comment cannot be blank.' | trans }}
+
- +