I am trying to make a general "my updates" page that shows the user unread posts and private messages. However, there doesn't seem to be a way to list private messages outside of the basic user/#/messages page.

CommentFileSizeAuthor
#3 privatemsg.views_.inc_.zip825 bytesjguffey

Comments

litwol’s picture

Version: 6.x-1.0-rc2 » 6.x-1.x-dev
Status: Active » Postponed

good feature. but it is not being developed right now. you are encouraged to sponsor feature development. thanks.

litwol’s picture

Status: Postponed » Closed (won't fix)

I am not sure if there is a way to expose private messages to views without breaking functionality,but also without enabling the user from being able to create poor views listing configuration which would end up in private data being publically accessible....

long story short, not a good idea at this time.

jguffey’s picture

Status: Closed (won't fix) » Needs review
StatusFileSize
new825 bytes

I managed to add some views support for PrivateMsg,

After switching to pm_lite (Because nodes are easier to make views for) and then switching back to PrivateMsg (because messages as nodes seems like a bad idea, as you point out). I added my own privatemsg.views.inc. I understand the risk of bad drupal admins exposing private information to the public, but I personally feel it's up to individual site administrators to take that risk or not- not us to decide to support something because of its risk of misuse.

That being said, I'm totally new to module development, but Views integration to existing modules seems easy enough. I managed to return a list of messages, and set up a recipient user ID relationship, so that the view would only show you messages that belong to you, as well as a "deleted or not" filter, to filter out messages that users have deleted.

Code to activate the views include, place this in privatemsg.module (I put it at the end.)

/*
 *	Implementation of hook_views_api()
 */
function privatemsg_views_api(){
  return array(
    'api' => 2
  );
}

Then just drop in privatemsg.views.inc that I've attached here, as a zip file (I don't know how to- or even if I should make a .patch file)

***Note, this is a rough first draft- proof of concept. I'm not a Drupal developer, and probably overlooked some things. Don't use this on your production site, unless you know what your doing.***

To get the most out of the view, make sure to add a relationship on the "Recipient ID", so that you gain access to all of the User fields and filters.

To filter out all but the currently logged in user, after the relationship add a argument, User:UID, and provide a default argument for the currently logged in user (which should be you).

LiveWire’s picture

Thank you for the input this is exactly what I am in need of. However I have not been successful in implementing. I have added the code at the end of the "privatemsg.module" and I have dropped the zip file in "views/modules." Any suggestions?

RoboPhred’s picture

Status: Needs review » Closed (duplicate)