vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   How do you implement varname from new settings in custom php script? (https://vborg.vbsupport.ru/showthread.php?t=267026)

EquinoxWorld 07-18-2011 12:07 PM

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.

Disasterpiece 07-18-2011 12:18 PM

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.

EquinoxWorld 07-18-2011 12:33 PM

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?

kh99 07-18-2011 01:16 PM

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".

EquinoxWorld 07-18-2011 01:20 PM

Quote:

Originally Posted by kh99 (Post 2221946)
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?

Disasterpiece 07-18-2011 01:52 PM

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 :)

EquinoxWorld 07-18-2011 03:01 PM

Quote:

Originally Posted by Disasterpiece (Post 2221965)
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.


All times are GMT. The time now is 12:29 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.00983 seconds
  • Memory Usage 1,735KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete