/**
  * Uninstalls the templates of this package.
  */
 public function uninstall()
 {
     // create templates list
     $templates = array();
     // get templates from log
     $sql = "SELECT\t*\n\t\t\tFROM\twcf" . WCF_N . "_template\n\t\t\tWHERE \tpackageID = " . $this->installation->getPackageID();
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $files[] = 'templates/' . $row['templateName'] . '.tpl';
     }
     if (count($files) > 0) {
         // delete template files
         $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $this->installation->getPackage()->getDir()));
         $deleteEmptyDirectories = $this->installation->getPackage()->isStandalone();
         $this->installation->deleteFiles($packageDir, $files, false, $deleteEmptyDirectories);
         // delete log entries
         parent::uninstall();
     }
 }
 /**
  * Uninstalls the files of this package.
  */
 public function uninstall()
 {
     // get absolute package dir
     $packageDir = FileUtil::addTrailingSlash(FileUtil::unifyDirSeperator(realpath(WCF_DIR . $this->installation->getPackage()->getDir())));
     // 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 = " . $this->installation->getPackageID();
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $files[] = $row['filename'];
     }
     if (count($files) > 0) {
         // delete files
         $this->installation->deleteFiles($packageDir, $files);
         // 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*\n\t\t\tFROM\twcf" . WCF_N . "_package_installation_sql_log\n\t\t\tWHERE\tpackageID = " . $this->installation->getPackageID();
     $result = WCF::getDB()->sendQuery($sql);
     $entries = array();
     while ($row = WCF::getDB()->fetchArray($result)) {
         $entries[] = $row;
     }
     // get all tablenames from database
     $existingTableNames = WCF::getDB()->getTablenames();
     // delete or alter tables
     foreach ($entries as $entry) {
         // don't alter table if it should be dropped
         if (!empty($entry['sqlColumn']) || !empty($entry['sqlIndex'])) {
             $isDropped = false;
             foreach ($entries as $entry_) {
                 if ($entry['sqlTable'] == $entry_['sqlTable'] && empty($entry_['sqlColumn']) && empty($entry_['sqlIndex'])) {
                     $isDropped = true;
                 }
             }
             if ($isDropped) {
                 continue;
             }
         }
         // drop table
         if (!empty($entry['sqlTable']) && empty($entry['sqlColumn']) && empty($entry['sqlIndex'])) {
             WCF::getDB()->sendQuery("DROP TABLE IF EXISTS " . $entry['sqlTable']);
         } elseif (in_array($entry['sqlTable'], $existingTableNames) && !empty($entry['sqlColumn']) && empty($entry['sqlIndex'])) {
             WCF::getDB()->sendQuery("ALTER TABLE \t`" . $entry['sqlTable'] . "` \n\t\t\t\t\t\t\t DROP COLUMN\t`" . $entry['sqlColumn']) . "`";
         } elseif (in_array($entry['sqlTable'], $existingTableNames) && empty($entry['sqlColumn']) && !empty($entry['sqlIndex'])) {
             WCF::getDB()->sendQuery("ALTER TABLE \t`" . $entry['sqlTable'] . "` \n\t\t\t\t\t\t\t DROP INDEX\t`" . $entry['sqlIndex']) . "`";
         }
     }
     // delete from log table
     parent::uninstall();
 }