|
|
@@ -14,6 +14,8 @@ use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
|
|
* If no page is selected or if this page does not have any root page as an ancestor,
|
|
|
* the action is forwarded to a page asking the user to select one.
|
|
|
*
|
|
|
+ * If only one website appears in the page-tree, this site is automatically selected
|
|
|
+ *
|
|
|
* Class BeOnSiteController
|
|
|
*/
|
|
|
class SelectedSiteController extends ActionController
|
|
|
@@ -26,13 +28,25 @@ class SelectedSiteController extends ActionController
|
|
|
protected $currentRootUid;
|
|
|
|
|
|
protected function callActionMethod() {
|
|
|
- try {
|
|
|
- $otPageRepository = GeneralUtility::makeInstance(OtPageRepository::class);
|
|
|
- $this->currentRootUid = $otPageRepository->getCurrentRootUid();
|
|
|
- } catch (NoSiteSelected $e) {
|
|
|
- $this->currentRootUid = null;
|
|
|
+
|
|
|
+ // Check if the current be-user has a db_mountpoint, and only has one.
|
|
|
+ // If so, this will be considered as the selected site (since its the only one available)
|
|
|
+ $mp = $GLOBALS['BE_USER']->user['db_mountpoints'];
|
|
|
+
|
|
|
+ if ($mp && count(explode(',', $mp)) === 1) {
|
|
|
+ $this->currentRootUid = (int)$mp;
|
|
|
+ } else {
|
|
|
+ // No db mountpoint has been set up, or more than one.
|
|
|
+ // Now we check if a site's page is selected
|
|
|
+ try {
|
|
|
+ $otPageRepository = GeneralUtility::makeInstance(OtPageRepository::class);
|
|
|
+ $this->currentRootUid = $otPageRepository->getCurrentRootUid();
|
|
|
+ } catch (NoSiteSelected $e) {
|
|
|
+ $this->currentRootUid = null;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ // No site is selected, redirect to the warning page
|
|
|
if ($this->actionMethodName != 'displayNoSelectedPageWarningAction' && $this->currentRootUid == null) {
|
|
|
$this->forward('displayNoSelectedPageWarning', 'SelectedSite', 'OtCore');
|
|
|
}
|