Okay so this one is a bit two-fold, but I have one piece in place. The goal is - based on a value of a cell (locked_c) we want to have the rest of the fields be set to read only, unless you’re in admin or a specific group (CanEdit). The second piece I’ve tested on it’s own and it works, but adding in the logic to try to change a variable ($readonly) based on the value of the locked_c (checkbox) value seems to not work… Or maybe it’s just not being implemented correctly since it seems to work on the first pass but no subsequent. Essentially we will have a task that sets specific records to locked at a set time. If you are not admin or within the CanEdit group, the fields should be read only.
Within the editviewdefs.php (override in custom/modulename, etc) I have the following code.
Essentially I have a $readonly variable that is declared as an empty string, the $lockedBean variable which I believe is the issue and is either not getting the value of that field or not flushing it and reinstating it when I change records.
This all goes into the logic that works that says if you are admin or in CanEdit, then readonly stays as ‘’, all wrapped in the check on the value. So if the value is locked AND you should be able to edit, the $readonly var stays as ‘’. If the record is locked AND you should NOT be able to edit, the $readonly is set to ‘readonly’. The below fields that would be locked have ‘type’=$readonly.
I have read through some documentation and can’t figure out how to get the specific bean that is in state to pull the locked_c value, without knowing the bean ID at least… I am pretty sure this logic here is my fail point.
$checkLocked=0;
$readonly='';
$Lockedbean = $bean.locked_c.value;
if($Lockedbean == 1)
{
$checkLocked=1;
$readonly='readonly';
}
else
{
$checkLocked=0;
$readonly='';
}
require_once 'modules/ACLRoles/ACLRole.php';
$objACLRole = new ACLRole();
$roles = $objACLRole->getUserRoles($GLOBALS['current_user']->id);
$readonly;
if($checkLocked=1)
{
//check if they are in the Admin or Admin Manager's role
if(in_array('Admin',$roles) || in_array('CanEdit',$roles)){
$readonly ='';
}
else{ //If not pass in a variable with the value readonly
$readonly='readonly';
}
}