Taking the above examples, the code in user_admin_perm (below) will match "module_permission" with "my_module_permission" as the check is for the permission with a trailing comma.
// Builds arrays for checked boxes for each role
if (strpos($role_permissions[$rid], $perm .',') !== FALSE) {
$status[$rid][] = $perm;
}
Just as a suggestion, I implemented the code below which will test the permission with the preceding comma and space and the terminating comma (unless its the very first permission), matching permissions exactly.
// Builds arrays for checked boxes for each role
if (strpos($role_permissions[$rid], $perm .',') !== FALSE) {
if (strpos(trim($role_permissions[$rid]), trim($perm) . ',') === 0) {
//1st occurance, must be ok
$status[$rid][] = $perm;
}else if (strpos($role_permissions[$rid], ', ' . $perm . ',') !== FALSE) {
//Full match on permission with begining and trailing comma
$status[$rid][] = $perm;
}
}
Comments