ckroon
Posts: 869
|
Posted: 10/28/2007, 11:12 AM |
|
Snaps to Walter Kempees for showing me how to do this neat little bit of coding using a CASE statement.
I am developing a website that has areas for 10 different security levels, each with their own areas of access.
Instead of each of them having their own login-landing pages I wanted to create one login-landing page where the buttons that appear, (control panel), are the ones only for their security level.
Make your panels, set visibility to off and then put the following code in the BeforeShow event of the Page.
You can have several panels show up for a security level, or just one specific one. Totally customizable and scalable.
//start code
switch ( CCGetGroupID()) {
case 0: //userlevel = 0
$Component->Panelname1->Visible = True;
break;
case 1: //userlevel =1
$Component->Panelname1->Visible = True;
$Component->Panelname2->Visible = True;
break;
case 2: // userlevel 2 more rights, assumed
$Component->Panelname1->Visible = True;
$Component->Panelname2->Visible = True;
$Component->Panelname3->Visible = True;
break;
case 9: // even higher level
$Component->Panelname1->Visible = True;
$Component->Panelname2->Visible = True;
$Component->Panelname3->Visible = True;
$Component->Panelname4->Visible = True;
$Component->Panelname5->Visible = True;
$Component->Panelname6->Visible = True;
$Component->Panelname7->Visible = True;
$Component->Panelname8->Visible = True;
break;
}
//This is just a sample.
Notice the “break” it should be the last statement in each case construct.
Remember: All panels need to be visible False by default.
_________________
Walter Kempees...you are dearly missed. |
|
|
wkempees
|
Posted: 10/29/2007, 9:46 AM |
|
default : // all other (non captured) levels
$Component->Panelname1->Visible = True;
$Component->Panelname2->Visible = True;
$Component->Panelname3->Visible = True;
$Component->Panelname4->Visible = True;
$Component->Panelname5->Visible = True;
$Component->Panelname6->Visible = True;
$Component->Panelname7->Visible = True;
$Component->Panelname8->Visible = True;
could be added just before the closing }
to execute for all not captured vaues
|
|
|
|