silverstripe / cwp

Common Web Platform (CWP) features module. We strongly recommend using it for all new CWP projects. Future features will be delivered here.
https://www.cwp.govt.nz
BSD 3-Clause "New" or "Revised" License
10 stars 26 forks source link

Cannot add quicklinks to home if you are also not a top level page "adder" #219

Closed camfindlay closed 5 years ago

camfindlay commented 5 years ago

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

robbieaverill commented 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?

robbieaverill commented 5 years ago

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?

robbieaverill commented 5 years ago

PR at https://github.com/silverstripe/cwp/pull/224

ScopeyNZ commented 5 years ago

Closed in #224