예제 #1
0
 /**
  * Saves the stack of package installations in the package installation queue table.
  */
 public function savePackageInstallationStack()
 {
     // get new process no
     require_once WCF_DIR . 'lib/acp/package/PackageInstallationQueue.class.php';
     $processNo = PackageInstallationQueue::getNewProcessNo();
     // build inserts
     $inserts = '';
     foreach ($this->packageInstallationStack as $package) {
         // unzip tar
         $package['archive'] = PackageArchive::unzipPackageArchive($package['archive']);
         if (!empty($inserts)) {
             $inserts .= ',';
         }
         $inserts .= "(" . $processNo . ", " . WCF::getUser()->userID . ", '" . escapeString($package['package']) . "', " . $package['packageID'] . ", '" . escapeString($package['archive']) . "', '" . escapeString($package['action']) . "')";
     }
     // save inserts
     if (!empty($inserts)) {
         $sql = "INSERT INTO\twcf" . WCF_N . "_package_installation_queue\n\t\t\t\t\t\t(processNo, userID, package, packageID, archive, action)\n\t\t\t\tVALUES\t\t" . $inserts;
         WCF::getDB()->sendQuery($sql);
     }
     return $processNo;
 }
 /**
  * Installs the requirements of the current package.
  * 
  * Inserts needed package installations or updates into the package installation queue.
  * Returns true, if no package installations are needed. Otherwise false.
  * 
  * @return	boolean
  */
 protected function installPackageRequirements()
 {
     // build queue inserts
     $queueInserts = '';
     foreach ($this->packageArchive->getOpenRequirements() as $requirement) {
         // the required package was not found
         // so the installation will be canceled
         if (!isset($requirement['file'])) {
             if (isset($requirement['minversion']) && !empty($requirement['packageID'])) {
                 throw new SystemException("required package '" . $requirement['name'] . "' in needed version '" . $requirement['minversion'] . "' not found.", 13006);
             } else {
                 throw new SystemException("required package '" . $requirement['name'] . "' not found.", 13006);
             }
         }
         // check the given filename
         if (!FileUtil::isURL($requirement['file'])) {
             // filename is no url
             // required package is delivered with this package
             $requirement['file'] = $this->packageArchive->extractTar($requirement['file'], 'requiredPackage_');
             // unzip tar
             $requirement['file'] = PackageArchive::unzipPackageArchive($requirement['file']);
         }
         if (!empty($queueInserts)) {
             $queueInserts .= ',';
         }
         $action = $requirement['action'];
         $cancelable = $action == 'install' && $this->getAction() == 'install' ? 1 : 0;
         $queueInserts .= "(" . $this->queueID . ", " . $this->processNo . ", " . WCF::getUser()->userID . ", '" . escapeString($requirement['name']) . "', " . $requirement['packageID'] . ", '" . escapeString($requirement['file']) . "', '" . $action . "', 'requirement', " . $cancelable . ")";
     }
     // insert needed installations or updates
     if (!empty($queueInserts)) {
         $sql = "INSERT INTO\twcf" . WCF_N . "_package_installation_queue\n\t\t\t\t\t\t(parentQueueID, processNo, userID, package, packageID, archive, action, packageType, cancelable)\n\t\t\t\tVALUES\t\t" . $queueInserts;
         WCF::getDB()->sendQuery($sql);
         return false;
     }
     return true;
 }