Add email template group
authorTim Düsterhus <duesterhus@woltlab.com>
Mon, 30 May 2016 13:43:52 +0000 (15:43 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Mon, 30 May 2016 14:04:37 +0000 (16:04 +0200)
wcfsetup/install/files/acp/templates/templateGroupList.tpl
wcfsetup/install/files/acp/update_com.woltlab.wcf_2.2.0.php
wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php
wcfsetup/install/files/lib/acp/form/TemplateGroupAddForm.class.php
wcfsetup/install/files/lib/acp/form/TemplateGroupEditForm.class.php
wcfsetup/install/files/lib/data/template/group/TemplateGroup.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml
wcfsetup/setup/db/install.sql

index b729e7f9b52dbb531b0beefac5d0611619e253df..a7a3ff480db16ca0cda4cb0738f4b91cfb996450 100644 (file)
                                {foreach from=$objects item=templateGroup}
                                        <tr class="jsTemplateGroupRow">
                                                <td class="columnIcon">
-                                                       <a href="{link controller='TemplateGroupEdit' id=$templateGroup->templateGroupID}{/link}" title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip"><span class="icon icon16 fa-pencil"></span></a>
-                                                       <span class="icon icon16 fa-times jsDeleteButton jsTooltip pointer" title="{lang}wcf.global.button.delete{/lang}" data-object-id="{@$templateGroup->templateGroupID}" data-confirm-message-html="{lang __encode=true}wcf.acp.template.group.delete.sure{/lang}"></span>
+                                                       {if !$templateGroup->isImmutable()}
+                                                               <a href="{link controller='TemplateGroupEdit' id=$templateGroup->templateGroupID}{/link}" title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip"><span class="icon icon16 fa-pencil"></span></a>
+                                                               <span class="icon icon16 fa-times jsDeleteButton jsTooltip pointer" title="{lang}wcf.global.button.delete{/lang}" data-object-id="{@$templateGroup->templateGroupID}" data-confirm-message-html="{lang __encode=true}wcf.acp.template.group.delete.sure{/lang}"></span>
+                                                       {else}
+                                                               <span class="icon icon16 fa-pencil disabled" title="{lang}wcf.global.button.edit{/lang}"></span>
+                                                               <span class="icon icon16 fa-times disabled" title="{lang}wcf.global.button.delete{/lang}"></span>
+                                                       {/if}
                                                        
                                                        {event name='rowButtons'}
                                                </td>
                                                <td class="columnID">{@$templateGroup->templateGroupID}</td>
-                                               <td class="columnTitle columnTemplateGroupName"><a href="{link controller='TemplateGroupEdit' id=$templateGroup->templateGroupID}{/link}">{$templateGroup->templateGroupName}</a></td>
+                                               <td class="columnTitle columnTemplateGroupName">
+                                                       {if !$templateGroup->isImmutable()}
+                                                               <a href="{link controller='TemplateGroupEdit' id=$templateGroup->templateGroupID}{/link}">
+                                                                       {$templateGroup->getName()}
+                                                               </a>
+                                                       {else}
+                                                               {$templateGroup->getName()}
+                                                       {/if}
+                                               </td>
                                                <td class="columnText columnTemplateGroupFolderName">{$templateGroup->templateGroupFolderName}</td>
                                                <td class="columnDigits columnTemplates">{#$templateGroup->templates}</td>
                                                
index a65f514caf8cc6dd257de15616f1184556fff3a6..4de44701bec15a605b5240302e04d2e814c91729 100644 (file)
@@ -2,3 +2,4 @@
 
 // TODO:
 // 1. update label's show order
+// 2. If a template group uses '_wcf_email' as the folder: Move it!
index 39c0eb3734c425e652bcce2dd3c4f03b38378a9a..1df63dc6b1d328c48f9af76ed5d13c0408737084 100644 (file)
@@ -189,6 +189,7 @@ class StyleAddForm extends AbstractForm {
                
                $templateGroupList = new TemplateGroupList();
                $templateGroupList->sqlOrderBy = "templateGroupName";
+               $templateGroupList->getConditionBuilder()->add('templateGroupPath <> ?', ['_wcf_email/']);
                $templateGroupList->readObjects();
                $this->availableTemplateGroups = $templateGroupList->getObjects();
                
index 05aaebdc7d22dfdbc8cc0eed14a4e9d703ecb9c4..b269d4096bda238c015ff55d77597854558f6911 100644 (file)
@@ -151,8 +151,8 @@ class TemplateGroupAddForm extends AbstractForm {
         * @inheritDoc
         */
        public function readData() {
-               $this->availableTemplateGroups = TemplateGroup::getSelectList([], 1);
-
+               $this->availableTemplateGroups = TemplateGroup::getSelectList([-1], 1);
+               
                parent::readData();
        }
        
index f86da863d573b74462df851fcb3cae70724ef4ae..b5c915c5a154ffa3369659eead495f49b3cba9c8 100644 (file)
@@ -4,6 +4,7 @@ use wcf\data\template\group\TemplateGroup;
 use wcf\data\template\group\TemplateGroupAction;
 use wcf\form\AbstractForm;
 use wcf\system\exception\IllegalLinkException;
+use wcf\system\exception\PermissionDeniedException;
 use wcf\system\WCF;
 
 /**
@@ -45,6 +46,9 @@ class TemplateGroupEditForm extends TemplateGroupAddForm {
                if (!$this->templateGroup->templateGroupID) {
                        throw new IllegalLinkException();
                }
+               if ($this->templateGroup->isImmutable()) {
+                       throw new PermissionDeniedException();
+               }
        }
        
        /**
@@ -89,7 +93,7 @@ class TemplateGroupEditForm extends TemplateGroupAddForm {
         * @inheritDoc
         */
        public function readData() {
-               $this->availableTemplateGroups = TemplateGroup::getSelectList([$this->templateGroupID], 1);
+               $this->availableTemplateGroups = TemplateGroup::getSelectList([$this->templateGroupID, -1], 1);
                
                AbstractForm::readData();
                
index 8160daff9ed756fe7f814f4f2a85c06bd9530aad..d96c10fe82839cb5d78f49d3e5063785aaa6379a 100644 (file)
@@ -33,10 +33,30 @@ class TemplateGroup extends DatabaseObject {
        protected static $templateGroupStructure = null;
        protected static $selectList = null;
        
+       /**
+        * Returns whether the template group is immutable (i.e. whether it's the email
+        * template group).
+        * 
+        * @return      boolean
+        */
+       public function isImmutable() {
+               return $this->templateGroupFolderName === '_wcf_email/';
+       }
+       
+       /**
+        * Returns the localized name of the template group.
+        * 
+        * @return      string
+        */
+       public function getName() {
+               return WCF::getLanguage()->get($this->templateGroupName);
+       }
+       
        /**
         * Creates a select list of all template groups.
         * 
-        * @param       integer[]       $ignore         Array of template group ids that should be excluded with all of their children
+        * @param       integer[]       $ignore         Array of template group ids that should be excluded with all of their children.
+        *                                              -1 denotes that all immutable groups should be ignored.
         * @param       integer         $initialDepth   Specifies the initial indentation depth of the list
         * @return      array
         */
@@ -44,7 +64,7 @@ class TemplateGroup extends DatabaseObject {
                if (self::$templateGroupStructure === null) {
                        self::$templateGroupStructure = [];
                        
-                       $sql = "SELECT          templateGroupID, templateGroupName, parentTemplateGroupID
+                       $sql = "SELECT          *
                                FROM            wcf".WCF_N."_template_group
                                ORDER BY        templateGroupName ASC";
                        $statement = WCF::getDB()->prepareStatement($sql);
@@ -72,9 +92,10 @@ class TemplateGroup extends DatabaseObject {
                
                foreach (self::$templateGroupStructure[$parentID ?: 0] as $templateGroup) {
                        if (!empty($ignore) && in_array($templateGroup->templateGroupID, $ignore)) continue;
+                       if (in_array(-1, $ignore) && $templateGroup->isImmutable()) continue;
                        
                        // we must encode html here because the htmloptions plugin doesn't do it
-                       $title = StringUtil::encodeHTML($templateGroup->templateGroupName);
+                       $title = StringUtil::encodeHTML($templateGroup->getName());
                        if ($depth > 0) $title = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $depth). ' ' . $title;
                        
                        self::$selectList[$templateGroup->templateGroupID] = $title;
index 40949f00010cdc59276aa938abec12e3c1dc8ca4..b67423202fdecc18bc98e562d885ccb2b0558276 100644 (file)
@@ -1504,6 +1504,7 @@ GmbH=Gesellschaft mit beschränkter Haftung]]></item>
                <item name="wcf.acp.template.list"><![CDATA[Templates]]></item>
                <item name="wcf.acp.template.group"><![CDATA[Templategruppe]]></item>
                <item name="wcf.acp.template.group.default"><![CDATA[Standardtemplates]]></item>
+               <item name="wcf.acp.template.group.email"><![CDATA[E-Mail-Templates]]></item>
                <item name="wcf.acp.template.application"><![CDATA[Anwendung]]></item>
                <item name="wcf.acp.template.add"><![CDATA[Template hinzufügen]]></item>
                <item name="wcf.acp.template.edit"><![CDATA[Template bearbeiten]]></item>
index d7a5855b48c7c2a7a30ce7454fab09baf023b5f1..756be90eef4af9845953a39475be4b599d97e860 100644 (file)
@@ -1510,6 +1510,7 @@ GmbH=Gesellschaft mit beschränkter Haftung]]></item>
                <item name="wcf.acp.template.list"><![CDATA[Templates]]></item>
                <item name="wcf.acp.template.group"><![CDATA[Template Group]]></item>
                <item name="wcf.acp.template.group.default"><![CDATA[Default Templates]]></item>
+               <item name="wcf.acp.template.group.email"><![CDATA[Email Templates]]></item>
                <item name="wcf.acp.template.application"><![CDATA[Application]]></item>
                <item name="wcf.acp.template.add"><![CDATA[Add Template]]></item>
                <item name="wcf.acp.template.edit"><![CDATA[Edit Template]]></item>
index 55e574d4a4f9040cdc9f150be825f99287b25a6d..de18136d67757a22474a2a187a812a43b1de0527 100644 (file)
@@ -2081,6 +2081,9 @@ INSERT INTO wcf1_style_variable (variableName, defaultValue) VALUES ('wcfTextSha
 INSERT INTO wcf1_style_variable (variableName, defaultValue) VALUES ('wcfTooltipBackground', 'rgba(0, 0, 0, .8)');
 INSERT INTO wcf1_style_variable (variableName, defaultValue) VALUES ('wcfTooltipText', 'rgba(255, 255, 255, 1)');
 
+-- Email template group
+INSERT INTO wcf1_template_group (parentTemplateGroupID, templateGroupName, templateGroupFolderName) VALUES (NULL, 'wcf.acp.template.group.email', '_wcf_email/');
+
 -- media providers
 -- Videos
        -- Youtube