Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Does nuBuilder have "field level access restrictions feature"? Topic is solved
Does nuBuilder have "field level access restrictions feature"?
Hi,
I have been studying nubuilder for a few days now and cant seem to find this feature:
I want to not only restrict access to the entire table to a certain user but also want to restrict access to a certain field within that table aswell.
For example, lets say you have a law firm and each employee can log in and submit documents enter data etc (on a table) but then the management (not me as a super admin/user but another user higher than employee) is the only one that has access to a certain field in that table and the employees can "read only" that field but the management can change that field to example "will receive promotion this month" as an example.
I hope this feature is already in nubuilder and if not what will be the easiest way for me to implement this with or without code (hopefully the most secure way)
Any help and guidance is much appreciated
Kind Regards,
Richard
I have been studying nubuilder for a few days now and cant seem to find this feature:
I want to not only restrict access to the entire table to a certain user but also want to restrict access to a certain field within that table aswell.
For example, lets say you have a law firm and each employee can log in and submit documents enter data etc (on a table) but then the management (not me as a super admin/user but another user higher than employee) is the only one that has access to a certain field in that table and the employees can "read only" that field but the management can change that field to example "will receive promotion this month" as an example.
I hope this feature is already in nubuilder and if not what will be the easiest way for me to implement this with or without code (hopefully the most secure way)
Any help and guidance is much appreciated
Kind Regards,
Richard
Last edited by rich3art on Wed Oct 19, 2022 1:54 pm, edited 1 time in total.
-
- nuBuilder Team
- Posts: 4297
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Does nuBuilder have "field level access restrictions feature"?
Hi,
Can this topic be moved to the general forum or is it somehow related to reports?
Can this topic be moved to the general forum or is it somehow related to reports?
Re: Does nuBuilder have "field level access restrictions feature"?
Hi Kevin, sure yes it can be moved sorry
-
- nuBuilder Team
- Posts: 4297
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Does nuBuilder have "field level access restrictions feature"?
Access can be restricted on the client side (with JavaScript), but this is not secure and can be easily bypassed.
That is why I recommend using PHP to make sure that the specific field has not been changed by an unauthorised person. I can provide an example if you wish.
That is why I recommend using PHP to make sure that the specific field has not been changed by an unauthorised person. I can provide an example if you wish.
Re: Does nuBuilder have "field level access restrictions feature"?
Yes please I would love an example and how and where to I then add the PHP to prevent this access per field?
-
- nuBuilder Team
- Posts: 4297
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Does nuBuilder have "field level access restrictions feature"?
I've prepared an example:
In the form's Custom Code, disable the field in question (in this example my_field) with JavaScript:
In the BS (Before Save) PHP event, check if the value of the field in question has been modified by an unauthorised person/Access Level.
In the form's Custom Code, disable the field in question (in this example my_field) with JavaScript:
Code: Select all
// If the Access Level Code does not equal to "Management", disable "my_field":
if (nuAccessLevelCode() != 'Management') {
nuDisable('my_field');
}
In the BS (Before Save) PHP event, check if the value of the field in question has been modified by an unauthorised person/Access Level.
Code: Select all
// The function dbGetValue() retrieves the original value from the table, before the record is saved
function dbGetValue($tableName, $primaryKey, $recordId, $columnName) {
$select = "SELECT `$columnName` FROM `$tableName` WHERE `$primaryKey` = ?";
$result = nuRunQuery($select, array($recordId));
$arr = db_fetch_array($result);
return $arr[$columnName];
}
// Replace my_table with your table name, my_table_primary_key with your table's primary key and my_field with your object id.
$orgValue = dbGetValue('my_table', 'my_table_primary_key', '#RECORD_ID#', 'my_field');
$newValue ='#my_field#';
// Compare the original value with the new value and disallow saving, if the field has been changed/manipulated by an Access Level code other than "Management".
if ($orgValue != '#my_field#' && '#ACCESS_LEVEL_CODE#' !== 'Management') {
nuDisplayError('It is not permitted to modify the field xyz...');
}
Re: Does nuBuilder have "field level access restrictions feature"?
Wow awesome thanks Kevin, Im going to give it a try and Il update you if I have any further question.
-
- nuBuilder Team
- Posts: 4297
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Does nuBuilder have "field level access restrictions feature"?
Small correction: It' the BS (Before Save) event, not BE of course.
Re: Does nuBuilder have "field level access restrictions feature"?
Oky I understand, but with that said can I not make it in the BE event so it will even prevent it from being edited?
-
- nuBuilder Team
- Posts: 4297
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Does nuBuilder have "field level access restrictions feature"?
Well you could but as I mentioned this can be easily bypassed if you know how.