From dcba0b0cdbce9524d713eda5bb690ce2e10013f2 Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Sat, 2 Jun 2018 20:02:59 +0200 Subject: [PATCH 01/23] test --- index.php | 3 ++- src/Controller/CommentApiController.php | 3 ++- src/Model/Comment.php | 2 ++ views/admin/settings.php | 6 ++++++ views/comments.php | 9 +++++++++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index eaa185c..d4058f9 100644 --- a/index.php +++ b/index.php @@ -127,7 +127,8 @@ 'notifications' => 'always', 'order' => 'ASC', 'replymail' => true, - 'require_email' => true + 'require_email' => true, + 'require_gdpr' => true ], diff --git a/src/Controller/CommentApiController.php b/src/Controller/CommentApiController.php index 8ca0762..a3e58b1 100644 --- a/src/Controller/CommentApiController.php +++ b/src/Controller/CommentApiController.php @@ -128,8 +128,9 @@ public function saveAction($data, $id = 0) $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.')); + $data['gdpr'] = $this->blog->config('comments.require_gdpr') && (!@$data['gdpr']); } $comment->user_id = $this->user->isAuthenticated() ? (int) $this->user->id : 0; diff --git a/src/Model/Comment.php b/src/Model/Comment.php index 9350da3..89eff9f 100755 --- a/src/Model/Comment.php +++ b/src/Model/Comment.php @@ -30,6 +30,8 @@ class Comment extends BaseComment implements \JsonSerializable /** @BelongsTo(targetEntity="Pagekit\User\Model\User", keyFrom="user_id") */ public $user; + public $gdpr; + public function setPost($post) { $this->post = $post; diff --git a/views/admin/settings.php b/views/admin/settings.php index b55a1df..df822f1 100755 --- a/views/admin/settings.php +++ b/views/admin/settings.php @@ -88,6 +88,9 @@

+

+ +

@@ -113,6 +116,9 @@

+

+ +

{{ 'Close comments on articles older than' | trans }} {{ 'days.' | trans }} diff --git a/views/comments.php b/views/comments.php index 2430cc5..3926468 100644 --- a/views/comments.php +++ b/views/comments.php @@ -112,6 +112,15 @@ +

+ +
+ + +

{{ 'Name cannot be blank.' | trans }}

+
+
+

From c0d09bea84b28852184df7543385b434c1c003e7 Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Sat, 2 Jun 2018 20:04:46 +0200 Subject: [PATCH 02/23] test --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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", From 5335123357fc7823605db42d1d45dbf97af69f21 Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Sat, 2 Jun 2018 21:09:03 +0200 Subject: [PATCH 03/23] test --- app/views/comments.js | 5 +++++ src/Controller/SiteController.php | 1 + views/comments.php | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/views/comments.js b/app/views/comments.js index cab53bb..0c40032 100644 --- a/app/views/comments.js +++ b/app/views/comments.js @@ -9,6 +9,7 @@ module.exports = { comments: [], messages: [], count: 0, + gdpr: true, replyForm: false }, window.$comments); }, @@ -89,6 +90,10 @@ module.exports = { return depth; }, + showGdpr: function () { + return this.config.enabled && !this.isLeaf && this.$root.replyForm.$parent !== this; + }, + showReplyButton: function () { return this.config.enabled && !this.isLeaf && this.$root.replyForm.$parent !== this; }, diff --git a/src/Controller/SiteController.php b/src/Controller/SiteController.php index 0744961..852b66f 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'), + 'requiregdpr' => $this->blog->config('comments.require_gdpr'), 'max_depth' => $this->blog->config('comments.max_depth'), 'user' => [ 'name' => $user->name, diff --git a/views/comments.php b/views/comments.php index 3926468..030a026 100644 --- a/views/comments.php +++ b/views/comments.php @@ -16,6 +16,8 @@

{{ message }}
+
+

{{ 'Comments are closed.' | trans }}

@@ -49,6 +51,8 @@

{{{ comment.content }}}

