1
|
|
|
<?php |
2
|
|
|
/********************************************************************************* |
3
|
|
|
* SugarCRM Community Edition is a customer relationship management program developed by |
4
|
|
|
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
5
|
|
|
|
6
|
|
|
* SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd. |
7
|
|
|
* Copyright (C) 2011 - 2014 Salesagility Ltd. |
8
|
|
|
* |
9
|
|
|
* This program is free software; you can redistribute it and/or modify it under |
10
|
|
|
* the terms of the GNU Affero General Public License version 3 as published by the |
11
|
|
|
* Free Software Foundation with the addition of the following permission added |
12
|
|
|
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK |
13
|
|
|
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY |
14
|
|
|
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. |
15
|
|
|
* |
16
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT |
17
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
18
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
19
|
|
|
* details. |
20
|
|
|
* |
21
|
|
|
* You should have received a copy of the GNU Affero General Public License along with |
22
|
|
|
* this program; if not, see http://www.gnu.org/licenses or write to the Free |
23
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
24
|
|
|
* 02110-1301 USA. |
25
|
|
|
* |
26
|
|
|
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, |
27
|
|
|
* SW2-130, Cupertino, CA 95014, USA. or at email address [email protected]. |
28
|
|
|
* |
29
|
|
|
* The interactive user interfaces in modified source and object code versions |
30
|
|
|
* of this program must display Appropriate Legal Notices, as required under |
31
|
|
|
* Section 5 of the GNU Affero General Public License version 3. |
32
|
|
|
* |
33
|
|
|
* In accordance with Section 7(b) of the GNU Affero General Public License version 3, |
34
|
|
|
* these Appropriate Legal Notices must retain the display of the "Powered by |
35
|
|
|
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not |
36
|
|
|
* reasonably feasible for technical reasons, the Appropriate Legal Notices must |
37
|
|
|
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
38
|
|
|
********************************************************************************/ |
39
|
|
|
|
40
|
|
|
class ViewPopup extends SugarView{ |
41
|
|
|
protected $override_popup = array(); |
42
|
|
|
var $type ='list'; |
43
|
|
|
|
44
|
2 |
|
public function __construct(){ |
45
|
2 |
|
parent::__construct(); |
46
|
2 |
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @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 |
50
|
|
|
*/ |
51
|
|
|
public function ViewPopup(){ |
52
|
|
|
$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
53
|
|
|
if(isset($GLOBALS['log'])) { |
54
|
|
|
$GLOBALS['log']->deprecated($deprecatedMessage); |
55
|
|
|
} |
56
|
|
|
else { |
57
|
|
|
trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
58
|
|
|
} |
59
|
|
|
self::__construct(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
|
63
|
1 |
|
function display(){ |
64
|
1 |
|
global $popupMeta, $mod_strings; |
65
|
|
|
|
66
|
1 |
|
if(($this->bean instanceOf SugarBean) && !$this->bean->ACLAccess('list')){ |
67
|
|
|
ACLController::displayNoAccess(); |
68
|
|
|
sugar_cleanup(true); |
69
|
|
|
} |
70
|
|
|
|
71
|
1 |
|
if(isset($_REQUEST['metadata']) && strpos($_REQUEST['metadata'], "..") !== false) |
72
|
|
|
die("Directory navigation attack denied."); |
73
|
1 |
|
if (!empty($_REQUEST['metadata']) && $_REQUEST['metadata'] != 'undefined' |
74
|
1 |
|
&& file_exists('custom/modules/' . $this->module . '/metadata/' . $_REQUEST['metadata'] . '.php')) { |
75
|
|
|
require 'custom/modules/' . $this->module . '/metadata/' . $_REQUEST['metadata'] . '.php'; |
76
|
1 |
|
} elseif (!empty($_REQUEST['metadata']) && $_REQUEST['metadata'] != 'undefined' |
77
|
1 |
|
&& file_exists('modules/' . $this->module . '/metadata/' . $_REQUEST['metadata'] . '.php')) { |
78
|
|
|
require 'modules/' . $this->module . '/metadata/' . $_REQUEST['metadata'] . '.php'; |
79
|
1 |
|
} elseif (file_exists('custom/modules/' . $this->module . '/metadata/popupdefs.php')) { |
80
|
|
|
require 'custom/modules/' . $this->module . '/metadata/popupdefs.php'; |
81
|
1 |
|
} elseif (file_exists('modules/' . $this->module . '/metadata/popupdefs.php')) { |
82
|
1 |
|
require 'modules/' . $this->module . '/metadata/popupdefs.php'; |
83
|
|
|
} |
84
|
|
|
|
85
|
1 |
|
if(!empty($popupMeta) && !empty($popupMeta['listviewdefs'])){ |
86
|
1 |
|
if(is_array($popupMeta['listviewdefs'])){ |
87
|
|
|
//if we have an array, then we are not going to include a file, but rather the |
88
|
|
|
//listviewdefs will be defined directly in the popupdefs file |
89
|
1 |
|
$listViewDefs[$this->module] = $popupMeta['listviewdefs']; |
90
|
|
|
}else{ |
91
|
|
|
//otherwise include the file |
92
|
1 |
|
require_once($popupMeta['listviewdefs']); |
93
|
|
|
} |
94
|
|
|
}elseif(file_exists('custom/modules/' . $this->module . '/metadata/listviewdefs.php')){ |
95
|
|
|
require_once('custom/modules/' . $this->module . '/metadata/listviewdefs.php'); |
96
|
|
|
}elseif(file_exists('modules/' . $this->module . '/metadata/listviewdefs.php')){ |
97
|
|
|
require_once('modules/' . $this->module . '/metadata/listviewdefs.php'); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
//check for searchdefs as well |
101
|
1 |
|
if(!empty($popupMeta) && !empty($popupMeta['searchdefs'])){ |
102
|
1 |
|
if(is_array($popupMeta['searchdefs'])){ |
103
|
|
|
//if we have an array, then we are not going to include a file, but rather the |
104
|
|
|
//searchdefs will be defined directly in the popupdefs file |
105
|
1 |
|
$searchdefs[$this->module]['layout']['advanced_search'] = $popupMeta['searchdefs']; |
106
|
|
|
}else{ |
107
|
|
|
//otherwise include the file |
108
|
1 |
|
require_once($popupMeta['searchdefs']); |
109
|
|
|
} |
110
|
|
|
}else if(empty($searchdefs) && file_exists('custom/modules/'.$this->module.'/metadata/searchdefs.php')){ |
|
|
|
|
111
|
|
|
require_once('custom/modules/'.$this->module.'/metadata/searchdefs.php'); |
112
|
|
|
}else if(empty($searchdefs) && file_exists('modules/'.$this->module.'/metadata/searchdefs.php')){ |
113
|
|
|
require_once('modules/'.$this->module.'/metadata/searchdefs.php'); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
//if you click the pagination button, it will populate the search criteria here |
117
|
1 |
|
if(!empty($this->bean) && isset($_REQUEST[$this->module.'2_'.strtoupper($this->bean->object_name).'_offset'])) { |
118
|
|
|
if(!empty($_REQUEST['current_query_by_page'])) { |
119
|
|
|
$blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount', |
120
|
|
|
'sortOrder', 'orderBy', 'request_data', 'current_query_by_page'); |
121
|
|
|
$current_query_by_page = sugar_unserialize(base64_decode($_REQUEST['current_query_by_page'])); |
122
|
|
|
foreach($current_query_by_page as $search_key=>$search_value) { |
123
|
|
|
if($search_key != $this->module.'2_'.strtoupper($this->bean->object_name).'_offset' |
124
|
|
|
&& !in_array($search_key, $blockVariables)) { |
125
|
|
|
if (!is_array($search_value)) { |
126
|
|
|
$_REQUEST[$search_key] = securexss($search_value); |
127
|
|
|
} |
128
|
|
|
else { |
129
|
|
|
foreach ($search_value as $key=>&$val) { |
130
|
|
|
$val = securexss($val); |
131
|
|
|
} |
132
|
|
|
$_REQUEST[$search_key] = $search_value; |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
} |
137
|
|
|
} |
138
|
|
|
|
139
|
1 |
|
if(!empty($listViewDefs) && !empty($searchdefs)){ |
140
|
1 |
|
require_once('include/Popups/PopupSmarty.php'); |
141
|
1 |
|
$displayColumns = array(); |
142
|
1 |
|
$filter_fields = array(); |
143
|
1 |
|
$popup = new PopupSmarty($this->bean, $this->module); |
144
|
1 |
|
foreach($listViewDefs[$this->module] as $col => $params) { |
145
|
1 |
|
$filter_fields[strtolower($col)] = true; |
146
|
1 |
|
if(!empty($params['related_fields'])) { |
147
|
|
|
foreach($params['related_fields'] as $field) { |
148
|
|
|
//id column is added by query construction function. This addition creates duplicates |
149
|
|
|
//and causes issues in oracle. #10165 |
150
|
|
|
if ($field != 'id') { |
151
|
|
|
$filter_fields[$field] = true; |
152
|
|
|
} |
153
|
|
|
} |
154
|
|
|
} |
155
|
1 |
|
if(!empty($params['default']) && $params['default']) |
156
|
1 |
|
$displayColumns[$col] = $params; |
157
|
|
|
} |
158
|
1 |
|
$popup->displayColumns = $displayColumns; |
159
|
1 |
|
$popup->filter_fields = $filter_fields; |
160
|
1 |
|
$popup->mergeDisplayColumns = true; |
161
|
|
|
//check to see if popupdefs contains searchdefs |
162
|
1 |
|
$popup->_popupMeta = $popupMeta; |
163
|
1 |
|
$popup->listviewdefs = $listViewDefs; |
164
|
1 |
|
$popup->searchdefs = $searchdefs; |
165
|
|
|
|
166
|
1 |
|
if(isset($_REQUEST['query'])){ |
167
|
|
|
$popup->searchForm->populateFromRequest(); |
168
|
|
|
} |
169
|
|
|
|
170
|
1 |
|
$massUpdateData = ''; |
171
|
1 |
|
if(isset($_REQUEST['mass'])) { |
172
|
|
|
foreach(array_unique($_REQUEST['mass']) as $record) { |
173
|
|
|
$massUpdateData .= "<input style='display: none' checked type='checkbox' name='mass[]' value='$record'>\n"; |
174
|
|
|
} |
175
|
|
|
} |
176
|
1 |
|
$popup->massUpdateData = $massUpdateData; |
177
|
|
|
|
178
|
1 |
|
$tpl = 'include/Popups/tpls/PopupGeneric.tpl'; |
179
|
1 |
|
if(file_exists($this->getCustomFilePathIfExists("modules/{$this->module}/tpls/popupGeneric.tpl"))) |
180
|
|
|
{ |
181
|
|
|
$tpl = $this->getCustomFilePathIfExists("modules/{$this->module}/tpls/popupGeneric.tpl"); |
182
|
|
|
} |
183
|
|
|
|
184
|
1 |
|
if(file_exists($this->getCustomFilePathIfExists("modules/{$this->module}/tpls/popupHeader.tpl"))) |
185
|
|
|
{ |
186
|
|
|
$popup->headerTpl = $this->getCustomFilePathIfExists("modules/{$this->module}/tpls/popupHeader.tpl"); |
187
|
|
|
} |
188
|
|
|
|
189
|
1 |
|
if(file_exists($this->getCustomFilePathIfExists("modules/{$this->module}/tpls/popupFooter.tpl"))) |
190
|
|
|
{ |
191
|
|
|
$popup->footerTpl = $this->getCustomFilePathIfExists("modules/{$this->module}/tpls/popupFooter.tpl"); |
192
|
|
|
} |
193
|
|
|
|
194
|
1 |
|
$popup->setup($tpl); |
195
|
|
|
|
196
|
|
|
//We should at this point show the header and javascript even if to_pdf is true. |
197
|
|
|
//The insert_popup_header javascript is incomplete and shouldn't be relied on. |
198
|
1 |
|
if (isset($this->options['show_all']) && $this->options['show_all'] == false) |
199
|
|
|
{ |
200
|
|
|
unset($this->options['show_all']); |
201
|
|
|
$this->options['show_javascript'] = true; |
202
|
|
|
$this->options['show_header'] = true; |
203
|
|
|
$this->_displayJavascript(); |
204
|
|
|
} |
205
|
1 |
|
insert_popup_header(null, false); |
206
|
1 |
|
if(isset($this->override_popup['template_data']) && is_array($this->override_popup['template_data'])) |
207
|
|
|
{ |
208
|
|
|
$popup->th->ss->assign($this->override_popup['template_data']); |
209
|
|
|
} |
210
|
1 |
|
echo $popup->display(); |
211
|
|
|
|
212
|
|
|
}else{ |
213
|
|
|
if(file_exists('modules/' . $this->module . '/Popup_picker.php')){ |
214
|
|
|
require_once('modules/' . $this->module . '/Popup_picker.php'); |
215
|
|
|
}else{ |
216
|
|
|
require_once('include/Popups/Popup_picker.php'); |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
$popup = new Popup_Picker(); |
220
|
|
|
$popup->_hide_clear_button = true; |
221
|
|
|
echo $popup->process_page(); |
222
|
|
|
} |
223
|
1 |
|
} |
224
|
|
|
} |
225
|
|
|
?> |
226
|
|
|
|
This check looks for calls to
isset(...)
orempty()
on variables that are yet undefined. These calls will always produce the same result and can be removed.This is most likely caused by the renaming of a variable or the removal of a function/method parameter.