PDA

View Full Version : Condition for usergroups in php files


Yorixz
09-18-2005, 11:06 AM
I'm hoping anyone can provide me with data of what condition I can use inside the bbcode parser (hardcoded) as condition.

Right now the only condition I've found is if ($vbulletin->userinfo['userid'])
{
bla
} Else {
bla
}
but what I want to do is check for the usergroup (and if it's higher than x do "bla")

Thanks for your possible reply ;)

Andreas
09-18-2005, 08:21 PM
Hardcoding = Bad
What exactly do you want to do?

Blaine0002
09-18-2005, 10:32 PM
i think he wants to get the persons usergroup id,
this probably dosent work but whatever, I tried.

if ($vbulletin->userinfo['usergroupid']) > '5'
{
bla
} Else {
bla
}

Yorixz
09-24-2005, 05:55 PM
Hardcoding = Bad
What exactly do you want to do?

What I want to do is create a modification similar to what you see here on vB.org; quotes/codes not visible untill a user is in a "special" usergroup (where he gets moved to when he validated his account in some way). As this can't be done by template edits I think this is the only possible way.

Sorry for the terrible slow reply, been busy this week.

Blaine0002
09-24-2005, 07:06 PM
What I want to do is create a modification similar to what you see here on vB.org; quotes/codes not visible untill a user is in a "special" usergroup (where he gets moved to when he validated his account in some way). As this can't be done by template edits I think this is the only possible way.

Sorry for the terrible slow reply, been busy this week.

you can change the usergroup by changing the 5, this is if the persons usergroup = 5 then they view the correct page. if not, they get an error.

if ($vbulletin->userinfo['usergroupid'] == 5)
{
echo'You are in the right usergroup!'
} Else {
echo'Sorry, you cant view this page!'
}

this is if the user has a larger usergroup id than 5, they view the page

if ($vbulletin->userinfo['usergroupid'] > 5)
{
echo'You are in the right usergroup!'
} Else {
echo'Sorry, you cant view this page!'
}


is this what you wanted?

Yorixz
09-25-2005, 07:31 AM
Yes, thanks a lot for your help; I'll go try it out on my testboard.

you can change the usergroup by changing the 5, this is if the persons usergroup = 5 then they view the correct page. if not, they get an error.

if ($vbulletin->userinfo['usergroupid'] == 5)
{
echo'You are in the right usergroup!'
} Else {
echo'Sorry, you cant view this page!'
}

this is if the user has a larger usergroup id than 5, they view the page

if ($vbulletin->userinfo['usergroupid'] > 5)
{
echo'You are in the right usergroup!'
} Else {
echo'Sorry, you cant view this page!'
}


is this what you wanted?
It's exactly what I want; changed it a little to my needs though; to be exact to this:

function handle_bbcode_code($code)
{
global $vbulletin, $vbphrase, $stylevar, $show;

// remove unnecessary line breaks and escaped quotes
$code = str_replace(array('<br>', '<br />', '\\"'), array('', '', '"'), $code);
$code = $this->strip_front_back_whitespace($code, 1);
if ($vbulletin->userinfo['usergroupid'] > 5) /* also tried == and != etc, plainly to try it out, neither of them did what I wanted */
{
$code = $code;
}
else
{
$code = "You are not allowed to view codes yet";
}

if ($this->printthread)
{
$code = $this->emulate_pre_tag($code);
$template = 'bbcode_code_printthread';
}
else
{
$blockheight = $this->fetch_block_height($code);
$template = 'bbcode_code';
}

eval('$html = "' . fetch_template($template) . '";');
return $html;
}
The only problem that I've got now is; it doesn't work, for some reason it just shows the data, no matter what I try.

Blaine0002
09-25-2005, 12:55 PM
sorry, im not good at php at all, try making the 5 into '5' (dont know if this will help at all.)

Marco van Herwaarden
09-25-2005, 01:02 PM
Do you have post caching turned on in your vB options?

Yorixz
09-25-2005, 02:00 PM
Do you have post caching turned on in your vB options?

Mm, thanks, I did have it enabled - disabling it shows up the message directly, only problem now is; what's the best option. Wont disabling the cache option hammer my mysql database a lot more?
(I'm actually wondering what the way is that the code is added here at vB.org, but I doubt I'll get to know that)

Marco van Herwaarden
09-25-2005, 04:01 PM
Yes disabling would stress your server more.

Boofo
09-25-2005, 04:15 PM
What's a good setting to have that at? It's the Posts Cache Lifespan setting right?

Yorixz
09-25-2005, 04:24 PM
What's a good setting to have that at? It's the Posts Cache Lifespan setting right?

Uh yeah, it's that setting. I wouldn't know what's an optimal setting, on my clean test install it was standard at 7 days...