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

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
janschoenherr committed Oct 27, 2015
1 parent 5fb0118 commit 9ea4965
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/views/admin/post-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ module.exports = {

this.resource.save({ id: 'copy' }, { ids: this.selected }, function (data) {
this.load();
this.$notify(data.message || data.error, data.error ? 'danger' : '');
this.$notify('Posts copied.');
});
},

Expand Down
5 changes: 2 additions & 3 deletions src/Controller/PostApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ public function deleteAction($id)
}

/**
* @Route(methods="POST")
* @Request({"ids": "int[]"}, csrf=true)
*/
public function copyAction($ids = [])
{
$count = 0;
foreach ($ids as $id) {
if ($post = Post::find((int) $id)) {
if(!App::user()->hasAccess('blog: manage all posts') && $post->user_id !== App::user()->id) {
Expand All @@ -135,11 +135,10 @@ public function copyAction($ids = [])
$post->title = $post->title.' - '.__('Copy');
$post->comment_count = 0;
$post->save();
$count++;
}
}

return ['message' => _c('{0} No post copied.|{1} Post copied.|]1,Inf[ Posts copied.', $count)];
return ['message' => 'success'];
}

/**
Expand Down

0 comments on commit 9ea4965

Please sign in to comment.