Page 1 of 1

Permission table tabs?

PostPosted: Tue Feb 23, 2010 3:50 pm
by rugcutter
I'm looking to include a table tab for "ADMIN" role users to manage the "Users" table. However I want to hide this tab for users that do not belong in the "ADMIN" role.

There was a previous post circa 2006 on how this might be done. viewtopic.php?t=3971#19896

But I'm still a little lost.

There are two places I see where it can be done -

1) Dataface_NavMenu.html - it looks like I should use Smarty to interrogate the user's role, but I'm not sure if this is the right way to go about doing this?

2) implement block__table_tabs() in the delegate class - I can get the user's role easily here, but not sure what the function should be returning?

Thanks in advance!

Re: Permission table tabs?

PostPosted: Tue Feb 23, 2010 3:59 pm
by shannah
Use the tables_menu_tail block. You can just output <li> tags that will appear as tabs at the end of your table tabs.

e.g.
Code: Select all
function block__tables_menu_tail(){
    $q = Dataface_Application::getInstance()->getQuery();
    if ( isAdmin() ){
        echo '<li '.(($q['-table'] == 'users')?'class="selected":'').'><a href="?-table=users">Users</a></li>';
    }
}

Re: Permission table tabs?

PostPosted: Thu Feb 25, 2010 6:42 pm
by strast
Correction-- there's a missing single quote in that code that will throw an error.

Code: Select all

function block__tables_menu_tail() {
  $q = Dataface_Application::getInstance()->getQuery();
  if ( isAdmin() ) {
    echo '<li '.(($q['-table'] == 'users')?'class="selected"':'').'><a href="?-table=users">Users</a></li>';
}



--Steve