Added missing cleanup
authorMarcel Werk <burntime@woltlab.com>
Wed, 22 May 2013 13:11:49 +0000 (15:11 +0200)
committerMarcel Werk <burntime@woltlab.com>
Wed, 22 May 2013 13:11:49 +0000 (15:11 +0200)
wcfsetup/install/files/lib/data/user/UserAction.class.php

index 21ad9758733a91e50d55bcab630660c567688706..a96d19efdd9c05b582718eaddfbbaaf666dbe5b4 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 namespace wcf\data\user;
+use wcf\data\object\type\ObjectTypeCache;
+use wcf\data\user\avatar\UserAvatarAction;
 use wcf\data\user\group\UserGroup;
 use wcf\data\AbstractDatabaseObjectAction;
 use wcf\data\IClipboardAction;
@@ -105,6 +107,42 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio
                $this->__validateAccessibleGroups();
        }
        
+       /**
+        * @see wcf\data\IDeleteAction::delete()
+        */
+       public function delete() {
+               if (empty($this->objects)) {
+                       $this->readObjects();
+               }
+               
+               // delete avatars
+               $avatarIDs = array();
+               foreach ($this->objects as $user) {
+                       if ($user->avatarID) $avatarIDs[] = $user->avatarID;
+               }
+               if (!empty($avatarIDs)) {
+                       $action = new UserAvatarAction($avatarIDs, 'delete');
+                       $action->executeAction();
+               }
+               
+               // delete profile comments
+               if (!empty($this->objectIDs)) {
+                       $objectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.comment.commentableContent', 'com.woltlab.wcf.user.profileComment');
+                       $conditionBuilder = new PreparedStatementConditionBuilder();
+                       $conditionBuilder->add('objectTypeID = ?', array($objectType->objectTypeID));
+                       $conditionBuilder->add('objectID IN (?)', array($this->objectIDs));
+                       
+                       $sql = "DELETE FROM     wcf".WCF_N."_comment
+                               ".$conditionBuilder;
+                       $statement = WCF::getDB()->prepareStatement($sql);
+                       $statement->execute($conditionBuilder->getParameters());
+               }
+               
+               $returnValue = parent::delete();
+               
+               return $returnValue;
+       }
+       
        /**
         * Validates permissions and parameters.
         */
@@ -272,7 +310,9 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio
                }
        }
        
-       
+       /**
+        * Add users to given groups.
+        */
        public function addToGroups() {
                if (empty($this->objects)) {
                        $this->readObjects();