mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #2768 from creative-commoners/pulls/5/rescue-master-canberoot-check
Rescue Master Branch PR: FIX Don't offer to restore to root if can_be_root is false
This commit is contained in:
commit
f9a19e7429
@ -2470,7 +2470,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
|||||||
// Note: It would be nice to have a canRestore() permission at some point
|
// Note: It would be nice to have a canRestore() permission at some point
|
||||||
if ($canEdit && !$isOnDraft && !$isPublished) {
|
if ($canEdit && !$isOnDraft && !$isPublished) {
|
||||||
// Determine if we should force a restore to root (where once it was a subpage)
|
// 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"
|
// "restore"
|
||||||
$title = $restoreToRoot
|
$title = $restoreToRoot
|
||||||
@ -2479,6 +2479,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
|||||||
$description = $restoreToRoot
|
$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_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');
|
: _t('SilverStripe\\CMS\\Controllers\\CMSMain.RESTORE_DESC', 'Restore the archived version to draft');
|
||||||
|
if (!$this->isParentArchived() || $restoreToRoot) {
|
||||||
$majorActions->push(
|
$majorActions->push(
|
||||||
FormAction::create('restore', $title)
|
FormAction::create('restore', $title)
|
||||||
->setDescription($description)
|
->setDescription($description)
|
||||||
@ -2487,6 +2488,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
|||||||
->setUseButtonTag(true)
|
->setUseButtonTag(true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If a page is on any stage it can be archived
|
// If a page is on any stage it can be archived
|
||||||
if (($isOnDraft || $isPublished) && $this->canArchive()) {
|
if (($isOnDraft || $isPublished) && $this->canArchive()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user