I was hoping to be able to create a privatemsg view and pull in private messages for a user into a block... Is there a reason why this module doesn't already have full views integration or am I missing something? Thanks in advance!

Files: 
CommentFileSizeAuthor
#139 privatesg-1573000-with-thread-link.patch12.18 KBdgtlmoon
FAILED: [[SimpleTest]]: [MySQL] 4,913 pass(es), 0 fail(s), and 26 exception(s).
[ View ]
#120 privatemsg-1573000-120.patch11.72 KBtucho
FAILED: [[SimpleTest]]: [MySQL] 4,913 pass(es), 0 fail(s), and 26 exception(s).
[ View ]
#118 privatemsg-1573000-118.patch11.69 KBandypost
FAILED: [[SimpleTest]]: [MySQL] 4,913 pass(es), 0 fail(s), and 26 exception(s).
[ View ]
#118 interdiff.txt18.28 KBandypost
#64 privatemsg-1573000-64.patch12.21 KBdawehner
FAILED: [[SimpleTest]]: [MySQL] 4,913 pass(es), 0 fail(s), and 26 exception(s).
[ View ]
#61 privatemsg-full_views_integration-1573000-61.patch13.71 KByce
PASSED: [[SimpleTest]]: [MySQL] 3,125 pass(es).
[ View ]
#57 privatemsg-full_views_integration-1573000-57.patch13.69 KByce
PASSED: [[SimpleTest]]: [MySQL] 3,125 pass(es).
[ View ]
#54 privatemsg-full_views_integration-1573000-54.patch12.34 KByce
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch privatemsg-full_views_integration-1573000-54.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#53 privatemsg-full_views_integration-1573000-53.patch12.29 KByce
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch privatemsg-full_views_integration-1573000-53.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#52 screenshot.png9.45 KBDrupalDan
#47 Drupal-Testing-Privatemsg-Threading-Index-Broken-Handler.png76.05 KBKristen Pol
#36 privatemsg-full_views_integration-1573000-36.patch12.12 KBtbenice
FAILED: [[SimpleTest]]: [MySQL] 3,118 pass(es), 7 fail(s), and 0 exception(s).
[ View ]
#27 privatemsg-full_views_integration-1573000-27.patch11.94 KBtbenice
FAILED: [[SimpleTest]]: [MySQL] 3,118 pass(es), 7 fail(s), and 0 exception(s).
[ View ]
#24 privatemsg-full_views_integration-1573000-24.patch6.75 KBnoahlively
FAILED: [[SimpleTest]]: [MySQL] 3,118 pass(es), 7 fail(s), and 0 exception(s).
[ View ]
#22 privatemsg-full_views_integration-1573000-22.patch6.19 KBnoahlively
FAILED: [[SimpleTest]]: [MySQL] 3,118 pass(es), 7 fail(s), and 0 exception(s).
[ View ]
#17 privatemsg-full_views_integration-1573000-9.patch11.28 KBtbenice
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in sites/default/modules/privatemsg/views/privatemsg.views.inc.
[ View ]
#9 privatemsg-full_views_integration-1573000-9.patch11.35 KBtbenice
FAILED: [[SimpleTest]]: [MySQL] 3,118 pass(es), 7 fail(s), and 0 exception(s).
[ View ]
#1 privatemsg-fullviewsintegration-1573000-1.patch7.44 KBtbenice
PASSED: [[SimpleTest]]: [MySQL] 3,119 pass(es).
[ View ]

Comments

tbenice’s picture

StatusFileSize
new7.44 KB
PASSED: [[SimpleTest]]: [MySQL] 3,119 pass(es).
[ View ]

I see now that there's no integration really. Here's a patch that did the trick for me. To get thread info just have to use the mid relationship. At least it's a start.

-Ted

tbenice’s picture

Status:Active» Needs review

please test...thnx!

meSte’s picture

Status:Needs review» Needs work

I get this error trying to use the thread_id

Broken/missing handler (Broken handler pm_index.thread_id)

Tried to create a view on messages with relationship to messages threads and also a view on messages threads with relationship to messages but I always get this error and can't access the thread_id but using a custom php field with a direct db select.

Except for this issue the patch seems to work nicely.

Nico7’s picture

Same error here. Could you please fix that?

tbenice’s picture

will do. a bit pressed at the moment. i also need to add a new handler for the message body so that it can use tokens (currently fails on that). will get to it soon.

1kenthomas’s picture

Hi guys,

Seems like a few other threads on this issue are stalled and unaware of this patch/approach, as they wait on changes to this and other modules.

Can we summarize the differences between those approaches and this, and move towards either integration or clarification?

Happy to help on things such as removing the error above-- may need help replicating if the description above is not enough.

tbenice’s picture

My idea behind this patch is to implement a baseline views integration to expose all of the pm related db fields in views. Also, I'm trying to expose the appropriate relationships and filters too.

@1kenthomas, would you mind making a list of the other threads that are relevant? I'd like to see what you're referring to above...thanks alot!

Addressing this patch is still on my list but I'm bogged down (still) with work. If you could try to address the above error that'd be super! If not then it'll wait for me to free some time.

Thanks a-lot!

1kenthomas’s picture

tbenice’s picture

StatusFileSize
new11.35 KB
FAILED: [[SimpleTest]]: [MySQL] 3,118 pass(es), 7 fail(s), and 0 exception(s).
[ View ]

Hi @1kenthomas,

Thanks. That first thread is this thread, and the second seems to be about adding the pm_thread table...which is there in 7.x. I think that this is the only issue trying to expose privatemsg tables to views.

I fixed the above referenced bug and added a new field handler to utilize token replacement on pm text-related fields that use tokens (subject and message).

Note, to allow token replacement, you must pull in the privatemsg id field into your display and enter that field's replacement pattern in the "ID of the Current Privatemsg (REQUIRED for token replacement)" options form field. Works great and uses the privatemsg_token_replace function so it acts just like the pm ui.

Please re-test! Cheers!
Ted

tbenice’s picture

Status:Needs work» Needs review

needs review.

Status:Needs review» Needs work

The last submitted patch, privatemsg-full_views_integration-1573000-9.patch, failed testing.

1kenthomas’s picture

My bad-- must have posted wrong link, should have been drupal.org/node/1042154, I believe. Second link was an issue stalling first thread. Will correct as possible; now about to try your code.

tbenice’s picture

Status:Needs work» Needs review

huh, that's interesting re: drupal.org/node/1042154. I'm not sure why one would want a separate module for views integration. This patch should do the trick. I'm using it successfully for several projects.

Also, not sure why it failed testing. I don't know what to make of the simpletest failures. I'm going to re-queue.

-T

tbenice’s picture

Status:Needs review» Needs work

The last submitted patch, privatemsg-full_views_integration-1573000-9.patch, failed testing.

tbenice’s picture

Status:Needs work» Needs review

I don't know why the patch is failing testing on 'tags functionality' since the patch does not touch this functionality. Looking forward to a human test. thanks!

tbenice’s picture

StatusFileSize
new11.28 KB
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in sites/default/modules/privatemsg/views/privatemsg.views.inc.
[ View ]

new patch

Status:Needs review» Needs work

The last submitted patch, privatemsg-full_views_integration-1573000-9.patch, failed testing.

konsul’s picture

maybe you have to involve the tags functionality!?

1kenthomas’s picture

Perhaps diff this version against the one that passed testing ?!?

/me's cliient had changed sftp password, so I'm going to try install again now...

tbenice’s picture

The patch is against head so maybe the site is comparing to the latest dev release? I still don't get the failure mode (tags?).

Anyways, a human test will be great. Thanks!

noahlively’s picture

Status:Needs work» Needs review
StatusFileSize
new6.19 KB
FAILED: [[SimpleTest]]: [MySQL] 3,118 pass(es), 7 fail(s), and 0 exception(s).
[ View ]

Please see this patch, which deals with 2 things:

  1. The PHP syntax error (there was an unescaped single quote in privatemsg.views.inc)
  2. Fixed the default field on the pm_index table views definition in privatemsg.views.inc (was privatemsg_thread, now thread_id). This was causing a broken/missing field handler message on new views of type "Privatemsg Threading Index" before it was fixed

Status:Needs review» Needs work

The last submitted patch, privatemsg-full_views_integration-1573000-22.patch, failed testing.

noahlively’s picture

StatusFileSize
new6.75 KB
FAILED: [[SimpleTest]]: [MySQL] 3,118 pass(es), 7 fail(s), and 0 exception(s).
[ View ]

My patch failed testing, but it looks like the tests are totally unrelated to the patch.

I'm submitting a second patch. This one addresses a couple more bugs I found while using the original patch.

I've added a join instruction between pm_index and pm_message, like this:

<?php
$data
['pm_index']['table']['join'] = array(
   
'pm_message' => array(
     
'handler' => 'views_join',
     
'left_table' => 'pm_message',
     
'left_field' => 'mid',
     
'field' => 'mid',
    ),
  );
?>

I also changed the views_handler_field_pm_new class to inherit views_handler_field_boolean instead of views_handler_field_field.

Lastly, the thread_id field on pm_index was always rendering as a thread link. I changed the views handler for $data['pm_index']['thread_id'] to views_handler_field_numeric and created a separate field for the thread link that uses views_handler_field_pm_thread_link, since there are occasions where the numeric thread ID alone will come in handy.

See attached.

noahlively’s picture

Status:Needs work» Needs review

Changing to "needs review"

Status:Needs review» Needs work

The last submitted patch, privatemsg-full_views_integration-1573000-24.patch, failed testing.

tbenice’s picture

Status:Needs work» Needs review
StatusFileSize
new11.94 KB
FAILED: [[SimpleTest]]: [MySQL] 3,118 pass(es), 7 fail(s), and 0 exception(s).
[ View ]

@noahlively- thanks for the help! I was using a relationship to access the thread table but the join makes much more sense and is definitely the right approach.

The new patch applied cleanly and the views worked great. However, I noticed we neglected to add a relationship for recipient on the pm_index table so I added that. Now we have relationships to both sender and recipient that can be used to access user fields for both...so I don't think we need the user table joins. Do you agree?

Fresh patch attached.

Status:Needs review» Needs work

The last submitted patch, privatemsg-full_views_integration-1573000-27.patch, failed testing.

zikaelismik’s picture

Hello, i applied the latest patch but still have the broken/missing field error when creating new Privatesmsg Threading Index. Patch applied against 7.x-2.x-dev, could this be the issue in some way?

EDIT: i tried with 7.x-1.x-dev still got the same error, plus i got a SQL statement error:


PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal_local.pm_disable' doesn't exist: SELECT 1 FROM {pm_disable} WHERE uid = :uid ; Array ( [:uid] => 1 ) in privatemsg_is_disabled() (line 377 privatemsg.module).

Sorry, this last error was not related to the issue, could be some mess in my test installation.
Anyway the handler error is still there, the sql error i got is about a join, only got this message:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM pm_index pm_index LEFT JOIN pm_message pm_message ON pm_index.mid = pm_mes' at line 1

showing the sql query in views gives me this:

SELECT
FROM
{pm_index} pm_index
LEFT JOIN {pm_message} pm_message ON pm_index.mid = pm_message.mid
INNER JOIN {pm_index} pm_index_pm_message ON pm_message.mid = pm_index_pm_message.mid

I guess something is wrong with table names on the inner join

tbenice’s picture

Status:Needs work» Needs review

Hi zikaelismik,

1) yes the patch is against 1.x-dev not 2.x-dev. I suspect that it will break if patching the latter, but might work too. I haven't tested that.

2) you probably need to clear cache. I have verified that the patch will give broken handlers if you do not clear cache to rebuild views after applying. I have also verified that it works great after a cache clear.

Hope that helps.

T

rikki_iki’s picture

I'm getting the same broken/missing handlers & sql error on 1.x-dev even after clearing the cache. Is there something else I can try?

zikaelismik’s picture

Thanks tbenice for your quick reply, unfortunately i'm stuck with that error even after clearing the cache. My other questions are:
1) which field is supposed to be there that gives that broken handler error?
2) i added a few custom fields to the messages, are those supposed to be accessible from views?

Thank you
Michele

EDIT: ok, patching against 1.3 works fine, anyway from what i understand the broken handler error doesn't compromise functionality, you just have to delete that field and manually add the thread id. am i right?
Question number 2) remains, correct me if i'm wrong, but from what i've seen, i suppose there is no easy way to load those fields from view.

tbenice’s picture

Hi Michelle. The patch should work against 1.x-dev, very strange.

1) Can you verify that the new handler files are being created in privatemsg/views?
2) I haven't tried that. Since privatemsg is an entity, I think that views should just pick up your fields. That is unless there's something missing. I'll look at it.

Thanks!

zikaelismik’s picture

Hi tbenice,
yes the files are there, and you're right about 2), the view picks up the fields correctly in messages now. What is still missing to me is the ability to filter by the id of the thread as a contextual filter. it just isn't in the list of available filters, the only ones i got are :

Privatemsg: Privatemsg Recipient
Privatemsg: Send Date

Thank you again for your responses!
Michele

tbenice’s picture

Oh ok. I see what you're after. Actually, that wasn't implemented but it makes plenty of sense. I'll put it in and re-roll the patch.

-T

tbenice’s picture

StatusFileSize
new12.12 KB
FAILED: [[SimpleTest]]: [MySQL] 3,118 pass(es), 7 fail(s), and 0 exception(s).
[ View ]

Here's the new patch with thread id contextual filter support.

Status:Needs review» Needs work

The last submitted patch, privatemsg-full_views_integration-1573000-36.patch, failed testing.

zikaelismik’s picture

Thank you! It works perfectly :) Still i'm not able to pass the thread id from a panel page (messages/view/% overridden with page manager existing pages) to the view but that's totally another business!

tbenice’s picture

Status:Needs work» Reviewed & tested by the community

Thanks Michele for the test. If the maintainer desires this in 1.x I think it's ready to be committed to that branch.

-T

igorik’s picture

So far I know 7.x version is based on 6.2x version,
so if you will add it for 2.x version, it can be used e.g. for 7.x version (if there is not something like this already)
Personally, I am very sceptic about any work for 6.1 version from Privatemsg maintainer.

gittosj’s picture

This issue was a deal-breaker for me. Thought it might be useful to mention how important it is since privatemsg would not fit / integrate with any of the use-cases / ui designs I had. As a result I've put together my own content-type called message using entity reference for the to: field etc. Far more flexible. Privatemsg seems like a great module but far too monolithic & inflexible.

Not meant as negative criticism but hope it makes clear how important views integration etc are.

superduperdan’s picture

I know this is not related to this post but I am very curious to know how to pull this off with entity reference? Is there somewhere you can share your process? Thanks

ryan.merritt’s picture

Status:Reviewed & tested by the community» Needs work

The last submitted patch, privatemsg-full_views_integration-1573000-36.patch, failed testing.

tbenice’s picture

Status:Needs work» Reviewed & tested by the community

Putting as reviewed. I have no idea why the tags test fails. Would love to get this committed to 1x and later to 2x (unless there is a different approach in 2x).

ryan.merritt’s picture

The most recent patch worked perfect for me!

Kristen Pol’s picture

Status:Reviewed & tested by the community» Needs work
StatusFileSize
new76.05 KB

I am trying out the patch from #36. When I use the "Privatemsg Threading Index" option, I get a broken handler error. See attached screenshot.

Drupal-Testing-Privatemsg-Threading-Index-Broken-Handler.png

Kristen Pol’s picture

I've tested the "Privatemsg Message" view and it works well so far! Good job :)

plessas’s picture

