Reputation: 6805
I've seen lots of various posts on SO regarding notification systems for users, (e.g., a user comments on a picture, sends a message, etc...).
I am curious how to put together "system notifications" that would be generated by the website administrator. These could be messages that are displayed to every user upon login, such as:
1) Reminders for system maintenance/downtime 2) Notice of upcoming changes 3) Any other messages that need to be displayed system-wide
What is a good way to do this? I would like these messages to be displayed for all users, and users would have the opportunity to "hide" (thus, marking it as "read") it so it doesn't show up again when they login later. Is this something that should be done database-side, with sessions, or both?
Any ideas on how to get this started would be greatly appreciated!
Upvotes: 2
Views: 2890
Reputation: 3488
I would have a notification table consisting of a msgID, message, creationTime, expirationTime. Then a users table such as userNotifications which would consist of userID, msgID.
When they, the user, flag a message as dismissed, add the msg id to the userNotifications. This lets you build queries for all notifications that are not expired and have also not been dismissed by the user.
Upvotes: 2