Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-18-2011, 12:07 PM
EquinoxWorld EquinoxWorld is offline
 
Join Date: Nov 2009
Location: Naples
Posts: 354
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How do you implement varname from new settings in custom php script?

Hello everyone, I have been trying to figure those out on my own for the whole weekend with no avail, I hope someone has some ideas as to what I can do to solve my concern.

I just created my first option for my custom script (first one! ) through debug mode in settings panel in admincp. It's called "Can View Contests" (of new group " Contest Of The Week") and I set the default value to be 6 as the usergroup allowed to view these pages by default. The option also has a varname which I created (oftw_can_view). Aside from the values of the new settings created how I do Implement now this new option into my custom pages? I want to be able to restrict with this option the ability to see these pages of my script to only usergroup 6 (for now by default).?? Please if anyone has any ideas or can shed any light please share. I can control who sees each page by a simple if condition within the php code of each page but I want to be able to control it globally and not have to edit each page every time I want to allow another usergroup.

Best Regards,

Equinox

Hope everyone had a great weekend.
Reply With Quote
  #2  
Old 07-18-2011, 12:18 PM
Disasterpiece's Avatar
Disasterpiece Disasterpiece is offline
 
Join Date: Apr 2007
Location: GER
Posts: 765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

All variables which you defined in the settings are available through
PHP Code:
$vbulletin->options['oftw_can_view'
the code snippet you're looking for is:
PHP Code:
if (!is_member_of($vbulletin->userinfo$vbulletin->options['oftw_can_view'])) {
    
print_no_permission();

If you want to improve your setting so you can define more usergroups separated through commata, use this instead:
PHP Code:
if (!(is_member_of($vbulletin->userinfoexplode(',',$vbulletin->options['oftw_can_view'])))) {
    
print_no_permission();    


Also make sure to position this code after global.php inclusion.
Reply With Quote
  #3  
Old 07-18-2011, 12:33 PM
EquinoxWorld EquinoxWorld is offline
 
Join Date: Nov 2009
Location: Naples
Posts: 354
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you so much for the fast reply Disasterpiece. Works perfect, now I understand so much better how those options work. Opens up a whole world of possibilities.

Just to see if I have it clear. I'll use the first if condition if I only want ot allow one usegroup per the options and the second if it's more that one?

--------------- Added [DATE]1310996257[/DATE] at [TIME]1310996257[/TIME] ---------------

Funny thing I tried to add another usegroup to this option like usergroups allowed: 6, 1 for example and I press save it loads returns to that same page but the value still remains 6 and not 6,1 like I had put?? Any ideas what I could be doing wrong?
Reply With Quote
  #4  
Old 07-18-2011, 01:16 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What did you select for "Data Validation Type"? If you want to be able to enter a comma-separated list you need to select "free".
Reply With Quote
  #5  
Old 07-18-2011, 01:20 PM
EquinoxWorld EquinoxWorld is offline
 
Join Date: Nov 2009
Location: Naples
Posts: 354
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
What did you select for "Data Validation Type"? If you want to be able to enter a comma-separated list you need to select "free".
Integer... ?

Ahhhh perfect now using Free.! Thanks khn99 Now it all works perfectly. Is there any official vb documentation one could use for this sort of issues?
Reply With Quote
  #6  
Old 07-18-2011, 01:52 PM
Disasterpiece's Avatar
Disasterpiece Disasterpiece is offline
 
Join Date: Apr 2007
Location: GER
Posts: 765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

6, 1 could make problems when you don't make the code more foolproof, but when you consistently stick to 1,2,3 instead of 1, 2, 3 then there are no problems
Reply With Quote
  #7  
Old 07-18-2011, 03:01 PM
EquinoxWorld EquinoxWorld is offline
 
Join Date: Nov 2009
Location: Naples
Posts: 354
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Disasterpiece View Post
6, 1 could make problems when you don't make the code more foolproof, but when you consistently stick to 1,2,3 instead of 1, 2, 3 then there are no problems
Good to know. At this point of my skill level I need every "foolproof" tip you can give me. Still learning but I love it though, I carry around a note pad to right down code in case I come up with an idea...Hope to be sharing with the community some of my work soon.
Reply With Quote
Reply


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 08:51 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04706 seconds
  • Memory Usage 2,227KB
  • 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
  • (3)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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