The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
[VB3 RC3] Attachments in private messages Details »» | |||||||||||||||||||||||||||
[VB3 RC3] Attachments in private messages
Developer Last Online: Jul 2014
Unsupported. VB3.5 version is here:
https://vborg.vbsupport.ru/showthread.php?t=91220 Tested on 3.0.3 This hack enables you to send attachments in a private message. This feature was really useful to me in vb2 and I kind of missed it on vb3 so I rehacked it myself. When a user writes a private message they will be given the option to add an attachment, the same as when writing a post. It uses the same rules you have defined for a convencional attachment including file types, quotas, etc. It is only an extension for attachments to be used in private messages. As always it is advised to backup your files before hacking in case you want to go back, this is some big hack including modification of multiple files, some templates and adding two extra columns in the database tables. Instructions are provided in the txt, and some screenshots on where the attachment option appears. Info for hackers: You may modify, improve, upgrade, redistribute this hack, include it in another hack or yours or translate it provided you do it free of charge and you distribute it in www.vbulletin.org at least, there is no need to pm me asking for permission Some portions of the code are (c) Jelsoft Enterprises Ltd. Edit by MarcoH64: Because of multiple requests to make this hack work on vB3.0.7 i created upgrade instructions. These upgrade instructions can be followed after the original instructions (the 3.0.3 version). The original coder can not be held responsible for my modification. Show Your Support
|
Comments |
#12
|
||||
|
||||
Does the regular attachments work the same way, or are they doing an unset?
|
#13
|
||||
|
||||
Quote:
In private messages it is a little more tricky because the same private message can be reused between multiple recipients, so we need to make sure that nobody needs the pmtext. Vbulletin does it by using an hourly cleanup to delete all orphan pmtext, I made it delete the attachments there also. ################################################## ################# # Code modifications in file "includes/cron/cleanup2.php" ################################################## ################# ------------------------------------------------------------------- at line 81, search for this code: ------------------------------------------------------------------- Code:
$pmtextids = '0'; while ($pmtext = $DB_site->fetch_array($pmtexts)) { $pmtextids .= ",$pmtext[pmtextid]"; } $DB_site->query("DELETE FROM " . TABLE_PREFIX . "pmtext WHERE pmtextid IN($pmtextids)"); } $DB_site->free_result($pmtexts); change it to: ------------------------------------------------------------------- Code:
$pmtextids = '0'; $pmtextidsAttach = ""; $pmtextAttach = array(); while ($pmtext = $DB_site->fetch_array($pmtexts)) { $pmtextids .= ",$pmtext[pmtextid]"; $pmtextAttach[] = $pmtext[pmtextid]; } $pmtextidsAttach = implode(",",$pmtextAttach); $DB_site->query("DELETE FROM " . TABLE_PREFIX . "pmtext WHERE pmtextid IN($pmtextids)"); } $DB_site->free_result($pmtexts); // Attachments for orphaned pmtext records are removed // Let's be very careful with this delete, a delete from attachment where private IN (0) will purge all non-private attachments // that's why an extra $pmtextidsAttachments is created instead of reusing the old one if ($pmtextidsAttach) { if ($vboptions['attachfile']) { $attachments = $DB_site->query(" SELECT attachmentid, userid FROM " . TABLE_PREFIX . "attachment WHERE private IN (".$pmtextidsAttach.") "); while ($attachment = $DB_site->fetch_array($attachments)) { $ids["$attachment[attachmentid]"] = $attachment; } require_once('./includes/functions_file.php'); delete_attachment_files($ids); } $DB_site->query("DELETE FROM " . TABLE_PREFIX . "attachment WHERE private IN (".$pmtextidsAttach.")"); } Code:
ALTER TABLE attachment add index (private); The .txt is also updated with this changes. You only need to apply them if you downloaded the txt before this post was made. |
#14
|
||||
|
||||
Quote:
Well, maybe someone else would hack it, I don't think I will be doing this one as I like how it works right now. |
#15
|
||||
|
||||
Thank you, sir.
|
#16
|
|||
|
|||
I am having problems with this...
I am sure i have followed all instructions... I am able to send the attachments, but the recipient does not receive them... And when I view trhe attachments i have posted in the user cp, it shows, In Progress... Have i dont something wrong? |
#17
|
||||
|
||||
Quote:
Is there a way to limit this to like the admin and/or mods or userid 1 and 2 or something like that then? Maybe a template condition? |
#18
|
||||
|
||||
You're using detailed time on your board, right? That is what it means by in progress. Have you tried to click on any of the attachments in the usercp? I have and they are there and show up fine.
|
#19
|
|||
|
|||
Quote:
In the user cp they do show up fine, but the problem is that the recipient of the PM does not receive the attachment... I can send it find with no errors, but the user doesn't receive it... |
#20
|
||||
|
||||
Quote:
However, I don't have any problem with viewing my attached file in the private message, are you sure you have this code around line ~1371? That's the one responsible for fetching the attachments. Code:
if ($pm['attach']) { $pm['attachments'] = array(); $attachments = $DB_site->query(" SELECT filename, filesize, visible, attachmentid, counter, postid, IF(thumbnail = '', 0, 1) AS hasthumbnail, LENGTH(thumbnail) AS thumbnailsize FROM " . TABLE_PREFIX . "attachment WHERE private='".$pm['pmtextid']."' "); while ($attachment = $DB_site->fetch_array($attachments)) { $attachment['kilobytes'] = vb_number_format($attachment['filesize'] / 1024, 1); $pm['attachments']["$attachment[attachmentid]"] = $attachment; } } |
#21
|
|||
|
|||
Quote:
Attachments in normal post do show fine... |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|