I have also tested the last patch and it seems to work. In the view i created i am able to get the messages of which the logged in user is the recipient of, however as i am trying to clone the functionality of this module "messages" page, i would like for each thread to show the most recent message only. Is there any way to make this grouping through the views UI? I have read that pragrammatistically this could be done by altering the query with views_pre_execute hook.

Another question i have is if it is possible in the bulk operations section to define "Mark as read" and "Mark as unread" actions. I was not able to find such an option.

Thanks in advance!

superduperdan’s picture

Any plan for this to be pushes to a fully release?

DrupalDan’s picture

sub

DrupalDan’s picture

StatusFileSize
new9.45 KB

Patching #36 is not entirely cleanly made. After applying the patch there was a line indicating there were some add whiteshapce errors. I don't quite understand what that means so I proceeded to create a privatemsg view to find out more, and then I added all privatemsg related fields and show them as a table. Here is what I found:

the message author and recipient were referred as user ID, not name (not sure if it is designed so or not, but if it is, perhaps it would be better if it is the name shown), and it seems that for now there is no way for users to change that

I deleted existing two messages for all users but those two messages are still shown in the view. This is very strange. To see if the messages really got deleted I log in as sender and recipient and yes, the inbox says "no messages available". I suppose this has nothing to do with clearing cache or not but I did that anyway and still, the messages are shown in the view. Most importantly, the View Thread is still alive, which directs me to the page with that message, the one where there's a delete link. I clicked that link and ticked the "Delete this message for all users?" and then "Delete". When I got back to the view, update it, the messages are still there; all are the same. It's like I can delete it for a million times.

A screenshot is attached.

yce’s picture

StatusFileSize
new12.29 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch privatemsg-full_views_integration-1573000-53.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

For me the patch at #36 with 1.3 works, but I had to fix it a little, because if the full_html format is disabled, nothing would appear on views fields.

check_markup() will fallback to a given format if $this->get_value($values, 'format') is empty.

http://api.drupal.org/api/drupal/modules%21filter%21filter.module/functi...

yce’s picture

StatusFileSize
new12.34 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch privatemsg-full_views_integration-1573000-54.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

A little fix for the previous fix :) sorry for that.

superduperdan’s picture

Has this been integrated into the latest dev version? Just saw a new version was released the day after post #54 with the latest patch.

czigor’s picture

yce’s picture

StatusFileSize
new13.69 KB
PASSED: [[SimpleTest]]: [MySQL] 3,125 pass(es).
[ View ]

I added a new filter for privetamsg view. It can now filter by messages which marked for deletion.

tofo1977’s picture

Hi folks :)

i got privatmsg 7.1.-1.x latest dev running and try to patch on my console with the last one from 31.1. maybe im stupid but i get message back "cant find input files". is it possible to got a little howto how i can apply that patch?

thanks & regars
Tom

fraweg’s picture

Hello Tom,

copy the patch into the module folder (..sites/all/modules/privatemsg). After that open a console and type in this folder:

patch -p1 <thepatchname.patch

Best regards
Frank

yannickoo’s picture

+++ b/privatemsg.infoundefined
@@ -12,3 +16,10 @@ files[] = privatemsg.admin.inc
+
+; Information added by drupal.org packaging script on 2012-06-20
+version = "7.x-1.3"
+core = "7.x"
+project = "privatemsg"
+datestamp = "1340212619"

Please remove that and clone the git repository and then apply your changes.

+++ b/views/privatemsg.views.incundefined
@@ -18,6 +18,219 @@ function privatemsg_views_data() {
+  ¶

Whitespaces

+++ b/views/views_handler_field_pm_markup.incundefined
@@ -0,0 +1,56 @@
+  ¶

Whitespaces

+++ b/views/views_handler_field_pm_thread_link.incundefined
@@ -0,0 +1,39 @@
+  ¶

Whitespaces

+++ b/views/views_handler_field_pm_thread_link.incundefined
@@ -0,0 +1,39 @@
+    $value = $this->get_value($values); ¶

Whitespace

+++ b/views/views_handler_filter_pm_deleted.incundefined
@@ -0,0 +1,29 @@
+  ¶

Whitespaces

+++ b/views/views_handler_filter_pm_deleted.incundefined
@@ -0,0 +1,29 @@
+  ¶

Whitespaces

+++ b/views/views_handler_filter_pm_deleted.incundefined
@@ -0,0 +1,29 @@
+    ¶

Whitespaces

yce’s picture

Status:Needs work» Needs review
StatusFileSize
new13.71 KB
PASSED: [[SimpleTest]]: [MySQL] 3,125 pass(es).
[ View ]

Removed whitespaces (sorry for that).
Fixed the new message indicator field.

yannickoo’s picture

Status:Needs review» Needs work

Thank you for the new version of the patch but found some issues again - sorry ;)

+++ b/privatemsg.infoundefined
@@ -12,3 +16,10 @@ files[] = privatemsg.admin.inc
+; Information added by drupal.org packaging script on 2012-06-20
+version = "7.x-1.3"
+core = "7.x"
+project = "privatemsg"

I told you in #60 to not use the development version of this module. You should clone the Git repository (git clone --branch 7.x-1.x http://git.drupal.org/project/privatemsg.git)

BTW why you are not using the 2.x version instead of 1.3? I guess that new features goes into 2.x but I don't know :/

