PDA

View Full Version : [How?] Usergroup permissions in a mod/hack?


Stagehandspace
02-16-2009, 04:47 PM
I'm trying to create a mod with usergroup permissions, I have placed
$vboptions[xx_xx_group]
within a conditional
<if condition="is_member_of($bbuserinfo,$vboptions[xx_xx_group])">
CONTENT
<else />
OTHER CONTENT
</if>
as a replacement for:
<if condition="is_member_of($bbuserinfo, 1,2,3) "> so to allow options in admincp but it only seems to work if only 1 group is selected otherwise the "else" content is shown.

I've searched high and low and have found different variations of this with and without arrays
<if condition="in_array($bbuserinfo[usergroupid],array(6,15))">
<if condition="is_member_of($bbuserinfo,array(6,15))">

and none seem to work.

Please help me!!

Dismounted
02-17-2009, 04:48 AM
My guess is that your option is a comma-separated list. Say you entered "1,2,3" into that option, you would expect this:
is_member_of($bbuserinfo, 1,2,3)
But instead, what PHP sees is this:
is_member_of($bbuserinfo, '1,2,3')
See the difference? What you need to do is convert the option into an array using explode() first.

bananalive
02-17-2009, 02:38 PM
<a href="https://vborg.vbsupport.ru/showthread.php?t=78823" target="_blank"> [How-To]Using Array conditionals with $vboptions </a>

Stagehandspace
02-17-2009, 06:16 PM
both are valid answers but I do not know php that well so would someone please explain abit more in detail as the code in top post is within a template and so php cannot be placed there.

How can I convert it or how can I wrap the template in php and still have it work, will I need to replace the template with a plugin instead or what and if so how?.......

bananalive
02-17-2009, 06:21 PM
in template
<if condition="is_member_of($bbuserinfo, explode(",", $vboptions[xx_xx_group]))">
CONTENT
<else />
OTHER CONTENT
</if>
in php file
$vboptions[xx_xx_group] = explode(",", $vboptions[xx_xx_group]);
if (is_member_of($vbulletin->userinfo, $vboptions[xx_xx_group])
{
//some php code here
}

Dismounted
02-18-2009, 06:01 AM
IIRC, explode() is not an allowed function, therefore, you must do that in a plugin.