/** * @see PackageInstallationPlugin::install() */ public function install() { parent::install(); // extract the file containing the patches (the 'diff') directly to a string ... $patchFileName = $this->installation->getXMLTag($this->tagName); // get the attribute containing the fuzz factor value. $fuzzFactor = 2; $instructions = $this->installation->getArchive()->getInstructions('install'); foreach ($instructions as $key => $instruction) { if ($key == $this->tagName && isset($instruction['fuzzfactor']) && $instruction['fuzzfactor']) { $fuzzFactor = $instruction['fuzzfactor']; break; } } $patchFileString = $this->installation->getArchive()->getTar()->extractToString($patchFileName['cdata']); // ... and pass that string to a new object instance of TemplatePatch.class. require_once WCF_DIR . 'lib/system/template/patch/TemplatePatch.class.php'; try { $patchObject = new TemplatePatch($this->installation->getPackageID(), $patchFileString, false, false, 0, $this->type, $fuzzFactor); } catch (TemplatePatchException $e) { // be a bit more friendly to the user. WCF::getTPL()->assign(array('errorCode' => $e->getCode(), 'errorMessage' => $e->getMessage(), 'affectedTemplateName' => $e->getTemplateName())); WCF::getTPL()->display('packageInstallationPatchFailed'); exit; } }
/** * Installs the templates of this package. */ public function install() { parent::install(); // extract files.tar to temp folder $tag = $this->installation->getXMLTag('templates'); $sourceFile = $this->installation->getArchive()->extractTar($tag['cdata'], 'templates_'); // create file handler $fileHandler = new TemplatesFileHandler($this->installation); // extract content of files.tar $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $this->installation->getPackage()->getDir())); try { $fileInstaller = $this->installation->extractFiles($packageDir . 'templates/', $sourceFile, $fileHandler); } catch (SystemException $e) { if (!@file_exists(WCF_DIR . 'acp/templates/packageInstallationFileInstallationFailed.tpl')) { // workaround for wcf 1.0 to 1.1 update throw $e; } else { WCF::getTPL()->assign(array('exception' => $e)); WCF::getTPL()->display('packageInstallationFileInstallationFailed'); exit; } } // look if tpl files are to be overwritten by this update, // and if so, check if these files have been patched before ... require_once WCF_DIR . 'lib/acp/package/plugin/TemplatePatchPackageInstallationPlugin.class.php'; $tar = new Tar($sourceFile); $files = $tar->getContentList(); $templatePatch = new TemplatePatchPackageInstallationPlugin($this->installation); $templatePatch->repatch($files); // delete temporary sourceArchive @unlink($sourceFile); }
/** * @see PackageInstallationPlugin::install() */ public function install() { parent::install(); require_once WCF_DIR . 'lib/data/style/StyleEditor.class.php'; $instructions = $this->installation->getInstructions(); $styles = $instructions['style']; if (count($styles) && isset($styles['cdata'])) { $styles = array($styles); } // Install each <style>-tag from package.xml foreach ($styles as $styleData) { // extract style tar from package archive // No <style>-tag in the instructions in package.xml if (!isset($styleData['cdata']) || !$styleData['cdata']) { return false; } // extract style tar $filename = $this->installation->getArchive()->extractTar($styleData['cdata'], 'style_'); // import style $style = StyleEditor::import($filename, $this->installation->getPackageID()); // set wcf basic style as default if (isset($styleData['default'])) { $style->setAsDefault(); } // delete tmp file @unlink($filename); } }
/** * @see PackageInstallationPlugin::install() */ public function install() { parent::install(); $dir = $this->installation->getPackage()->getDir(); if (empty($dir)) { if ($this->installation->getPackage()->getParentPackageID() > 0) { // plugin // use parents package dir $dir = $this->installation->getPackage()->getParentPackage()->getDir(); } else { if ($this->installation->getPackage()->isStandalone() == 1 && $this->installation->getPackage()->getPackage() != 'com.woltlab.wcf' && $this->installation->getAction() == 'install') { // standalone package // prompt package dir $dir = $this->promptPackageDir(); } } // save package dir if (!empty($dir)) { $sql = "UPDATE\twcf" . WCF_N . "_package\n\t\t\t\t\tSET\tpackageDir = '" . escapeString($dir) . "'\n\t\t\t\t\tWHERE\tpackageID = " . $this->installation->getPackageID(); WCF::getDB()->sendQuery($sql); $this->installation->getPackage()->setDir($dir); } } // absolute path to package dir $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $dir)); // extract files.tar to temp folder $tag = $this->installation->getXMLTag('files'); $sourceFile = $this->installation->getArchive()->extractTar($tag['cdata'], 'files_'); // create file handler $fileHandler = new FilesFileHandler($this->installation); // extract content of files.tar try { $fileInstaller = $this->installation->extractFiles($packageDir, $sourceFile, $fileHandler); } catch (SystemException $e) { if (!@file_exists(WCF_DIR . 'acp/templates/packageInstallationFileInstallationFailed.tpl')) { // workaround for wcf 1.0 to 1.1 update throw $e; } else { WCF::getTPL()->assign(array('exception' => $e)); WCF::getTPL()->display('packageInstallationFileInstallationFailed'); exit; } } // if this a standalone package, write config.inc.php for this package if ($this->installation->getPackage()->isStandalone() == 1 && $this->installation->getPackage()->getPackage() != 'com.woltlab.wcf' && $this->installation->getAction() == 'install') { // touch file $fileInstaller->touchFile(PackageInstallation::CONFIG_FILE); // create file Package::writeConfigFile($this->installation->getPackageID()); // log file $sql = "INSERT INTO\twcf" . WCF_N . "_package_installation_file_log\n\t\t\t\t\t\t(packageID, filename)\n\t\t\t\tVALUES\t\t(" . $this->installation->getPackageID() . ", 'config.inc.php')"; WCF::getDB()->sendQuery($sql); } // delete temporary sourceArchive @unlink($sourceFile); // update acp style file StyleUtil::updateStyleFile(); }
/** * Runs a script. */ public function install() { parent::install(); // get installation path of package $sql = "SELECT\tpackageDir\n\t\t\tFROM\twcf" . WCF_N . "_package\n\t\t\tWHERE\tpackageID = " . $this->installation->getPackageID(); $packageDir = WCF::getDB()->getFirstRow($sql); $packageDir = $packageDir['packageDir']; // get relative path of script $scriptTag = $this->installation->getXMLTag('script'); $path = FileUtil::getRealPath(WCF_DIR . $packageDir); // run script $this->run($path . $scriptTag['cdata']); // delete script if (@unlink($path . $scriptTag['cdata'])) { // delete file log entry $sql = "DELETE FROM\twcf" . WCF_N . "_package_installation_file_log\n\t\t\t\tWHERE\t\tpackageID = " . $this->installation->getPackageID() . "\n\t\t\t\t\t\tAND filename = '" . escapeString($scriptTag['cdata']) . "'"; WCF::getDB()->sendQuery($sql); } }
/** * Installs the templates of this package. */ public function install() { parent::install(); // extract files.tar to temp folder $tag = $this->installation->getXMLTag('templates'); $sourceFile = $this->installation->getArchive()->extractTar($tag['cdata'], 'templates_'); // create file handler $fileHandler = new TemplatesFileHandler($this->installation); // extract content of files.tar $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $this->installation->getPackage()->getDir())); $fileInstaller = $this->installation->extractFiles($packageDir . 'templates/', $sourceFile, $fileHandler); // look if tpl files are to be overwritten by this update, // and if so, check if these files have been patched before ... require_once WCF_DIR . 'lib/acp/package/plugin/TemplatePatchPackageInstallationPlugin.class.php'; $tar = new Tar($sourceFile); $files = $tar->getContentList(); $templatePatch = new TemplatePatchPackageInstallationPlugin($this->installation); $templatePatch->repatch($files); // delete temporary sourceArchive @unlink($sourceFile); }
/** * Installs sql tables, columns or indeces. */ public function install() { parent::install(); // extract sql file from archive if ($this->sqlStr = $this->readSQL($this->installation)) { $standalonePackage = $this->installation->getPackage(); if ($standalonePackage->getParentPackageID()) { // package is a plugin; get parent package $standalonePackage = $standalonePackage->getParentPackage(); } if ($standalonePackage->isStandalone() == 1) { // package is standalone $packageAbbr = $standalonePackage->getAbbreviation(); $tablePrefix = WCF_N . '_' . $standalonePackage->getInstanceNo() . '_'; // Replace the variable xyz1_1 with $tablePrefix in the table names. $this->sqlStr = str_replace($packageAbbr . '1_1_', $packageAbbr . $tablePrefix, $this->sqlStr); } // replace wcf1_ with the actual WCF_N value $this->sqlStr = str_replace("wcf1_", "wcf" . WCF_N . "_", $this->sqlStr); // replace charset configuration if (Database::$dbCharsets[CHARSET] != 'utf8') { $this->sqlStr = str_replace('DEFAULT CHARSET=utf8', 'DEFAULT CHARSET=' . Database::$dbCharsets[CHARSET], $this->sqlStr); } // get dontAskAgain value from session $handleType = WCF::getSession()->getVar('overrideTablesUserDescission'); $isSetInSession = false; if (empty($handleType)) { $handleType = 'askAgain'; } else { $isSetInSession = true; } // check if user decided to not show him again conflicted tables if (isset($_POST['dontAskAgainOverride'])) { $handleType = $_POST['dontAskAgainOverride'] ? 'dontAskAgainOverride' : 'askAgain'; } elseif (isset($_POST['dontAskAgainKeep'])) { $handleType = $_POST['dontAskAgainKeep'] ? 'dontAskAgainKeep' : 'askAgain'; } if ($handleType == 'dontAskAgainKeep') { $this->keepAll = true; } // store in session if (!$isSetInSession && $handleType != 'askAgain') { WCF::getSession()->register('overrideTablesUserDescission', $handleType); WCF::getSession()->update(); Session::resetSessions(); } // check and edit (if a table should not be overwritten) sql string $this->checkSQL($this->installation->getPackageID(), $this->installation->getAction()); // display overrides template if ($handleType == 'askAgain' && !isset($_POST['overrideTables']) && count($this->overrideTables) > 0) { // rearrange array. store each table just one time foreach ($this->overrideTables as $table) { $tmp[$table['tableName']][] = $table['overrideType']; } $this->overrideTables = array(); // make an indexed array for the javascript funktion selectAll foreach ($tmp as $tableName => $table) { $this->overrideTables[] = array('tableName' => $tableName, 'overrideTypes' => $table); } WCF::getTPL()->assign('tables', $this->overrideTables); WCF::getTPL()->display('packageInstallationCheckOverrideTables'); exit; } // execute queries QueryParser::sendQueries($this->sqlStr, $this->installation->getPackageID()); } }