|
1
|
|
|
<?php |
|
2
|
|
|
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3
|
|
|
/********************************************************************************* |
|
4
|
|
|
* SugarCRM Community Edition is a customer relationship management program developed by |
|
5
|
|
|
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
|
6
|
|
|
|
|
7
|
|
|
* SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd. |
|
8
|
|
|
* Copyright (C) 2011 - 2014 Salesagility Ltd. |
|
9
|
|
|
* |
|
10
|
|
|
* This program is free software; you can redistribute it and/or modify it under |
|
11
|
|
|
* the terms of the GNU Affero General Public License version 3 as published by the |
|
12
|
|
|
* Free Software Foundation with the addition of the following permission added |
|
13
|
|
|
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK |
|
14
|
|
|
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY |
|
15
|
|
|
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. |
|
16
|
|
|
* |
|
17
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT |
|
18
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
19
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
|
20
|
|
|
* details. |
|
21
|
|
|
* |
|
22
|
|
|
* You should have received a copy of the GNU Affero General Public License along with |
|
23
|
|
|
* this program; if not, see http://www.gnu.org/licenses or write to the Free |
|
24
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
25
|
|
|
* 02110-1301 USA. |
|
26
|
|
|
* |
|
27
|
|
|
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, |
|
28
|
|
|
* SW2-130, Cupertino, CA 95014, USA. or at email address [email protected]. |
|
29
|
|
|
* |
|
30
|
|
|
* The interactive user interfaces in modified source and object code versions |
|
31
|
|
|
* of this program must display Appropriate Legal Notices, as required under |
|
32
|
|
|
* Section 5 of the GNU Affero General Public License version 3. |
|
33
|
|
|
* |
|
34
|
|
|
* In accordance with Section 7(b) of the GNU Affero General Public License version 3, |
|
35
|
|
|
* these Appropriate Legal Notices must retain the display of the "Powered by |
|
36
|
|
|
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not |
|
37
|
|
|
* reasonably feasible for technical reasons, the Appropriate Legal Notices must |
|
38
|
|
|
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
|
39
|
|
|
********************************************************************************/ |
|
40
|
|
|
|
|
41
|
|
|
require_once('include/SubPanel/SubPanel.php'); |
|
42
|
|
|
require_once('include/SubPanel/SubPanelDefinitions.php'); |
|
43
|
|
|
require_once('include/SubPanel/SubPanelTiles.php'); |
|
44
|
|
|
/** |
|
45
|
|
|
* Tabbed subpanel tiles |
|
46
|
|
|
* @api |
|
47
|
|
|
*/ |
|
48
|
|
|
class SubPanelTilesTabs extends SubPanelTiles |
|
49
|
|
|
{ |
|
50
|
|
|
|
|
51
|
|
|
function __construct(&$focus, $layout_def_key='', $layout_def_override = '') |
|
52
|
|
|
{ |
|
53
|
|
|
|
|
54
|
|
|
$this->focus = $focus; |
|
55
|
|
|
$this->id = $focus->id; |
|
56
|
|
|
$this->module = $focus->module_dir; |
|
57
|
|
|
$this->layout_def_key = $layout_def_key; |
|
58
|
|
|
$this->subpanel_definitions = new SubPanelDefinitions($focus, $layout_def_key, $layout_def_override); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
function getSubpanelGroupLayout($selectedGroup) |
|
62
|
|
|
{ |
|
63
|
|
|
global $current_user; |
|
64
|
|
|
|
|
65
|
|
|
$layoutParams = $this->module; |
|
66
|
|
|
//WDong Bug: 12258 "All" tab in the middle of a record's detail view is not localized. |
|
67
|
|
|
if($selectedGroup != translate('LBL_TABGROUP_ALL')) |
|
68
|
|
|
{ |
|
69
|
|
|
$layoutParams .= ':'.$selectedGroup; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
// see if user current user has custom subpanel layout |
|
73
|
|
|
return $current_user->getPreference('subpanelLayout', $layoutParams); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
function applyUserCustomLayoutToTabs($tabs, $key='All') |
|
77
|
|
|
{ |
|
78
|
|
|
//WDong Bug: 12258 "All" tab in the middle of a record's detail view is not localized. |
|
79
|
|
|
if($key=='All') |
|
80
|
|
|
{ |
|
81
|
|
|
$key=translate('LBL_TABGROUP_ALL'); |
|
82
|
|
|
} |
|
83
|
|
|
$usersCustomLayout = SubPanelTilesTabs::getSubpanelGroupLayout($key); |
|
84
|
|
|
if(!empty($usersCustomLayout)) |
|
85
|
|
|
{ |
|
86
|
|
|
/* Return elements of the custom layout |
|
87
|
|
|
* which occur in $tabs in unchanged order. |
|
88
|
|
|
* Then append elements of $tabs which are |
|
89
|
|
|
* not included in the layout. */ |
|
90
|
|
|
$diff = array_diff($tabs, $usersCustomLayout); |
|
91
|
|
|
$tabs = array_intersect($usersCustomLayout, $tabs); |
|
92
|
|
|
foreach($diff as $subpanel) |
|
93
|
|
|
{ |
|
94
|
|
|
$tabs []= $subpanel; |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
return $tabs; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/* |
|
102
|
|
|
* Place subpanels into tabs for display on a DetailView |
|
103
|
|
|
* @param array $tabs Array containing the ids of all subpanels to be placed into tabs |
|
|
|
|
|
|
104
|
|
|
* @param boolean $showTabs Call the view code to display the generated tabs |
|
105
|
|
|
* @param string $selectedGroup (Optional) Name of any selected tab (defaults to 'All') |
|
106
|
|
|
*/ |
|
107
|
|
|
function getTabs($showTabs = true, $selectedGroup='') { |
|
108
|
|
|
$args = func_get_args(); |
|
109
|
|
|
return call_user_func_array(array($this, '_getTabs'), $args); |
|
110
|
|
|
} |
|
111
|
|
|
function _getTabs($tabs, $showTabs = true, $selectedGroup='All') |
|
112
|
|
|
{ |
|
113
|
|
|
//WDong Bug: 12258 "All" tab in the middle of a record's detail view is not localized. |
|
114
|
|
|
if($selectedGroup=='All') |
|
115
|
|
|
$selectedGroup=translate('LBL_TABGROUP_ALL'); |
|
116
|
|
|
|
|
117
|
|
|
// Set up a mapping from subpanelID, found in the $tabs list, to the source module name |
|
118
|
|
|
// As the $GLOBALS['tabStructure'] array holds the Group Tabs by module name we need to efficiently convert between the two |
|
119
|
|
|
// when constructing the subpanel tabs |
|
120
|
|
|
// Note that we can't use the very similar GroupedTabStructure class as it lacks this mapping, and logically, it is designed |
|
121
|
|
|
// for use when constructing the module by module tabs, not the subpanel tabs, as we move away from using module names to represent |
|
122
|
|
|
// subpanels, and use unique subpanel IDs instead. |
|
123
|
|
|
|
|
124
|
|
|
$moduleNames = array () ; |
|
125
|
|
|
foreach ( $tabs as $subpanelID ) |
|
126
|
|
|
{ |
|
127
|
|
|
// Bug #44344 : Custom relationships under same module only show once in subpanel tabs |
|
128
|
|
|
// use object property instead new object to have ability run unit test (can override subpanel_definitions) |
|
129
|
|
|
$subpanel = $this->subpanel_definitions->load_subpanel( $subpanelID ); |
|
130
|
|
|
if ($subpanel !== false) |
|
131
|
|
|
$moduleNames [ $subpanelID ] = $subpanel->get_module_name() ; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
$groups = array () ; |
|
135
|
|
|
$found = array () ; |
|
136
|
|
|
|
|
137
|
|
|
foreach( $GLOBALS['tabStructure'] as $mainTab => $subModules) |
|
138
|
|
|
{ |
|
139
|
|
|
foreach( $subModules['modules'] as $key => $subModule ) |
|
140
|
|
|
{ |
|
141
|
|
|
foreach ( $tabs as $subpanelID ) |
|
142
|
|
|
if (isset($moduleNames[ $subpanelID ] ) && strcasecmp( $subModule , $moduleNames[ $subpanelID ] ) === 0) |
|
143
|
|
|
{ |
|
144
|
|
|
// Bug #44344 : Custom relationships under same module only show once in subpanel tabs |
|
145
|
|
|
$groups [ translate ( $mainTab ) ] [ 'modules' ] [] = $subpanelID ; |
|
146
|
|
|
$found [ $subpanelID ] = true ; |
|
147
|
|
|
} |
|
148
|
|
|
} |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
// Put all the remaining subpanels into the 'Other' tab. |
|
152
|
|
|
|
|
153
|
|
|
foreach( $tabs as $subpanelID ) |
|
154
|
|
|
{ |
|
155
|
|
|
if ( ! isset ( $found [ $subpanelID ] ) ) |
|
156
|
|
|
$groups [ translate ('LBL_TABGROUP_OTHER') ]['modules'] [] = $subpanelID ; |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
/* Move history to same tab as activities */ |
|
160
|
|
|
if(in_array('history', $tabs) && in_array('activities', $tabs)) |
|
161
|
|
|
{ |
|
162
|
|
|
foreach($groups as $mainTab => $group) |
|
163
|
|
|
{ |
|
164
|
|
|
if(in_array('activities', array_map('strtolower', $group['modules']))) |
|
165
|
|
|
{ |
|
166
|
|
|
if(!in_array('history', array_map('strtolower', $group['modules']))) |
|
167
|
|
|
{ |
|
168
|
|
|
/* Move hist from there to here */ |
|
169
|
|
|
$groups[$mainTab]['modules'] []= 'history'; |
|
170
|
|
|
} |
|
171
|
|
|
} |
|
172
|
|
|
else if(false !== ($i = array_search('history', array_map('strtolower', $group['modules'])))) |
|
173
|
|
|
{ |
|
174
|
|
|
unset($groups[$mainTab]['modules'][$i]); |
|
175
|
|
|
if(empty($groups[$mainTab]['modules'])) |
|
176
|
|
|
{ |
|
177
|
|
|
unset($groups[$mainTab]); |
|
178
|
|
|
} |
|
179
|
|
|
} |
|
180
|
|
|
} |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
/* Add the 'All' group. |
|
184
|
|
|
* Note that if a tab group already exists with the name 'All', |
|
185
|
|
|
* it will be overwritten in this union operation. |
|
186
|
|
|
*/ |
|
187
|
|
|
if(count($groups) <= 1) |
|
188
|
|
|
$groups = array(translate('LBL_TABGROUP_ALL') => array('label' => translate('LBL_TABGROUP_ALL'), 'modules' => $tabs)); |
|
189
|
|
|
else |
|
190
|
|
|
$groups = array(translate('LBL_TABGROUP_ALL') => array('label' => translate('LBL_TABGROUP_ALL'), 'modules' => $tabs)) + $groups; |
|
191
|
|
|
/* Note - all $display checking and array_intersects with $tabs |
|
192
|
|
|
* are now redundant (thanks to GroupedTabStructure), and could |
|
193
|
|
|
* be removed for performance, but for now can stay to help ensure |
|
194
|
|
|
* that the tabs get renedered correctly. |
|
195
|
|
|
*/ |
|
196
|
|
|
|
|
197
|
|
|
$retTabs = array(); |
|
198
|
|
|
if($showTabs) |
|
199
|
|
|
{ |
|
200
|
|
|
require_once('include/SubPanel/SugarTab.php'); |
|
201
|
|
|
$sugarTab = new SugarTab(); |
|
202
|
|
|
|
|
203
|
|
|
$displayTabs = array(); |
|
204
|
|
|
$otherTabs = array(); |
|
205
|
|
|
|
|
206
|
|
|
foreach ($groups as $key=>$tab) |
|
207
|
|
|
{ |
|
208
|
|
|
$display = false; |
|
209
|
|
|
foreach($tab['modules'] as $subkey=>$subtab) |
|
210
|
|
|
{ |
|
211
|
|
|
if(in_array(strtolower($subtab), $tabs)) |
|
212
|
|
|
{ |
|
213
|
|
|
$display = true; |
|
214
|
|
|
break; |
|
215
|
|
|
} |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
$selected = ''; |
|
219
|
|
|
|
|
220
|
|
|
if($selectedGroup == $key) |
|
221
|
|
|
{ |
|
222
|
|
|
$selected = 'current'; |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
if($display) |
|
226
|
|
|
{ |
|
227
|
|
|
$relevantTabs = SubPanelTilesTabs::applyUserCustomLayoutToTabs($tabs, $key); |
|
228
|
|
|
|
|
229
|
|
|
$sugarTabs[$key] = array(//'url'=>'index.php?module=' . $_REQUEST['module'] . '&record=' . $_REQUEST['record'] . '&action=' . $_REQUEST['action']. '&subpanel=' . $key.'#tabs', |
|
230
|
|
|
//'url'=>"javascript:SUGAR.util.retrieveAndFill('index.php?to_pdf=1&module=MySettings&action=LoadTabSubpanels&loadModule={$_REQUEST['module']}&record={$_REQUEST['record']}&subpanel=$key','subpanel_list',null,null,null);", |
|
231
|
|
|
'label'=>( !empty($tab['label']) ? $tab['label']: $key ), |
|
232
|
|
|
'type'=>$selected); |
|
233
|
|
|
|
|
234
|
|
|
$otherTabs[$key] = array('key'=>$key, 'tabs'=>array()); |
|
235
|
|
|
|
|
236
|
|
|
$orderedTabs = array_intersect($relevantTabs, array_map('strtolower', $groups[$key]['modules'])); |
|
237
|
|
|
|
|
238
|
|
|
foreach($orderedTabs as $subkey => $subtab) |
|
239
|
|
|
{ |
|
240
|
|
|
$otherTabs[$key]['tabs'][$subkey] = array('key'=>$subtab, 'label'=>translate($this->subpanel_definitions->layout_defs['subpanel_setup'][$subtab]['title_key'])); |
|
241
|
|
|
} |
|
242
|
|
|
|
|
243
|
|
|
if($selectedGroup == $key) |
|
244
|
|
|
{ |
|
245
|
|
|
$displayTabs = $otherTabs[$key]['tabs']; |
|
246
|
|
|
$retTabs = $orderedTabs; |
|
247
|
|
|
} |
|
248
|
|
|
} |
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
|
|
if(empty($displayTabs) && !empty($otherTabs)) |
|
252
|
|
|
{ |
|
253
|
|
|
//WDong Bug: 12258 "All" tab in the middle of a record's detail view is not localized. |
|
254
|
|
|
$selectedGroup = translate('LBL_TABGROUP_ALL'); |
|
255
|
|
|
$displayTabs = $otherTabs[$selectedGroup]['tabs']; |
|
256
|
|
|
$sugarTabs[$selectedGroup]['type'] = 'current'; |
|
257
|
|
|
$retTabs = array_intersect($tabs, array_map('strtolower', $groups[$selectedGroup]['modules'])); |
|
258
|
|
|
} |
|
259
|
|
|
|
|
260
|
|
|
if (!empty($sugarTabs) || !empty($otherTabs) ) { |
|
261
|
|
|
$sugarTab->setup($sugarTabs, $otherTabs, $displayTabs, $selectedGroup); |
|
262
|
|
|
$sugarTab->display(); |
|
263
|
|
|
} |
|
264
|
|
|
} |
|
265
|
|
|
else |
|
266
|
|
|
{ |
|
267
|
|
|
$tabs = SubPanelTilesTabs::applyUserCustomLayoutToTabs($tabs, $selectedGroup); |
|
268
|
|
|
|
|
269
|
|
|
$retTabs = array_intersect($tabs, array_map('strtolower', $groups[$selectedGroup]['modules'])); |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
return $retTabs; |
|
273
|
|
|
} |
|
274
|
|
|
} |
|
275
|
|
|
?> |
|
276
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.