* Represents a list of conversations.
*
* @author Marcel Werk
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf.conversation
* @subpackage data.conversation
*/
class ConversationList extends DatabaseObjectList {
/**
- * @see \wcf\data\DatabaseObjectList::$className
+ * @inheritDoc
*/
- public $className = 'wcf\data\conversation\Conversation';
+ public $className = Conversation::class;
}
--- /dev/null
+<?php
+namespace wcf\system\cache\runtime;
+use wcf\data\conversation\Conversation;
+use wcf\data\conversation\ConversationList;
+
+/**
+ * Runtime cache implementation for conversations.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf.conversation
+ * @subpackage system.cache.runtime
+ * @category Community Framework
+ * @since 2.2
+ *
+ * @method Conversation getObject($objectID)
+ * @method Conversation[] getObjects(array $objectIDs)
+ */
+class ConversationRuntimeCache extends AbstractRuntimeCache {
+ /**
+ * @inheritDoc
+ */
+ protected $listClassName = ConversationList::class;
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace wcf\system\cache\runtime;
+use wcf\data\conversation\Conversation;
+use wcf\data\conversation\UserConversationList;
+use wcf\system\WCF;
+
+/**
+ * Runtime cache implementation for conversation fetched using UserConversationList.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf.conversation
+ * @subpackage system.cache.runtime
+ * @category Community Framework
+ * @since 2.2
+ *
+ * @method Conversation getObject($objectID)
+ * @method Conversation[] getObjects(array $objectIDs)
+ */
+class UserConversationRuntimeCache extends AbstractRuntimeCache {
+ /**
+ * @inheritDoc
+ */
+ protected $listClassName = UserConversationList::class;
+
+ /**
+ * @inheritDoc
+ */
+ protected function getObjectList() {
+ return new UserConversationList(WCF::getUser()->userID);
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\page\handler;
+use wcf\system\conversation\ConversationHandler;
+use wcf\system\WCF;
+
+/**
+ * Page handler implementation for the conversation list.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf.conversation
+ * @subpackage system.page.handler
+ * @category Community Framework
+ * @since 2.2
+ */
+class ConversationListPageHandler extends AbstractMenuPageHandler {
+ /**
+ * @inheritDoc
+ */
+ public function getOutstandingItemCount($objectID = null) {
+ return ConversationHandler::getInstance()->getUnreadConversationCount();
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function isVisible($objectID = null) {
+ return WCF::getUser()->userID != 0;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\page\handler;
+
+/**
+ * Default implementation of a board-related page handler.
+ *
+ * Only use this class when you need the online location handling for a board-related page.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf.conversation
+ * @subpackage system.page.handler
+ * @category Community Framework
+ * @since 2.2
+ */
+class DefaultConversationRelatedPageHandler extends AbstractMenuPageHandler implements IOnlineLocationPageHandler {
+ use TConversationOnlineLocationPageHandler;
+}
--- /dev/null
+<?php
+namespace wcf\system\page\handler;
+use wcf\data\page\Page;
+use wcf\data\user\online\UserOnline;
+use wcf\system\cache\runtime\UserConversationRuntimeCache;
+use wcf\system\WCF;
+
+/**
+ * Implementation of the online location-related page handler methods for conversations.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf.conversation
+ * @subpackage system.page.handler
+ * @category Community Framework
+ * @since 2.2
+ */
+trait TConversationOnlineLocationPageHandler {
+ use TOnlineLocationPageHandler;
+
+ /**
+ * @see IMenuPageHandler::getOnlineLocation()
+ */
+ public function getOnlineLocation(Page $page, UserOnline $user) {
+ if ($user->objectID === null) {
+ return '';
+ }
+
+ $conversation = UserConversationRuntimeCache::getInstance()->getObject($user->objectID);
+ if ($conversation === null || !$conversation->canRead()) {
+ return '';
+ }
+
+ return WCF::getLanguage()->getDynamicVariable('wcf.page.onlineLocation.'.$page->identifier, ['conversation' => $conversation]);
+ }
+
+ /**
+ * @see IOnlineLocationPageHandler::prepareOnlineLocation()
+ */
+ public function prepareOnlineLocation(Page $page, UserOnline $user) {
+ if ($user->objectID !== null) {
+ UserConversationRuntimeCache::getInstance()->cacheObjectID($user->objectID);
+ }
+ }
+}
+++ /dev/null
-<?php
-namespace wcf\system\user\online\location;
-use wcf\data\conversation\Conversation;
-use wcf\data\user\online\UserOnline;
-use wcf\system\database\util\PreparedStatementConditionBuilder;
-use wcf\system\WCF;
-
-/**
- * Implementation of IUserOnlineLocation for the conversation page location.
- *
- * @author Marcel Werk
- * @copyright 2001-2016 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf.conversation
- * @subpackage system.user.online.location
- * @category Community Framework
- */
-class ConversationLocation implements IUserOnlineLocation {
- /**
- * conversation ids
- * @var integer[]
- */
- protected $conversationIDs = array();
-
- /**
- * list of conversations
- * @var Conversation[]
- */
- protected $conversations = null;
-
- /**
- * @see \wcf\system\user\online\location\IUserOnlineLocation::cache()
- */
- public function cache(UserOnline $user) {
- if ($user->objectID) $this->conversationIDs[] = $user->objectID;
- }
-
- /**
- * @see \wcf\system\user\online\location\IUserOnlineLocation::get()
- */
- public function get(UserOnline $user, $languageVariable = '') {
- if ($this->conversations === null) {
- $this->readConversations();
- }
-
- if (!isset($this->conversations[$user->objectID])) {
- return '';
- }
-
- return WCF::getLanguage()->getDynamicVariable($languageVariable, array('conversation' => $this->conversations[$user->objectID]));
- }
-
- /**
- * Loads the conversations.
- */
- protected function readConversations() {
- $this->conversations = array();
-
- if (!WCF::getUser()->userID) return;
- if (empty($this->conversationIDs)) return;
- $this->conversationIDs = array_unique($this->conversationIDs);
-
- $conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add('conversation_to_user.participantID = ?', array(WCF::getUser()->userID));
- $conditionBuilder->add('conversation_to_user.conversationID IN (?)', array($this->conversationIDs));
- $conditionBuilder->add('conversation_to_user.hideConversation <> ?', array(Conversation::STATE_LEFT));
-
- $sql = "SELECT conversation.*
- FROM wcf".WCF_N."_conversation_to_user conversation_to_user
- LEFT JOIN wcf".WCF_N."_conversation conversation
- ON (conversation.conversationID = conversation_to_user.conversationID)
- ".$conditionBuilder;
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute($conditionBuilder->getParameters());
- while ($conversation = $statement->fetchObject('\wcf\data\conversation\Conversation')) {
- $this->conversations[$conversation->conversationID] = $conversation;
- }
- }
-}
<item name="wcf.page.com.woltlab.wcf.conversation.ConversationMessageEditForm"><![CDATA[Konversationsnachricht bearbeiten]]></item>
<item name="wcf.page.com.woltlab.wcf.conversation.ConversationListPage"><![CDATA[Konversationen]]></item>
<item name="wcf.page.com.woltlab.wcf.conversation.ConversationPage"><![CDATA[Konversation]]></item>
+ <item name="wcf.page.onlineLocation.com.woltlab.wcf.conversation.ConversationAdd"><![CDATA[Neue Konversation]]></item>
+ <item name="wcf.page.onlineLocation.com.woltlab.wcf.conversation.ConversationList"><![CDATA[Konversationenliste]]></item>
+ <item name="wcf.page.onlineLocation.com.woltlab.wcf.conversation.ConversationMessageAdd"><![CDATA[Antwort erstellen in Konversation <a href="{link controller='Conversation' object=$conversation}{/link}" class="conversationLink" data-conversation-id="{@$conversation->conversationID}">{$conversation->subject}</a>]]></item>
+ <item name="wcf.page.onlineLocation.com.woltlab.wcf.conversation.ConversationMessageEdit"><![CDATA[Nachricht bearbeiten in Konversation <a href="{link controller='Conversation' object=$conversation}{/link}" class="conversationLink" data-conversation-id="{@$conversation->conversationID}">{$conversation->subject}</a>]]></item>
+ <item name="wcf.page.onlineLocation.com.woltlab.wcf.conversation.Conversation"><![CDATA[Konversation <a href="{link controller='Conversation' object=$conversation}{/link}" class="conversationLink" data-conversation-id="{@$conversation->conversationID}">{$conversation->subject}</a>]]></item>
</category>
<category name="wcf.search">
<item name="wcf.user.option.conversationsPerPage"><![CDATA[Konversationen pro Seite]]></item>
<item name="wcf.user.option.canSendConversation"><![CDATA[Kann Konversationen schreiben]]></item>
</category>
-
- <category name="wcf.user.usersOnline">
- <item name="wcf.user.usersOnline.location.ConversationAddForm"><![CDATA[Erstellt eine neue Konversation]]></item>
- <item name="wcf.user.usersOnline.location.ConversationListPage"><![CDATA[Betrachtet die Liste seiner Konversationen]]></item>
- <item name="wcf.user.usersOnline.location.ConversationMessageAddForm"><![CDATA[Schreibt eine Antwort auf die Konversation <a href="{link controller='Conversation' object=$conversation}{/link}" class="conversationLink" data-conversation-id="{@$conversation->conversationID}">{$conversation->subject}</a>]]></item>
- <item name="wcf.user.usersOnline.location.ConversationMessageEditForm"><![CDATA[Bearbeitet eine Nachricht in der Konversation <a href="{link controller='Conversation' object=$conversation}{/link}" class="conversationLink" data-conversation-id="{@$conversation->conversationID}">{$conversation->subject}</a>]]></item>
- <item name="wcf.user.usersOnline.location.ConversationPage"><![CDATA[Liest die Konversation <a href="{link controller='Conversation' object=$conversation}{/link}" class="conversationLink" data-conversation-id="{@$conversation->conversationID}">{$conversation->subject}</a>]]></item>
- </category>
</language>
<item name="wcf.page.com.woltlab.wcf.conversation.ConversationMessageEditForm"><![CDATA[Edit Conversation Message]]></item>
<item name="wcf.page.com.woltlab.wcf.conversation.ConversationListPage"><![CDATA[Conversations]]></item>
<item name="wcf.page.com.woltlab.wcf.conversation.ConversationPage"><![CDATA[Conversation]]></item>
+ <item name="wcf.page.onlineLocation.com.woltlab.wcf.conversation.ConversationAdd"><![CDATA[Create Conversation]]></item>
+ <item name="wcf.page.onlineLocation.com.woltlab.wcf.conversation.ConversationList"><![CDATA[Conversation List]]></item>
+ <item name="wcf.page.onlineLocation.com.woltlab.wcf.conversation.ConversationMessageAdd"><![CDATA[Reply to conversation <a href="{link controller='Conversation' object=$conversation}{/link}" class="conversationLink" data-conversation-id="{@$conversation->conversationID}">{$conversation->subject}</a>]]></item>
+ <item name="wcf.page.onlineLocation.com.woltlab.wcf.conversation.ConversationMessageEdit"><![CDATA[Edit message in conversation <a href="{link controller='Conversation' object=$conversation}{/link}" class="conversationLink" data-conversation-id="{@$conversation->conversationID}">{$conversation->subject}</a>]]></item>
+ <item name="wcf.page.onlineLocation.com.woltlab.wcf.conversation.Conversation"><![CDATA[Conversation <a href="{link controller='Conversation' object=$conversation}{/link}" class="conversationLink" data-conversation-id="{@$conversation->conversationID}">{$conversation->subject}</a>]]></item>
</category>
<category name="wcf.search">
<item name="wcf.user.option.conversationsPerPage"><![CDATA[Conversations Per Page]]></item>
<item name="wcf.user.option.canSendConversation"><![CDATA[Can Add Me to Conversations]]></item>
</category>
-
- <category name="wcf.user.usersOnline">
- <item name="wcf.user.usersOnline.location.ConversationAddForm"><![CDATA[Creating a conversation]]></item>
- <item name="wcf.user.usersOnline.location.ConversationListPage"><![CDATA[Viewing list of conversations]]></item>
- <item name="wcf.user.usersOnline.location.ConversationMessageAddForm"><![CDATA[Writing a reply to conversation <a href="{link controller='Conversation' object=$conversation}{/link}" class="conversationLink" data-conversation-id="{@$conversation->conversationID}">{$conversation->subject}</a>]]></item>
- <item name="wcf.user.usersOnline.location.ConversationMessageEditForm"><![CDATA[Editing message in conversation <a href="{link controller='Conversation' object=$conversation}{/link}" class="conversationLink" data-conversation-id="{@$conversation->conversationID}">{$conversation->subject}</a>]]></item>
- <item name="wcf.user.usersOnline.location.ConversationPage"><![CDATA[Reading conversation <a href="{link controller='Conversation' object=$conversation}{/link}" class="conversationLink" data-conversation-id="{@$conversation->conversationID}">{$conversation->subject}</a>]]></item>
- </category>
</language>
</type>
<!-- /Modification Log -->
- <!-- user online locations -->
- <type>
- <name>com.woltlab.wcf.conversation.ConversationListPage</name>
- <definitionname>com.woltlab.wcf.user.online.location</definitionname>
- <controller>wcf\page\ConversationListPage</controller>
- <languagevariable>wcf.user.usersOnline.location.ConversationListPage</languagevariable>
- </type>
- <type>
- <name>com.woltlab.wcf.conversation.ConversationAddForm</name>
- <definitionname>com.woltlab.wcf.user.online.location</definitionname>
- <controller>wcf\form\ConversationAddForm</controller>
- <languagevariable>wcf.user.usersOnline.location.ConversationAddForm</languagevariable>
- </type>
- <type>
- <name>com.woltlab.wcf.conversation.ConversationPage</name>
- <definitionname>com.woltlab.wcf.user.online.location</definitionname>
- <classname>wcf\system\user\online\location\ConversationLocation</classname>
- <controller>wcf\page\ConversationPage</controller>
- <languagevariable>wcf.user.usersOnline.location.ConversationPage</languagevariable>
- </type>
- <type>
- <name>com.woltlab.wcf.conversation.ConversationMessageAddForm</name>
- <definitionname>com.woltlab.wcf.user.online.location</definitionname>
- <classname>wcf\system\user\online\location\ConversationLocation</classname>
- <controller>wcf\form\ConversationMessageAddForm</controller>
- <languagevariable>wcf.user.usersOnline.location.ConversationMessageAddForm</languagevariable>
- </type>
- <type>
- <name>com.woltlab.wcf.conversation.ConversationMessageEditForm</name>
- <definitionname>com.woltlab.wcf.user.online.location</definitionname>
- <classname>wcf\system\user\online\location\ConversationLocation</classname>
- <controller>wcf\form\ConversationMessageEditForm</controller>
- <languagevariable>wcf.user.usersOnline.location.ConversationMessageEditForm</languagevariable>
- </type>
- <!-- /user online locations -->
-
<!-- importers -->
<type>
<name>com.woltlab.wcf.conversation</name>
<instruction type="userOption" />
<instruction type="eventListener" />
<instruction type="script">acp/install_com.woltlab.wcf.conversation.php</instruction>
+ <instruction type="page" />
</instructions>
</package>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<data xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/page.xsd">
+ <import>
+ <page identifier="com.woltlab.wcf.conversation.ConversationList">
+ <controller>wcf\page\ConversationListPage</controller>
+ <name language="de"><![CDATA[Konversationenliste]]></name>
+ <name language="en"><![CDATA[Conversation List]]></name>
+ <pagetype>system</pagetype>
+ </page>
+ <page identifier="com.woltlab.wcf.conversation.Conversation">
+ <controller>wcf\page\ConversationPage</controller>
+ <handler>wcf\system\page\handler\DefaultConversationRelatedPageHandler</handler>
+ <name language="de"><![CDATA[Konversation]]></name>
+ <name language="en"><![CDATA[Conversation]]></name>
+ <pagetype>system</pagetype>
+ </page>
+ <page identifier="com.woltlab.wcf.conversation.ConversationAdd">
+ <controller>wcf\form\ConversationAddForm</controller>
+ <handler>wcf\system\page\handler\DefaultConversationRelatedPageHandler</handler>
+ <name language="de"><![CDATA[Konversation starten]]></name>
+ <name language="en"><![CDATA[New Conversation]]></name>
+ <pagetype>system</pagetype>
+ </page>
+ <page identifier="com.woltlab.wcf.conversation.ConversationMessageAdd">
+ <controller>wcf\form\ConversationMessageAddForm</controller>
+ <handler>wcf\system\page\handler\DefaultConversationRelatedPageHandler</handler>
+ <name language="de"><![CDATA[Antwort auf Konversation erstellen]]></name>
+ <name language="en"><![CDATA[Reply to Conversation]]></name>
+ <pagetype>system</pagetype>
+ <requireObjectID>1</requireObjectID>
+ </page>
+ <page identifier="com.woltlab.wcf.conversation.ConversationMessageEdit">
+ <controller>wcf\form\ConversationMessageEditForm</controller>
+ <name language="de"><![CDATA[Antwort auf Konversation bearbeiten]]></name>
+ <name language="en"><![CDATA[Edit Reply to Conversation]]></name>
+ <pagetype>system</pagetype>
+ <requireObjectID>1</requireObjectID>
+ </page>
+ </import>
+</data>