Only search active conversation when in a conversation
authorMatthias Schmidt <gravatronics@live.com>
Tue, 24 Nov 2015 21:09:05 +0000 (22:09 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Tue, 24 Nov 2015 21:09:05 +0000 (22:09 +0100)
CHANGELOG.md
files/lib/system/search/ConversationMessageSearch.class.php
language/de.xml
language/en.xml
templateListener.xml
templates/__searchAreaConversationSettings.tpl

index 4f4af3fcd62a4700a33ac61a264a7c3e4cc85f45..0803860ff7336794820ab0061892039cbfbaef05 100644 (file)
@@ -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.
index 0d78631dfc1cdabd7966ec9a16d1f6ae9d4edcc4..f658b1ddadbdf75e4b5e4ec2c29b85375b67ff92 100644 (file)
@@ -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;
        }
        
index 70f6dfba3b8d48d78da86efc6ff43416ad9814be..f7c1de5ed15e57360809672b36c2700aeea122b4 100644 (file)
                <item name="wcf.conversation.ownPosts"><![CDATA[Diese Konversation enthält Nachrichten von Ihnen.]]></item>
                <item name="wcf.conversation.gotoLastPost"><![CDATA[Zur letzten Nachricht springen]]></item>
                <item name="wcf.conversation.searchConversations"><![CDATA[Konversationen durchsuchen]]></item>
+               <item name="wcf.conversation.searchConversation"><![CDATA[Aktuelle Konversation durchsuchen]]></item>
                <item name="wcf.conversation.participants.other"><![CDATA[und {if $conversation->participants - $participantSummaryCount == 1}ein weiterer{else}{#$conversation->participants-$participantSummaryCount} weitere{/if}]]></item>
                <item name="wcf.conversation.attachments"><![CDATA[Diese Konversation enthält {if $conversation->attachments == 1}einen Dateianhang{else}{#$conversation->attachments} Dateianhänge{/if}.]]></item>
                <item name="wcf.conversation.error.mailboxIsFull"><![CDATA[Sie haben das zulässige Limit für Konversationen bereits erreicht und können keine neuen Konversationen starten.]]></item>
index 2f12033aff4cf2464eab9c3ec611aea895c45ce2..aad3b42d4c9c5c552452091dd75d3f321341497e 100644 (file)
                <item name="wcf.conversation.ownPosts"><![CDATA[Conversation contains own messages]]></item>
                <item name="wcf.conversation.gotoLastPost"><![CDATA[Jump to Last Message]]></item>
                <item name="wcf.conversation.searchConversations"><![CDATA[Search Conversations]]></item>
+               <item name="wcf.conversation.searchConversation"><![CDATA[Search This Conversation Only]]></item>
                <item name="wcf.conversation.participants.other"><![CDATA[and {if $conversation->participants - $participantSummaryCount == 1}one other{else}{#$conversation->participants-$participantSummaryCount} others{/if}]]></item>
                <item name="wcf.conversation.attachments"><![CDATA[Conversation contains {#$conversation->attachments} attachment{if $conversation->attachments != 1}s{/if}]]></item>
                <item name="wcf.conversation.error.mailboxIsFull"><![CDATA[You have reached your maximum limit of conversations and are unable to start new ones.]]></item>
index 4764803f9f03d753bd1723a866e9b6e3e8406c3d..b1435c09ba4d4f531d0b589d2be3102a14205ed2 100644 (file)
                
                <templatelistener name="searchAreaConversationSettings">
                        <environment>user</environment>
-                       <templatename>searchArea</templatename>
+                       <templatename>pageHeaderSearch</templatename>
                        <eventname>settings</eventname>
                        <templatecode><![CDATA[{include file='__searchAreaConversationSettings'}]]></templatecode>
                </templatelistener>
        </import>
+       
+       <delete>
+               <templatelistener name="searchAreaConversationSettings">
+                       <environment>user</environment>
+                       <templatename>searchArea</templatename>
+                       <eventname>settings</eventname>
+                       <templatecode><![CDATA[{include file='__searchAreaConversationSettings'}]]></templatecode>
+               </templatelistener>
+       </delete>
 </data>
\ No newline at end of file
index b5566292d92581a1cb9cc115ee893c98df4dc0be..02e7d2d9bf9a1619bccdeff22c553653bc3119f7 100644 (file)
@@ -1,5 +1,5 @@
 {if $__searchAreaInitialized|empty && $templateName|substr:0:12 == 'conversation'}
-       {capture assign='__searchInputPlaceholder'}{lang}wcf.conversation.searchConversations{/lang}{/capture}
-       {capture assign='__searchHiddenInputFields'}<input type="hidden" name="types[]" value="com.woltlab.wcf.conversation.message" />{/capture}
+       {capture assign='__searchInputPlaceholder'}{if $conversation|isset}{lang}wcf.conversation.searchConversation{/lang}{else}{lang}wcf.conversation.searchConversations{/lang}{/if}{/capture}
+       {capture assign='__searchHiddenInputFields'}<input type="hidden" name="types[]" value="com.woltlab.wcf.conversation.message" />{if $conversation|isset}<input type="hidden" name="conversationID" value="{@$conversation->conversationID}" />{/if}{/capture}
        {assign var='__searchAreaInitialized' value=true}
-{/if}
\ No newline at end of file
+{/if}