Closed (duplicate)
Project:
Privatemsg
Component:
Code
Priority:
Critical
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
3 Sep 2008 at 15:49 UTC
Updated:
17 Jan 2009 at 10:53 UTC
Create a function that takes a single UID as parameter and returns a raw URL to create a message form with user name pre-filled in the 'to' field.
Notify Michelle so she can use it in adv forum module.
Comments
Comment #1
litwol commentedRaising importance level for important people :)
Comment #2
naheemsays commentedIs this to be different from "messages/new/%"?
Comment #3
litwol commentedfor the sakes of the argument lets assume that our URL format standards will not change from the above. then this API function would return 'messages/new/%' where % is the UID of the user the link was requested for.
that being said, i know that we may change our URL structure. to help other modules integrate with privatemsg module i want to provide a function that when called will always return the correct current URL. so other modules use this function once and never have to worry for correctness of URLs with regard to privatemsg module.
i hope this made sense.
Comment #4
michelleI normally loathe "subscribe" posts but since this issue is directed at me, it would be good to have it in my tracker. ;)
Michelle
Comment #5
naheemsays commentedso something like
???
(not sure that is actually valid code...)
Comment #6
litwol commentedit needs better name. otherwise this is the major idea.
in the future when we change our URL namespace, we will just change the return string from that function so other modules dont have to worry about it.
Comment #7
naheemsays commented"pm_send_to_user"?
Comment #8
mrtoner commentedI had actually whipped this up last night:
but I had some questions about access control, etc.:
Should we assume Michelle and other module writers won't use a UID for the for the currently logged-n user? Do we return a link in that case? Do we return a link if the current user doesn't have "write" permission? Do we return a link if the recipient doesn't have "read" privileges?
Comment #9
litwol commentedwe should try to have the same access control that we have for the rest of the module.
also if the user doesnt pass the permission check, we need to return FALSE. that way we give some feedback if there was a failure.
Comment #10
michelleInteresting. Hadn't thought about putting the access check in this function. FWIW, here is the .inc for making privatemsg 5 work with advforum 5. You can see all the checking it goes through.
Michelle
Comment #11
litwol commentedThis is the line that would idealy be replaced with
we should consider whether its important to ask for $user object or just UID. if we have UID then we can load the user if necessary. but if we have the user object then we skip any loading in the future.
Comment #12
naheemsays commentedThat may not be enough - if we go ahead with a scheme such as "user/%/messages/new/%", we would also need to know the current user's UID.
I do't see the need to get the full user object as we will be loading the user data again anyway. (unless there is an acceptable way to carry all the data across).
Comment #13
mrtoner commentedWe don't need to have the current user's UID passed to the function -- that's already available in $user.
Comment #14
litwol commentedThe function will work for any UID passed in, not only for user that is currently logged in.
one of the applications is to present 'send message to' link to a profile of some one else while _i_ am logged in.
Lets improve on code in #8.
Comment #15
michelleWhy would you do #12? The only reason I can think of is to allow someone to send a private message as another user. I can see some convenience for an admin that has a personal account, maybe, but I don't know if it's worth that. I certianly wouldn't put that ability in any integration I do and the sending user would always be the logged in user.
I think this is in danger of getting into bikeshed territory here... It really doesn't need to be that complicated. Just pick a URL that has the currently logged in user sending a PM to a given UID and there ya go.
Michelle
Comment #16
naheemsays commentedCall that lack-of-sleep-stupidity! Forget what I wrote, the code proposed by litwol is enough.
Comment #17
berdirI'm closing this as a duplicate of #288183: Provide api function for other modules to send messages.. The patch does have a privatemsg_get_link($recipient, $account) function and privatemsg.author-pane.inc is now part of our module.