+

+

{{ 'Reply' | trans }}

@@ -115,7 +119,7 @@
- +

{{ 'Name cannot be blank.' | trans }}

From 0a07eb384da9d6c3834e4c0d334c1a9811c6022e Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Sat, 2 Jun 2018 21:39:22 +0200 Subject: [PATCH 04/23] Some Changes to test out --- src/Model/Comment.php | 2 -- views/comments.php | 9 +++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Model/Comment.php b/src/Model/Comment.php index 89eff9f..9350da3 100755 --- a/src/Model/Comment.php +++ b/src/Model/Comment.php @@ -30,8 +30,6 @@ class Comment extends BaseComment implements \JsonSerializable /** @BelongsTo(targetEntity="Pagekit\User\Model\User", keyFrom="user_id") */ public $user; - public $gdpr; - public function setPost($post) { $this->post = $post; diff --git a/views/comments.php b/views/comments.php index 030a026..eb1663a 100644 --- a/views/comments.php +++ b/views/comments.php @@ -18,6 +18,11 @@
+ +

{{ 'Comments are closed.' | trans }}

@@ -51,7 +56,7 @@

{{{ comment.content }}}

-

+

{{ 'Reply' | trans }}

@@ -119,7 +124,7 @@
- +

{{ 'Name cannot be blank.' | trans }}

From e1d07e0d279ddab7477372913edf9d248ad4f0c6 Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Sat, 2 Jun 2018 21:52:47 +0200 Subject: [PATCH 05/23] slight change --- src/Controller/CommentApiController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controller/CommentApiController.php b/src/Controller/CommentApiController.php index a3e58b1..a832717 100644 --- a/src/Controller/CommentApiController.php +++ b/src/Controller/CommentApiController.php @@ -130,7 +130,7 @@ public function saveAction($data, $id = 0) $data['url'] = $this->user->url; } elseif ($this->blog->config('comments.require_email') && (!@$data['author'] || !@$data['email'])){ App::abort(400, __('Please provide valid name and email.')); - $data['gdpr'] = $this->blog->config('comments.require_gdpr') && (!@$data['gdpr']); + $data['gdpr'] = $this->blog->config('comments.require_gdpr'); } $comment->user_id = $this->user->isAuthenticated() ? (int) $this->user->id : 0; From b0ebbcbd5076e01b1f509f7d1ebdbb86091fcdc8 Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Sat, 2 Jun 2018 22:04:06 +0200 Subject: [PATCH 06/23] lil change again --- app/views/comments.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/views/comments.js b/app/views/comments.js index 0c40032..926b9b7 100644 --- a/app/views/comments.js +++ b/app/views/comments.js @@ -9,7 +9,7 @@ module.exports = { comments: [], messages: [], count: 0, - gdpr: true, + showGdpr: false, replyForm: false }, window.$comments); }, @@ -55,6 +55,21 @@ module.exports = { parent: parent }).$mount().$appendTo(parent.$els.reply); + }, + + gdpr: function (parent) { + + parent = parent || this; + + if (this.showGdpr) { + this.showGdpr.$destroy(true); + } + + this.showGdpr = new this.$options.components['gdpr']({ + data: {config: this.config, parent: parent.comment && parent.comment.id || 0}, + parent: parent + }).$mount().$appendTo(parent.$els.gdpr); + } }, @@ -91,7 +106,7 @@ module.exports = { }, showGdpr: function () { - return this.config.enabled && !this.isLeaf && this.$root.replyForm.$parent !== this; + return this.config.enabled && !this.isLeaf && this.$root.showGdpr.$parent !== this; }, showReplyButton: function () { From e7b66b12d568fd5cb588f58ee5f56f3b8b94b840 Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Sun, 3 Jun 2018 00:01:54 +0200 Subject: [PATCH 07/23] more testing stuff --- app/components/post-settings.vue | 3 +++ app/views/comments.js | 1 - scripts.php | 2 +- src/Model/Comment.php | 3 +++ src/Model/Post.php | 3 --- views/comments.php | 10 ++++++---- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/components/post-settings.vue b/app/components/post-settings.vue index c00e07d..69c45fc 100644 --- a/app/components/post-settings.vue +++ b/app/components/post-settings.vue @@ -74,6 +74,9 @@
+
+ +
diff --git a/app/views/comments.js b/app/views/comments.js index 926b9b7..f43f681 100644 --- a/app/views/comments.js +++ b/app/views/comments.js @@ -37,7 +37,6 @@ module.exports = { UIkit.Utils.scrollToElement(anchor); } }); - this.reply(); }); }, diff --git a/scripts.php b/scripts.php index d1f86d9..13d42da 100644 --- a/scripts.php +++ b/scripts.php @@ -96,4 +96,4 @@ ] -]; \ No newline at end of file +]; diff --git a/src/Model/Comment.php b/src/Model/Comment.php index 9350da3..1346547 100755 --- a/src/Model/Comment.php +++ b/src/Model/Comment.php @@ -30,6 +30,9 @@ class Comment extends BaseComment implements \JsonSerializable /** @BelongsTo(targetEntity="Pagekit\User\Model\User", keyFrom="user_id") */ public $user; + /** @Column(type="boolean") */ + public $gdpr_status; + public function setPost($post) { $this->post = $post; diff --git a/src/Model/Post.php b/src/Model/Post.php index a94f9c4..beef14e 100755 --- a/src/Model/Post.php +++ b/src/Model/Post.php @@ -53,9 +53,6 @@ class Post implements \JsonSerializable /** @Column(type="datetime") */ public $modified; - /** @Column(type="boolean") */ - public $comment_status; - /** @Column(type="integer") */ public $comment_count = 0; diff --git a/views/comments.php b/views/comments.php index eb1663a..6a695bc 100644 --- a/views/comments.php +++ b/views/comments.php @@ -23,6 +23,8 @@ I agree to the terms and conditions. +
+

{{ 'Comments are closed.' | trans }}

@@ -121,12 +123,12 @@ -
+
{{ 'You accept the agreement' | trans }}
- - -

{{ 'Name cannot be blank.' | trans }}

+

+

+

{{ 'You don't agreed to the terms.' | trans }}

From f5b5104b405822fa1fcf355b0eaf6ed108a00daa Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Mon, 4 Jun 2018 23:05:24 +0200 Subject: [PATCH 08/23] Test Version Big Thanks to yns.wtf --- views/admin/settings.php | 4 ++-- views/comments.php | 25 ++++++------------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/views/admin/settings.php b/views/admin/settings.php index df822f1..58481a1 100755 --- a/views/admin/settings.php +++ b/views/admin/settings.php @@ -89,7 +89,7 @@

- +

@@ -117,7 +117,7 @@

- +

{{ 'Close comments on articles older than' | trans }} diff --git a/views/comments.php b/views/comments.php index 6a695bc..6c28813 100644 --- a/views/comments.php +++ b/views/comments.php @@ -16,15 +16,6 @@

{{ message }}
-
- - - -
-

{{ 'Comments are closed.' | trans }}

@@ -58,8 +49,6 @@

{{{ comment.content }}}

-

-

{{ 'Reply' | trans }}

@@ -123,17 +112,15 @@ -
{{ 'You accept the agreement' | trans }} -
-

-

-

{{ 'You don't agreed to the terms.' | trans }}

-
+
+

- +

From 4a9e21692de17b46daccbe9cd54dcf9c273afa8f Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Mon, 4 Jun 2018 23:05:48 +0200 Subject: [PATCH 09/23] Test Version Big Thanks to yns.wtf --- index.php | 2 +- views/admin/settings.php | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/index.php b/index.php index d4058f9..4779951 100644 --- a/index.php +++ b/index.php @@ -128,7 +128,7 @@ 'order' => 'ASC', 'replymail' => true, 'require_email' => true, - 'require_gdpr' => true + 'require_term' => true ], diff --git a/views/admin/settings.php b/views/admin/settings.php index 58481a1..d40f022 100755 --- a/views/admin/settings.php +++ b/views/admin/settings.php @@ -88,9 +88,6 @@

-

- -

From 452848efc22647722d808d12341a8eb028e99275 Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Mon, 4 Jun 2018 23:13:00 +0200 Subject: [PATCH 10/23] Changes --- src/Model/Comment.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Model/Comment.php b/src/Model/Comment.php index 1346547..9350da3 100755 --- a/src/Model/Comment.php +++ b/src/Model/Comment.php @@ -30,9 +30,6 @@ class Comment extends BaseComment implements \JsonSerializable /** @BelongsTo(targetEntity="Pagekit\User\Model\User", keyFrom="user_id") */ public $user; - /** @Column(type="boolean") */ - public $gdpr_status; - public function setPost($post) { $this->post = $post; From f8ff33160d400c77d30bb4e099aea5e714c94045 Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Mon, 4 Jun 2018 23:18:15 +0200 Subject: [PATCH 11/23] test --- app/views/comments.js | 21 --------------------- src/Controller/CommentApiController.php | 2 +- src/Controller/SiteController.php | 2 +- 3 files changed, 2 insertions(+), 23 deletions(-) diff --git a/app/views/comments.js b/app/views/comments.js index f43f681..de90823 100644 --- a/app/views/comments.js +++ b/app/views/comments.js @@ -9,7 +9,6 @@ module.exports = { comments: [], messages: [], count: 0, - showGdpr: false, replyForm: false }, window.$comments); }, @@ -54,23 +53,7 @@ module.exports = { parent: parent }).$mount().$appendTo(parent.$els.reply); - }, - - gdpr: function (parent) { - - parent = parent || this; - - if (this.showGdpr) { - this.showGdpr.$destroy(true); - } - - this.showGdpr = new this.$options.components['gdpr']({ - data: {config: this.config, parent: parent.comment && parent.comment.id || 0}, - parent: parent - }).$mount().$appendTo(parent.$els.gdpr); - } - }, components: { @@ -104,10 +87,6 @@ module.exports = { return depth; }, - showGdpr: function () { - return this.config.enabled && !this.isLeaf && this.$root.showGdpr.$parent !== this; - }, - showReplyButton: function () { return this.config.enabled && !this.isLeaf && this.$root.replyForm.$parent !== this; }, diff --git a/src/Controller/CommentApiController.php b/src/Controller/CommentApiController.php index a832717..81f86a7 100644 --- a/src/Controller/CommentApiController.php +++ b/src/Controller/CommentApiController.php @@ -130,7 +130,7 @@ public function saveAction($data, $id = 0) $data['url'] = $this->user->url; } elseif ($this->blog->config('comments.require_email') && (!@$data['author'] || !@$data['email'])){ App::abort(400, __('Please provide valid name and email.')); - $data['gdpr'] = $this->blog->config('comments.require_gdpr'); + $data['term'] = $this->blog->config('comments.require_term'); } $comment->user_id = $this->user->isAuthenticated() ? (int) $this->user->id : 0; diff --git a/src/Controller/SiteController.php b/src/Controller/SiteController.php index 852b66f..e482340 100644 --- a/src/Controller/SiteController.php +++ b/src/Controller/SiteController.php @@ -147,7 +147,7 @@ public function postAction($id = 0) 'post' => $post->id, 'enabled' => $post->isCommentable(), 'requireinfo' => $this->blog->config('comments.require_email'), - 'requiregdpr' => $this->blog->config('comments.require_gdpr'), + 'term' => $this->blog->config('comments.require_term'), 'max_depth' => $this->blog->config('comments.max_depth'), 'user' => [ 'name' => $user->name, From e8ca9d04bd33fa094a5b2920a8a1acbd4b5e98bd Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Mon, 4 Jun 2018 23:24:50 +0200 Subject: [PATCH 12/23] test --- src/Model/Post.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Model/Post.php b/src/Model/Post.php index beef14e..a94f9c4 100755 --- a/src/Model/Post.php +++ b/src/Model/Post.php @@ -53,6 +53,9 @@ class Post implements \JsonSerializable /** @Column(type="datetime") */ public $modified; + /** @Column(type="boolean") */ + public $comment_status; + /** @Column(type="integer") */ public $comment_count = 0; From e51e7d6b7db9ff1da86cbd5a5c35ed44a10ea36f Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Mon, 4 Jun 2018 23:28:03 +0200 Subject: [PATCH 13/23] test --- app/views/comments.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/comments.js b/app/views/comments.js index de90823..501f6cf 100644 --- a/app/views/comments.js +++ b/app/views/comments.js @@ -125,7 +125,8 @@ module.exports = { email: '', content: '', error: false, - form: false + form: false, + term: true }; }, From f4e07163f65cdff29e964e344d05aaf9885aafc4 Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Tue, 5 Jun 2018 00:37:11 +0200 Subject: [PATCH 14/23] Testint Package --- app/views/comments.js | 2 +- index.php | 3 ++- views/comments.php | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/views/comments.js b/app/views/comments.js index 501f6cf..67cc3c6 100644 --- a/app/views/comments.js +++ b/app/views/comments.js @@ -126,7 +126,7 @@ module.exports = { content: '', error: false, form: false, - term: true + term: false }; }, diff --git a/index.php b/index.php index 4779951..596f97a 100644 --- a/index.php +++ b/index.php @@ -128,7 +128,8 @@ 'order' => 'ASC', 'replymail' => true, 'require_email' => true, - 'require_term' => true + 'require_term' => false + ], diff --git a/views/comments.php b/views/comments.php index 6c28813..83df444 100644 --- a/views/comments.php +++ b/views/comments.php @@ -112,12 +112,14 @@ -
+
+
+

