Hiding tables from certain users

In my Xataface application, I'd like the "admin" to be able to see all the tables. However, there are some tables that the normal users should not need to have access to. I want those tables to disappear from the navigation menu for other users. Also, I want those tables to be inaccessible from URL's.
The solution I came up with was to create a beforeHandleRequest function in my ApplicationDelegate.php:
Although this works, I was wondering if there's a better way to be doing this.
Thank you,
-Rob
The solution I came up with was to create a beforeHandleRequest function in my ApplicationDelegate.php:
- Code: Select all
function beforeHandleRequest() {
if ($this->isLoggedIn()) {
if ($this->getLoggedInUsername() !== 'admin') {
$app =& Dataface_Application::getInstance();
// Makes sure that the NavMenu cannot see these tables
unset($app->_conf['_tables']['phone_types']);
unset($app->_conf['_tables']['address_types']);
unset($app->_conf['_tables']['email_types']);
unset($app->_conf['_tables']['users']);
// Makes sure that a non-admin user cannot access the tables
// from the browser.
$app->_conf['_disallowed_tables']['hide_admin1'] = 'phone_types';
$app->_conf['_disallowed_tables']['hide_admin2'] = 'address_types';
$app->_conf['_disallowed_tables']['hide_admin3'] = 'email_types';
$app->_conf['_disallowed_tables']['hide_admin4'] = 'users';
}
}
}
Although this works, I was wondering if there's a better way to be doing this.
Thank you,
-Rob