From 7a35596c28b504944d7aea9ad50a70925b8fec78 Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Thu, 6 Aug 2009 23:30:17 +0000 Subject: [PATCH] BUGFIX prevent a nasty permissions situation where no one but an admin can edit a new page git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@83999 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/SiteTree.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index fcea1d189..da5dd429d 100644 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -1211,6 +1211,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } } + // If this is a new page, it does not have a parent, and the edit type is + // set to inherit, change it to logged in users only (otherwise only admins + // will be able to edit it) + if (!$this->ID && !$this->ParentID && $this->CanEditType == 'Inherit') { + $this->CanEditType = 'LoggedInUsers'; + } + parent::onBeforeWrite(); }