From 1fe1e8997d39baa0697bee27664a3a024df3bb84 Mon Sep 17 00:00:00 2001 From: Albert221 Date: Sun, 3 Jan 2016 14:26:41 +0100 Subject: [PATCH 1/2] #256 Added multiple author search gambit --- .../src/Core/Search/Discussion/Gambit/AuthorGambit.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/framework/core/src/Core/Search/Discussion/Gambit/AuthorGambit.php b/framework/core/src/Core/Search/Discussion/Gambit/AuthorGambit.php index 640e7b752..62e399cd3 100644 --- a/framework/core/src/Core/Search/Discussion/Gambit/AuthorGambit.php +++ b/framework/core/src/Core/Search/Discussion/Gambit/AuthorGambit.php @@ -45,10 +45,14 @@ class AuthorGambit extends AbstractRegexGambit throw new LogicException('This gambit can only be applied on a DiscussionSearch'); } - $username = trim($matches[1], '"'); + $usernames = trim($matches[1], '"'); + $usernames = explode(',', $usernames); - $id = $this->users->getIdForUsername($username); + $ids = []; + foreach($usernames as $username) { + $ids[] = $this->users->getIdForUsername($username); + } - $search->getQuery()->where('start_user_id', $negate ? '!=' : '=', $id); + $search->getQuery()->whereIn('start_user_id', $ids, 'and', $negate); } } From 176f9a7c93e5dd3110463614b27cf4384a51a072 Mon Sep 17 00:00:00 2001 From: Albert221 Date: Sun, 3 Jan 2016 14:30:35 +0100 Subject: [PATCH 2/2] Fixed code style --- .../core/src/Core/Search/Discussion/Gambit/AuthorGambit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/core/src/Core/Search/Discussion/Gambit/AuthorGambit.php b/framework/core/src/Core/Search/Discussion/Gambit/AuthorGambit.php index 62e399cd3..830f033c1 100644 --- a/framework/core/src/Core/Search/Discussion/Gambit/AuthorGambit.php +++ b/framework/core/src/Core/Search/Discussion/Gambit/AuthorGambit.php @@ -49,7 +49,7 @@ class AuthorGambit extends AbstractRegexGambit $usernames = explode(',', $usernames); $ids = []; - foreach($usernames as $username) { + foreach ($usernames as $username) { $ids[] = $this->users->getIdForUsername($username); }