mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
LeftAndMainSubsites failover if map() returns an array instead of an SS_Map
This commit is contained in:
parent
070eaf54ae
commit
19a904d1d2
@ -131,7 +131,9 @@ class LeftAndMainSubsites extends Extension {
|
|||||||
return true; //admin can access all subsites
|
return true; //admin can access all subsites
|
||||||
}
|
}
|
||||||
|
|
||||||
$sites = Subsite::accessible_sites("CMS_ACCESS_{$this->owner->class}")->map('ID', 'Title')->toArray();
|
$sites = Subsite::accessible_sites("CMS_ACCESS_{$this->owner->class}")->map('ID', 'Title');
|
||||||
|
if(is_object($sites)) $sites = $sites->toArray();
|
||||||
|
|
||||||
if($sites && !isset($sites[Subsite::currentSubsiteID()])) {
|
if($sites && !isset($sites[Subsite::currentSubsiteID()])) {
|
||||||
$siteIDs = array_keys($sites);
|
$siteIDs = array_keys($sites);
|
||||||
Subsite::changeSubsite($siteIDs[0]);
|
Subsite::changeSubsite($siteIDs[0]);
|
||||||
@ -142,14 +144,15 @@ class LeftAndMainSubsites extends Extension {
|
|||||||
$menu = CMSMenu::get_menu_items();
|
$menu = CMSMenu::get_menu_items();
|
||||||
foreach($menu as $candidate) {
|
foreach($menu as $candidate) {
|
||||||
if($candidate->controller != $this->owner->class) {
|
if($candidate->controller != $this->owner->class) {
|
||||||
|
$sites = Subsite::accessible_sites("CMS_ACCESS_{$candidate->controller}")->map('ID', 'Title');
|
||||||
|
if(is_object($sites)) $sites = $sites->toArray();
|
||||||
|
|
||||||
$sites = Subsite::accessible_sites("CMS_ACCESS_{$candidate->controller}")->map('ID', 'Title')->toArray();
|
|
||||||
if($sites && !isset($sites[Subsite::currentSubsiteID()])) {
|
if($sites && !isset($sites[Subsite::currentSubsiteID()])) {
|
||||||
$siteIDs = array_keys($sites);
|
$siteIDs = array_keys($sites);
|
||||||
Subsite::changeSubsite($siteIDs[0]);
|
Subsite::changeSubsite($siteIDs[0]);
|
||||||
$cClass = $candidate->controller;
|
$cClass = $candidate->controller;
|
||||||
$cObj = new $cClass();
|
$cObj = new $cClass();
|
||||||
$this->owner->redirect($cObj->Link());
|
Director::redirect($cObj->Link());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,6 +173,3 @@ class LeftAndMainSubsites extends Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
Loading…
Reference in New Issue
Block a user