Is it possible to display in the list of messages, after the "last update column" the user that posted this last private message?

It should be quite simple, but I cannot find the way to change the query to do this.

Ideally, it would be nice to have an way to tell whether a user has answered a private message, but I think that having the name of the last user is maybe better.

Any idea on how to do it (work around or not)?

Thanks.

Comments

lionux’s picture

Title: last user responding to a private message » who was the last user responding to a private message? (message answered flag)
Berdir’s picture

Status: Active » Postponed

No, right now, it's not quite simple :). To be more exact, it is simply not possible, at least not with mysql.

This requires #647212: Load participants in thread list in a single but separate query and/or #744374: Introduce a pm_thread table.

lionux’s picture

On line 1181, I have added this new fragments code ... to capture the last_participant.
It seems to work, but now I need to ADD it next to the other columns ... next to the participants.

$fragments['select'][] = '(SELECT GROUP_CONCAT(DISTINCT pmia.uid SEPARATOR ",")
FROM {pm_index} pmia
WHERE pmia.thread_id = pmi.thread_id) AS participants';
>>>> NEW LINES
$fragments['select'][] = '(SELECT pm_message.author
FROM pm_message, {pm_index} pmia
WHERE pm_message.mid = pmia.mid and pmia.thread_id = pmi.thread_id order by pm_message.timestamp desc limit 1) AS last_participant';
<<<<<<

The code is very SMART (too smart) so that without a proper debugger ... it is rather difficult to see how the code is working.
Doing some reverse engineering ;((

The SQL query should be ok in term of speed, I think.
So, still working on it ...

Thanks if someone could help here.

Berdir’s picture

Status: Postponed » Needs work

Hm..

Yeah, you're right, adding a new select column with a subquery makes this possible. Not really fast, but we can still make it fast once we have pm_thread.

We have some documentation on how to add an additional column, see http://blog.worldempire.ch/de/api/group/theming/1. Basically, you need to create a header and field theme function and it should work.

I suggest that you extend the query and don't overwrite it but then make it optional similiar to the existing fields. Then each user can select if he wants to use last_participant or participants.

Would be awesome if you could provide a patch, I'm happy to answer any questions you have.

Berdir’s picture

Category: support » feature
lionux’s picture

Thanks Berdir for your help.

Before your reply, I updated (added) the user name within the "timestamp" column from that select query; so the time of the last message is given along with the author of that message. I agree, this is not nice, but quite useful for my users.

Currently, I am polishing the website with additional features, and when I am 99% done, I would like to create a patch for others to use.

It is just taking me so much time to learn the basics (although I must admit, without this module, I'll just simply never have made it in just 2 months lead-time working few hours after work).

Great module! really worth it!

Thanks.

Berdir’s picture

Ok, great. I suggest to read http://www.webchick.net/embrace-the-chaos :)

In short, I suggest you simply create a patch of what you have and I can give you some first comments/basic feedback. It's much easier to do chances on your code now than after you spent hours polishing every aspect of it (and then be frustrated when I tell you that would be a lot easier if you make a few changes).

The patch isn't going to be commited in the first iteration, you can trust me on that :)

robby.smith’s picture

subscribing

oadaeh’s picture

Issue summary: View changes
Status: Needs work » Closed (won't fix)

This issue is being closed because it is against a branch for a version of Drupal that is no longer supported.
If you feel that this issue is still valid, feel free to re-open and update it (and any possible patch) to work with the 7.x-1.x branch (bug fixes only) or the 7.x-2.x branch.
Thank you.