Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use current user as default publisher #464

Merged
merged 4 commits into from
Sep 10, 2019
Merged
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
1 change: 1 addition & 0 deletions lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
'updated_date' => 'Updated date',
'published' => 'Published',
'published_by' => 'Published by',
'current_user' => 'Current user',
'published_date' => 'Published date',
'published_validation' => 'Please specify the published date',
'tab_edit' => 'Edit',
Expand Down
1 change: 1 addition & 0 deletions lang/nl/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
'updated_date' => 'Bijgewerkt op',
'published' => 'Gepubliceerd',
'published_by' => 'Gepubliceerd door',
'current_user' => 'Huidige gebruiker',
'published_date' => 'Gepubliceerd op',
'published_validation' => 'Graag een publicatie datum opgeven',
'tab_edit' => 'Bewerken',
Expand Down
4 changes: 4 additions & 0 deletions models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ public function afterValidate()

public function beforeSave()
{
if (empty($this->user)) {
$user = BackendAuth::getUser();
$this->user = $user->id;
}
$this->content_html = self::formatHtml($this->content);
}

Expand Down
1 change: 1 addition & 0 deletions models/post/fields.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ secondaryTabs:
span: right
type: relation
nameFrom: login
emptyOption: rainlab.blog::lang.post.current_user

published_at:
tab: rainlab.blog::lang.post.tab_manage
Expand Down