vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   print_no_permission(); Problem (https://vborg.vbsupport.ru/showthread.php?t=163396)

Twilkey 11-22-2007 09:44 PM

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.

King Kovifor 11-22-2007 11:29 PM

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.

Twilkey 11-23-2007 12:10 AM

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.

Opserty 11-23-2007 02:45 PM

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.

Twilkey 11-23-2007 03:33 PM

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.

Opserty 11-23-2007 03:53 PM

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))
    {
    //... 



All times are GMT. The time now is 01:10 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.01099 seconds
  • Memory Usage 1,754KB
  • 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
  • (2)bbcode_code_printable
  • (6)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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