Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
[VB3 RC3] Attachments in private messages Details »»
[VB3 RC3] Attachments in private messages
Version: 1.00, by Kentaurus Kentaurus is offline
Developer Last Online: Jul 2014 Show Printable Version Email this Page

Version: 3.0.0 Rating:
Released: 01-06-2004 Last Update: Never Installs: 134
 
No support by the author.

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

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #47  
Old 01-13-2004, 02:19 AM
Kentaurus's Avatar
Kentaurus Kentaurus is offline
 
Join Date: Dec 2001
Posts: 332
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Boofo
Ok, I've narrowed it down a bit further. It seems the attachments get added to any message that is sent out with the Quick PM Reply hack. The regular reply works fine. Any way to fix this?
Is that a problem of the Quick PM reply hack or mine? In my forum it works well.
I'll install the Quick PM reply and see where to fix it.
Reply With Quote
  #48  
Old 01-13-2004, 02:22 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you, sir.

I told Erwin about it but he said he couldn't fix problems with other people's hacks. :tired:
Reply With Quote
  #49  
Old 01-13-2004, 02:57 AM
Kentaurus's Avatar
Kentaurus Kentaurus is offline
 
Join Date: Dec 2001
Posts: 332
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Boofo
Thank you, sir.

I told Erwin about it but he said he couldn't fix problems with other people's hacks. :tired:
I could also say that I can't fix problems with other people's hacks
Reply With Quote
  #50  
Old 01-13-2004, 03:06 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If I had to make a choice, yours will stay.
Reply With Quote
  #51  
Old 01-13-2004, 03:40 AM
Kentaurus's Avatar
Kentaurus Kentaurus is offline
 
Join Date: Dec 2001
Posts: 332
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Boofo
If I had to make a choice, yours will stay.
Well.. jokes away, this is something bad. If you have both hacks installed and use quick reply it would cause all attachments, not only the ones in that private message to belong to the new pm. That is a really really bad thing.

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]
				");
		}
replace it with this:

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
Reply With Quote
  #52  
Old 01-13-2004, 03:57 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #53  
Old 01-13-2004, 04:01 AM
Kentaurus's Avatar
Kentaurus Kentaurus is offline
 
Join Date: Dec 2001
Posts: 332
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Boofo
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?
Either if you have Erwin's hack installed or not it won't hurt. It's just an additional security check. I would recommend installing it though.

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.
Reply With Quote
  #54  
Old 01-13-2004, 04:06 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #55  
Old 01-13-2004, 04:52 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #56  
Old 01-13-2004, 01:50 PM
Kentaurus's Avatar
Kentaurus Kentaurus is offline
 
Join Date: Dec 2001
Posts: 332
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Boofo
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.
I'm afraid that is because when you sent a private message all the forum attachments were marked to belong to that new private message.

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
Reply With Quote
  #57  
Old 01-13-2004, 07:47 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #58  
Old 01-17-2004, 10:34 PM
Kentaurus's Avatar
Kentaurus Kentaurus is offline
 
Join Date: Dec 2001
Posts: 332
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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&amp;pmid=$pm[pmid]"><if condition="$show['unread']"><strong>$pm[title]</strong><else />$pm[title]</if></a>
add before:

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.
Reply With Quote
  #59  
Old 01-17-2004, 11:33 PM
Kentaurus's Avatar
Kentaurus Kentaurus is offline
 
Join Date: Dec 2001
Posts: 332
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
");
change it to:

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
");
and in the modifyattachmentsbit template

change
Code:
<div><strong>$vbphrase[in_private_message]</strong></div>
to this
Code:
<div><strong>$vbphrase[in_private_message]:</strong> <a href="private.php?do=showpm&pmid=$post[pmid]">$post[title]</a></div>
I'll leave the from and sent-to, that's because a private message can be sent to multiple members. And deciding who the attachment belongs to can be real tricky.. right now it only appears to the person that sent the private message.
Reply With Quote
  #60  
Old 01-18-2004, 03:29 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #61  
Old 01-18-2004, 09:29 PM
SloppyGoat's Avatar
SloppyGoat SloppyGoat is offline
 
Join Date: Feb 2002
Posts: 339
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kentaurus
Wouldn't that be a little hard on your users? I usually download an attachment more than once, and after I download it I expect it to remain there. That would seem a little un(user-friendly) to me.

This hack uses the same quotas and options that you have already defined for your attachments so if you have a quota for each user no matter if they attach files to posts or private message once they reach their limit they would have to delete some to continue attaching files.
How would that be hard on users? I could see your point if more than one person was dnlding the attachment, but there will always only be one person viewing the PM, right? Once they have the file, I see no reason to let them store the attachments indefinitely. The only way this could be bad, is if a dnld failed, I guess. But I've yet to see that happen.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:47 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05152 seconds
  • Memory Usage 2,377KB
  • Queries Executed 30 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (9)bbcode_code
  • (6)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (16)post_thanks_box
  • (16)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (16)post_thanks_postbit_info
  • (15)postbit
  • (16)postbit_onlinestatus
  • (16)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete