View Issue Details

IDProjectCategoryView StatusLast Update
3438Composrcns_warningspublic2024-07-25 21:58
ReporterChris Graham Assigned ToPDStig  
PrioritynormalSeverityfeature 
Status resolvedResolutionfixed 
Summary3438: Hooks for the punish form
DescriptionPatrick: "I would recommend the warnings bundled addon to also work via. hooks. That way, certain features / addons can have their own entries in the punishment form. For example, say if I create an addon where users earn charms for their profile... and I want staff to be able to revoke charms as a form of punishment. The addon can then create a hook for the punishment form allowing me to choose charms to revoke for that user.

Another reason would be if I decide to make and release my karma addon. It'd be much easier to implement into the warnings system via. hooks."
TagsRisk: Database change , Roadmap: v11
Attach Tags
Time estimation (hours)1.5
Sponsorship open

Sponsor

Date Added Member Amount Sponsored

Relationships

related to 5476 ResolvedPDStig Add a warning hook to allow specifying recent point transactions to reverse 
related to 5081 ClosedPDStig Demerits / Warning Points system 

Activities

PDStig

2023-11-06 15:20

administrator   ~8016

I've already started working on this a while ago for another client. And now that the upcoming karma addon for v11 will also necessitate this, I'm marking this on the map for v11.

I went with a different approach, however, from the issue. I decided on a restructuring of the warnings system. But I believe it will result in a lot of benefit for the Composr software.

* The warnings system is now "centered" around warnings hooks. Each punitive action that can be taken is a hook. Hooks also have a get_details method which currently just defines order (order which the fields will appear on the warning form and the actions taken will appear in the message text when auto-generating).
* The warnings form uses the hooks to load in fields for the warning form (except for type of warning, explanation, and message fields which will remain native to the module as they do not relate to specific punitive actions).
* The addon uses the hooks as well to actualise punitive actions and auto-generate punitive action text.
* A new table was created: f_warnings_punitive, which is a log of every punitive action taken (and whether it was reversed) mapped to the warning ID.
* The f_warnings table has been changed; all p_* punitive action columns have been removed. The upgrader will migrate data from the removed columns over to the new f_warnings_punitive table.
* Due to the database changes and the fact each punitive action is a hook, we can now also better support the ability to undo / reverse punitive actions and to visualize the actions taken on the warnings screens. Usually, every punitive action can be reversed except ones dealing with deleting content.

And the biggest benefit of them all:
* Now that the warnings system uses hooks, other addons can make warning hooks to introduce new forms of punitive actions. For example, you could make a hook for Buildr that defines a punitive action where you lose all your items, or you lose X health. Or giftr could define an action that causes the member to lose a specific gift they have. There are many possibilities. A real-world example is the upcoming karma addon will have a hook allowing to define an amount of bad karma to be assigned to the member for their warning.

PDStig

2023-11-28 11:20

administrator   ~8073

It has been completed. I also did a lot of improvements to the warnings screens. More tweaks are to come in the future, but the bulk of the work has been finished.

Issue History

Date Modified Username Field Change
2017-11-29 14:03 Chris Graham New Issue
2023-02-11 19:41 Chris Graham Relationship added related to 5081
2023-11-05 05:34 PDStig Tag Attached: Roadmap: v11
2023-11-05 05:34 PDStig Assigned To => user4172
2023-11-05 05:34 PDStig Status Not Assigned => Assigned
2023-11-06 15:20 PDStig Note Added: 0008016
2023-11-06 15:24 PDStig Tag Attached: Risk: Database change
2023-11-28 11:20 PDStig Status Assigned => Resolved
2023-11-28 11:20 PDStig Resolution open => fixed
2023-11-28 11:20 PDStig Note Added: 0008073
2024-07-25 21:58 Chris Graham Relationship added related to 5476