filtering records for display
Posted: Tue Jul 05, 2011 7:54 am
Hi,
I try to filter the display of records depending on a property of the current user ( $user->val('id_niveau1') )
I found some parts of the code below in this forum but something doesn't work :
class tables_intervention {
function getPermissions(&$record){
$auth =& Dataface_AuthenticationTool::getInstance();
$user =& $auth->getLoggedInUser();
if ( !isset($user) ) return Dataface_PermissionsTool::NO_ACCESS();
$role = $user->val('role');
if ($role && $role != 'ADMINISTRATEUR' && $role != 'MAINTENANCE' && $role != 'COORDINATEUR_MAINTENANCE' && $role != 'CONSULTATION')
return Dataface_PermissionsTool::NO_ACCESS();
// Only show records concerning the user
if (($role == 'CONSULTATION') && ($user->val('id_niveau1') != $record->val('id_niveau1')))
return Dataface_PermissionsTool::NO_ACCESS();
return Dataface_PermissionsTool::getRolePermissions($role);
}
}
(of course, id_niveau1 is a field of the 'users' table, and id_niveau1 is a field of the 'intervention' table)
in the first record of the table, if the field $user->val('id_niveau1') == $record->val('id_niveau1'), it works well
otherwise, the message below is displayed
Errors
Permission to perform action 'list' denied. Requires permission 'list' but only granted ''
Thanks for your help
I try to filter the display of records depending on a property of the current user ( $user->val('id_niveau1') )
I found some parts of the code below in this forum but something doesn't work :
class tables_intervention {
function getPermissions(&$record){
$auth =& Dataface_AuthenticationTool::getInstance();
$user =& $auth->getLoggedInUser();
if ( !isset($user) ) return Dataface_PermissionsTool::NO_ACCESS();
$role = $user->val('role');
if ($role && $role != 'ADMINISTRATEUR' && $role != 'MAINTENANCE' && $role != 'COORDINATEUR_MAINTENANCE' && $role != 'CONSULTATION')
return Dataface_PermissionsTool::NO_ACCESS();
// Only show records concerning the user
if (($role == 'CONSULTATION') && ($user->val('id_niveau1') != $record->val('id_niveau1')))
return Dataface_PermissionsTool::NO_ACCESS();
return Dataface_PermissionsTool::getRolePermissions($role);
}
}
(of course, id_niveau1 is a field of the 'users' table, and id_niveau1 is a field of the 'intervention' table)
in the first record of the table, if the field $user->val('id_niveau1') == $record->val('id_niveau1'), it works well
otherwise, the message below is displayed
Errors
Permission to perform action 'list' denied. Requires permission 'list' but only granted ''
Thanks for your help