From: Alexander Ebert Date: Mon, 9 Feb 2015 09:57:58 +0000 (+0100) Subject: Fixed updating/deleting template groups incorrectly ignoring applications X-Git-Tag: 2.1.0_RC_1~51 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0890229e573e6ba101f7981694da04550866b11d;p=GitHub%2FWoltLab%2FWCF.git Fixed updating/deleting template groups incorrectly ignoring applications --- diff --git a/wcfsetup/install/files/lib/data/template/group/TemplateGroupEditor.class.php b/wcfsetup/install/files/lib/data/template/group/TemplateGroupEditor.class.php index 79428e4037..5433cb0e0f 100644 --- a/wcfsetup/install/files/lib/data/template/group/TemplateGroupEditor.class.php +++ b/wcfsetup/install/files/lib/data/template/group/TemplateGroupEditor.class.php @@ -2,14 +2,17 @@ namespace wcf\data\template\group; use wcf\data\DatabaseObjectEditor; use wcf\data\IEditableCachedObject; +use wcf\data\package\PackageCache; +use wcf\system\application\ApplicationHandler; use wcf\system\cache\builder\TemplateGroupCacheBuilder; +use wcf\system\WCF; use wcf\util\DirectoryUtil; /** * Provides functions to edit template groups. * * @author Marcel Werk - * @copyright 2001-2014 WoltLab GmbH + * @copyright 2001-2015 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.template.group @@ -29,6 +32,20 @@ class TemplateGroupEditor extends DatabaseObjectEditor implements IEditableCache if (isset($parameters['templateGroupFolderName']) && ($parameters['templateGroupFolderName'] != $this->templateGroupFolderName)) { @rename(WCF_DIR . 'templates/' . $this->templateGroupFolderName, WCF_DIR . 'templates/' . $parameters['templateGroupFolderName']); + + // check template group folders in other applications + $sql = "SELECT DISTINCT application + FROM wcf".WCF_N."_template + WHERE templateGroupID = ? + AND application <> ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($this->templateGroupID, 'wcf')); + while ($row = $statement->fetchArray()) { + $application = ApplicationHandler::getInstance()->getApplication($row['application']); + $package = PackageCache::getInstance()->getPackage($application->packageID); + + @rename(WCF_DIR . $package->packageDir . 'templates/' . $this->templateGroupFolderName, WCF_DIR . $package->packageDir . 'templates/' . $parameters['templateGroupFolderName']); + } } } @@ -54,6 +71,22 @@ class TemplateGroupEditor extends DatabaseObjectEditor implements IEditableCache if (file_exists(WCF_DIR . 'templates/' . $this->templateGroupFolderName)) { DirectoryUtil::getInstance(WCF_DIR . 'templates/' . $this->templateGroupFolderName)->removeAll(); } + + // check template group folders in other applications + $sql = "SELECT DISTINCT application + FROM wcf".WCF_N."_template + WHERE templateGroupID = ? + AND application <> ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($this->templateGroupID, 'wcf')); + while ($row = $statement->fetchArray()) { + $application = ApplicationHandler::getInstance()->getApplication($row['application']); + $package = PackageCache::getInstance()->getPackage($application->packageID); + + if (file_exists(WCF_DIR . $package->packageDir . 'templates/' . $this->templateGroupFolderName)) { + DirectoryUtil::getInstance(WCF_DIR . $package->packageDir . 'templates/' . $this->templateGroupFolderName)->removeAll(); + } + } } /**