Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Gdpr branch #30

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Blog Extension

A blog extensions with a built-in comment system.
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.
5 changes: 2 additions & 3 deletions app/views/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ module.exports = {
UIkit.Utils.scrollToElement(anchor);
}
});

this.reply();
});
},
Expand All @@ -55,7 +54,6 @@ module.exports = {
}).$mount().$appendTo(parent.$els.reply);

}

},

components: {
Expand Down Expand Up @@ -127,7 +125,8 @@ module.exports = {
email: '',
content: '',
error: false,
form: false
form: false,
term: false
};
},

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
'replymail' => true,
'require_email' => true


],

'posts' => [
Expand Down
3 changes: 2 additions & 1 deletion languages/de_DE/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,5 @@
'View' => 'Ansicht',
'Numeric' => 'Numerisch',
'Name' => 'Name',
);
' I agree to the terms and conditions.' => ' Ich stimme den Nutzungsbedinungen laut Datenschutzerklärung zu.'
);
3 changes: 1 addition & 2 deletions scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,4 @@
}

]

];
];
3 changes: 1 addition & 2 deletions src/Controller/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down Expand Up @@ -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'),
]
]
];
Expand Down
6 changes: 3 additions & 3 deletions src/Controller/CommentApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.'));
}

Expand Down Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/Controller/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions views/admin/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@
<p class="uk-form-controls-condensed">
<label><input type="checkbox" v-model="config.posts.comments_enabled"> {{ 'Enable Comments' | trans }}</label>
</p>
<p class="uk-form-controls-condensed">
<label><input type="checkbox" v-model="config.posts.term_enabled"> {{ 'Enable Require Term Agreement' | trans }}</label>
</p>
</div>

</div>

</li>
Expand Down
14 changes: 12 additions & 2 deletions views/comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,24 @@
<div class="uk-form-row">
<label for="form-comment" class="uk-form-label">{{ 'Comment' | trans }}</label>
<div class="uk-form-controls">
<textarea id="form-comment" class="uk-form-width-large" name="content" rows="10" v-model="content" v-validate:required></textarea>
<textarea id="form-comment" class="uk-form-width-large" name="content" rows="10" v-model="content" v-validate:required></textarea><br>

<p class="uk-form-help-block uk-text-danger" v-show="form.content.invalid">{{ 'Comment cannot be blank.' | trans }}</p>
</div>
</div>

<div id="term">
<p>
<div class="uk-form-row" v-if="config.requireterm">
<label class="checkbox">
<input id="term" type="checkbox" name="term" v-model="term" v-validate:required>{{ ' I agree to the terms and conditions.' | trans }}
</label>
</div>
</p>
</div>

<p>
<button class="uk-button uk-button-primary" type="submit" accesskey="s">{{ 'Submit' | trans }}</button>
<button class="uk-button uk-button-primary" :disabled="term === false" type="submit" accesskey="s">{{ 'Submit' | trans }}</button>
<button class="uk-button" accesskey="c" v-if="parent" @click.prevent="cancel">{{ 'Cancel' | trans }}</button>
</p>

Expand Down