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)

Erwin 01-10-2004 08:38 AM

Very good idea, and well done. :) Should be standard in vB3 if you ask me. ;)

Boofo 01-10-2004 09:27 AM

kentaurus, did you chnage anything in the hack yesterday? OI noticed your firest post was updated with Hack Update.

Kentaurus 01-10-2004 02:38 PM

Quote:

Originally Posted by Boofo
kentaurus, did you chnage anything in the hack yesterday? OI noticed your firest post was updated with Hack Update.

It's still the same hack, only I edited the edit reason because some people downloaded the old attachment. The only two updates I have done are the ones that are also commented in the forum, the delete the file when the attachment is deleted and the fix for the view attachments in cp.

Boofo 01-11-2004 08:59 PM

kentaurus, found a major problem with this hack. When I reply to a message (haven't checked the forwarding out yet), it sends the attachments I have stored along with the message. On a new message, it works fine. Only on replies so far (or forwards, I haven't checked yet).

Boofo 01-12-2004 02:32 PM

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?

Kentaurus 01-13-2004 02:19 AM

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.

Boofo 01-13-2004 02:22 AM

Thank you, sir. ;)

I told Erwin about it but he said he couldn't fix problems with other people's hacks. :tired:

Kentaurus 01-13-2004 02:57 AM

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

Boofo 01-13-2004 03:06 AM

If I had to make a choice, yours will stay. ;)

Kentaurus 01-13-2004 03:40 AM

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

Boofo 01-13-2004 03:57 AM

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?

Kentaurus 01-13-2004 04:01 AM

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.

Boofo 01-13-2004 04:06 AM

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

Boofo 01-13-2004 04:52 AM

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

Kentaurus 01-13-2004 01:50 PM

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

Boofo 01-13-2004 07:47 PM

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

Kentaurus 01-17-2004 10:34 PM

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.

Kentaurus 01-17-2004 11:33 PM

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.

Boofo 01-18-2004 03:29 AM

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?

SloppyGoat 01-18-2004 09:29 PM

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.

SloppyGoat 01-18-2004 09:34 PM

Quote:

Originally Posted by Boofo
Does this hack follow what you have set for the attchment storage as far as where they are stored? I have mine stored on the disk and not the db.

A bit off topic, but can you tell me how you do that? I'd rather have my files stored on disk too! I prefer to keep the db as small as possible.

Kentaurus 01-18-2004 10:04 PM

Quote:

Originally Posted by SloppyGoat
A bit off topic, but can you tell me how you do that? I'd rather have my files stored on disk too! I prefer to keep the db as small as possible.

In the admin control panel, in the menu go to attachments -> attachment storage type. there you can switch between database and disk.

Quote:

The only way this could be bad, is if a dnld failed, I guess. But I've yet to see that happen.
Downloads fail for me all the time.. maybe it is just my isp. Also, I am likely to forget where in my hd (or in which computer) I stored the file, I might end searching in the pm so I can dl it again.

SloppyGoat 01-19-2004 12:31 AM

Quote:

Originally Posted by kentaurus
In the admin control panel, in the menu go to attachments -> attachment storage type. there you can switch between database and disk.

Oh! I saw the one for avatars, and I was thinking of that. Now that I look, I've already transfered all my attachments too. DOH! I'm going to have to stop thinking in vB2.X terms, eh? :rolleyes:

Quote:

Downloads fail for me all the time.. maybe it is just my isp. Also, I am likely to forget where in my hd (or in which computer) I stored the file, I might end searching in the pm so I can dl it again.
I only allow 150K attachments, so that's not usually an issue(that I've heard of), on my server anyway. I don't mind this at all, as long as the attachments can be stored on the HDD. :up:

Have all the changes discussed in this thread been updated in the original txt now, or do I need to go back and read all of this again? Nice hack! I'm liking this more and more now...the more I read about it. :up:

Kentaurus 01-19-2004 08:27 AM

Quote:

Originally Posted by SloppyGoat
Oh! I saw the one for avatars, and I was thinking of that. Now that I look, I've already transfered all my attachments too. DOH! I'm going to have to stop thinking in vB2.X terms, eh? :rolleyes:

I only allow 150K attachments, so that's not usually an issue(that I've heard of), on my server anyway. I don't mind this at all, as long as the attachments can be stored on the HDD. :up:

Have all the changes discussed in this thread been updated in the original txt now, or do I need to go back and read all of this again? Nice hack! I'm liking this more and more now...the more I read about it. :up:

All changes are applied to the txt, I only write them in the forum for the people that already had the hack installed and don't want to go all over the instructions again.

SloppyGoat 01-19-2004 08:46 AM

Great! Thanks! I'll be installing this one soon then. ;)

Boofo 01-21-2004 03:07 AM

Quote:

Originally Posted by Boofo
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?

I've narrowed this down to if you send yourself a message with attachments in it, it shows them twice on the Attachments listing. What do I need to do to stop this? ;)

Boofo 01-22-2004 01:12 AM

When you click on the "Show Thumbnails" link, it doesn't show the thumbnails for private attachments. Is there a fix for this, also? ;)

thuffner 01-22-2004 05:17 AM

Just installed vB3 RC3 and re-did this hack twice with no avail.

Doesn't seem to work on RC3... :(:(

Boofo 01-22-2004 05:18 AM

Works great on my RC3. You must have missed something somewhere. ;)

thuffner 01-22-2004 05:27 AM

Well everything works fine except the attachment doesnt show up in a PM...

thuffner 01-22-2004 05:43 AM

Just installed again and it didn't work.

