From: Marcel Werk Date: Tue, 24 May 2016 17:08:44 +0000 (+0200) Subject: Added global disable switch for languages X-Git-Tag: 3.0.0_Beta_1~1640^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=408effbceb4af08088022d87c2fe3fbd4a0a1d15;p=GitHub%2FWoltLab%2FWCF.git Added global disable switch for languages --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 821f1df839..9b640a6144 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ * Added support for embedded youtube playlists * Scaled embedded youtube videos to maximum width * `\wcf\form\AbstractCaptchaForm`: added parameter to force captcha usage for registered users. +* Added global disable switch for languages. #### CMS diff --git a/wcfsetup/install/files/acp/templates/languageList.tpl b/wcfsetup/install/files/acp/templates/languageList.tpl index b0a637c385..caba703294 100644 --- a/wcfsetup/install/files/acp/templates/languageList.tpl +++ b/wcfsetup/install/files/acp/templates/languageList.tpl @@ -13,6 +13,7 @@ window.location.reload(); } }); + new WCF.Action.Toggle('wcf\\data\\language\\LanguageAction', $('.jsLanguageRow')); }); //]]> @@ -60,12 +61,15 @@ {if !$language->isDefault} - + + {else} - + + {/if} + {if !$language->isDefault} {else} diff --git a/wcfsetup/install/files/lib/data/language/LanguageAction.class.php b/wcfsetup/install/files/lib/data/language/LanguageAction.class.php index 20bb5853f1..72a443f81c 100644 --- a/wcfsetup/install/files/lib/data/language/LanguageAction.class.php +++ b/wcfsetup/install/files/lib/data/language/LanguageAction.class.php @@ -1,6 +1,7 @@ languageEditor->setAsDefault(); } + + /** + * @inheritdoc + */ + public function validateToggle() { + parent::validateUpdate(); + + foreach ($this->objects as $language) { + if ($language->isDefault) { + throw new UserInputException('objectIDs'); + } + } + } + + /** + * @inheritdoc + */ + public function toggle() { + foreach ($this->objects as $language) { + $isDisabled = ($language->isDisabled) ? 0 : 1; + $language->update(['isDisabled' => $isDisabled]); + } + } } diff --git a/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php index cfd4ac6af6..fc141893f2 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php @@ -31,6 +31,7 @@ class LanguageCacheBuilder extends AbstractCacheBuilder { // get languages $languageList = new LanguageList(); + $languageList->getConditionBuilder()->add('language.isDisabled = ?', [0]); $languageList->readObjects(); $data['languages'] = $languageList->getObjects(); foreach ($languageList->getObjects() as $language) { diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index a3f06dc442..29f617b29a 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -485,6 +485,7 @@ CREATE TABLE wcf1_language ( countryCode VARCHAR(10) NOT NULL DEFAULT '', isDefault TINYINT(1) NOT NULL DEFAULT 0, hasContent TINYINT(1) NOT NULL DEFAULT 0, + isDisabled TINYINT(1) NOT NULL DEFAULT 0, UNIQUE KEY languageCode (languageCode) );