Modification log overhaul
authorMarcel Werk <burntime@woltlab.com>
Thu, 7 Mar 2013 19:12:21 +0000 (20:12 +0100)
committerMarcel Werk <burntime@woltlab.com>
Thu, 7 Mar 2013 19:12:21 +0000 (20:12 +0100)
files/js/WCF.Conversation.js
files/lib/data/conversation/ConversationAction.class.php
files/lib/data/conversation/ConversationEditor.class.php
files/lib/data/modification/log/ConversationLogModificationLogList.class.php
files/lib/data/modification/log/ViewableConversationModificationLog.class.php
files/lib/page/ConversationLogPage.class.php [deleted file]
files/lib/system/log/modification/ConversationModificationLogHandler.class.php
language/de.xml
templates/conversation.tpl
templates/conversationLog.tpl [deleted file]
templates/conversationMessageListLog.tpl

index 051c152bfecc1ab8d2ffa36bd13f18387f4db9d7..866d396e62aefea14b24248d64207680507a7a43 100644 (file)
@@ -830,7 +830,15 @@ WCF.Conversation.RemoveParticipant = WCF.Action.Delete.extend({
         * @see WCF.Action.Delete._success()
         */
        _success: function(data, textStatus, jqXHR) {
-               this.triggerEffect([ data.returnValues.userID ]);
+               var $userID = data.returnValues.userID;
+               
+               for (var $index in this._containers) {
+                       var $container = $('#' + this._containers[$index]);
+                       if ($container.find('.jsDeleteButton').data('objectID') == $userID) {
+                               $container.find('.userLink').addClass('conversationLeft');
+                               $container.find('.jsDeleteButton').remove();
+                       }
+               }
        }
 });
 
index d7e47a663f497666d729b97e4a272e98b745797c..9e6454bc37c96838a9d0fed0b7bd854e7cff7e80 100644 (file)
@@ -441,6 +441,15 @@ class ConversationAction extends AbstractDatabaseObjectAction implements IClipbo
                        UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'unreadConversationCount');
                }
                
+               // add modification log entry
+               if ($this->parameters['hideConversation'] == Conversation::STATE_LEFT) {
+                       if (empty($this->objects)) $this->readObjects();
+                       
+                       foreach ($this->objects as $conversation) {
+                               ConversationModificationLogHandler::getInstance()->leave($conversation->getDecoratedObject());
+                       }
+               }
+               
                // unmark items
                $this->unmarkItems();
                
index dcfead6501bd2f033a50b1b82cf831e16c8dfecd..9863bcb7bd742742466add4e7f1df207f73e0ecc 100644 (file)
@@ -105,11 +105,13 @@ class ConversationEditor extends DatabaseObjectEditor {
         * @param       integer         $userID
         */
        public function removeParticipant($userID) {
-               $sql = "DELETE FROM     wcf".WCF_N."_conversation_to_user
-                       WHERE           conversationID = ?
-                                       AND participantID = ?";
+               $sql = "UPDATE  wcf".WCF_N."_conversation_to_user
+                       SET     hideConversation = ?
+                       WHERE   conversationID = ?
+                               AND participantID = ?";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute(array(
+                       2,
                        $this->conversationID,
                        $userID
                ));
