Fixes packageID for copied templates
authorMatthias Schmidt <gravatronics@live.com>
Thu, 31 Oct 2013 13:58:53 +0000 (14:58 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 31 Oct 2013 13:58:53 +0000 (14:58 +0100)
wcfsetup/install/files/lib/acp/form/TemplateAddForm.class.php

index f9f1afbee58b1e7fb1ee9032d68b2ff5bcfd2d25..f238c1827a7d0d3d4640725031ae919e884c4b77 100644 (file)
@@ -110,15 +110,17 @@ class TemplateAddForm extends AbstractForm {
                if (isset($_POST['templateGroupID'])) $this->templateGroupID = intval($_POST['templateGroupID']);
                
                // get package id for this template
-               $sql = "SELECT  packageID
-                       FROM    wcf".WCF_N."_template
-                       WHERE   templateName = ?
-                               AND templateGroupID IS NULL";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute(array($this->tplName));
-               $row = $statement->fetchArray();
-               if ($row !== false) {
-                       $this->packageID = $row['packageID'];
+               if (!$this->packageID) {
+                       $sql = "SELECT  packageID
+                               FROM    wcf".WCF_N."_template
+                               WHERE   templateName = ?
+                                       AND templateGroupID IS NULL";
+                       $statement = WCF::getDB()->prepareStatement($sql);
+                       $statement->execute(array($this->tplName));
+                       $row = $statement->fetchArray();
+                       if ($row !== false) {
+                               $this->packageID = $row['packageID'];
+                       }
                }
        }