It attaches to a PM fine. I send it to myself, open the PM, and no attachment is in the PM...

Boofo 01-23-2004 10:15 AM

kentaurus, are you still supporting this hack? ;)

Kentaurus 01-23-2004 02:18 PM

Quote:

Originally Posted by Boofo
kentaurus, are you still supporting this hack? ;)

not at the same pace, but yes, I am :) If a really big bad bug appears I would of course give priority to it, for small modifications I usually delay a little more. I even tested this with RC3 yesterday and checked if the instructions were still ok.

About that double attachment in the attachment screen I am still thinking if I should fix that. The attachments in private message are somehow more controversial than the common attachments...

Right now I can duplicate the attachment for the attachment owner and all the members for which the attachment is sent.. that takes a lot of space in little time because a single attachment can be stored twice, or three times, or more. If I don't do that ownership of the attachment is difficult to determine.

If the owner of the attachment is the one that sent the attachment then I can go to attachments -> delete this attachment and the person that received it keeps nothing. I don't think this is natural, right now if someone sends me something by mail there is no way they can delete it after being sent.

If the owner of the attachment is the recipient then I have to do that store-attachments-more-than-once, and that's not nice for the db or the filesystem. I can't store it only once because a pm can be sent to multiple recipients, and then any recipient would be able to delete it leaving the rest with no attachment. This is even worse than the owner deleting it.

And now, why does the attachment appears twice in the attachment screen? That is because it appears once for each of your pm with that attachments, and if you send the pm to yourself and also you keep a copy then you have 2 pm's. Then that screen will link once to the pm you recieved from yourself and once to the pm that is in the sent folder.. even if it's the same attachment. That is why I haven't fixed it yet.. I am still debating if I should. Sending a pm to yourself is not that natural anyway, unless I were using the pm as a personal notepad or something.

Kentaurus 01-23-2004 02:21 PM

Quote:

Originally Posted by thuffner
Just installed again and it didn't work.

It attaches to a PM fine. I send it to myself, open the PM, and no attachment is in the PM...

There was also someone having that problem before. Do you have any other hack installed that deals with functions_posting.php or private.php?

Also, did you made all the code modifications in private.php? That's usually the problem.

sonic3d 01-23-2004 08:09 PM

nice job

thuffner 01-23-2004 11:16 PM

Quote:

Originally Posted by kentaurus
There was also someone having that problem before. Do you have any other hack installed that deals with functions_posting.php or private.php?

Also, did you made all the code modifications in private.php? That's usually the problem.

Nope no other hacks installed. And did the private.php mods. I switched over to thumbnail attached images in my ACP and it works fine now. A workaround, but I'll take it. :)

Boofo 01-24-2004 03:07 AM

Quote:

Originally Posted by kentaurus
not at the same pace, but yes, I am :) If a really big bad bug appears I would of course give priority to it, for small modifications I usually delay a little more. I even tested this with RC3 yesterday and checked if the instructions were still ok.

About that double attachment in the attachment screen I am still thinking if I should fix that. The attachments in private message are somehow more controversial than the common attachments...

Right now I can duplicate the attachment for the attachment owner and all the members for which the attachment is sent.. that takes a lot of space in little time because a single attachment can be stored twice, or three times, or more. If I don't do that ownership of the attachment is difficult to determine.

If the owner of the attachment is the one that sent the attachment then I can go to attachments -> delete this attachment and the person that received it keeps nothing. I don't think this is natural, right now if someone sends me something by mail there is no way they can delete it after being sent.

If the owner of the attachment is the recipient then I have to do that store-attachments-more-than-once, and that's not nice for the db or the filesystem. I can't store it only once because a pm can be sent to multiple recipients, and then any recipient would be able to delete it leaving the rest with no attachment. This is even worse than the owner deleting it.

And now, why does the attachment appears twice in the attachment screen? That is because it appears once for each of your pm with that attachments, and if you send the pm to yourself and also you keep a copy then you have 2 pm's. Then that screen will link once to the pm you recieved from yourself and once to the pm that is in the sent folder.. even if it's the same attachment. That is why I haven't fixed it yet.. I am still debating if I should. Sending a pm to yourself is not that natural anyway, unless I were using the pm as a personal notepad or something.

That makes more sense now. I usually don't send pms with attachmnets to myself, so that is not any problem having it show up twice. It was just a test message that I have already erased anyway. ;)

What about the Show Thumbnails not working with pm attachments? Can that be fixed?

Kentaurus 01-25-2004 02:46 AM

Quote:

Originally Posted by Boofo
What about the Show Thumbnails not working with pm attachments? Can that be fixed?

Of course, of course :nervous:

In profile.php search for this:

Code:

$show['thumbnail'] = iif($post['hasthumbnail'] == 1 AND $vboptions['attachthumbs'] AND $showthumbs AND $post['postid'], 1, 0);
replace it with:

Code:

$show['thumbnail'] = iif($post['hasthumbnail'] == 1 AND $vboptions['attachthumbs'] AND $showthumbs AND ($post['postid'] OR $post['private']), 1, 0);

Boofo 01-25-2004 03:04 AM

Thank you, sir. ;) Will you be updating the file in the first post with this?

Kentaurus 01-25-2004 03:35 AM

Quote:

Originally Posted by Boofo
Thank you, sir. ;) Will you be updating the file in the first post with this?

Already updated.


All times are GMT. The time now is 02:52 AM.

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.01537 seconds
  • Memory Usage 1,878KB
  • 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
  • (11)bbcode_code_printable
  • (20)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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