Commit e08325ec authored by Kevin Ditscheid's avatar Kevin Ditscheid

Merge branch 'editing-mode' into 'master'

[BUGFIX] Fix editing mode for admins when only override mode is enabled

Closes #20

See merge request !20
parents 9408f9c6 4cf7da45
......@@ -52,15 +52,20 @@ abstract class AbstractBackendController extends AbstractController {
}
$editingMode = $this->session->getDataByKey('editingMode');
$availableEditingModes = $this->configurationService->getAvailableEditingModes();
if ($this->backendUser->isAdmin()) {
if (empty($editingMode)) {
$this->session->setDataByKey('editingMode', 'extension');
$firstAvailableEditMode = key($availableEditingModes);
$this->session->setDataByKey('editingMode', $firstAvailableEditMode);
}
$canChangeEditingModes = TRUE;
$canChangeEditingModes = count($availableEditingModes) > 0;
} else {
$canChangeEditingModes = $this->backendUser->user['lfeditor_change_editing_modes'] !== 0;
$canChangeEditingModes = count($availableEditingModes) > 0
&& $this->backendUser->user['lfeditor_change_editing_modes'] !== 0;
if (!$canChangeEditingModes || empty($editingMode)) {
$this->session->setDataByKey('editingMode', 'override');
end($availableEditingModes);
$lastAvailableEditMode = key($availableEditingModes);
$this->session->setDataByKey('editingMode', $lastAvailableEditMode);
}
}
$this->session->setDataByKey('defaultLanguagePermission', $this->backendUser->checkLanguageAccess(0));
......@@ -176,30 +181,9 @@ abstract class AbstractBackendController extends AbstractController {
* (and does not do redirection or forwarding at the end)
*/
protected function commonViewRenderingActionSettings() {
$editingModeOptions = array(
'extension' => LocalizationUtility::translate('select.editingMode.extension', 'lfeditor'),
'l10n' => LocalizationUtility::translate('select.editingMode.l10n', 'lfeditor'),
'override' => LocalizationUtility::translate('select.editingMode.override', 'lfeditor'),
);
if (7 === PHP_MAJOR_VERSION) {
$backendConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['lfeditor'], []);
} else {
$backendConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['lfeditor']);
}
if (isset($backendConfiguration['editModeExtension']) && ((int) $backendConfiguration['editModeExtension']) === 0) {
unset($editingModeOptions['extension']);
}
if (isset($backendConfiguration['editModeL10n']) && ((int) $backendConfiguration['editModeL10n']) === 0) {
unset($editingModeOptions['l10n']);
}
if (isset($backendConfiguration['editModeOverride']) && ((int) $backendConfiguration['editModeOverride']) === 0) {
unset($editingModeOptions['override']);
}
$this->setLastCalledControllerActionPair();
$this->view->assign('editingMode', $this->session->getDataByKey('editingMode'));
$this->view->assign('editingModeOptions', $editingModeOptions);
$this->view->assign('editingModeOptions', $this->configurationService->getAvailableEditingModes());
$this->view->assign('adminUser', $this->backendUser->isAdmin());
$this->view->assign('defaultLanguagePermission', $this->session->getDataByKey('defaultLanguagePermission'));
$this->view->assign('canChangeEditingModes', $this->session->getDataByKey('canChangeEditingModes'));
......
......@@ -59,6 +59,13 @@ class ConfigurationService extends AbstractService {
*/
protected $langArray = [];
/**
* Available editing modes based on extension configuration
* @var array
* @see prepareConfig()
*/
protected $availabledEditingModes = [];
/**
* @var \SGalinski\Lfeditor\Service\FileBaseService
*/
......@@ -160,6 +167,22 @@ class ConfigurationService extends AbstractService {
$this->extConfig['defaultLanguage'] = 'default';
}
}
// editing modes
$this->availabledEditingModes = array(
'extension' => LocalizationUtility::translate('select.editingMode.extension', 'lfeditor'),
'l10n' => LocalizationUtility::translate('select.editingMode.l10n', 'lfeditor'),
// Note: override should be always available because it is the fallback mode for editors
'override' => LocalizationUtility::translate('select.editingMode.override', 'lfeditor'),
);
if (isset($this->extConfig['editModeExtension']) && ((int) $this->extConfig['editModeExtension']) === 0) {
unset($this->availabledEditingModes['extension']);
}
if (isset($this->extConfig['editModeL10n']) && ((int) $this->extConfig['editModeL10n']) === 0) {
unset($this->availabledEditingModes['l10n']);
}
return $this->extConfig;
}
......@@ -633,6 +656,13 @@ class ConfigurationService extends AbstractService {
$this->invalidLanguages = $invalidLanguages;
}
/**
* @return array
*/
public function getAvailableEditingModes() {
return $this->availabledEditingModes;
}
/**
* @return ObjectManager
*/
......
......@@ -20,6 +20,3 @@ editModeExtension = 1
# cat=basic; type=boolean; label=Allow edit mode "l10n"
editModeL10n = 1
# cat=basic; type=boolean; label=Allow edit mode "override"
editModeOverride = 1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment