When you clone an entity it maintains the original author. I'd like to let users clone other users entities and modify for themselves. Is this possible? Or can someone point me in a direction via code?
Thanks
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | 3078811-16.patch | 14.93 KB | guilhermevp |
| #16 | interdiff_14-16.txt | 2.99 KB | guilhermevp |
| #14 | 3078811-14.patch | 14.88 KB | guilhermevp |
| #14 | interdiff_10-14.txt | 8.31 KB | guilhermevp |
| #10 | reroll_diff_8-10.txt | 1.93 KB | andreymaximov |
Comments
Comment #2
emek commentedYou can subscribe to the POST_CLONE event and update the author to the one that is logged in.
Comment #3
BerndB commentedAutomatically changing the author on cloning will be required to give the user full access.
Otherwise you have to change the author manuelly as administrator.
Please make this a part of the settings of this module - this would really help a lot!
Comment #4
maticb commentedI've added a patch with the following concept behind this:
- I add permissions "allow user to take ownership of cloned entity" to all the content types that have the ownership trait (meaning they can have owners)
- If user has this permission he will see a checkbox on the clone form, if ticked, the owner will be changed to drupal's current user.
* Note: patch will only apply to the latest dev version, because of some other changes on the form in a commit before. Doesn't apply to beta 3.
Comment #5
maticb commentedReuploading patch because of a copy&paste mistake when creating patch.
Comment #6
bcizej commentedThere were some issues with the patch, clone form was checking for incorrect permissions based on entity bundle instead of type.
I also fixed the TypeError with injected AccountProxyInterface service, replaced deprecated
FILE_EXISTS_RENAMEconstant and minor fixes to method descriptions.Comment #7
nace_fr commentedI have applied and tested the patch. It applied without errors and worked as described from maticb. I'm changing status to "Reviewed".
Comment #8
matthiasm11 commentedAdded an extra checkbox to the entity_clone settings:
Whether the "Take ownership" option should be checked by default on the entity clone form.Comment #9
nace_fr commentedHi. I have also applied and tested patch from #8. It applied without errors and worked as described. I'm changing status to "RTBC".
Comment #10
andreymaximov commentedRerolling #8
Comment #11
colanI'd have more confidence in committing this if someone could test the reroll.
Comment #12
colanI had changed my mind and was about to merge this because tests are passing, but then I noticed the code duplication.
EntityClonePermissions::entityTypeHasOwnerTrait()is basically identical toEntityCloneForm::entityHasOwnerTrait(). Why not simply have the latter just get the type and then pass it to the former? There's no need to duplicate the entire thing.Comment #13
guilhermevp commentedComment #14
guilhermevp commentedComment #16
guilhermevp commentedUpdated patch.
Comment #17
luiscarvalho commentedHello, I just tried applying the patch #16 with
git apply 3078811-16.patchand it failed with the following errors:
error: patch failed: src/EntityClone/Content/ContentEntityCloneBase.php:32
error: src/EntityClone/Content/ContentEntityCloneBase.php: patch does not apply
I believe it needs a reroll.
Comment #18
suresh prabhu parkala commentedRe-rolled patch.
Comment #19
guilhermevp commentedRe-rolled patch, please review. It's basically the same that #18 re-rolled, but I renamed some classes for clarity.
Comment #21
guilhermevp commentedNeeds review for #18
Comment #22
adalbertov commentedHello, I have just checked patch #18. Things are in order after the reroll. and besides that, it seems to work fine. I'm moving it to RTBC
Comment #24
colanThanks all!