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

Reply
 
Thread Tools Display Modes
  #1  
Old 06-25-2002, 08:33 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Different Styles for Different Users

I just wanted to take the time to write up a conceptual "how to" allow different users to use different style sets. I am not writing up a specific hack because there is no one size fits all for this customization, and I also don't have time to support newbies right now.

For example, I have 2 premium style sets that do not have banners and that have most of my hacking work installed. Only my premium users can select those styles. In addition, my premium users can select any of the styles available to non-premium members.

1. The first thing to do is to add a column to your users table to indicate the user status. On my board, I have an integer column called "premium" that I set to 1 if the user is a paid member. However, with this system, it is possible to have more than one type of status. For example, you could set the value to 1 for your banner free surfers, 2 for your advanced feature surfers, etc.


2. Next is to set your styles so that they can only be used by the authorized users. Currently, in the database, there are two values for userselect in the styles table: 0 and 1. If the value is 0, the user cannot select it. If the style is 1, all users can select it. The trick is to make this value a higher integer for styles you only want used by certain people. On my board, I set userselect =2 for any styleset that should only be available for premium members. (I do this right within phpmyadmin)

3. Next, you want to tell global.php about your changes.

Look for:

PHP Code:
if ($style=$DB_site->query_first("SELECT templatesetid,replacementsetid,userselect FROM style WHERE styleid='$styleid'")) {
    if (!
$style['userselect']) {
      unset(
$style);
      
$styleid=1;
    }
  } else {
    unset(
$style);
    
$styleid=1;
  } 
This code block checks to see if users are authorized to use a given style. Currently, it just checks to see if the value of userselect is greater than 0. You need to modify it so that only your authorized users can access styles based on the value of userselect. For example:

PHP Code:
if ($style=$DB_site->query_first("SELECT templatesetid,replacementsetid,userselect FROM style WHERE styleid='$styleid'")) {
    if (!(
$style['userselect']) or (($style['userselect']==2) and ($bbuserinfo[premium]!=1))) {
      unset(
$style);
      
$styleid=1;
    }
  } else {
    unset(
$style);
    
$styleid=1;
  } 

4. The final step is to give authorized users access to the styles.
Edit member.php so that:

PHP Code:
$stylesetlist "";
  if (
$allowchangestyles==1) {
    
$stylesets=$DB_site->query("SELECT * FROM style WHERE userselect=1 ORDER BY title");
    if ( !isset(
$bbuserinfo['realstyleid']) ) {
      
$bbuserinfo['realstyleid'] = $bbuserinfo['styleid'];
    }
    while(
$thisset=$DB_site->fetch_array($stylesets)) {
      if (
$bbuserinfo['realstyleid']==$thisset['styleid']) {
        
$selected "selected";
      } else {
        
$selected "";
      }
      
$thisid $thisset['styleid'];
      
$thisstylename $thisset['title'];
      eval (
"\$stylesetlist .= \"".gettemplate("modifyoptions_styleset")."\";");
      eval (
"\$stylecell = \"".gettemplate("modifyoptions_stylecell")."\";");
    }
  } else {
    
$stylecell "";
  } 
is replaced by something like:

PHP Code:
$stylesetlist "";
  if (
$allowchangestyles==and $bbuserinfo[premium]==1) {
    
$stylesets=$DB_site->query("SELECT * FROM style WHERE userselect=1 or userselect=2 ORDER BY title");
    if ( !isset(
$bbuserinfo['realstyleid']) ) {
      
$bbuserinfo['realstyleid'] = $bbuserinfo['styleid'];
    }
    while(
$thisset=$DB_site->fetch_array($stylesets)) {
      if (
$bbuserinfo['realstyleid']==$thisset['styleid']) {
        
$selected "selected";
      } else {
        
$selected "";
      }
      
$thisid $thisset['styleid'];
      
$thisstylename $thisset['title'];
      eval (
"\$stylesetlist .= \"".gettemplate("modifyoptions_styleset")."\";");
      eval (
"\$stylecell = \"".gettemplate("modifyoptions_stylecell")."\";");
    }
  } else {
     if (
$allowchangestyles==1) {
    
$stylesets=$DB_site->query("SELECT * FROM style WHERE userselect=1 ORDER BY title");
    if ( !isset(
$bbuserinfo['realstyleid']) ) {
      
$bbuserinfo['realstyleid'] = $bbuserinfo['styleid'];
    }
    while(
$thisset=$DB_site->fetch_array($stylesets)) {
      if (
$bbuserinfo['realstyleid']==$thisset['styleid']) {
        
$selected "selected";
      } else {
        
$selected "";
      }
      
$thisid $thisset['styleid'];
      
$thisstylename $thisset['title'];
      eval (
"\$stylesetlist .= \"".gettemplate("modifyoptions_styleset")."\";");
      eval (
"\$stylecell = \"".gettemplate("modifyoptions_stylecell")."\";");
    }
  } else {
    
$stylecell "";
  }


Conceptually, that's all there is to it. DO NOT TRY TO CUT AND PASTE the code I just showed you. You will need to work out your own variations based on how you set up your style hierarchy. My premium users have access to all styles. Yours might not.

I hope this helps somebody. I have been running this hack for months now, and it works quite well. My premium members have 3 styles and my default members have 1. Any new hacks go into my premium styles for the most part.

Amy
Reply With Quote
  #2  
Old 06-25-2002, 08:35 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I forgot to note, I use this now instead of the hack that I wrote that allows admins to set a style as the default for a given usergroup. This hack gives my premium members choice instead of limiting them to one style.

Amy
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:52 AM.


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.03649 seconds
  • Memory Usage 2,208KB
  • Queries Executed 13 (?)
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
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)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_postinfo_query
  • fetch_postinfo
  • 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