2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
41 require_once('include/tabConfig.php');
43 class GroupedTabStructure
46 * Prepare the tabs structure.
47 * Uses 'Other' tab functionality.
48 * If $modList is not specified, $modListHeader is used as default.
50 * @param array optional list of modules considered valid
51 * @param array optional array to temporarily union into the root of the tab structure
52 * @param bool if we set this param true, the other group tab will be returned no matter $sugar_config['other_group_tab_displayed'] is true or false
53 * @param bool We use label value as return array key by default. But we can set this param true, that we can use the label name as return array key.
55 * @return array the complete tab-group structure
57 function get_tab_structure($modList = '', $patch = '', $ignoreSugarConfig=false, $labelAsKey=false)
59 global $modListHeader, $app_strings, $app_list_strings, $modInvisListActivities;
61 /* Use default if not provided */
64 $modList =& $modListHeader;
67 /* Apply patch, use a reference if we can */
70 $tabStructure = $GLOBALS['tabStructure'];
72 foreach($patch as $mainTab => $subModules)
74 $tabStructure[$mainTab]['modules'] = array_merge($tabStructure[$mainTab]['modules'], $subModules);
79 $tabStructure =& $GLOBALS['tabStructure'];
84 //the invisible list should be merged if activities is set to be hidden
85 if(in_array('Activities', $modList)){
86 $modList = array_merge($modList,$modInvisListActivities);
89 //Add any iFrame tabs to the 'other' group.
90 $moduleExtraMenu = array();
91 if(!should_hide_iframes()) {
92 $iFrame = new iFrame();
93 $frames = $iFrame->lookup_frames('tab');
94 foreach($frames as $key => $values){
95 $moduleExtraMenu[$key] = $values;
97 } else if(isset($modList['iFrames'])) {
98 unset($modList['iFrames']);
101 $modList = array_merge($modList,$moduleExtraMenu);
103 /* Only return modules which exists in the modList */
104 foreach($tabStructure as $mainTab => $subModules)
106 //Ensure even empty groups are returned
108 $retStruct[$subModules['label']]['modules'] = array();
110 $retStruct[$app_strings[$subModules['label']]]['modules']= array();
113 foreach($subModules['modules'] as $key => $subModule)
115 /* Perform a case-insensitive in_array check
116 * and mark whichever module matched as used.
118 foreach($modList as $module)
120 if(is_string($module) && strcasecmp($subModule, $module) === 0)
123 $retStruct[$subModules['label']]['modules'][$module] = $app_list_strings['moduleList'][$module];
125 $retStruct[$app_strings[$subModules['label']]]['modules'][$module] = $app_list_strings['moduleList'][$module];
127 $mlhUsed[$module] = true;
132 //remove the group tabs if it has no sub modules under it
134 if (empty($retStruct[$subModules['label']]['modules'])){
135 unset($retStruct[$subModules['label']]);
138 if (empty($retStruct[$app_strings[$subModules['label']]]['modules'])){
139 unset($retStruct[$app_strings[$subModules['label']]]);