Improve unsuccessful/modification of conversation-specific searches
authorMatthias Schmidt <gravatronics@live.com>
Sun, 29 Nov 2015 17:26:06 +0000 (18:26 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 29 Nov 2015 17:26:06 +0000 (18:26 +0100)
If a conversation-specific search was unsuccessful and/or the user
decided to modify their search, the search form forgot that only a
specific conversation has been searched. This commit changes this by
adding an additional checkbox which remembers the searched conversation
and allows the user to expand the search to all conversations by
unchecking.

files/lib/system/search/ConversationMessageSearch.class.php
language/de.xml
language/en.xml
templates/searchConversationMessage.tpl [new file with mode: 0644]

index f658b1ddadbdf75e4b5e4ec2c29b85375b67ff92..a53f39178a751b384dc4bbbcf2347abbd17f022b 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\system\search;
 use wcf\data\conversation\message\SearchResultConversationMessageList;
+use wcf\data\conversation\Conversation;
 use wcf\form\IForm;
 use wcf\system\database\util\PreparedStatementConditionBuilder;
 use wcf\system\WCF;
@@ -22,6 +23,12 @@ class ConversationMessageSearch extends AbstractSearchableObjectType {
         */
        public $conversationID = 0;
        
+       /**
+        * searched conversation
+        * @var Conversation
+        */
+       public $conversation;
+       
        /**
         * message data cache
         * @var array<\wcf\data\conversation\message\SearchResultConversationMessage>
@@ -62,7 +69,7 @@ class ConversationMessageSearch extends AbstractSearchableObjectType {
         */
        public function getJoins() {
                return "JOIN wcf".WCF_N."_conversation_to_user conversation_to_user ON (conversation_to_user.participantID = ".WCF::getUser()->userID." AND conversation_to_user.conversationID = ".$this->getTableName().".conversationID)
-               LEFT JOIN wcf".WCF_N."_conversation conversation ON (conversation.conversationID = ".$this->getTableName().".conversationID)";
+                       LEFT JOIN wcf".WCF_N."_conversation conversation ON (conversation.conversationID = ".$this->getTableName().".conversationID)";
        }
        
        /**
@@ -108,4 +115,36 @@ class ConversationMessageSearch extends AbstractSearchableObjectType {
        public function isAccessible() {
                return (WCF::getUser()->userID ? true : false);
        }
+       
+       /**
+        * @see \wcf\system\search\ISearchableObjectType::getFormTemplateName()
+        */
+       public function getFormTemplateName() {
+               if ($this->conversation) {
+                       return 'searchConversationMessage';
+               }
+               
+               return null;
+       }
+       
+       /**
+        * @see \wcf\system\search\ISearchableObjectType::show()
+        */
+       public function show(IForm $form = null) {
+               // get existing values
+               if ($form !== null && isset($form->searchData['additionalData']['com.woltlab.wcf.conversation.message']['conversationID'])) {
+                       $this->conversationID = $form->searchData['additionalData']['com.woltlab.wcf.conversation.message']['conversationID'];
+                       
+                       if ($this->conversationID) {
+                               $this->conversation = Conversation::getUserConversation($this->conversationID, WCF::getUser()->userID);
+                               
+                               if ($this->conversation === null || !$this->conversation->canRead()) {
+                                       $this->conversationID = 0;
+                                       $this->conversation = null;
+                               }
+                       }
+               }
+               
+               WCF::getTPL()->assign('searchedConversation', $this->conversation);
+       }
 }
index f7c1de5ed15e57360809672b36c2700aeea122b4..ded11b0b8d35eb2987b6f49361afde246ac61346 100644 (file)
                <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.searchedConversation"><![CDATA[Nur Konversation <a href="{link controller='Conversation' object=$searchedConversation}{/link}">{$searchedConversation->getTitle()}</a> 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 aad3b42d4c9c5c552452091dd75d3f321341497e..2695b97834357e6b3dae382a82662414dd45e306 100644 (file)
                <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.searchedConversation"><![CDATA[Only search conversation <a href="{link controller='Conversation' object=$searchedConversation}{/link}">{$searchedConversation->getTitle()}</a>]]></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>
diff --git a/templates/searchConversationMessage.tpl b/templates/searchConversationMessage.tpl
new file mode 100644 (file)
index 0000000..9ce05c2
--- /dev/null
@@ -0,0 +1,4 @@
+<dl>
+       <dt></dt>
+       <dd><label><input type="checkbox" name="conversationID" value="{@$searchedConversation->conversationID}" checked="checked" /> {lang}wcf.conversation.searchedConversation{/lang}</label></dd>
+</dl>