The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
![]() |
|||||||||||||||||||||||||||
[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 |
#47
|
||||
|
||||
![]() Quote:
I'll install the Quick PM reply and see where to fix it. |
#48
|
||||
|
||||
![]()
Thank you, sir.
![]() I told Erwin about it but he said he couldn't fix problems with other people's hacks. :tired: |
#49
|
||||
|
||||
![]() Quote:
![]() |
#50
|
||||
|
||||
![]()
If I had to make a choice, yours will stay.
![]() |
#51
|
||||
|
||||
![]() Quote:
I was relying on the posthash for the attachments, the quick reply has no posthash (an empty one) so the code just assumes that all attachments with an empty posthash are for that message (ie - all other attachments in the forum). I made a patch so this hack will work cooperative with the quick reply, I'll pm Erwin and see if he wants to update his hack also, either hack can be patched but I can only modify mine of course. find this: Code:
$attachcount = $DB_site->query_first(" SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "attachment WHERE posthash = '" . addslashes($_POST['posthash']) . "' AND userid = $bbuserinfo[userid] "); $totalattachments = $attachcount['count']; if ($totalattachments) { $DB_site->query("UPDATE " . TABLE_PREFIX . "pmtext SET attach='$totalattachments' WHERE pmtextid='$pmtextid'"); $DB_site->query(" UPDATE " . TABLE_PREFIX . "attachment SET private = $pmtextid, posthash = '' WHERE posthash = '" . addslashes($_POST['posthash']) . "' AND userid = $bbuserinfo[userid] "); } Code:
if ($_POST['posthash']) { $attachcount = $DB_site->query_first(" SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "attachment WHERE posthash = '" . addslashes($_POST['posthash']) . "' AND posthash<>'' AND userid = $bbuserinfo[userid] "); $totalattachments = $attachcount['count']; if ($totalattachments) { $DB_site->query("UPDATE " . TABLE_PREFIX . "pmtext SET attach='$totalattachments' WHERE pmtextid='$pmtextid'"); $DB_site->query(" UPDATE " . TABLE_PREFIX . "attachment SET private = $pmtextid, posthash = '' WHERE posthash = '" . addslashes($_POST['posthash']) . "' AND userid = $bbuserinfo[userid] "); } } TXT is updated also |
#52
|
||||
|
||||
![]()
Will this hurt anything for anyone who doesn't have Erwin's hack installed? Or is this ONLY to be used if you are using his hack, too?
|
#53
|
||||
|
||||
![]() Quote:
In the txt this code is included for the people that install the hack for their first time to ensure that they don't have any problems if they install the quick reply after. |
#54
|
||||
|
||||
![]()
Thank you very much, sir, for the fast fix.
![]() I'm looking forward to more of your great hacks in the future. You seem to care about fixing things to work with and around other's hacks, when it is a lot easier to pass the buck, sometimes. ![]() |
#55
|
||||
|
||||
![]()
I hate to be the bearer of bad news, but there is a small problem now. Oh, it works great with Erwin's hack now but all of my attachments are showing as Private Message even when they aren't.
![]() |
#56
|
||||
|
||||
![]() Quote:
That is why I told before that it was really bad, because without the fix as soon as you used quick reply all the attachments in the forum would go to the private message. Right now there is no easy way to fix this, since the damage is already done... I wish I had seen that coming before. However, you can run a query to recover all the attachments in posts, this will return them to think they belong to a post and not to a private message, the only ones that can't be recovered are the ones in the private message, they already belong to the last pm that was sent. Ok, this is the scenario: attachment1 - in private message attachment2 - in private message attachment3 - in private message attachment4 - in private message after running the query attachment1 - in post xxx attachment2 - in post yyy attachment3 - in private message attachment4 - in post zzz the attachment 3 remains in a private message, but potentially not the one that it should but the last one sent via pm quick reply. The next time you use attachments in private message there will be no problem, it's just that the quick reply messed up the attachments that weren't expecting a hashless post to come along. Query: Code:
update attachment set private=0 where postid<>0 |
#57
|
||||
|
||||
![]()
Thanks for the query. All seems well again.
![]() Is there any way to add a From: and Sent to: the listing of attachments under the Private Message part? It might be nice to know at a quick glance who the attachment was sent to or came from. ![]() |
#58
|
||||
|
||||
![]()
I have a small change (template edit). It is completely optional.
This will add a paperclip to the left of the title of the private message if the private message contains an attachment. In pm_messagelistbit find this: Code:
<a href="private.php?$session[sessionurl]do=showpm&pmid=$pm[pmid]"><if condition="$show['unread']"><strong>$pm[title]</strong><else />$pm[title]</if></a> Code:
<if condition="$pm['attach']"><img class="inlineimg" src="$stylevar[imgdir_misc]/paperclip.gif" alt="<phrase 1="$pm[attach]">$vbphrase[x_attachments]</phrase>" /></if> Next I will do is that From and Title for the attachments' screen. |
#59
|
||||
|
||||
![]()
Only for the people that already have it installed.
This will add a link to the private message sent in the attachments screen so you can go and read to message or at least know which private message it was. Find this query in profile.php Code:
$attachments = $DB_site->query(" SELECT thread.forumid, post.postid, post.threadid AS p_threadid, post.title AS p_title, if(post.postid,post.dateline,pmtext.dateline) AS p_dateline, attachment.attachmentid, thread.title AS t_title, attachment.filename, attachment.counter, attachment.filesize AS size, IF(thumbnail = '', 0, 1) AS hasthumbnail, user.username, thread.open, attachment.userid, attachment.private, FROM " . TABLE_PREFIX . "attachment AS attachment LEFT JOIN " . TABLE_PREFIX . "post AS post ON (post.postid = attachment.postid) LEFT JOIN " . TABLE_PREFIX . "pmtext AS pmtext ON (pmtext.pmtextid = attachment.private) LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON (post.threadid = thread.threadid) LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON(attachment.postid = deletionlog.primaryid AND type = 'post') LEFT JOIN " . TABLE_PREFIX . "user AS user ON (attachment.userid = user.userid) WHERE attachment.userid = $userid AND ((forumid IN (0$forumids) AND thread.visible = 1 AND post.visible = 1 AND deletionlog.primaryid IS NULL) " . iif($userid==$bbuserinfo['userid'], "OR attachment.postid = 0") . ") ORDER BY attachment.attachmentid DESC LIMIT " . ($limitlower - 1) . ", $perpage "); Code:
$attachments = $DB_site->query(" SELECT thread.forumid, post.postid, post.threadid AS p_threadid, post.title AS p_title, if(post.postid,post.dateline,pmtext.dateline) AS p_dateline, attachment.attachmentid, thread.title AS t_title, attachment.filename, attachment.counter, attachment.filesize AS size, IF(thumbnail = '', 0, 1) AS hasthumbnail, user.username, thread.open, attachment.userid, attachment.private, pmtext.title, pm.pmid FROM " . TABLE_PREFIX . "attachment AS attachment LEFT JOIN " . TABLE_PREFIX . "post AS post ON (post.postid = attachment.postid) LEFT JOIN " . TABLE_PREFIX . "pmtext AS pmtext ON (pmtext.pmtextid = attachment.private) LEFT JOIN " . TABLE_PREFIX . "pm AS pm ON (pmtext.pmtextid=pm.pmtextid AND pm.userid=$userid) LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON (post.threadid = thread.threadid) LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON(attachment.postid = deletionlog.primaryid AND type = 'post') LEFT JOIN " . TABLE_PREFIX . "user AS user ON (attachment.userid = user.userid) WHERE attachment.userid = $userid AND ((forumid IN (0$forumids) AND thread.visible = 1 AND post.visible = 1 AND deletionlog.primaryid IS NULL) " . iif($userid==$bbuserinfo['userid'], "OR attachment.postid = 0") . ") ORDER BY attachment.attachmentid DESC LIMIT " . ($limitlower - 1) . ", $perpage "); change Code:
<div><strong>$vbphrase[in_private_message]</strong></div> Code:
<div><strong>$vbphrase[in_private_message]:</strong> <a href="private.php?do=showpm&pmid=$post[pmid]">$post[title]</a></div> |
#60
|
||||
|
||||
![]()
Ok, that works but it now shows each pm attachment twice in the attachments list.
![]() Have the instructions from the first post been updated with this and the paperclip code? |
#61
|
||||
|
||||
![]() Quote:
|
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|