Rick Page
|
Posted: 12/01/2003, 12:13 PM |
|
Hello fellow programmers,
I am trying to add custom HTML based on if someone is logged in and if this person is an administrator.
In the header, I have images for navigation. One of these images is to the administration page. I don't want this image to show up unless an administrator is logged in. I am using CCS Version 2.2.2.40 with PHP4+templates and PHP globals are turned off.
I placed a Label control called CustomHTML... I am going off on of the examples in the help file. I placed this code in the BeforeShow function for the Label. The problem is that my variable $UserGroup is always empty.
<?php
// //Events @1-F81417CB
//Header_CustomHTML_BeforeShow @7-AEF41E29
function Header_CustomHTML_BeforeShow()
{
$Header_CustomHTML_BeforeShow = true;
//End Header_CustomHTML_BeforeShow
//Custom Code @8-DBA303E4
// -------------------------
global $Header;
// Write your own code here.
$UserGroup = CCGetSession("UserID");
if ($UserGroup > 1)
{
$Header->CustomHTML->SetValue("<a href=Administration.php><img src=images/administration-button.gif border=0></a>");
}
// -------------------------
//End Custom Code
//Close Header_CustomHTML_BeforeShow @7-BBDEE9AE
return $Header_CustomHTML_BeforeShow;
}
//End Close Header_CustomHTML_BeforeShow
?>
Does anybody see something wrong with the above? Do I have to use $HTTP_SESSION_VAR to get what I want?
Thanks,
Rick Page
|
|
|
Rick Page
|
Posted: 12/01/2003, 12:24 PM |
|
Sorry for the typo... I was playing with the other variables.
$UserGroup = CCGetSession("UserID"); should be
$UserGroup = CCGetSession("GroupID");
|
|
|
Rick Page
|
Posted: 12/01/2003, 1:13 PM |
|
Hi all,
This is the "round-about-way" to solve my problem.
CCGetSession really should work the way it's suppose to work.
global $Header;
// Write your own code here.
global $DBmydb;
$UserID = CCGetUserID("user_id", 0);
$UserGroup = CCdlookup("group_id","employees","emp_id=".$UserID,$DBmydb);
if ($UserGroup > 1)
{
$Header->CustomHTML->SetValue("<a href=Administration.php><img src=images/administration-button.gif border=0></a>");
}
Hope this helps someone.
Rick Page
|
|
|
RonB
|
Posted: 12/02/2003, 3:41 PM |
|
$UserGroup = CCGetGroupID();
if ($UserGroup > 1)
{
$Header->CustomHTML->SetValue("<a href=Administration.php><img src=images/administration-button.gif border=0></a>");
}
RonB
|
|
|
|