PDA

View Full Version : setting $vbulletin->options


squishi
21 Dec 2009, 21:11
I found that I can no longer upload images to any of my vbulletin albums.
The link to upload pictures has disappeared.

In a plugin that I am developing, I set
$vbulletin->options['album_maxpicsperalbum'] = 30;

This won't save the option, no?
If so, how do I reset it again and make the upload link show again?

Lynne
21 Dec 2009, 23:21
Save the original value before setting it in your plugin and then set it back to the original value at the end of your plugin.

squishi
22 Dec 2009, 11:25
Hmm, picture upload is working again. I guess I must have hit the album limit with the debugging that I did for my album addon.

Thank you for the suggestion, Lynne. That is a good idea. :up:

--------------- Added 1261486047 at 1261486047 ---------------

It doesn't seem to work.

Here is my problem:

I am programming an album addon. This special album should disregard the album limitations (size, # of album pics, # of total album pics).

I have set the maxpicsperalbum to 25 for my admin account.
I'm at 24 total pictures and receive the error message "This picture exceeds your total album picture quota by 7". I cannot explain the "7". Also, I do not have this error message in my code. So it must be in one of the classes that I use for album image uploading.
Uploads work fine if I increase the album picture limitations.

class_upload.php contains this:
if ($this->userinfo['permissions']['albummaxpics'])
{
$overage = fetch_count_overage($this->userinfo['userid'], $this->userinfo['permissions']['albummaxpics'], 1);
if ($overage > 0)
{
$this->set_error('upload_total_album_pics_countfull', vb_number_format($overage));
return false;
}
}
This is the error message that is triggered in my case.

So I set these variables before the upload part of my script:
//disregard any restrictions!
$userinfo['permissions']['albummaxsize'] = 99999;
$userinfo['permissions']['albummaxpics'] = 99999;
$albuminfo['moderation'] = 0;
$vbulletin->options['album_maxpicsperalbum'] = 30;


I've tried all kinds of combinations to not make vbulletin check the album limits.
For example:
$userinfo['permissions']['albummaxsize'] = false;
$userinfo['permissions']['albummaxsize'] = "";

It still jumps into the if clause and throws the error message.

What could be the problem?
Is it object related? Do I need to set these variables in a different way?

--------------- Added 1261493810 at 1261493810 ---------------

Instead of
$userinfo['permissions']['albummaxsize'] = false;
I just tried
$vbulletin->$userinfo['permissions']['albummaxsize'] = false;
with no luck...

Lynne
22 Dec 2009, 16:47
Did you pick a hook location that is valid for what you want to do? (Make sure you are setting the permissions after the permissions have been grabbed - if you set them before the vb code has gotten them, then the vb code will write over what you have done.) Did you look at the code around the hook to see what format the variables are in?

squishi
22 Dec 2009, 18:52
It's all in my own php file.
I set the permissions before the upload part of the script.
The script uses the vB_DataManager to create albums and upload images.

But again, it's a good idea. I will move the definition of the settings below the inclusion of the upload class.

--------------- Added 1261508611 at 1261508611 ---------------

Oh, and I'm sorry, I accidentally posted this into the vb4 forum, while I am using vb 3.8.4.

--------------- Added 1261508773 at 1261508773 ---------------

Hmm, moving the definition of the settings below class_upload.php did not help...

--------------- Added 1261508937 at 1261508937 ---------------

class_upload.php is the only file that contains the error message that I am receiving.

if ($this->userinfo['permissions']['albummaxpics'])
{
$overage = fetch_count_overage($this->userinfo['userid'], $this->userinfo['permissions']['albummaxpics'], 1);
if ($overage > 0)
{
$this->set_error('upload_total_album_pics_countfull', vb_number_format($overage));
return false;
}
}

I need to find a way not to trigger that error when the above code is executed in class_upload.php.

--------------- Added 1261584982 at 1261584982 ---------------

I found the problem.
I had to set the restrictions like this:

$upload->userinfo['permissions']['albummaxsize'] = 0;
$upload->userinfo['permissions']['albummaxpics'] = 0;