index 6233658f307ede3f3e048303f18bb17ca7336336..c494e80691ddacc18b17e2ec06e1815c4424e5e4 100644 (file)
@@ -69,11 +69,15 @@ class ConversationLogModificationLogList extends ModificationLogList {
         * @see wcf\data\DatabaseObjectList::readObjects()
         */
        public function readObjects() {
-               $sql = "SELECT  modification_log.*
-                       FROM    wcf".WCF_N."_modification_log modification_log
-                       WHERE   modification_log.objectTypeID = ?
-                               AND modification_log.objectID = ?
-                               ".(!empty($this->sqlOrderBy) ? "ORDER BY ".$this->sqlOrderBy : '');
+               $sql = "SELECT          user_avatar.*,
+                                       user_table.email, user_table.enableGravatar, user_table.disableAvatar,
+                                       modification_log.*
+                       FROM            wcf".WCF_N."_modification_log modification_log
+                       LEFT JOIN       wcf".WCF_N."_user user_table ON (user_table.userID = modification_log.userID)
+                       LEFT JOIN       wcf".WCF_N."_user_avatar user_avatar ON (user_avatar.avatarID = user_table.avatarID)            
+                       WHERE           modification_log.objectTypeID = ?
+                                       AND modification_log.objectID = ?
+                                       ".(!empty($this->sqlOrderBy) ? "ORDER BY ".$this->sqlOrderBy : '');
                $statement = WCF::getDB()->prepareStatement($sql, $this->sqlLimit, $this->sqlOffset);
                $statement->execute(array(
                        $this->conversationObjectTypeID,
index a3ade1d0e70c33bad37aa499bb069bb1e8f8927e..f565512a2e266c8813220bc3a1c7a2b214cf9c7f 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 namespace wcf\data\modification\log;
+use wcf\data\user\User;
+use wcf\data\user\UserProfile;
 use wcf\data\DatabaseObjectDecorator;
 use wcf\system\WCF;
 
@@ -19,10 +21,29 @@ class ViewableConversationModificationLog extends DatabaseObjectDecorator {
         */
        protected static $baseClass = 'wcf\data\modification\log\ModificationLog';
        
+       /**
+        * user profile object
+        * @var wcf\data\user\UserProfile
+        */
+       protected $userProfile = null;
+       
        /**
         * Returns readable representation of current log entry.
         */
        public function __toString() {
                return WCF::getLanguage()->getDynamicVariable('wcf.conversation.log.conversation.'.$this->action, array('additionalData' => $this->additionalData));
        }
+       
+       /**
+        * Returns the profile object of the user who created the modification entry.
+        *
+        * @return      wcf\data\user\UserProfile
+        */
+       public function getUserProfile() {
+               if ($this->userProfile === null) {
+                       $this->userProfile = new UserProfile(new User(null, $this->getDecoratedObject()->data));
+               }
+       
+               return $this->userProfile;
+       }
 }
diff --git a/files/lib/page/ConversationLogPage.class.php b/files/lib/page/ConversationLogPage.class.php
deleted file mode 100644 (file)
index b4022d0..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-<?php
-namespace wcf\page;
-use wcf\data\conversation\Conversation;
-use wcf\system\breadcrumb\Breadcrumb;
-use wcf\system\exception\IllegalLinkException;
-use wcf\system\exception\PermissionDeniedException;
-use wcf\system\request\LinkHandler;
-use wcf\system\WCF;
-
-/**
- * Shows the conversation log page.
- * 
- * @author     Alexander Ebert
- * @copyright  2001-2012 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    com.woltlab.wcf.conversation
- * @subpackage page
- * @category   Community Framework
- */
-class ConversationLogPage extends SortablePage {
-       /**
-        * conversation id
-        * @var integer
-        */
-       public $conversationID = 0;
-       
-       /**
-        * conversation object
-        * @var wcf\data\conversation\Conversation
-        */
-       public $conversation = null;
-       
-       /**
-        * @see wcf\page\SortablePage::$defaultSortField
-        */
-       public $defaultSortField = 'time';
-       
-       /**
-        * @see wcf\page\SortablePage::$defaultSortOrder
-        */
-       public $defaultSortOrder = 'DESC';
-       
-       /**
-        * @see wcf\page\MultipleLinkPage::$objectListClassName
-        */
-       public $objectListClassName = 'wcf\data\modification\log\ConversationLogModificationLogList';
-       
-       /**
-        * @see wcf\page\SortablePage::$validSortFields
-        */
-       public $validSortFields = array('logID', 'time', 'username');
-       
-       /**
-        * @see wcf\page\IPage::readParameters()
-        */
-       public function readParameters() {
-               parent::readParameters();
-               
-               if (isset($_REQUEST['id'])) $this->conversationID = intval($_REQUEST['id']);
-               $this->conversation = new Conversation($this->conversationID);
-               if (!$this->conversation->conversationID) {
-                       throw new IllegalLinkException();
-               }
-               
-               if (!Conversation::isParticipant(array($this->conversation->conversationID))) {
-                       throw new PermissionDeniedException();
-               }
-       }
-       
-       /**
-        * @see wcf\page\MultipleLinkPage::initObjectList()
-        */
-       protected function initObjectList() {
-               parent::initObjectList();
-               
-               $this->objectList->setConversation($this->conversation);
-       }
-       
-       /**
-        * @see wcf\page\IPage::readData()
-        */
-       public function readData() {
-               parent::readData();
-               
-               // add breadcrumbs
-               WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('wcf.conversation.conversations'), LinkHandler::getInstance()->getLink('ConversationList')));
-               WCF::getBreadcrumbs()->add($this->conversation->getBreadcrumb());
-       }
-       
-       /**
-        * @see wcf\page\IPage::assignVariables()
-        */
-       public function assignVariables() {
-               parent::assignVariables();
-               
-               WCF::getTPL()->assign(array(
-                       'conversation' => $this->conversation
-               ));
-       }
-}
index 7109722dfafe1c4c9e7498b2d4cfb201b272d0a1..ec765c7cfea039a0045a21a2aaa0e47ce3073890 100644 (file)
@@ -56,6 +56,15 @@ class ConversationModificationLogHandler extends ModificationLogHandler {
                $this->add($conversation, 'open');
        }
        
+       /**
+        * Adds a log entry for conversation leave.
+        *
+        * @param       wcf\data\conversation\Conversation      $conversation
+        */
+       public function leave(Conversation $conversation) {
+               $this->add($conversation, 'leave');
+       }
+       
        /**
         * Adds a log entry for a removed participant.
         * 
index c282597f3e47de3298679fb9c399f8e1878064cd..3bb624edc578b6b08e8a3abd930972c8572d466b 100644 (file)
        </category>
        
        <category name="wcf.conversation.log">
-               <item name="wcf.conversation.log"><![CDATA[Änderungsprotokoll]]></item>
-               <item name="wcf.conversation.log.noEntries"><![CDATA[Es wurden keine Änderungen für diese Konversation protokolliert.]]></item>
-               <item name="wcf.conversation.log.title"><![CDATA[Protokollierte Änderungen]]></item>
-               <item name="wcf.conversation.log.action"><![CDATA[Aktion]]></item>
-               <item name="wcf.conversation.log.time"><![CDATA[Datum]]></item>
-               <item name="wcf.conversation.log.conversation.open"><![CDATA[Konversation geöffnet]]></item>
-               <item name="wcf.conversation.log.conversation.close"><![CDATA[Konversation geschlossen]]></item>
-               <item name="wcf.conversation.log.conversation.addParticipants"><![CDATA[Neue Teilnehmer wurden hinzugefügt: {implode from=$additionalData[participants] item=participant}<a href="{link controller='User' id=$participant[userID] title=$participant[username]}{/link}" class="userLink" data-user-id="{@$participant[userID]}">{$participant[username]}</a>{/implode}]]></item>
-               <item name="wcf.conversation.log.conversation.removeParticipant"><![CDATA[Ein Teilnehmer wurde entfernt: <a href="{link controller='User' id=$additionalData[userID] title=$additionalData[username]}{/link}" class="userLink" data-user-id="{@$additionalData[userID]}">{$additionalData[username]}</a>]]></item>
+               <item name="wcf.conversation.log.conversation.open"><![CDATA[Hat die Konversation wieder geöffnet.]]></item>
+               <item name="wcf.conversation.log.conversation.close"><![CDATA[Hat die Konversation für neue Nachrichten geschlossen.]]></item>
+               <item name="wcf.conversation.log.conversation.leave"><![CDATA[Hat die Konversation verlassen.]]></item>
+               <item name="wcf.conversation.log.conversation.addParticipants"><![CDATA[Hat folgende Teilnehmer hinzugefügt: {implode from=$additionalData[participants] item=participant}<a href="{link controller='User' id=$participant[userID] title=$participant[username]}{/link}" class="userLink" data-user-id="{@$participant[userID]}">{$participant[username]}</a>{/implode}]]></item>
+               <item name="wcf.conversation.log.conversation.removeParticipant"><![CDATA[Hat folgende Teilnehmer entfernt: <a href="{link controller='User' id=$additionalData[userID] title=$additionalData[username]}{/link}" class="userLink" data-user-id="{@$additionalData[userID]}">{$additionalData[username]}</a>]]></item>
        </category>
        
        <category name="wcf.search">
index 1c829a5d9c1af29949eb89597e7006eafd438dbe..0ae8191d3bcf669338efe91d62bda16a64530eb3 100644 (file)
 
 <body id="tpl{$templateName|ucfirst}">
 
-{capture assign='headerNavigation'}
-       <li><a href="{link controller='ConversationLog' id=$conversation->conversationID}{/link}" title="{lang}wcf.conversation.log{/lang}" class="jsTooltip"><span class="icon icon16 icon-tasks"></span> <span class="invisible">{lang}wcf.conversation.log{/lang}</span></a></li>
-{/capture}
-
 {include file='header'}
 
 <header class="boxHeadline marginTop conversationHeadline">
@@ -81,7 +77,7 @@
                                                                <h1>
                                                                        <a href="{link controller='User' object=$participant}{/link}" class="userLink{if $participant->hideConversation == 2} conversationLeft{/if}" data-user-id="{@$participant->userID}">{$participant->username}</a>
                                                                        {if $participant->isInvisible}<small>({lang}wcf.conversation.invisible{/lang})</small>{/if}
-                                                                       {if ($conversation->userID == $__wcf->getUser()->userID) && ($participant->userID != $__wcf->getUser()->userID)}
+                                                                       {if ($conversation->userID == $__wcf->getUser()->userID) && ($participant->userID != $__wcf->getUser()->userID) && $participant->hideConversation != 2}
                                                                                <a class="jsDeleteButton jsTooltip" title="{lang}wcf.conversation.participants.removeParticipant{/lang}" data-confirm-message="{lang}wcf.conversation.participants.removeParticipant.confirmMessage{/lang}" data-object-id="{@$participant->userID}"><span class="icon icon16 icon-remove"></span></a>
                                                                        {/if}
                                                                </h1>
diff --git a/templates/conversationLog.tpl b/templates/conversationLog.tpl
deleted file mode 100644 (file)
index 6c42c7f..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-{include file='documentHeader'}
-
-<head>
-       <title>{lang}wcf.conversation.log{/lang} - {$conversation->subject} - {PAGE_TITLE|language}</title>
-       
-       {include file='headInclude'}
-</head>
-
-<body id="tpl{$templateName|ucfirst}">
-
-{include file='header'}
-
-<header class="boxHeadline marginTop">
-       <hgroup>
-               <h1><a href="{link controller='ConversationLog' id=$conversation->conversationID}{/link}">{lang}wcf.conversation.log{/lang}</a></h1>
-       </hgroup>
-</header>
-
-{include file='userNotice'}
-
-<div class="contentNavigation">
-       {pages print=true assign=pagesLinks controller='ConversationLog' id=$conversation->conversationID link="pageNo=%d"}
-</div>
-
-{hascontent}
-       <div class="tabularBox tabularBoxTitle marginTop">
-               <hgroup>
-                       <h1>{lang}wcf.conversation.log.title{/lang} <span class="badge badgeInverse">{#$items}</span></h1>
-               </hgroup>
-               
-               <table class="table">
-                       <thead>
-                               <tr>
-                                       <th class="columnID{if $sortField == 'logID'} active {@$sortOrder}{/if}"><a href="{link controller='ConversationLog' id=$conversation->conversationID}pageNo={@$pageNo}&sortField=logID&sortOrder={if $sortField == 'logID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.global.objectID{/lang}</a></th>
-                                       <th class="columnText">{lang}wcf.conversation.log.action{/lang}</th>
-                                       <th class="columnID{if $sortField == 'username'} active {@$sortOrder}{/if}"><a href="{link controller='ConversationLog' id=$conversation->conversationID}pageNo={@$pageNo}&sortField=username&sortOrder={if $sortField == 'username' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.user.username{/lang}</a></th>
-                                       <th class="columnID{if $sortField == 'time'} active {@$sortOrder}{/if}"><a href="{link controller='ConversationLog' id=$conversation->conversationID}pageNo={@$pageNo}&sortField=time&sortOrder={if $sortField == 'time' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.conversation.log.time{/lang}</a></th>
-                               </tr>
-                       </thead>
-                       <tbody>
-                               {content}
-                                       {foreach from=$objects item=entry}
-                                               <tr>
-                                                       <td class="columnID"><p>{#$entry->logID}</p></td>
-                                                       <td class="columnText"><p>{@$entry}</p></td>
-                                                       <td class="columnText"><p><a href="{link controller='User' id=$entry->userID title=$entry->username}{/link}" class="userLink" data-user-id="{@$entry->userID}">{$entry->username}</a></p></td>
-                                                       <td class="columnData"><p><small>{@$entry->time|time}</small></p></td>
-                                               </tr>
-                                       {/foreach}
-                               {/content}
-                       </tbody>
-               </table>
-       </div>
-{hascontentelse}
-       <p class="info">{lang}wcf.conversation.log.noEntries{/lang}</p>
-{/hascontent}
-
-<div class="contentNavigation">
-       {@$pagesLinks}
-</div>
-
-{include file='footer'}
-
-</body>
-</html>
index f42b0ee2809560283c5bbe33af2b74fac31bc897..ad277ad6222e7e04e6968628547c92c5d95f49a0 100644 (file)
@@ -5,15 +5,13 @@
                        <article class="message messageCollapsed">
                                <div class="messageHeader">
                                        <div class="box24">
-                                               <span class="icon icon16 icon-tasks"></span>
+                                               <a href="{link controller='User' object=$modificationLogEntry->getUserProfile()}{/link}" class="framed">{@$modificationLogEntry->getUserProfile()->getAvatar()->getImageTag(24)}</a>
                                                
                                                <hgroup>
-                                                       <h1>{@$modificationLogEntry}</h1>
-                                                       <h2>
-                                                               <a href="{link controller='User' id=$modificationLogEntry->userID title=$modificationLogEntry->username}{/link}" class="userLink" data-user-id="{@$modificationLogEntry->userID}">{$modificationLogEntry->username}</a>
+                                                       <h1><a href="{link controller='User' object=$modificationLogEntry->getUserProfile()}{/link}" class="userLink" data-user-id="{@$modificationLogEntry->userID}">{$modificationLogEntry->username}</a>
                                                                -
-                                                               {@$modificationLogEntry->time|time}
-                                                       </h2>
+                                                               {@$modificationLogEntry->time|time}</h1>
+                                                       <h2>{@$modificationLogEntry}</h2>
                                                </hgroup>
                                        </div>
                                </div>