/**
  * Deletes the messages with the given message ids.
  * 
  * @param	string		$pmIDs
  */
 public static function deleteAll($pmIDs)
 {
     // get message data
     $sql = "SELECT\t\trecipients.recipientID, recipients.isDeleted,\n\t\t\t\t\tpm.pmID, pm.userID, pm.saveInOutbox\n\t\t\tFROM \t\twcf" . WCF_N . "_pm pm\n\t\t\tLEFT JOIN \twcf" . WCF_N . "_pm_to_user recipients\n\t\t\tON \t\t(recipients.pmID = pm.pmID\n\t\t\t\t\tAND recipients.recipientID = " . WCF::getUser()->userID . "\n\t\t\t\t\tAND recipients.isDeleted < 2)\n\t\t\tWHERE \t\tpm.pmID IN (" . $pmIDs . ")";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         if ($row['userID'] == WCF::getUser()->userID && $row['saveInOutbox'] == 1) {
             // remove from outbox
             $sql = "UPDATE\twcf" . WCF_N . "_pm\n\t\t\t\t\tSET\tsaveInOutbox = 0\n\t\t\t\t\tWHERE\tpmID = " . $row['pmID'];
             WCF::getDB()->sendQuery($sql);
         }
         if (isset($row['recipientID'])) {
             // move to trash or mark as deleted completely
             $sql = "UPDATE\twcf" . WCF_N . "_pm_to_user\n\t\t\t\t\tSET\tisDeleted = " . ($row['isDeleted'] == 0 ? 1 : 2) . "\n\t\t\t\t\tWHERE\tpmID = " . $row['pmID'] . "\n\t\t\t\t\t\tAND recipientID = " . WCF::getUser()->userID;
             WCF::getDB()->sendQuery($sql);
         }
     }
     // update message count
     PM::updateTotalMessageCount(WCF::getUser()->userID);
     PM::updateUnreadMessageCount(WCF::getUser()->userID);
     Session::resetSessions(WCF::getUser()->userID);
     // delete messages completely
     $deletePmIDs = '';
     $sql = "SELECT\t\tpm.pmID,\n\t\t\t\t\tCOUNT(recipients.recipientID) AS count\n\t\t\tFROM\t\twcf" . WCF_N . "_pm pm\n\t\t\tLEFT JOIN \twcf" . WCF_N . "_pm_to_user recipients\n\t\t\tON \t\t(recipients.pmID = pm.pmID\n\t\t\t\t\tAND recipients.isDeleted < 2)\n\t\t\tWHERE \t\tpm.pmID IN (" . $pmIDs . ")\n\t\t\t\t\tAND saveInOutbox = 0\n\t\t\tGROUP BY\tpm.pmID\n\t\t\tHAVING \t\tcount = 0";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         if (!empty($deletePmIDs)) {
             $deletePmIDs .= ',';
         }
         $deletePmIDs .= $row['pmID'];
     }
     if (!empty($deletePmIDs)) {
         self::deleteData($deletePmIDs);
         self::unmark(explode(',', $deletePmIDs));
     }
 }