mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
BUGFIX: If you log into a subsite that you don't have access to on a section that you don't have access to, redirect to both the section and the subsite that you can access.
quote> BUGFIX: Fixed SiteConfig selection for subsites. (from r90019)
This commit is contained in:
parent
df1eb95a2a
commit
8049ead131
@ -117,7 +117,6 @@ class LeftAndMainSubsites extends Extension {
|
||||
public function alternateAccessCheck() {
|
||||
$className = $this->owner->class;
|
||||
|
||||
|
||||
// Switch to the subsite of the current page
|
||||
if ($this->owner->class == 'CMSMain' && $currentPage = $this->owner->currentPage()) {
|
||||
if (Subsite::currentSubsiteID() != $currentPage->SubsiteID) {
|
||||
@ -133,8 +132,24 @@ class LeftAndMainSubsites extends Extension {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!$sites) return null;
|
||||
// Switch to a different top-level menu item
|
||||
$menu = CMSMenu::get_menu_items();
|
||||
foreach($menu as $candidate) {
|
||||
if($candidate->controller != $this->owner->class) {
|
||||
|
||||
$sites = Subsite::accessible_sites("CMS_ACCESS_{$candidate->controller}")->toDropdownMap();
|
||||
if($sites && !isset($sites[Subsite::currentSubsiteID()])) {
|
||||
$siteIDs = array_keys($sites);
|
||||
Subsite::changeSubsite($siteIDs[0]);
|
||||
$cClass = $candidate->controller;
|
||||
$cObj = new $cClass();
|
||||
Director::redirect($cObj->Link());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If all of those fail, you really don't have access to the CMS
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,10 @@ class SiteConfigSubsites extends DataObjectDecorator {
|
||||
if(Subsite::$disable_subsite_filter) return;
|
||||
|
||||
// If you're querying by ID, ignore the sub-site - this is a bit ugly...
|
||||
if (!$query->where || (!preg_match('/\.(\'|"|`|)ID(\'|"|`|)( ?)=/', $query->where[0]))) {
|
||||
if (!$query->where || (
|
||||
!preg_match('/\.(\'|"|`|)ID(\'|"|`|)( ?)=/', $query->where[0]) &&
|
||||
!preg_match('/\.?(\'|"|`|)SubsiteID(\'|"|`|)( ?)=/', $query->where[0])
|
||||
)) {
|
||||
|
||||
if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
|
||||
else $subsiteID = (int)Subsite::currentSubsiteID();
|
||||
|
Loading…
Reference in New Issue
Block a user