From ba9525ad3af7e244a3f8a794649a0dc6cc5ebd3c Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Tue, 5 Jun 2018 23:36:53 +0200 Subject: [PATCH 15/23] testing zone --- app/views/comments.js | 3 +-- index.php | 3 ++- scripts.php | 1 + src/Controller/BlogController.php | 7 +++++-- src/Controller/CommentApiController.php | 6 +++--- src/Controller/SiteController.php | 2 +- src/Model/Post.php | 9 +++++++++ views/admin/settings.php | 4 ++++ views/comments.php | 2 +- 9 files changed, 27 insertions(+), 10 deletions(-) diff --git a/app/views/comments.js b/app/views/comments.js index 67cc3c6..de90823 100644 --- a/app/views/comments.js +++ b/app/views/comments.js @@ -125,8 +125,7 @@ module.exports = { email: '', content: '', error: false, - form: false, - term: false + form: false }; }, diff --git a/index.php b/index.php index 596f97a..0a75ec1 100644 --- a/index.php +++ b/index.php @@ -137,7 +137,8 @@ 'posts_per_page' => 20, 'comments_enabled' => true, - 'markdown_enabled' => true + 'markdown_enabled' => true, + 'term_enabled' => true ], diff --git a/scripts.php b/scripts.php index 13d42da..434ea03 100644 --- a/scripts.php +++ b/scripts.php @@ -19,6 +19,7 @@ $table->addColumn('excerpt', 'text'); $table->addColumn('comment_status', 'boolean', ['default' => false]); $table->addColumn('comment_count', 'integer', ['default' => 0]); + $table->addColumn('term_status', 'boolean', ['default' => false]); $table->addColumn('data', 'json_array', ['notnull' => false]); $table->addColumn('roles', 'simple_array', ['notnull' => false]); $table->setPrimaryKey(['id']); diff --git a/src/Controller/BlogController.php b/src/Controller/BlogController.php index 1cc0848..579348b 100644 --- a/src/Controller/BlogController.php +++ b/src/Controller/BlogController.php @@ -56,11 +56,13 @@ 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') + 'comment_status' => (bool) $module->config('posts.comments_enabled'), + 'term_status' => (bool) $module->config('posts.term_enabled') ]); $post->set('title', $module->config('posts.show_title')); $post->set('markdown', $module->config('posts.markdown_enabled')); + $post->set('term', $module->config('posts.term_enabled')); } $user = App::user(); @@ -124,7 +126,8 @@ 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'), + 'termrequired' => App::module('blog')->config('config.comments.require_term') ] ] ]; diff --git a/src/Controller/CommentApiController.php b/src/Controller/CommentApiController.php index 81f86a7..2f6e850 100644 --- a/src/Controller/CommentApiController.php +++ b/src/Controller/CommentApiController.php @@ -118,10 +118,10 @@ 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.')); } - + $data['term'] = ($this->blog->config('comments.require_term')); $comment = Comment::create(); if ($this->user->isAuthenticated()) { @@ -130,7 +130,6 @@ public function saveAction($data, $id = 0) $data['url'] = $this->user->url; } elseif ($this->blog->config('comments.require_email') && (!@$data['author'] || !@$data['email'])){ App::abort(400, __('Please provide valid name and email.')); - $data['term'] = $this->blog->config('comments.require_term'); } $comment->user_id = $this->user->isAuthenticated() ? (int) $this->user->id : 0; @@ -174,6 +173,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 e482340..8c8d84f 100644 --- a/src/Controller/SiteController.php +++ b/src/Controller/SiteController.php @@ -147,7 +147,7 @@ public function postAction($id = 0) 'post' => $post->id, 'enabled' => $post->isCommentable(), 'requireinfo' => $this->blog->config('comments.require_email'), - 'term' => $this->blog->config('comments.require_term'), + 'requireterm' => $this->blog->config('comments.require_term'), 'max_depth' => $this->blog->config('comments.max_depth'), 'user' => [ 'name' => $user->name, diff --git a/src/Model/Post.php b/src/Model/Post.php index a94f9c4..929fb7f 100755 --- a/src/Model/Post.php +++ b/src/Model/Post.php @@ -56,6 +56,9 @@ class Post implements \JsonSerializable /** @Column(type="boolean") */ public $comment_status; + /** @Column(type="boolean") */ + public $term_status; + /** @Column(type="integer") */ public $comment_count = 0; @@ -102,6 +105,12 @@ public function isCommentable() return $this->comment_status && (!$autoclose or $this->date >= new \DateTime("-{$autoclose} day")); } + public function isEnabled() + { + $termenabled = $blog->config('config.posts.term_enabled'); + return $this->post_status && (!$termenabled); + } + public function getAuthor() { return $this->user ? $this->user->username : null; diff --git a/views/admin/settings.php b/views/admin/settings.php index d40f022..6582872 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 83df444..2680e18 100644 --- a/views/comments.php +++ b/views/comments.php @@ -113,7 +113,7 @@
-
+
{{ 'I agree to the terms and conditions.' | trans }} From d6b386ff227d32f1d842699448f5be71ba8937c3 Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Wed, 6 Jun 2018 00:39:34 +0200 Subject: [PATCH 16/23] Test Release --- app/components/post-settings.vue | 3 --- src/Controller/BlogController.php | 4 ---- src/Controller/CommentApiController.php | 1 - src/Controller/SiteController.php | 2 +- src/Model/Post.php | 2 +- views/admin/settings.php | 5 +---- views/comments.php | 7 +++---- 7 files changed, 6 insertions(+), 18 deletions(-) diff --git a/app/components/post-settings.vue b/app/components/post-settings.vue index 69c45fc..c00e07d 100644 --- a/app/components/post-settings.vue +++ b/app/components/post-settings.vue @@ -74,9 +74,6 @@
-
- -
diff --git a/src/Controller/BlogController.php b/src/Controller/BlogController.php index 579348b..25909bb 100644 --- a/src/Controller/BlogController.php +++ b/src/Controller/BlogController.php @@ -56,13 +56,10 @@ 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'), - 'term_status' => (bool) $module->config('posts.term_enabled') ]); $post->set('title', $module->config('posts.show_title')); $post->set('markdown', $module->config('posts.markdown_enabled')); - $post->set('term', $module->config('posts.term_enabled')); } $user = App::user(); @@ -127,7 +124,6 @@ public function commentAction($filter = [], $post = 0, $page = null) 'page' => $page, 'post' => $post, 'limit' => App::module('blog')->config('comments.comments_per_page'), - 'termrequired' => App::module('blog')->config('config.comments.require_term') ] ] ]; diff --git a/src/Controller/CommentApiController.php b/src/Controller/CommentApiController.php index 2f6e850..827d10b 100644 --- a/src/Controller/CommentApiController.php +++ b/src/Controller/CommentApiController.php @@ -121,7 +121,6 @@ public function saveAction($data, $id = 0) if (!$this->user->hasAccess('blog: post comments')){ App::abort(403, __('Insufficient User Rights.')); } - $data['term'] = ($this->blog->config('comments.require_term')); $comment = Comment::create(); if ($this->user->isAuthenticated()) { diff --git a/src/Controller/SiteController.php b/src/Controller/SiteController.php index 8c8d84f..a0eb2cc 100644 --- a/src/Controller/SiteController.php +++ b/src/Controller/SiteController.php @@ -147,7 +147,7 @@ public function postAction($id = 0) 'post' => $post->id, 'enabled' => $post->isCommentable(), 'requireinfo' => $this->blog->config('comments.require_email'), - 'requireterm' => $this->blog->config('comments.require_term'), + 'requireterm' => $this->blog->config('posts.term_enabled'), 'max_depth' => $this->blog->config('comments.max_depth'), 'user' => [ 'name' => $user->name, diff --git a/src/Model/Post.php b/src/Model/Post.php index 929fb7f..a17ec3a 100755 --- a/src/Model/Post.php +++ b/src/Model/Post.php @@ -108,7 +108,7 @@ public function isCommentable() public function isEnabled() { $termenabled = $blog->config('config.posts.term_enabled'); - return $this->post_status && (!$termenabled); + return $termenabled; } public function getAuthor() diff --git a/views/admin/settings.php b/views/admin/settings.php index 6582872..af71853 100755 --- a/views/admin/settings.php +++ b/views/admin/settings.php @@ -89,7 +89,7 @@

- +

@@ -117,9 +117,6 @@

-

- -

{{ 'Close comments on articles older than' | trans }} {{ 'days.' | trans }} diff --git a/views/comments.php b/views/comments.php index 2680e18..8b3226e 100644 --- a/views/comments.php +++ b/views/comments.php @@ -106,17 +106,16 @@

- +

{{ 'Comment cannot be blank.' | trans }}

-
From e6aa8621e93f1202f5f3514b195000c679793d34 Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Wed, 6 Jun 2018 00:52:18 +0200 Subject: [PATCH 17/23] Test Release --- app/views/comments.js | 3 ++- index.php | 4 +--- scripts.php | 1 - src/Model/Post.php | 9 --------- 4 files changed, 3 insertions(+), 14 deletions(-) diff --git a/app/views/comments.js b/app/views/comments.js index de90823..67cc3c6 100644 --- a/app/views/comments.js +++ b/app/views/comments.js @@ -125,7 +125,8 @@ module.exports = { email: '', content: '', error: false, - form: false + form: false, + term: false }; }, diff --git a/index.php b/index.php index 0a75ec1..5bb7571 100644 --- a/index.php +++ b/index.php @@ -127,8 +127,7 @@ 'notifications' => 'always', 'order' => 'ASC', 'replymail' => true, - 'require_email' => true, - 'require_term' => false + 'require_email' => true ], @@ -138,7 +137,6 @@ 'posts_per_page' => 20, 'comments_enabled' => true, 'markdown_enabled' => true, - 'term_enabled' => true ], diff --git a/scripts.php b/scripts.php index 434ea03..13d42da 100644 --- a/scripts.php +++ b/scripts.php @@ -19,7 +19,6 @@ $table->addColumn('excerpt', 'text'); $table->addColumn('comment_status', 'boolean', ['default' => false]); $table->addColumn('comment_count', 'integer', ['default' => 0]); - $table->addColumn('term_status', 'boolean', ['default' => false]); $table->addColumn('data', 'json_array', ['notnull' => false]); $table->addColumn('roles', 'simple_array', ['notnull' => false]); $table->setPrimaryKey(['id']); diff --git a/src/Model/Post.php b/src/Model/Post.php index a17ec3a..a94f9c4 100755 --- a/src/Model/Post.php +++ b/src/Model/Post.php @@ -56,9 +56,6 @@ class Post implements \JsonSerializable /** @Column(type="boolean") */ public $comment_status; - /** @Column(type="boolean") */ - public $term_status; - /** @Column(type="integer") */ public $comment_count = 0; @@ -105,12 +102,6 @@ public function isCommentable() return $this->comment_status && (!$autoclose or $this->date >= new \DateTime("-{$autoclose} day")); } - public function isEnabled() - { - $termenabled = $blog->config('config.posts.term_enabled'); - return $termenabled; - } - public function getAuthor() { return $this->user ? $this->user->username : null; From bf5bedf987523ebf89a2395580c0992c12844e1e Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Wed, 6 Jun 2018 00:56:43 +0200 Subject: [PATCH 18/23] Test Release --- app/views/comments.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/comments.js b/app/views/comments.js index 67cc3c6..de90823 100644 --- a/app/views/comments.js +++ b/app/views/comments.js @@ -125,8 +125,7 @@ module.exports = { email: '', content: '', error: false, - form: false, - term: false + form: false }; }, From 3bb1c85d3bb7afa31a53b35bc321b83d25059de4 Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Wed, 6 Jun 2018 01:00:47 +0200 Subject: [PATCH 19/23] Test Release --- app/views/comments.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/comments.js b/app/views/comments.js index de90823..67cc3c6 100644 --- a/app/views/comments.js +++ b/app/views/comments.js @@ -125,7 +125,8 @@ module.exports = { email: '', content: '', error: false, - form: false + form: false, + term: false }; }, From 44aacbffefc3504f69ae609254fff6e38ec102f1 Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Wed, 6 Jun 2018 01:10:22 +0200 Subject: [PATCH 20/23] Test Release --- views/comments.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/views/comments.php b/views/comments.php index 8b3226e..5f0e9c1 100644 --- a/views/comments.php +++ b/views/comments.php @@ -112,14 +112,16 @@ -
-
- +
+

