コード例 #1
0
 /**
  * @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) {
                 continue;
             }
             $post = clone $post;
             $post->id = null;
             $post->status = Post::STATUS_DRAFT;
             $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)];
 }
コード例 #2
0
 /**
  * @Route(methods="POST")
  * @Request({"ids": "int[]"}, csrf=true)
  */
 public function copyAction($ids = [])
 {
     foreach ($ids as $id) {
         if ($post = Post::find((int) $id)) {
             if (!App::user()->hasAccess('blog: manage all posts') && !App::user()->hasAccess('blog: manage own posts') && $post->user_id !== App::user()->id) {
                 continue;
             }
             $post = clone $post;
             $post->id = null;
             $post->status = Post::STATUS_DRAFT;
             $post->title = $post->title . ' - ' . __('Copy');
             $post->comment_count = 0;
             $post->date = new \DateTime();
             $post->save();
         }
     }
     return ['message' => 'success'];
 }
コード例 #3
0
 /**
  * @Access("blog: manage comments")
  * @Request({"filter": "array", "post":"int", "page":"int"})
  */
 public function commentAction($filter = [], $post = 0, $page = null)
 {
     $post = Post::find($post);
     $filter['order'] = 'created DESC';
     return ['$view' => ['title' => $post ? __('Comments on %title%', ['%title%' => $post->title]) : __('Comments'), 'name' => 'blog/admin/comment-index.php'], '$data' => ['statuses' => Comment::getStatuses(), 'config' => ['filter' => (object) $filter, 'page' => $page, 'post' => $post, 'limit' => App::module('blog')->config('comments.comments_per_page')]]];
 }