|
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
|
|
|
|
|
42
|
1 |
|
require_once('include/ListView/ListViewDisplay.php'); |
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
1 |
|
require_once('include/contextMenus/contextMenu.php'); |
|
46
|
|
|
|
|
47
|
|
|
class ListViewSmarty extends ListViewDisplay{ |
|
48
|
|
|
|
|
49
|
|
|
var $data; |
|
50
|
|
|
var $ss; // the smarty object |
|
51
|
|
|
var $displayColumns; |
|
52
|
|
|
var $searchColumns; // set by view.list.php |
|
53
|
|
|
var $tpl; |
|
54
|
|
|
var $moduleString; |
|
55
|
|
|
var $export = true; |
|
56
|
|
|
var $delete = true; |
|
57
|
|
|
var $select = true; |
|
58
|
|
|
var $mailMerge = true; |
|
59
|
|
|
var $email = true; |
|
60
|
|
|
var $targetList = false; |
|
61
|
|
|
var $multiSelect = true; |
|
62
|
|
|
var $quickViewLinks = true; |
|
63
|
|
|
var $lvd; |
|
64
|
|
|
var $mergeduplicates = true; |
|
65
|
|
|
var $contextMenus = true; |
|
66
|
|
|
var $showMassupdateFields = true; |
|
67
|
|
|
var $menu_location = 'top'; |
|
68
|
|
|
/** |
|
69
|
|
|
* Constructor, Smarty object immediately available after |
|
70
|
|
|
* |
|
71
|
|
|
*/ |
|
72
|
5 |
|
public function __construct() { |
|
73
|
5 |
|
parent::__construct(); |
|
74
|
5 |
|
$this->ss = new Sugar_Smarty(); |
|
75
|
5 |
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @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 |
|
79
|
|
|
*/ |
|
80
|
|
|
public function ListViewSmarty(){ |
|
81
|
|
|
$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
|
82
|
|
|
if(isset($GLOBALS['log'])) { |
|
83
|
|
|
$GLOBALS['log']->deprecated($deprecatedMessage); |
|
84
|
|
|
} |
|
85
|
|
|
else { |
|
86
|
|
|
trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
|
87
|
|
|
} |
|
88
|
|
|
self::__construct(); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Processes the request. Calls ListViewData process. Also assigns all lang strings, export links, |
|
94
|
|
|
* This is called from ListViewDisplay |
|
95
|
|
|
* |
|
96
|
|
|
* @param file file Template file to use |
|
97
|
|
|
* @param data array from ListViewData |
|
98
|
|
|
* @param html_var string the corresponding html var in xtpl per row |
|
99
|
|
|
* |
|
100
|
|
|
*/ |
|
101
|
4 |
|
function process($file, $data, $htmlVar) { |
|
102
|
4 |
|
if(!$this->should_process)return; |
|
103
|
4 |
|
global $odd_bg, $even_bg, $hilite_bg, $click_bg, $app_strings, $sugar_config; |
|
104
|
4 |
|
parent::process($file, $data, $htmlVar); |
|
105
|
|
|
|
|
106
|
4 |
|
$this->tpl = $file; |
|
107
|
4 |
|
$this->data = $data; |
|
108
|
|
|
|
|
109
|
4 |
|
$totalWidth = 0; |
|
110
|
4 |
|
foreach($this->displayColumns as $name => $params) { |
|
111
|
2 |
|
$totalWidth += $params['width']; |
|
112
|
|
|
} |
|
113
|
4 |
|
$adjustment = $totalWidth / 100; |
|
114
|
|
|
|
|
115
|
4 |
|
$contextMenuObjectsTypes = array(); |
|
116
|
4 |
|
foreach($this->displayColumns as $name => $params) { |
|
117
|
2 |
|
$this->displayColumns[$name]['width'] = floor($this->displayColumns[$name]['width'] / $adjustment); |
|
118
|
|
|
// figure out which contextMenu objectsTypes are required |
|
119
|
2 |
|
if(!empty($params['contextMenu']['objectType'])) |
|
120
|
2 |
|
$contextMenuObjectsTypes[$params['contextMenu']['objectType']] = true; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
//Check if inline editing is enabled for list view. |
|
124
|
4 |
|
if(!isset($sugar_config['enable_line_editing_list']) || $sugar_config['enable_line_editing_list']){ |
|
125
|
4 |
|
$this->ss->assign('inline_edit', true); |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
4 |
|
$this->ss->assign('sugarconfig', $this->displayColumns); |
|
129
|
4 |
|
$this->ss->assign('displayColumns', $this->displayColumns); |
|
130
|
4 |
|
$this->ss->assign('APP',$app_strings); |
|
131
|
|
|
|
|
132
|
4 |
|
$this->ss->assign('bgHilite', $hilite_bg); |
|
133
|
4 |
|
$this->ss->assign('colCount', count($this->displayColumns) + 10); |
|
134
|
4 |
|
$this->ss->assign('htmlVar', strtoupper($htmlVar)); |
|
135
|
4 |
|
$this->ss->assign('moduleString', $this->moduleString); |
|
136
|
4 |
|
$this->ss->assign('editLinkString', $app_strings['LBL_EDIT_BUTTON']); |
|
137
|
4 |
|
$this->ss->assign('viewLinkString', $app_strings['LBL_VIEW_BUTTON']); |
|
138
|
4 |
|
$this->ss->assign('allLinkString',$app_strings['LBL_LINK_ALL']); |
|
139
|
4 |
|
$this->ss->assign('noneLinkString',$app_strings['LBL_LINK_NONE']); |
|
140
|
4 |
|
$this->ss->assign('recordsLinkString',$app_strings['LBL_LINK_RECORDS']); |
|
141
|
4 |
|
$this->ss->assign('selectLinkString',$app_strings['LBL_LINK_SELECT']); |
|
142
|
|
|
|
|
143
|
|
|
// Bug 24677 - Correct the page total amount on the last page of listviews |
|
144
|
4 |
|
$pageTotal = $this->data['pageData']['offsets']['next']-$this->data['pageData']['offsets']['current']; |
|
145
|
4 |
|
if ( $this->data['pageData']['offsets']['next'] < 0 ) { |
|
146
|
4 |
|
$pageTotal = $this->data['pageData']['offsets']['total'] - $this->data['pageData']['offsets']['current']; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
4 |
|
if($this->select)$this->ss->assign('selectLinkTop', $this->buildSelectLink('select_link', $this->data['pageData']['offsets']['total'], $pageTotal)); |
|
150
|
4 |
|
if($this->select)$this->ss->assign('selectLinkBottom', $this->buildSelectLink('select_link', $this->data['pageData']['offsets']['total'], $pageTotal, "bottom")); |
|
151
|
|
|
|
|
152
|
4 |
|
if($this->show_action_dropdown) |
|
153
|
|
|
{ |
|
154
|
4 |
|
$action_menu = $this->buildActionsLink(); |
|
155
|
4 |
|
$this->ss->assign('actionsLinkTop', $action_menu); |
|
156
|
4 |
|
if(count($action_menu['buttons']) > 0) { |
|
157
|
4 |
|
$this->ss->assign('actionDisabledLink', preg_replace("/id\s*\=(\"\w+\"|w+)/i", "", $action_menu['buttons'][0])); |
|
158
|
|
|
} |
|
159
|
4 |
|
$menu_location = 'bottom'; |
|
160
|
4 |
|
$this->ss->assign('actionsLinkBottom', $this->buildActionsLink('actions_link' ,$menu_location)); |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
4 |
|
$this->ss->assign('quickViewLinks', $this->quickViewLinks); |
|
164
|
|
|
|
|
165
|
|
|
// handle save checks and stuff |
|
166
|
4 |
|
if($this->multiSelect) |
|
167
|
|
|
{ |
|
168
|
2 |
|
$this->ss->assign('selectedObjectsSpan', $this->buildSelectedObjectsSpan(true, (isset($_POST['mass'])) ? count($_POST['mass']): 0)); |
|
169
|
2 |
|
$this->ss->assign('multiSelectData', $this->getMultiSelectData()); |
|
170
|
|
|
} else { |
|
171
|
2 |
|
$this->ss->assign('multiSelectData', '<textarea style="display: none" name="uid"></textarea>'); |
|
172
|
|
|
} |
|
173
|
|
|
// include button for Adding to Target List if in one of four applicable modules |
|
174
|
4 |
|
if ( isset ( $_REQUEST['module']) && in_array ( $_REQUEST['module'] , array ( 'Contacts','Prospects','Leads','Accounts' )) |
|
175
|
4 |
|
&& ACLController::checkAccess('ProspectLists','edit',true)) { |
|
176
|
|
|
$this->ss->assign( 'targetLink', $this->buildTargetList() ) ; |
|
177
|
|
|
} |
|
178
|
4 |
|
$this->processArrows($data['pageData']['ordering']); |
|
179
|
4 |
|
$this->ss->assign('prerow', $this->multiSelect); |
|
180
|
4 |
|
$this->ss->assign('clearAll', $app_strings['LBL_CLEARALL']); |
|
181
|
4 |
|
$this->ss->assign('rowColor', array('oddListRow', 'evenListRow')); |
|
182
|
4 |
|
$this->ss->assign('bgColor', array($odd_bg, $even_bg)); |
|
183
|
4 |
|
$this->ss->assign('contextMenus', $this->contextMenus); |
|
184
|
4 |
|
$this->ss->assign('is_admin_for_user', $GLOBALS['current_user']->isAdminForModule('Users')); |
|
185
|
4 |
|
$this->ss->assign('is_admin', $GLOBALS['current_user']->isAdmin()); |
|
186
|
|
|
|
|
187
|
|
|
|
|
188
|
4 |
|
if($this->contextMenus && !empty($contextMenuObjectsTypes)) { |
|
189
|
|
|
$script = ''; |
|
190
|
|
|
$cm = new contextMenu(); |
|
191
|
|
|
foreach($contextMenuObjectsTypes as $type => $value) { |
|
192
|
|
|
$cm->loadFromFile($type); |
|
193
|
|
|
$script .= $cm->getScript(); |
|
194
|
|
|
$cm->menuItems = array(); // clear menuItems out |
|
195
|
|
|
} |
|
196
|
|
|
$this->ss->assign('contextMenuScript', $script); |
|
197
|
|
|
} |
|
198
|
4 |
|
} |
|
199
|
|
|
|
|
200
|
|
|
/** |
|
201
|
|
|
* Assigns the sort arrows in the tpl |
|
202
|
|
|
* |
|
203
|
|
|
* @param ordering array data that contains the ordering info |
|
204
|
|
|
* |
|
205
|
|
|
*/ |
|
206
|
4 |
|
function processArrows($ordering) |
|
207
|
|
|
{ |
|
208
|
4 |
|
$pathParts = pathinfo(SugarThemeRegistry::current()->getImageURL('arrow.gif',false)); |
|
209
|
|
|
|
|
210
|
4 |
|
list($width,$height) = getimagesize($pathParts['dirname'].'/'.$pathParts['basename']); |
|
211
|
|
|
|
|
212
|
4 |
|
$this->ss->assign('arrowExt', $pathParts['extension']); |
|
213
|
4 |
|
$this->ss->assign('arrowWidth', $width); |
|
214
|
4 |
|
$this->ss->assign('arrowHeight', $height); |
|
215
|
4 |
|
$this->ss->assign('arrowAlt', translate('LBL_SORT')); |
|
216
|
4 |
|
} |
|
217
|
|
|
|
|
218
|
|
|
|
|
219
|
|
|
|
|
220
|
|
|
/** |
|
221
|
|
|
* Displays the xtpl, either echo or returning the contents |
|
222
|
|
|
* |
|
223
|
|
|
* @param end bool display the ending of the listview data (ie MassUpdate) |
|
224
|
|
|
* |
|
225
|
|
|
*/ |
|
226
|
3 |
|
function display($end = true) { |
|
227
|
|
|
|
|
228
|
3 |
|
if(!$this->should_process) return $GLOBALS['app_strings']['LBL_SEARCH_POPULATE_ONLY']; |
|
229
|
3 |
|
global $app_strings, $sugar_version, $sugar_flavor, $server_unique_key, $currentModule, $app_list_strings; |
|
230
|
3 |
|
$this->ss->assign('moduleListSingular', $app_list_strings["moduleListSingular"]); |
|
231
|
3 |
|
$this->ss->assign('moduleList', $app_list_strings['moduleList']); |
|
232
|
3 |
|
$this->ss->assign('data', $this->data['data']); |
|
233
|
3 |
|
$this->ss->assign('query', $this->data['query']); |
|
234
|
3 |
|
$this->ss->assign('sugar_info', array("sugar_version" => $sugar_version, |
|
235
|
3 |
|
"sugar_flavor" => $sugar_flavor)); |
|
236
|
3 |
|
$this->data['pageData']['offsets']['lastOffsetOnPage'] = $this->data['pageData']['offsets']['current'] + count($this->data['data']); |
|
237
|
3 |
|
$this->ss->assign('pageData', $this->data['pageData']); |
|
238
|
|
|
|
|
239
|
3 |
|
$navStrings = array('next' => $app_strings['LNK_LIST_NEXT'], |
|
240
|
3 |
|
'previous' => $app_strings['LNK_LIST_PREVIOUS'], |
|
241
|
3 |
|
'end' => $app_strings['LNK_LIST_END'], |
|
242
|
3 |
|
'start' => $app_strings['LNK_LIST_START'], |
|
243
|
3 |
|
'of' => $app_strings['LBL_LIST_OF']); |
|
244
|
3 |
|
$this->ss->assign('navStrings', $navStrings); |
|
245
|
|
|
|
|
246
|
3 |
|
$displayEmptyDataMessages = TRUE; |
|
247
|
|
|
//TODO: Cleanup, better logic for which modules are exempt from the new messaging. |
|
248
|
3 |
|
$modulesExemptFromEmptyDataMessages = array('WorkFlow','ContractTypes', 'OAuthKeys', 'TimePeriods'); |
|
249
|
3 |
|
if( (isset($GLOBALS['moduleTabMap'][$currentModule]) && $GLOBALS['moduleTabMap'][$currentModule] == 'Administration') |
|
250
|
3 |
|
|| isset($GLOBALS['adminOnlyList'][$currentModule]) || in_array($currentModule, $modulesExemptFromEmptyDataMessages) ) |
|
251
|
|
|
{ |
|
252
|
|
|
$displayEmptyDataMessages = FALSE; |
|
253
|
|
|
} |
|
254
|
3 |
|
$this->ss->assign('displayEmptyDataMesssages', $displayEmptyDataMessages); |
|
255
|
|
|
|
|
256
|
3 |
|
$str = parent::display(); |
|
257
|
3 |
|
$strend = $this->displayEnd(); |
|
258
|
|
|
|
|
259
|
3 |
|
return $str . $this->ss->fetch($this->tpl) . (($end) ? $strend : ''); |
|
|
|
|
|
|
260
|
|
|
} |
|
261
|
3 |
|
function displayEnd() { |
|
262
|
3 |
|
$str = ''; |
|
263
|
3 |
|
if($this->show_mass_update_form) { |
|
264
|
1 |
|
if($this->showMassupdateFields){ |
|
265
|
1 |
|
$str .= $this->mass->getMassUpdateForm(true); |
|
266
|
|
|
} |
|
267
|
1 |
|
$str .= $this->mass->endMassUpdateForm(); |
|
268
|
|
|
} |
|
269
|
|
|
|
|
270
|
3 |
|
return $str; |
|
271
|
|
|
} |
|
272
|
|
|
} |
|
273
|
|
|
|
|
274
|
|
|
?> |
|
275
|
|
|
|
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.