Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Private Messages Notification

edited March 2007 in Vanilla 1.0 Help
I am currently using Private Messages 1.1 and it functions perfectly but I would like to add some functionality to it and need a bit of a push in the right direction. I would like users to see some sort of visual identifier saying they have unread PMs when they visit the site - probably just a box at the top, I have yet to decide. What would be the proper way to query the database and return the number of unread PMs for that user?

Comments

  • I've done some digging through the Private Message extension and found the a class entitled 'PrivateMessages' and a function called 'GetNewmessageCount' which returns the number of new messages (obviously).

    I have also found a line that reads
    $NoticeCollector->AddNotice($Context->GetDefinition('SelectPrivateMessagesCategory'));

    So, this AddNotice function gets my attention - it seems to be an effective way of notifying the user's they have unread Private Messages. But, I'm not well-versed in OOP PHP. How would I call the GetNewMessageCount() function within the PrivateMessages class from ./index.php (I am thinking in the same area where it builds page controls).
  • http://lussumo.com/community/discussion/4578/2/private-messages-11/ use bshultz version or at least it might be helpful for your work. He created a side panel notification
  • i agree that a box in the header would be good, and possibly more useful than the sidebar notification (although i'm not complaining - it seems to be working fine).
    a similar notification box is included in the extension that notifies users of new whispers. i forget the name of it now... maybe it's just called notify?
  • I made a rather weak attempt at this yesterday - I'm not quite used to Vanilla's extension system. Here's what I tried that did not work:

    In index.php, line 58 (after the if ($ShowUpdateMessage) block):

    $PrivateMessages = $Context->ObjectFactory->NewContextObject($Context, 'PrivateMessages'); if ($PrivateMessages->GetNewMessagesCount() > 0) { $NoticeCollector->AddNotice('You have unread private messages.'); }

    Honestly, I wasn't really expecting this to work - it was a shot in the dark. I'm going to take a look over the work that bshultz did and see if I can devise something.
This discussion has been closed.