$subModules) { $tabStructure[$mainTab]['modules'] = array_merge($tabStructure[$mainTab]['modules'], $subModules); } } else { $tabStructure =& $GLOBALS['tabStructure']; } $retStruct = array(); $mlhUsed = array(); //the invisible list should be merged if activities is set to be hidden if (in_array('Activities', $modList)) { $modList = array_merge($modList, $modInvisListActivities); } //Add any iFrame tabs to the 'other' group. $moduleExtraMenu = array(); if (!should_hide_iframes()) { $iFrame = new iFrame(); $frames = $iFrame->lookup_frames('tab'); foreach ($frames as $key => $values) { $moduleExtraMenu[$key] = $values; } } else { if (isset($modList['iFrames'])) { unset($modList['iFrames']); } } $modList = array_merge($modList, $moduleExtraMenu); /* Only return modules which exists in the modList */ foreach ($tabStructure as $mainTab => $subModules) { //Ensure even empty groups are returned if ($labelAsKey) { $retStruct[$subModules['label']]['modules'] = array(); } else { $retStruct[$app_strings[$subModules['label']]]['modules']= array(); } foreach ($subModules['modules'] as $key => $subModule) { /* Perform a case-insensitive in_array check * and mark whichever module matched as used. */ foreach ($modList as $module) { if (is_string($module) && strcasecmp($subModule, $module) === 0) { if ($labelAsKey) { $retStruct[$subModules['label']]['modules'][$module] = $app_list_strings['moduleList'][$module]; } else { $retStruct[$app_strings[$subModules['label']]]['modules'][$module] = $app_list_strings['moduleList'][$module]; } $mlhUsed[$module] = true; break; } } } //remove the group tabs if it has no sub modules under it if ($labelAsKey) { if (empty($retStruct[$subModules['label']]['modules'])) { unset($retStruct[$subModules['label']]); } } else { if (empty($retStruct[$app_strings[$subModules['label']]]['modules'])) { unset($retStruct[$app_strings[$subModules['label']]]); } } } return $retStruct; } }