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 03-14-2006, 11:14 AM
lightnb lightnb is offline
 
Join Date: Dec 2005
Posts: 106
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Checking user group from a non vb page

I have the following code in my footer, which is included on every page:

PHP Code:
<?php

$forumpath 
"http://www.mysite.com/community/forums/";

if (
$vbulletin->userinfo['groupid']=6) {

echo 
"Admin/Mod CP button goes here!";

?>
I want it to check to see if the user is logged into vB and is in the admin usergroup, and if so, to display a button that links to the admin cp.

right now, it is showing the button regardless of log in status. what variable does vB use to store the user's usergroup?


thanks,

nick
Reply With Quote
  #2  
Old 03-17-2006, 10:34 PM
lightnb lightnb is offline
 
Join Date: Dec 2005
Posts: 106
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Bump
Reply With Quote
  #3  
Old 03-17-2006, 11:06 PM
Freesteyelz's Avatar
Freesteyelz Freesteyelz is offline
 
Join Date: Jan 2006
Posts: 1,552
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

With conditionals I use:

Code:
<if condition="is_member_of($bbuserinfo, x)">
Your code here
</if>
Just extract from "is". Where "x" is just replace it with the Usergroup ID. To add more ID's add ", y, z" and so forth.
Reply With Quote
  #4  
Old 03-19-2006, 03:56 PM
lightnb lightnb is offline
 
Join Date: Dec 2005
Posts: 106
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

With:

PHP Code:
<if condition="is_member_of($bbuserinfo, 6)">
My code here
</if> 
I get:

"Parse error: parse error, unexpected '<' in /home/.sites/22/site13/web/livexchange/footer.php on line 66"
Reply With Quote
  #5  
Old 03-25-2006, 02:27 AM
lightnb lightnb is offline
 
Join Date: Dec 2005
Posts: 106
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

bump
Reply With Quote
  #6  
Old 03-25-2006, 05:48 AM
Freesteyelz's Avatar
Freesteyelz Freesteyelz is offline
 
Join Date: Jan 2006
Posts: 1,552
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You'll need to adjust the code to make it work. That was just an example conditional used in vB. I'm not sure exactly what the PHP protocol is but maybe:

Code:
if ($vbulletin->userinfo['usergroupid']=="6") 
{
echo "Admin/Mod CP button goes here!";
}
Reply With Quote
  #7  
Old 03-26-2006, 03:33 AM
lightnb lightnb is offline
 
Join Date: Dec 2005
Posts: 106
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Freesteyelz
You'll need to adjust the code to make it work. That was just an example conditional used in vB. I'm not sure exactly what the PHP protocol is but maybe:

Code:
if ($vbulletin->userinfo['usergroupid']=="6") 
{
echo "Admin/Mod CP button goes here!";
}
That doesn't produce any errors, but it doesn't do anything either...

I think there needs to be some other code before it to tell the script that it is looking for a vB variable...
Reply With Quote
  #8  
Old 03-26-2006, 06:50 PM
Pickalo Pickalo is offline
 
Join Date: Dec 2002
Location: Victoria
Posts: 61
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You need to include the config.php I'd say.
Reply With Quote
  #9  
Old 03-26-2006, 07:51 PM
Cole2026 Cole2026 is offline
 
Join Date: Feb 2004
Location: Pittsburgh, PA
Posts: 224
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No, Config.php just contains server-connect information.

You could do:
PHP Code:
$forumpath "http://www.mysite.com/community/forums";
require_once(
$forumpath '/global.php');

global 
$vbulletin;

if ( 
is_member_of($vbulletin6) )
{
   echo 
"Admin CP and ModCP links go here";
}

unset(
$vbulletin); 
Reply With Quote
  #10  
Old 03-28-2006, 03:16 AM
lightnb lightnb is offline
 
Join Date: Dec 2005
Posts: 106
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Doesn't seem to be working. I tried the code you gave me, but it just causes the page to sit forever, then asks me if i want to run or download the PHP file.

The whole footer is as follows:


HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Xchange Footer</title>
<style type="text/css">
<!--
.style10 {color: #FFFFFF; font-family: Copperplate;}
-->
</style>
<script type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>

<body onload="MM_preloadImages('forums/images/greenleaf/misc/contact_over.gif','http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/privacystatement_over.gif','forums/images/greenleaf/misc/top_over.gif','http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/contact_over.gif','http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/top_over.gif')">
<table width="850" border="0" cellspacing="0" align="center" cellpadding="0">
  <tr height="25">
    <td><img src="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/mainbgbottom.jpg" width="850" height="25" /></td>
  </tr>
  <tr background="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/navbg.gif">
    <td><div align="center">
      <table width="850" border="0" cellspacing="0" cellpadding="0">
        <tr background="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/navbg.gif">
          <td width="258"><div align="left"><img src="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/cp.gif" width="257" height="27" /></div></td>
          <td width="347" background="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/navbg.gif">
		  
		  
<?PHP
$forumpath = "http://www.rahlentertainment.com/livexchange/forums";
require_once($forumpath . '/global.php');

global $vbulletin;

if ( is_member_of($vbulletin, 6) )
{
   echo "Admin CP and ModCP links go here";
}
unset($vbulletin);  
?>

</td>
          <td width="245"><div align="right"><a href="http://www.rahlentertainment.com/livexchange/forums/sendmessage.php4" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('contactus','','http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/contact_over.gif',1)"><img src="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/contact.gif" alt="Contact US" name="contactus" width="71" height="26" border="0" id="contactus" /></a><a href="http://www.rahlentertainment.com/livexchange/privacy.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Privacy','','http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/privacystatement_over.gif',1)"><img src="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/privacystatement.gif" alt="Privacy Statement" name="Privacy" width="130" height="26" border="0" id="Privacy" /></a><a href="#top" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('top','','http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/top_over.gif',1)"><img src="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/top.gif" alt="TOP" name="top" width="43" height="26" border="0" id="top" /></a></div></td>
        </tr>
      </table>
    </div></td>
  </tr>
</table>
</body>
</html>
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 03:22 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.05975 seconds
  • Memory Usage 2,287KB
  • 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
  • (3)bbcode_code
  • (1)bbcode_html
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (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_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