Wednesday, April 23, 2008

Xataface - How to unset tabs in the table view

Inside of a delegate class' fields.ini file, you can specify the notion of "tabs" and actually put separate fields into their tabs.

Sometimes you don't want a tab to appear in the view of a record. You can set the permissions of this like this:



function __tabs__(&$record){
$user =& getUser();

$t =& $record->_table;
$tabs = $t->_tabs;
if ( $record and !isAdmin() ){

if ( !$record->val('people_approval_status') )
unset($tabs['__people__']);
if ( !$record->val('researcher_approval_status') )
unset($tabs['__gcms__']);
}
return $tabs;
}


Here we call the __tabs__ function to actually process the tabs before they are run. And then we unset the tabs that we don't want the user to see.

No comments: