The post data contains userid, username, secret, token and so forth. Some of that info is hashed to authenticate the post. That is why it needs to be submitted as the real user. That's why I am inclined to use the data as is and work it server side after the post is made. Here's a rough idea of what I'm thinking.
Post is clicked anonymous. That click changes the class on the reply button to call the custom controller using jquery.
The controller hands off the data to the createcontent controller and intercepts the jsonResponse.
The json Response has the nodeid of the new post. The controller then takes that nodeid and does an insert into the anonymous db table with userid and whatever else may be needed, then returns the jsonResponse to the browser to complete the post and reload the page.
In the content template, there would be a conditional that checks if the post nodeid =anonymous.nodeid, if it does, it replaces the post authorname with "Anonymous" else it just continues loading as usual.
There will need to be an api extension made to query the anonymous table. The whole process should only add one db query.
This is just a rough idea and may not work as I haven't tested any of it.
I do have a working api extension to query the database for the template conditional that I can share with you.
|