From: Tim Düsterhus Date: Mon, 30 May 2016 13:43:52 +0000 (+0200) Subject: Add email template group X-Git-Tag: 3.0.0_Beta_1~1568^2~4 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=76eee28f8502fec923fe1d374cf008ab42f23a28;p=GitHub%2FWoltLab%2FWCF.git Add email template group --- diff --git a/wcfsetup/install/files/acp/templates/templateGroupList.tpl b/wcfsetup/install/files/acp/templates/templateGroupList.tpl index b729e7f9b5..a7a3ff480d 100644 --- a/wcfsetup/install/files/acp/templates/templateGroupList.tpl +++ b/wcfsetup/install/files/acp/templates/templateGroupList.tpl @@ -58,13 +58,26 @@ {foreach from=$objects item=templateGroup} - - + {if !$templateGroup->isImmutable()} + + + {else} + + + {/if} {event name='rowButtons'} {@$templateGroup->templateGroupID} - {$templateGroup->templateGroupName} + + {if !$templateGroup->isImmutable()} + + {$templateGroup->getName()} + + {else} + {$templateGroup->getName()} + {/if} + {$templateGroup->templateGroupFolderName} {#$templateGroup->templates} diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_2.2.0.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_2.2.0.php index a65f514caf..4de44701be 100644 --- a/wcfsetup/install/files/acp/update_com.woltlab.wcf_2.2.0.php +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_2.2.0.php @@ -2,3 +2,4 @@ // TODO: // 1. update label's show order +// 2. If a template group uses '_wcf_email' as the folder: Move it! diff --git a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php index 39c0eb3734..1df63dc6b1 100644 --- a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php @@ -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(); diff --git a/wcfsetup/install/files/lib/acp/form/TemplateGroupAddForm.class.php b/wcfsetup/install/files/lib/acp/form/TemplateGroupAddForm.class.php index 05aaebdc7d..b269d4096b 100644 --- a/wcfsetup/install/files/lib/acp/form/TemplateGroupAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/TemplateGroupAddForm.class.php @@ -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(); } diff --git a/wcfsetup/install/files/lib/acp/form/TemplateGroupEditForm.class.php b/wcfsetup/install/files/lib/acp/form/TemplateGroupEditForm.class.php index f86da863d5..b5c915c5a1 100644 --- a/wcfsetup/install/files/lib/acp/form/TemplateGroupEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/TemplateGroupEditForm.class.php @@ -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(); diff --git a/wcfsetup/install/files/lib/data/template/group/TemplateGroup.class.php b/wcfsetup/install/files/lib/data/template/group/TemplateGroup.class.php index 8160daff9e..d96c10fe82 100644 --- a/wcfsetup/install/files/lib/data/template/group/TemplateGroup.class.php +++ b/wcfsetup/install/files/lib/data/template/group/TemplateGroup.class.php @@ -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('    ', $depth). ' ' . $title; self::$selectList[$templateGroup->templateGroupID] = $title; diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 40949f0001..b67423202f 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1504,6 +1504,7 @@ GmbH=Gesellschaft mit beschränkter Haftung]]> + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index d7a5855b48..756be90eef 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -1510,6 +1510,7 @@ GmbH=Gesellschaft mit beschränkter Haftung]]> + diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index 55e574d4a4..de18136d67 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -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