How? Make one field read-only for usergroup
How? Make one field read-only for usergroup
Hi,
I want to avoid that a regular user (not admin) can edit a certain field in a record (but the user must be allowed to edit other fields of the record).
How can I accomplish that?
Searching the forum for read only did not help me.
Olaf
I want to avoid that a regular user (not admin) can edit a certain field in a record (but the user must be allowed to edit other fields of the record).
How can I accomplish that?
Searching the forum for read only did not help me.
Olaf
Some postings I was involved, you might find useful:
Multi Path Upload (MPU) / dynamic upload folder; SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button
Multi Path Upload (MPU) / dynamic upload folder; SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button
Re: How? Make one field read-only for usergroup
Hi,
you would need to provide a little bit more information about your setting. There are a lot of posts about making a field read-only and it depends on the field you have. Is it a look_up field, text field, .... ?
Do you need to make it read-only when the record is already created, or only when it is updated?
you would need to provide a little bit more information about your setting. There are a lot of posts about making a field read-only and it depends on the field you have. Is it a look_up field, text field, .... ?
Do you need to make it read-only when the record is already created, or only when it is updated?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: How? Make one field read-only for usergroup
Hi pbötcher,
in the table are 3 fields at this time:
ID, Container, Place.
Of course, the admin (of super admin) should be able to edit the column container and place (ID is PK,autoincrement).
The regular user should not be able to edit the column Container, but only change the column Place of the entity Container.
I am not sure how to do this, as the regular user also needs the ability to edit the record (but only place).
Probably it would be useful, if the admin (super admin) can also add new records (meaning new Container and setting some Place). This I can do using the regular user-/group-setup permissions I think.
Olaf
in the table are 3 fields at this time:
ID, Container, Place.
Of course, the admin (of super admin) should be able to edit the column container and place (ID is PK,autoincrement).
The regular user should not be able to edit the column Container, but only change the column Place of the entity Container.
I am not sure how to do this, as the regular user also needs the ability to edit the record (but only place).
Probably it would be useful, if the admin (super admin) can also add new records (meaning new Container and setting some Place). This I can do using the regular user-/group-setup permissions I think.
Olaf
Some postings I was involved, you might find useful:
Multi Path Upload (MPU) / dynamic upload folder; SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button
Multi Path Upload (MPU) / dynamic upload folder; SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button
Re: How? Make one field read-only for usergroup
Hi,
in the hooks/TABLENAME.php file you have a function TABLENAME_footer.
in the case section "detailview" or "tableview+detailview" depending on what you use put
TABLENAME is your TABLE and VIEW is either detailview or tableview+detailview
in the hooks/TABLENAME.php file you have a function TABLENAME_footer.
in the case section "detailview" or "tableview+detailview" depending on what you use put
Code: Select all
case 'VIEW':
if ($memberInfo['group'] != 'Admins') {
$footer="<%%FOOTER%%><script>\$j('#Container').attr('readonly','true')</script>";
}
else $footer='';
break;
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: How? Make one field read-only for usergroup
Hi pbötcher,
thank you a lot. I will try that. ... No, it did not work. Same for super admin and user of a different group.
I added/replaced to function tbl_Contain_footer
Olaf
thank you a lot. I will try that. ... No, it did not work. Same for super admin and user of a different group.
I added/replaced to function tbl_Contain_footer
Code: Select all
case 'detailview':
//$footer='';
if ($memberInfo['group'] != 'Admins') {
$footer="<%%FOOTER%%><script>\$j('#Container').attr('readonly','true')</script>";
}
else $footer='';
break;
case 'tableview+detailview':
//$footer='';
if ($memberInfo['group'] != 'Admins') {
$footer="<%%FOOTER%%><script>\$j('#Container').attr('readonly','true')</script>";
}
else $footer='';
break;
Some postings I was involved, you might find useful:
Multi Path Upload (MPU) / dynamic upload folder; SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button
Multi Path Upload (MPU) / dynamic upload folder; SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button
Re: How? Make one field read-only for usergroup
Hi, can you run the $j('#Container').attr('readonly','true') in the debug mode to see if it works.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: How? Make one field read-only for usergroup
Hi,
yes, that works fine.
(I did change the ID to ContainerCode to match the fields)
$j('#ContainerCode').attr('readonly','true')
Of course, I changed that in your original suggestion as well.
Olaf
yes, that works fine.
(I did change the ID to ContainerCode to match the fields)
$j('#ContainerCode').attr('readonly','true')
Of course, I changed that in your original suggestion as well.
Olaf
Some postings I was involved, you might find useful:
Multi Path Upload (MPU) / dynamic upload folder; SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button
Multi Path Upload (MPU) / dynamic upload folder; SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button
Re: How? Make one field read-only for usergroup
ok, so is it working now? in the code you posted you had #Container
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: How? Make one field read-only for usergroup
Hi,
no, it's not working with this code (but when I enter your line in the console the field get's deactivated). I am posting the full function to make sure, I am in the correct place in the file.
Olaf
no, it's not working with this code (but when I enter your line in the console the field get's deactivated). I am posting the full function to make sure, I am in the correct place in the file.
Code: Select all
function tbl_Container_footer($contentType, $memberInfo, &$args){
$footer='';
switch($contentType){
case 'tableview':
//$footer='';
if ($memberInfo['group'] != 'Admins') {
$footer="<%%FOOTER%%><script>\$j('#ContainerCode').attr('readonly','true')</script>";
}
else $footer='';
break;
case 'detailview':
//$footer='';
if ($memberInfo['group'] != 'Admins') {
$footer="<%%FOOTER%%><script>\$j('#ContainerCode').attr('readonly','true')</script>";
}
else $footer='';
break;
case 'tableview+detailview':
//$footer='';
if ($memberInfo['group'] != 'Admins') {
$footer="<%%FOOTER%%><script>\$j('#ContainerCode').attr('readonly','true')</script>";
}
else $footer='';
break;
case 'print-tableview':
$footer='';
break;
case 'print-detailview':
$footer='';
break;
case 'filters':
$footer='';
break;
}
return $footer;
}
Some postings I was involved, you might find useful:
Multi Path Upload (MPU) / dynamic upload folder; SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button
Multi Path Upload (MPU) / dynamic upload folder; SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button
Re: How? Make one field read-only for usergroup
Hi
oh, I tested on Vivaldi (chromium) and Edge. Same result.
Olaf
oh, I tested on Vivaldi (chromium) and Edge. Same result.
Olaf
Some postings I was involved, you might find useful:
Multi Path Upload (MPU) / dynamic upload folder; SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button
Multi Path Upload (MPU) / dynamic upload folder; SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button
Re: How? Make one field read-only for usergroup
Hi,
I added
Diese Ausgabe erscheint aber nicht im generierten HTML Code der Seite.
Kann es sein, dass der (Hook) Code gar nicht ausgeführt wird? Wie kann ich das prüfen?
Olaf
I added
Code: Select all
$footer='<!--TEST: '.$memberInfo['group'].' -->"
Kann es sein, dass der (Hook) Code gar nicht ausgeführt wird? Wie kann ich das prüfen?
Olaf
Some postings I was involved, you might find useful:
Multi Path Upload (MPU) / dynamic upload folder; SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button
Multi Path Upload (MPU) / dynamic upload folder; SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button
Re: How? Make one field read-only for usergroup
Hi,
problem SOLVED.
a) the suggestion from pbötcher ( viewtopic.php?f=2&t=3036&p=10110#p10093 ) works fine. Thank you.
b) In the hooks folder there was a file tbl_container ... I renamed the table and I simply added his suggestion to the wrong hooks-file. My fault.
Olaf
problem SOLVED.
a) the suggestion from pbötcher ( viewtopic.php?f=2&t=3036&p=10110#p10093 ) works fine. Thank you.
b) In the hooks folder there was a file tbl_container ... I renamed the table and I simply added his suggestion to the wrong hooks-file. My fault.
Olaf
Some postings I was involved, you might find useful:
Multi Path Upload (MPU) / dynamic upload folder; SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button
Multi Path Upload (MPU) / dynamic upload folder; SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button
- aarlauskas
- Veteran Member
- Posts: 127
- Joined: 2019-04-28 18:03
- Location: Medway, UK
Re: How? Make one field read-only for usergroup
Hi, how do you add additional fields to be read only in detail view? Also this seems to be only working for Text type of field. Anyway to deactivate lookup fields? Thanks
Re: How? Make one field read-only for usergroup
Hi,
I am not clear on what you are asking.
Are the additional fields added to the table?
I would look at the tablename_dv hook. There, you can add criteria if the field is readonly for some and not others. If the field is readonly for all users, then another option is to put it in tablename-dv.js file. In either case, this approach requires JQuery coding. The JQuery code is something link
$j('#fieldname').attr('readonly',true);
Hope that helps. Good luck.
~Paul
I am not clear on what you are asking.
Are the additional fields added to the table?
I would look at the tablename_dv hook. There, you can add criteria if the field is readonly for some and not others. If the field is readonly for all users, then another option is to put it in tablename-dv.js file. In either case, this approach requires JQuery coding. The JQuery code is something link
$j('#fieldname').attr('readonly',true);
Hope that helps. Good luck.
~Paul
Re: How? Make one field read-only for usergroup
Hi Arni,
for a lookup you need either to wait for the element to be created, which happens after the page is loaded.
An alternativ solution could be that you create a special template file for this case and use the _init hook to point in the needed case to that template.
for a lookup you need either to wait for the element to be created, which happens after the page is loaded.
An alternativ solution could be that you create a special template file for this case and use the _init hook to point in the needed case to that template.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
- aarlauskas
- Veteran Member
- Posts: 127
- Joined: 2019-04-28 18:03
- Location: Medway, UK
Re: How? Make one field read-only for usergroup
Hi and thanks for the tips. The original Pascal's solution is good enough for what I need right now, all I want to know is how to lock two or three fields in detail view. The below code locks field 'Container'. If I want to lock 2x fields, 'Container' and 'Ship' for example, how to add 'ship' to this code? Tried some combinations but no luck
Code: Select all
$footer="<%%FOOTER%%><script>\$j('#Container').attr('readonly','true')</script>";
Re: How? Make one field read-only for usergroup
Hi Arni,
just add the additional field with a comma sepatation.
e.g. $j('#Container, #FIELD2, #FIELD3').attr('readonly','true')
just add the additional field with a comma sepatation.
e.g. $j('#Container, #FIELD2, #FIELD3').attr('readonly','true')
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
- aarlauskas
- Veteran Member
- Posts: 127
- Joined: 2019-04-28 18:03
- Location: Medway, UK
Re: How? Make one field read-only for usergroup
Brilliant! Thanks Pascal
Re: How? Make one field read-only for usergroup
Hi,
If data security is not important, you can hide or define fields read only with just CSS. You can add a usergroup where these rules should apply. Consider, that the hidden information is still accessible in the html source code. So it's not a column based security feature but a useful usability hack. See this howto to implement it in Appgini: https://forums.appgini.com/phpbb/viewto ... f=7&t=5416
If data security is not important, you can hide or define fields read only with just CSS. You can add a usergroup where these rules should apply. Consider, that the hidden information is still accessible in the html source code. So it's not a column based security feature but a useful usability hack. See this howto to implement it in Appgini: https://forums.appgini.com/phpbb/viewto ... f=7&t=5416