From 52528bd117ffa6aa6799b67363e508462cc0ab7f Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 24 Oct 2013 13:50:02 +0200 Subject: [PATCH] Added 'application' attribute for script-PIP --- .../ScriptPackageInstallationPlugin.class.php | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/wcfsetup/install/files/lib/system/package/plugin/ScriptPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ScriptPackageInstallationPlugin.class.php index b0b8ff6ff4..36abd12bc2 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ScriptPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ScriptPackageInstallationPlugin.class.php @@ -1,6 +1,8 @@ prepareStatement($sql); - $statement->execute(array($this->installation->getPackageID())); - $packageDir = $statement->fetchArray(); - $packageDir = $packageDir['packageDir']; + $abbreviation = 'wcf'; + if (isset($this->instruction['attributes']['application'])) { + $abbreviation = $this->instruction['attributes']['application']; + } + else if ($this->installation->getPackage()->isApplication) { + $abbreviation = Package::getAbbreviation($this->installation->getPackage()->package); + } - // get relative path of script - $path = FileUtil::getRealPath(WCF_DIR.$packageDir); + $dirConstant = strtoupper($abbreviation) . '_DIR'; + if (!defined($dirConstant)) { + throw new SystemException("Can not execute script-PIP, abbreviation '".$abbreviation."' is unknown"); + } // reset WCF cache CacheHandler::getInstance()->flushAll(); // run script - $this->run($path.$this->instruction['value']); + $this->run(constant($dirConstant).$this->instruction['value']); // delete script - if (@unlink($path.$this->instruction['value'])) { + if (@unlink(constant($dirConstant).$this->instruction['value'])) { // delete file log entry $sql = "DELETE FROM wcf".WCF_N."_package_installation_file_log WHERE packageID = ? -- 2.20.1