diff --git a/app/controllers/CommentController.php b/app/controllers/CommentController.php index 063a7b7..55335dd 100755 --- a/app/controllers/CommentController.php +++ b/app/controllers/CommentController.php @@ -5,7 +5,7 @@ class CommentController extends ApplicationController { $this->helper('Avatar', 'Post'); } - + protected function filters() { return array( @@ -52,12 +52,12 @@ class CommentController extends ApplicationController } $user_id = current_user()->id; - + $comment = new Comment(array_merge($this->params()->comment, array('ip_addr' => $this->request()->remoteIp(), 'user_id' => $user_id))); if ($this->params()->commit == "Post without bumping") { $comment->do_not_bump_post = true; } - + if ($comment->save()) { $this->respond_to_success("Comment created", '#index'); } else { @@ -75,7 +75,7 @@ class CommentController extends ApplicationController public function index() { $this->set_title('Comments'); - + if ($this->request()->format() == "json" || $this->request()->format() == "xml") { $this->comments = Comment::generate_sql($this->params()->all())->order("id DESC")->paginate($this->page_number(), 25); $this->respond_to_list("comments"); @@ -99,30 +99,30 @@ class CommentController extends ApplicationController $query = Comment::order('id desc'); $search_query = explode(' ', $this->params()->query); $search_terms = array(); - + $user_search = false; + foreach ($search_query as $s) { if (!$s) { continue; } - - if (strpos($s, 'user:') === 0 && strlen($s) > 5) { + + if (!$user_search && strpos($s, 'user:') === 0 && strlen($s) > 5) { list($search_type, $param) = explode(':', $s); - + if ($user = User::where(['name' => $param])->first()) { $query->where('user_id = ?', $user->id); - } else { - $query->where('false'); + $user_search = true; } + continue; } $search_terms[] = $s; } - + if ($search_terms) { $query->where('body LIKE ?', '%' . implode('%', $search_terms) . '%'); - } else { - # MI: this query makes no sense, it will return nothing. + } elseif (!$user_search) { $query->where('false'); } diff --git a/app/views/post/_social_meta.php b/app/views/post/_social_meta.php index 52c2d24..d81923d 100755 --- a/app/views/post/_social_meta.php +++ b/app/views/post/_social_meta.php @@ -3,8 +3,12 @@ tag('meta', array('property' => 'og:title', 'content' => $this->html_title())) ?> tag('meta', array('property' => 'og:type', 'content' => 'article')) ?> tag('meta', array('property' => 'og:url', 'content' => $this->urlFor(array('post#show', 'id' => $this->post->id, 'only_path' => false)))) ?> -tag('meta', array('property' => 'og:image', 'content' => $this->post->sample_url())) ?> tag('meta', array('property' => 'og:site_name', 'content' => CONFIG()->app_name)) ?> tag('meta', array('property' => 'og:description', 'content' => $this->post->tags())) ?> -tag('link', array('rel' => 'image_src', 'href' => $this->post->sample_url())) ?> +can_see_post(current_user(), $this->post)) { + echo $this->tag('link', array('rel' => 'image_src', 'href' => $this->post->sample_url())); + echo $this->tag('meta', array('property' => 'og:image', 'content' => $this->post->sample_url())); +} +?>