/** * @see PackageInstallationPlugin::uninstall() */ public function uninstall() { // call uninstall event EventHandler::fireAction($this, 'uninstall'); // get container types $containerTypes = array(); $sql = "SELECT\tcontainerType\n\t\t\tFROM\twcf" . WCF_N . "_" . $this->tableName . "\n\t\t\tWHERE\tpackageID = " . $this->installation->getPackageID(); $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $containerTypes[] = $row['containerType']; } if (count($containerTypes)) { require_once WCF_DIR . 'lib/data/attachment/AttachmentEditor.class.php'; // delete attachments (files) $sql = "SELECT\t*\n\t\t\t\tFROM\twcf" . WCF_N . "_attachment\n\t\t\t\tWHERE\tpackageID = " . $this->installation->getPackageID() . "\n\t\t\t\t\tAND containerType IN ('" . implode("','", array_map('escapeString', $containerTypes)) . "')"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $attachment = new AttachmentEditor(null, $row); $attachment->deleteFile(); } // delete attachments (rows) $sql = "DELETE FROM\twcf" . WCF_N . "_attachment\n\t\t\t\tWHERE\t\tpackageID = " . $this->installation->getPackageID() . "\n\t\t\t\t\t\tAND containerType IN ('" . implode("','", array_map('escapeString', $containerTypes)) . "')"; WCF::getDB()->sendQuery($sql); // delete container $sql = "DELETE FROM\twcf" . WCF_N . "_" . $this->tableName . "\n\t\t\t\tWHERE\t\tpackageID = " . $this->installation->getPackageID(); WCF::getDB()->sendQuery($sql); } }