Exemplo n.º 1
0
 public function action_create($album_image_id = null)
 {
     if (!$album_image_id || !($album_image = Model_AlbumImage::find($album_image_id))) {
         throw new \HttpNotFoundException();
     }
     // Lazy validation
     if (\Input::post('body')) {
         \Util_security::check_csrf();
         // Create a new comment
         $comment = new Model_AlbumImageComment(array('body' => \Input::post('body'), 'album_image_id' => $album_image_id, 'member_id' => $this->u->id));
         // Save the post and the comment will save too
         if ($comment->save()) {
             \Session::set_flash('message', 'コメントしました。');
         } else {
             \Session::set_flash('error', 'コメントに失敗しました。');
         }
         \Response::redirect('album/image/' . $album_image_id);
     } else {
         Controller_Image::action_detail($album_image_id);
     }
 }
Exemplo n.º 2
0
 private function save_comment($member_id, $body = null)
 {
     if (is_null($body)) {
         $body = 'This is test comment.';
     }
     $comment = new Model_AlbumImageComment(array('body' => $body, 'album_image_id' => self::$album_image->id, 'member_id' => $member_id));
     $comment->save();
     return $comment;
 }