From 16a5b9b745b2b04b97ca4de37ea20162a7cfe110 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 14 Aug 2008 04:38:22 +0000 Subject: [PATCH] BUGFIX Fixed partial merge from nzct (originally from r47039, partially merged in r60440) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@60723 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/TableListField.php | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/forms/TableListField.php b/forms/TableListField.php index bc29b6917..6b592489b 100755 --- a/forms/TableListField.php +++ b/forms/TableListField.php @@ -336,7 +336,7 @@ JS $allowedActions->push(new ViewableData()); } } - + return $allowedActions; } @@ -1200,6 +1200,31 @@ class TableListField_Item extends ViewableData { return $this->parent->Can($mode); } + /** + * Returns all row-based actions not disallowed through permissions. + * See TableListField->Action for a similiar dummy-function to work + * around template-inheritance issues. + * + * @return DataObjectSet + */ + function Actions() { + $allowedActions = new DataObjectSet(); + foreach($this->parent->actions as $actionName => $actionSettings) { + if($this->parent->Can($actionName)) { + $allowedActions->push(new ArrayData(array( + 'Name' => $actionName, + 'Link' => $this->{ucfirst($actionName).'Link'}(), + 'Icon' => $actionSettings['icon'], + 'Label' => $actionSettings['label'], + 'Class' => $actionSettings['class'], + 'Default' => ($actionName == $this->parent->defaultAction), + ))); + } + } + + return $allowedActions; + } + function Link() { return Controller::join_links($this->parent->Link() . "item/" . $this->item->ID); } @@ -1239,7 +1264,7 @@ class TableListField_Item extends ViewableData { return (count($classes) > 0) ? " " . implode(" ", $classes) : false; } - + /** * Legacy: Please use permissions instead */