Beispiel #1
0
 /**
  * @see wcf\page\IPage::show()
  */
 public function show()
 {
     parent::show();
     // check master password
     WCFACP::checkMasterPassword();
     switch ($this->action) {
         case 'install':
         case 'update':
             if ($this->action == 'install') {
                 WCF::getSession()->checkPermissions(array('admin.system.package.canInstallPackage'));
             } else {
                 WCF::getSession()->checkPermissions(array('admin.system.package.canUpdatePackage'));
             }
             $queue = new PackageInstallationQueue($this->queueID);
             $dispatcher = new PackageInstallationDispatcher($queue);
             $dispatcher->beginInstallation();
             break;
         case 'rollback':
             // TODO
             die('ROLLBACK');
             //WCF::getSession()->checkPermissions(array('admin.system.package.canInstallPackage'));
             break;
         case 'openQueue':
             PackageInstallationDispatcher::openQueue($this->parentQueueID, $this->processNo);
             break;
         case 'startUninstall':
             WCF::getSession()->checkPermissions(array('admin.system.package.canUninstallPackage'));
             PackageUninstallationDispatcher::checkDependencies();
             break;
     }
 }
 /**
  * Builds nodes for all dependent packages.
  */
 protected function buildDependentPackageNodes()
 {
     if (!PackageUninstallationDispatcher::hasDependencies($this->installation->queue->packageID)) {
         return;
     }
     $packageList = PackageUninstallationDispatcher::getOrderedPackageDependencies($this->installation->queue->packageID);
     $queue = $this->installation->queue;
     foreach ($packageList as $package) {
         $queue = PackageInstallationQueueEditor::create(array('processNo' => $queue->processNo, 'parentQueueID' => $queue->queueID, 'userID' => WCF::getUser()->userID, 'package' => $package->package, 'packageName' => $package->getName(), 'packageID' => $package->packageID, 'action' => 'uninstall'));
         // spawn nodes
         $uninstallation = new PackageUninstallationDispatcher($queue);
         $uninstallation->nodeBuilder->setParentNode($this->node);
         $uninstallation->nodeBuilder->buildNodes();
         $this->parentNode = $uninstallation->nodeBuilder->getCurrentNode();
         $this->node = $this->getToken();
     }
 }
 /**
  * Uninstalls the specified package.
  * $package may either be the packageID or the package identifier.
  * 
  * @param	mixed	$package
  */
 private function uninstall($package)
 {
     if (Package::isValidPackageName($package)) {
         $packageID = PackageCache::getInstance()->getPackageID($package);
     } else {
         $packageID = $package;
     }
     // UninstallPackageAction::prepare()
     $package = new Package($packageID);
     if (!$package->packageID || !$package->canUninstall()) {
         $this->error('invalidUninstallation');
     }
     // get new process no
     $processNo = PackageInstallationQueue::getNewProcessNo();
     // create queue
     $queue = PackageInstallationQueueEditor::create(array('processNo' => $processNo, 'userID' => CLIWCF::getUser()->userID, 'packageName' => $package->getName(), 'packageID' => $package->packageID, 'action' => 'uninstall'));
     // initialize uninstallation
     $installation = new PackageUninstallationDispatcher($queue);
     $installation->nodeBuilder->purgeNodes();
     $installation->nodeBuilder->buildNodes();
     CLIWCF::getTPL()->assign(array('queue' => $queue));
     $queueID = $installation->nodeBuilder->getQueueByNode($queue->processNo, $installation->nodeBuilder->getNextNode());
     $step = 'uninstall';
     $node = $installation->nodeBuilder->getNextNode();
     $currentAction = CLIWCF::getLanguage()->get('wcf.package.installation.step.uninstalling');
     $progress = 0;
     // initialize progressbar
     $progressbar = new ProgressBar(new ConsoleProgressBar(array('width' => CLIWCF::getTerminal()->getWidth(), 'elements' => array(ConsoleProgressBar::ELEMENT_PERCENT, ConsoleProgressBar::ELEMENT_BAR, ConsoleProgressBar::ELEMENT_TEXT), 'textWidth' => min(floor(CLIWCF::getTerminal()->getWidth() / 2), 50))));
     // InstallPackageAction::readParameters()
     $finished = false;
     while (!$finished) {
         $queue = new PackageInstallationQueue($queueID);
         $installation = new PackageUninstallationDispatcher($queue);
         switch ($step) {
             case 'uninstall':
                 $_node = $installation->uninstall($node);
                 if ($_node == '') {
                     // remove node data
                     $installation->nodeBuilder->purgeNodes();
                     // UninstallPackageAction::finalize()
                     CacheHandler::getInstance()->flushAll();
                     // /UninstallPackageAction::finalize()
                     // show success
                     $currentAction = CLIWCF::getLanguage()->get('wcf.acp.package.uninstallation.step.success');
                     $progress = 100;
                     $step = 'success';
                     $finished = true;
                     continue;
                 }
                 // continue with next node
                 $queueID = $installation->nodeBuilder->getQueueByNode($installation->queue->processNo, $installation->nodeBuilder->getNextNode($node));
                 $step = 'uninstall';
                 $progress = $installation->nodeBuilder->calculateProgress($node);
                 $node = $_node;
         }
         $progressbar->update($progress, $currentAction);
     }
     $progressbar->getAdapter()->finish();
 }