CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Hide?show a panel depending on User's security level

Print topic Send  topic

Author Message
ckroon

Posts: 869
Posted: 09/25/2007, 6:28 PM

A database I am working on is growing too big andI need to get rid of the separate control panels for each user level.

I was hoping there is a way to have one control panel page (all the buttons to all the components) and the only ones that show up are the ones that are relevant to your User security level.

table is 'userinfo', field is 'level'

I have experience with hiding/showing panels using this code in the before show event

if (CCGetFromGet("ID",-1) == -1)
$Component->Visible = False;
else
$Component->Visible = True;

But how do I configure it for getting a session variable such as the level?

Thanks!

_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
mamboBROWN


Posts: 1713
Posted: 09/25/2007, 6:58 PM

ckroon
When the user initially logs into the system you could store the level information in a session variable by using the PHP function CCSetSession. Once to get to a specific page you can obtain the variable of the session variable by using the CCGetSession function. Checkout the links below:

http://docs.codecharge.com/studio31/html/Components/Fun...ession.html?toc
http://docs.codecharge.com/studio31/html/Components/Fun...ession.html?toc
http://docs.codecharge.com/studio31/html/ProgrammingTec...nVariables.html
View profile  Send private message
ckroon

Posts: 869
Posted: 09/25/2007, 7:50 PM

Cool!.. ok so I read through them and let me know if I got this right..

On the login form..on the on click event of the Login button I put this code
//
function Login_DoLogin_OnClick(& $sender) {

if ($Login_DoLogin_OnClick == true) {
$db = new clsDBConnection1();
CCSetSession("level", CCDLookUp("level","userinfo","ID=".$db->ToSQL(CCGetUserID(),ccsInteger), $db) );
$db->close();
}

}
//

Is that about right?

(Userinfo table has ID, level as field names)
_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
wkempees


Posts: 1679
Posted: 09/26/2007, 4:02 AM

Not sure if I understand the question right, but have you read
CCGetGroupID()

This will automatically be set upon login and reflects the logged in users level.
No need to change anything in the Login function.
Anyplace you need it a call to CCGetGroupID() will work.

Assuming of course your table setup is correctly defined.

Walter


_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
wkempees


Posts: 1679
Posted: 09/26/2007, 4:04 AM

You would then need to decide how to go about things.
You could have all the buttons carry a level.
Upon presentation you could hide all buttons and unhie only those with a level equal or lower than the CCGetGroupID()

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
ckroon

Posts: 869
Posted: 09/26/2007, 6:22 AM

That sounds like just the thing I need.

I will have 10 panels that contain buttons for 10 different user levels: Teachers, Admins, Lead Teachers, Special ed teachers etc... the list is long.

So I just want to hide/show that panel depending on their user level... I have assigned a different user level to each "group" of users.

So, on the Teachers panel beforeshow event do I add this?:

if (CCGetGroupID() == 1) // 1 is the level for Teachers
$Component->Visible = False;
else
$Component->Visible = True;



_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
datadoit.com
Posted: 09/26/2007, 7:42 AM

You may want to look at the Student Information System at
http://www.miller-group.net/. It's FREE with no support, fees if you
need support. PHP/MySQL-based.

You should be able to modularize it with CodeCharge for custom
components that you need.
wkempees


Posts: 1679
Posted: 09/26/2007, 7:55 AM

Sounds ok to me.
Other option is to set all panels to visible=False
And make a switch construct based on CCGetGroupID().
But yours looks ok to me.

Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
ckroon

Posts: 869
Posted: 09/26/2007, 8:12 AM

Many thanks Data and Walter!!!!

_________________
Walter Kempees...you are dearly missed.
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.