|
1
|
|
|
<?php |
|
2
|
1 |
|
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
|
1 |
|
require_once('include/EditView/SugarVCR.php'); |
|
42
|
|
|
/** |
|
43
|
|
|
* ListView - list of many objects |
|
44
|
|
|
* @api |
|
45
|
|
|
*/ |
|
46
|
|
|
class ListView |
|
47
|
|
|
{ |
|
48
|
|
|
var $local_theme= null; |
|
49
|
|
|
var $local_app_strings= null; |
|
50
|
|
|
var $local_image_path = null; |
|
51
|
|
|
var $local_current_module = null; |
|
52
|
|
|
var $local_mod_strings = null; |
|
53
|
|
|
var $records_per_page = 20; |
|
54
|
|
|
var $xTemplate = null; |
|
55
|
|
|
var $xTemplatePath = null; |
|
56
|
|
|
var $seed_data = null; |
|
57
|
|
|
var $query_where = null; |
|
58
|
|
|
var $query_limit = -1; |
|
59
|
|
|
var $query_orderby = null; |
|
60
|
|
|
var $header_title = ''; |
|
61
|
|
|
var $header_text = ''; |
|
62
|
|
|
var $initialized = false; |
|
63
|
|
|
var $show_export_button = true; |
|
64
|
|
|
var $show_delete_button = true; |
|
65
|
|
|
var $show_select_menu = true; |
|
66
|
|
|
var $show_paging = true; |
|
67
|
|
|
var $show_mass_update = true; |
|
68
|
|
|
var $show_mass_update_form = true; |
|
69
|
|
|
var $query_where_has_changed = false; |
|
70
|
|
|
var $display_header_and_footer = true; |
|
71
|
|
|
var $baseURL = ''; |
|
72
|
|
|
var $is_dynamic = false; |
|
73
|
|
|
var $inline = false; |
|
74
|
|
|
var $start_link_wrapper = ''; |
|
75
|
|
|
var $end_link_wrapper = ''; |
|
76
|
|
|
var $list_field_defs = array(); |
|
77
|
|
|
|
|
78
|
|
|
var $shouldProcess = false; |
|
79
|
|
|
var $data_array; |
|
80
|
|
|
var $related_field_name = ''; |
|
81
|
|
|
var $child_focus = ''; |
|
82
|
|
|
var $layout_manager = null; |
|
83
|
|
|
var $process_for_popups = false; |
|
84
|
|
|
var $multi_select_popup=false; |
|
85
|
|
|
var $_additionalDetails = false; |
|
86
|
|
|
var $additionalDetailsFunction = null; |
|
87
|
|
|
var $sort_order = ''; |
|
88
|
|
|
var $force_mass_update=false; |
|
89
|
|
|
var $keep_mass_update_form_open=false; |
|
90
|
|
|
var $ignorePopulateOnly = false; |
|
91
|
|
|
|
|
92
|
|
|
function setDataArray($value) { |
|
93
|
|
|
$this->data_array = $value; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
function processListViewMulti($seed, $xTemplateSection, $html_varName) { |
|
97
|
|
|
|
|
98
|
|
|
$this->shouldProcess = true; |
|
99
|
|
|
|
|
100
|
|
|
echo "<form name='MassUpdate' method='post' action='index.php'>"; |
|
101
|
|
|
$this->processListViewTwo($seed, $xTemplateSection, $html_varName); |
|
102
|
|
|
|
|
103
|
|
|
echo "<a href='javascript:" . ((!$this->multi_select_popup) ? 'sListView.' : ''). "check_all(document.MassUpdate, \"mass[]\", true)'>".translate('LBL_CHECKALL')."</a> - <a href='javascript:sListView.check_all(document.MassUpdate, \"mass[]\", false);'>".translate('LBL_CLEARALL')."</a>"; |
|
104
|
|
|
echo '<br><br>'; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
|
|
108
|
|
|
function processListView($seed, $xTemplateSection, $html_varName) |
|
109
|
|
|
{ |
|
110
|
|
|
global $sugar_config; |
|
111
|
|
|
|
|
112
|
|
|
$populateOnly = $this->ignorePopulateOnly ? FALSE : (!empty($sugar_config['save_query']) && $sugar_config['save_query'] == 'populate_only'); |
|
113
|
|
|
if(isset($seed->module_dir) && $populateOnly) { |
|
114
|
|
|
if(empty($GLOBALS['displayListView']) && strcmp(strtolower($_REQUEST['action']), 'popup') != 0 && (!empty($_REQUEST['clear_query']) || $_REQUEST['module'] == $seed->module_dir && ((empty($_REQUEST['query']) || $_REQUEST['query'] == 'MSI')&& (empty($_SESSION['last_search_mod']) || $_SESSION['last_search_mod'] != $seed->module_dir)))) { |
|
115
|
|
|
$_SESSION['last_search_mod'] = $_REQUEST['module'] ; |
|
116
|
|
|
return; |
|
117
|
|
|
} |
|
118
|
|
|
} |
|
119
|
|
|
if(strcmp(strtolower($_REQUEST['action']), 'popup') != 0){ |
|
120
|
|
|
$_SESSION['last_search_mod'] = $_REQUEST['module'] ; |
|
121
|
|
|
} |
|
122
|
|
|
//following session variable will track the detail view navigation history. |
|
123
|
|
|
//needs to the reset after each search. |
|
124
|
|
|
$this->setLocalSessionVariable($html_varName,"DETAIL_NAV_HISTORY",false); |
|
125
|
|
|
|
|
126
|
|
|
require_once('include/MassUpdate.php'); |
|
127
|
|
|
$mass = new MassUpdate(); |
|
128
|
|
|
$add_acl_javascript = false; |
|
129
|
|
|
if(!isset($_REQUEST['action'])) { |
|
130
|
|
|
$this->shouldProcess=false; |
|
131
|
|
|
} else { |
|
132
|
|
|
$this->shouldProcess = is_subclass_of($seed, "SugarBean") |
|
133
|
|
|
&& (($_REQUEST['action'] == 'index') || ('ListView' == substr($_REQUEST['action'],0,8)) /* cn: to include all ListViewXXX.php type views */) |
|
134
|
|
|
&& ($_REQUEST['module'] == $seed->module_dir); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
//when processing a multi-select popup. |
|
138
|
|
|
if($this->process_for_popups && $this->multi_select_popup) $this->shouldProcess =true; |
|
139
|
|
|
//mass update turned off? |
|
140
|
|
|
if(!$this->show_mass_update) $this->shouldProcess = false; |
|
141
|
|
|
if(is_subclass_of($seed, "SugarBean")) { |
|
142
|
|
|
if($seed->bean_implements('ACL')) { |
|
143
|
|
|
if(!ACLController::checkAccess($seed->module_dir,'list',true)) { |
|
144
|
|
|
if($_REQUEST['module'] != 'Home') { |
|
145
|
|
|
ACLController::displayNoAccess(); |
|
146
|
|
|
} |
|
147
|
|
|
return; |
|
148
|
|
|
} |
|
149
|
|
|
if(!ACLController::checkAccess($seed->module_dir,'export',true)) { |
|
150
|
|
|
$sugar_config['disable_export']= true; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
} |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
//force mass update form if requested. |
|
157
|
|
|
if($this->force_mass_update) { |
|
158
|
|
|
$this->shouldProcess = true; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
if($this->shouldProcess) { |
|
162
|
|
|
echo $mass->getDisplayMassUpdateForm(true, $this->multi_select_popup); |
|
163
|
|
|
echo $mass->getMassUpdateFormHeader($this->multi_select_popup); |
|
164
|
|
|
$mass->setSugarBean($seed); |
|
165
|
|
|
|
|
166
|
|
|
//C.L. Fix for 10048, do not process handleMassUpdate for multi select popups |
|
167
|
|
|
if(!$this->multi_select_popup) { |
|
168
|
|
|
$mass->handleMassUpdate(); |
|
169
|
|
|
} |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
$this->processListViewTwo($seed,$xTemplateSection, $html_varName); |
|
173
|
|
|
|
|
174
|
|
|
if($this->shouldProcess && empty($this->process_for_popups)) { |
|
175
|
|
|
//echo "<a href='javascript:sListView.clear_all(document.MassUpdate, \"mass[]\");'>".translate('LBL_CLEARALL')."</a>"; |
|
176
|
|
|
// cn: preserves current functionality, exception is InboundEmail |
|
177
|
|
|
if($this->show_mass_update_form) { |
|
178
|
|
|
echo $mass->getMassUpdateForm(); |
|
179
|
|
|
} |
|
180
|
|
|
if(!$this->keep_mass_update_form_open) { |
|
181
|
|
|
echo $mass->endMassUpdateForm(); |
|
182
|
|
|
} |
|
183
|
|
|
} |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
|
|
187
|
|
|
function process_dynamic_listview($source_module, $sugarbean,$subpanel_def) |
|
188
|
|
|
{ |
|
189
|
|
|
$this->source_module = $source_module; |
|
190
|
|
|
$this->subpanel_module = $subpanel_def->name; |
|
191
|
|
|
if(!isset($this->xTemplate)) |
|
192
|
|
|
$this->createXTemplate(); |
|
193
|
|
|
|
|
194
|
|
|
$html_var = $this->subpanel_module . "_CELL"; |
|
195
|
|
|
|
|
196
|
|
|
$list_data = $this->processUnionBeans($sugarbean,$subpanel_def, $html_var); |
|
197
|
|
|
|
|
198
|
|
|
$list = $list_data['list']; |
|
199
|
|
|
$parent_data = $list_data['parent_data']; |
|
200
|
|
|
|
|
201
|
|
|
if($subpanel_def->isCollection()) { |
|
202
|
|
|
$thepanel=$subpanel_def->get_header_panel_def(); |
|
203
|
|
|
} else { |
|
204
|
|
|
$thepanel=$subpanel_def; |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
|
|
208
|
|
|
|
|
209
|
|
|
$this->process_dynamic_listview_header($thepanel->get_module_name(), $thepanel, $html_var); |
|
210
|
|
|
$this->process_dynamic_listview_rows($list,$parent_data, 'dyn_list_view', $html_var,$subpanel_def); |
|
211
|
|
|
|
|
212
|
|
|
if($this->display_header_and_footer) |
|
213
|
|
|
{ |
|
214
|
|
|
$this->getAdditionalHeader(); |
|
215
|
|
|
if(!empty($this->header_title)) |
|
216
|
|
|
{ |
|
217
|
|
|
echo get_form_header($this->header_title, $this->header_text, false); |
|
218
|
|
|
} |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
$this->xTemplate->out('dyn_list_view'); |
|
222
|
|
|
|
|
223
|
|
|
if(isset($_SESSION['validation'])) |
|
224
|
|
|
{ |
|
225
|
|
|
print base64_decode('PGEgaHJlZj0naHR0cDovL3d3dy5zdWdhcmNybS5jb20nPlBPV0VSRUQmbmJzcDtCWSZuYnNwO1NVR0FSQ1JNPC9hPg=='); |
|
226
|
|
|
} |
|
227
|
|
|
if(isset($list_data['query'])) { |
|
228
|
|
|
return ($list_data['query']); |
|
229
|
|
|
} |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
/** |
|
233
|
|
|
* @return void |
|
234
|
|
|
* @param unknown $data |
|
235
|
|
|
* @param unknown $xTemplateSection |
|
|
|
|
|
|
236
|
|
|
* @param unknown $html_varName |
|
237
|
|
|
* @desc INTERNAL FUNCTION handles the rows |
|
238
|
|
|
*/ |
|
239
|
|
|
function process_dynamic_listview_rows($data,$parent_data, $xtemplateSection, $html_varName, $subpanel_def) |
|
240
|
|
|
{ |
|
241
|
|
|
global $subpanel_item_count; |
|
242
|
|
|
global $odd_bg; |
|
243
|
|
|
global $even_bg; |
|
244
|
|
|
global $hilite_bg; |
|
245
|
|
|
global $click_bg; |
|
246
|
|
|
|
|
247
|
|
|
$this->xTemplate->assign("BG_HILITE", $hilite_bg); |
|
248
|
|
|
$this->xTemplate->assign('CHECKALL', SugarThemeRegistry::current()->getImage('blank', '', 1, 1, ".gif", '')); |
|
249
|
|
|
//$this->xTemplate->assign("BG_CLICK", $click_bg); |
|
250
|
|
|
$subpanel_item_count = 0; |
|
251
|
|
|
$oddRow = true; |
|
252
|
|
|
$count = 0; |
|
253
|
|
|
reset($data); |
|
254
|
|
|
|
|
255
|
|
|
//GETTING OFFSET |
|
256
|
|
|
$offset = $this->getOffset($html_varName); |
|
257
|
|
|
//$totaltime = 0; |
|
258
|
|
|
$processed_ids = array(); |
|
259
|
|
|
|
|
260
|
|
|
$fill_additional_fields = array(); |
|
261
|
|
|
//Either retrieve the is_fill_in_additional_fields property from the lone |
|
262
|
|
|
//subpanel or visit each subpanel's subpanels to retrieve the is_fill_in_addition_fields |
|
263
|
|
|
//property |
|
264
|
|
|
$subpanel_list=array(); |
|
265
|
|
|
if($subpanel_def->isCollection()) { |
|
266
|
|
|
$subpanel_list=$subpanel_def->sub_subpanels; |
|
267
|
|
|
} else { |
|
268
|
|
|
$subpanel_list[]= $subpanel_def; |
|
269
|
|
|
} |
|
270
|
|
|
|
|
271
|
|
|
foreach($subpanel_list as $this_subpanel) |
|
272
|
|
|
{ |
|
273
|
|
|
if($this_subpanel->is_fill_in_additional_fields()) |
|
274
|
|
|
{ |
|
275
|
|
|
$fill_additional_fields[] = $this_subpanel->bean_name; |
|
276
|
|
|
$fill_additional_fields[$this_subpanel->bean_name] = true; |
|
277
|
|
|
} |
|
278
|
|
|
} |
|
279
|
|
|
|
|
280
|
|
|
if ( empty($data) ) { |
|
281
|
|
|
$this->xTemplate->assign("ROW_COLOR", 'oddListRow'); |
|
282
|
|
|
$thepanel=$subpanel_def; |
|
283
|
|
|
if($subpanel_def->isCollection()) |
|
284
|
|
|
$thepanel=$subpanel_def->get_header_panel_def(); |
|
285
|
|
|
$this->xTemplate->assign("COL_COUNT", count($thepanel->get_list_fields())); |
|
286
|
|
|
$this->xTemplate->parse($xtemplateSection.".nodata"); |
|
287
|
|
|
} |
|
288
|
|
|
while(list($aVal, $aItem) = each($data)) |
|
|
|
|
|
|
289
|
|
|
{ |
|
290
|
|
|
$subpanel_item_count++; |
|
291
|
|
|
$aItem->check_date_relationships_load(); |
|
292
|
|
|
// TODO: expensive and needs to be removed and done better elsewhere |
|
293
|
|
|
|
|
294
|
|
|
if(!empty($fill_additional_fields[$aItem->object_name]) |
|
295
|
|
|
|| ($aItem->object_name == 'Case' && !empty($fill_additional_fields['aCase'])) |
|
296
|
|
|
) |
|
297
|
|
|
{ |
|
298
|
|
|
$aItem->fill_in_additional_list_fields(); |
|
299
|
|
|
//$aItem->fill_in_additional_detail_fields(); |
|
300
|
|
|
} |
|
301
|
|
|
//rrs bug: 25343 |
|
302
|
|
|
$aItem->call_custom_logic("process_record"); |
|
303
|
|
|
|
|
304
|
|
|
if(isset($parent_data[$aItem->id])) { |
|
305
|
|
|
|
|
306
|
|
|
$aItem->parent_name = $parent_data[$aItem->id]['parent_name']; |
|
307
|
|
|
if(!empty($parent_data[$aItem->id]['parent_name_owner'])) { |
|
308
|
|
|
$aItem->parent_name_owner = $parent_data[$aItem->id]['parent_name_owner']; |
|
309
|
|
|
$aItem->parent_name_mod = $parent_data[$aItem->id]['parent_name_mod']; |
|
310
|
|
|
}} |
|
311
|
|
|
$fields = $aItem->get_list_view_data(); |
|
312
|
|
|
if(isset($processed_ids[$aItem->id])) { |
|
313
|
|
|
continue; |
|
314
|
|
|
|
|
315
|
|
|
} else { |
|
316
|
|
|
$processed_ids[$aItem->id] = 1; |
|
317
|
|
|
} |
|
318
|
|
|
|
|
319
|
|
|
|
|
320
|
|
|
//ADD OFFSET TO ARRAY |
|
321
|
|
|
$fields['OFFSET'] = ($offset + $count + 1); |
|
322
|
|
|
|
|
323
|
|
|
if($this->shouldProcess) { |
|
324
|
|
|
if($aItem->ACLAccess('EditView')) { |
|
325
|
|
|
$this->xTemplate->assign('PREROW', "<input type='checkbox' class='checkbox' name='mass[]' value='". $fields['ID']. "' />"); |
|
326
|
|
|
} else { |
|
327
|
|
|
$this->xTemplate->assign('PREROW', ''); |
|
328
|
|
|
|
|
329
|
|
|
} |
|
330
|
|
|
if($aItem->ACLAccess('DetailView')) { |
|
331
|
|
|
$this->xTemplate->assign('TAG_NAME','a'); |
|
332
|
|
|
} else { |
|
333
|
|
|
$this->xTemplate->assign('TAG_NAME','span'); |
|
334
|
|
|
} |
|
335
|
|
|
$this->xTemplate->assign('CHECKALL', "<input type='checkbox' title='".$GLOBALS['app_strings']['LBL_SELECT_ALL_TITLE']."' class='checkbox' name='massall' id='massall' value='' onclick='sListView.check_all(document.MassUpdate, \"mass[]\", this.checked);' />"); |
|
336
|
|
|
} |
|
337
|
|
|
|
|
338
|
|
|
if($oddRow) |
|
339
|
|
|
{ |
|
340
|
|
|
$ROW_COLOR = 'oddListRow'; |
|
341
|
|
|
$BG_COLOR = $odd_bg; |
|
342
|
|
|
} |
|
343
|
|
|
else |
|
344
|
|
|
{ |
|
345
|
|
|
$ROW_COLOR = 'evenListRow'; |
|
346
|
|
|
$BG_COLOR = $even_bg; |
|
347
|
|
|
} |
|
348
|
|
|
$oddRow = !$oddRow; |
|
349
|
|
|
$button_contents = array(); |
|
350
|
|
|
$this->xTemplate->assign("ROW_COLOR", $ROW_COLOR); |
|
351
|
|
|
$this->xTemplate->assign("BG_COLOR", $BG_COLOR); |
|
352
|
|
|
$layout_manager = $this->getLayoutManager(); |
|
353
|
|
|
$layout_manager->setAttribute('context','List'); |
|
354
|
|
|
$layout_manager->setAttribute('image_path',$this->local_image_path); |
|
355
|
|
|
$layout_manager->setAttribute('module_name', $subpanel_def->_instance_properties['module']); |
|
356
|
|
|
if(!empty($this->child_focus)) |
|
357
|
|
|
$layout_manager->setAttribute('related_module_name',$this->child_focus->module_dir); |
|
358
|
|
|
|
|
359
|
|
|
//AG$subpanel_data = $this->list_field_defs; |
|
360
|
|
|
//$bla = array_pop($subpanel_data); |
|
361
|
|
|
//select which sub-panel to display here, the decision will be made based on the type of |
|
362
|
|
|
//the sub-panel and panel in the bean being processed. |
|
363
|
|
|
if($subpanel_def->isCollection()) { |
|
364
|
|
|
$thepanel=$subpanel_def->sub_subpanels[$aItem->panel_name]; |
|
365
|
|
|
} else { |
|
366
|
|
|
$thepanel=$subpanel_def; |
|
367
|
|
|
} |
|
368
|
|
|
|
|
369
|
|
|
/* BEGIN - SECURITY GROUPS */ |
|
370
|
|
|
|
|
371
|
|
|
//This check is costly doing it field by field in the below foreach |
|
372
|
|
|
//instead pull up here and do once per record.... |
|
373
|
|
|
$aclaccess_is_owner = false; |
|
374
|
|
|
$aclaccess_in_group = false; |
|
375
|
|
|
|
|
376
|
|
|
global $current_user; |
|
377
|
|
|
if(is_admin($current_user)) { |
|
378
|
|
|
$aclaccess_is_owner = true; |
|
379
|
|
|
} else { |
|
380
|
|
|
$aclaccess_is_owner = $aItem->isOwner($current_user->id); |
|
381
|
|
|
} |
|
382
|
|
|
|
|
383
|
|
|
require_once("modules/SecurityGroups/SecurityGroup.php"); |
|
384
|
|
|
$aclaccess_in_group = SecurityGroup::groupHasAccess($aItem->module_dir,$aItem->id); |
|
385
|
|
|
|
|
386
|
|
|
/* END - SECURITY GROUPS */ |
|
387
|
|
|
|
|
388
|
|
|
//get data source name |
|
389
|
|
|
$linked_field=$thepanel->get_data_source_name(); |
|
390
|
|
|
$linked_field_set=$thepanel->get_data_source_name(true); |
|
391
|
|
|
static $count; |
|
392
|
|
|
if(!isset($count))$count = 0; |
|
393
|
|
|
/* BEGIN - SECURITY GROUPS */ |
|
394
|
|
|
/** |
|
395
|
|
|
$field_acl['DetailView'] = $aItem->ACLAccess('DetailView'); |
|
396
|
|
|
$field_acl['ListView'] = $aItem->ACLAccess('ListView'); |
|
397
|
|
|
$field_acl['EditView'] = $aItem->ACLAccess('EditView'); |
|
398
|
|
|
$field_acl['Delete'] = $aItem->ACLAccess('Delete'); |
|
399
|
|
|
*/ |
|
400
|
|
|
//pass is_owner, in_group...vars defined above |
|
401
|
|
|
$field_acl['DetailView'] = $aItem->ACLAccess('DetailView',$aclaccess_is_owner,$aclaccess_in_group); |
|
402
|
|
|
$field_acl['ListView'] = $aItem->ACLAccess('ListView',$aclaccess_is_owner,$aclaccess_in_group); |
|
403
|
|
|
$field_acl['EditView'] = $aItem->ACLAccess('EditView',$aclaccess_is_owner,$aclaccess_in_group); |
|
404
|
|
|
$field_acl['Delete'] = $aItem->ACLAccess('Delete',$aclaccess_is_owner,$aclaccess_in_group); |
|
405
|
|
|
/* END - SECURITY GROUPS */ |
|
406
|
|
|
foreach($thepanel->get_list_fields() as $field_name=>$list_field) |
|
407
|
|
|
{ |
|
408
|
|
|
//add linked field attribute to the array. |
|
409
|
|
|
$list_field['linked_field']=$linked_field; |
|
410
|
|
|
$list_field['linked_field_set']=$linked_field_set; |
|
411
|
|
|
|
|
412
|
|
|
$usage = empty($list_field['usage']) ? '' : $list_field['usage']; |
|
413
|
|
|
if($usage == 'query_only' && !empty($list_field['force_query_only_display'])){ |
|
414
|
|
|
//if you are here you have column that is query only but needs to be displayed as blank. This is helpful |
|
415
|
|
|
//for collections such as Activities where you have a field in only one object and wish to show it in the subpanel list |
|
416
|
|
|
$count++; |
|
417
|
|
|
$widget_contents = ' '; |
|
418
|
|
|
$this->xTemplate->assign('CLASS', ""); |
|
419
|
|
|
$this->xTemplate->assign('CELL_COUNT', $count); |
|
420
|
|
|
$this->xTemplate->assign('CELL', $widget_contents); |
|
421
|
|
|
$this->xTemplate->parse($xtemplateSection.".row.cell"); |
|
422
|
|
|
|
|
423
|
|
|
}else if($usage != 'query_only') |
|
424
|
|
|
{ |
|
425
|
|
|
$list_field['name']=$field_name; |
|
426
|
|
|
|
|
427
|
|
|
$module_field = $field_name.'_mod'; |
|
428
|
|
|
$owner_field = $field_name.'_owner'; |
|
429
|
|
|
if(!empty($aItem->$module_field)) { |
|
430
|
|
|
|
|
431
|
|
|
$list_field['owner_id'] = $aItem->$owner_field; |
|
432
|
|
|
$list_field['owner_module'] = $aItem->$module_field; |
|
433
|
|
|
|
|
434
|
|
|
} else { |
|
435
|
|
|
$list_field['owner_id'] = false; |
|
436
|
|
|
$list_field['owner_module'] = false; |
|
437
|
|
|
} |
|
438
|
|
|
if(isset($list_field['alias'])) $list_field['name'] = $list_field['alias']; |
|
439
|
|
|
else $list_field['name']=$field_name; |
|
440
|
|
|
$list_field['fields'] = $fields; |
|
441
|
|
|
$list_field['module'] = $aItem->module_dir; |
|
442
|
|
|
$list_field['start_link_wrapper'] = $this->start_link_wrapper; |
|
443
|
|
|
$list_field['end_link_wrapper'] = $this->end_link_wrapper; |
|
444
|
|
|
$list_field['subpanel_id'] = $this->subpanel_id; |
|
445
|
|
|
$list_field += $field_acl; |
|
446
|
|
|
if ( isset($aItem->field_defs[strtolower($list_field['name'])])) { |
|
447
|
|
|
require_once('include/SugarFields/SugarFieldHandler.php'); |
|
448
|
|
|
// We need to see if a sugar field exists for this field type first, |
|
449
|
|
|
// if it doesn't, toss it at the old sugarWidgets. This is for |
|
450
|
|
|
// backwards compatibility and will be removed in a future release |
|
451
|
|
|
$vardef = $aItem->field_defs[strtolower($list_field['name'])]; |
|
452
|
|
|
if ( isset($vardef['type']) ) { |
|
453
|
|
|
$fieldType = isset($vardef['custom_type'])?$vardef['custom_type']:$vardef['type']; |
|
454
|
|
|
$tmpField = SugarFieldHandler::getSugarField($fieldType,true); |
|
455
|
|
|
} else { |
|
456
|
|
|
$tmpField = NULL; |
|
457
|
|
|
} |
|
458
|
|
|
|
|
459
|
|
|
if ( $tmpField != NULL ) { |
|
460
|
|
|
$widget_contents = SugarFieldHandler::displaySmarty($list_field['fields'],$vardef,'ListView',$list_field); |
|
461
|
|
|
} else { |
|
462
|
|
|
// No SugarField for this particular type |
|
463
|
|
|
// Use the old, icky, SugarWidget for now |
|
464
|
|
|
$widget_contents = $layout_manager->widgetDisplay($list_field); |
|
465
|
|
|
} |
|
466
|
|
|
|
|
467
|
|
|
if ( isset($list_field['widget_class']) && $list_field['widget_class'] == 'SubPanelDetailViewLink' ) { |
|
468
|
|
|
// We need to call into the old SugarWidgets for the time being, so it can generate a proper link with all the various corner-cases handled |
|
469
|
|
|
// So we'll populate the field data with the pre-rendered display for the field |
|
470
|
|
|
$list_field['fields'][$field_name] = $widget_contents; |
|
471
|
|
|
if('full_name' == $field_name){//bug #32465 |
|
472
|
|
|
$list_field['fields'][strtoupper($field_name)] = $widget_contents; |
|
473
|
|
|
} |
|
474
|
|
|
|
|
475
|
|
|
//vardef source is non db, assign the field name to varname for processing of column. |
|
476
|
|
|
if(!empty($vardef['source']) && $vardef['source']=='non-db'){ |
|
477
|
|
|
$list_field['varname'] = $field_name; |
|
478
|
|
|
|
|
479
|
|
|
} |
|
480
|
|
|
$widget_contents = $layout_manager->widgetDisplay($list_field); |
|
481
|
|
|
} else if(isset($list_field['widget_class']) && $list_field['widget_class'] == 'SubPanelEmailLink' ) { |
|
482
|
|
|
$widget_contents = $layout_manager->widgetDisplay($list_field); |
|
483
|
|
|
} |
|
484
|
|
|
|
|
485
|
|
|
$count++; |
|
486
|
|
|
$this->xTemplate->assign('CELL_COUNT', $count); |
|
487
|
|
|
$this->xTemplate->assign('CLASS', ""); |
|
488
|
|
|
if ( empty($widget_contents) ) $widget_contents = ' '; |
|
489
|
|
|
$this->xTemplate->assign('CELL', $widget_contents); |
|
490
|
|
|
$this->xTemplate->parse($xtemplateSection.".row.cell"); |
|
491
|
|
|
} else { |
|
492
|
|
|
// This handles the edit and remove buttons and icon widget |
|
493
|
|
|
if( isset($list_field['widget_class']) && $list_field['widget_class'] == "SubPanelIcon") { |
|
494
|
|
|
$count++; |
|
495
|
|
|
$widget_contents = $layout_manager->widgetDisplay($list_field); |
|
496
|
|
|
$this->xTemplate->assign('CELL_COUNT', $count); |
|
497
|
|
|
$this->xTemplate->assign('CLASS', ""); |
|
498
|
|
|
if ( empty($widget_contents) ) $widget_contents = ' '; |
|
499
|
|
|
$this->xTemplate->assign('CELL', $widget_contents); |
|
500
|
|
|
$this->xTemplate->parse($xtemplateSection.".row.cell"); |
|
501
|
|
|
} elseif (preg_match("/button/i", $list_field['name'])) { |
|
502
|
|
|
if ((($list_field['name'] === 'edit_button' && $field_acl['EditView']) || ($list_field['name'] === 'close_button' && $field_acl['EditView']) || ($list_field['name'] === 'remove_button' && $field_acl['Delete'])) && '' != ($_content = $layout_manager->widgetDisplay($list_field)) ) |
|
503
|
|
|
{ |
|
504
|
|
|
$button_contents[] = $_content; |
|
505
|
|
|
unset($_content); |
|
506
|
|
|
} |
|
507
|
|
|
else |
|
508
|
|
|
{ |
|
509
|
|
|
$button_contents[] = ''; |
|
510
|
|
|
} |
|
511
|
|
|
} else { |
|
512
|
|
|
$count++; |
|
513
|
|
|
$this->xTemplate->assign('CLASS', ""); |
|
514
|
|
|
$widget_contents = $layout_manager->widgetDisplay($list_field); |
|
515
|
|
|
$this->xTemplate->assign('CELL_COUNT', $count); |
|
516
|
|
|
if ( empty($widget_contents) ) $widget_contents = ' '; |
|
517
|
|
|
$this->xTemplate->assign('CELL', $widget_contents); |
|
518
|
|
|
$this->xTemplate->parse($xtemplateSection.".row.cell"); |
|
519
|
|
|
} |
|
520
|
|
|
} |
|
521
|
|
|
|
|
522
|
|
|
} |
|
523
|
|
|
} |
|
524
|
|
|
|
|
525
|
|
|
|
|
526
|
|
|
// Make sure we have at least one button before rendering a column for |
|
527
|
|
|
// the action buttons in a list view. Relevant bugs: #51647 and #51640. |
|
528
|
|
|
if(!empty($button_contents)) |
|
529
|
|
|
{ |
|
530
|
|
|
$button_contents = array_filter($button_contents); |
|
531
|
|
|
if (!empty($button_contents)) |
|
532
|
|
|
{ |
|
533
|
|
|
// this is for inline buttons on listviews |
|
534
|
|
|
// bug#51275: smarty widget to help provide the action menu functionality as it is currently sprinkled throughout the app with html |
|
535
|
|
|
require_once('include/Smarty/plugins/function.sugar_action_menu.php'); |
|
536
|
|
|
$tempid = create_guid(); |
|
537
|
|
|
array_unshift($button_contents, "<div style='display: inline' id='$tempid'>" . array_shift($button_contents) . "</div>"); |
|
538
|
|
|
$action_button = smarty_function_sugar_action_menu(array( |
|
539
|
|
|
'id' => $tempid, |
|
540
|
|
|
'buttons' => $button_contents, |
|
541
|
|
|
'class' => 'clickMenu subpanel records fancymenu button', |
|
542
|
|
|
'flat' => false //assign flat value as false to display dropdown menu at any other preferences. |
|
543
|
|
|
), $this->xTemplate); |
|
544
|
|
|
} |
|
545
|
|
|
else |
|
546
|
|
|
{ |
|
547
|
|
|
$action_button = ''; |
|
548
|
|
|
} |
|
549
|
|
|
$this->xTemplate->assign('CLASS', "inlineButtons"); |
|
550
|
|
|
$this->xTemplate->assign('CELL_COUNT', ++$count); |
|
551
|
|
|
//Bug#51275 for beta3 pre_script is not required any more |
|
552
|
|
|
$this->xTemplate->assign('CELL', $action_button); |
|
553
|
|
|
$this->xTemplate->parse($xtemplateSection . ".row.cell"); |
|
554
|
|
|
} |
|
555
|
|
|
|
|
556
|
|
|
|
|
557
|
|
|
$aItem->setupCustomFields($aItem->module_dir); |
|
558
|
|
|
$aItem->custom_fields->populateAllXTPL($this->xTemplate, 'detail', $html_varName, $fields); |
|
559
|
|
|
|
|
560
|
|
|
$count++; |
|
561
|
|
|
|
|
562
|
|
|
$this->xTemplate->parse($xtemplateSection.".row"); |
|
563
|
|
|
} |
|
564
|
|
|
|
|
565
|
|
|
$this->xTemplate->parse($xtemplateSection); |
|
566
|
|
|
} |
|
567
|
|
|
|
|
568
|
|
|
/**sets whether or not to display the xtemplate header and footer |
|
569
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
570
|
|
|
* All Rights Reserved. |
|
571
|
|
|
* Contributor(s): ______________________________________. |
|
572
|
|
|
*/ |
|
573
|
|
|
function setDisplayHeaderAndFooter($bool) { |
|
574
|
|
|
$this->display_header_and_footer = $bool; |
|
575
|
|
|
} |
|
576
|
|
|
|
|
577
|
|
|
/**initializes ListView |
|
578
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
579
|
|
|
* All Rights Reserved. |
|
580
|
|
|
* Contributor(s): ______________________________________. |
|
581
|
|
|
*/ |
|
582
|
|
|
function __construct() { |
|
583
|
|
|
|
|
584
|
|
|
|
|
585
|
|
|
if(!$this->initialized) { |
|
586
|
|
|
global $sugar_config; |
|
587
|
|
|
$this->records_per_page = $sugar_config['list_max_entries_per_page'] + 0; |
|
588
|
|
|
$this->initialized = true; |
|
589
|
|
|
global $app_strings, $currentModule; |
|
590
|
|
|
$this->local_theme = SugarThemeRegistry::current()->__toString(); |
|
591
|
|
|
$this->local_app_strings =$app_strings; |
|
592
|
|
|
$this->local_image_path = SugarThemeRegistry::current()->getImagePath(); |
|
593
|
|
|
$this->local_current_module = $currentModule; |
|
594
|
|
|
} |
|
595
|
|
|
} |
|
596
|
|
|
|
|
597
|
|
|
|
|
598
|
|
|
/** |
|
599
|
|
|
* @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead |
|
600
|
|
|
*/ |
|
601
|
|
|
function ListView(){ |
|
602
|
|
|
$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
|
603
|
|
|
if(isset($GLOBALS['log'])) { |
|
604
|
|
|
$GLOBALS['log']->deprecated($deprecatedMessage); |
|
605
|
|
|
} |
|
606
|
|
|
else { |
|
607
|
|
|
trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
|
608
|
|
|
} |
|
609
|
|
|
self::__construct(); |
|
610
|
|
|
} |
|
611
|
|
|
|
|
612
|
|
|
/**sets how many records should be displayed per page in the list view |
|
613
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
614
|
|
|
* All Rights Reserved. |
|
615
|
|
|
* Contributor(s): ______________________________________. |
|
616
|
|
|
*/ |
|
617
|
|
|
function setRecordsPerPage($count) { |
|
618
|
|
|
$this->records_per_page = $count; |
|
619
|
|
|
} |
|
620
|
|
|
/**sets the header title */ |
|
621
|
|
|
function setHeaderTitle($value) { |
|
622
|
|
|
$this->header_title = $value; |
|
623
|
|
|
} |
|
624
|
|
|
/**sets the header text this is text that's appended to the header table and is usually used for the creation of buttons |
|
625
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
626
|
|
|
* All Rights Reserved. |
|
627
|
|
|
* Contributor(s): ______________________________________. |
|
628
|
|
|
*/ |
|
629
|
|
|
function setHeaderText($value) { |
|
630
|
|
|
$this->header_text = $value; |
|
631
|
|
|
} |
|
632
|
|
|
/**sets the path for the XTemplate HTML file to be used this is only needed to be set if you are allowing ListView to create the XTemplate |
|
633
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
634
|
|
|
* All Rights Reserved. |
|
635
|
|
|
* Contributor(s): ______________________________________. |
|
636
|
|
|
*/ |
|
637
|
|
|
function setXTemplatePath($value) { |
|
638
|
|
|
$this->xTemplatePath= $value; |
|
639
|
|
|
} |
|
640
|
|
|
|
|
641
|
|
|
/**this is a helper function for allowing ListView to create a new XTemplate it groups parameters that should be set into a single function |
|
642
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
643
|
|
|
* All Rights Reserved. |
|
644
|
|
|
* Contributor(s): ______________________________________. |
|
645
|
|
|
*/ |
|
646
|
|
|
function initNewXTemplate($XTemplatePath, $modString, $imagePath = null) { |
|
647
|
|
|
$this->setXTemplatePath($XTemplatePath); |
|
648
|
|
|
if(isset($modString)) |
|
649
|
|
|
$this->setModStrings($modString); |
|
650
|
|
|
if(isset($imagePath)) |
|
651
|
|
|
$this->setImagePath($imagePath); |
|
652
|
|
|
} |
|
653
|
|
|
|
|
654
|
|
|
|
|
655
|
|
|
function getOrderBy($varName, $defaultOrderBy='', $force_sortorder='') { |
|
656
|
|
|
$sortBy = $this->getSessionVariable($varName, "ORDER_BY") ; |
|
657
|
|
|
|
|
658
|
|
|
$orderByDirection = $this->getSessionVariableName($varName, "order_by_direction"); |
|
659
|
|
|
$orderByColumn = $this->getSessionVariableName($varName, "ORDER_BY"); |
|
660
|
|
|
$lastEqualsSortBy = false; |
|
661
|
|
|
$defaultOrder = false; //ascending |
|
662
|
|
|
|
|
663
|
|
|
if(empty($sortBy)) { |
|
664
|
|
|
$this->setUserVariable($varName, "ORDER_BY", $defaultOrderBy); |
|
665
|
|
|
$sortBy = $defaultOrderBy; |
|
666
|
|
|
} else { |
|
667
|
|
|
$this->setUserVariable($varName, "ORDER_BY", $sortBy); |
|
668
|
|
|
} |
|
669
|
|
|
|
|
670
|
|
|
$desc = $this->getSessionVariable($varName, $sortBy."S"); |
|
671
|
|
|
|
|
672
|
|
|
if (empty($desc)) |
|
673
|
|
|
{ |
|
674
|
|
|
$desc = $defaultOrder; |
|
675
|
|
|
} |
|
676
|
|
|
$defaultOrder = $desc ? 'desc' : 'asc'; |
|
677
|
|
|
$orderByValue = $defaultOrder; |
|
678
|
|
|
if (isset($_REQUEST[$orderByDirection])) |
|
679
|
|
|
{ |
|
680
|
|
|
$possibleRequestOrderBy = $_REQUEST[$orderByDirection]; |
|
681
|
|
|
if ($possibleRequestOrderBy == 'asc' || $possibleRequestOrderBy == 'desc') |
|
682
|
|
|
{ |
|
683
|
|
|
$orderByValue = $possibleRequestOrderBy; |
|
684
|
|
|
} |
|
685
|
|
|
} |
|
686
|
|
|
|
|
687
|
|
|
if (isset($_REQUEST[$orderByColumn])) |
|
688
|
|
|
{ |
|
689
|
|
|
$last = $this->getSessionVariable($varName, "OBL"); |
|
690
|
|
|
} |
|
691
|
|
|
if (!empty($last) && $last == $sortBy) |
|
692
|
|
|
{ |
|
693
|
|
|
$lastEqualsSortBy = true; |
|
694
|
|
|
} else |
|
695
|
|
|
{ |
|
696
|
|
|
$orderByValue = $defaultOrder; |
|
697
|
|
|
$this->setSessionVariable($varName, "OBL", $sortBy); |
|
698
|
|
|
} |
|
699
|
|
|
$desc = $orderByValue == 'desc'; |
|
700
|
|
|
$orderByDirectionValue = false; |
|
701
|
|
|
$this->setSessionVariable($varName, $sortBy . "S", $desc); |
|
702
|
|
|
if (!empty($sortBy)) |
|
703
|
|
|
{ |
|
704
|
|
|
if (empty($force_sortorder)) |
|
705
|
|
|
{ |
|
706
|
|
|
if (substr_count(strtolower($sortBy), ' desc') == 0 && substr_count(strtolower($sortBy), ' asc') == 0) |
|
707
|
|
|
{ |
|
708
|
|
|
if ($sortBy) |
|
709
|
|
|
{ |
|
710
|
|
|
$orderByDirectionValue = $desc ? 'asc' : 'desc'; |
|
711
|
|
|
} |
|
712
|
|
|
$this->query_orderby = $sortBy . ' ' . $orderByValue; |
|
713
|
|
|
} |
|
714
|
|
|
} else |
|
715
|
|
|
{ |
|
716
|
|
|
$this->query_orderby = $sortBy . ' ' . $force_sortorder; |
|
717
|
|
|
} |
|
718
|
|
|
if (!isset($this->appendToBaseUrl)) |
|
719
|
|
|
{ |
|
720
|
|
|
$this->appendToBaseUrl = array(); |
|
721
|
|
|
} |
|
722
|
|
|
if ($orderByDirectionValue) |
|
723
|
|
|
{ |
|
724
|
|
|
$this->appendToBaseUrl[$orderByDirection] = $orderByDirectionValue; |
|
725
|
|
|
} |
|
726
|
|
|
$offsetVar = $this->getSessionVariableName($varName, "offset"); |
|
727
|
|
|
if (isset($_REQUEST[$offsetVar])) |
|
728
|
|
|
{ |
|
729
|
|
|
$this->appendToBaseUrl[$offsetVar] = $_REQUEST[$offsetVar]; |
|
730
|
|
|
} |
|
731
|
|
|
//Just clear from url... |
|
732
|
|
|
$this->appendToBaseUrl[$orderByColumn] = false; |
|
733
|
|
|
}else { |
|
734
|
|
|
$this->query_orderby = ""; |
|
735
|
|
|
} |
|
736
|
|
|
$this->sortby = $sortBy; |
|
737
|
|
|
return $this->query_orderby; |
|
738
|
|
|
|
|
739
|
|
|
} |
|
740
|
|
|
|
|
741
|
|
|
|
|
742
|
|
|
/**sets the parameters dealing with the db |
|
743
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
744
|
|
|
* All Rights Reserved. |
|
745
|
|
|
* Contributor(s): ______________________________________. |
|
746
|
|
|
*/ |
|
747
|
|
|
function setQuery($where, $limit, $orderBy, $varName, $allowOrderByOveride=true) { |
|
748
|
|
|
$this->query_where = $where; |
|
749
|
|
|
if($this->getSessionVariable("query", "where") != $where) { |
|
750
|
|
|
$this->query_where_has_changed = true; |
|
751
|
|
|
$this->setSessionVariable("query", "where", $where); |
|
752
|
|
|
} |
|
753
|
|
|
|
|
754
|
|
|
$this->query_limit = $limit; |
|
755
|
|
|
if(!$allowOrderByOveride) { |
|
756
|
|
|
$this->query_orderby = $orderBy; |
|
757
|
|
|
return; |
|
758
|
|
|
} |
|
759
|
|
|
$this->getOrderBy($varName, $orderBy); |
|
760
|
|
|
|
|
761
|
|
|
$this->setLocalSessionVariable($varName, "QUERY_WHERE", $where); |
|
762
|
|
|
|
|
763
|
|
|
//SETTING ORDER_BY FOR USE IN DETAILVIEW |
|
764
|
|
|
$this->setLocalSessionVariable($varName, "ORDER_BY_DETAIL", $this->query_orderby); |
|
765
|
|
|
} |
|
766
|
|
|
|
|
767
|
|
|
function displayArrow() { |
|
768
|
|
|
|
|
769
|
|
|
} |
|
770
|
|
|
|
|
771
|
|
|
/**sets the theme used only use if it is different from the global |
|
772
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
773
|
|
|
* All Rights Reserved. |
|
774
|
|
|
* Contributor(s): ______________________________________. |
|
775
|
|
|
*/ |
|
776
|
|
|
function setTheme($theme) { |
|
777
|
|
|
$this->local_theme = $theme; |
|
778
|
|
|
if(isset($this->xTemplate))$this->xTemplate->assign("THEME", $this->local_theme); |
|
779
|
|
|
} |
|
780
|
|
|
|
|
781
|
|
|
/**sets the AppStrings used only use if it is different from the global |
|
782
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
783
|
|
|
* All Rights Reserved. |
|
784
|
|
|
* Contributor(s): ______________________________________. |
|
785
|
|
|
*/ |
|
786
|
|
|
function setAppStrings($app_strings) { |
|
787
|
|
|
unset($this->local_app_strings); |
|
788
|
|
|
$this->local_app_strings = $app_strings; |
|
789
|
|
|
if(isset($this->xTemplate))$this->xTemplate->assign("APP", $this->local_app_strings); |
|
790
|
|
|
} |
|
791
|
|
|
|
|
792
|
|
|
/**sets the ModStrings used |
|
793
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
794
|
|
|
* All Rights Reserved. |
|
795
|
|
|
* Contributor(s): ______________________________________. |
|
796
|
|
|
*/ |
|
797
|
|
|
function setModStrings($mod_strings) { |
|
798
|
|
|
unset($this->local_module_strings); |
|
799
|
|
|
$this->local_mod_strings = $mod_strings; |
|
800
|
|
|
if(isset($this->xTemplate))$this->xTemplate->assign("MOD", $this->local_mod_strings); |
|
801
|
|
|
} |
|
802
|
|
|
|
|
803
|
|
|
/**sets the ImagePath used |
|
804
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
805
|
|
|
* All Rights Reserved. |
|
806
|
|
|
* Contributor(s): ______________________________________. |
|
807
|
|
|
*/ |
|
808
|
|
|
function setImagePath($image_path) { |
|
809
|
|
|
$this->local_image_path = $image_path; |
|
810
|
|
|
if(empty($this->local_image_path)) { |
|
811
|
|
|
$this->local_image_path = SugarThemeRegistry::get($this->local_theme)->getImagePath(); |
|
812
|
|
|
} |
|
813
|
|
|
if(isset($this->xTemplate))$this->xTemplate->assign("IMAGE_PATH", $this->local_image_path); |
|
814
|
|
|
} |
|
815
|
|
|
|
|
816
|
|
|
/**sets the currentModule only use if this is different from the global |
|
817
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
818
|
|
|
* All Rights Reserved. |
|
819
|
|
|
* Contributor(s): ______________________________________. |
|
820
|
|
|
*/ |
|
821
|
|
|
function setCurrentModule($currentModule) { |
|
822
|
|
|
unset($this->local_current_module); |
|
823
|
|
|
$this->local_current_module = $currentModule; |
|
824
|
|
|
if(isset($this->xTemplate))$this->xTemplate->assign("MODULE_NAME", $this->local_current_module); |
|
825
|
|
|
} |
|
826
|
|
|
|
|
827
|
|
|
/**INTERNAL FUNCTION creates an XTemplate DO NOT CALL THIS THIS IS AN INTERNAL FUNCTION |
|
828
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
829
|
|
|
* All Rights Reserved. |
|
830
|
|
|
* Contributor(s): ______________________________________. |
|
831
|
|
|
*/ |
|
832
|
|
|
function createXTemplate() { |
|
833
|
|
|
if(!isset($this->xTemplate)) { |
|
834
|
|
|
if(isset($this->xTemplatePath)) { |
|
835
|
|
|
|
|
836
|
|
|
$this->xTemplate = new XTemplate($this->xTemplatePath); |
|
837
|
|
|
$this->xTemplate->assign("APP", $this->local_app_strings); |
|
838
|
|
|
if(isset($this->local_mod_strings))$this->xTemplate->assign("MOD", $this->local_mod_strings); |
|
839
|
|
|
$this->xTemplate->assign("THEME", $this->local_theme); |
|
840
|
|
|
$this->xTemplate->assign("IMAGE_PATH", $this->local_image_path); |
|
841
|
|
|
$this->xTemplate->assign("MODULE_NAME", $this->local_current_module); |
|
842
|
|
|
} else { |
|
843
|
|
|
$GLOBALS['log']->error("NO XTEMPLATEPATH DEFINED CANNOT CREATE XTEMPLATE"); |
|
844
|
|
|
} |
|
845
|
|
|
} |
|
846
|
|
|
} |
|
847
|
|
|
|
|
848
|
|
|
/**sets the XTemplate telling ListView to use newXTemplate as its current XTemplate |
|
849
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
850
|
|
|
* All Rights Reserved. |
|
851
|
|
|
* Contributor(s): ______________________________________. |
|
852
|
|
|
*/ |
|
853
|
|
|
function setXTemplate($newXTemplate) { |
|
854
|
|
|
$this->xTemplate = $newXTemplate; |
|
855
|
|
|
} |
|
856
|
|
|
|
|
857
|
|
|
/**returns the XTemplate |
|
858
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
859
|
|
|
* All Rights Reserved. |
|
860
|
|
|
* Contributor(s): ______________________________________. |
|
861
|
|
|
*/ |
|
862
|
|
|
function getXTemplate() { |
|
863
|
|
|
return $this->xTemplate; |
|
864
|
|
|
} |
|
865
|
|
|
|
|
866
|
|
|
/**assigns a name value pair to the XTemplate |
|
867
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
868
|
|
|
* All Rights Reserved. |
|
869
|
|
|
* Contributor(s): ______________________________________. |
|
870
|
|
|
*/ |
|
871
|
|
|
function xTemplateAssign($name, $value) { |
|
872
|
|
|
|
|
873
|
|
|
if(!isset($this->xTemplate)) { |
|
874
|
|
|
$this->createXTemplate(); |
|
875
|
|
|
} |
|
876
|
|
|
$this->xTemplate->assign($name, $value); |
|
877
|
|
|
|
|
878
|
|
|
} |
|
879
|
|
|
|
|
880
|
|
|
/**INTERNAL FUNCTION returns the offset first checking the query then checking the session if the where clause has changed from the last time it returns 0 |
|
881
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
882
|
|
|
* All Rights Reserved. |
|
883
|
|
|
* Contributor(s): ______________________________________. |
|
884
|
|
|
*/ |
|
885
|
|
|
function getOffset($localVarName) { |
|
886
|
|
|
if($this->query_where_has_changed || isset($GLOBALS['record_has_changed'])) { |
|
887
|
|
|
$this->setSessionVariable($localVarName,"offset", 0); |
|
888
|
|
|
} |
|
889
|
|
|
$offset = $this->getSessionVariable($localVarName,"offset"); |
|
890
|
|
|
if(isset($offset)) { |
|
891
|
|
|
return $offset; |
|
892
|
|
|
} |
|
893
|
|
|
return 0; |
|
894
|
|
|
} |
|
895
|
|
|
|
|
896
|
|
|
/**INTERNAL FUNCTION sets the offset in the session |
|
897
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
898
|
|
|
* All Rights Reserved. |
|
899
|
|
|
* Contributor(s): ______________________________________. |
|
900
|
|
|
*/ |
|
901
|
|
|
function setOffset($localVarName, $value) { |
|
902
|
|
|
$this->setSessionVariable($localVarName, "offset", $value); |
|
903
|
|
|
} |
|
904
|
|
|
|
|
905
|
|
|
/**INTERNAL FUNCTION sets a session variable |
|
906
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
907
|
|
|
* All Rights Reserved. |
|
908
|
|
|
* Contributor(s): ______________________________________. |
|
909
|
|
|
*/ |
|
910
|
|
|
function setSessionVariable($localVarName,$varName, $value) { |
|
911
|
|
|
$_SESSION[$this->local_current_module."_".$localVarName."_".$varName] = $value; |
|
912
|
|
|
} |
|
913
|
|
|
|
|
914
|
|
|
function setUserVariable($localVarName,$varName, $value) { |
|
915
|
|
|
if($this->is_dynamic || $localVarName == 'CELL')return; |
|
916
|
|
|
global $current_user; |
|
917
|
|
|
$current_user->setPreference($this->local_current_module."_".$localVarName."_".$varName, $value); |
|
918
|
|
|
} |
|
919
|
|
|
|
|
920
|
|
|
/**INTERNAL FUNCTION returns a session variable first checking the query for it then checking the session |
|
921
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
922
|
|
|
* All Rights Reserved. |
|
923
|
|
|
* Contributor(s): ______________________________________. |
|
924
|
|
|
*/ |
|
925
|
|
|
function getSessionVariable($localVarName,$varName) { |
|
926
|
|
|
//Set any variables pass in through request first |
|
927
|
|
|
if(isset($_REQUEST[$this->getSessionVariableName($localVarName, $varName)])) { |
|
928
|
|
|
$this->setSessionVariable($localVarName,$varName,$_REQUEST[$this->getSessionVariableName($localVarName, $varName)]); |
|
929
|
|
|
} |
|
930
|
|
|
|
|
931
|
|
|
if(isset($_SESSION[$this->getSessionVariableName($localVarName, $varName)])) { |
|
932
|
|
|
return $_SESSION[$this->getSessionVariableName($localVarName, $varName)]; |
|
933
|
|
|
} |
|
934
|
|
|
return ""; |
|
935
|
|
|
} |
|
936
|
|
|
|
|
937
|
|
|
function getUserVariable($localVarName, $varName) { |
|
938
|
|
|
global $current_user; |
|
939
|
|
|
if($this->is_dynamic || $localVarName == 'CELL')return; |
|
940
|
|
|
if(isset($_REQUEST[$this->getSessionVariableName($localVarName, $varName)])) { |
|
941
|
|
|
|
|
942
|
|
|
$this->setUserVariable($localVarName,$varName,$_REQUEST[$this->getSessionVariableName($localVarName, $varName)]); |
|
943
|
|
|
} |
|
944
|
|
|
return $current_user->getPreference($this->getSessionVariableName($localVarName, $varName)); |
|
945
|
|
|
} |
|
946
|
|
|
|
|
947
|
|
|
|
|
948
|
|
|
/** |
|
949
|
|
|
* helper method to determine sort order by priority of source |
|
950
|
|
|
* 1. explicit in request object |
|
951
|
|
|
* 2. in session variable |
|
952
|
|
|
* 3. subpaneldefs metadata |
|
953
|
|
|
* 4. default 'asc' |
|
954
|
|
|
* @param array $sortOrderList - contains options |
|
955
|
|
|
* @return string 'asc' | 'desc' |
|
956
|
|
|
*/ |
|
957
|
|
|
function calculateSortOrder($sortOrderList) |
|
958
|
|
|
{ |
|
959
|
|
|
$priority_map = array( |
|
960
|
|
|
'request', |
|
961
|
|
|
'session', |
|
962
|
|
|
'subpaneldefs', |
|
963
|
|
|
'default', |
|
964
|
|
|
); |
|
965
|
|
|
|
|
966
|
|
|
foreach($priority_map as $p) { |
|
967
|
|
|
if (key_exists($p, $sortOrderList)) { |
|
968
|
|
|
$order = strtolower($sortOrderList[$p]); |
|
969
|
|
|
if (in_array($order, array('asc', 'desc'))) { |
|
970
|
|
|
return $order; |
|
971
|
|
|
} |
|
972
|
|
|
} |
|
973
|
|
|
} |
|
974
|
|
|
return 'asc'; |
|
975
|
|
|
} |
|
976
|
|
|
|
|
977
|
|
|
|
|
978
|
|
|
/** |
|
979
|
|
|
|
|
980
|
|
|
* @return void |
|
981
|
|
|
* @param unknown $localVarName |
|
982
|
|
|
* @param unknown $varName |
|
983
|
|
|
* @desc INTERNAL FUNCTION returns the session/query variable name |
|
984
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
985
|
|
|
* All Rights Reserved. |
|
986
|
|
|
* Contributor(s): ______________________________________.. |
|
987
|
|
|
*/ |
|
988
|
|
|
function getSessionVariableName($localVarName,$varName) { |
|
989
|
|
|
return $this->local_current_module."_".$localVarName."_".$varName; |
|
990
|
|
|
} |
|
991
|
|
|
|
|
992
|
|
|
/** |
|
993
|
|
|
|
|
994
|
|
|
* @return void |
|
995
|
|
|
* @param unknown $seed |
|
996
|
|
|
* @param unknown $xTemplateSection |
|
|
|
|
|
|
997
|
|
|
* @param unknown $html_varName |
|
998
|
|
|
* @desc INTERNAL FUNCTION Handles List Views using seeds that extend SugarBean |
|
999
|
|
|
$XTemplateSection is the section in the XTemplate file that should be parsed usually main |
|
1000
|
|
|
$html_VarName is the variable name used in the XTemplateFile e.g. TASK |
|
1001
|
|
|
$seed is a seed that extends SugarBean |
|
1002
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.. |
|
1003
|
|
|
* All Rights Reserved.. |
|
1004
|
|
|
* Contributor(s): ______________________________________.. |
|
1005
|
|
|
*/ |
|
1006
|
|
|
function processSugarBean($xtemplateSection, $html_varName, $seed) { |
|
1007
|
|
|
global $list_view_row_count; |
|
1008
|
|
|
|
|
1009
|
|
|
$current_offset = $this->getOffset($html_varName); |
|
1010
|
|
|
$response = array(); |
|
1011
|
|
|
|
|
1012
|
|
|
//ADDING VCR CONTROL |
|
1013
|
|
|
SugarVCR::erase($seed->module_dir); |
|
1014
|
|
|
$params = array(); |
|
1015
|
|
|
//$filter = array('id', 'full_name'); |
|
1016
|
|
|
$filter=array(); |
|
1017
|
|
|
$ret_array = $seed->create_new_list_query($this->query_orderby, $this->query_where, $filter, $params, 0, '', true, $seed, true); |
|
1018
|
|
|
if(!is_array($params)) $params = array(); |
|
1019
|
|
|
if(!isset($params['custom_select'])) $params['custom_select'] = ''; |
|
1020
|
|
|
if(!isset($params['custom_from'])) $params['custom_from'] = ''; |
|
1021
|
|
|
if(!isset($params['custom_where'])) $params['custom_where'] = ''; |
|
1022
|
|
|
if(!isset($params['custom_order_by'])) $params['custom_order_by'] = ''; |
|
1023
|
|
|
$main_query = $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['where'] . $params['custom_where'] . $ret_array['order_by'] . $params['custom_order_by']; |
|
1024
|
|
|
SugarVCR::store($seed->module_dir, $main_query); |
|
1025
|
|
|
//ADDING VCR CONTROL |
|
1026
|
|
|
|
|
1027
|
|
|
if(empty($this->related_field_name)) { |
|
1028
|
|
|
$response = $seed->get_list($this->query_orderby, $this->query_where, $current_offset, $this->query_limit); |
|
1029
|
|
|
} else { |
|
1030
|
|
|
$related_field_name = $this->related_field_name; |
|
1031
|
|
|
$response = $seed->get_related_list($this->child_focus,$related_field_name, $this->query_orderby, |
|
1032
|
|
|
$this->query_where, $current_offset, $this->query_limit); |
|
1033
|
|
|
} |
|
1034
|
|
|
|
|
1035
|
|
|
$list = $response['list']; |
|
1036
|
|
|
$row_count = $response['row_count']; |
|
1037
|
|
|
$next_offset = $response['next_offset']; |
|
1038
|
|
|
$previous_offset = $response['previous_offset']; |
|
1039
|
|
|
|
|
1040
|
|
|
if(!empty($response['current_offset'])) { |
|
1041
|
|
|
$current_offset = $response['current_offset']; |
|
1042
|
|
|
} |
|
1043
|
|
|
|
|
1044
|
|
|
$list_view_row_count = $row_count; |
|
1045
|
|
|
$this->processListNavigation($xtemplateSection,$html_varName, $current_offset, $next_offset, $previous_offset, $row_count, null, null, empty($seed->column_fields) ? null : count($seed->column_fields)); |
|
1046
|
|
|
|
|
1047
|
|
|
return $list; |
|
1048
|
|
|
} |
|
1049
|
|
|
|
|
1050
|
|
|
|
|
1051
|
|
|
|
|
1052
|
|
|
function processUnionBeans($sugarbean, $subpanel_def, $html_var = 'CELL') { |
|
1053
|
|
|
|
|
1054
|
|
|
$last_detailview_record = $this->getSessionVariable("detailview", "record"); |
|
1055
|
|
|
if(!empty($last_detailview_record) && $last_detailview_record != $sugarbean->id){ |
|
1056
|
|
|
$GLOBALS['record_has_changed'] = true; |
|
1057
|
|
|
} |
|
1058
|
|
|
$this->setSessionVariable("detailview", "record", $sugarbean->id); |
|
1059
|
|
|
|
|
1060
|
|
|
$current_offset = $this->getOffset($html_var); |
|
1061
|
|
|
$module = isset($_REQUEST['module']) ? $_REQUEST['module'] : ''; |
|
1062
|
|
|
$response = array(); |
|
1063
|
|
|
|
|
1064
|
|
|
// choose sort order |
|
1065
|
|
|
$sort_order = array(); |
|
1066
|
|
|
$sort_order['default'] = 'asc'; |
|
1067
|
|
|
|
|
1068
|
|
|
// explicit request parameter gets priority over all |
|
1069
|
|
|
$sort_order['request'] = isset($_REQUEST['sort_order']) ? $_REQUEST['sort_order'] : null; |
|
1070
|
|
|
|
|
1071
|
|
|
// see if the session data has a sort order |
|
1072
|
|
|
if (isset($_SESSION['last_sub' . $this->subpanel_module . '_order'])) |
|
1073
|
|
|
{ |
|
1074
|
|
|
$sort_order['session'] = $_SESSION['last_sub' . $this->subpanel_module . '_order']; |
|
1075
|
|
|
|
|
1076
|
|
|
// We swap the order when the request contains an offset (indicating a column sort issued); |
|
1077
|
|
|
// otherwise we do not sort. If we don't make this check, then the subpanel listview will |
|
1078
|
|
|
// swap ordering each time a new record is entered via quick create forms |
|
1079
|
|
|
if (isset($_REQUEST[$module . '_' . $html_var . '_offset'])) |
|
1080
|
|
|
{ |
|
1081
|
|
|
$sort_order['session'] = $sort_order['session'] == 'asc' ? 'desc' : 'asc'; |
|
1082
|
|
|
} |
|
1083
|
|
|
} |
|
1084
|
|
|
else |
|
1085
|
|
|
{ |
|
1086
|
|
|
$sort_order['session'] = null; |
|
1087
|
|
|
} |
|
1088
|
|
|
|
|
1089
|
|
|
// does the metadata have a default sort order? |
|
1090
|
|
|
$sort_order['subpaneldefs'] = isset($subpanel_def->_instance_properties['sort_order']) ? |
|
1091
|
|
|
$subpanel_def->_instance_properties['sort_order'] : null; |
|
1092
|
|
|
|
|
1093
|
|
|
$this->sort_order = $this->calculateSortOrder($sort_order); |
|
1094
|
|
|
|
|
1095
|
|
|
|
|
1096
|
|
|
if (isset($subpanel_def->_instance_properties['sort_by'])) { |
|
1097
|
|
|
$this->query_orderby = $subpanel_def->_instance_properties['sort_by']; |
|
1098
|
|
|
} else { |
|
1099
|
|
|
$this->query_orderby = 'id'; |
|
1100
|
|
|
} |
|
1101
|
|
|
|
|
1102
|
|
|
$this->getOrderBy($html_var,$this->query_orderby, $this->sort_order); |
|
1103
|
|
|
|
|
1104
|
|
|
$_SESSION['last_sub' .$this->subpanel_module. '_order'] = $this->sort_order; |
|
1105
|
|
|
$_SESSION['last_sub' .$this->subpanel_module. '_url'] = $this->getBaseURL($html_var); |
|
1106
|
|
|
|
|
1107
|
|
|
// Bug 8139 - Correct Subpanel sorting on 'name', when subpanel sorting default is 'last_name, first_name' |
|
1108
|
|
|
if (($this->sortby == 'name' || $this->sortby == 'last_name') && |
|
1109
|
|
|
str_replace(' ', '', trim($subpanel_def->_instance_properties['sort_by'])) == 'last_name,first_name') { |
|
1110
|
|
|
$this->sortby = 'last_name '.$this->sort_order.', first_name '; |
|
1111
|
|
|
} |
|
1112
|
|
|
|
|
1113
|
|
|
if(!empty($this->response)){ |
|
1114
|
|
|
$response =& $this->response; |
|
1115
|
|
|
echo 'cached'; |
|
1116
|
|
|
}else{ |
|
1117
|
|
|
$response = SugarBean::get_union_related_list($sugarbean,$this->sortby, $this->sort_order, $this->query_where, $current_offset, -1, $this->records_per_page,$this->query_limit,$subpanel_def); |
|
1118
|
|
|
$this->response =& $response; |
|
1119
|
|
|
} |
|
1120
|
|
|
$list = $response['list']; |
|
1121
|
|
|
$row_count = $response['row_count']; |
|
1122
|
|
|
$next_offset = $response['next_offset']; |
|
1123
|
|
|
$previous_offset = $response['previous_offset']; |
|
1124
|
|
|
if(!empty($response['current_offset']))$current_offset = $response['current_offset']; |
|
1125
|
|
|
global $list_view_row_count; |
|
1126
|
|
|
$list_view_row_count = $row_count; |
|
1127
|
|
|
$this->processListNavigation('dyn_list_view', $html_var, $current_offset, $next_offset, $previous_offset, $row_count, $sugarbean,$subpanel_def); |
|
1128
|
|
|
|
|
1129
|
|
|
return array('list'=>$list, 'parent_data'=>$response['parent_data'], 'query'=>$response['query']); |
|
1130
|
|
|
} |
|
1131
|
|
|
|
|
1132
|
|
|
function getBaseURL($html_varName) { |
|
1133
|
|
|
static $cache = array(); |
|
1134
|
|
|
|
|
1135
|
|
|
if(!empty($cache[$html_varName]))return $cache[$html_varName]; |
|
1136
|
|
|
$blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount','current_query_by_page'); |
|
1137
|
|
|
if(!empty($this->base_URL)) { |
|
1138
|
|
|
return $this->base_URL; |
|
1139
|
|
|
} |
|
1140
|
|
|
|
|
1141
|
|
|
$baseurl = $_SERVER['PHP_SELF']; |
|
1142
|
|
|
if(empty($baseurl)) { |
|
1143
|
|
|
$baseurl = 'index.php'; |
|
1144
|
|
|
} |
|
1145
|
|
|
|
|
1146
|
|
|
/*fixes an issue with deletes when doing a search*/ |
|
1147
|
|
|
foreach(array_merge($_GET, $_POST) as $name=>$value) { |
|
1148
|
|
|
//echo ("$name = $value <br/>"); |
|
1149
|
|
|
if(!empty($value) && $name != 'sort_order' //&& $name != ListView::getSessionVariableName($html_varName,"ORDER_BY") |
|
1150
|
|
|
&& $name != ListView::getSessionVariableName($html_varName,"offset") |
|
1151
|
|
|
/*&& substr_count($name, "ORDER_BY")==0*/ && !in_array($name, $blockVariables)) |
|
1152
|
|
|
{ |
|
1153
|
|
|
if(is_array($value)) { |
|
1154
|
|
|
foreach($value as $valuename=>$valuevalue) { |
|
1155
|
|
|
if(substr_count($baseurl, '?') > 0) |
|
1156
|
|
|
$baseurl .= "&{$name}[]=".$valuevalue; |
|
1157
|
|
|
else |
|
1158
|
|
|
$baseurl .= "?{$name}[]=".$valuevalue; |
|
1159
|
|
|
} |
|
1160
|
|
|
} else { |
|
1161
|
|
|
$value = urlencode($value); |
|
1162
|
|
|
if(substr_count($baseurl, '?') > 0) { |
|
1163
|
|
|
$baseurl .= "&$name=$value"; |
|
1164
|
|
|
} else { |
|
1165
|
|
|
$baseurl .= "?$name=$value"; |
|
1166
|
|
|
} |
|
1167
|
|
|
} |
|
1168
|
|
|
} |
|
1169
|
|
|
} |
|
1170
|
|
|
|
|
1171
|
|
|
|
|
1172
|
|
|
if($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
1173
|
|
|
// at this point it is possible that the above foreach already executed resulting in double ?'s in the url |
|
1174
|
|
|
if(substr_count($baseurl, '?') == 0) { |
|
1175
|
|
|
$baseurl .= '?'; |
|
1176
|
|
|
} |
|
1177
|
|
|
if(isset($_REQUEST['action'])) $baseurl.= '&action='.$_REQUEST['action']; |
|
1178
|
|
|
if(isset($_REQUEST['record'])) $baseurl .= '&record='.$_REQUEST['record']; |
|
1179
|
|
|
if(isset($_REQUEST['module'])) $baseurl .= '&module='.$_REQUEST['module']; |
|
1180
|
|
|
} |
|
1181
|
|
|
|
|
1182
|
|
|
$baseurl .= "&".ListView::getSessionVariableName($html_varName,"offset")."="; |
|
1183
|
|
|
$cache[$html_varName] = $baseurl; |
|
1184
|
|
|
return $baseurl; |
|
1185
|
|
|
} |
|
1186
|
|
|
/** |
|
1187
|
|
|
* @return void |
|
1188
|
|
|
* @param unknown $data |
|
|
|
|
|
|
1189
|
|
|
* @param unknown $xTemplateSection |
|
|
|
|
|
|
1190
|
|
|
* @param unknown $html_varName |
|
1191
|
|
|
* @desc INTERNAL FUNCTION process the List Navigation |
|
1192
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
1193
|
|
|
* All Rights Reserved. |
|
1194
|
|
|
* Contributor(s): ______________________________________.. |
|
1195
|
|
|
*/ |
|
1196
|
|
|
function processListNavigation($xtemplateSection, $html_varName, $current_offset, $next_offset, $previous_offset, $row_count, $sugarbean=null, $subpanel_def=null, $col_count = 20) { |
|
1197
|
|
|
|
|
1198
|
|
|
global $export_module; |
|
1199
|
|
|
global $sugar_config; |
|
1200
|
|
|
global $current_user; |
|
1201
|
|
|
global $currentModule; |
|
1202
|
|
|
global $app_strings; |
|
1203
|
|
|
|
|
1204
|
|
|
$start_record = $current_offset + 1; |
|
1205
|
|
|
|
|
1206
|
|
|
if(!is_numeric($col_count)) |
|
1207
|
|
|
$col_count = 20; |
|
1208
|
|
|
|
|
1209
|
|
|
if($row_count == 0) |
|
1210
|
|
|
$start_record = 0; |
|
1211
|
|
|
|
|
1212
|
|
|
$end_record = $start_record + $this->records_per_page; |
|
1213
|
|
|
// back up the the last page. |
|
1214
|
|
|
if($end_record > $row_count+1) { |
|
1215
|
|
|
$end_record = $row_count+1; |
|
1216
|
|
|
} |
|
1217
|
|
|
// Determine the start location of the last page |
|
1218
|
|
|
if($row_count == 0) |
|
1219
|
|
|
$number_pages = 0; |
|
1220
|
|
|
else |
|
1221
|
|
|
$number_pages = floor(($row_count - 1) / $this->records_per_page); |
|
1222
|
|
|
|
|
1223
|
|
|
$last_offset = $number_pages * $this->records_per_page; |
|
1224
|
|
|
|
|
1225
|
|
|
if(empty($this->query_limit) || $this->query_limit > $this->records_per_page) { |
|
1226
|
|
|
$this->base_URL = $this->getBaseURL($html_varName); |
|
1227
|
|
|
$dynamic_url = ''; |
|
1228
|
|
|
|
|
1229
|
|
|
if($this->is_dynamic) { |
|
1230
|
|
|
$dynamic_url .='&'. $this->getSessionVariableName($html_varName,'ORDER_BY') . '='. $this->getSessionVariable($html_varName,'ORDER_BY').'&sort_order='.$this->sort_order.'&to_pdf=true&action=SubPanelViewer&subpanel=' . $this->subpanel_module; |
|
1231
|
|
|
} |
|
1232
|
|
|
|
|
1233
|
|
|
$current_URL = htmlentities($this->base_URL.$current_offset.$dynamic_url); |
|
1234
|
|
|
$start_URL = htmlentities($this->base_URL."0".$dynamic_url); |
|
1235
|
|
|
$previous_URL = htmlentities($this->base_URL.$previous_offset.$dynamic_url); |
|
1236
|
|
|
$next_URL = htmlentities($this->base_URL.$next_offset.$dynamic_url); |
|
1237
|
|
|
$end_URL = htmlentities($this->base_URL.'end'.$dynamic_url); |
|
1238
|
|
|
|
|
1239
|
|
|
if(!empty($this->start_link_wrapper)) { |
|
1240
|
|
|
$current_URL = $this->start_link_wrapper.$current_URL.$this->end_link_wrapper; |
|
1241
|
|
|
$start_URL = $this->start_link_wrapper.$start_URL.$this->end_link_wrapper; |
|
1242
|
|
|
$previous_URL = $this->start_link_wrapper.$previous_URL.$this->end_link_wrapper; |
|
1243
|
|
|
$next_URL = $this->start_link_wrapper.$next_URL.$this->end_link_wrapper; |
|
1244
|
|
|
$end_URL = $this->start_link_wrapper.$end_URL.$this->end_link_wrapper; |
|
1245
|
|
|
} |
|
1246
|
|
|
|
|
1247
|
|
|
$moduleString = htmlspecialchars("{$currentModule}_{$html_varName}_offset"); |
|
1248
|
|
|
$moduleStringOrder = htmlspecialchars("{$currentModule}_{$html_varName}_ORDER_BY"); |
|
1249
|
|
|
if($this->shouldProcess && !$this->multi_select_popup) { |
|
1250
|
|
|
// check the checkboxes onload |
|
1251
|
|
|
echo "<script>YAHOO.util.Event.addListener(window, \"load\", sListView.check_boxes);</script>\n"; |
|
1252
|
|
|
|
|
1253
|
|
|
$massUpdateRun = isset($_REQUEST['massupdate']) && $_REQUEST['massupdate'] == 'true'; |
|
1254
|
|
|
$uids = empty($_REQUEST['uid']) || $massUpdateRun ? '' : $_REQUEST['uid']; |
|
1255
|
|
|
$select_entire_list = ($massUpdateRun) ? 0 : (isset($_POST['select_entire_list']) ? $_POST['select_entire_list'] : (isset($_REQUEST['select_entire_list']) ? htmlspecialchars($_REQUEST['select_entire_list']) : 0)); |
|
1256
|
|
|
|
|
1257
|
|
|
echo "<textarea style='display: none' name='uid'>{$uids}</textarea>\n" . |
|
1258
|
|
|
"<input type='hidden' name='select_entire_list' value='{$select_entire_list}'>\n". |
|
1259
|
|
|
"<input type='hidden' name='{$moduleString}' value='0'>\n". |
|
1260
|
|
|
"<input type='hidden' name='{$moduleStringOrder}' value='0'>\n"; |
|
1261
|
|
|
|
|
1262
|
|
|
} |
|
1263
|
|
|
|
|
1264
|
|
|
|
|
1265
|
|
|
$GLOBALS['log']->debug("Offsets: (start, previous, next, last)(0, $previous_offset, $next_offset, $last_offset)"); |
|
1266
|
|
|
|
|
1267
|
|
|
if(0 == $current_offset) { |
|
1268
|
|
|
$start_link = "<button type='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("start_off","aborder='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])."</button>"; |
|
1269
|
|
|
$previous_link = "<button type='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("previous_off","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>"; |
|
1270
|
|
|
} else { |
|
1271
|
|
|
if($this->multi_select_popup) {// nav links for multiselect popup, submit form to save checks. |
|
1272
|
|
|
$start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick='javascript:save_checks(0, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("start","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])."</button>"; |
|
1273
|
|
|
$previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick='javascript:save_checks($previous_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("previous","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>"; |
|
1274
|
|
|
} elseif($this->shouldProcess) { |
|
1275
|
|
|
$start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick='location.href=\"$start_URL\"; sListView.save_checks(0, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("start","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])."</button>"; |
|
1276
|
|
|
$previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick='location.href=\"$previous_URL\"; sListView.save_checks($previous_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("previous","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>"; |
|
1277
|
|
|
} else { |
|
1278
|
|
|
$onClick = ''; |
|
1279
|
|
|
if(0 != preg_match('/javascript.*/', $start_URL)){ |
|
1280
|
|
|
$onClick = "\"$start_URL;\""; |
|
1281
|
|
|
}else{ |
|
1282
|
|
|
$onClick ="'location.href=\"$start_URL\";'"; |
|
1283
|
|
|
} |
|
1284
|
|
|
$start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("start","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])."</button>"; |
|
1285
|
|
|
|
|
1286
|
|
|
$onClick = ''; |
|
1287
|
|
|
if(0 != preg_match('/javascript.*/', $previous_URL)){ |
|
1288
|
|
|
$onClick = "\"$previous_URL;\""; |
|
1289
|
|
|
}else{ |
|
1290
|
|
|
$onClick = "'location.href=\"$previous_URL\";'"; |
|
1291
|
|
|
} |
|
1292
|
|
|
$previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("previous","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>"; |
|
1293
|
|
|
} |
|
1294
|
|
|
} |
|
1295
|
|
|
|
|
1296
|
|
|
if($last_offset <= $current_offset) { |
|
1297
|
|
|
$end_link = "<button type='button' name='listViewEndButton' title='{$this->local_app_strings['LNK_LIST_END']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("end_off","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END'])."</button>"; |
|
1298
|
|
|
$next_link = "<button type='button' name='listViewNextButton' title='{$this->local_app_strings['LNK_LIST_NEXT']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("next_off","aborder='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT'])."</button>"; |
|
1299
|
|
|
} else { |
|
1300
|
|
|
if($this->multi_select_popup) { // nav links for multiselect popup, submit form to save checks. |
|
1301
|
|
|
$end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick='javascript:save_checks($last_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("end","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END'])."</button>"; |
|
1302
|
|
|
if(!empty($sugar_config['disable_count_query'])) { |
|
1303
|
|
|
$end_link = ''; |
|
1304
|
|
|
} |
|
1305
|
|
|
$next_link = "<button type='button' name='listViewNextButton' title='{$this->local_app_strings['LNK_LIST_NEXT']}' class='button' onClick='javascript:save_checks($next_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("next","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT'])."</button>"; |
|
1306
|
|
|
} elseif($this->shouldProcess) { |
|
1307
|
|
|
$end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick='location.href=\"$end_URL\"; sListView.save_checks(\"end\", \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("end","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END'])."</button>"; |
|
1308
|
|
|
$next_link = "<button type='button' name='listViewNextButton' class='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' onClick='location.href=\"$next_URL\"; sListView.save_checks($next_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("next","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT'])."</button>"; |
|
1309
|
|
|
} else { |
|
1310
|
|
|
$onClick = ''; |
|
1311
|
|
|
if(0 != preg_match('/javascript.*/', $next_URL)){ |
|
1312
|
|
|
$onClick = "\"$next_URL;\""; |
|
1313
|
|
|
}else{ |
|
1314
|
|
|
$onClick ="'location.href=\"$next_URL\";'"; |
|
1315
|
|
|
} |
|
1316
|
|
|
$next_link = "<button type='button' name='listViewNextButton' class='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("next","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT'])."</button>"; |
|
1317
|
|
|
|
|
1318
|
|
|
$onClick = ''; |
|
1319
|
|
|
if(0 != preg_match('/javascript.*/', $end_URL)){ |
|
1320
|
|
|
$onClick = "\"$end_URL;\""; |
|
1321
|
|
|
}else{ |
|
1322
|
|
|
$onClick = "'location.href=\"$end_URL\";'"; |
|
1323
|
|
|
} |
|
1324
|
|
|
$end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("end","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END'])."</button>"; |
|
1325
|
|
|
|
|
1326
|
|
|
} |
|
1327
|
|
|
} |
|
1328
|
|
|
|
|
1329
|
|
|
$GLOBALS['log']->info("Offset (next, current, prev)($next_offset, $current_offset, $previous_offset)"); |
|
1330
|
|
|
$GLOBALS['log']->info("Start/end records ($start_record, $end_record)"); |
|
1331
|
|
|
|
|
1332
|
|
|
$end_record = $end_record-1; |
|
1333
|
|
|
|
|
1334
|
|
|
$script_href = "<a style=\'width: 150px\' name=\"thispage\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'if (document.MassUpdate.select_entire_list.value==1){document.MassUpdate.select_entire_list.value=0;sListView.check_all(document.MassUpdate, \"mass[]\", true, $this->records_per_page)}else {sListView.check_all(document.MassUpdate, \"mass[]\", true)};\' href=\'#\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_CURRENT']} ({$this->records_per_page})‎</a>" |
|
1335
|
|
|
. "<a style=\'width: 150px\' name=\"selectall\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'sListView.check_entire_list(document.MassUpdate, \"mass[]\",true,{$row_count});\' href=\'#\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_ENTIRE']} ({$row_count})‎</a>" |
|
1336
|
|
|
. "<a style=\'width: 150px\' name=\"deselect\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'sListView.clear_all(document.MassUpdate, \"mass[]\", false);\' href=\'#\'>{$this->local_app_strings['LBL_LISTVIEW_NONE']}</a>"; |
|
1337
|
|
|
|
|
1338
|
|
|
$close_inline_img = SugarThemeRegistry::current()->getImage('close_inline', 'border=0', null, null, ".gif", $app_strings['LBL_CLOSEINLINE']); |
|
1339
|
|
|
|
|
1340
|
|
|
echo "<script> |
|
1341
|
|
|
function select_dialog() { |
|
1342
|
|
|
var \$dialog = \$('<div></div>') |
|
1343
|
|
|
.html('<a style=\'width: 150px\' name=\"thispage\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'if (document.MassUpdate.select_entire_list.value==1){document.MassUpdate.select_entire_list.value=0;sListView.check_all(document.MassUpdate, \"mass[]\", true, $this->records_per_page)}else {sListView.check_all(document.MassUpdate, \"mass[]\", true)};\' href=\'javascript:void(0)\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_CURRENT']} ({$this->records_per_page})‎</a>" |
|
1344
|
|
|
. "<a style=\'width: 150px\' name=\"selectall\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'sListView.check_entire_list(document.MassUpdate, \"mass[]\",true,{$row_count});\' href=\'javascript:void(0)\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_ENTIRE']} ({$row_count})‎</a>" |
|
1345
|
|
|
. "<a style=\'width: 150px\' name=\"deselect\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'sListView.clear_all(document.MassUpdate, \"mass[]\", false);\' href=\'javascript:void(0)\'>{$this->local_app_strings['LBL_LISTVIEW_NONE']}</a>') |
|
1346
|
|
|
.dialog({ |
|
1347
|
|
|
autoOpen: false, |
|
1348
|
|
|
width: 150 |
|
1349
|
|
|
}); |
|
1350
|
|
|
\$dialog.dialog('open'); |
|
1351
|
|
|
|
|
1352
|
|
|
} |
|
1353
|
|
|
</script>"; |
|
1354
|
|
|
|
|
1355
|
|
|
if($this->show_select_menu) |
|
1356
|
|
|
{ |
|
1357
|
|
|
$total_label = ""; |
|
1358
|
|
|
$total = $row_count; |
|
1359
|
|
|
$pageTotal = ($row_count > 0) ? $end_record - $start_record + 1 : 0; |
|
1360
|
|
|
if (!empty($GLOBALS['sugar_config']['disable_count_query']) && $GLOBALS['sugar_config']['disable_count_query'] === true && $total > $pageTotal) { |
|
1361
|
|
|
$this->show_plus = true; |
|
1362
|
|
|
$total = $pageTotal; |
|
1363
|
|
|
$total_label = $total.'+'; |
|
1364
|
|
|
} else { |
|
1365
|
|
|
$this->show_plus = false; |
|
1366
|
|
|
$total_label = $total; |
|
1367
|
|
|
} |
|
1368
|
|
|
echo "<input type='hidden' name='show_plus' value='{$this->show_plus}'>\n"; |
|
1369
|
|
|
|
|
1370
|
|
|
//Bug#52931: Replace with actionMenu |
|
1371
|
|
|
//$select_link = "<a id='select_link' onclick='return select_dialog();' href=\"javascript:void(0)\">".$this->local_app_strings['LBL_LINK_SELECT']." ".SugarThemeRegistry::current()->getImage('MoreDetail', 'border=0', 11, 7, '.png', $app_strings['LBL_MOREDETAIL'])."</a>"; |
|
1372
|
|
|
$menuItems = array( |
|
1373
|
|
|
"<input title=\"".$app_strings['LBL_SELECT_ALL_TITLE']."\" type='checkbox' class='checkbox massall' name='massall' id='massall' value='' onclick='sListView.check_all(document.MassUpdate, \"mass[]\", this.checked);' /><a href='javascript: void(0);'></a>", |
|
1374
|
|
|
"<a name='thispage' id='button_select_this_page' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' onclick='if (document.MassUpdate.select_entire_list.value==1){document.MassUpdate.select_entire_list.value=0;sListView.check_all(document.MassUpdate, \"mass[]\", true, $pageTotal)}else {sListView.check_all(document.MassUpdate, \"mass[]\", true)};' href='#'>{$app_strings['LBL_LISTVIEW_OPTION_CURRENT']} ({$pageTotal})‎</a>", |
|
1375
|
|
|
"<a name='selectall' id='button_select_all' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' onclick='sListView.check_entire_list(document.MassUpdate, \"mass[]\",true,{$total});' href='#'>{$app_strings['LBL_LISTVIEW_OPTION_ENTIRE']} ({$total_label})‎</a>", |
|
1376
|
|
|
"<a name='deselect' id='button_deselect' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' onclick='sListView.clear_all(document.MassUpdate, \"mass[]\", false);' href='#'>{$app_strings['LBL_LISTVIEW_NONE']}</a>", |
|
1377
|
|
|
); |
|
1378
|
|
|
require_once('include/Smarty/plugins/function.sugar_action_menu.php'); |
|
1379
|
|
|
$select_link = smarty_function_sugar_action_menu(array( |
|
1380
|
|
|
'class' => 'clickMenu selectmenu', |
|
1381
|
|
|
'id' => 'selectLink', |
|
1382
|
|
|
'buttons' => $menuItems, |
|
1383
|
|
|
'flat' => false, |
|
1384
|
|
|
),$this->xTemplate); |
|
1385
|
|
|
|
|
1386
|
|
|
} else { |
|
1387
|
|
|
$select_link = " "; |
|
1388
|
|
|
} |
|
1389
|
|
|
|
|
1390
|
|
|
$export_link = '<input class="button" type="button" value="'.$this->local_app_strings['LBL_EXPORT'].'" ' . |
|
1391
|
|
|
'onclick="return sListView.send_form(true, \''.$_REQUEST['module'].'\', \'index.php?entryPoint=export\',\''.$this->local_app_strings['LBL_LISTVIEW_NO_SELECTED'].'\')">'; |
|
1392
|
|
|
|
|
1393
|
|
|
if($this->show_delete_button) { |
|
1394
|
|
|
$delete_link = '<input class="button" type="button" id="delete_button" name="Delete" value="'.$this->local_app_strings['LBL_DELETE_BUTTON_LABEL'].'" onclick="return sListView.send_mass_update(\'selected\',\''.$this->local_app_strings['LBL_LISTVIEW_NO_SELECTED'].'\', 1)">'; |
|
1395
|
|
|
} else { |
|
1396
|
|
|
$delete_link = ' '; |
|
1397
|
|
|
} |
|
1398
|
|
|
|
|
1399
|
|
|
$admin = new Administration(); |
|
1400
|
|
|
$admin->retrieveSettings('system'); |
|
1401
|
|
|
|
|
1402
|
|
|
$user_merge = $current_user->getPreference('mailmerge_on'); |
|
1403
|
|
|
if($user_merge == 'on' && isset($admin->settings['system_mailmerge_on']) && $admin->settings['system_mailmerge_on']) { |
|
1404
|
|
|
echo "<script> |
|
1405
|
|
|
function mailmerge_dialog(el) { |
|
1406
|
|
|
var \$dialog = \$('<div></div>') |
|
1407
|
|
|
.html('<a style=\'width: 150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'return sListView.send_form(true, \"MailMerge\", \"index.php\", \"{$this->local_app_strings['LBL_LISTVIEW_NO_SELECTED']}\")\' href=\'javascript:void(0)\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_SELECTED']}</a>" |
|
1408
|
|
|
. "<a style=\'width: 150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' href=\'index.php?action=index&module=MailMerge\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_CURRENT']}</a>" |
|
1409
|
|
|
. "<a style=\'width: 150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' href=\'index.php?action=index&module=MailMerge&entire=true\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_ENTIRE']}</a>') |
|
1410
|
|
|
.dialog({ |
|
1411
|
|
|
autoOpen: false, |
|
1412
|
|
|
title: '". $this->local_app_strings['LBL_MAILMERGE']."', |
|
1413
|
|
|
width: 150, |
|
1414
|
|
|
position: { |
|
1415
|
|
|
my: myPos, |
|
1416
|
|
|
at: atPos, |
|
1417
|
|
|
of: \$(el) |
|
1418
|
|
|
} |
|
1419
|
|
|
}); |
|
1420
|
|
|
|
|
1421
|
|
|
} |
|
1422
|
|
|
</script>"; |
|
1423
|
|
|
$merge_link = " | <a id='mailmerge_link' onclick='return mailmerge_dialog(this)'; href=\"javascript:void(0)\">".$this->local_app_strings['LBL_MAILMERGE']."</a>"; |
|
1424
|
|
|
} else { |
|
1425
|
|
|
$merge_link = " "; |
|
1426
|
|
|
} |
|
1427
|
|
|
|
|
1428
|
|
|
$selected_objects_span = " | {$this->local_app_strings['LBL_LISTVIEW_SELECTED_OBJECTS']}<input style='border: 0px; background: transparent; font-size: inherit; color: inherit' type='text' readonly name='selectCount[]' value='" . ((isset($_POST['mass'])) ? count($_POST['mass']): 0) . "' />"; |
|
1429
|
|
|
|
|
1430
|
|
|
if($_REQUEST['module'] == 'Home' || $this->local_current_module == 'Import' |
|
1431
|
|
|
|| $this->show_export_button == false |
|
|
|
|
|
|
1432
|
|
|
|| (!empty($sugar_config['disable_export'])) |
|
1433
|
|
|
|| (!empty($sugar_config['admin_export_only']) |
|
1434
|
|
|
&& !( |
|
1435
|
|
|
is_admin($current_user) |
|
1436
|
|
|
|| (ACLController::moduleSupportsACL($_REQUEST['module']) |
|
1437
|
|
|
&& ACLAction::getUserAccessLevel($current_user->id,$_REQUEST['module'], 'access') == ACL_ALLOW_ENABLED |
|
1438
|
|
|
&& (ACLAction::getUserAccessLevel($current_user->id, $_REQUEST['module'], 'admin') == ACL_ALLOW_ADMIN || |
|
1439
|
|
|
ACLAction::getUserAccessLevel($current_user->id, $_REQUEST['module'], 'admin') == ACL_ALLOW_ADMIN_DEV))))) |
|
1440
|
|
|
{ |
|
1441
|
|
|
if ($_REQUEST['module'] != 'InboundEmail' && $_REQUEST['module'] != 'EmailMan' && $_REQUEST['module'] != 'iFrames') { |
|
1442
|
|
|
$selected_objects_span = ''; |
|
1443
|
|
|
} |
|
1444
|
|
|
$export_link = " "; |
|
1445
|
|
|
$merge_link = " "; |
|
1446
|
|
|
} elseif($_REQUEST['module'] != "Accounts" && $_REQUEST['module'] != "Cases" && $_REQUEST['module'] != "Contacts" && $_REQUEST['module'] != "Leads" && $_REQUEST['module'] != "Opportunities") { |
|
1447
|
|
|
$merge_link = " "; |
|
1448
|
|
|
} |
|
1449
|
|
|
|
|
1450
|
|
|
if($this->show_paging == true) { |
|
|
|
|
|
|
1451
|
|
|
if(!empty($sugar_config['disable_count_query'])) { |
|
1452
|
|
|
if($row_count > $end_record) { |
|
1453
|
|
|
$row_count .= '+'; |
|
1454
|
|
|
} |
|
1455
|
|
|
} |
|
1456
|
|
|
|
|
1457
|
|
|
$html_text = ''; |
|
1458
|
|
|
$html_text .= "<tr class='pagination' role='presentation'>\n"; |
|
1459
|
|
|
$html_text .= "<td COLSPAN=\"$col_count\" align=\"right\">\n"; |
|
1460
|
|
|
//$html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\" >$export_link$merge_link$selected_objects_span</td>\n"; |
|
1461
|
|
|
//$html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\" >"; |
|
1462
|
|
|
if ($subpanel_def != null) { |
|
1463
|
|
|
include_once('include/SubPanel/SubPanelTiles.php'); |
|
1464
|
|
|
$subpanelTiles = new SubPanelTiles($sugarbean); |
|
1465
|
|
|
$html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\" >"; |
|
1466
|
|
|
|
|
1467
|
|
|
//attempt to get the query to recreate this subpanel |
|
1468
|
|
|
if(!empty($this->response)){ |
|
1469
|
|
|
$response =& $this->response; |
|
1470
|
|
|
}else{ |
|
1471
|
|
|
$response = SugarBean::get_union_related_list($sugarbean,$this->sortby, $this->sort_order, $this->query_where, $current_offset, -1, $this->records_per_page,$this->query_limit,$subpanel_def); |
|
1472
|
|
|
$this->response = $response; |
|
1473
|
|
|
} |
|
1474
|
|
|
//if query is present, then pass it in as parameter |
|
1475
|
|
|
if (isset($response['query']) && !empty($response['query'])){ |
|
1476
|
|
|
$html_text .= $subpanelTiles->get_buttons($subpanel_def, $response['query']); |
|
1477
|
|
|
}else{ |
|
1478
|
|
|
$html_text .= $subpanelTiles->get_buttons($subpanel_def); |
|
1479
|
|
|
} |
|
1480
|
|
|
} |
|
1481
|
|
|
else { |
|
1482
|
|
|
$html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\" nowrap>$select_link $export_link $delete_link $selected_objects_span"; |
|
1483
|
|
|
} |
|
1484
|
|
|
$html_text .= "</td>\n<td nowrap align=\"right\">".$start_link." ".$previous_link." <span class='pageNumbers'>(".$start_record." - ".$end_record." ".$this->local_app_strings['LBL_LIST_OF']." ".$row_count.")</span> ".$next_link." ".$end_link."</td></tr></table>\n"; |
|
1485
|
|
|
$html_text .= "</td>\n"; |
|
1486
|
|
|
$html_text .= "</tr>\n"; |
|
1487
|
|
|
$this->xTemplate->assign("PAGINATION",$html_text); |
|
1488
|
|
|
} |
|
1489
|
|
|
|
|
1490
|
|
|
//C.L. - Fix for 23461 |
|
1491
|
|
|
if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') { |
|
1492
|
|
|
$_SESSION['export_where'] = $this->query_where; |
|
1493
|
|
|
} |
|
1494
|
|
|
$this->xTemplate->parse($xtemplateSection.".list_nav_row"); |
|
1495
|
|
|
} |
|
1496
|
|
|
} // end processListNavigation |
|
1497
|
|
|
|
|
1498
|
|
|
function processOrderBy($html_varName) { |
|
1499
|
|
|
|
|
1500
|
|
|
if(!isset($this->base_URL)) { |
|
1501
|
|
|
$this->base_URL = $_SERVER['PHP_SELF']; |
|
1502
|
|
|
|
|
1503
|
|
|
if(isset($_SERVER['QUERY_STRING'])) { |
|
1504
|
|
|
$this->base_URL = preg_replace("/\&".$this->getSessionVariableName($html_varName,"ORDER_BY")."=[0-9a-zA-Z\_\.]*/","",$this->base_URL .'?'.$_SERVER['QUERY_STRING']); |
|
1505
|
|
|
$this->base_URL = preg_replace("/\&".$this->getSessionVariableName($html_varName,"offset")."=[0-9]*/","",$this->base_URL); |
|
1506
|
|
|
} |
|
1507
|
|
|
if($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
1508
|
|
|
$this->base_URL .= '?'; |
|
1509
|
|
|
if(isset($_REQUEST['action'])) $this->base_URL .= '&action='.$_REQUEST['action']; |
|
1510
|
|
|
if(isset($_REQUEST['record'])) $this->base_URL .= '&record='.$_REQUEST['record']; |
|
1511
|
|
|
if(isset($_REQUEST['module'])) $this->base_URL .= '&module='.$_REQUEST['module']; |
|
1512
|
|
|
} |
|
1513
|
|
|
$this->base_URL .= "&".$this->getSessionVariableName($html_varName,"offset")."="; |
|
1514
|
|
|
} |
|
1515
|
|
|
|
|
1516
|
|
|
if($this->is_dynamic) { |
|
1517
|
|
|
$this->base_URL.='&to_pdf=true&action=SubPanelViewer&subpanel=' . $this->source_module; |
|
1518
|
|
|
} |
|
1519
|
|
|
|
|
1520
|
|
|
//bug43465 start |
|
1521
|
|
|
if (isset($this->appendToBaseUrl) && is_array($this->appendToBaseUrl)) |
|
1522
|
|
|
{ |
|
1523
|
|
|
foreach ($this->appendToBaseUrl as $key => $value) |
|
1524
|
|
|
{ |
|
1525
|
|
|
$fullRequestString = $key . '=' . $value; |
|
1526
|
|
|
|
|
1527
|
|
|
if ($this->base_URL == "/index.php") |
|
1528
|
|
|
{ |
|
1529
|
|
|
$this->base_URL .= "?"; |
|
1530
|
|
|
} else |
|
1531
|
|
|
{ |
|
1532
|
|
|
if ($fullRequestString == substr($this->baseURL, '-' . strlen($fullRequestString))) |
|
1533
|
|
|
{ |
|
1534
|
|
|
$this->base_URL = preg_replace("/&" . $key . "\=.*/", "", $this->base_URL); |
|
1535
|
|
|
} else |
|
1536
|
|
|
{ |
|
1537
|
|
|
$this->base_URL = preg_replace("/&" . $key . "\=.*?&/", "&", $this->base_URL); |
|
1538
|
|
|
} |
|
1539
|
|
|
$this->base_URL .= "&"; |
|
1540
|
|
|
} |
|
1541
|
|
|
if (!empty($value)) |
|
1542
|
|
|
{ |
|
1543
|
|
|
$this->base_URL .= "{$key}={$value}"; |
|
1544
|
|
|
} |
|
1545
|
|
|
} |
|
1546
|
|
|
} |
|
1547
|
|
|
//bug43465 end |
|
1548
|
|
|
|
|
1549
|
|
|
$sort_URL_base = $this->base_URL. "&".$this->getSessionVariableName($html_varName,"ORDER_BY")."="; |
|
1550
|
|
|
|
|
1551
|
|
|
if($sort_URL_base !== "") |
|
1552
|
|
|
{ |
|
1553
|
|
|
$this->xTemplate->assign("ORDER_BY", $sort_URL_base); |
|
1554
|
|
|
return $sort_URL_base; |
|
1555
|
|
|
} else { |
|
1556
|
|
|
return ''; |
|
1557
|
|
|
} |
|
1558
|
|
|
} |
|
1559
|
|
|
|
|
1560
|
|
|
|
|
1561
|
|
|
function getAdditionalHeader() { |
|
1562
|
|
|
|
|
1563
|
|
|
} |
|
1564
|
|
|
|
|
1565
|
|
|
|
|
1566
|
|
|
/** |
|
1567
|
|
|
* @return void |
|
1568
|
|
|
* @param unknown $data |
|
1569
|
|
|
* @param unknown $xTemplateSection |
|
|
|
|
|
|
1570
|
|
|
* @param unknown $html_varName |
|
1571
|
|
|
* @desc INTERNAL FUNCTION handles the rows |
|
1572
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
1573
|
|
|
* All Rights Reserved. |
|
1574
|
|
|
* Contributor(s): ______________________________________.. |
|
1575
|
|
|
*/ |
|
1576
|
|
|
function processListRows($data, $xtemplateSection, $html_varName) |
|
1577
|
|
|
{ |
|
1578
|
|
|
global $odd_bg; |
|
1579
|
|
|
global $even_bg; |
|
1580
|
|
|
global $hilite_bg; |
|
1581
|
|
|
global $app_strings, $sugar_version, $sugar_config; |
|
1582
|
|
|
global $currentModule; |
|
1583
|
|
|
|
|
1584
|
|
|
$this->xTemplate->assign('BG_HILITE', $hilite_bg); |
|
1585
|
|
|
$this->xTemplate->assign('CHECKALL', SugarThemeRegistry::current()->getImage('blank', '', 1, 1, ".gif", '')); |
|
1586
|
|
|
//$this->xTemplate->assign("BG_CLICK", $click_bg); |
|
1587
|
|
|
$oddRow = true; |
|
1588
|
|
|
$count = 0; |
|
1589
|
|
|
reset($data); |
|
1590
|
|
|
|
|
1591
|
|
|
//GETTING OFFSET |
|
1592
|
|
|
$offset = $this->getOffset($html_varName); |
|
1593
|
|
|
$timeStamp = $this->unique_id(); |
|
1594
|
|
|
$_SESSION[$html_varName."_FROM_LIST_VIEW"] = $timeStamp; |
|
1595
|
|
|
|
|
1596
|
|
|
$associated_row_data = array(); |
|
1597
|
|
|
|
|
1598
|
|
|
//mail merge list |
|
1599
|
|
|
$mergeList = array(); |
|
1600
|
|
|
$module = ''; |
|
1601
|
|
|
//todo what is this? It is using an array as a boolean |
|
1602
|
|
|
while(list($aVal, $aItem) = each($data)) |
|
1603
|
|
|
{ |
|
1604
|
|
|
if(isset($this->data_array)) { |
|
1605
|
|
|
$fields = $this->data_array; |
|
1606
|
|
|
} else { |
|
1607
|
|
|
$aItem->check_date_relationships_load(); |
|
1608
|
|
|
$fields = $aItem->get_list_view_data(); |
|
1609
|
|
|
} |
|
1610
|
|
|
|
|
1611
|
|
|
if(is_object($aItem)) { // cn: bug 5349 |
|
1612
|
|
|
//add item id to merge list, if the button is clicked |
|
1613
|
|
|
$mergeList[] = $aItem->id; |
|
1614
|
|
|
if(empty($module)) { |
|
1615
|
|
|
$module = $aItem->module_dir; |
|
1616
|
|
|
} |
|
1617
|
|
|
} |
|
1618
|
|
|
//ADD OFFSET TO ARRAY |
|
1619
|
|
|
|
|
1620
|
|
|
$fields['OFFSET'] = ($offset + $count + 1); |
|
1621
|
|
|
|
|
1622
|
|
|
$fields['STAMP'] = $timeStamp; |
|
1623
|
|
|
if($this->shouldProcess) { |
|
1624
|
|
|
|
|
1625
|
|
|
$prerow = ''; |
|
1626
|
|
|
if(!isset($this->data_array)) { |
|
1627
|
|
|
$prerow .= "<input onclick='sListView.check_item(this, document.MassUpdate)' type='checkbox' class='checkbox' name='mass[]' value='". $fields['ID']. "'>"; |
|
1628
|
|
|
} |
|
1629
|
|
|
$this->xTemplate->assign('PREROW', $prerow); |
|
1630
|
|
|
|
|
1631
|
|
|
$this->xTemplate->assign('CHECKALL', "<input type='checkbox' class='checkbox' title='".$GLOBALS['app_strings']['LBL_SELECT_ALL_TITLE']."' name='massall' id='massall' value='' onclick='sListView.check_all(document.MassUpdate, \"mass[]\", this.checked)'>"); |
|
1632
|
|
|
} |
|
1633
|
|
|
if(!isset($this->data_array)) { |
|
1634
|
|
|
$tag = $aItem->listviewACLHelper(); |
|
1635
|
|
|
$this->xTemplate->assign('TAG',$tag) ; |
|
1636
|
|
|
} |
|
1637
|
|
|
|
|
1638
|
|
|
if($oddRow) |
|
1639
|
|
|
{ |
|
1640
|
|
|
$ROW_COLOR = 'oddListRow'; |
|
1641
|
|
|
$BG_COLOR = $odd_bg; |
|
1642
|
|
|
} |
|
1643
|
|
|
else |
|
1644
|
|
|
{ |
|
1645
|
|
|
$ROW_COLOR = 'evenListRow'; |
|
1646
|
|
|
$BG_COLOR = $even_bg; |
|
1647
|
|
|
} |
|
1648
|
|
|
$oddRow = !$oddRow; |
|
1649
|
|
|
|
|
1650
|
|
|
$this->xTemplate->assign('ROW_COLOR', $ROW_COLOR); |
|
1651
|
|
|
$this->xTemplate->assign('BG_COLOR', $BG_COLOR); |
|
1652
|
|
|
|
|
1653
|
|
|
if(isset($this->data_array)) |
|
1654
|
|
|
{ |
|
1655
|
|
|
$this->xTemplate->assign('KEY', $aVal); |
|
1656
|
|
|
$this->xTemplate->assign('VALUE', $aItem); |
|
1657
|
|
|
$this->xTemplate->assign('INDEX', $count); |
|
1658
|
|
|
|
|
1659
|
|
|
} |
|
1660
|
|
|
else |
|
1661
|
|
|
{ |
|
1662
|
|
|
//AED -- some modules do not have their additionalDetails.php established. Add a check to ensure require_once does not fail |
|
1663
|
|
|
// Bug #2786 |
|
1664
|
|
|
if($this->_additionalDetails && $aItem->ACLAccess('DetailView') && (file_exists('modules/' . $aItem->module_dir . '/metadata/additionalDetails.php') || file_exists('custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php'))) { |
|
1665
|
|
|
|
|
1666
|
|
|
$additionalDetailsFile = 'modules/' . $aItem->module_dir . '/metadata/additionalDetails.php'; |
|
1667
|
|
|
if(file_exists('custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php')){ |
|
1668
|
|
|
$additionalDetailsFile = 'custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php'; |
|
1669
|
|
|
} |
|
1670
|
|
|
|
|
1671
|
|
|
require_once($additionalDetailsFile); |
|
1672
|
|
|
$ad_function = (empty($this->additionalDetailsFunction) ? 'additionalDetails' : $this->additionalDetailsFunction) . $aItem->object_name; |
|
1673
|
|
|
$results = $ad_function($fields); |
|
1674
|
|
|
$results['string'] = str_replace(array("'", "'"), '\'', $results['string']); // no xss! |
|
1675
|
|
|
|
|
1676
|
|
|
if(trim($results['string']) == '') $results['string'] = $app_strings['LBL_NONE']; |
|
1677
|
|
|
$fields[$results['fieldToAddTo']] = $fields[$results['fieldToAddTo']].'</a>'; |
|
1678
|
|
|
} |
|
1679
|
|
|
|
|
1680
|
|
|
if($aItem->ACLAccess('Delete')) { |
|
1681
|
|
|
$delete = '<a class="listViewTdToolsS1" onclick="return confirm(\''.$this->local_app_strings['NTC_DELETE_CONFIRMATION'].'\')" href="'.'index.php?action=Delete&module='.$aItem->module_dir.'&record='.$fields['ID'].'&return_module='.$aItem->module_dir.'&return_action=index&return_id=">'.$this->local_app_strings['LBL_DELETE_INLINE'].'</a>'; |
|
1682
|
|
|
require_once('include/Smarty/plugins/function.sugar_action_menu.php'); |
|
1683
|
|
|
$fields['DELETE_BUTTON'] = smarty_function_sugar_action_menu(array( |
|
1684
|
|
|
'id' => $aItem->module_dir.'_'.$fields['ID'].'_create_button', |
|
1685
|
|
|
'buttons' => array($delete), |
|
1686
|
|
|
), $this); |
|
1687
|
|
|
|
|
1688
|
|
|
} |
|
1689
|
|
|
|
|
1690
|
|
|
$this->xTemplate->assign($html_varName, $fields); |
|
1691
|
|
|
$aItem->setupCustomFields($aItem->module_dir); |
|
1692
|
|
|
$aItem->custom_fields->populateAllXTPL($this->xTemplate, 'detail', $html_varName, $fields); |
|
1693
|
|
|
} |
|
1694
|
|
|
if(!isset($this->data_array) && $aItem->ACLAccess('DetailView')) { |
|
1695
|
|
|
$count++; |
|
1696
|
|
|
} |
|
1697
|
|
|
if(isset($this->data_array)) { |
|
1698
|
|
|
$count++; |
|
1699
|
|
|
} |
|
1700
|
|
|
if(!isset($this->data_array)) { |
|
1701
|
|
|
$aItem->list_view_parse_additional_sections($this->xTemplate, $xtemplateSection); |
|
1702
|
|
|
|
|
1703
|
|
|
if($this->xTemplate->exists($xtemplateSection.'.row.pro')) { |
|
1704
|
|
|
$this->xTemplate->parse($xtemplateSection.'.row.pro'); |
|
1705
|
|
|
} |
|
1706
|
|
|
} |
|
1707
|
|
|
$this->xTemplate->parse($xtemplateSection . '.row'); |
|
1708
|
|
|
|
|
1709
|
|
|
if(isset($fields['ID'])) { |
|
1710
|
|
|
$associated_row_data[$fields['ID']] = $fields; |
|
1711
|
|
|
// Bug 38908: cleanup data for JS to avoid having shuffled around |
|
1712
|
|
|
foreach($fields as $key => $value) { |
|
1713
|
|
|
if($value == ' ') { |
|
1714
|
|
|
$associated_row_data[$fields['ID']][$key] = ''; |
|
1715
|
|
|
} |
|
1716
|
|
|
} |
|
1717
|
|
|
} |
|
1718
|
|
|
} |
|
1719
|
|
|
|
|
1720
|
|
|
$_SESSION['MAILMERGE_RECORDS'] = $mergeList; |
|
1721
|
|
|
$_SESSION['MAILMERGE_MODULE_FROM_LISTVIEW'] = $module; |
|
1722
|
|
|
if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') { |
|
1723
|
|
|
$_SESSION['MAILMERGE_MODULE'] = $module; |
|
1724
|
|
|
} |
|
1725
|
|
|
|
|
1726
|
|
|
if($this->process_for_popups) |
|
1727
|
|
|
{ |
|
1728
|
|
|
$json = getJSONobj(); |
|
1729
|
|
|
$is_show_fullname = showFullName() ? 1 : 0; |
|
1730
|
|
|
$associated_javascript_data = '<script type="text/javascript">' . "\n" |
|
1731
|
|
|
//. '<!-- // associated javascript data generated by ListView' . "\n" |
|
1732
|
|
|
. 'var associated_javascript_data = ' |
|
1733
|
|
|
. $json->encode($associated_row_data) . ";\n" |
|
1734
|
|
|
//. '-->' . "\n" |
|
1735
|
|
|
. 'var is_show_fullname = ' |
|
1736
|
|
|
. $is_show_fullname . ";\n" |
|
1737
|
|
|
. '</script>'; |
|
1738
|
|
|
$this->xTemplate->assign('ASSOCIATED_JAVASCRIPT_DATA', $associated_javascript_data); |
|
1739
|
|
|
} |
|
1740
|
|
|
|
|
1741
|
|
|
$this->xTemplate->parse($xtemplateSection); |
|
1742
|
|
|
} |
|
1743
|
|
|
|
|
1744
|
|
|
|
|
1745
|
|
|
function getLayoutManager() |
|
1746
|
|
|
{ |
|
1747
|
|
|
require_once('include/generic/LayoutManager.php'); |
|
1748
|
|
|
if($this->layout_manager == null) |
|
1749
|
|
|
{ |
|
1750
|
|
|
$this->layout_manager = new LayoutManager(); |
|
1751
|
|
|
} |
|
1752
|
|
|
return $this->layout_manager; |
|
1753
|
|
|
} |
|
1754
|
|
|
|
|
1755
|
|
|
|
|
1756
|
|
|
function process_dynamic_listview_header($source_module, $subpanel_def, $html_var = 'CELL') |
|
1757
|
|
|
{ |
|
1758
|
|
|
|
|
1759
|
|
|
|
|
1760
|
|
|
$layout_manager = $this->getLayoutManager(); |
|
1761
|
|
|
$layout_manager->setAttribute('order_by_link',$this->processOrderBy($html_var)); |
|
1762
|
|
|
$layout_manager->setAttribute('context','HeaderCell'); |
|
1763
|
|
|
$layout_manager->setAttribute('image_path',$this->local_image_path); |
|
1764
|
|
|
$layout_manager->setAttribute('html_varName',$html_var); |
|
1765
|
|
|
$layout_manager->setAttribute('module_name', $source_module); |
|
1766
|
|
|
list($orderBy,$desc) = $this->getOrderByInfo($html_var); |
|
|
|
|
|
|
1767
|
|
|
|
|
1768
|
|
|
if($orderBy == 'amount*1') |
|
1769
|
|
|
{ |
|
1770
|
|
|
$orderBy= 'amount'; |
|
1771
|
|
|
} |
|
1772
|
|
|
$buttons = false; |
|
1773
|
|
|
$col_count = 0; |
|
1774
|
|
|
foreach($subpanel_def->get_list_fields() as $column_name=>$widget_args) |
|
1775
|
|
|
{ |
|
1776
|
|
|
$usage = empty($widget_args['usage']) ? '' : $widget_args['usage']; |
|
1777
|
|
|
if($usage != 'query_only' || !empty($widget_args['force_query_only_display'])) |
|
1778
|
|
|
{ |
|
1779
|
|
|
$imgArrow = ''; |
|
1780
|
|
|
|
|
1781
|
|
|
if($orderBy == $column_name || (isset($widget_args['sort_by']) && str_replace('.','_',$widget_args['sort_by']) == $orderBy)) |
|
1782
|
|
|
{ |
|
1783
|
|
|
$imgArrow = "_down"; |
|
1784
|
|
|
if($this->sort_order == 'asc') { |
|
1785
|
|
|
$imgArrow = "_up"; |
|
1786
|
|
|
} |
|
1787
|
|
|
} |
|
1788
|
|
|
|
|
1789
|
|
|
if (!preg_match("/_button/i", $column_name)) { |
|
1790
|
|
|
$widget_args['name']=$column_name; |
|
1791
|
|
|
$widget_args['sort'] = $imgArrow; |
|
1792
|
|
|
$widget_args['start_link_wrapper'] = $this->start_link_wrapper; |
|
1793
|
|
|
$widget_args['end_link_wrapper'] = $this->end_link_wrapper; |
|
1794
|
|
|
$widget_args['subpanel_module'] = $this->subpanel_module; |
|
1795
|
|
|
|
|
1796
|
|
|
$widget_contents = $layout_manager->widgetDisplay($widget_args); |
|
1797
|
|
|
$cell_width = empty($widget_args['width']) ? '' : $widget_args['width']; |
|
1798
|
|
|
$this->xTemplate->assign('HEADER_CELL', $widget_contents); |
|
1799
|
|
|
static $count; |
|
1800
|
|
|
if(!isset($count))$count = 0; else $count++; |
|
1801
|
|
|
if($col_count == 0 || $column_name == 'name') $footable = 'data-toggle="true"'; |
|
1802
|
|
|
else { |
|
1803
|
|
|
$footable = 'data-hide="phone"'; |
|
1804
|
|
|
if ($col_count > 2) $footable = 'data-hide="phone,phonelandscape"'; |
|
1805
|
|
|
if ($col_count > 4) $footable = 'data-hide="phone,phonelandscape,tablet"'; |
|
1806
|
|
|
} |
|
1807
|
|
|
$this->xTemplate->assign('FOOTABLE', $footable); |
|
1808
|
|
|
$this->xTemplate->assign('CELL_COUNT', $count); |
|
1809
|
|
|
$this->xTemplate->assign('CELL_WIDTH', $cell_width); |
|
1810
|
|
|
$this->xTemplate->parse('dyn_list_view.header_cell'); |
|
1811
|
|
|
} else { |
|
1812
|
|
|
$buttons = true; |
|
1813
|
|
|
} |
|
1814
|
|
|
} |
|
1815
|
|
|
++$col_count; |
|
1816
|
|
|
} |
|
1817
|
|
|
|
|
1818
|
|
|
if($buttons) { |
|
1819
|
|
|
$this->xTemplate->assign('FOOTABLE', ''); |
|
1820
|
|
|
$this->xTemplate->assign('HEADER_CELL', " "); |
|
1821
|
|
|
$this->xTemplate->assign('CELL_COUNT', $count); |
|
1822
|
|
|
$this->xTemplate->assign('CELL_WIDTH', $cell_width); |
|
1823
|
|
|
$this->xTemplate->parse('dyn_list_view.header_cell'); |
|
1824
|
|
|
} |
|
1825
|
|
|
|
|
1826
|
|
|
} |
|
1827
|
|
|
|
|
1828
|
|
|
|
|
1829
|
|
|
/** |
|
1830
|
|
|
* @return void |
|
1831
|
|
|
* @param unknown $seed |
|
1832
|
|
|
* @param unknown $xTemplateSection |
|
1833
|
|
|
* @param unknown $html_varName |
|
1834
|
|
|
* @desc PUBLIC FUNCTION Handles List Views using seeds that extend SugarBean |
|
1835
|
|
|
$XTemplateSection is the section in the XTemplate file that should be parsed usually main |
|
1836
|
|
|
$html_VarName is the variable name used in the XTemplateFile e.g. TASK |
|
1837
|
|
|
$seed is a seed there are two types of seeds one is a subclass of SugarBean, the other is a list usually created from a sugar bean using get_list |
|
1838
|
|
|
if no XTemplate is set it will create a new XTemplate |
|
1839
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.. |
|
1840
|
|
|
* All Rights Reserved.. |
|
1841
|
|
|
* Contributor(s): ______________________________________.. |
|
1842
|
|
|
*/ |
|
1843
|
|
|
|
|
1844
|
|
|
function processListViewTwo($seed, $xTemplateSection, $html_varName) { |
|
1845
|
|
|
global $current_user; |
|
1846
|
|
|
if(!isset($this->xTemplate)) { |
|
1847
|
|
|
$this->createXTemplate(); |
|
1848
|
|
|
} |
|
1849
|
|
|
|
|
1850
|
|
|
$isSugarBean = is_subclass_of($seed, "SugarBean"); |
|
1851
|
|
|
$list = null; |
|
1852
|
|
|
|
|
1853
|
|
|
if($isSugarBean) { |
|
1854
|
|
|
$list = $this->processSugarBean($xTemplateSection, $html_varName, $seed); |
|
|
|
|
|
|
1855
|
|
|
} else { |
|
1856
|
|
|
$list = $seed; |
|
1857
|
|
|
} |
|
1858
|
|
|
|
|
1859
|
|
|
if (is_object($seed) && isset($seed->object_name) && $seed->object_name == 'WorkFlow') { |
|
1860
|
|
|
$tab=array(); |
|
1861
|
|
|
$access = get_workflow_admin_modules_for_user($current_user); |
|
1862
|
|
|
for ($i = 0; $i < count($list); $i++) { |
|
|
|
|
|
|
1863
|
|
|
if(!empty($access[$list[$i]->base_module])){ |
|
1864
|
|
|
$tab[]=$list[$i]; |
|
1865
|
|
|
} |
|
1866
|
|
|
} |
|
1867
|
|
|
$list = $tab; |
|
1868
|
|
|
} |
|
1869
|
|
|
|
|
1870
|
|
|
if($this->is_dynamic) { |
|
1871
|
|
|
$this->processHeaderDynamic($xTemplateSection,$html_varName); |
|
|
|
|
|
|
1872
|
|
|
$this->processListRows($list,$xTemplateSection, $html_varName); |
|
|
|
|
|
|
1873
|
|
|
} else { |
|
1874
|
|
|
$this->processSortArrows($html_varName); |
|
1875
|
|
|
|
|
1876
|
|
|
if($isSugarBean) { |
|
1877
|
|
|
$seed->parse_additional_headers($this->xTemplate, $xTemplateSection); |
|
1878
|
|
|
} |
|
1879
|
|
|
$this->xTemplateAssign('CHECKALL', SugarThemeRegistry::current()->getImage('blank', '', 1, 1, ".gif", '')); |
|
1880
|
|
|
|
|
1881
|
|
|
// Process the order by before processing the pro_nav. The pro_nav requires the order by values to be set |
|
1882
|
|
|
$this->processOrderBy($html_varName); |
|
1883
|
|
|
|
|
1884
|
|
|
|
|
1885
|
|
|
$this->processListRows($list,$xTemplateSection, $html_varName); |
|
|
|
|
|
|
1886
|
|
|
} |
|
1887
|
|
|
|
|
1888
|
|
|
if($this->display_header_and_footer) { |
|
1889
|
|
|
$this->getAdditionalHeader(); |
|
1890
|
|
|
if(!empty($this->header_title)) { |
|
1891
|
|
|
echo get_form_header($this->header_title, $this->header_text, false); |
|
1892
|
|
|
} |
|
1893
|
|
|
} |
|
1894
|
|
|
|
|
1895
|
|
|
$this->xTemplate->out($xTemplateSection); |
|
1896
|
|
|
|
|
1897
|
|
|
if(isset($_SESSION['validation'])) { |
|
1898
|
|
|
print base64_decode('PGEgaHJlZj0naHR0cDovL3d3dy5zdWdhcmNybS5jb20nPlBPV0VSRUQmbmJzcDtCWSZuYnNwO1NVR0FSQ1JNPC9hPg=='); |
|
1899
|
|
|
} |
|
1900
|
|
|
} |
|
1901
|
|
|
|
|
1902
|
|
|
function getArrowStart() { |
|
1903
|
|
|
$imgFileParts = pathinfo(SugarThemeRegistry::current()->getImageURL("arrow.gif")); |
|
1904
|
|
|
|
|
1905
|
|
|
return " <!--not_in_theme!--><img border='0' src='".$imgFileParts['dirname']."/".$imgFileParts['filename'].""; |
|
1906
|
|
|
} |
|
1907
|
|
|
|
|
1908
|
|
|
function getArrowUpDownStart($upDown) { |
|
1909
|
|
|
$ext = ( SugarThemeRegistry::current()->pngSupport ? "png" : "gif" ); |
|
|
|
|
|
|
1910
|
|
|
|
|
1911
|
|
|
if (!isset($upDown) || empty($upDown)) { |
|
1912
|
|
|
$upDown = ""; |
|
1913
|
|
|
} |
|
1914
|
|
|
return " <img border='0' src='".SugarThemeRegistry::current()->getImageURL("arrow{$upDown}.{$ext}")."' "; |
|
1915
|
|
|
} |
|
1916
|
|
|
|
|
1917
|
|
|
function getArrowEnd() { |
|
1918
|
|
|
$imgFileParts = pathinfo(SugarThemeRegistry::current()->getImageURL("arrow.gif")); |
|
1919
|
|
|
|
|
1920
|
|
|
list($width,$height) = ListView::getArrowImageSize(); |
|
1921
|
|
|
|
|
1922
|
|
|
return '.'.$imgFileParts['extension']."' width='$width' height='$height' align='absmiddle' alt=".translate('LBL_SORT').">"; |
|
1923
|
|
|
} |
|
1924
|
|
|
|
|
1925
|
|
|
function getArrowUpDownEnd($upDown) { |
|
1926
|
|
|
if (!isset($upDown) || empty($upDown)) { |
|
1927
|
|
|
$upDown = ""; |
|
1928
|
|
|
} |
|
1929
|
|
|
$imgFileParts = pathinfo(SugarThemeRegistry::current()->getImageURL("arrow{$upDown}.gif")); |
|
1930
|
|
|
|
|
1931
|
|
|
list($width,$height) = ListView::getArrowUpDownImageSize($upDown); |
|
1932
|
|
|
|
|
1933
|
|
|
//get the right alt tag for the sort |
|
1934
|
|
|
$sortStr = translate('LBL_ALT_SORT'); |
|
1935
|
|
|
if($upDown == '_down'){ |
|
1936
|
|
|
$sortStr = translate('LBL_ALT_SORT_DESC'); |
|
1937
|
|
|
}elseif($upDown == '_up'){ |
|
1938
|
|
|
$sortStr = translate('LBL_ALT_SORT_ASC'); |
|
1939
|
|
|
} |
|
1940
|
|
|
return " width='$width' height='$height' align='absmiddle' alt='$sortStr'>"; |
|
1941
|
|
|
} |
|
1942
|
|
|
|
|
1943
|
|
|
function getArrowImageSize() { |
|
1944
|
|
|
// jbasicChartDashletsExpColust get the non-sort image's size.. the up and down have be the same. |
|
1945
|
|
|
$image = SugarThemeRegistry::current()->getImageURL("arrow.gif",false); |
|
1946
|
|
|
|
|
1947
|
|
|
$cache_key = 'arrow_size.'.$image; |
|
1948
|
|
|
|
|
1949
|
|
|
// Check the cache |
|
1950
|
|
|
$result = sugar_cache_retrieve($cache_key); |
|
1951
|
|
|
if(!empty($result)) |
|
1952
|
|
|
return $result; |
|
1953
|
|
|
|
|
1954
|
|
|
// No cache hit. Calculate the value and return. |
|
1955
|
|
|
$result = getimagesize($image); |
|
1956
|
|
|
sugar_cache_put($cache_key, $result); |
|
1957
|
|
|
return $result; |
|
1958
|
|
|
} |
|
1959
|
|
|
|
|
1960
|
|
|
function getArrowUpDownImageSize($upDown) { |
|
1961
|
|
|
// just get the non-sort image's size.. the up and down have be the same. |
|
1962
|
|
|
$image = SugarThemeRegistry::current()->getImageURL("arrow{$upDown}.gif",false); |
|
1963
|
|
|
|
|
1964
|
|
|
$cache_key = 'arrowupdown_size.'.$image; |
|
1965
|
|
|
|
|
1966
|
|
|
// Check the cache |
|
1967
|
|
|
$result = sugar_cache_retrieve($cache_key); |
|
1968
|
|
|
if(!empty($result)) |
|
1969
|
|
|
return $result; |
|
1970
|
|
|
|
|
1971
|
|
|
// No cache hit. Calculate the value and return. |
|
1972
|
|
|
$result = getimagesize($image); |
|
1973
|
|
|
sugar_cache_put($cache_key, $result); |
|
1974
|
|
|
return $result; |
|
1975
|
|
|
} |
|
1976
|
|
|
|
|
1977
|
|
|
function getOrderByInfo($html_varName) |
|
1978
|
|
|
{ |
|
1979
|
|
|
$orderBy = $this->getSessionVariable($html_varName, "OBL"); |
|
1980
|
|
|
$desc = $this->getSessionVariable($html_varName, $orderBy.'S'); |
|
1981
|
|
|
$orderBy = str_replace('.', '_', $orderBy); |
|
1982
|
|
|
return array($orderBy,$desc); |
|
1983
|
|
|
} |
|
1984
|
|
|
|
|
1985
|
|
|
function processSortArrows($html_varName) |
|
1986
|
|
|
{ |
|
1987
|
|
|
|
|
1988
|
|
|
$this->xTemplateAssign("arrow_start", $this->getArrowStart()); |
|
1989
|
|
|
|
|
1990
|
|
|
list($orderBy,$desc) = $this->getOrderByInfo($html_varName); |
|
1991
|
|
|
|
|
1992
|
|
|
$imgArrow = "_up"; |
|
1993
|
|
|
if($desc) { |
|
1994
|
|
|
$imgArrow = "_down"; |
|
1995
|
|
|
} |
|
1996
|
|
|
/** |
|
1997
|
|
|
* @deprecated only used by legacy opportunites listview, nothing current. Leaving for BC |
|
1998
|
|
|
*/ |
|
1999
|
|
|
if($orderBy == 'amount') |
|
2000
|
|
|
{ |
|
2001
|
|
|
$this->xTemplateAssign('amount_arrow', $imgArrow); |
|
2002
|
|
|
} |
|
2003
|
|
|
else if($orderBy == 'amount_usdollar') |
|
2004
|
|
|
{ |
|
2005
|
|
|
$this->xTemplateAssign('amount_usdollar_arrow', $imgArrow); |
|
2006
|
|
|
} |
|
2007
|
|
|
else |
|
2008
|
|
|
{ |
|
2009
|
|
|
$this->xTemplateAssign($orderBy.'_arrow', $imgArrow); |
|
2010
|
|
|
} |
|
2011
|
|
|
|
|
2012
|
|
|
$this->xTemplateAssign('arrow_end', $this->getArrowEnd()); |
|
2013
|
|
|
} |
|
2014
|
|
|
|
|
2015
|
|
|
// this is where translation happens for dynamic list views |
|
2016
|
|
|
function loadListFieldDefs(&$subpanel_fields,&$child_focus) |
|
2017
|
|
|
{ |
|
2018
|
|
|
$this->list_field_defs = $subpanel_fields; |
|
2019
|
|
|
|
|
2020
|
|
|
for($i=0;$i < count($this->list_field_defs);$i++) |
|
|
|
|
|
|
2021
|
|
|
{ |
|
2022
|
|
|
$list_field = $this->list_field_defs[$i]; |
|
2023
|
|
|
$field_def = null; |
|
2024
|
|
|
$key = ''; |
|
2025
|
|
|
if(!empty($list_field['vname'])) |
|
2026
|
|
|
{ |
|
2027
|
|
|
$key = $list_field['vname']; |
|
2028
|
|
|
} else if(isset($list_field['name']) && isset($child_focus->field_defs[$list_field['name']])) |
|
2029
|
|
|
{ |
|
2030
|
|
|
$field_def = $child_focus->field_defs[$list_field['name']]; |
|
2031
|
|
|
$key = $field_def['vname']; |
|
2032
|
|
|
} |
|
2033
|
|
|
if(!empty($key)) |
|
2034
|
|
|
{ |
|
2035
|
|
|
$list_field['label'] = translate($key,$child_focus->module_dir); |
|
2036
|
|
|
$this->list_field_defs[$i]['label'] = preg_replace('/:$/','',$list_field['label']); |
|
2037
|
|
|
} |
|
2038
|
|
|
else |
|
2039
|
|
|
{ |
|
2040
|
|
|
$this->list_field_defs[$i]['label'] =' '; |
|
2041
|
|
|
} |
|
2042
|
|
|
} |
|
2043
|
|
|
} |
|
2044
|
|
|
|
|
2045
|
|
|
function unique_id() { |
|
2046
|
|
|
return sugar_microtime(); |
|
2047
|
|
|
} |
|
2048
|
|
|
|
|
2049
|
|
|
/**INTERNAL FUNCTION sets a session variable keeping it local to the listview |
|
2050
|
|
|
not the current_module |
|
2051
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
2052
|
|
|
* All Rights Reserved. |
|
2053
|
|
|
* Contributor(s): ______________________________________. |
|
2054
|
|
|
*/ |
|
2055
|
|
|
function setLocalSessionVariable($localVarName,$varName, $value) { |
|
2056
|
|
|
$_SESSION[$localVarName."_".$varName] = $value; |
|
2057
|
|
|
} |
|
2058
|
|
|
|
|
2059
|
|
|
/**INTERNAL FUNCTION returns a session variable that is local to the listview, |
|
2060
|
|
|
not the current_module |
|
2061
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
2062
|
|
|
* All Rights Reserved. |
|
2063
|
|
|
* Contributor(s): ______________________________________. |
|
2064
|
|
|
*/ |
|
2065
|
|
|
function getLocalSessionVariable($localVarName,$varName) { |
|
2066
|
|
|
if(isset($_SESSION[$localVarName."_".$varName])) { |
|
2067
|
|
|
return $_SESSION[$localVarName."_".$varName]; |
|
2068
|
|
|
} |
|
2069
|
|
|
else{ |
|
2070
|
|
|
return ""; |
|
2071
|
|
|
} |
|
2072
|
|
|
} |
|
2073
|
|
|
|
|
2074
|
|
|
/* Set to true if you want Additional Details to appear in the listview |
|
2075
|
|
|
*/ |
|
2076
|
|
|
function setAdditionalDetails($value = true, $function = '') { |
|
2077
|
|
|
if(!empty($function)) $this->additionalDetailsFunction = $function; |
|
2078
|
|
|
$this->_additionalDetails = $value; |
|
2079
|
|
|
} |
|
2080
|
|
|
|
|
2081
|
|
|
} |
|
2082
|
|
|
?> |
|
2083
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$irelandis not defined by the methodfinale(...).The most likely cause is that the parameter was changed, but the annotation was not.