Closed camfindlay closed 5 years ago
So you're suggesting this change?
public function canCreate($member = null, $context = [])
{
- return $this->Parent()->canCreate($member, $context);
+ return $this->canEdit($member);
}
Seems fine to me. Want to make a PR?
Also, do you think we should also add some extendedCan()
calls before this in case people (like you) want to modify this behaviour in custom code?
Closed in #224
I recently struck this issue where we have a group of content editors that aren't suppose to change the top level of the SiteTree (they "cant" create) but are expected to be able to add/edit/remove quicklinks on the already existing homepage on the top level of the site tree.
The canCreate/Edit/View etc methods make the assumption that the $this->Parent returns true but in this scenario, you really want those that canEdit the HomePage should also be allow to canCreate/Edit the QuickLink objects attached to that homepage.
Suggest a change from $this->Parent()->canCreate to check the canEdit method for the homepage which would make more sense.
This would apply in both CWP1 and 2.
https://github.com/silverstripe/cwp/blob/270b719d54fd5aca122d9e459d369ed9e5f34af3/code/model/QuickLink.php#L47