+++ b/views/privatemsg.views.incundefined
@@ -18,6 +18,219 @@ function privatemsg_views_data() {
+  //*****PRIVATE MESSAGE TABLE

Minor notice but why you are using such a comment style? // Private message table looks more like coding standards.

+++ b/views/privatemsg.views.incundefined
@@ -18,6 +18,219 @@ function privatemsg_views_data() {
+    'title' => t('Message Author'),

Why do you uppercase "Author"? Is it a song? ;) I think "Message author" would be better because other fields haven't the title uppercases. But that is a minor issue.

igorik’s picture

I am curious if something like this will be for 7.2x version this year :)
it is really hard to understand why privatemsg 7.2x is not already based on views

dawehner’s picture

Status:Needs work» Needs review
StatusFileSize
new13.81 KB
new12.21 KB
FAILED: [[SimpleTest]]: [MySQL] 4,913 pass(es), 0 fail(s), and 26 exception(s).
[ View ]

Fixed some points all over the places.

I really didn't got on handler: views_handler_field_pm_markup
As far as I understand the goal is to render the message of the result row as field. Do we really have to force people to set the token, because the pmid should be available on the sql result.

In general here is a cleanup of quite some code.

sol0matrix80’s picture

Status:Needs review» Needs work

ok after hours of trying to figure it out i was still unable to get views to display the fields i wanted using relationship am i missing something ?? i have tried privatemsg-1573000-64.patch & privatemsg-full_views_integration-1573000-61.patch still cant make a relationship. Can someone post a step by step please any help is greatly appreciated

tbenice’s picture

Hey dawehner, The reason for views_handler_field_pm_markup is that it is needed to render any token replacement from the messages in the view. Without it if a user uses token replacement in a message then the tokens are rendered in the view as the raw token values. Kindof a fail.

dawehner’s picture

Cool, thanks for the explanation.

One thing i'm not sure about at the moment is that you have to specify the token for the mlid, is there a reason for that? The code should be able to automatically determine the mlid in the result, wouldn't it?

xbrianx’s picture

I am using this patch - privatemsg-1573000-64.patch

One thing I am getting is Html markup displaying in the view. For example if i display the field of Privatemsg: Message it will out put <p>TEST</p> instead of just TEST

xbrianx’s picture

Another weird thing, After I delete the message, it is still showing the message in the views display.

Kristen Pol’s picture

Fyi... I have used the patch in #64 and it works pretty well. There are some shortcomings (e.g. for example, no filter by message id) but I think it is good enough to get into PM!!! We can have follow up issues for the polish, no?

Btw, here's a post I wrote about having troubles creating an admin dashboard for PM messages:

http://www.kristen.org/content/drupal-misadventures-configuring-private-...

:)

Kristen Pol’s picture

Some things that would be handy to have are:

* Filter by recipient
* Filter by author
* Filter by send date

And for fields, the option to link fields to the private message thread, e.g. if you add a thread id field, it has a checkbox for linking to the thread link.

:)

But, I'm cool with committing this "as is" so that this bit of functionality gets in!

Kristen Pol’s picture

Btw, I'm filtering (exposed) by author and recipient using a relationship so that works well! :)

ptmkenny’s picture

Version:7.x-1.x-dev» 7.x-2.x-dev

2.x is the new features branch. This definitely qualifies as a new feature.

ptmkenny’s picture

Status:Needs work» Needs review

#64: privatemsg-1573000-64.patch queued for re-testing.

ptmkenny’s picture

@Kristen Pol I don't think we can say this patch is ready yet because, at a minimum:

#66 token support is broken
#68 HTML markup appears as plaintext when it should be rendered
#69 deleted messages not actually deleted

At the very least, these reported issues need to be investigated.

Kristen Pol’s picture

Ah... well, the delete feature works fine because private messages aren't permanently deleted until the date configured in your PM settings at:

admin/config/messaging/privatemsg

To get the "deleted" private messages to not show up in the view, you need to filter by the PM "is deleted" filter.

So... I don't think anything should be done for this patch regarding the deleted messages as this is how PM is designed... right?

But, token and HTML support sound good. Hope those aren't too hard to do.

tbenice’s picture

Hey yall, i'm surprised that html is not rendering as that's what the *_pm_markup handler was there for. It extends the markup views handler. Maybe something regressed along the way? Not sure about the token support.
Thanks for grabbing onto this. It'll be awesome to replace my fork with a supported release!

-Ted

Kristen Pol’s picture

I'm running into an issue where the view results show up for admin users but not non-admin users. I tried turning off field_permissions with no luck. I also tried granting all roles all privatemsg permissions and it still didn't fix it. I don't have any content access modules enabled.

Anyone have any thoughts on why I don't see messages via views for non-admins while I can see them in the default PM pages (e.g. messages/sent).

I'm perplexed :/

Kristen Pol’s picture

It is something about that particular view itself because I made a super simple view and can see the results from different roles. I'll post back if when I figure out the issue.

tbenice’s picture

Be careful with relationships. Sometimes they can cause such access issues. Try setting the view query settings to ignore sql rewriting.

Kristen Pol’s picture

Thanks for the tip @tbenice! I will try that :) I have a ton of relationships :) I'll figure out how to set views to ignore the rewriting.

Hydra’s picture

Status:Needs review» Reviewed & tested by the community

