Hello, I am using privatemsg 6.x-2.x-dev, and trying to set up a user admin role for a social site.

Privacy considerations aside, neither User 1 nor any role with the "read all messages" permission can actually read user messages. Inspected user appears to have no messages, despite being able to access them from the user's own account...

Am I doing something wrong, or is this broken in 6.x-2.x-dev?

Thank you in advance.

Comments

berdir’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: -privatemsg, -all, -permission, -messages

This should work. Works for me in my dev site and we have tests for this.

- Do you have a special url prefix configured?

- Other modules which integrate with Privatemsg?

- How do you access the messages of another user?

Edit: the tags field is to group similar issues together and add special meaning to them with pre-defined tags. No need to add random tags to it.

marktheshark’s picture

Thought tags were meant for keywords... My bad, I guess.

To answer your questions:

  • No, just configured a local subdomain on Apache (mysite.localhost)
  • AFAIK, only privatemsg limits
  • I'm accessing a user's messages through: e.g. http://mysite.localhost/user/19/messages (base path: user/%user/messages)
marktheshark’s picture

Status: Postponed (maintainer needs more info) » Active

Changing to active after providing more info.

marktheshark’s picture

Sorry for bumping, but is there any feedback on this?

The user admin of our site currently cannot access any private messages (unless I am mistaken about the path where the admin should access them, i.e. the user's main 'messages' page)...

Thanks once more

berdir’s picture

Well, I simply do not know. As I said, I verified that it works for me and we have tests for this which work fine too.

About the prefix, I meant not your site but the url prefix privatemsg configuration setting (defaults to "messages")

You likely need to start debugging this.

Start by adding a "dpm($query);" to the function "privatemsg_list" after it's created (line looks like "$query = _privatemsg_assemble_query('list', $account, $argument);"). Does the query look correct? Is it using the correct user id? If unsure, post the query here.

You can also try to execute the query with phpmyadmin, remember to remove the curly braces around table names.

marktheshark’s picture

This is the query for user with uid 23 when looking at their own messages:

SELECT pmi.thread_id, MIN(pm.subject) as subject, MAX(pm.timestamp) as last_updated, SUM(pmi.is_new) as is_new, (SELECT GROUP_CONCAT(DISTINCT CONCAT(pmia.type, '_', pmia.recipient) SEPARATOR ',') FROM {pm_index} pmia WHERE pmia.type = 'user' AND pmia.thread_id = pmi.thread_id AND pmia.recipient <> 23) AS participants FROM {pm_message} pm INNER JOIN {pm_index} pmi ON pm.mid = pmi.mid WHERE (pmi.recipient = 23 AND pmi.type IN ('user', 'hidden')) AND (pmi.deleted = 0) GROUP BY pmi.thread_id ORDER BY last_updated DESC

User 23, in this example, has one active conversation thread, and this gets displayed correctly.

This is the query for user with uid 18 which has the "read all messages" permission, when they tries to see user 23's messages (path: user/23/messages):

SELECT pmi.thread_id, MIN(pm.subject) as subject, MAX(pm.timestamp) as last_updated, SUM(pmi.is_new) as is_new, (SELECT GROUP_CONCAT(DISTINCT CONCAT(pmia.type, '_', pmia.recipient) SEPARATOR ',') FROM {pm_index} pmia WHERE pmia.type = 'user' AND pmia.thread_id = pmi.thread_id AND pmia.recipient <> 18) AS participants FROM {pm_message} pm INNER JOIN {pm_index} pmi ON pm.mid = pmi.mid WHERE (pmi.recipient = 18</strong> AND pmi.type IN ('user', 'hidden')) AND (pmi.deleted = 0) GROUP BY pmi.thread_id ORDER BY last_updated DESC

This is the exact same query as when user 18 looks at their own messages (uid 23 isn't referenced at all), of which there are none (in this example). In other words, the user admin gets their own message listing when trying to see a member's messages...

Same behaviour observed for user 1 as well.

berdir’s picture

Strange.

- Are you sure you are using the most recent version of 6.x-2.x?

- Again, do you have changed the privatemsg url prefix in the settings?

- What user is the $account object passed to that function, 18 or 23?

- Can you add a dpm(func_get_args()); debug call to the function privatemsg_list_page(), what are the arguments received by that function?

marktheshark’s picture

  • Drupal reports no updates for installed Privatemsg (released 2011-Mar-04)
  • I'm confused as to what you mean with url prefix, because I see no field explicitly named that way. The only URL related setting I have touched is the Base URL path, setting it to user/%user/messages, so that the 'Messages' tab/menu appears on a user's account page, as suggested in the help text (' Possible paths include 'user/%user/messages' (pages appear as children of the user account page) or 'messages' (the default path).')
  • $account object corresponds to user 18

I reverted back to using Base URL path messages, and user-1 and user-18 were able to see user-23's messages, but now all users have lost their 'Messages' tab from their account page.

It seems to me privatemsg should not pass someone's own account as an argument when viewing another user's messages.

berdir’s picture

That was the setting I was talking about, it has been renamed in the UI...

Yes, it shouldn't, I'll try again myself with the same configuration.

berdir’s picture

Are you using i18n.module?

If yes, check if the privatemsg_url_prefix variable has language-specific configuration for the privatemsg_url_prefix setting.

This has caused very weird issues on my test site.

marktheshark’s picture

Yes, I am using i18n. Haven't configured anything locale/language related in the Base URL path though, just user/%user/messages, as mentioned above (if I'm understanding your question correctly).

berdir’s picture

Neither did I, but somehow, I had a locale specific setting for "privatemsg_url_prefix" in the i18n_variable table. Check that table directly.

marktheshark’s picture

Checked i18n_variable table.

Only privatemsg variables found:

  • pm_email_notify_subject
  • pm_email_notify_body

...for languages installed. No privatemsg_url_prefix found.

berdir’s picture

I simply have no clue what could causing this..

A few things to try..

- What is the output of this query:

select path, load_functions, page_arguments from menu_router where path = 'user/%/messages';

Should be:

+-----------------+----------------------------+--------------------------------+
| path            | load_functions             | page_arguments                 |
+-----------------+----------------------------+--------------------------------+
| user/%/messages | a:1:{i:1;s:9:"user_load";} | a:2:{i:0;s:5:"inbox";i:1;i:1;} |
+-----------------+----------------------------+--------------------------------+

And second, implement hook_menu_alter() in a custom module and add (you need devel.module enabled):

dpm($items['user/%user/messages']);

Then rebuild the menu.

Third, you can try a different base path, for example 'user/%user/pm'

marktheshark’s picture

Category: support » bug

Sorry for the delay. Tried the query:

+-----------------+----------------------------+--------------------------------+
| path            | load_functions             | page_arguments                 |
+-----------------+----------------------------+--------------------------------+
| user/%/messages | a:1:{i:1;s:9:"user_load";} | a:1:{i:0;s:4:"list";}          |
+-----------------+----------------------------+--------------------------------+

I'll give a try to your other suggestions tomorrow.

berdir’s picture

Oh, I have an idea.

Did you chose list as your default listing?

Try to set it to inbox instead, I'm pretty sure it will work fine then.

Should be rather easy to fix, I'll come up with a patch once you confirmed that this is the issue.

marktheshark’s picture

I'll try that, though I have no idea where the configuration setting for the listing is...

berdir’s picture

Just a bit above the base URL path setting in "Configure listings".

marktheshark’s picture

StatusFileSize
new25.45 KB

Attaching screenshot for configure listings section.

I see no default listing setting available... :-( Can't even find the word 'inbox' anywhere in the source...

berdir’s picture

Status: Active » Needs review
StatusFileSize
new1.04 KB

Ah, now I got it.

Sorry for the confusion. The problem is that you don't have privatemsg_filter enabled (which would provide that option). And we don't have any tests for this case.

The fix is trivial, try the attached patch.

marktheshark’s picture

Tried to patch it with patch (for Windows) in the same directory as privatemsg.module:

c:\xampp\htdocs\site_name\sites\all\modules\privatemsg>patch < fix_menu_definition.patch
patching file privatemsg.module
Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354

Should I have tried git?

Anyway, I made the code change manually. No change, user 1 cannot see any private messages...

berdir’s picture

You probably either need a new version of patch or git to apply these patches, yes. But it's only a one line change.

Did you rebuild the menu after applying the patch? by re-saving the menu selection, for example.

marktheshark’s picture

Yay, flushed caches and it did the trick. Sorry about that... Will this be ported to the 6.x-2.x-dev branch soon?

Btw, I got patch from http://gnuwin32.sourceforge.net/packages/patch.htm

Not only did it not work, but it crashed as well (on Win 7 x64).

Many thanks for your support, I assume for a total overview of messages exchanged one would need to create a view?

berdir’s picture

Yes, I will commit the patch soon, I'll try to improve the tests before doing that, though.

Yes, you will need views, but you currently can't do that because we don't provide views integration for messages and privatemsg_views doesn't support 6.x-2.x. It is just way to complex right now.

berdir’s picture

Status: Needs review » Fixed

Commited the patch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.