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

Reply
 
Thread Tools Display Modes
  #1  
Old 01-20-2008, 09:41 PM
Alfa1's Avatar
Alfa1 Alfa1 is offline
 
Join Date: Dec 2005
Location: Netherlands
Posts: 3,537
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to restrict usergroups from using certain functionality?

It is possible to restrict viewing of certain (template) functions to member groups of choice, by using this conditional:

<if condition="is_member_of($bbuserinfo,4,5,6,7)">[insert code that you want to restrict]</if>

4,5,6,7 are the user groups and can be replaced for any other user group.

This way you can for instance restrict all members, except those in usergroups 4,5,6 and 7 to see videos on profiles.

However, this way of restricting functions for visitors of the page is often confused with restricting functions for the member the function relates to. i.e. the member who's profile, post is concerned.

If you have a function on profiles or posts that you want to restrict to certain usergroups, then how do you handle that? For example: You want only users within usergroup 11and 12 to be able to show a video on their profile.

What conditional code can you use to accomplish this?
Should MEMBERINFO be modified for this or is there a more backend way of doing this?
Reply With Quote
  #2  
Old 07-31-2008, 08:15 PM
Alfa1's Avatar
Alfa1 Alfa1 is offline
 
Join Date: Dec 2005
Location: Netherlands
Posts: 3,537
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

With a big thanks to Digital Jedi:

<if condition="in_array($post['usergroupid'], array(4,5,6,7))">[insert code that you want to restrict]</if>

Only 4,5,6 and 7 will be able to use the functionality.
Reply With Quote
  #3  
Old 07-31-2008, 09:44 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

the recommened way of doing things is using is_member_of() as it checks additional usergroups and also means that your code won't break if vBulletin change the usergroupid column name (obviously they really wouldn't but it is just an example of how it could break).

I didn't understand what half of your post said though.

$post is used in the postbit(_legacy) template so it won't have any effect in the MEMBERINFO template.

$userinfo or $prepared (3.6/3.7 respectively) are the variables in use in the MEMBERINFO template.

$bbuserinfo is the variable for the user that is currently browsing the page.
Reply With Quote
  #4  
Old 07-31-2008, 10:03 PM
Alfa1's Avatar
Alfa1 Alfa1 is offline
 
Join Date: Dec 2005
Location: Netherlands
Posts: 3,537
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Could you give me examples of how you would restrict a function on postbit and on MEMBERINFO? I am not certain of the syntax when using is_member_of().
Reply With Quote
  #5  
Old 07-31-2008, 10:35 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You've given the correct usage in your first post.
Reply With Quote
  #6  
Old 07-31-2008, 11:07 PM
Alfa1's Avatar
Alfa1 Alfa1 is offline
 
Join Date: Dec 2005
Location: Netherlands
Posts: 3,537
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh wow. I totally looked over that.

What are the variables for memberlist, groups, Blog and forum leaders?
Reply With Quote
  #7  
Old 07-31-2008, 11:13 PM
RLShare RLShare is offline
 
Join Date: Jun 2008
Posts: 499
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Opserty View Post
the recommened way of doing things is using is_member_of() as it checks additional usergroups and also means that your code won't break if vBulletin change the usergroupid column name (obviously they really wouldn't but it is just an example of how it could break).

I didn't understand what half of your post said though.

$post is used in the postbit(_legacy) template so it won't have any effect in the MEMBERINFO template.

$userinfo or $prepared (3.6/3.7 respectively) are the variables in use in the MEMBERINFO template.

$bbuserinfo is the variable for the user that is currently browsing the page.
Doesn't ismemberof() add an extra query for evertime its executed on a page though?
Reply With Quote
  #8  
Old 07-31-2008, 11:21 PM
Alfa1's Avatar
Alfa1 Alfa1 is offline
 
Join Date: Dec 2005
Location: Netherlands
Posts: 3,537
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I dont think so. I checked before and after adding this.
Reply With Quote
  #9  
Old 08-01-2008, 01:57 AM
RLShare RLShare is offline
 
Join Date: Jun 2008
Posts: 499
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Edit:
Oh no Im thinking of the can_moderate function.
Reply With Quote
  #10  
Old 08-06-2008, 02:38 PM
Alfa1's Avatar
Alfa1 Alfa1 is offline
 
Join Date: Dec 2005
Location: Netherlands
Posts: 3,537
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I tried to apply this code to newpost_usernamecode in order to add user group permissions to Anonymous posting
I tried adding the red section:
--------------
<if condition="$show['anonymous'] AND is_member_of($post,4,5,6,7)"><div><input type="checkbox" id="cb_anonymous" class="bginput" name="anonymous" value="1" <if condition="$vbulletin->GPC['anonymous']">checked="checked"</if>/>$vbphrase[zointsanony_anonymous_post]</div></if>
--------------
Do you have any idea?
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 01: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.04483 seconds
  • Memory Usage 2,250KB
  • 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_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete