mybb - how to check for new private messages
I'm trying to build an chrome app/extension for my website which is mostly a mybb for开发者_开发知识库um. I am wondering if anybody knows how would I check to see if a user has new Pm's or maybe new posts on his thread? Maybe by JS, AJAX, or PHP
As far as events go, generally for PM's there is a field in the database called 'read', which is false if they haven't opened it, and true if they have. On a page load, check to see if there are any messages to the user that are 'unread', and if so, load them, and use JQuery to make a pop up saying a short description of them. You could also have a small AJAX script periodically check for this.
As far as new posts go, the traditional way that I've seen it done (but by no means the best way) is to keep a timestamp of when a user last visited the site. On page load, get every new post/topic that was created after that timestamp, then serialize this data and store it in the database, or in a cookie (if this serialized data already exists, unserialize it, merge the two and reserialize it). If a user visits a topic, get all data from the serialized entry that matches (IE, in the same topic, or the post number) and remove it from the serialized data. Then again on page load or by using an AJAX script, check periodically if they have an 'unread' post on a topic that belong to them (IE, created after their last timestamp value), and use a bit of JQuery to notify them.
- Learn JQuery. It is a very friendly javascript framework and you will be up and running in no time. Coding in JQuery is fun!
- Do periodic AJAX request.
- inject data into DOM or maybe if you are creating a Google Chrome Extension like your tag is telling use the awesome Desktop Notifications System.
精彩评论