From c0844e0dd9346ca9b5d2b66bbcc5c10f939983a1 Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Mon, 1 Mar 2010 21:27:52 +0000 Subject: [PATCH] BUGFIX: When opening the CMS, switch to a site that you actually have access to. (from r88968) --- code/LeftAndMainSubsites.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/code/LeftAndMainSubsites.php b/code/LeftAndMainSubsites.php index ca75c29..12875eb 100644 --- a/code/LeftAndMainSubsites.php +++ b/code/LeftAndMainSubsites.php @@ -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]); + } } /**