Commit aeda66e3 authored by Fabio Stegmeyer's avatar Fabio Stegmeyer

Merge branch 'feature_remove_everything_thats_not_visibility_related' into 'master'

[TASK] Feature remove everything thats not visibility related

See merge request !8
parents 9822bb29 b3ec1f12
<?php
namespace TYPO3\Languagevisibility\Hook;
/***************************************************************
* Copyright notice
*
* (c) 2009 AOE media <dev@aoemedia.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/#
use Exception;
use TYPO3\CMS\Backend\Controller\EditDocumentController;
use TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseUserPermissionCheck;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\Languagevisibility\Service\BackendServices;
/**
* Class/Function which manipulates the item-array for the listing (see piFlexform).
*
* @author Fabrizio Brance
* @author Timo Schmidt
*/
class AlternativeDocumentHook {
/**
* @param array $params
* @param DatabaseUserPermissionCheck $permissionCheck
* @param EditDocumentController|null $ref
* @return bool
* @throws Exception
*/
public function makeEditForm_accessCheck(
array $params, DatabaseUserPermissionCheck $permissionCheck, EditDocumentController $ref = NULL
): bool {
if ($params['hasAccess']) {
return TRUE;
}
// user wants to edit/create page record but has no access to default language
$hasAccess = FALSE;
if ($params['table'] === 'pages' && !$GLOBALS['BE_USER']->checkLanguageAccess(0)) {
$row = BackendUtility::getRecord($params['table'], $params['uid']);
if ($row !== NULL && BackendServices::hasUserAccessToPageRecord($row, $params['cmd'])) {
$hasAccess = TRUE;
}
}
return $hasAccess;
}
}
......@@ -108,7 +108,7 @@ class PageHook implements \LanguageVisibilityPageRepositoryGetPageOverlayHookInt
public function getRecordOverlay_preProcess(
$table, &$row, &$sys_language_content, $OLmode, \LanguageVisibilityPageRepository $parent
) {
// Do nothing
// Do nothing [@devs: Don't try to remove this method, it needs to be implemented, even if it does nothing]
}
public function getRecordOverlay_postProcess(
......
<?php
namespace TYPO3\Languagevisibility\Hook;
/***************************************************************
* Copyright notice
*
* (c) 2010 Tolleiv Nietsch <nietsch@aoemedia.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use Exception;
use TYPO3\Languagevisibility\Service\BackendServices;
/**
* Class UserAuthGroupHook
*
* @author Tolleiv
* @package TYPO3
* @version $Id:$
*/
class UserAuthGroupHook {
/**
*
* @param array $params
* @param object $ref
* @return bool
* @throws Exception
*/
public function checkFullLanguagesAccess($params, $ref): bool {
if (isset($params['recordLocalizationAccess']) && $params['recordLocalizationAccess']) {
// so far the user had access to all existing overlay-languages
return BackendServices::hasUserAccessToEditRecord($params['table'], $params['row']['uid']);
}
return $params['recordLocalizationAccess'];
}
}
......@@ -125,121 +125,6 @@ class BackendServices extends AbstractServices {
return $result;
}
/**
* checks if the current BE_USER has access to the page record:
* that is the case if:
* a) new page created -> always because then the languagevisibility is set to never for all languages where the user has no access
* b) edit page record: only if the record is only visible in languages where the user has access to
* b.1) also if the languages that are visible and falls back to allowed languages
* c) delete: same as for edit (only if user has access to all visible languages)
*
* @param array $row
* @param string $cmd
* @return bool
* @throws Exception
*/
public static function hasUserAccessToPageRecord(array $row, string $cmd = 'edit'): bool {
if ($cmd === 'new') {
return TRUE;
}
$siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
try {
$site = $siteFinder->getSiteByPageId($row['uid']);
} catch (\Exception $e) {
return FALSE;
}
$availableLanguages = $site->getAllLanguages();
foreach ($availableLanguages as $language) {
if (self::isVisible($row, 'pages', $language->getLanguageId())) {
if (!$GLOBALS['BE_USER']->checkLanguageAccess($language->getLanguageId())) {
//no access to a visible language: check fallbacks
$isInFallback = FALSE;
$fallbacks = $language->getFallbackLanguageIds();
foreach ($fallbacks as $lId) {
if ($GLOBALS['BE_USER']->checkLanguageAccess($lId)) {
$isInFallback = TRUE;
continue;
}
}
if (!$isInFallback) {
return FALSE;
}
}
}
}
return TRUE;
}
/**
* checks if the current BE_USER has access to a record:
* that is the case if:
* a) new page created -> always because then the languagevisibility is set to never for all languages where the user has no access
* b) edit page record: only if the record is only visible in languages where the user has access to
*
* @param string $table
* @param array $row
* @return bool
* @throws Exception
*/
public static function hasUserAccessToEditRecord(string $table, array $row): bool {
if (!self::isSupportedTable($table)) {
return TRUE;
}
if (self::isOverlayRecord($row, $table)) {
if ($GLOBALS['BE_USER']->checkLanguageAccess($row['sys_language_uid'])) {
return TRUE;
}
return FALSE;
}
$siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
if ($table === 'pages') {
$pid = $row['uid'];
} else {
$pid = $row['pid'];
}
try {
$site = $siteFinder->getSiteByPageId($pid);
} catch (\Exception $e) {
return FALSE;
}
$availableLanguages = $site->getAllLanguages();
foreach ($availableLanguages as $language) {
if (self::isVisible($row, $table, $language->getLanguageId())) {
if (!$GLOBALS['BE_USER']->checkLanguageAccess($language->getLanguageId())) {
// no access to a visible language: check fallbacks
$isInFallback = FALSE;
$fallbacks = $language->getFallbackLanguageIds();
foreach ($fallbacks as $lId) {
if ($GLOBALS['BE_USER']->checkLanguageAccess($lId)) {
// TODO - write testcase - this can't be right
$isInFallback = TRUE;
continue;
}
}
if (!$isInFallback) {
return FALSE;
}
}
}
}
return TRUE;
}
/**
* Method to check if the translatedAsDefaultEnabled is enabled or not
*
......
......@@ -133,6 +133,14 @@ class FieldVisibilityUserFunction extends AbstractFormElement {
/** @var BackendUserAuthentication $backendUser */
$backendUser = $GLOBALS['BE_USER'];
if(!$GLOBALS['BE_USER']->check('tables_modify', 'tx_languagevisibility_visibility_flag')){
return ['html' =>
'<div class="alert alert-info">' .
$this->getLLL('backend.error.noAccessToVisibilityFlags') .
'</div>'
];
}
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.2.0', '<')) {
$this->modTSconfig = BackendUtility::getRawPagesTSconfig($pageId)['mod.']['languagevisibility.'];
} else {
......
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" target-language="de" datatype="plaintext" original="messages" date="">
<header>
<type>database</type>
<description>Language labels for database tables/fields belonging to extension 'languagevisibility'</description>
<generator>LFEditor</generator>
</header>
<body>
<trans-unit id="applyRecursive" approved="yes">
<source>Apply to all subpages</source>
<target>Für alle Unterseiten übernehmen</target>
</trans-unit>
<trans-unit id="default" approved="yes">
<source>-default-</source>
<target>-Standard-</target>
</trans-unit>
<trans-unit id="enableLogging" approved="yes">
<source>Enable logging of the changes for the recursive functionallity. (Slow for many pages)</source>
<target>Aktiviere das Loggen der Änderungen für die Rekursiv-Funktion. (Langsam für viele Seiten)</target>
</trans-unit>
<trans-unit id="fallback" approved="yes" xml:space="preserve">
<source>if a translation in fallback exists</source>
<target>Wenn eine Übersetzung im Fallback existiert</target>
</trans-unit>
<trans-unit id="hastranslation" approved="yes">
<source>Is translated</source>
<target>Übersetzt</target>
</trans-unit>
<trans-unit id="isshown" approved="yes">
<source>Is visible</source>
<target>Sichtbar</target>
</trans-unit>
<trans-unit id="language" approved="yes">
<source>Language</source>
<target>Sprache</target>
</trans-unit>
<trans-unit id="no" approved="yes">
<source>never</source>
<target>niemals</target>
</trans-unit>
<trans-unit id="pages.tx_languagevisibility_visibility" approved="yes">
<source>Language visibility:</source>
<target>Sprachsichtbarkeit:</target>
</trans-unit>
<trans-unit id="reports.fail.message" approved="yes">
<source>Unsupported values (other than &quot;ignore&quot;) used on:</source>
<target>Nicht unterstützte Werte (andere als &quot;ignore&quot;) benutzt in:</target>
</trans-unit>
<trans-unit id="reports.fail.message.detail" approved="yes">
<source>Page %1$d and its subpages - uses mode &quot;%3$s&quot; (sys_template:%2$d)</source>
<target>Seite %1$d und dessen Unterseiten - benutzter Modus &quot;%3$s&quot; (sys_template:%2$d)</target>
</trans-unit>
<trans-unit id="reports.fail.value" approved="yes">
<source>Unsupported value</source>
<target>Nicht unterstüzter Wert</target>
</trans-unit>
<trans-unit id="reports.ok.value" approved="yes">
<source>OK</source>
<target>OK</target>
</trans-unit>
<trans-unit id="tabname" approved="yes">
<source>Language</source>
<target>Sprache</target>
</trans-unit>
<trans-unit id="translated" approved="yes">
<source>if translated</source>
<target>wenn übersetzt</target>
</trans-unit>
<trans-unit id="tt_content.tx_languagevisibility_visibility" approved="yes">
<source>Language visibility:</source>
<target>Sprachsichtbarkeit:</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility.I." approved="yes">
<source>empty</source>
<target>leer</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility.I.active" approved="yes">
<source>Active</source>
<target>Verfügbar</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility.I.fallback" approved="yes">
<source>&#160;&#160;&#160;+ or in fallback</source>
<target>&#160;&#160;&#160;+ oder im Fallback</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility.I.inactive" approved="yes">
<source>Inactive</source>
<target>Nicht verfügbar</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility.I.translated" approved="yes">
<source>+ only if translated</source>
<target>+ nur falls übersetzt</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility.I.enforce" approved="yes">
<source>+ enforce</source>
<target>+ erzwingen</target>
</trans-unit>
<trans-unit id="visibility" approved="yes">
<source>visibility setting</source>
<target>Sichtbarkeits-Einstellungen</target>
</trans-unit>
<trans-unit id="visibility_in_default" approved="yes">
<source>Default visibility</source>
<target>Standard-Sichtbarkeit</target>
</trans-unit>
<trans-unit id="visibility_in_overlay" approved="yes">
<source>Translation visibility</source>
<target>Sichtbarkeit der Übersetzung</target>
</trans-unit>
<trans-unit id="visibility_options" approved="yes">
<source>Visibility options</source>
<target>Sichtbarkeits-Optionen</target>
</trans-unit>
<trans-unit id="visibility_currently" approved="yes">
<source>Visibility </source>
<target>Sichtbarkeit aktuell</target>
</trans-unit>
<trans-unit id="yes" approved="yes">
<source>always</source>
<target>immer</target>
</trans-unit>
<trans-unit id="backend.error.settingsCorrupt">
<source>Visibility Settings seems to be corrupt</source>
<target>Die Sichtbarkeitseinstellungen sind korrupt</target>
</trans-unit>
<trans-unit id="backend.error.elementNotSupported">
<source>Localization of this element is not supported</source>
<target>Die Übersetzung dieses Elements wird nicht unterstützt</target>
</trans-unit>
<trans-unit id="backend.error.siteNotFound">
<source>The site of this element couldn't be determined</source>
<target>Die Seite dieses Elements wurde nicht gefunden</target>
</trans-unit>
<trans-unit id="backend.error.languageNotAvailable">
<source>The specified language is not available</source>
<target>Die Sprache des Elements ist nicht verfügbar</target>
</trans-unit>
<trans-unit id="backend.justEditableInTheDefault" approved="yes">
<source>This field can only be edited in the default language.</source>
<target>Dieses Feld kann nur in der Standardsprache bearbeitet werden.</target>
</trans-unit>
<trans-unit id="backend.configuredInParent">
<source>Parent configuration is set to:</source>
<target>Standardsprache ist konfiguriert mit:</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility_flag">
<target>Vom Standard abweichende language-visibility-Einstellungen</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility_flag.record_table">
<target>Tabelle</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility_flag.record_uid">
<target>Uid</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility_flag.record_language_uid">
<target>Sprache</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility_flag.record_flag">
<target>Einstellung</target>
</trans-unit>
<trans-unit id="backend.error.noVisibilitySettingsAvailable" approved="yes">
<target><![CDATA[Keine Sichtbarkeits-Einstellungen verfügbar. Sie befinden sich entweder auf einer Root-Seite [pid = 0] oder einer noch nicht gespeicherten Seite.]]></target>
</trans-unit>
</body>
<header>
<type>database</type>
<description>Language labels for database tables/fields belonging to extension 'languagevisibility'</description>
<generator>LFEditor</generator>
</header>
<body>
<trans-unit id="applyRecursive" approved="yes">
<source>Apply to all subpages</source>
<target>Für alle Unterseiten übernehmen</target>
</trans-unit>
<trans-unit id="backend.configuredInParent" approved="yes">
<source>Parent configuration is set to:</source>
<target>Standardsprache ist konfiguriert mit:</target>
</trans-unit>
<trans-unit id="backend.error.elementNotSupported" approved="yes">
<source>Localization of this element is not supported</source>
<target>Die Übersetzung dieses Elements wird nicht unterstützt</target>
</trans-unit>
<trans-unit id="backend.error.languageNotAvailable" approved="yes">
<source>The specified language is not available</source>
<target>Die Sprache des Elements ist nicht verfügbar</target>
</trans-unit>
<trans-unit id="backend.error.noAccessToVisibilityFlags" approved="yes">
<source><![CDATA[Your user doesn't have access to the language visbility settings.]]></source>
<target><![CDATA[Ihr benutzer hat keinen Zugriff auf die Sprach-Sichtbarkeitseinstellungen.]]></target>
</trans-unit>
<trans-unit id="backend.error.noVisibilitySettingsAvailable" approved="yes">
<source></source>
<target><![CDATA[Keine Sichtbarkeits-Einstellungen verfügbar. Sie befinden sich entweder auf einer Root-Seite [pid = 0] oder einer noch nicht gespeicherten Seite.]]></target>
</trans-unit>
<trans-unit id="backend.error.settingsCorrupt" approved="yes">
<source>Visibility Settings seems to be corrupt</source>
<target>Die Sichtbarkeitseinstellungen sind korrupt</target>
</trans-unit>
<trans-unit id="backend.error.siteNotFound" approved="yes">
<source>The site of this element couldn't be determined</source>
<target>Die Seite dieses Elements wurde nicht gefunden</target>
</trans-unit>
<trans-unit id="backend.justEditableInTheDefault" approved="yes">
<source>This field can only be edited in the default language.</source>
<target>Dieses Feld kann nur in der Standardsprache bearbeitet werden.</target>
</trans-unit>
<trans-unit id="default" approved="yes">
<source>-default-</source>
<target>-Standard-</target>
</trans-unit>
<trans-unit id="enableLogging" approved="yes">
<source>Enable logging of the changes for the recursive functionallity. (Slow for many pages)</source>
<target>Aktiviere das Loggen der Änderungen für die Rekursiv-Funktion. (Langsam für viele Seiten)</target>
</trans-unit>
<trans-unit id="fallback" approved="yes">
<source>if a translation in fallback exists</source>
<target>Wenn eine Übersetzung im Fallback existiert</target>
</trans-unit>
<trans-unit id="hastranslation" approved="yes">
<source>Is translated</source>
<target>Übersetzt</target>
</trans-unit>
<trans-unit id="isshown" approved="yes">
<source>Is visible</source>
<target>Sichtbar</target>
</trans-unit>
<trans-unit id="language" approved="yes">
<source>Language</source>
<target>Sprache</target>
</trans-unit>
<trans-unit id="no" approved="yes">
<source>never</source>
<target>niemals</target>
</trans-unit>
<trans-unit id="pages.tx_languagevisibility_visibility" approved="yes">
<source>Language visibility:</source>
<target>Sprachsichtbarkeit:</target>
</trans-unit>
<trans-unit id="reports.fail.message" approved="yes">
<source>Unsupported values (other than &quot;ignore&quot;) used on:</source>
<target>Nicht unterstützte Werte (andere als &quot;ignore&quot;) benutzt in:</target>
</trans-unit>
<trans-unit id="reports.fail.message.detail" approved="yes">
<source>Page %1$d and its subpages - uses mode &quot;%3$s&quot; (sys_template:%2$d)</source>
<target>Seite %1$d und dessen Unterseiten - benutzter Modus &quot;%3$s&quot; (sys_template:%2$d)</target>
</trans-unit>
<trans-unit id="reports.fail.value" approved="yes">
<source>Unsupported value</source>
<target>Nicht unterstüzter Wert</target>
</trans-unit>
<trans-unit id="reports.ok.value" approved="yes">
<source>OK</source>
<target>OK</target>
</trans-unit>
<trans-unit id="tabname" approved="yes">
<source>Language</source>
<target>Sprache</target>
</trans-unit>
<trans-unit id="translated" approved="yes">
<source>if translated</source>
<target>wenn übersetzt</target>
</trans-unit>
<trans-unit id="tt_content.tx_languagevisibility_visibility" approved="yes">
<source>Language visibility:</source>
<target>Sprachsichtbarkeit:</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility.I." approved="yes">
<source>empty</source>
<target>leer</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility.I.active" approved="yes">
<source>Active</source>
<target>Verfügbar</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility.I.enforce" approved="yes">
<source>+ enforce</source>
<target>+ erzwingen</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility.I.fallback" approved="yes">
<source>&#160;&#160;&#160;+ or in fallback</source>
<target>&#160;&#160;&#160;+ oder im Fallback</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility.I.inactive" approved="yes">
<source>Inactive</source>
<target>Nicht verfügbar</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility.I.translated" approved="yes">
<source>+ only if translated</source>
<target>+ nur falls übersetzt</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility_flag" approved="yes">
<source></source>
<target>Vom Standard abweichende language-visibility-Einstellungen</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility_flag.record_flag" approved="yes">
<source></source>
<target>Einstellung</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility_flag.record_language_uid" approved="yes">
<source></source>
<target>Sprache</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility_flag.record_table" approved="yes">
<source></source>
<target>Tabelle</target>
</trans-unit>
<trans-unit id="tx_languagevisibility_visibility_flag.record_uid" approved="yes">
<source></source>
<target>Uid</target>
</trans-unit>
<trans-unit id="visibility" approved="yes">
<source>visibility setting</source>
<target>Sichtbarkeits-Einstellungen</target>
</trans-unit>
<trans-unit id="visibility_currently" approved="yes">
<source>Visibility</source>
<target>Sichtbarkeit aktuell</target>
</trans-unit>
<trans-unit id="visibility_in_default" approved="yes">
<source>Default visibility</source>
<target>Standard-Sichtbarkeit</target>
</trans-unit>
<trans-unit id="visibility_in_overlay" approved="yes">
<source>Translation visibility</source>
<target>Sichtbarkeit der Übersetzung</target>
</trans-unit>
<trans-unit id="visibility_options" approved="yes">
<source>Visibility options</source>
<target>Sichtbarkeits-Optionen</target>
</trans-unit>
<trans-unit id="yes" approved="yes">
<source>always</source>
<target>immer</target>
</trans-unit>
</body>
</file>
</xliff>
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="">
<header>
<type>database</type>
<description>Language labels for database tables/fields belonging to extension 'languagevisibility'</description>
<generator>LFEditor</generator>
</header>
<body>
<trans-unit id="applyRecursive">
<source>Apply to all subpages</source>
</trans-unit>
<trans-unit id="default">
<source>-default-</source>
</trans-unit>
<trans-unit id="enableLogging">
<source>Enable logging of the changes for the recursive functionallity. (Slow for many pages)</source>
</trans-unit>
<trans-unit id="fallback">
<source>if a translation in fallback exists</source>
</trans-unit>
<trans-unit id="hastranslation">
<source>Is translated</source>
</trans-unit>
<trans-unit id="isshown">