I'm using Silex (not sure if relevant) to build a blog, and I want to add the possibility for the user to report a comment.
Initially I just added a boolean flagged
column to my comments
table, set it to false
by default, and switched it to true
whenever a user clicked on the "Report the comment" button. My plan was to then be able to easily show all flagged comments to the admin. But I realised that any user could then just go and Report every comment, drowning the administration panel with it.
So I want to try it differently. I want to count how many times a specific comment has been flagged, so I can reflect that on the "Flagged comments" section of the administration panel, that way the admin can quickly see which comments have been flagged by one lonely troll and which ones have been massively flagged and deserve attention.
I also want to remember what comments a specific user has flagged himself, so I can disable the "Report the comment" button for him on comments he did already flag.
Two questions here :
Thanks !
One good way to do this would be to create a new table to hold at the bare minimum userid and commentid. Add other columns for any other information you would want to track when a user has flagged the comment.
The benefit in this method is that it will allow you to use joins in your sql to pull a user and all their flagged comments, or a comment and all the users who flagged it. It also allows you to do quick counts by querying that table directly.
Indexes on your userid and commentid columns, will keep things snappy as the table grows.