From c05728ad308eb77d06cd7355d304102baa629736 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Wed, 13 May 2009 05:13:20 +0000 Subject: [PATCH] API CHANGE: Added SiteTree::doDeleteFromLive() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@76723 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/SiteTree.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index cc0d32e04..940ce181b 100644 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -697,12 +697,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid // if page can't be edited, don't grant delete permissions if(!$this->canEdit($member)) return false; - + $children = $this->AllChildren(); if($children) foreach($children as $child) { if(!$child->canDelete($member)) return false; } - + return $this->stat('can_create') != false; } @@ -1520,6 +1520,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid return $result; } + + function doDeleteFromLive() { + $origStage = Versioned::current_stage(); + Versioned::reading_stage('Live'); + $this->delete(); + Versioned::reading_stage($origStage); + } /** * Check if this page is new - that is, if it has yet to have been written