DISCUSSION: First attempt at introducing an action/hooks interface for detailed customization of Admidio #1899
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a first proof-of-concept to add a proper messaging system with hooks, filters and actions to Admidio, similar to the actions/filters of Wordpress. This is not yet meant for immediate merge, but to get some feedback for the final, polished implementation.
The changes to User.php, common.php and changelog.php show how this can be used inside the existing Admidio code.
Filters can modify the objects passed to them, but are not expected to have many side-effects.
All filters registered for 'changelog_headline' will be given a chance to modify the passed object(s). E.g. anywhere in a PHP file that is loaded on startup (plugin, other module, ...), you can register a filter. This example simply wraps "HOOKED: {........}" around the original headline:
To add a listener to the action, simply register a function with add_action:
Of course, to be able to properly make use of this functionality, one needs to go through all the Admidio code and add lots of generic hooks and actions all over the place to make Admidio as flexible as possible.
My first target is to hook into the User creation/modification/deletion to sync the user data to Nextcloud via SCIM (as basis for the SSO). But other uses I envision is to modify the sidebar menu depending on the user groups.
This would also allow us to entangle some code in Admidio, e.g. by moving the user modification notification mails out from the User.php class into their own listeners in a separated file (in the future, even in a separate plugin, once a proper plugin system is implemented).