Issue Bug Closed

#106238The enventlistener's ModifyEditFormUserAccessEvent method denyUserAccess() still allows users to delete content

Michael Perlbach 02/23/25, 12:55 updated 03/07/25, 23:34

Description

When trying to deny a user’s access to a content element using the eventlistener “ModifyEditFormUserAccessEvent” and it’s method denyUserAccess() method.

Although denyUserAccess() prevents a user from editing a content the user is still allowed to delete this content. This is not the expected behaviour. denyUserAccess() should also disallow deleting a content element.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

Files 1

History 10

  1. Georg Ringer commented and changed status New Needs Feedback 02/25/25, 06:57

    Thanks for creating this issue.

    You mean deleting via datahandler or using a different UI? this needs to be checked using one of the hooks of the datahandler. This event is just for the ui

  2. Michael Perlbach commented 02/25/25, 09:36

    I did not take a deeper insight into the technical details as I am currently in production and have to deliver.

    The Eventlistener’s method “denyUserAccess()” denies access to the edit interface of a content element (which works) – and at the same time still allows for that user to delete that content element.

    Either there should be a clear naming of the methods which indicate what one might expect, something (for example) like:
    denyUserEditAccess()
    denyUserShowAccess()
    denyUserDeleteAccess()
    denyUserCreateAccess()

    or “denyUserAccess()” should also prevent from deleting.

  3. Georg Ringer commented 02/25/25, 21:03

    thanks for the fast feedback. sorry for my lack of understanding but what do you mean with

    > and at the same time still allows for that user to delete that content element.

    thanks!

  4. Michael Perlbach commented and changed attached celm.jpg 02/25/25, 22:01

    Hi Georg,

    Please refer to the image I sent along this reply.

    I created a custom content element named “event”. A user with restricted access can see a list of these events on a single-column-page in the module Web-Page.

    For each of these content elements there is an “edit” button and a “delete” button (and there is no way in TYPO3 to hide them).

    In an EventListener I used ModifyEditFormUserAccessEvent() to allow a user to edit some events and some not – based on his user group. When a user is NOT allowed to edit an event and he clicks on the “edit”-symbol [1] he gets an error message. However, when the user clicks on the “delete”-symbol [2] of this same event he can delete the event – although he is denied access. I do not think that this is consistent behaviour.

    Just to illustrate it further – here is a code snippet:

    if(!in_array($editgroup,$beusergroups)){
        $event->denyUserAccess();
    }

    That’s my condition. So when setting “$event->denyUserAccess()” a user cannot edit this CE (error message instead of edit form). But he can delete it.

    I have no idea how to explain it better.

  5. Oliver Bartsch commented 03/03/25, 11:01

    Hi Michael,

    thanks for your detailed explanation! As the event’s name already suggests, does it only apply to the editing form (FormEngine). The buttons your are part of the page module and are therefore not affected by this event. To hide e.g. the delete button, there would be a couple of options, naming two of them:

    1. By dynamically applying user TSconfig (https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/UserTsconfig/Options.html#confval-useroptions-disabledelete)
    2. Using $GLOBALS[‘TYPO3_CONF_VARS’][‘SC_OPTIONS’][‘t3lib/class.t3lib_userauthgroup.php’][‘calcPerms’] hook to dynamically set the permissions.

    I hope this helps.

    Best,
    Oli

  6. Michael Perlbach commented 03/03/25, 11:19

    Hi Oli,

    Thanks for your answer.

    So you say the “delete” button and the “delete” function is not part of the editing form? It is part of – what then?
    The thing is that when I set “denyUserAccess()” I do not expect that a user is not allowed to access to the content’s edit form – but at the same time can delete this content element.
    I consider this inconsistent and for a normal programmer like me hardly comprehensible.

    Fortunately I am now using the eventlistener “ModifyDatabaseQueryForContentEvent” which enables me to only show content elements of appropriate usergroups – so the problem of being able to delete content of other users is no longer a problem for me.

    However, I think the eventlistener “ModifyEditFormUserAccessEvent” needs some rework.

  7. Oliver Bartsch commented and changed status Needs Feedback Closed 03/03/25, 22:08

    Hi Michael,

    I really appreciate your feedback, and I’d like to clarify a few things. When we talk about the delete button in the page module, we refer to a UX element used in other backend modules—such as the list module—to initiate the deletion workflow. This workflow has nothing to do with the editing form, which is a component for editing records in the backend. The event—just as its name implies—is solely concerned with managing access to the editing form, regardless of where that form is linked from in the backend. Therefore, it does not connect in any manner with the delete button(s) or the underlying delete functionality. It’s important not to mix these aspects. The delete button you’re referring to is just a part of the backend’s user interface, whereas the event “ModifyEditFormUserAccessEvent” strictly governs access to the editing form itself. This separation of concerns is intentional and aligns with the previous hook ($GLOBALS[‘TYPO3_CONF_VARS’][‘SC_OPTIONS’][‘typo3/alt_doc.php’][‘makeEditForm_accessCheck’]), which functioned in the same way.

    I hope this clears up any confusion. There won’t be any changes in this behavior, as it’s working as designed.

    Since you found another event, which suits better for your use case, I will close this issue for now. Please don’t hesitate to come back in case there is still something not working with the event.

    Best regards,
    Oli

  8. Michael Perlbach commented 03/05/25, 13:24

    Hi Oli,

    Although this issue is closed, one last remark from my side.

    First of all: I still think TYPO3 is the best open source CMS framework currently on the market – that’s why I am still working with it.

    As I am not part of the TYPO3 developer team I can hardly have any influence on how things are handled in TYPO3 but I think that I may speak on behalf of programmers working with TYPO3.

    Basically, programmers working with TYPO3 do not care how processes are handled within TYPO3 internally and which class, method, function, module or process is responsible for what.
    What programmers working with TYPO3 rather require is a flexible, easy-to-learn, easy-to-work-with and consistent programming environment.

    The edit form for content elements is the best example for an inconsistency on that level – on the one hand being able to disable access to a content element’s edit form but not being able to disable a content element’s delete button at the same place. I understand that there are different processes to handle access to the edit form and the delete button.
    But then there should be some sort of intermediate layer using those different processes to provide an understandable and consistent interface for a programmer working with TYPO3.

    In the case of the “ModifyEditFormUserAccessEvent” at least these methods should be made available (“show” does not make much sense here as the event is only triggered when a user clicks on something):

    - denyUserEditAccess()
    - denyUserDeleteAccess()
    - denyUserCreateAccess()
    - denyUserAllAccess()

    And the Eventlistener’s method “$event->getCommand()“
    should provide the following commands:
    - new (already available)
    - edit (already available)
    - delete (not available)

    I hope I made myself clear on that point. And no offence intended.

    Kind regards
    Michael

  9. Oliver Bartsch commented 03/07/25, 21:21

    Hi Michael,

    I completely understand that. Although it’s hard to achieve in this specific case as the underlying functionality is just not “designed” for this. For example, there is no “delete” command, because FormEngin (the editing form) only knows “new” and “edit”. One can either create a new record or edit / update an existing one. Deleting a record – as said before – is actually an action which is processed by a completely other system component. But again, I completely understand that this is hard to grasp when not that familiar with all those internals. I will definitely keep this in mind and hope that I can come up with a better and more intuitive solution.

    Best, Oli

  10. Michael Perlbach commented 03/07/25, 23:34

    I just read the roadmap for TYPO3 14 – and it looks promising.
    https://typo3.org/article/roadmap-for-typo3-v14-the-high-level-objectives-and-strategic-goals