MarioM1977
Posts: 23
|
| Posted: 09/10/2010, 1:12 AM |
|
Hi,
Any help with this issue is very welcome. CCS3 and PHP project.
Link name: Link5
Href Source: Test.ccp
I would like to hide this link if detected user by $_SERVER['LOGON_USER'] has no "MASTERADMIN" role. All roles I have in SQL table.
Connection name: DB1
Table name: Roles
Table fields: ID, User, RoleName
Example values:
1, AAAA, MASTERADMIN
2, BBBB, LOCALADMIN
3, CCCC, MASTERADMIN
Should I use Event -> Before Show -> Hide-Show Component for this Link5 object? If yes, how to set all parameter in proper way?
Thanks in advance for any help.
Mariusz
|
 |
 |
datadoit
|
| Posted: 09/10/2010, 6:03 AM |
|
1. When you set up your project's security settings, you likely
specified the user table, the user ID field, user login, etc. Those
values can always be referenced in your project via CCGetUserID() and
CCGetUserLogin() functions.
2. For your link control, make sure it's visible property is set to
'Dynamic'.
3. In the link control's BeforeShow event, add an Action and choose
DLookup. For the DLookup properties, set:
Expression: "RoleName"
Domain: "Roles"
Criteria: "User=" . CCToSQL(CCGetUserLogin(), ccsText)
Connection: YourConnection
Convert result to: Text
Type of Target: Variable
Target: RoleName
4. In the link control's BeforeShow event, add another Action and choose
Hide-Show Component. For the Hide-Show Component properties, set:
Component Name: Choose your link control
Action: Hide
Condition Type: Expression
Condition: $RoleName <> "MASTERADMIN"
That's it! No "programming" involved. :)
|
|
|
 |
MarioM1977
Posts: 23
|
| Posted: 09/15/2010, 5:13 AM |
|
I found the mistake in my thinking and now it works very well :)
thanks a lot
|
 |
 |
datadoit
|
| Posted: 09/15/2010, 6:40 AM |
|
In your development and test environments, turn on PHP's display errors,
and/or PHP error logging. That will show you where the error is, as
opposed to just a blank page.
|
|
|
 |
MarioM1977
Posts: 23
|
| Posted: 09/15/2010, 6:52 AM |
|
Quote datadoit:
In your development and test environments, turn on PHP's display errors,
and/or PHP error logging. That will show you where the error is, as
opposed to just a blank page.
I did it exactly as you said. I turned it on.
My problem was I tried to use: "User=" . CCToSQL(CCGetUserLogin(), ccsText)
The correct one and working is: "User=" . CCToSQL($_SERVER['LOGON_USER'], ccsText)
|
 |
 |
datadoit
|
| Posted: 09/15/2010, 8:44 AM |
|
Under the Project Settings -> Security section, you should see where you
set your User ID field, your Login field, and your Group ID field.
Those are what get set into CCGetUserID(), CCGetUserLogin(), and
CCGetGroupID().
Another way to retrieve those session values are also via
CCGetSession("UserID"), CCGetSession("UserLogin"), and
CCGetSession("GroupID").
Recognize that the PHP predefined variable $_SERVER['LOGON_USER'] only
works on the Windows platform. If you must go that route, then for
cross platform compatibility use $_SERVER['PHP_AUTH_USER'] instead.
The strong recommendation, though, is to use the CodeCharge route and
set your Project Settings appropriately in order to harness the full
power and flexibility of the IDE.
|
|
|
 |
MarioM1977
Posts: 23
|
| Posted: 09/15/2010, 9:01 AM |
|
Quote datadoit:Recognize that the PHP predefined variable $_SERVER['LOGON_USER'] only
works on the Windows platform. If you must go that route, then for
cross platform compatibility use $_SERVER['PHP_AUTH_USER'] instead.
Thanks for this info. I will remember about it. PHP is something very new for me. My page will be used only with Windows clients.
|
 |
 |
|