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
1 changed files with 10 additions and 8 deletions

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,13 +2479,15 @@ 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');
$majorActions->push(
FormAction::create('restore', $title)
->setDescription($description)
->setAttribute('data-to-root', $restoreToRoot)
->addExtraClass('btn-warning font-icon-back-in-time')
->setUseButtonTag(true)
);
if (!$this->isParentArchived() || $restoreToRoot) {
$majorActions->push(
FormAction::create('restore', $title)
->setDescription($description)
->setAttribute('data-to-root', $restoreToRoot)
->addExtraClass('btn-warning font-icon-back-in-time')
->setUseButtonTag(true)
);
}
}
// If a page is on any stage it can be archived