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)

RobinHood 09-14-2004 02:34 AM

Quote:

Originally Posted by Weasel
I'm having problems with your code RobinHood, it seems to break the permissions of normal attachments, i.e. no one can view them now.

Okay, try this:

Change:

PHP Code:

if (!($forumperms CANGETATTACHMENT)) 

    
$vboptions['viewattachedimages'] = 0
    
$vboptions['attachthumbs'] = 0


To:

PHP Code:

if (!($forumperms CANVIEW) OR !($forumperms CANGETATTACHMENT)) 

    
$vboptions['viewattachedimages'] = 0
    
$vboptions['attachthumbs'] = 0


That should do the trick. Let me know how it goes. :)

BamaStangGuy 09-14-2004 05:08 AM

Quote:

Originally Posted by RobinHood
Okay, try this:

Change:

PHP Code:

if (!($forumperms CANGETATTACHMENT)) 

    
$vboptions['viewattachedimages'] = 0
    
$vboptions['attachthumbs'] = 0


To:

PHP Code:

if (!($forumperms CANVIEW) OR !($forumperms CANGETATTACHMENT)) 

    
$vboptions['viewattachedimages'] = 0
    
$vboptions['attachthumbs'] = 0


That should do the trick. Let me know how it goes. :)

all my thumbnails are red x's and I get a no permisson

I have done what you said to do above and it still doesnt work

BamaStangGuy 09-14-2004 05:12 AM

Something I just realized

It breaks all the thumbnails and images that were uploaded before the pm hack was installed. But if I upload a new image on the forum it works fine.

Basically all my old attachments show up as red x's and give a no permission when clicked.

But if I add a new attachment to a thread then it works fine

BamaStangGuy 09-14-2004 05:57 AM

Quote:

Code:

if (!($forumperms & CANGETATTACHMENT))
{
    $vboptions['viewattachedimages'] = 0;
    $vboptions['attachthumbs'] = 0;
}

// check if there is a forum password and if so, ensure the user has it set
    verify_forum_password($attachmentinfo['forumid'], $attachmentinfo['password']);

$pmUsers = $DB_site->query_first("SELECT toUserArray FROM ".TABLE_PREFIX."pmtext WHERE pmtextid='".$attachmentinfo['private']."'");
    $toUserArray = unserialize($pmUsers['toUserArray']);         
    if ($toUserArray[$bbuserinfo['userid']] != $bbuserinfo['username'] && $attachmentinfo['userid'] != $bbuserinfo['userid']) {
            print_no_permission();       
          }


It works fine until I had this part. Id di it in steps. Aded the first uploaded images showed. Added the second part images still showed. When I added the above part the images broke.

It still does it with what you posted in your lsat post as well

Weasel 09-14-2004 10:38 AM

Yea same here, it breaks all previously uploaded attechments to the forum (thumbs and permissions to view).

Saphrym 09-14-2004 05:49 PM

Quote:

Originally Posted by Weasel
Yea same here, it breaks all previously uploaded attechments to the forum (thumbs and permissions to view).

Ok. Got this thing to work right in 3.0.3. I spent some time trying to figure out exactly what was trying to be done with the edits, and figured out how to do it.


Start with a fresh attachment.php (or one without the modifications for pms)

Find:
PHP Code:

attachment.visiblemimetypeNOT ISNULL(deletionlog.primaryid) AS isdeleted,
        
thread.forumidforum.passwordthread.threadid 

Change to: (Purpose: Adds private as an option variable)
PHP Code:

attachment.visiblemimetypeNOT ISNULL(deletionlog.primaryid) AS isdeleted,
        
thread.forumidforum.passwordthread.threadid, private 

Find:
PHP Code:

if ($attachment['postid'] == AND $bbuserinfo['userid'] == $attachmentinfo['userid']) 

Add Above: (Purpose: Starts an if/then statement that if it's not a private message attachment do things like normal)
PHP Code:

if (!$attachmentinfo['private']) { 

Find:
PHP Code:

    // check if there is a forum password and if so, ensure the user has it set
    
verify_forum_password($attachmentinfo['forumid'], $attachmentinfo['password']);

    if (!
$attachmentinfo['visible'] AND !can_moderate($attachmentinfo['forumid'], 'canmoderateattachments') AND $attachmentinfo['userid'] != $bbuserinfo['userid'])
    {
        
$idname 'attachment';
        eval(
print_standard_error('error_invalidid'));
    }


Add Below: (Purpose: Ends the if/then statement and adds what to do if it IS a private message attachment.)
PHP Code:

} else {
    
$pmUsers $DB_site->query_first("SELECT toUserArray FROM ".TABLE_PREFIX."pmtext WHERE pmtextid='".$attachmentinfo['private']."'");
    
$toUserArray unserialize($pmUsers['toUserArray']);         
    if (
$toUserArray[$bbuserinfo['userid']] != $bbuserinfo['username'] && $attachmentinfo['userid'] != $bbuserinfo['userid']) {
            
print_no_permission();        
           }


I've tested it with different users until I got the code working properly for both regular attachments and pm attachments. So this should work fine for those of you using 3.0.3.

Hope this helps.

BamaStangGuy 09-14-2004 06:02 PM

It worked!!!

Thanks

Weasel 09-14-2004 09:16 PM

Good job, the simplest solution is always the best, huh?

RobinHood 09-18-2004 09:46 PM

Quote:

Originally Posted by Weasel
Good job, the simplest solution is always the best, huh?

Is it just me or is there something wrong with the script? Why does it kept deleting the attachments right after a few hours or so???

AZone 09-19-2004 06:23 PM

I am sorry, but can someone summarize all the steps I need to do to get it work? Or does the file in the first post contain complete solution?
Thank you.


All times are GMT. The time now is 08:14 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.01198 seconds
  • Memory Usage 1,775KB
  • 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
  • (1)bbcode_code_printable
  • (10)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)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