It would be nice if we can add permissions for each paragraph bundle. This way we can have something like an admin bundle, where data can be added without other users changing it.

Comments

seanb’s picture

Assigned: Unassigned » seanb
Status: Active » Needs work
StatusFileSize
new6.05 KB

Attached is a first attempt at a patch (based on the beta4 version, sorry for that!).
It seemed relatively easy to add some checks, but it could be that I'm missing some important stuff.

It works for me, please let me know what you think!

jeroen.b’s picture

Looks good. I'm not really sure this is something that should be handled by the main module...
I think this is overkill to include in the default functionality.
Maybe it's better to get this into a submodule (which could be in the same repo) like modules/paragraphs_permissions?

seanb’s picture

I will look into that today!

seanb’s picture

I created a sandbox project for this. Do you want to add this to the module or should this be a seperate project?
https://www.drupal.org/sandbox/seanpenn079/2289265

jeroen.b’s picture

Looks good.
I'll test this tomorrow. Will add it inside the paragraphs module if it's ok with you?

seanb’s picture

No problem!

jeroen.b’s picture

Assigned: seanb » jeroen.b
jeroen.b’s picture

To be included in beta5

jstoller’s picture

I haven't had the opportunity to test this sandbox module yet, but I wanted to give you a use case to consider as you move toward implementing this feature in Paragraphs.

I have a Paragraphs bundle for inserting views within my page content. I only want site admins to be able to add/edit these items. However, once a views item has been added to the content on a page, I need my editors to see that the item is there and be able to order it within the list of paragraphs items, but without being able to remove it or edit its contents.

If #2273555: Collapsible paragraphs in node edit form is implemented, then that may be able to help with this. If a user doesn't have permission to use a particular paragraphs bundle then it could be locked in its collapsed state.

  • jeroen.b committed 2c138d6 on 7.x-1.x authored by seanB
    Add #2287735: paragraphs permissions per bundle
    
jeroen.b’s picture

Thanks @seanB, commited to dev! Please test!
Also did some changes to make it work with the new "paragraph add button method".

My only problem right now is that you are still able to edit when the default edit mode is "open", should be an easy fix, but might I fix it in combination with #2273555.

seanb’s picture

Nice! Thnx for the update..

seanb’s picture

Status: Needs work » Fixed
jeroen.b’s picture

Status: Fixed » Needs work

I don't consider this fixed just yet, first want to fix the issue I mentioned in #11, I'm also planning to make it more flexible by making a hook_paragraphs_access to the main module and have the permission module implement it

jeroen.b’s picture

I rewrote the paragraph_permissions module, I also renamed it to paragraphs_bundle_permissions.
I made a more advanced permission system in paragraphs. By default, everyone has access that also has access tot the host entity, but by implementing hook_paragraphs_item_access you can change the access by returning one of the following:
PARAGRAPHS_ITEM_ACCESS_IGNORE
PARAGRAPHS_ITEM_ACCESS_ALLOW
PARAGRAPHS_ITEM_ACCESS_DENY

I implemented hook_paragraphs_item_access in the paragraphs_bundle_permissions now.

Please test!

jeroen.b’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.