Page 1 of 1

problem with table problem

PostPosted: Wed Feb 15, 2012 12:35 am
by samhans
hai

a problem in giving permissions. what i want that a particular role can view a table.
from the application delegate i have given permission to only admin. all others are denied.

my demand.php file is there in the tables/demand
<?php
class tables_demand {
function getPermissions(&$record){
//if ( !isset($user) ) return Dataface_PermissionsTool::NO_ACCESS();
$auth =&Dataface_AuthenticationTool::getInstance();
$user =& $auth ->getLoggedInUser();
$role = $user->val('Role');
if ( isAdmin() ) return Dataface_PermissionsTool::ALL();
if($user->val('Role') == 'DEMANDE' ) return Dataface_PermissionsTool::getRolePermissions($role);

return Dataface_PermissionsTool::NO_ACCESS();

}

}

?>

this works fine when i logged in , but when i logged out and click on the demand tab, i get the error
Fatal error: Call to a member function val() on a non-object in C:\xampp\htdocs\www\tables\demand\demand.php on line 11

the line 11 is the if ($user->val(role....... line.

can anyone help me i am stuck at this point.

thanks in advance

Re: problem with table problem

PostPosted: Wed Feb 15, 2012 9:50 am
by shannah
Problem is this line:
Code: Select all
if($user->val('Role') == 'DEMANDE' ) return Dataface_PermissionsTool::getRolePermissions($role);


If the user isn't logged in yet, then $user will be null.
Must first check that user is not null before calling method on it.

-Steve

Re: problem with table problem

PostPosted: Wed Feb 15, 2012 10:12 am
by samhans
Steve ,
solved the problem you are exactly right. declared the role first. and then it works fine.

thanks a lot