Well, dawehners patch in #64 is working well, I share Kristens opinion. It would be great to get this in as a basis, to implement even more great views stuff. For example would it be nice to be able to aggregate threads, to aim the functunallity of the /messages page. But this would make this patch more complex, we can do this in followup's.
About the issues in #75, we should create follow ups for them as well. It will be easyer for people who are willing to contibute to that, if they don't need to understand and work through the full views integration patch in #64.

Code looks decent, manuel testing did was I expected the code to do, so for me this is RTBC. Let's hear what the maintainers think about it :)

Kristen Pol’s picture

I agree with @Hydra! :) RTBC++

bennos’s picture

long thread.
looked at the last patch https://drupal.org/node/1573000#comment-7329124
tested it and it works, basic stuff for views, but now we have start with the basic stuff

would be nice to get this in the dev version.
think it will create a lot of followup issues and feature request.

igorik’s picture

Good work!
would be great to have it commited into 2.x version

ptmkenny’s picture

Title:Full Views Integration?» Preliminary Views integration

Need to make clear that what is RTBC is partial, not full Views integration.

andypost’s picture

Status:Reviewed & tested by the community» Needs work

Got the same as #47 also there's no way to use filters - author or recipient at least

Cromian’s picture

Has anyone had any luck creating a delete link for messages through views? I.e. in the listing have a delete thread link just like we have a view thread link.

- C

tbenice’s picture

Those are both great suggestions. However, can we please get this "preliminary" views integration in and then start new issues to address 87 and 88?

pinkonomy’s picture

How can I use this patch? #64
I have applied to the version 7.x-1.3 and i tried to create a view.But there is nothing to do with private message.
Any instructions please?

Hydra’s picture

Status:Needs work» Reviewed & tested by the community

Yeah WT*.
Let's get this in, to have a base to work with. This issue does not a full views integration with all the needy features we want and need, "Preliminary Views integration" is what this issue is about, so please, just let us get this ready and create followups.

@tbenice: Just set it back to RTBC
@pinkonomy: you need to apply it to the latest git version. If you don't have experience with patching, check out the dokumentation pages -> https://drupal.org/patch

pinkonomy’s picture

@Hydra:I patched the 7.x-1.x version.Is this correct or should I apply to 7.x-2.x version?
What should I do next after patch applying?

tbenice’s picture

@pinkonomy- did you clear cache? That has to happen for views to pick up the new handlers.

pinkonomy’s picture

@tbenice I cleared Cache and yes,I can see private messaging when creating a new view,thanks!!

pinkonomy’s picture

Idea:Use Views bulk operations for the Actions (Delete,Mark as unread,Mark as read).
Also use Exposed filters to filter for Inbox,Sent messages,All messages.
thanks!

Majdi’s picture

StatusFileSize
new401.65 KB

I'm building website need private message features, I try this module , The main problem i found That the module is not integrated with views, and I have complex requirements from the designer, I check the theming ability private message module, i found it a bit complex and its don't give you want you want.

this lead me to think how I can build this module using what Drupal have

basically we have Entity, Views, Views Bulk operation using this 3 modules I end up with the 80% of this module functionality and that was fair enough for the requirements I have.

It was a bit confused to create that views with relations but I manage to do it

I attach image for the result I have.

I really think this module should be written in different way for Drupal 7 +

ptmkenny’s picture

Status:Reviewed & tested by the community» Postponed

I talked to Berdir (the maintainer) and he wrote the following:

We skip a number of API's like our dynamic query altering, a lot of
submodules rely on that to do additional things, so a lot of things
won't work anymore, it's easy to misconfigure which results in
security issues (always true with views but Privatemsg is complicated)
and committing the current patch means basically supporting that and
getting lots of bug reports/support questions. There is a
privatemsg_views project where someone tried to provide views
integration but then quickly gave up when it came to these additional
features and modules. Supporting all those features in two different
implementations means a lot of additional work and code. So if
anything, it should probably aim to completely replace what we have
right now, which is a large undertaking.

Also, it should rely on #744374: Introduce a pm_thread table once that is in.

So, I am postponing this issue until we can get #744374: Introduce a pm_thread table working and ported to D7.

Kristen Pol’s picture

The patch from #744374: Introduce a pm_thread table is from 2011 :/ Is someone going to be working on that issue soon?

ptmkenny’s picture

Yes, unfortunately #744374: Introduce a pm_thread table is a D6 issue that needs to be fixed in both D6 and D7.

It would be great if someone stepped forward, but as of right now no one has (to my knowledge, and I've cleaned up about 100 issues in this module's issue queue in the past month).

Currently, working patches (that have tests) are being committed, but I think it's fair to say that no new features are actively being developed at this point.

tbenice’s picture

alright, i'll just keep maintaining my fork for the time being. thanks!

igorik’s picture

Hi,
no offense, I highly respect work of Litwol and Berdir work on privatemsg module for last 7 years.

However, #744374 issue is dated March 16, 2010, and currently nobody is working on it, I think, so we are in the circle and this (preliminary views issue) will be IMHO probably never done same as pm_thread table issue. :(((

So the only option I can see it will be probably to do on addon for message module for using it as substitute privatemsg.

Kristen Pol’s picture

This is unfortunate. I will likely need to rip out my PM views then as it's too risky to use it now. I thought with all the RTBC comments that the views stuff would get in soon but it's clear it won't. I don't know enough about the inner workings of PM to attempt to the the thread table patch.

Sigh.

Well, I can't abandon the module entirely as I've already integrated it heavily into my site so I will either:

* Maintain a customized version of this module with the views integration in place - this will make upgrading to D8 tricky

or

* Not use the views integration and write some code to show what I want to show in various places - safer but more work now

Tis a sad day in Drupal-land but thanks to everyone for their hard work! Who knows... maybe someone will dive in and tackle the thread table beast.

herosen’s picture

Status:Postponed» Needs review

#64: privatemsg-1573000-64.patch queued for re-testing.

ptmkenny’s picture

Status:Needs review» Postponed

Moving back to postponed since the re-test is complete.

herosen’s picture

please give a link to the patched version, I did not get patched

ptmkenny’s picture

@herosen: You can find the documentation on how to apply patches here: https://drupal.org/patch/apply

alesr’s picture

If Privatemsg doesn't support Views integration yet.. is there an alternative to have private messages with views support in Drupal?

ptmkenny’s picture

@alesr I don't think there is another all-in-one solution like Privatemsg, but you could try making a custom solution using the Message, Entityreference, Rules, and Views modules, which all integrate with one another. Even for a basic use case, though, my guess is that this would be a lot of work.

igorik’s picture

The best thing for the future is move out from privatemsg to message, as soon as possible.

alesr’s picture

I'm using Message module for activity stream and Message Notify for sending invites.
"Message stack" with message types defined is good for storing and sending system generated messages.
I don't see how Message could replace Privatemsg without a lot of custom coding.
As I see it, Message would still need most of Privatemsg functionallity to support all features like, reply, correct listing between users, etc..
Maybe a module which implements Message and adds this would be an option. Do you have an idea?

muschpusch’s picture

message module isn't meant for the usecase of privatemsg...

igorik’s picture

yes, now, but it could be I think, with some work about user relationships

Ditiwi’s picture

Status:Postponed» Needs review

#64: privatemsg-1573000-64.patch queued for re-testing.

ptmkenny’s picture

Status:Needs review» Postponed
druvision’s picture

