/** * Uninstalls a package. * * @param bool $installDump When TRUE, the sql dump will be importet * * @throws rex_functional_exception * * @return bool TRUE on success, FALSE on error */ public function uninstall($installDump = true) { $isActivated = $this->package->isActivated(); if ($isActivated && !$this->deactivate()) { return false; } try { $this->package->setProperty('install', false); // include uninstall.php if (is_readable($this->package->getPath(rex_package::FILE_UNINSTALL))) { if (!$isActivated) { rex_i18n::addDirectory($this->package->getPath('lang')); } $this->package->includeFile(rex_package::FILE_UNINSTALL); if (($instmsg = $this->package->getProperty('installmsg', '')) != '') { throw new rex_functional_exception($instmsg); } if ($this->package->isInstalled()) { throw new rex_functional_exception($this->i18n('no_reason')); } } // import uninstall.sql $uninstallSql = $this->package->getPath(rex_package::FILE_UNINSTALL_SQL); if ($installDump === true && is_readable($uninstallSql)) { rex_sql_util::importDump($uninstallSql); } // delete assets $assets = $this->package->getAssetsPath(); if (is_dir($assets) && !rex_dir::delete($assets)) { throw new rex_functional_exception($this->i18n('install_cant_delete_files')); } rex_config::removeNamespace($this->package->getPackageId()); $this->saveConfig(); $this->message = $this->i18n('uninstalled', $this->package->getName()); return true; } catch (rex_functional_exception $e) { $this->message = $e->getMessage(); } catch (rex_sql_exception $e) { $this->message = 'SQL error: ' . $e->getMessage(); } $this->package->setProperty('install', true); if ($isActivated) { $this->package->setProperty('status', true); } $this->saveConfig(); $this->message = $this->i18n('no_uninstall', $this->package->getName()) . '<br />' . $this->message; return false; }