Merge pull request #496 from creative-commoners/pulls/2.7-release/historyviewer

FIX Do not show copy to subsite buttons in history viewer
This commit is contained in:
Guy Sartorelli 2022-12-14 10:54:12 +13:00 committed by GitHub
commit a7e9e8dcdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,6 +29,7 @@ use SilverStripe\Subsites\Model\Subsite;
use SilverStripe\Subsites\Service\ThemeResolver;
use SilverStripe\Subsites\State\SubsiteState;
use SilverStripe\View\SSViewer;
use SilverStripe\VersionedAdmin\Controllers\HistoryViewerController;
/**
* Extension for the SiteTree object to add subsites support
@ -117,10 +118,12 @@ class SiteTreeSubsites extends DataExtension
$subsitesMap = new Map(ArrayList::create());
}
$viewingPageHistory = Controller::has_curr() && Controller::curr() instanceof HistoryViewerController;
// Master page edit field (only allowed from default subsite to avoid inconsistent relationships)
$isDefaultSubsite = $this->owner->SubsiteID == 0 || $this->owner->Subsite()->DefaultSite;
if ($isDefaultSubsite && $subsitesMap->count()) {
if ($isDefaultSubsite && $subsitesMap->count() && !$viewingPageHistory) {
$fields->addFieldToTab(
'Root.Main',
ToggleCompositeField::create(