PDA

View Full Version : Changing Attachment Size Dynamically


ShannonA
10-06-2005, 10:59 PM
I've got my boards set up to allow some users access to bigger attachments than others. I used to do this through some mods to the files, but I'm trying to do it through the hooks now, but to no success. Here's what I've got right now, where "isMember" is my own function:


if ($isMember) {

foreach($vbulletin->attachmentcache AS $extension)
{
if (is_array($extension))
{
$extension['size'] = 1024 * 100;
}

}

}


I've got this in global_start, but I've also tried it in newattachment_start, and nothing seems to quite do it.

Any ideas?

Shannon

Andreas
10-06-2005, 11:20 PM
What was your 3.0 Code?



if ($isMember)
{
foreach ($vbulletin->attachmentcache AS $key => $extension)
{
if (is_array($extension))
{
$vbulletin->attachmentcache["$key"]['size'] = 1024 * 100;
}

}
}

ShannonA
10-07-2005, 04:27 PM
In 3.0 I was doing in a somewhat backward way, changing the size right after it was returned:

functions_file.php:

$maxattachsize = $attachtypes["$extension"]['size'];

global $isMember;

if ($isMember)
$maxattachsize = 100 * 1024;


I figured actually resetting the extension variables was more versatile, and did it that way in the 3.5 hook, but clearly wasn't accessing the variable correctly. Thanks for the help.

Shannon