/** * @see wcf\system\package\plugin\IPackageInstallationPlugin::uninstall() */ public function uninstall() { // create ACP-templates list $templates = array(); // get ACP-templates from log $sql = "SELECT * FROM wcf".WCF_N."_acp_template WHERE packageID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($this->installation->getPackageID())); while ($row = $statement->fetchArray()) { // store acp template with suffix (_$packageID) $templates[] = 'acp/templates/'.$row['templateName'].'.tpl'; } if (!empty($templates)) { // delete template files $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR.$this->installation->getPackage()->packageDir)); $deleteEmptyDirectories = $this->installation->getPackage()->isApplication; $this->installation->deleteFiles($packageDir, $templates, false, $deleteEmptyDirectories); // delete log entries parent::uninstall(); } }
/** * @see \wcf\system\package\plugin\IPackageInstallationPlugin::uninstall() */ public function uninstall() { // fetch ACP templates from log $sql = "SELECT\ttemplateName, application\n\t\t\tFROM\twcf" . WCF_N . "_acp_template\n\t\t\tWHERE\tpackageID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($this->installation->getPackageID())); $templates = array(); while ($row = $statement->fetchArray()) { if (!isset($templates[$row['application']])) { $templates[$row['application']] = array(); } $templates[$row['application']][] = 'acp/templates/' . $row['templateName'] . '.tpl'; } foreach ($templates as $application => $templateNames) { $this->installation->deleteFiles(Application::getDirectory($application), $templateNames, false, $this->installation->getPackage()->isApplication); // delete log entries parent::uninstall(); } }
/** * Uninstalls the templates of this package. */ public function uninstall() { // create templates list $templates = array(); // get templates from log $sql = "SELECT\ttemplateName\n\t\t\tFROM\twcf" . WCF_N . "_template\n\t\t\tWHERE \tpackageID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($this->installation->getPackageID())); while ($row = $statement->fetchArray()) { $templates[] = 'templates/' . $row['templateName'] . '.tpl'; } if (count($templates) > 0) { // delete template files $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $this->installation->getPackage()->packageDir)); $deleteEmptyDirectories = $this->installation->getPackage()->isApplication; $this->installation->deleteFiles($packageDir, $templates, false, $deleteEmptyDirectories); // delete log entries parent::uninstall(); } }
/** * Deletes the sql tables or columns which where installed by the package. */ public function uninstall() { // get logged sql tables/columns $sql = "SELECT\t\t*\n\t\t\tFROM\t\twcf" . WCF_N . "_package_installation_sql_log\n\t\t\tWHERE\t\tpackageID = ?\n\t\t\tORDER BY \tsqlIndex DESC, sqlColumn DESC"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($this->installation->getPackageID())); $entries = array(); while ($row = $statement->fetchArray()) { $entries[] = $row; } // get all tablenames from database $existingTableNames = WCF::getDB()->getEditor()->getTablenames(); // delete or alter tables foreach ($entries as $entry) { // don't alter table if it should be dropped if (!empty($entry['sqlColumn'])) { $isDropped = false; foreach ($entries as $entry2) { if ($entry['sqlTable'] == $entry2['sqlTable'] && empty($entry2['sqlColumn']) && empty($entry2['sqlIndex'])) { $isDropped = true; } } if ($isDropped) { continue; } } // drop table if (!empty($entry['sqlTable']) && empty($entry['sqlColumn']) && empty($entry['sqlIndex'])) { WCF::getDB()->getEditor()->dropTable($entry['sqlTable']); } else { if (in_array($entry['sqlTable'], $existingTableNames) && !empty($entry['sqlColumn'])) { WCF::getDB()->getEditor()->dropColumn($entry['sqlTable'], $entry['sqlColumn']); } else { if (in_array($entry['sqlTable'], $existingTableNames) && !empty($entry['sqlIndex'])) { if (substr($entry['sqlIndex'], -3) == '_fk') { WCF::getDB()->getEditor()->dropForeignKey($entry['sqlTable'], $entry['sqlIndex']); } else { WCF::getDB()->getEditor()->dropIndex($entry['sqlTable'], $entry['sqlIndex']); } } } } } // delete from log table parent::uninstall(); }
/** * @see \wcf\system\package\plugin\IPackageInstallationPlugin::uninstall() */ public function uninstall() { // fetch files from log $sql = "SELECT\tfilename, application\n\t\t\tFROM\twcf" . WCF_N . "_package_installation_file_log\n\t\t\tWHERE\tpackageID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($this->installation->getPackageID())); $files = array(); while ($row = $statement->fetchArray()) { if (!isset($files[$row['application']])) { $files[$row['application']] = array(); } $files[$row['application']][] = $row['filename']; } foreach ($files as $application => $filenames) { $this->installation->deleteFiles(Application::getDirectory($application), $filenames); // delete log entries parent::uninstall(); } }
/** * @see wcf\system\package\plugin\IPackageInstallationPlugin::uninstall() */ public function uninstall() { parent::uninstall(); // execute cleanup $this->cleanup(); }
/** * Uninstalls the files of this package. */ public function uninstall() { // get absolute package dir $packageDir = FileUtil::addTrailingSlash(FileUtil::unifyDirSeperator(realpath(WCF_DIR . $this->installation->getPackage()->packageDir))); // create file list $files = array(); // get files from log $sql = "SELECT\t*\n\t\t\tFROM\twcf" . WCF_N . "_package_installation_file_log\n\t\t\tWHERE \tpackageID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($this->installation->getPackageID())); while ($row = $statement->fetchArray()) { $files[] = $row['filename']; } if (count($files) > 0) { // delete files $this->installation->deleteFiles($packageDir, $files); // delete log entries parent::uninstall(); } }