problem with table problem

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

problem with table problem

Postby samhans » Wed Feb 15, 2012 12:35 am

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
samhans
 
Posts: 96
Joined: Fri Feb 10, 2012 1:22 am

Re: problem with table problem

Postby shannah » Wed Feb 15, 2012 9:50 am

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
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: problem with table problem

Postby samhans » Wed Feb 15, 2012 10:12 am

Steve ,
solved the problem you are exactly right. declared the role first. and then it works fine.

thanks a lot
samhans
 
Posts: 96
Joined: Fri Feb 10, 2012 1:22 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 30 guests

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