vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   [VB3 RC3] Attachments in private messages (https://vborg.vbsupport.ru/showthread.php?t=59840)

Boofo 01-08-2004 05:13 PM

Does the regular attachments work the same way, or are they doing an unset?

Kentaurus 01-08-2004 06:14 PM

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.

Kentaurus 01-08-2004 06:25 PM

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.

Boofo 01-08-2004 06:36 PM

Thank you, sir. ;)

Convergys 01-08-2004 06:49 PM

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?

Boofo 01-08-2004 06:51 PM

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?

Boofo 01-08-2004 07:03 PM

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. ;)

Convergys 01-08-2004 07:12 PM

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...

Kentaurus 01-08-2004 07:19 PM

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.

Convergys 01-08-2004 07:28 PM

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...


All times are GMT. The time now is 08:12 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.01463 seconds
  • Memory Usage 1,763KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete