mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
BUGFIX: When opening the CMS, switch to a site that you actually have access to. (from r88968)
This commit is contained in:
parent
866e55d574
commit
c0844e0dd9
@ -14,11 +14,19 @@ class LeftAndMainSubsites extends Extension {
|
||||
Requirements::javascript('subsites/javascript/LeftAndMain_Subsites.js');
|
||||
Requirements::javascript('subsites/javascript/VirtualPage_Subsites.js');
|
||||
|
||||
// Switch to the subsite of the current page
|
||||
if ($this->owner->class == 'CMSMain' && $currentPage = $this->owner->currentPage()) {
|
||||
if (Subsite::currentSubsiteID() != $currentPage->SubsiteID) {
|
||||
Subsite::changeSubsite($currentPage->SubsiteID);
|
||||
}
|
||||
}
|
||||
|
||||
// Switch to a subsite that this user can actually access.
|
||||
$sites = Subsite::accessible_sites("CMS_ACCESS_{$this->owner->class}")->toDropdownMap();
|
||||
if(!isset($sites[Subsite::currentSubsiteID()])) {
|
||||
$siteIDs = array_keys($sites);
|
||||
Subsite::changeSubsite($siteIDs[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user