Im making a commentsystem for the user´s status.
I have made so you can comment, see the comment and so on.
Now i would like to make notifications for it. So if you have commented on an status, you will by default “follow” the status, and by that means that if any other also writes a comment in the same status, then you will be notified.
I have thought about it for some time now, I need an idea/example in which way i could do this.
I have users_msg to hold all the notifications the users get. On every page(include) it is checking if you got any new notifications(checking if theres any new rows that you havent seen in users_msg) and then displays it in an jgrowl. Works fine.
Im stuck at how should it check if any other has commented? Have thought of this:
1) Storing the $statusid in a var, and then check after the id in users_statuscomments? Then I would also need an column to check if it has been shown for EACH user..
2) Or maybe make a table users_notifications, and insert the userid + what statusid you follow on submit, and when another user is submitting an comment, then it checks if theres any that is following the status(checking the users_notifications) and then make a new row in users_msg for those who follow?
I like the 2) as i can think that it can work fine, but im insecure if this is a good method(if no, why not/any other solution?)
As you can hear im stuck, hope for some good solutions on how to do this simple and smartest as possible.
Thank you
The second variant is how Observer design pattern works. It looks more appropriate.