filtering records for display

A place for users and developers of the Xataface to discuss and receive support.

filtering records for display

Postby xenajo » 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 :D
otherwise, the message below is displayed :(
Errors
Permission to perform action 'list' denied. Requires permission 'list' but only granted ''


Thanks for your help
xenajo
 
Posts: 6
Joined: Thu May 19, 2011 6:16 am

Re: filtering records for display

Postby silma » Wed Jul 06, 2011 12:56 am

Hello,

I needed the same sort of thing for my app, Steve helped me here : http://www.xataface.com/forum/viewtopic.php?f=4&t=4834
The working code is in the last post.
Sorry for my english !

Silma
silma
 
Posts: 87
Joined: Tue Apr 28, 2009 11:47 pm

Re: filtering records for display

Postby xenajo » Thu Jul 07, 2011 9:38 am

Well done Silma,

your answer is exactly what I expected ! :wink:

altering the query with __sql__ delegate class method is much more powerful than using triggers

thank's a lot
xenajo
 
Posts: 6
Joined: Thu May 19, 2011 6:16 am

Re: filtering records for display

Postby silma » Fri Jul 08, 2011 12:37 am

I'm glad i could help, but steve has done the work here :)
silma
 
Posts: 87
Joined: Tue Apr 28, 2009 11:47 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 27 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved