Merge pull request #145 from purplespider/patch-2

Fixes #135: LeftAndMain switching between subsites
This commit is contained in:
Will Rossiter 2014-11-24 15:11:12 +13:00
commit 0520b57f84
1 changed files with 15 additions and 15 deletions

View File

@ -207,21 +207,6 @@ class LeftAndMainSubsites extends Extension {
// 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)
@ -236,6 +221,21 @@ class LeftAndMainSubsites extends Extension {
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()) {