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 11-22-2007, 09:44 PM
Twilkey's Avatar
Twilkey Twilkey is offline
 
Join Date: Oct 2006
Posts: 314
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default print_no_permission(); Problem

I am making a mod and my mod is loaded in iframes. The code for the frames is in a template and the template is called by my php file. I have everything working except rather then the No Permission page loading in the frames, I want the frames to just not load. I need the frames to not load when the mod is not activated or if the member is not in the right usergroup. All I need is the code or atleast a nudge in the right direction for the else statement.

As I said I have the code that will display the mod, now i just need the else code that will keep the frames template from loading so that not even the permissions page shows.

If my code is needed to be seen then just say and I will post the part that is catching me.
Reply With Quote
  #2  
Old 11-22-2007, 11:29 PM
King Kovifor's Avatar
King Kovifor King Kovifor is offline
 
Join Date: Nov 2004
Location: PA
Posts: 3,872
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Wrap it in a conditional. Something like:

$array = array(1,2,3,4,5,6);

if(is_member_of($array))
{
display_code_here();
}

That way, if they do not succed in the conditional, the server will not run the display code.
Reply With Quote
  #3  
Old 11-23-2007, 12:10 AM
Twilkey's Avatar
Twilkey Twilkey is offline
 
Join Date: Oct 2006
Posts: 314
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok I am not sure how that would work. I have the code to check if the member is in the right group. I have it set up so that if the mod is active then it checks if the member is in the right group. now in the else is where I need to not display the frame.
Reply With Quote
  #4  
Old 11-23-2007, 02:45 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You don't need to write an else clause, if the conditional does not match then it simply won't execute the code between the braces.

PHP Code:
if(is_member_of($vbulletin->userinfo245))
{
    
// Fetch our template
    // Display our template...
}
//If users are NOT in usergroup 2, 4, 5 then they get a blank page... 
I think maybe you are over complicating matters? It's not exactly clear what you are trying to achieve.
Reply With Quote
  #5  
Old 11-23-2007, 03:33 PM
Twilkey's Avatar
Twilkey Twilkey is offline
 
Join Date: Oct 2006
Posts: 314
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is the code I have.
PHP Code:
    $usergroupid $vbulletin->userinfo['usergroupid'];
    
$query "SELECT * FROM imagewtf_settings WHERE settingname='uploaderactive'";
    
$settings $db->query_read($query);
    
$setting $db->fetch_array($settings);
    
$set $setting['switch1'];

    if(
$set == 1)
    {
// Permissions Check 
        
$usergroupid $vbulletin->userinfo['usergroupid'];
        
$query "SELECT * FROM imagewtf_settings WHERE settingname='allowedusergroups'";
        
$settings $db->query_read($query);
        
$setting $db->fetch_array($settings);
        
$set $setting['switch2'];
    
        
$allowedug explode(","$set);
        if(
in_array $usergroupid$allowedug ))
        {
            eval(
'print_output("' fetch_template('imagewtf_frame') . '");');
        }
// End Permissions Check 
    
}
    else{
         
print_no_permission();
    } 
I need to replace
PHP Code:
    else{
         
print_no_permission();
    } 
with the code that will get rid of the frames if the mod is not enabled or if it is and the member is just not in the required group.
Reply With Quote
  #6  
Old 11-23-2007, 03:53 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Make a new template? Like imagewtf_noframes and then check if they have frames or something?

I think you may be going about it the wrong way. Heres the way I would have done it.

PHP Code:
// START OF MAIN SCRIPT

$db->query(// Query for settings
if($uploadactive == true// Or however you plan on checking it
{
    if(...) 
// Check if in correct usergroup
        
{
            eval(
'$innertemp = "'fetch_template('imagewtf_frame') .'";');
    }
}

// NOW WE CALL THE SHELL TEMPLATE

eval('print_output("'fetch_template('imagewtf_shell') .'");'); 
Example template imagewtf_frame:
Code:
    We have our content here
Example template imagewtf_shell:
Code:
<html>
<head....

...body>

We have our standard content here, which is displayed regardless of usergroup or if modification is active

$innerhtml
</body>
</html>
Notice the $innerhtml variable, now if the modification is not active or the user is not in the required usergroup then $innerhtml will be empty and therefore will not appear. I don't see why you need to use frames unless you are trying to achieve something else.

Also some general pointers.
  1. You can store settings in vBulletin Options (Enter debug mode then navigate to your options). If you add them to vBulletin options then you can access by using $vbulletin->options['....'] instead of performing a number of queries just to obtain settings for your modification.
  2. If you are querying for just a single piece of data from MySQL use the $db->query_first(...) database function, it will reduce the lines of code you need significantly. For example:
    PHP Code:
    $settings $db->query_first("SELECT * FROM imagewtf_settings WHERE settingname='allowedusergroups' LIMIT 1");
    // No need for this line: $settings = $db->query_read($query);
    // No need for this line: $setting = $db->fetch_array($settings);
    $set $setting['switch2']; 
  3. Use the is_member_of($userinfo, $usergroups); function as this checks both primary and secondary usergroups.
    PHP Code:
    // $allowedug = explode(",", $set);
    // if(in_array ( $usergroupid, $allowedug ))
    // ------------- NOW BECOMES ---------------

    $allowedug exmplode(','$set);
    if(
    is_member_of($vbulletin->userinfo$allowedug))
    {
    //... 
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 12:08 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.03995 seconds
  • Memory Usage 2,239KB
  • 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
  • (2)bbcode_code
  • (6)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