getPreferences function problem resolved
Archived from the Xataface Users forum.
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!
shannah — Mon Oct 03, 2011 5:53 pm
Are you sure you’re logging in as a user with role ‘ADMIN’?
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 ). Many thanks!