Currently, the only way for allowing users to delete scheduled transitions, the administer scheduled transitions permission has to be given. This also gives access to the scheduled transitions settings form, which is not always the desired behavior.

Just as there are per entity type & bundle permissions for "view" and "add" operations, I think it would be logical to provide the same for "delete" operations.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rp7 created an issue. See original summary.

rp7’s picture

A first attempt at this, be gentle :-)

I had (possibly still have) a hard time grasping my head around access mirroring.

rp7’s picture

Status: Active » Needs review

Status: Needs review » Needs work
rp7’s picture

StatusFileSize
new16.3 KB

Fixing a few tests. Still WIP.

dpi’s picture

Currently, the only way for allowing users to delete scheduled transitions, the administer scheduled transitions permission has to be given.

Are you sure this is true?

I think if the user has access to delete the associated entity, they will also have access to delete the scheduled transition.

Understandably having permission to do both isnt always desired, perhaps this issue should be about implementing mirror operation functionality?

As far as the patch approach goes, take a look at ScheduledTransitionsRouteProvider.php and copy the _entity_access things from there, and override the getDeleteFormRoute method. Changes to \Drupal\scheduled_transitions\ScheduledTransitionsAccessControlHandler::checkAccess are not necessary.

You basically need to add an extra Delete section whereever the existing Add/View operation logic happens, there shouldnt be any Delete specific code (e.g new code in ScheduledTransitionsAccessControlHandler::checkAccess)

config/install/scheduled_transitions.settings.yml needs to be modified and an update path for existing sites is required. Mirror 'delete' to 'update' sounds logical.

rp7’s picture

StatusFileSize
new16.18 KB

Re-rolled patch against latest dev.

@dpi You may very well be right. I'll have to investigate it further. I'm hopeful I can find some time soon.

dpi’s picture

Similar work is undertaken in #3119360: Reschedule transitions, which will be posted in the near future.

rp7’s picture

StatusFileSize
new21.59 KB

Hi @dpi

I think if the user has access to delete the associated entity, they will also have access to delete the scheduled transition.

Correct.

Understandably having permission to do both isnt always desired, perhaps this issue should be about implementing mirror operation functionality?

Correct.

Re-rolled patch against 2.x & is now more in line with the solution in #3119360: Reschedule transitions. The upgrade path (update hook) is probably not complete yet.

Bare in mind that this functionality is also impacted by the issue mentioned in #3179616: Rescheduling not possible without "View all scheduled transitions" permission.

rp7’s picture

Status: Needs work » Needs review
rp7’s picture

StatusFileSize
new21.45 KB

Now without the same mistake for delete operations as in #3118123: Custom access rules impossible for scheduled transitions.

Status: Needs review » Needs work

The last submitted patch, 11: scheduled_transitions-delete_permissions-3082728-11.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

rp7’s picture

StatusFileSize
new21.45 KB

This fixes at least 1 failed assertion. Will need help with the other one (same a in [#3118123).

falc0’s picture

Updated to the latest version (2.2.1).
Wrong file, correct one in next comment.

falc0’s picture

StatusFileSize
new21.26 KB
alfattal’s picture

@falc0 Patch in #15 failed to apply.

rp7’s picture

Fixed patch in #15 so that it applies to 2.3.x

mjmorley’s picture

Added a patch here to update the hook update number so it applies to 2.4.x

falc0’s picture

Had an error:
Error: Call to undefined method Drupal\node\Entity\Node::isProcessed() in Drupal\scheduled_transitions\ScheduledTransitionsAccessControlHandler->checkAccess() (line 55 of /app/web/modules/contrib/scheduled_transitions/src/ScheduledTransitionsAccessControlHandler.php).

Fixed it in the latest patch (see interdiff).

gugalamaciek made their first commit to this issue’s fork.