Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Access control list and globeadmin

Questions related to using nuBuilder Forte.
Post Reply
yvesf
Posts: 315
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 87 times
Been thanked: 11 times

Access control list and globeadmin

Unread post by yvesf »

Hello,

I am using now the access control list which works as expected : I have adapted SQL clauses accordingly.
Ex of SQL clause :

Code: Select all

SELECT
 status.*,
    task.*

FROM
    status
        JOIN task ON task.tsk_status = status.status_id
WHERE
  ((task.tsk_assigned_to ='#USER_CODE#'))
When I am connected as globeadmin, I don't see any task because no task has been assigned to globeadmin. How can I desactivate this where clause when I am connected as globeadmin in order to see all data ?
There is maybe another way to implement access control list ? If yes, is there any example of that ?

Many thanks for your help.

Yves
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Access control list and globeadmin

Unread post by kev1n »

Change the WHERE clause to:

Code: Select all

((task.tsk_assigned_to ='#USER_CODE#' OR '#GLOBAL_ACCESS#' = '1'))
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Access control list and globeadmin

Unread post by kev1n »

SQL corrected
nac
Posts: 115
Joined: Tue Dec 12, 2017 11:28 pm
Location: Aberdeen, UK
Has thanked: 9 times
Been thanked: 12 times

Re: Access control list and globeadmin

Unread post by nac »

Yves,

I often use some PHP code in Before Browse (BB) to create the list of records to be displayed. This is done by modifying the WHERE clause. In the example below I have tried to reproduce your scenario, but this could be extended to use any combination of logic to determine the records that any given user can see. This is done by replacing the 'WHERE TRUE' clause with a customised expression.

Code: Select all

$qry = "
		SELECT status.*,  task.*
		FROM status JOIN task ON task.tsk_status = status.status_id
		WHERE TRUE
";

if ('#ACCESS_LEVEL_CODE#' == 'user_level') {   //  use the code for the access level you require
  $qry = str_replace("WHERE TRUE","WHERE (task.tsk_assigned_to  = '#USER_CODE#') ", $qry );
}

nuRunQuery("CREATE TABLE #TABLE_ID# ".$qry);

Then in the Browse source use:

Code: Select all

SELECT * FROM #TABLE_ID# 

I hope this helps.

Neil
Last edited by nac on Tue Nov 01, 2022 6:21 pm, edited 1 time in total.
yvesf
Posts: 315
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 87 times
Been thanked: 11 times

Re: Access control list and globeadmin

Unread post by yvesf »

Thanks Neil, very helpful
Post Reply