/** * Creates a new FTPUninstaller object. * * @param string $targetDir directory from the deleting files * @param array $files delete files * @param FTP $ftp active ftp connection * @param boolean $deleteEmptyTargetDir delete target dir if empty * @param boolean $deleteEmptyDirectories delete sub-directories if empty */ public function __construct($targetDir, $files, FTP $ftp, $deleteEmptyTargetDir, $deleteEmptyDirectories) { $this->ftp = $ftp; $this->ftpPath = FTPUtil::getRelativeFtpPath($this->ftp, $targetDir); if (!$this->ftpPath) { throw new SystemException(WCF::getLanguage()->get('warnings.couldNotFindFTPPath', array('{$dir}' => $targetDir))); } parent::__construct($this->ftpPath, $files, $deleteEmptyTargetDir, $deleteEmptyDirectories); }
/** * Install packages slated for installation during transaction */ static function commit() { if (self::$inTransaction === false) { return false; } $installer = new Uninstaller; // validate dependencies $errs = new \PEAR2\MultiErrors; $reg = Config::current()->registry; try { foreach (self::$uninstallPackages as $package) { $package->validateUninstallDependencies(self::$uninstallPackages, $errs); } if (count($errs->E_ERROR)) { throw new Installer\Exception('Dependency validation failed ' . 'for some installed packages, installation aborted', $errs); } // create dependency connections and load them into the directed graph $graph = new DirectedGraph; foreach (self::$uninstallPackages as $package) { $package->makeUninstallConnections($graph, self::$uninstallPackages); } // topologically sort packages and install them via iterating over the graph $actual = array(); foreach ($graph as $package) { $actual[] = $package; } // easy reverse topological sort array_reverse($actual); AtomicFileTransaction::begin(); $reg->begin(); try { foreach ($actual as $package) { $installer->uninstall($package, $reg); self::$uninstalledPackages[] = $package; } $dirtrees = array(); foreach (self::$uninstalledPackages as $package) { $dirtrees[] = $reg->info($package->name, $package->channel, 'dirtree'); $previous = $reg->toPackageFile($package->name, $package->channel, true); self::$registeredPackages[] = array($package, $previous); $reg->uninstall($package->name, $package->channel); } AtomicFileTransaction::rmEmptyDirs($dirtrees); AtomicFileTransaction::commit(); $reg->commit(); AtomicFileTransaction::removeBackups(); } catch (\Exception $e) { if (AtomicFileTransaction::inTransaction()) { AtomicFileTransaction::rollback(); } $reg->rollback(); throw $e; } self::$uninstallPackages = array(); Config::current()->saveConfig(); if (isset(Main::$options['install-plugins'])) { Config::setCurrent(self::$lastCurrent->path); } } catch (\Exception $e) { self::rollback(); throw $e; } }
public function uninstall_9() { if ($this->accessAdminPage(2)) { require_once dirname(__FILE__) . '/resources/uninstall.php'; $uninstaller = new Uninstaller($this->parent); return $uninstaller->uninstall(9); } else { $this->parent->parent->addHeader('Location', '/admin/modules/'); return new ActionResult($this, '/admin/modules/', 1, 'You are not allowed to do that', B_T_FAIL); } }
/** * Installer::_revertInstall() * * @return */ private function _revertInstall() { $this->parent->parent->debug($this::name_space . ': Reverting install...'); // Include the uninstaller (lazy again) require_once dirname(__FILE__) . '/uninstall.php'; $uninstaller = new Uninstaller($this->parent); if ($this->step === null) { return false; } // Fetch the module ID (if applicable) as the uninstaller needs it $fetch_query = $this->mySQL_r->prepare("SELECT `module_id` FROM `core_modules` WHERE `namespace`=?"); if ($fetch_query !== false) { $fetch_query->bind_param('s', $this->namespace); $fetch_query->bind_result($MOD_ID); $fetch_query->execute(); $fetch_query->store_result(); if ($fetch_query->num_rows == 1) { while ($fetch_query->fetch()) { $mod_id = $MOD_ID; } } else { $mod_id = null; } $fetch_query->free_result(); } // Work out the details $dir = __MODULE__ . '/' . strtolower($this->namespace); $details = array('dir' => $dir, 'id' => $mod_id, 'ns' => $this->namespace); // Call the uninstall steps switch ($this->step) { case 7: case 6: $uninstaller->uninstall(3, $details); case 5: $uninstaller->uninstall(4, $details); case 4: $uninstaller->uninstall(6, $details); case 3: $uninstaller->uninstall(7, $details); case 2: $uninstaller->uninstall(8, $details); case 1: $this->parent->parent->debug($this::name_space . ': Removing "' . str_replace(__EXECDIR__, '', $this->tempModule) . '"'); WebApp::rmDir($this->tempModule); break; } }