From ea3bb816b4e88bfe734be8ee9298614670ea156d Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Tue, 24 Nov 2015 22:09:05 +0100 Subject: [PATCH] Only search active conversation when in a conversation --- CHANGELOG.md | 2 ++ .../ConversationMessageSearch.class.php | 23 ++++++++++++++++++- language/de.xml | 1 + language/en.xml | 1 + templateListener.xml | 11 ++++++++- .../__searchAreaConversationSettings.tpl | 6 ++--- 6 files changed, 39 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f4af3f..0803860 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,3 +3,5 @@ ## 2.2 ### 2.2.0 Alpha 1 (XXXX-YY-ZZ) + +* Only search active conversation when using search bar in a conversation. diff --git a/files/lib/system/search/ConversationMessageSearch.class.php b/files/lib/system/search/ConversationMessageSearch.class.php index 0d78631..f658b1d 100644 --- a/files/lib/system/search/ConversationMessageSearch.class.php +++ b/files/lib/system/search/ConversationMessageSearch.class.php @@ -16,11 +16,17 @@ use wcf\system\WCF; * @category Community Framework */ class ConversationMessageSearch extends AbstractSearchableObjectType { + /** + * id of the searched conversation + * @var integer + */ + public $conversationID = 0; + /** * message data cache * @var array<\wcf\data\conversation\message\SearchResultConversationMessage> */ - public $messageCache = array(); + public $messageCache = []; /** * @see \wcf\system\search\ISearchableObjectType::cacheObjects() @@ -34,6 +40,15 @@ class ConversationMessageSearch extends AbstractSearchableObjectType { } } + /** + * @see \wcf\system\search\ISearchableObjectType::getAdditionalData() + */ + public function getAdditionalData() { + return [ + 'conversationID' => $this->conversationID + ]; + } + /** * @see \wcf\system\search\ISearchableObjectType::getObject() */ @@ -78,6 +93,12 @@ class ConversationMessageSearch extends AbstractSearchableObjectType { $conditionBuilder = new PreparedStatementConditionBuilder(); $conditionBuilder->add('conversation_to_user.hideConversation IN (0,1)'); + if (isset($_POST['conversationID'])) { + $this->conversationID = intval($_POST['conversationID']); + + $conditionBuilder->add('conversation.conversationID = ?', [$this->conversationID]); + } + return $conditionBuilder; } diff --git a/language/de.xml b/language/de.xml index 70f6dfb..f7c1de5 100644 --- a/language/de.xml +++ b/language/de.xml @@ -111,6 +111,7 @@ + participants - $participantSummaryCount == 1}ein weiterer{else}{#$conversation->participants-$participantSummaryCount} weitere{/if}]]> attachments == 1}einen Dateianhang{else}{#$conversation->attachments} Dateianhänge{/if}.]]> diff --git a/language/en.xml b/language/en.xml index 2f12033..aad3b42 100644 --- a/language/en.xml +++ b/language/en.xml @@ -111,6 +111,7 @@ + participants - $participantSummaryCount == 1}one other{else}{#$conversation->participants-$participantSummaryCount} others{/if}]]> attachments} attachment{if $conversation->attachments != 1}s{/if}]]> diff --git a/templateListener.xml b/templateListener.xml index 4764803..b1435c0 100644 --- a/templateListener.xml +++ b/templateListener.xml @@ -24,9 +24,18 @@ user - searchArea + pageHeaderSearch settings + + + + user + searchArea + settings + + + \ No newline at end of file diff --git a/templates/__searchAreaConversationSettings.tpl b/templates/__searchAreaConversationSettings.tpl index b556629..02e7d2d 100644 --- a/templates/__searchAreaConversationSettings.tpl +++ b/templates/__searchAreaConversationSettings.tpl @@ -1,5 +1,5 @@ {if $__searchAreaInitialized|empty && $templateName|substr:0:12 == 'conversation'} - {capture assign='__searchInputPlaceholder'}{lang}wcf.conversation.searchConversations{/lang}{/capture} - {capture assign='__searchHiddenInputFields'}{/capture} + {capture assign='__searchInputPlaceholder'}{if $conversation|isset}{lang}wcf.conversation.searchConversation{/lang}{else}{lang}wcf.conversation.searchConversations{/lang}{/if}{/capture} + {capture assign='__searchHiddenInputFields'}{if $conversation|isset}{/if}{/capture} {assign var='__searchAreaInitialized' value=true} -{/if} \ No newline at end of file +{/if} -- 2.20.1