Page 1 of 1

peculiar problem with grafted field

PostPosted: Wed Feb 22, 2012 2:20 am
by samhans
HAI STEVE AND ALL,

a peculiar problem arrived, when i put a grafted field in my table delegate class. every thing worked fine but when i added a column in my table demand the page displays error "there is no column demand.demd_qty................."

the demd_qty is the new filed i added. when i delete this grafted field from my delegate class everything worked fine. I cant able to know what is the issue??


my demand.php is like this

<?php

class tables_demand {




// here permission of demand table is set for demande and approver,admin is by default
function getPermissions(&$record){
//if ( !isset($user) ) return Dataface_PermissionsTool::NO_ACCESS();
$auth =&Dataface_AuthenticationTool::getInstance();
$user =& $auth ->getLoggedInUser();
if ( !isset($user) ) return Dataface_PermissionsTool::NO_ACCESS();
if ( isAdmin() ) return Dataface_PermissionsTool::ALL();
$role = $user->val('Role');
if($user->val('Role') == 'DEMANDE' ) return Dataface_PermissionsTool::getRolePermissions($role);
if($user->val('Role') == 'APPROVER' ) return Dataface_PermissionsTool::getRolePermissions($role);
if($user->val('Role') == 'LOAN INCHARGE' ) return Dataface_PermissionsTool::getRolePermissions($role);
//if ( isAdmin() ) return Dataface_PermissionsTool::ALL();
return Dataface_PermissionsTool::NO_ACCESS();

}


//this create the role column in demand table,this is a grafted column.
function __sql__(){
$user_id = getcurrentUsername();
return "select demand.*,if(owner_id='".addslashes($user_id)."','owner',if(approver='".addslashes($user_id)."','approver', null)) as role from demand";

}


function init(&$table){
$user = getUser();
if($user and $user->val('Role')!='ADMIN'){
$table->setSecurityFilter(array('role'=>'>'));
}return array();
}


// field level permission starts from here.

function sec_commander__permissions(&$record) {
$auth = & Dataface_AuthenticationTool::getInstance();
$user =& $auth->getLoggedInUser();
$role = $user->val('Role');

if(isAdmin()){
return Dataface_PermissionsTool::ALL();
} elseif($user->val('Role') == 'APPROVER' ) {
return Dataface_PermissionsTool::getRolePermissions($role);
} else return Dataface_PermissionsTool::NO_ACCESS();
}


}


what is the problem , i have deleted and created a fresh table also, but to no avail. please help

Re: peculiar problem with grafted field

PostPosted: Wed Feb 22, 2012 12:27 pm
by shannah
You may need to delete all of the cache views that dataface creates. These are the views with names line dataface__view_xxxxxxxxxx

When using custom __sql__ dataface creates these for performance reasons... but if you then add fields, you may need to clear them.

-Steve