The latest patch (#64) applies against privatemsg 6.4 except for one file - privatemsg.views.inc - which is not found.

ptmkenny’s picture

Just a reminder that #744374: Introduce a pm_thread table must be completed _before_ this patch can be finished, so work should start there...

andypost’s picture

Issue summary:View changes
Parent issue:» #744374: Introduce a pm_thread table
andypost’s picture

StatusFileSize
new18.28 KB
new11.69 KB
FAILED: [[SimpleTest]]: [MySQL] 4,913 pass(es), 0 fail(s), and 26 exception(s).
[ View ]

Updated patch:
- used real column names
- subject and body should use replacement when needed
- strings are changed
- added sorts and filters

EDIT patch implemented in sandbox module views_privatemsg https://drupal.org/sandbox/uzlov/2149597

mttjn’s picture

As in #95, is there a way to set up distinct views for inbox and sent messages?

I've tried various configurations in views but I can't get this. Can only manage to show all messages pertaining to the logged in user, both received and sent.

Would be grateful for any suggestions.

tucho’s picture

StatusFileSize
new11.72 KB
FAILED: [[SimpleTest]]: [MySQL] 4,913 pass(es), 0 fail(s), and 26 exception(s).
[ View ]

I applied the patch from #118 and it works fine.

But I got the following error when using the "Subject" field in a view:

Notice: Undefined index: format en views_handler_field_markup->construct() (line 26 of sites/all/modules/contrib/views/handlers/views_handler_field_markup.inc).

I just added the format to the subject field of pm_message to the patch.

'format' => 'plain_text',

camster’s picture

#120 worked for me, cheers to everyone who has worked on this.

I noticed that it doesn't work with views bulk operations. I tried to do a bulk delete, but it doesn't delete them. Would be nice if it can be added.

mori’s picture

Has anyone tried to work with Views & VBO? I would like to delete messages and mark them as "read/unread" like in the default installation page under "/messages" but somehow "delete" does not work nor "mark/unmark as deleted".

Any patches available?

gladiatorhl2’s picture

I applied #64 patch (7.x-1.4) and there is an error Broken/missing handler (Broken handler pm_message.privatemsg_body). Is something missing? I tried other patches and they don't work either.

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM pm_message pm_message LIMIT 10 OFFSET 0' at line 1

I suppose that this happens because of the newest version of Views?

Privatemsg 7.x-2.x-dev doesn't work for Drupal 7.31 or isn't it possible correctly update from 7.x-1.4 to 7.x-2.x-dev?

JulienThomas’s picture

Good morning.

Just to confirm, #120 works really like a charm and let me built a 4 tabs panel with new / received / sent / trash.

Really good patch !

Thanks.

gladiatorhl2’s picture

Good morning.

Just to confirm, #120 works really like a charm and let me built a 4 tabs panel with new / received / sent / trash.

Really good patch !

Thanks.

On which versions of Drupal, Privatemsg and Views?

JulienThomas’s picture

The dev version for privatemsg (2.x-dev) and Drupal 7.31.

However, I confirm VBO is not working, no matter the setting among the 4 following possibilities:
skip confirmation yes/no
queue operation yes/no

gladiatorhl2’s picture

The dev version for privatemsg (2.x-dev) and Drupal 7.31.

However, I confirm VBO is not working, no matter the setting among the 4 following possibilities:
skip confirmation yes/no
queue operation yes/no

What about Views?

cbrody’s picture

Confirming that the patch in #120 doesn't work on Drupal 7.32 with Views 7.x-3.8

darol100’s picture

I'm developing a dashboard and I want to be able to show 10 private message and they have to be sort by the newest activity (similar of how the dashboard of the post on Drupal works). If they new message should be able to show on top. This is a views block so I can have it on my dashboard. However, I was not be able to do this with this patch is this is supported on this patch ? Or I did something wrong ?

Here is the configuration page - http://i.imgur.com/exQAsyD.png
And here is the ouput - http://i.imgur.com/OBkucTo.png

The problem that I'm having is that the "New Message" are not longer new and does not update the view like it supposed too. They have been read it and for some reason still showing off there. And I'm not sure if I did something wrong or this is not currently supported.

I'm using the latest version of Views 7.x-3.8 on Drupal 7.34.

The last submitted patch, 64: privatemsg-1573000-64.patch, failed testing.

ptmkenny’s picture

For those of you trying to use this on the latest versions (Privatemsg 2.x-dev, Views 3.10, and Drupal 7.34), I wasn't able to get the patch in #120 working, but I was able to use the sandbox module in #118 with the fix described in #120.

igorik’s picture

does it work with views 3?

ptmkenny’s picture

@igorik Yes it does, sorry I typed the wrong version No. I have updated my post (#132).

cmonnow’s picture

darol100: From a quick check of the sandbox module (+ single line in #120) it appears that is_new works as expected but that's from a few minutes experience.

I haven't tested VBO but I'm already delighted to potentially have a display view.

I used the module Views Distinct (https://www.drupal.org/project/views_distinct) to simulate a dashboard view that would show threads with new messages in descending order (I filtered by thread id in Views Distinct field settings so that only the last message and its respective date would represent the updated thread (somewhat analogous to Facebook, except Facebook renders only the last line of the last message)). Based on the way the module works though it makes page limits not work as desired after removing duplicates. Since I use PostgreSQL I suppose I'd have to hack the SQL to use ROW_NUMBER() to achieve what I want (MySQL's default behaviour is simpler).

cmonnow’s picture

I believe that views_handler_field_pm_thread_link.inc should also give us the option to not display as a rendered link for greater extensibility (e.g. using the link outside a div).

Suggested update:

<?php
/**
 * @file
 * Contains \views_handler_field_pm_thread_link.
 */

/**
 * Provides a field handler that renders a link to the private message thread.
 *
 * @ingroup views_field_handlers
 */
class views_handler_field_pm_thread_link extends views_handler_field {

 
/**
   * {@inheritdoc}
   */
 
function option_definition() {
   
$options = parent::option_definition();
   
$options['link_text'] = array('default' => t('View thread'), 'translatable' => TRUE);
   
$options['display_as_link'] = array('default' => TRUE, 'bool' => TRUE);
    return
$options;
  }

 
/**
   * {@inheritdoc}
   */
 
function options_form(&$form, &$form_state) {
   
$form['display_as_link'] = array(
     
'#title' => t('Display as link'),
     
'#type' => 'checkbox',
     
'#default_value' => !empty($this->options['display_as_link']),
    );
   
$form['link_text'] = array(
     
'#type' => 'textfield',
     
'#title' => t('Link text'),
     
'#description' => t('The text to show in the link'),
     
'#default_value' => $this->options['link_text'],
    );   
   
parent::options_form($form, $form_state);
  }

 
/**
   * {@inheritdoc}
   */
 
function access() {
    return
privatemsg_user_access();
  }


 
/**
   * {@inheritdoc}
   */
 
function render($values) {
   
$value = $this->get_value($values);
   
$data = 'messages/view/' . $value;
    return
$this->render_link($this->sanitize_value($data));
  }
 
  function
render_link($data) {
    if (!empty(
$this->options['display_as_link'])) {
     
$this->options['alter']['make_link'] = TRUE;
     
$this->options['alter']['path'] = $data;
      return
$this->sanitize_value($this->options['link_text']);
    }

    return
$data;
  } 

}
?>
darol100’s picture

@cmonnow,

Can you created that into a patch ?

dgtlmoon’s picture

Status:Postponed» Needs work
StatusFileSize
new7.48 KB

(ignore this one) sorry :/

dgtlmoon’s picture

StatusFileSize
new12.18 KB
FAILED: [[SimpleTest]]: [MySQL] 4,913 pass(es), 0 fail(s), and 26 exception(s).
[ View ]
jlbellido’s picture

Status:Needs work» Needs review

Thanks! Let's test it.

The last submitted patch, 118: privatemsg-1573000-118.patch, failed testing.

The last submitted patch, 120: privatemsg-1573000-120.patch, failed testing.

Status:Needs review» Needs work

The last submitted patch, 139: privatesg-1573000-with-thread-link.patch, failed testing.

cmonnow’s picture

Status:Needs work» Needs review

Hi,

Sorry I've been away.

I've never even bothered to test the patch in #120 after I read in #132 that it didn't work. I've been using the sandbox module at https://drupal.org/sandbox/uzlov/2149597.

Beyond that, I was under the impression this patch would never make it unless the whole pm_thread table was issue was finalised (https://www.drupal.org/node/744374), which appears stagnated.

dgtlmoon’s picture

@cmonnow yes i think so too, but good to keep the patches organised