Permission table tabs?

A place to discuss development of the Xataface core.

Permission table tabs?

Postby rugcutter » Tue Feb 23, 2010 3:50 pm

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!
rugcutter
 
Posts: 11
Joined: Thu Apr 23, 2009 9:43 pm

Re: Permission table tabs?

Postby shannah » Tue Feb 23, 2010 3:59 pm

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

Re: Permission table tabs?

Postby strast » Thu Feb 25, 2010 6:42 pm

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
strast
 
Posts: 29
Joined: Thu Feb 05, 2009 6:14 pm


Return to Xataface Developers

Who is online

Users browsing this forum: No registered users and 9 guests

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