Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases

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

Does the regular attachments work the same way, or are they doing an unset?
Reply With Quote
  #13  
Old 01-08-2004, 06:14 PM
Kentaurus's Avatar
Kentaurus Kentaurus is offline
 
Join Date: Dec 2001
Posts: 332
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Boofo
Does the regular attachments work the same way, or are they doing an unset?
The regular attachments are deleted when the post is deleted or the user deletes the attachment via the usercp, in my hack I forgot to write some code to delete any unused attachment.

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.")");
}
Also, I forgot to mention earlier, you should add an index to the attachment table for the private column, it really matters for large tables. Here is the query:

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

Quote:
Originally Posted by Boofo
Is there a way to maybe add a settings group for this like a limit on how many attachments you can have (not dependent on the regukar attachmnets settings for posts)? I really hate to tie up the db with a lot of leftover attachmnets in the pm area. Maybe even have a usergroup option to only allow certain usergroups to use it. Might make them want to do better to move up and be able to access this.
I really prefer them to be tied to the regular attachments, otherwise you need to almost duplicate the quota code for the attachments, it shouldn't be so hard to do but still it's not something I would really be using, it's easier for my users just to have one attachment quota.

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.
Reply With Quote
  #15  
Old 01-08-2004, 06:36 PM
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.
Reply With Quote
  #16  
Old 01-08-2004, 06:49 PM
Convergys Convergys is offline
 
Join Date: Feb 2003
Posts: 56
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

Quote:
Originally Posted by kentaurus
I really prefer them to be tied to the regular attachments, otherwise you need to almost duplicate the quota code for the attachments, it shouldn't be so hard to do but still it's not something I would really be using, it's easier for my users just to have one attachment quota.

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.
That makes sense.

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

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.
Reply With Quote
  #19  
Old 01-08-2004, 07:12 PM
Convergys Convergys is offline
 
Join Date: Feb 2003
Posts: 56
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Boofo
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.
Are you are speaking with me? If so, thanks...
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...
Reply With Quote
  #20  
Old 01-08-2004, 07:19 PM
Kentaurus's Avatar
Kentaurus Kentaurus is offline
 
Join Date: Dec 2001
Posts: 332
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Convergys
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?
The "In progress" status is a bug, I'll fix it soon. That's because there is no post associated to the attachment.

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;
		 }
}
Also, the attachments in a normal post show fine? The same code that creates the postbit for a thread is the code that creates it for a pm.
Reply With Quote
  #21  
Old 01-08-2004, 07:28 PM
Convergys Convergys is offline
 
Join Date: Feb 2003
Posts: 56
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kentaurus
The "In progress" status is a bug, I'll fix it soon. That's because there is no post associated to the attachment.

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;
 		 }
 }
Also, the attachments in a normal post show fine? The same code that creates the postbit for a thread is the code that creates it for a pm.
Yeah, I have that change in the code... Not sure what is causing the problem...

Attachments in normal post do show fine...
Reply With Quote
Reply

Thread Tools

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 09:28 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04951 seconds
  • Memory Usage 2,321KB
  • Queries Executed 25 (?)
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
  • (5)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
  • (3)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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