/** * @see \wcf\form\IForm::save() */ public function save() { parent::save(); // get new process no $processNo = PackageInstallationQueue::getNewProcessNo(); // obey foreign key $packageID = $this->package ? $this->package->packageID : null; $archive = $this->downloadPackage; if ($this->stylePackageImportLocation) { $archive = $this->stylePackageImportLocation; } else { if (!empty($this->uploadPackage['tmp_name'])) { $archive = $this->uploadPackage['name']; } } // insert queue $isApplication = PackageValidationManager::getInstance()->getPackageValidationArchive()->getArchive()->getPackageInfo('isApplication'); $this->queue = PackageInstallationQueueEditor::create(array('processNo' => $processNo, 'userID' => WCF::getUser()->userID, 'package' => PackageValidationManager::getInstance()->getPackageValidationArchive()->getArchive()->getPackageInfo('name'), 'packageName' => PackageValidationManager::getInstance()->getPackageValidationArchive()->getArchive()->getLocalizedPackageInfo('packageName'), 'packageID' => $packageID, 'archive' => $archive, 'action' => $this->package != null ? 'update' : 'install', 'isApplication' => !$isApplication ? '0' : '1')); $this->saved(); // open queue PackageInstallationDispatcher::openQueue(0, $processNo); }
/** * Validates if an installed package excludes the current package and vice versa. * * @param string $package */ protected function validateExclusion($package) { $packageVersion = $this->archive->getPackageInfo('version'); // excluding packages: installed -> current $sql = "SELECT\t\tpackage.*, package_exclusion.*\n\t\t\tFROM\t\twcf" . WCF_N . "_package_exclusion package_exclusion\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_package package\n\t\t\tON\t\t(package.packageID = package_exclusion.packageID)\n\t\t\tWHERE\t\texcludedPackage = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($this->getArchive()->getPackageInfo('name'))); $excludingPackages = array(); while ($row = $statement->fetchArray()) { $excludingPackage = $row['package']; // use exclusions of queued package if (isset(self::$excludedPackages[$excludingPackage])) { if (isset(self::$excludedPackages[$excludingPackage][$package])) { for ($i = 0, $count = count(self::$excludedPackages[$excludingPackage][$package]); $i < $count; $i++) { if (Package::compareVersion($packageVersion, self::$excludedPackages[$excludingPackage][$package][$i], '<')) { continue; } $excludingPackages[] = new Package(null, $row); } continue; } } else { if (Package::compareVersion($packageVersion, $row['excludedPackageVersion'], '<')) { continue; } $excludingPackages[] = new Package(null, $row); } } if (!empty($excludingPackages)) { throw new PackageValidationException(PackageValidationException::EXCLUDING_PACKAGES, array('packages' => $excludingPackages)); } // excluded packages: current -> installed if (!empty(self::$excludedPackages[$package])) { // get installed packages $conditions = new PreparedStatementConditionBuilder(); $conditions->add("package IN (?)", array(array_keys(self::$excludedPackages[$package]))); $sql = "SELECT\t*\n\t\t\t\tFROM\twcf" . WCF_N . "_package\n\t\t\t\t" . $conditions; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute($conditions->getParameters()); $packages = array(); while ($row = $statement->fetchArray()) { $packages[$row['package']] = new Package(null, $row); } $excludedPackages = array(); foreach ($packages as $excludedPackage => $packageObj) { $version = PackageValidationManager::getInstance()->getVirtualPackage($excludedPackage); if ($version === null) { $version = $packageObj->packageVersion; } for ($i = 0, $count = count(self::$excludedPackages[$package][$excludedPackage]); $i < $count; $i++) { if (Package::compareVersion($version, self::$excludedPackages[$package][$excludedPackage][$i], '<')) { continue; } $excludedPackages[] = $packageObj; } } if (!empty($excludedPackages)) { throw new PackageValidationException(PackageValidationException::EXCLUDED_PACKAGES, array('packages' => $excludedPackages)); } } }
/** * @see \wcf\page\IPage::assignVariables() */ public function assignVariables() { parent::assignVariables(); WCF::getTPL()->assign(array('archive' => $this->packageInstallationDispatcher->getArchive(), 'packageValidationArchives' => PackageValidationManager::getInstance()->getPackageValidationArchiveList(), 'queue' => $this->queue, 'validationPassed' => $this->validationPassed, 'installingImportedStyle' => $this->installingImportedStyle)); }