Attachments for privatemsg
velo - December 4, 2008 - 15:25
| Project: | Privatemsg |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Description
I need this functionality for users in a work-flow environment. I know this was addressed before with 5.x-1.8 and I applied the patches but all I get are error messages when sending a message with an attachment. Can someone please help?

#1
I agree, I need this functionality too. In todays world with community websites where in my case a lot of real time collaboration is occurring it is also nice to just send a PM with a small attachment to it as a quick file to the collaborators. I too used the patch for an earlier version and received PHP errors I think these errors were related to the version of PHP that my host is using. So this is something that will probably have to be upgraded along with this feature if they decide to implement it. Update status on this would be nice to hear about, the last post was from back in April 2008 and no word still anywhere. Maybe someone could develop an add on module for this that will be supported through version 5 and 6 etc. There are probably lots of people who would love to have this feature.
#2
I will gladly apply this patch to d5 branch if some one provides it, however i personally will not work on it. my focus is on d6. i will definitely include this useful functionality in d6 at some point.
#3
Hi, I need this as well, but in d6. Would you have any kind of time frame so I may have an idea when to look for it.
Thank you.
#4
does anyone intend to work on this or sponsor it's development ?
#5
Again, maybe after #288183: Provide api function for other modules to send messages.. An API should make it possible to do this as a submodule (Change Form -> add validate hook -> add submit hook)
#6
Wonderful news Berdir, I see that this is actively being discussed as far as I have read on the #288183 reference you mentioned. And at sometime following the API solution would be an attachment feature as a submodule possibly, I'm sure lots of people will be happy for this one. Thanks for responding and clearing this up.
Eric
#7
Attached is a first version of the privatemsg_attachments submodule. It does depend on the newest patch in #288183: Provide api function for other modules to send messages..
It is actually a very similiar to upload, I am using the same theme functions and it does work like upload.
Features:
- multiple files
- reply and new message form is supported
- messages are displayed below the message body
- attachments are deleted when alle recipients delete the message
Important:
- As soon as the message is sent, attachments are read-only, just like the messages too.
-This is not yet ready, there are some open issues, see the api issue. But it works, atleast for me, so try it out and report if it does work for you.
We currently have pm_xy and privatemsg_xy submodules, privatemsg_attachments is very long, should I rename it to pm_attachments ?
#8
Will your patch work on Privatemsg 5.x-3.0, this is the version I am using. I have never been able to get patches to work for some reason, not very skilled with this sort of thing. Do I apply the patch to my existing version and then just extract your privatemsg_attachments.zip files into the privatemsg module folder root ? Also what version of PHP is required my host is still on 4.4.4. Appologize for the noob ?'s
Thanks
Eric
#9
The patches etc are currently for the Drupal 6 version of privatemsg - chances of new features for the drupal 5 version are nil to zero unless someone else steps up to the table. The code bases are very different.
#10
ok thanks, it's not that critical. I will just wait until I am ready to move into version 6 and install it then.
#11
I am not good at applying patches, can I grab the latest snapshot, would that have the latest attachment code? or would someone be able to attach a patched version of the module for me to download?
Thank you.
#12
Here is the updated version. Only technical changes to get it working with the latest version of the API patch.
To install it, download the latest patch (or the zip of changed files) of #288183: Provide api function for other modules to send messages., apply/unzip it and then unzip the privatemsg_attachments.zip into the privatemsg folder and active the module.
Please report any issues you can find.
#13
Okay, enough is enough, how much cash are asking to add this functionality to version 5.x-3.0?
The support and modules for Drupal 6 are no where near ready for a production site.
#14
@Berdir, nbz: ping me on IRC to discuss this patch. thanks :)
#15
Does thsi need to be updated for any further updates to the api patch?
Also, this may be a stupid question but line 56:
<?phpfunction _privatemsg_upload_form($files = array()) {
?>
ANy reason that that is not
_privatemsg_attachments_upload_form?#16
@velo: Unfortunately there are no developers available/interested in working on the d5 functionality. If you wish to see d5 version of this functionality then you should hire a developer to implement it. Perhaps do it in privatemsg issue queue because some developers here are already familiar with the d5 version of the module.
#17
After installing the attachment module I'm getting this error.
user warning: Table 'xxxxx_dev.pm_index' doesn't exist query: SELECT DISTINCT pm.author, u.name FROM d6_pm_message pm INNER JOIN pm_index pmi ON pm.mid = pmi.mid INNER JOIN d6_users u ON pm.author = u.uid WHERE pmi.uid = 5 AND u.uid > 0 ORDER BY u.name in /home/xxxxxx/public_html/dev/sites/all/modules/privatemsg/privatemsg_filter/privatemsg_filter.module on line 203.#18
The error is not related to the module, it's a bug in privatemsg rc2. You need to upgrade to the -dev version, replace "pm_index" with "{pm_index}" on the mentioned line or wait for a rc3 release.
However, the module needs to be rerolled and will not work in the current version.
#19
module seems to work but when I log in as the user I sent the PM too, there are no files visible.
#20
Yes, there were some changes in the api patch and this module needs to be changed to work with the version which was commited.
#21
Re-roll of the module.
@litwol: You were right, we don't need the #privatemsg_message stuff, I can store the data in storage. However, we do need to add the content of $form_state['storage'] to $message so that modules can access the data they stored there when a message is sent. It might be possible to hack around this by loading the form out of the cache in the _insert function, but this seems ugly to me and would not work with programatically created nodes*
Changes:
- Changed $cached_form['#privatemsg_message'] to $form_state['storage']
- Renamed privatemsg_attachments_privatemsg_message_delete to ..._flush, so that attachments only get deleted when they are flushed. Relies on the flush patch obviously, but is ignored if that one is not present.
- Used the trick described at http://drupal.org/patch/create to add new files into a new directory with a patch.
in privatemsg.module:
- remove old comment about #privatemsg_message
- add $form_state['storage'] to $message
* With the changes in #375999: #288183 followup: Developer friendlify privatemsg_new_thread API. , it would be possible to programatically send messages with attachments, this is not yet documented. First, save a file with file_save_upload and second, add the relevant infos to $options['files']. This module could maybe provide a helper method.
PS: @velo: It is *very* unlikely that someone of the developers (litwol, nbz, me, ..) will work on attachments for privatemsg 5.x-3.0, I never used 5.x.
#22
Would this work with upload path, I can test it if you wish.
#23
upload path? Can't follow you, do you mean private/public downloads?
As this module is more or less a port of the upload.module of core, changes are high that it will (maybe with some work) work together with stuff that is supported by the upload.module.
But I haven't tested it yet.
#24
Sorry, I was not very clear, was I. We use the upload path module (http://drupal.org/project/uploadpath) where users upload files to their own personal folder. I was wondering whether that module would clash with this one... but I shall test it soon and let you know.
#25
I have tested the module, and I can confirm it works perfectly. However, it does not take the uploadpath module into consideration, PM uploads are attachment in the "normal" upload folder instead of the personal folders uploadpath provides.
#26
About uploadpath, I just had a short look at the code. They use hook_nodeapi to rename the files so it obviously doesn't work with privatemsg_attachments.
However, they could also add a hook_privatemsg_message_insert and use the same code, they would just need to loop over $message['files'] instead of $node->files. I would suggest to add a feature request to that module when this has been commited. It doesn't really makes sense before.
#27
I shall certainly do that, Berdir, not that is it is very important but it would create a consistent environment. I am not sure what you mean by "when this has been commited", does it require action from my side?
#28
No, it doesn't. What I meant was that is doesn't really make sense for the upload_path module to write and commit a privatemsg hook when the privatemsg_attachments module is not part of an official privatemsg release.
But you could already open a feature request there and point to that thread and the api documentation.
#29
Done... http://drupal.org/node/398886 and I changed to status to "postponed".
And thanks :)
#30
Berdir
Why call the access "Upload files" ? The best is to create a permission in the privatemsg modules.Because for example in my site i have user who can upload file in a node but can not send attachment in private message !
#31
are the attachments supposed to appear in the recipients message? In my case they upload to the images folder but do not get listed in the message....
#32
Hi,
Sorry to be a pain but I've read the above up and down several times and I've got myself really confused. It's not the first time i've tried patching etc. but I am fairly new to it and there are a few things I'd like clarifying...
1. Are add on modules like this designed to be used with the rc version or the dev version of this module?
2. Is it still necessary to apply the API patch near the top of the page or is this included in more recent releases of the module?
3. Should patches be applied on top of one another in chronological order or do you only need to apply the most up to date one?
4. Where should I be looking for the answers to these kinds of questions?
I would love to use this module extension - could someone who has it working kindly describe the exact steps I need to get it going.
Many thanks,
Ben
#33
Patches are always against -dev version. -dev is where the development happens, it does not make sense to create a patch against releases.
Just the latest patch should be enough.
You can look at http://drupal.org/patch, this is a generic explanation of how to apply and create patches.
#34
How do these patches relate to the new release of Private Message? Should they still work? Which one to use? I can't get them to work. I'm getting the upload field on the "write message" page but nothing appears at the recipients end.
Any advice?
Many thanks,
B
#35
subscribe
#36
many thanks - most of my users seem to want this feature
#37
Thanks to #599358: Simplify pm_send_validate and pass custom fields/values through., this does not need any changes to privatemsg.module anymore.
Just unzip the attached archive (which contains a few bug fixes) into your modules directory and enable the module. It is possible that the necessary change is not yet in the -dev version, to be safe, wait a few hours before you download it, as that one is only rebuild every 12h.
#38
I have installed the module, and it looks great in the write message screen, however when the recipient receives the message there is no sign of the attachment. Are you able to shed some light on this, or is there a step that I have missed out during the install?
Cheers
#39
Are you using the latest (rc4) version of privatemsg? It will only work with that one...
#40
I'm getting the same issue as @ashjeyes - any ideas why this could be?
Thanks
#41
As I've already said, something like that should only happen if you use a old version of privatemsg.module.
Make sure you are using the latest version of privatemsg.module (rc4 or a newer -dev release) (without any of the patches that were posted in this issue earlier) and *only* the privatemsg_attachments-1.tar_.gz file from comment #37.
#42
Subscribe
#43
I used no patches and uploaded rc4 version to my modules directory turned on the module, I then extracted the tar file from #37 and uploaded the privatemsg_attachments folder to my modules directory. Then I turned this module on. I too can see the attach file form, and all seems to function properly from the write new message part. However when I open up the message as a receiver of the message, I cannot see any attachment anywhere. Is there a particular place I should be looking for this attachment ? I tried this whole process again with the latest dev version too but no difference. I am using Drupal 6.13
Eric
#44
@berdir I had RC3, I'll upgrade to RC4 and let you know. Cheers
#45
@berdir, thanks for the advice, now working with RC4. Apologies if I had missed that instruction in previous documentation