Suppose you have 2 columns: owner_id and approver_id. Then you want to create a grafted field called role such that:
If current user is the owner, role = 'owner'
else if current user is an approver, role = 'approver'
else role is null.
Then you could implement an __sql__() method like:
Code: Select all
function __sql__(){
$user_id = getUser(); ///
return "select demand.*, if(owner_id='".addslashes($user_id)."','owner', if(approver_id='".addslashes($user_id)."', 'approver', null)) as role from demand";
}
Then you could set a security filter on the "role" field:
Code: Select all
$table->setSecurityFilter(array('role'=>'>'));
steve i am getting the error: addslashes()expects parameter 1 to be string, object given in ......demand.php
please help. i think some problem with addslashes.