+

+ +
+

-
- +

From 784a6797019a7ff30d20315aa6093f2d63c94089 Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Wed, 6 Jun 2018 01:21:33 +0200 Subject: [PATCH 21/23] Test Release --- index.php | 2 +- scripts.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/index.php b/index.php index 5bb7571..63aeebd 100644 --- a/index.php +++ b/index.php @@ -136,7 +136,7 @@ 'posts_per_page' => 20, 'comments_enabled' => true, - 'markdown_enabled' => true, + 'markdown_enabled' => true ], diff --git a/scripts.php b/scripts.php index 13d42da..cbba5a5 100644 --- a/scripts.php +++ b/scripts.php @@ -95,5 +95,4 @@ } ] - ]; From 9133abf1847f41ebb86a91863ff14ad2317a3bd1 Mon Sep 17 00:00:00 2001 From: Fosphatic Date: Wed, 6 Jun 2018 01:23:56 +0200 Subject: [PATCH 22/23] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From 732000fbb6794a56ae1da2a4ca08ca6eb7027c4d Mon Sep 17 00:00:00 2001 From: Fosphatic-Duke Date: Wed, 6 Jun 2018 22:06:50 +0200 Subject: [PATCH 23/23] Additional German translation --- languages/de_DE/messages.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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.' +);