From 03265942cce026161aa851319112471c03119839 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Fri, 12 Sep 2008 03:22:56 +0000 Subject: [PATCH] MemberTableField delete just removes the member from the group git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@62311 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/MemberTableField.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/code/MemberTableField.php b/code/MemberTableField.php index 6f9b3790..b4b960a0 100755 --- a/code/MemberTableField.php +++ b/code/MemberTableField.php @@ -408,6 +408,14 @@ class MemberTableField extends ComplexTableField { $this->sourceItems(); // Called for its side-effect of setting total count return $this->totalCount; } + + /** + * Handles item requests + * MemberTableField needs its own item request class so that it can overload the delete method + */ + function handleItem($request) { + return new MemberTableField_ItemRequest($this, $request->param('ID')); + } } /** @@ -473,4 +481,20 @@ class MemberTableField_Popup extends ComplexTableField_Popup { } } } + +class MemberTableField_ItemRequest extends ComplexTableField_ItemRequest { + /** + * Deleting an item from a member table field should just remove that member from the group + */ + function delete() { + if($this->ctf->Can('delete') !== true) { + return false; + } + + $groupID = $this->ctf->sourceID(); + $this->dataObj()->Groups()->remove($groupID); + } + +} + ?>