public function testget_user_allowed_modules() { //execute the method and test it it returns expected contents $expected = array(); $actual = get_user_allowed_modules('1'); $this->assertSame($expected, $actual); }
function get_tabs($user) { $display_tabs = $this->get_user_tabs($user, 'display'); $hide_tabs = $this->get_user_tabs($user, 'hide'); $remove_tabs = $this->get_user_tabs($user, 'remove'); $system_tabs = $this->get_system_tabs(); // remove access to tabs that roles do not give them permission to foreach ($system_tabs as $key => $value) { if (!isset($display_tabs[$key])) { $display_tabs[$key] = $value; } } //////////////////////////////////////////////////////////////////// // Jenny - Bug 6286: If someone has "old school roles" defined (before 4.0) and upgrades, // then they can't remove those old roles through the UI. Also, when new tabs are added, // users who had any of those "old school roles" defined have no way of being able to see // those roles. We need to disable role checking. //$roleCheck = query_user_has_roles($user->id); $roleCheck = 0; //////////////////////////////////////////////////////////////////// if ($roleCheck) { //grabs modules a user has access to via roles $role_tabs = get_user_allowed_modules($user->id); // adds modules to display_tabs if existant in roles foreach ($role_tabs as $key => $value) { if (!isset($display_tabs[$key])) { $display_tabs[$key] = $value; } } } // removes tabs from display_tabs if not existant in roles // or exist in the hidden tabs foreach ($display_tabs as $key => $value) { if ($roleCheck) { if (!isset($role_tabs[$key])) { unset($display_tabs[$key]); } } if (!isset($system_tabs[$key])) { unset($display_tabs[$key]); } if (isset($hide_tabs[$key])) { unset($display_tabs[$key]); } } // removes tabs from hide_tabs if not existant in roles foreach ($hide_tabs as $key => $value) { if ($roleCheck) { if (!isset($role_tabs[$key])) { unset($hide_tabs[$key]); } } if (!isset($system_tabs[$key])) { unset($hide_tabs[$key]); } } // remove tabs from user if admin has removed specific tabs foreach ($remove_tabs as $key => $value) { if (isset($display_tabs[$key])) { unset($display_tabs[$key]); } if (isset($hide_tabs[$key])) { unset($hide_tabs[$key]); } } return array($display_tabs, $hide_tabs, $remove_tabs); }