Skip to content

Commit

Permalink
Merge pull request #145 from purplespider/patch-2
Browse files Browse the repository at this point in the history
Fixes #135: LeftAndMain switching between subsites
  • Loading branch information
wilr committed Nov 24, 2014
2 parents b6f5974 + 47df87f commit 0520b57
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions code/extensions/LeftAndMainSubsites.php
Expand Up @@ -207,21 +207,6 @@ public function onBeforeInit() {

// FIRST, check if we need to change subsites due to the URL.

// Automatically redirect the session to appropriate subsite when requesting a record.
// This is needed to properly initialise the session in situations where someone opens the CMS via a link.
$record = $this->owner->currentPage();
if($record && isset($record->SubsiteID) && is_numeric($record->SubsiteID)) {

if ($this->shouldChangeSubsite($this->owner->class, $record->SubsiteID, Subsite::currentSubsiteID())) {
// Update current subsite in session
Subsite::changeSubsite($record->SubsiteID);

//Redirect to clear the current page
return $this->owner->redirect('admin/');
}

}

// Catch forced subsite changes that need to cause CMS reloads.
if(isset($_GET['SubsiteID'])) {
// Clear current page when subsite changes (or is set for the first time)
Expand All @@ -236,6 +221,21 @@ public function onBeforeInit() {
return $this->owner->redirect('admin/');
}

// Automatically redirect the session to appropriate subsite when requesting a record.
// This is needed to properly initialise the session in situations where someone opens the CMS via a link.
$record = $this->owner->currentPage();
if($record && isset($record->SubsiteID) && is_numeric($record->SubsiteID) && isset($this->owner->urlParams['ID'])) {

if ($this->shouldChangeSubsite($this->owner->class, $record->SubsiteID, Subsite::currentSubsiteID())) {
// Update current subsite in session
Subsite::changeSubsite($record->SubsiteID);

//Redirect to clear the current page
return $this->owner->redirect('admin/');
}

}

// SECOND, check if we need to change subsites due to lack of permissions.

if (!$this->owner->canAccess()) {
Expand Down

0 comments on commit 0520b57

Please sign in to comment.