Subject: Plugin development.
Alrighty, so I'm helping my friend out by writing a "post as anonymous" plugin, as per this thread. So, what I've got so far, is the config page, saving the settings, and adding the required fields and tables. Here's how I have it planned to work..
'anon' field added to posts, to flag a post as anonymous.
'anonypost' table added: id, threadid, userid, anonymous name
Two setting added: basename for the anonymous name, and the avatar to use for them
1. User opens the Post Options below the post, and checks off "Post Anonymously".
2. Plugin sees this, and sets the added "anon" field in the posts table to 1, for this post.
3. When the post is being parsed, in the post.preparse phase, it checks for the anon flag. If it's found..
4. Look in the "anonypost" table for this thread to see if this user has posted in this thread already. example: select name from anonypost where ((threadid = thisthread) and (userid = thisuser)). if a name's returned, use it. Otherwise, pull all the anonymous names (select name from anonypost where threadid=thisthread), trim them to just the number, get the max, and increment it.
5. Use the "anonymous name" instead of their real one. Use an anonymous-specific avatar. Remove the signature and other information.
6. If an admin is looking at the post, show the post normally, but add "this was posted anonymously" to the end of the message.
Now, I've got some of this done, but the API and Hooks are kicking my butt.
I'm stalled at step 2 - I can add the option to the Post Options section, but there seems to be no way to read that! post.preparse doesn't do it. post.postthreadcreate doesn't do it.
edit: okay, got it. Have to check $_POST array in post.verifyaccept.
Also, one potential issue I see is with quoting - is there a "prequote" hook?
I'm trying to write this as an actual plugin, rather than just hack the code into shape.
'anon' field added to posts, to flag a post as anonymous.
'anonypost' table added: id, threadid, userid, anonymous name
Two setting added: basename for the anonymous name, and the avatar to use for them
1. User opens the Post Options below the post, and checks off "Post Anonymously".
2. Plugin sees this, and sets the added "anon" field in the posts table to 1, for this post.
3. When the post is being parsed, in the post.preparse phase, it checks for the anon flag. If it's found..
4. Look in the "anonypost" table for this thread to see if this user has posted in this thread already. example: select name from anonypost where ((threadid = thisthread) and (userid = thisuser)). if a name's returned, use it. Otherwise, pull all the anonymous names (select name from anonypost where threadid=thisthread), trim them to just the number, get the max, and increment it.
5. Use the "anonymous name" instead of their real one. Use an anonymous-specific avatar. Remove the signature and other information.
6. If an admin is looking at the post, show the post normally, but add "this was posted anonymously" to the end of the message.
Now, I've got some of this done, but the API and Hooks are kicking my butt.
I'm stalled at step 2 - I can add the option to the Post Options section, but there seems to be no way to read that! post.preparse doesn't do it. post.postthreadcreate doesn't do it.
edit: okay, got it. Have to check $_POST array in post.verifyaccept.
Also, one potential issue I see is with quoting - is there a "prequote" hook?
I'm trying to write this as an actual plugin, rather than just hack the code into shape.

TwystNeko
Show profile
Link to this post