Added report function for user profiles
authorMarcel Werk <burntime@woltlab.com>
Wed, 26 Mar 2014 16:23:22 +0000 (17:23 +0100)
committerMarcel Werk <burntime@woltlab.com>
Wed, 26 Mar 2014 16:23:22 +0000 (17:23 +0100)
com.woltlab.wcf/objectType.xml
com.woltlab.wcf/templates/moderationUser.tpl [new file with mode: 0644]
com.woltlab.wcf/templates/user.tpl
wcfsetup/install/files/lib/data/user/User.class.php
wcfsetup/install/files/lib/system/moderation/queue/report/UserModerationQueueReportHandler.class.php [new file with mode: 0644]
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 0824bfb07d149eda16f3687b346200608b2cdd05..bc9bcb86456f00b8a14d2be4a74dd5ae8cb156e2 100644 (file)
                        <allowsidebar>1</allowsidebar>
                </type>
                
+               <type>
+                       <name>com.woltlab.wcf.user</name>
+                       <definitionname>com.woltlab.wcf.moderation.report</definitionname>
+                       <classname>wcf\system\moderation\queue\report\UserModerationQueueReportHandler</classname>
+               </type>
+               
                <!-- user online locations -->
                <type>
                        <name>com.woltlab.wcf.user.UserPage</name>
diff --git a/com.woltlab.wcf/templates/moderationUser.tpl b/com.woltlab.wcf/templates/moderationUser.tpl
new file mode 100644 (file)
index 0000000..552bafa
--- /dev/null
@@ -0,0 +1,13 @@
+<div class="container marginTop">
+       <ol class="containerList userList">
+               {include file='userListItem'}
+       </ol>
+</div>
+
+<script data-relocate="true">
+       //<![CDATA[
+       $(function() {
+               $('#removeContent').hide();
+       });
+       //]]>
+</script>
index 2592ad8e94bb879b54f131b113b7b996fb9715b2..306d9ef8e3d046b0099eb77e90bd8028a2b1f95b 100644 (file)
@@ -7,7 +7,8 @@
        
        <link rel="canonical" href="{link controller='User' object=$user}{/link}" />
        
-       <script data-relocate="true" src="{@$__wcf->getPath('wcf')}js/WCF.User{if !ENABLE_DEBUG_MODE}.min{/if}.js?v={@$__wcfVersion}"></script>
+       <script data-relocate="true" src="{@$__wcf->getPath()}js/WCF.Moderation{if !ENABLE_DEBUG_MODE}.min{/if}.js?v={@$__wcfVersion}"></script>
+       <script data-relocate="true" src="{@$__wcf->getPath()}js/WCF.User{if !ENABLE_DEBUG_MODE}.min{/if}.js?v={@$__wcfVersion}"></script>
        {event name='javascriptInclude'}
        <script data-relocate="true">
                //<![CDATA[
                                });
                        {/if}
                        
+                       WCF.Language.addObject({
+                               'wcf.moderation.report.reportContent': '{lang}wcf.user.profile.report{/lang}',
+                               'wcf.moderation.report.success': '{lang}wcf.moderation.report.success{/lang}'
+                       });
+                       new WCF.Moderation.Report.Content('com.woltlab.wcf.user', '.jsReportUser');
+                               
                        {event name='javascriptInit'}
                });
                //]]>
                                        </ul>
                                </li>
                        {/hascontent}
+                       <li class="jsReportUser jsOnly" data-object-id="{@$user->userID}"><a title="{lang}wcf.user.profile.report{/lang}" class="button jsTooltip"><span class="icon icon16 icon-warning-sign"></span> <span class="invisible">{lang}wcf.user.profile.report{/lang}</span></a></li>
                        {if $user->userID != $__wcf->user->userID}{if $user->isAccessible('canViewEmailAddress')}<li><a class="button jsTooltip" href="mailto:{@$user->getEncodedEmail()}" title="{lang}wcf.user.button.mail{/lang}"><span class="icon icon16 icon-envelope-alt"></span> <span class="invisible">{lang}wcf.user.button.mail{/lang}</span></a></li>{elseif $user->isAccessible('canMail') && $__wcf->session->getPermission('user.profile.canMail')}<li><a class="button jsTooltip" href="{link controller='Mail' object=$user}{/link}" title="{lang}wcf.user.button.mail{/lang}"><span class="icon icon16 icon-envelope-alt"></span> <span class="invisible">{lang}wcf.user.button.mail{/lang}</span></a></li>{/if}{/if}
                        {event name='buttons'}
                </ul>
