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
This modification may not be copied, reproduced or published elsewhere without author's permission.
if (!($forumperms & CANGETATTACHMENT))
{
$vboptions['viewattachedimages'] = 0;
$vboptions['attachthumbs'] = 0;
}
// check if there is a forum password and if so, ensure the user has it set
verify_forum_password($attachmentinfo['forumid'], $attachmentinfo['password']);
$pmUsers = $DB_site->query_first("SELECT toUserArray FROM ".TABLE_PREFIX."pmtext WHERE pmtextid='".$attachmentinfo['private']."'");
$toUserArray = unserialize($pmUsers['toUserArray']);
if ($toUserArray[$bbuserinfo['userid']] != $bbuserinfo['username'] && $attachmentinfo['userid'] != $bbuserinfo['userid']) {
print_no_permission();
}
It works fine until I had this part. Id di it in steps. Aded the first uploaded images showed. Added the second part images still showed. When I added the above part the images broke.
It still does it with what you posted in your lsat post as well
Yea same here, it breaks all previously uploaded attechments to the forum (thumbs and permissions to view).
Ok. Got this thing to work right in 3.0.3. I spent some time trying to figure out exactly what was trying to be done with the edits, and figured out how to do it.
Start with a fresh attachment.php (or one without the modifications for pms)
Find:
PHP Code:
attachment.visible, mimetype, NOT ISNULL(deletionlog.primaryid) AS isdeleted,
thread.forumid, forum.password, thread.threadid
Change to: (Purpose: Adds private as an option variable)
PHP Code:
attachment.visible, mimetype, NOT ISNULL(deletionlog.primaryid) AS isdeleted,
thread.forumid, forum.password, thread.threadid, private
Find:
PHP Code:
if ($attachment['postid'] == 0 AND $bbuserinfo['userid'] == $attachmentinfo['userid'])
Add Above: (Purpose: Starts an if/then statement that if it's not a private message attachment do things like normal)
PHP Code:
if (!$attachmentinfo['private']) {
Find:
PHP Code:
// check if there is a forum password and if so, ensure the user has it set
verify_forum_password($attachmentinfo['forumid'], $attachmentinfo['password']);
if (!$attachmentinfo['visible'] AND !can_moderate($attachmentinfo['forumid'], 'canmoderateattachments') AND $attachmentinfo['userid'] != $bbuserinfo['userid'])
{
$idname = 'attachment';
eval(print_standard_error('error_invalidid'));
}
}
Add Below: (Purpose: Ends the if/then statement and adds what to do if it IS a private message attachment.)
PHP Code:
} else {
$pmUsers = $DB_site->query_first("SELECT toUserArray FROM ".TABLE_PREFIX."pmtext WHERE pmtextid='".$attachmentinfo['private']."'");
$toUserArray = unserialize($pmUsers['toUserArray']);
if ($toUserArray[$bbuserinfo['userid']] != $bbuserinfo['username'] && $attachmentinfo['userid'] != $bbuserinfo['userid']) {
print_no_permission();
}
}
I've tested it with different users until I got the code working properly for both regular attachments and pm attachments. So this should work fine for those of you using 3.0.3.
I am sorry, but can someone summarize all the steps I need to do to get it work? Or does the file in the first post contain complete solution?
Thank you.