I'm just starting to re-implement an old anti-spam mod I wrote for my forum as an extension. One of the things I need to do is to mark a post as un-approved at the point of posting, depending on a few variables.
As a proof-of-concept of what I wanted to do, I hooked a listener onto the core.posting_modify_submit_post_before event. Then it looked like I needed to add force_approved_state to the post's $data array.
I stumbled a little when I found that I couldn't just set $event['data']['force_approved_state'] directly in my code (because $event['data'] is done with ArrayAccess?) so I ended up with the following code:
Code: Select all
$data = $event['data']; $data['force_approved_state'] = ITEM_UNAPPROVED; $event['data'] = $data;
a) Is this the right way to add a value to $data in the event listener? Copying the whole array, adding a value, and writing it back again seems a little clunky.
b) Does this look like a sane approach to changing the approval status of a post at the point of submission?