Fixed issue #49.
This commit is contained in:
parent
5776745bb8
commit
685a3230f8
@ -97,14 +97,17 @@ class CommentController extends ApplicationController
|
||||
public function search()
|
||||
{
|
||||
$query = Comment::order('id desc');
|
||||
// $conds = $cond_params = $search_terms = array();
|
||||
if ($this->params()->query) {
|
||||
$keywords = array();
|
||||
foreach (explode(' ', $this->params()->query) as $s) {
|
||||
if (!$s) continue;
|
||||
$search_query = explode(' ', $this->params()->query);
|
||||
$search_terms = array();
|
||||
|
||||
foreach ($search_query as $s) {
|
||||
if (!$s) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (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 {
|
||||
@ -115,10 +118,13 @@ class CommentController extends ApplicationController
|
||||
|
||||
$search_terms[] = $s;
|
||||
}
|
||||
|
||||
if ($search_terms) {
|
||||
$query->where('body LIKE ?', '%' . implode('%', $search_terms) . '%');
|
||||
// $options['conditions'] = array_merge(array(implode(' AND ', $conds)), $cond_params);
|
||||
} else
|
||||
} else {
|
||||
# MI: this query makes no sense, it will return nothing.
|
||||
$query->where('false');
|
||||
}
|
||||
|
||||
$this->comments = $query->paginate($this->page_number(), 30);
|
||||
|
||||
|
Reference in New Issue
Block a user