Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 02-16-2009, 04:47 PM
Stagehandspace Stagehandspace is offline
 
Join Date: Jun 2008
Posts: 85
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default [How?] Usergroup permissions in a mod/hack?

I'm trying to create a mod with usergroup permissions, I have placed
PHP Code:
$vboptions[xx_xx_group
within a conditional
PHP Code:
<if condition="is_member_of($bbuserinfo,$vboptions[xx_xx_group])">
CONTENT
<else />
OTHER CONTENT
</if> 
as a replacement for:
PHP Code:
<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
PHP Code:
<if condition="in_array($bbuserinfo[usergroupid],array(6,15))"
PHP Code:
<if condition="is_member_of($bbuserinfo,array(6,15))"
and none seem to work.

Please help me!!
Reply With Quote
  #2  
Old 02-17-2009, 04:48 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

My guess is that your option is a comma-separated list. Say you entered "1,2,3" into that option, you would expect this:
PHP Code:
is_member_of($bbuserinfo1,2,3
But instead, what PHP sees is this:
PHP Code:
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.
Reply With Quote
  #3  
Old 02-17-2009, 02:38 PM
bananalive bananalive is offline
 
Join Date: Oct 2007
Location: UK
Posts: 2,802
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<a href="https://vborg.vbsupport.ru/showthread.php?t=78823" target="_blank"> [How-To]Using Array conditionals with $vboptions </a>
Reply With Quote
  #4  
Old 02-17-2009, 06:16 PM
Stagehandspace Stagehandspace is offline
 
Join Date: Jun 2008
Posts: 85
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?.......
Reply With Quote
  #5  
Old 02-17-2009, 06:21 PM
bananalive bananalive is offline
 
Join Date: Oct 2007
Location: UK
Posts: 2,802
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

in template
HTML Code:
<if condition="is_member_of($bbuserinfo, explode(",", $vboptions[xx_xx_group]))">
CONTENT
<else />
OTHER CONTENT
</if>
in php file
PHP Code:
$vboptions[xx_xx_group] = explode(","$vboptions[xx_xx_group]);
if (
is_member_of($vbulletin->userinfo$vboptions[xx_xx_group])
{
//some php code here

Reply With Quote
  #6  
Old 02-18-2009, 06:01 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

IIRC, explode() is not an allowed function, therefore, you must do that in a plugin.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:20 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08284 seconds
  • Memory Usage 2,216KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_html
  • (8)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete