getPreferences function problem resolved

A place for users and developers of the Xataface to discuss and receive support.

getPreferences function problem resolved

Postby lhat » Mon Oct 03, 2011 4:19 pm

Hi, all!

Following the 'Disabling Unnecssary Fetures" tutorial, I've added a getPreferences function to my ApplicationDelegate.php aiming to hide the tables menu/tabs depending on the user's role--so 'admin' users should see the tabs while others should not. Here's what I've got:


Code: Select all
     function getPreferences(){
         $auth =& Dataface_AuthenticationTool::getInstance();
         $user =& $auth->getLoggedInUser();
// check to see if user's logged in; if not, no tables menu
         if ( !isset($user) ) {
            return array('show_tables_menu'=>0);  }
// first branch: if logged in and an admin, show tables menu
         elseif
            ( $user && ($user->val('role') == 'ADMIN') ) {
                return array(
                'show_tables_menu'=>1,
                'show_table_tabs'=>1 );
         } else {
// second branch, if not an ADMIN, no tables menu
               return array(
               'show_table_tabs'=>0,
               'show_tables_menu'=>0 );
         }
     }



But though this hides tables menu well enough when the log-in page first appears, it doesn't restore those tabs after the user has logged in, regardless whether that user has the admin role or not. I'm not seeing where I'm amiss, so any and all help most welcome!
Last edited by lhat on Tue Oct 04, 2011 8:52 am, edited 1 time in total.
lhat
 
Posts: 40
Joined: Thu Aug 06, 2009 3:31 pm

Re: My getPreferences function isn't working

Postby shannah » Mon Oct 03, 2011 5:53 pm

Are you sure you're logging in as a user with role 'ADMIN'?
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: getPreferences function problem resolved

Postby lhat » Tue Oct 04, 2011 8:52 am

Right on the money, Steve--my value for the user was 'ADMIN' all right, but the field was called 'Role' rather than 'role' (sigh :oops: ). Many thanks!
lhat
 
Posts: 40
Joined: Thu Aug 06, 2009 3:31 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 20 guests

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