Fixes issues with templates
authorMatthias Schmidt <gravatronics@live.com>
Sun, 19 May 2013 13:25:18 +0000 (15:25 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 19 May 2013 13:25:18 +0000 (15:25 +0200)
wcfsetup/install/files/lib/acp/form/TemplateAddForm.class.php
wcfsetup/setup/db/install.sql

index f1b3dbdcca4b7f39c3635b4e47fbcf1149e27b93..fe3918cee617f3c7701a2bc8751715c70c179189 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 namespace wcf\acp\form;
+use wcf\data\package\Package;
+use wcf\data\package\PackageCache;
 use wcf\data\template\group\TemplateGroup;
 use wcf\data\template\group\TemplateGroupAction;
 use wcf\data\template\group\TemplateGroupList;
@@ -74,6 +76,12 @@ class TemplateAddForm extends AbstractForm {
         */
        public $copiedTemplate = null;
        
+       /**
+        * application the template belongs to
+        * @var string
+        */
+       public $application = '';
+       
        /**
         * @see wcf\page\IPage::readParameters()
         */
@@ -87,6 +95,7 @@ class TemplateAddForm extends AbstractForm {
                                throw new IllegalLinkException();
                        }
                        
+                       $this->application = $this->copiedTemplate->application;
                        $this->packageID = $this->copiedTemplate->packageID;
                }
        }
@@ -173,7 +182,12 @@ class TemplateAddForm extends AbstractForm {
        public function save() {
                parent::save();
                
+               if (empty($this->application)) {
+                       $this->application = Package::getAbbreviation(PackageCache::getInstance()->getPackage($this->package));
+               }
+               
                $this->objectAction = new TemplateAction(array(), 'create', array('data' => array(
+                       'application' => $this->application,
                        'templateName' => $this->tplName,
                        'packageID' => $this->packageID,
                        'templateGroupID' => $this->templateGroupID
index 3930441adec03c03104312a787857126e6d1d7cf..df1b8d6edff8eabde233792333c6ea986226b442 100644 (file)
@@ -589,8 +589,8 @@ CREATE TABLE wcf1_template (
        application VARCHAR(255) NOT NULL,
        templateGroupID INT(10),
        lastModificationTime INT(10) NOT NULL DEFAULT 0,
-       UNIQUE KEY applicationTemplate (application, templateName),
-       UNIQUE KEY templateGroupID (application, templateGroupID, templateName)
+       UNIQUE KEY applicationTemplate (application, templateGroupID, templateName),
+       KEY templateGroupID (packageID, templateGroupID, templateName)
 );
 
 DROP TABLE IF EXISTS wcf1_template_group;