From 03e67fe1003ae5949844c50d073fd565aa1291d2 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Tue, 19 Feb 2008 00:37:17 +0000 Subject: [PATCH] Merged revisions 45748 via svnmerge from svn://svn.silverstripe.com/silverstripe/modules/sapphire/branches/2.1.0-rc3oriwave2 ........ r45748 | sminnee | 2007-11-27 17:45:11 +1300 (Tue, 27 Nov 2007) | 1 line Create Group::canEdit(), which can be used to filter the SecurityAdmin group list ........ git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@49790 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- security/Group.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/security/Group.php b/security/Group.php index c9227121f..98aa0e7a5 100644 --- a/security/Group.php +++ b/security/Group.php @@ -177,6 +177,26 @@ class Group extends DataObject { $this->setCode($this->Title); } } + + public function canEdit() { + if($this->hasMethod('alternateCanEdit')) return $this->alternateCanEdit(); + else return Member::currentUserID() ? true : false; + } + + /** + * Returns all of the children for the CMS Tree. + * Filters to only those groups that the current user can edit + */ + function AllChildrenIncludingDeleted() { + $children = $this->extInstance('Hierarchy')->AllChildrenIncludingDeleted(); + $filteredChildren = new DataObjectSet(); + + foreach($children as $child) { + if($child->canEdit()) $filteredChildren->push($child); + } + + return $filteredChildren; + } } /**