FIX Don't offer to restore to root if can_be_root is false

This commit is contained in:
Mike Cochrane 2018-05-01 15:00:00 +12:00 committed by Guy Sartorelli
parent c130b55ecb
commit b46876b8a8
No known key found for this signature in database
GPG Key ID: F313E3B9504D496A

View File

@ -2470,7 +2470,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
// Note: It would be nice to have a canRestore() permission at some point
if ($canEdit && !$isOnDraft && !$isPublished) {
// Determine if we should force a restore to root (where once it was a subpage)
$restoreToRoot = $this->isParentArchived();
$restoreToRoot = $this->isParentArchived() && $this->config()->get('can_be_root');
// "restore"
$title = $restoreToRoot
@ -2479,6 +2479,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
$description = $restoreToRoot
? _t('SilverStripe\\CMS\\Controllers\\CMSMain.RESTORE_TO_ROOT_DESC', 'Restore the archived version to draft as a top level page')
: _t('SilverStripe\\CMS\\Controllers\\CMSMain.RESTORE_DESC', 'Restore the archived version to draft');
if (!$this->isParentArchived() || $restoreToRoot) {
$majorActions->push(
FormAction::create('restore', $title)
->setDescription($description)
@ -2487,6 +2488,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
->setUseButtonTag(true)
);
}
}
// If a page is on any stage it can be archived
if (($isOnDraft || $isPublished) && $this->canArchive()) {