Closed (fixed)
Project:
Privatemsg
Version:
7.x-1.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
12 Aug 2009 at 13:11 UTC
Updated:
18 Jun 2014 at 09:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
berdirThere is no pre-built views integration right now, but you can easily use the function privatemsg_get_link() in a theme function.
1. Add a random field, for example the uid of the user. It does not matter as long as you can access the uid somehow.
2. Create a theme function for that field, and do something like this:
That should display a link if the user is allowed to write a message.
Please set this to fixed if it does work.
Comment #2
rajiv.r.in commentedThis is little complicated for me. Can something be done using ‘Global: Custom text’ in views. But here I need a ‘replacement pattern’. Is that a possibility currently?
Comment #3
rajiv.r.in commentedI also see a link on user page saying, "send this user a message". How do I use this feature from somewhere else? Can I link this from views?
Comment #4
berdirApply the (simple) patch and untar the tar.gz into the privatemsg folder. Clear the views cache and then you should have a configurable "Privatemsg: Send Privatemsg link"
Comment #5
liliplanet commentedHi Berdir,
This would be wonderful as an option in views.
Unfortunately, the patch seems to create the error:
warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'privatemsg_user_access' was given in /home/public_html/includes/menu.inc on line 452..This happens when visiting a profile page tpl with a custom send pm:
Look forward to your reply, and thank you.
Lilian
Comment #6
Michsk commentedcould the population field url be changed to the username instead of the uid..
Comment #7
volocuga commentedShould it work (#4) if I have Content Profile installed?
Now I see only text "Send message:" without link.
Comment #8
Bilmar commentedHello,
Received the below error when saving the View with the new field to send private msg, and when visiting the page that has the view with the new field.
Fatal error: Call to undefined function privatemsg_user_access() in /home/example/public_html/drupal/sites/all/modules/privatemsg/views/views_handler_field_privatemsg_link.inc on line 60
Are others experiencing the same issue?
Thanks
Comment #9
gsvitak commentedHi
Thanks for the exciting patch.
I have a content type called idea and I have created a new view called similar ideas. I would like someone to search the view via filters and then allow someone to click an action link in the view to connect the current user to the author of the idea node. Is this possible with this patch or is this functionality supposed to work only on the profile node?
I am able to see the field type when I configure the view but I am not able to see see a link when I look at the view in the browser.How does the patch figure out which value to pass to the api? Do I need to do something special in the view configuration?
I know documentation is a pain for a patch but could someone please post a screen shot of a working configuration of the view and the field?
Thanks
Greg
Comment #10
berdir@#8: Use the latest (rc4) version of privatemsg
@#9: Try the updated tar.gz (the patch did not change), that should work now. The reason was that the author field is actually called users_uid and not simply uid. This needs to be more flexible but for now, it should work for both cases. Note that you need to add the author as a field too, you can hide it if you don't want to display the author.
Comment #11
gsvitak commented#10
Thanks that works great..
Couple of other little things/feature requests?
How would I integrate into the Popups API (which is another great patch) ?
Also how would I prepopulate the message subject with the node title - just like the PrivateMsg with the PopupAPI/
Thanks again for the quick work?
Greg
Comment #12
berdirReworked the configuration completely.
It allows now to define the link text and the message subject and you can use tokens. You can also easily append the destination so that the user is redirected back to the form after sending the message by setting a checkbox.
@#11: The new subject configuration should solve your use case. Regarding popups module, check out the other issue, the last proposed version should work too for that too and there will hopefully be a new patch soon that will integrate that.
Comment #13
gsvitak commentedAWESOME!!!! Thank you for the quick turnaround
I tried the above tarball and the functionality works fine except I am getting the following error message when I run the view:
Missing argument 1 for views_handler_field::get_render_tokens(), called in /modules/privatemsg/views/views_handler_field_privatemsg_link.inc on line 125 and defined in modules/privatemsg/views/views_handler_field_privatemsg_link.inc on line 639
Text to display:
Send a Message to [name]
Pre-filled subject:
Reach Out request for Idea: [title]
Any suggestions?
G
Comment #14
Bilmar commentedThank you Berdir for this great addition to privatemsg!
As #13 gsvitak mentioned above I am also getting an error:
warning: Missing argument 1 for views_handler_field::get_render_tokens(), called in /home/example/public_html/drupal/sites/all/modules/privatemsg/views/views_handler_field_privatemsg_link.inc on line 125 and defined in /home/example/public_html/drupal/sites/all/modules/views/handlers/views_handler_field.inc on line 642.
Comment #15
Bilmar commentedI added the field after the error msg above and clicked the send privatemsg link on the view.
It successfully went to the Send Message screen with the To: populated with the user from views (awesome!!)
I wrote a test msg 'testing privatemsg link with this message' and sent it - received below error message:
I hope my input helps debug any issues =)
* user warning: Unknown column 'format' in 'field list' query: INSERT INTO pm_message (subject, author, body, format, timestamp) VALUES ('testing privatemsg link with this message', 1, 'testing privatemsg link with this message', 1, 1256037087) in /home/example/public_html/drupal/sites/all/modules/privatemsg/privatemsg.module on line 1619.
* warning: Missing argument 1 for views_handler_field::get_render_tokens(), called in /home/example/public_html/drupal/sites/all/modules/privatemsg/views/views_handler_field_privatemsg_link.inc on line 125 and defined in /home/example/public_html/drupal/sites/all/modules/views/handlers/views_handler_field.inc on line 642.
* warning: Missing argument 1 for views_handler_field::get_render_tokens(), called in /home/example/public_html/drupal/sites/all/modules/privatemsg/views/views_handler_field_privatemsg_link.inc on line 125 and defined in /home/example/public_html/drupal/sites/all/modules/views/handlers/views_handler_field.inc on line 642.
Comment #16
berdirI think you are using an old Views module. function get_render_tokens() in Views 2.6 does not have any arguments.
Edit: And for the second error, you need to run update.php.
Comment #17
Bilmar commentedAhh - sorry about the problem that was easily solved with update.php
I had this version installed:
Views 6.x-3.x-dev (2009-Oct-09)
Updated to this version:
Views 6.x-2.x-dev (2009-Oct-20)
still getting this error:
warning: Missing argument 1 for views_handler_field::get_render_tokens(), called in /home/example/public_html/drupal/sites/all/modules/privatemsg/views/views_handler_field_privatemsg_link.inc on line 125 and defined in /home/example/public_html/drupal/sites/all/modules/views/handlers/views_handler_field.inc on line 642.
does this only work for 6.x-2.6 official release?
Comment #18
berdirThe updated version should work with both 2.x-dev and 2.6.
Comment #19
gsvitak commentedThanks again for the quick turn around..
I am using views dev-3.x.. I need to use this version due the multiple selection field groupings CCK field..
will try and let you know..
Thanks
Greg
Comment #20
gsvitak commentedHi
I tried the patch in #19 and it works great as long as you do not have popup-api patch applied as well. Somehow it appears the patch cause Jquery not be declared in the HTML output because firebug error console state "Jquery is undefined".
I will try and figure out the issue and post the fix.
Thanks again for the great work. Hopefully you can committ to the main dev branch for full release support.
Comment #21
berdirPlease provide a more detailed bug report in the other issue, with the exact error message (on which line, on which page and so on) including screenshots, if possible.
Also, try to check if that only happens when both patches are applied and not also if only the other patch is enabled. Thanks
Comment #22
gsvitak commentedAppears the problem was with my view config. I had disabled the Use Ajax option to try and debug something. Everything works great.
Could you please add one more thing to the config? The label of the link always says Send Privatemsg link:
IE
Send Privatemsg link: Reach the author of this idea
Can you please change the config of the field label back to the first patch where I can enter what ever I wanted..
thanks
G
Comment #23
berdirRe-added the Label configuration option and cleaned up option handling a bit, it should not work correctly with the default values.
Comment #24
gsvitak commentedThanks will test tonight.
Comment #25
gsvitak commentedworks great.
I got the pop-ups to work by hardcoding the path of the page view into the module. It would be great if you could somehow add a config form to the patch to list out all possible paths that could be enabled.
function privatemsg_popups() {
if (variable_get('privatemsg_popups', TRUE)) {
return array(
'user/*' => array( // profile pages
'a[href*=messages/new]' // Send privatemsg
),
'node/*' => array( // node pages
'a[href*=messages/new]', // Send privatemsg
),
'similarideas/*' => array( // node pages
'a[href*=messages/new]', // Send privatemsg
),
'reachinview/*' => array( // node pages
'a[href*=messages/new]', // Send privatemsg
),
'*' => array(
'div#block-privatemsg-privatemsg-menu a[href*=messages/new]',
)
);
}
}
Comment #26
andypostI think using user_load() for every link is very expensive! Is this really required?
I found another views integration issue #502688: Views integration but it seems a wrong way
Comment #27
berdirYes, it is. The user object isn't required for views, it's required for privatemsg. Because all the permissions and blocking rules need to be checked and that needs a user object.
Edit: The other issue is about exposing the messages to views but that will not see the light any time soon. Simply because our queries are way to complex (With heavy use of Group By, Having, Subqueries and so on) for views.
Comment #28
andypostI think that better make own user_load() analog because this function is not cacheable so for every link the whole user+profile is loaded.
Upd: suppose new stdClass with uid is enough to check user_access() and query blocking rules...
Comment #29
berdirI fully agree, that's something I want to do. But not only for views integration, privatemsg.module should use that function (privatemsg_user_load()) wherever possible, since we usually load *lots* of users and I'm really concerned about that.
So this isn't specific to this issue, please open a new task for this. You are also welcome to work on a patch. Note that the uid is not enough, we need atleast uid, name and the roles array.
Comment #30
berdirAdded to 6.x-1.x-dev. Needs to be ported to D7.
Comment #31
berdirCommited to 7.x-1.x-dev.
Comment #32
berdirComment #34
willowdigit commentedThe link in the latest dev version:
; Information added by drupal.org packaging script on 2013-10-01
version = "7.x-2.x-dev"
does not accept the label entry and neither are the default options for Style Settings, Rewrite Results etc. available.
This is because the parent options are not included.
Patch attached.
(As this is a closely related issue (bar the versioning of this queue) I include it here.)
Comment #35
berdirA patch in a closed issue is useless, open a new one instead.