Closed (fixed)
Project:
Privatemsg
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
22 Aug 2008 at 08:14 UTC
Updated:
1 Oct 2009 at 17:20 UTC
Jump to comment: Most recent file
I have spent waaaaay to much time on this, playing with D6's menu system and wildcards and callbacks and more, without any success. When a user with 'read all private messages' permissions is viewing another user's messages, the Inbox and Sent messages links lead back to the logged-in user's messages.
For example, while on messages/inbox/4, the Sent messages link is messages/sent instead of messages/sent/4.
I should note that I'm using the patch at #297835: Tabs, not tree to provide tabs. If someone can look at this and figure it out, I'd be grateful.
| Comment | File | Size | Author |
|---|---|---|---|
| #62 | read_all_port_d7.patch | 18.4 KB | berdir |
| #60 | axyjo-privatemsg-298502-2.patch | 15.29 KB | axyjo |
| #58 | axyjo-privatemsg-298502.patch | 15.33 KB | axyjo |
| #55 | privatemsg_readall_7.patch | 16.35 KB | naheemsays |
| #53 | privatemsg_readall_6.patch | 16.87 KB | berdir |
Comments
Comment #1
naheemsays commentedI am looking into this atm.
I think the current method to do this is suboptimal as viewing the inboxes of other users by going to messages/% or messages/inbox/% also shows the write new message tab.
For viewing another users messages, I think there should be new menu item(s) at user/%/messages (local task), user/%/messages/inbox (default localtask) and user/%/messages/sent (local task).
I am hacking around this atm and if I find a (hacky) nugget, I will post a patch.
Comment #2
naheemsays commentedA patch-that-needs-work to do what I mentioned above.
It needs permissions stuff to eb done properly. Currently it just checks if the user has read privatemsg permission, but this needs to be turned into a permissions call where it will check for read privatemsg permission id the person is viewing own account, but use read all privatemsg permission if viewing another user's account.
Comment #3
naheemsays commentedupdated patch - only show these tabs for users with permissions to read all private messages. I guess this is acceptable as a user can view own messages through the normal way.
Comment #4
naheemsays commentedComment #5
mrtoner commentedOoh, I like it! Much better than what I was trying to do. I'm attaching a patch to
There are two UI anomalies here. The first is the secondary tabs showing up on the Access Denied page. The second is the disappearance of the Edit item from the primary tabs when viewing user/%/messages/sent. I don't have the knowledge to correct either.
Comment #6
mrtoner commentedOkay, this patch not only has been re-rolled against HEAD, but it
Oh, the second UI anomaly I mentioned (edit menu disappearance) seems to be a problem in several other modules (Subscriptions, Notifications) I looked at. I don't think that should hold up this patch.
Comment #7
naheemsays commentedAny reason to make the new privatemsg_access function private?
As for the problemic tabs, I have opened another issue: #303087: Move "Sent Messages" to privatemsg_filter, Add inbox, improve user filtering. to get opinions. I think the sent messages menu item(s) do not work in threaded conversations.
EDIT - oops, fixed the link.
Comment #8
mrtoner commentedOnly to get you to ask the question. :-) (Really, because I just kinda copied what Subscriptions was doing for access and didn't consider any implications of making it private.)
Comment #9
naheemsays commentedI don't think there are implications, as I have used private functions from other modules.
PS if you are online, hop into irc channel drupal-games - planning to have a talk about the module with litwol as soon as he has reviewed some patches (I use x-chat. Free and available for Windows.)
Comment #10
naheemsays commentedreroll of #6 to cover changes in HEAD.
This will probably not go in, but I am posting it as a (currently) working fallback position.
Second patch is the same as above, but with no option to view sent messages of the user.
In a threaded conversation (which is where I would like to take this module), the latter will probably be the better method to use for viewing the inbox if we go down the current approach of having user/%/messages (which is unlikely).
Comment #11
litwol commentedI dont have an issue of using user/%/messages as the messages namespace. Whichever solution we pick, as long as its consistent i'm fine with it.
Comment #12
naheemsays commentedI have sat on it and I really don't think it is a good idea to cram everything into one namespace. Why?
1. If we did, I would prefer the messages/uid... approach but I cannot think how to make the ui work with that.
2. If we go user/uid/messages, while the lists are user specific actions, the message view and new message are not.
Unless I can get a pointer to how to make the ui work, I prefer the approach already implemented in the attached patches (with the exception that$box should be renamed to $tag as that is what it wil eventually become and already is sort of.)
In short all the current problems I can think of are:
1. UI to get to another user's messages. Simple in approach 2, I have no idea how to do this in approach 1.
2. Top level menu item to own messages. Simple in approach 1, will probably need a hack for approach 2.
3. Keep message viewing simple for moderators (ie an admin is sent a link to a message complaining about abuse). This would be the same for all users with access in approach 2, but with one it would be a little (not much) more envolved.
4. New messages. All users will have the same link with 1 (unless we want a UID in there in this case too), but different with case 2(or same if we include UID). IMO user/%/messages/new is acceptable, but it may confuse those used to typing in address manually as being a method to send the message to that user (I did put something similar to that in a previous patch...).
The main issue IMO is the first one - I do not know how to add a UI to access other users' messages with that namespacing system.
I find the hybrid system in the patches simpler than going purely on one or the other.
It is your call.
Comment #13
mrtoner commentedLet's let Michelle do it! :-)
They'll get over it. Seriously, with a link on the user's account page and the API function to return that link anywhere, there's no need to be typing anything. And this is a new version -- they expect things to change.
Comment #14
michelleHuh? I just stumbled on this issue and am completely perplexed as to why I got volunteered in that last comment. What does this have to do with me?
Michelle
Comment #15
naheemsays commentedhehe, that was more about the integration with advanced forum etc as it was about how to send a user new messages. Just ignore that comment.
PS viewing another user's messages is totally broken atm.
I was thinking, maybe only allow to view another users messages via the admin pages? something like admin/content/messages?
Comment #16
litwol commentedi prefer user/%/messages/%
Comment #17
berdirWe need to get this rolling again..
Trying to catch up the conversation, I'm with nbz.. Putting all in one namespace (/user/%user/messages XOR /messages) seems very hard to do and doesn't make sense from a user perspective imho.. (for example, is user/%user/messages/new now the generic write new message form, or is it a form to send %user a message?, it could actually be both, depending on which user you're looking at.. I don't really like that :))
My Ideas:
- Keep what we currently have at /messages, but remove the /messages/%uid thing
- Add a new Tab "messages" below user/%user => user/%user/messages. This one is only visible if the user has the permission to read alle messages
- Add "All messages/Inbox", "Read message", ("Sent") Sub-Tabs to messages
- These are just menu items, they point to the same functions as the /messages menu items, maybe with an optional argument indicating that it's an admin view
- That "prefix/namespace" allows us to know at which user's messages we're looking. Read message is only displayed when looking at a message, just as in /messsages
- I am not sure if that needs to be read-only or not.. While I think it's useful to be able to delete messages for a specific user (eventually add a new permission, delete all messages), I think we shouldn't allow to to other things like mark as read, block/unblock, tagging or even reply as user X. However, this really needs to be thought out, for example to be able to delete a message for a specific user, we would either need a way to act as user X, or be able to delete the message for all participants at once, maybe even both.
- As a admin may want to answer on a thread, that hasn't been sent to him, we could add a statement like "You're currently reading the thread as user X. If you want to answer, please go to /messages/read/%thread.
- If we go with the generic prefix user/%user, we could use a wrapper function for l which determinates if whe're on a admin view and automatically prefixing user/%user. It's not possible to do this in a generic way with messages/%user
I haven't written any code yet nor looked at the other patches, so I'm not 100% sure if what I've written is actually possible. But if we want to do this right, it's pretty complex imho. But I like to do things right if I do them at all, so we should first discuss what we want and what should be allowed/possible. Especially if admin's would have the possibilty to do something as user X, it really gets complicated..
Comment #18
uprojects commentedSo what is the status of this issue ? Can i test the patch of nbz on last dev ?
Comment #19
naheemsays commentedThe current patch should be more or less useless except as a guideline to getting things back up again - too much has changed since it was last rolled.
My personal plan of action is:
1. Review #348907: Per thread/Multiple thread actions and #376023: #288183 followup: change hook_privatemsg_block_message to work on multiple recipients
2. Re roll #303087: Move "Sent Messages" to privatemsg_filter, Add inbox, improve user filtering.
3. Potentially go back to this one.
Saying that, this feature may not make it for the 1.0 release as there are a few questions on how some parts should work for those with permissions to view all messages.
Comment #20
uprojects commentedFor what I think is a basic functionality for a system of private message.But i understand the problematic
Comment #21
berdirComment #22
rmjiv commentedShould I assume from this discussion that the message/%uid method doesn't work right now?
Comment #23
naheemsays commentedyes
Comment #24
uprojects commentedIt might be interresting now to introduce this feature in the core of private message, is not it?
Comment #25
uprojects commentedComment #26
naheemsays commentedThis is still cnw as there are things to be worked on, a patch developed.
Comment #27
naheemsays commentedI wasw about to atart working on this, but I ran into a small hitch.
With that menu code and a drupal_set_message(); in privatemsg_list, I was getting an arg of "settings" passed through instead of the actual uid . (3 in the case of user/3/messages)
I cleared the caches and even emptied the table manually, but no change.
Comment #28
litwol commentedneeds to become >
Comment #29
naheemsays commentedJust to get the ball rolling - not complete at all. Just the menu implementation - and I have left off the inbox/sent messages as this is mostly for admins only and they do not need all the normal goodies that are available through the normal messages/% path.
Questions -
1. Do we want the admin to be able to reply in the conversation? this may be needed to give in coversation warnings etc, or maybe the admin could do that separately.
2. Hiding the normal delete etc buttons as the delete task will not do anything considering that the admin is not in the index for the conversation...
Comment #30
naheemsays commentedOk, this patch is now far bigger than I wanted it to be.
1. Adds the menu link and the access permission function as per last patch.
2. Rearranged the thread load function to get the participants of a conversation before loading all the mid's.
3. If a user is not a participant and also has read all permission it now sets a $read_all flag to true.
4. In privatemsg_sql_load, totally got rid of the uid check as it was unneeded.
5. Got rid of the $message['user'] = $account; in _privatemsg_load in addition to getting rid of the account check full stop for this function - its not needed.
6. in privatemsg_sql_messages if the $read_all check is TRUE, then the list here will not be filtered by $uid either, otherwise it will be as is the case for normal users. What this allows is for a person with read all messages permission to still be able to use own account as normal without much hampering.
7. in privatemsg_message_change_delete if no account is presented, then the message is deleted for all users.
Still ToDo:
1. modify privatemsg_delete and privatemsg_delete_submit to have three options: delete, delete for all users and cancel. This will mean not using confirm_form as that is binary only.
considerations:
1. If the user with "read all messages" permission can act on the message (for instance delete), then the permission is badly named. Is there a better alternative name?
I am setting to CNR as even with the ToDo items, the rest should work as expected and input is appreciated.
Comment #31
naheemsays commentedComment #32
naheemsays commentedHopefully completed patch:
1. Adds the menu link and the access permission function as per last patch.
2. Rearranged the thread load function to get the participants of a conversation before loading all the mid's.
3. If a user is not a participant and also has read all permission it now sets a $read_all flag to true.
4. In privatemsg_sql_load, totally got rid of the uid check as it was unneeded.
5. Got rid of the $message['user'] = $account; in _privatemsg_load in addition to getting rid of the account check full stop for this function - its not needed.
6. in privatemsg_sql_messages if the $read_all check is TRUE, then the list here will not be filtered by $uid either, otherwise it will be as is the case for normal users. What this allows is for a person with read all messages permission to still be able to use own account as normal without much hampering.
7. in privatemsg_message_change_delete if no account is presented, then the message is deleted for all users.
8. Add an option to the delete function to allow to delete for all users.
9. Slightly Fix api documentation in privatemsg.api.php
Please test and comment.
Comment #33
berdirDo we want that? (provide a second way to read own messages for a "normal" user)
I haven't yet tested this, but it looks really nice, good work! :)
Comment #34
naheemsays commentedNo idea and good question.
The second question is was I too hasty in changing the privatemsg_load api (and the privatemsg_sql_load function)? There is also a $message['user'] in there which I deleted as I could not see it being used, but maybe that was a placeholder for future functionality?
Comment #35
naheemsays commentedJust added the following line to the above patch:
Comment #36
naheemsays commentedthe changes to _privatemsg_load and privatemsg_sql load are not needed for this patch and also incorrect.
Comment #37
naheemsays commentedAttached patch removes the changes to _privatemsg_load and privatemsg_sql_load - the user object is needed there for other stuff.
I have also had to change the delete api because the full message is no longer loaded when deleting:
I did have a question about $deleted_by_all though:
Is that not counter intuitive? TRUE when the message as not been deleted by all, FALSE when it has?
Comment #38
gooddesignusa commentedWill this be fine with 6.x-1.0-rc3 ?
Comment #39
naheemsays commentedYes, it should.
I must warn you that the patch is a WIP and has not been reviewed by others in order to critique it/point out the flaws. ofcourse, you can be the first to do that.
Comment #40
naheemsays commentedrerolled and also fixes the buggy $deleted_by_all boolean.
There is a change of api in this patch:
<?php
- module_invoke_all('privatemsg_message_delete', $message, $deleted_by_all);
(some lines later:)
+ module_invoke_all('privatemsg_message_delete', $pmid, $deleted_by_all);
This had to be done to allow messages to be deleted for other users (use case: admin deleting an offensive/abusive message for all users), and in that case we cannot load the whole message object. Instead we we pass fordward the $pmid which is the same for all cases.
Comment #41
naheemsays commentedrerolled to apply on top of current changes.
Also, removed "$message['user'] = $account;" from _privatemsg_load as that was a hack that is no longer being used.
Comment #42
naheemsays commentedand rerolled again.
Comment #43
berdirRe-rolled and fixed a few bugs...
- Removed the $read_all param and made $account optional for both the load and messages sql query function.
- Moved the message that you are viewing a thread in read all mode to the privatemsg_view() function and changed it to a warning message. I just thing that warning is more appropriate, but I don't really care...
- I also changed the load function so that it correctly returns FALSE if no message could be loaded. Not necessary for this patch, but it generates ugly empty messages when a message can't be loaded.
Other than that, there are quite a few documentation improvements, which are always nice. I think this is more or less ready...
Comment #44
naheemsays commentedrerolled with the missing segment from privatemsg_view() - other than that, rtbc IMO.
Comment #45
axyjo commentedSubscribe. I'm also testing the patch out currently.
Comment #46
naheemsays commentedok, asygo - both me and Berdir think it is ready to go but since both of us also had a hand in crafting it, we will leave it in your capable hands to set to "reviews and tested", so once you are satisfied and have no questions/problems with the patch let us know.
Comment #47
axyjo commentedNo problem. Even though I'm not 'supposed to', I'm using the patch on a production site. Nothing's broken yet, but I'll wait at least 4 more hours before RTBCing this.
Comment #48
axyjo commentedHaven't had any problems. RTBC
Comment #49
gooddesignusa commentedsweet just in time.
I'm going to test it out on my dev site.
thanks everyone for your hard work :)
Comment #50
berdirOk, I have another update for this.
There was a problem when sending a message in read all mode. The problem was that after replying, you can then only see your own message and read all mode isn't triggered anymore. This is solved by forwarding the read_all flag to the form and send functions and if set, the author is added as recipient to all existing messages of that thread.
There are also a few coding style improvements in _privatemsg_send() as I had to touch that code...
Comment #51
naheemsays commentedA few documentation fixes - no functional changes to Berdir's patch.
Comment #52
naheemsays commentedTested and back to rtbc.
Comment #53
berdirAdded a $thread['participants'] = array(); to avoid warnings when privatemsg_thread_load() tries to load an invalid thread (can happen if you visit messages/new/uid, for example)
Comment #54
litwol commentedand thus....
Comment #55
naheemsays commentedDocumentation fixes from comment 51 re-added. Other than that, good to go I think.
Comment #56
litwol commentedGreat works guys.
Comment #57
naheemsays commentedneeds to be ported to the d7 branch too.
Comment #58
axyjo commentedI'm pretty sure I got all changes to DBTNG in this patch.
Comment #59
berdirThanks for working on this, there are a few missing things:
You should add the same code that is removed. Actually, it can probably be written in a single line:
Isn't DBTNG nice :)
Minor coding style issue, the condition should be on the second line.
Looks like I forgot to change that, since you already touch that part of the code, can you replace that with proper DBTNG code (:mid)?
That part needs to updated too. _privatemsg_assemble_query() returns a SelectQuery object that you can execute() and then loop over it with foreach and instead of executing $query, add the values to the $query object as the other calls in that functions.
If you have questions, please ping me in irc. :)
Comment #60
axyjo commentedThanks for the review, Berdir! I think I addressed all of your comments, but please do go through the patch, just to make sure that I did things in the right way.
Comment #61
berdirreally minor.. there are two ";" at the end :)
Sorry, haven't seen this before. the apidocs need work anyway, but as you touch it, can you remove the whole $fragments part? that is obsolete now...
Almost there :)
while the first two lines work, you can write them as "foreach ($conversation->execute() as $result)" (or probably even "foreach ($conversation->execute()->fetchCol() as $mid) and then access it as $mid instead of $result['mid'] but you need to test that.
the inner lines needs to be converted to dbtng, something like:
As $query is already a InsertQuery object to which you can add additional values. However, you need to make sure that the whole part is above the $query->execute() line, I'm not sure about that.
Comment #62
berdirHere is a re-roll with the mentioned changes... This is tested and should be ready...
Comment #63
axyjo commentedSorry, should have said that I was going to be slightly busy. Thanks Berdir!
Comment #64
litwol commented