[BUGFIX] Only show translate button for available languages 54/62854/2
authorDaniel Goerz <daniel.goerz@posteo.de>
Sun, 12 Jan 2020 16:06:38 +0000 (17:06 +0100)
committerSusanne Moog <look@susi.dev>
Sun, 12 Jan 2020 20:58:11 +0000 (21:58 +0100)
The list module now takes the available SiteLanguages
into account when rendering the buttons for creating new
translations of records. If a language gets deleted from
the site configuration it is no longer possible to create
record translations to this language.

Resolves: #86662
Releases: master, 9.5
Change-Id: If03598fbb63496d36c93cd832cbdb3028b5e32e1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62854
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Susanne Moog <look@susi.dev>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Susanne Moog <look@susi.dev>
typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php

index d230c93..17f85cc 100644 (file)
@@ -578,6 +578,15 @@ class DatabaseRecordList
     protected $showOnlyTranslatedRecords = false;
 
     /**
+     * All languages that are included in the site configuration
+     * for the current page. New records can only be created in those
+     * languages.
+     *
+     * @var array
+     */
+    protected $systemLanguagesOnPage;
+
+    /**
      * Constructor
      */
     public function __construct()
@@ -2309,10 +2318,14 @@ class DatabaseRecordList
         $translations = $this->translateTools->translationInfo($table, $row['uid'], 0, $row, $this->selFieldList);
         if (is_array($translations)) {
             $this->translations = $translations['translations'];
-            // Traverse page translations and add icon for each language that does NOT yet exist:
+            // Traverse page translations and add icon for each language that does NOT yet exist and is included in site configuration:
             $lNew = '';
             foreach ($this->pageOverlays as $lUid_OnPage => $lsysRec) {
-                if ($this->isEditable($table) && !isset($translations['translations'][$lUid_OnPage]) && $this->getBackendUserAuthentication()->checkLanguageAccess($lUid_OnPage)) {
+                if (isset($this->systemLanguagesOnPage[$lUid_OnPage])
+                    && $this->isEditable($table)
+                    && !isset($translations['translations'][$lUid_OnPage])
+                    && $this->getBackendUserAuthentication()->checkLanguageAccess($lUid_OnPage)
+                ) {
                     $redirectUrl = (string)$this->uriBuilder->buildUriFromRoute(
                         'record_edit',
                         [
@@ -2783,6 +2796,8 @@ class DatabaseRecordList
         // Setting internal variables:
         // sets the parent id
         $this->id = (int)$id;
+        // Store languages that are included in the site configuration for the current page.
+        $this->systemLanguagesOnPage = $this->translateTools->getSystemLanguages($this->id);
         if ($GLOBALS['TCA'][$table]) {
             // Setting single table mode, if table exists:
             $this->table = $table;