index 3e9ec98af9d0d63daf219a8790333d00d79613c6..6d3a69be8e2cb8f4c365587498ddf57156f58eaa 100644 (file)
@@ -3,9 +3,11 @@ namespace wcf\data\user;
 use wcf\data\user\group\UserGroup;
 use wcf\data\user\UserList;
 use wcf\data\DatabaseObject;
+use wcf\data\IUserContent;
 use wcf\system\cache\builder\UserOptionCacheBuilder;
 use wcf\system\language\LanguageFactory;
 use wcf\system\request\IRouteController;
+use wcf\system\request\LinkHandler;
 use wcf\system\user\storage\UserStorageHandler;
 use wcf\system\WCF;
 use wcf\util\PasswordUtil;
@@ -20,7 +22,7 @@ use wcf\util\PasswordUtil;
  * @subpackage data.user
  * @category   Community Framework
  */
-final class User extends DatabaseObject implements IRouteController {
+final class User extends DatabaseObject implements IRouteController, IUserContent {
        /**
         * @see \wcf\data\DatabaseObject::$databaseTableName
         */
@@ -429,4 +431,36 @@ final class User extends DatabaseObject implements IRouteController {
                
                return $this->hasAdministrativePermissions;
        }
+       
+       /**
+        * @see \wcf\data\IMessage::getUserID()
+        */
+       public function getUserID() {
+               return $this->userID;
+       }
+       
+       /**
+        * @see \wcf\data\IMessage::getUsername()
+        */
+       public function getUsername() {
+               return $this->username;
+       }
+       
+       /**
+        * @see \wcf\data\IMessage::getTime()
+        */
+       public function getTime() {
+               return $this->registrationDate;
+       }
+       
+       /**
+        * @see \wcf\data\ILinkableObject::getLink()
+        */
+       public function getLink() {
+               return LinkHandler::getInstance()->getLink('User', array(
+                       'application' => 'wcf',
+                       'object' => $this,
+                       'forceFrontend' => true
+               ));
+       }
 }
diff --git a/wcfsetup/install/files/lib/system/moderation/queue/report/UserModerationQueueReportHandler.class.php b/wcfsetup/install/files/lib/system/moderation/queue/report/UserModerationQueueReportHandler.class.php
new file mode 100644 (file)
index 0000000..5f7502a
--- /dev/null
@@ -0,0 +1,161 @@
+<?php
+namespace wcf\system\moderation\queue\report;
+use wcf\data\moderation\queue\ModerationQueue;
+use wcf\data\moderation\queue\ViewableModerationQueue;
+use wcf\data\user\UserList;
+use wcf\data\user\UserProfile;
+use wcf\data\user\User;
+use wcf\system\exception\SystemException;
+use wcf\system\moderation\queue\AbstractModerationQueueHandler;
+use wcf\system\moderation\queue\ModerationQueueManager;
+use wcf\system\WCF;
+
+/**
+ * An implementation of IModerationQueueReportHandler for user profiles.
+ * 
+ * @author     Marcel Werk
+ * @copyright  2001-2014 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.moderation.queue
+ * @category   Community Framework
+ */
+class UserModerationQueueReportHandler extends AbstractModerationQueueHandler implements IModerationQueueReportHandler {
+       /**
+        * @see \wcf\system\moderation\queue\AbstractModerationQueueHandler::$className
+        */
+       protected $className = 'wcf\data\user\User';
+       
+       /**
+        * @see \wcf\system\moderation\queue\AbstractModerationQueueHandler::$definitionName
+        */
+       protected $definitionName = 'com.woltlab.wcf.moderation.report';
+       
+       /**
+        * @see \wcf\system\moderation\queue\AbstractModerationQueueHandler::$objectType
+        */
+       protected $objectType = 'com.woltlab.wcf.user';
+       
+       /**
+        * list of users
+        * @var array<\wcf\data\user\User>
+        */
+       protected static $users = array();
+       
+       /**
+        * @see \wcf\system\moderation\queue\IModerationQueueHandler::assignQueues()
+        */
+       public function assignQueues(array $queues) {
+               $assignments = array();
+               foreach ($queues as $queue) {
+                       $assignUser = false;
+                       if (WCF::getSession()->getPermission('mod.general.canUseModeration')) {
+                               $assignUser = true;
+                       }
+                               
+                       $assignments[$queue->queueID] = $assignUser;
+               }
+               
+               ModerationQueueManager::getInstance()->setAssignment($assignments);
+       }
+       
+       /**
+        * @see \wcf\system\moderation\queue\report\IModerationQueueReportHandler::canReport()
+        */
+       public function canReport($objectID) {
+               if (!$this->isValid($objectID)) {
+                       return false;
+               }
+               
+               return true;
+       }
+       
+       /**
+        * @see \wcf\system\moderation\queue\IModerationQueueHandler::getContainerID()
+        */
+       public function getContainerID($objectID) {
+               return 0;
+       }
+       
+       /**
+        * @see \wcf\system\moderation\queue\report\IModerationQueueReportHandler::getReportedContent()
+        */
+       public function getReportedContent(ViewableModerationQueue $queue) {
+               WCF::getTPL()->assign(array(
+                       'user' => new UserProfile($queue->getAffectedObject())
+               ));
+               
+               return WCF::getTPL()->fetch('moderationUser');
+       }
+       
+       /**
+        * @see \wcf\system\moderation\queue\report\IModerationQueueReportHandler::getReportedObject()
+        */
+       public function getReportedObject($objectID) {
+               if ($this->isValid($objectID)) {
+                       return $this->getUser($objectID);
+               }
+               
+               return null;
+       }
+       
+       /**
+        * @see \wcf\system\moderation\queue\IModerationQueueHandler::isValid()
+        */
+       public function isValid($objectID) {
+               if ($this->getUser($objectID) === null) {
+                       return false;
+               }
+               
+               return true;
+       }
+       
+       /**
+        * Returns a user object by user id or null if user id is invalid.
+        * 
+        * @param       integer         $objectID
+        * @return      \wcf\data\user\User
+        */
+       protected function getUser($objectID) {
+               if (!array_key_exists($objectID, self::$users)) {
+                       self::$users[$objectID] = new User($objectID);
+                       if (!self::$users[$objectID]->userID) {
+                               self::$users[$objectID] = null;
+                       }
+               }
+               
+               return self::$users[$objectID];
+       }
+       
+       /**
+        * @see \wcf\system\moderation\queue\IModerationQueueHandler::populate()
+        */
+       public function populate(array $queues) {
+               $objectIDs = array();
+               foreach ($queues as $object) {
+                       $objectIDs[] = $object->objectID;
+               }
+               
+               // fetch users
+               $userList = new UserList();
+               $userList->setObjectIDs($objectIDs);
+               $userList->readObjects();
+               $users = $userList->getObjects();
+               
+               foreach ($queues as $object) {
+                       if (isset($users[$object->objectID])) {
+                               $object->setAffectedObject($users[$object->objectID]);
+                       }
+                       else {
+                               $object->setIsOrphaned();
+                       }
+               }
+       }
+       
+       /**
+        * @see \wcf\system\moderation\queue\IModerationQueueHandler::removeContent()
+        */
+       public function removeContent(ModerationQueue $queue, $message) {
+               throw new SystemException("it's not allowed to delete users using the moderation");
+       }
+}
index 0bfdbe8e20c36bd7ed91fc375317fa4059eb9b38..60124621d7781d79e6b752a95916a215dbc502dd 100644 (file)
@@ -1892,6 +1892,7 @@ Fehler sind beispielsweise:
                <item name="wcf.moderation.type.com.woltlab.wcf.moderation.report"><![CDATA[Meldung]]></item>
                <item name="wcf.moderation.type.com.woltlab.wcf.comment.comment"><![CDATA[Kommentar]]></item>
                <item name="wcf.moderation.type.com.woltlab.wcf.comment.response"><![CDATA[Antwort auf Kommentar]]></item>
+               <item name="wcf.moderation.type.com.woltlab.wcf.user"><![CDATA[Benutzerprofil]]></item>
                <item name="wcf.moderation.showAll"><![CDATA[Alle Einträge anzeigen]]></item>
                <item name="wcf.moderation.showDeletedContent"><![CDATA[Gelöschte Inhalte anzeigen]]></item>
                <item name="wcf.moderation.deletedContent.objectTypes"><![CDATA[Gelöschte Inhalte]]></item>
@@ -2467,6 +2468,7 @@ Möchten Sie diese E-Mail-Benachrichtigung in Zukunft nicht mehr erhalten, könn
                <item name="wcf.user.profile.menu.wall"><![CDATA[Pinnwand]]></item>
                <item name="wcf.user.profile.recentActivity.profileComment"><![CDATA[Hat einen Kommentar an die <a href="{link controller='User' object=$user}{/link}#wall">Pinnwand von {$user->username}</a> geschrieben.]]></item>
                <item name="wcf.user.profile.recentActivity.profileCommentResponse"><![CDATA[Hat auf einen Kommentar von <a href="{link controller='User' object=$commentAuthor}{/link}">{$commentAuthor->username}</a> an der <a href="{link controller='User' object=$user}{/link}#wall">Pinnwand von {$user->username}</a> geantwortet.]]></item>
+               <item name="wcf.user.profile.report"><![CDATA[Benutzerprofil melden]]></item>
        </category>
        
        <category name="wcf.user.objectWatch">
index 497928ead6fc23fb258aa3b9600cda30b6d579e6..aa835ed35a2f738bc024be487b31143bfa1dc5ca 100644 (file)
@@ -1891,6 +1891,7 @@ Errors are:
                <item name="wcf.moderation.type.com.woltlab.wcf.moderation.report"><![CDATA[Report]]></item>
                <item name="wcf.moderation.type.com.woltlab.wcf.comment.comment"><![CDATA[Comment]]></item>
                <item name="wcf.moderation.type.com.woltlab.wcf.comment.response"><![CDATA[Comment Reply]]></item>
+               <item name="wcf.moderation.type.com.woltlab.wcf.user"><![CDATA[User Profile]]></item>
                <item name="wcf.moderation.showAll"><![CDATA[Show All Items]]></item>
                <item name="wcf.moderation.showDeletedContent"><![CDATA[Show Deleted Content]]></item>
                <item name="wcf.moderation.deletedContent.objectTypes"><![CDATA[Deleted Content]]></item>
@@ -2465,6 +2466,7 @@ If you do not want to receive further email notifications for this event, you ca
                <item name="wcf.user.profile.menu.wall"><![CDATA[Wall]]></item>
                <item name="wcf.user.profile.recentActivity.profileComment"><![CDATA[Wrote a comment on <a href="{link controller='User' object=$user}{/link}#wall">{$user->username}’s wall</a>.]]></item>
                <item name="wcf.user.profile.recentActivity.profileCommentResponse"><![CDATA[Replied to a comment by <a href="{link controller='User' object=$commentAuthor}{/link}">{$commentAuthor->username}</a> on <a href="{link controller='User' object=$user}{/link}#wall">{$user->username}’s wall</a>.]]></item>
+               <item name="wcf.user.profile.report"><![CDATA[Report User Profile]]></item>
        </category>
        
        <category name="wcf.user.objectWatch">