Hi Fabio,
actually, my suggestion (pbötchers code in the thread) does almost what you want I believe - lock data for some usergroup, leave it open for others.
I will try to suggest some workflow, but not knowing your settings it's kind of theoretical.
I am not good at jquery though.
The code
Code: Select all
case 'VIEW':
if ($memberInfo['group'] != 'Admins') {
$footer="<%%FOOTER%%><script>\$j('#Container').attr('readonly','true')</script>";
}
else $footer='';
break;
does make a field readonly except for members of the admin group. So we can modify it to make it readonly for more than one group (use your "staff" group here)
Code: Select all
if ($memberInfo['group'] != 'Admins' && $memberInfo['group'] != 'staff') {
But as you say, the field should only be readonly for all others if it does carry any value already.
Unfortunately there are no field related permissions yet in AG, so we need to check if the field has any value, if yes, we lock it, if not, do nothing.
I suggest you write code (as bbötcher suggested) at the rendering of the page (hook -> _header function). Check if the surname field already contains data (use php and sql, see docs "sqlvalue" function) and set some php variable accordingly. In the _footer function you check for the contents of this variable and lock the data with the code above.
Another way would be to drop new data in your field
In the hooks for that file (tablename) in the _before_update function you might add some code that checks the usergroup of the person: admin, staff do nothing; all others read the old value for surname from your table, if it exists, replace the current value that comes from the form something like $data['surname'] (check the function header comments). As a result, only staff and admin can change the surename, all others can not. Maybe you want to add some additional information for the general user to explain this.
Olaf