This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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 - 2015 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 | function getEditFieldHTML($module, $fieldname, $aow_field, $view = 'EditView', $id = '', $alt_type = '', $currency_id = '') |
||
41 | { |
||
42 | |||
43 | global $current_language, $app_strings, $app_list_strings, $current_user, $beanFiles, $beanList; |
||
44 | |||
45 | $bean = BeanFactory::getBean($module,$id); |
||
46 | |||
47 | if(!checkAccess($bean)){ |
||
48 | return false; |
||
49 | } |
||
50 | |||
51 | |||
52 | $value = getFieldValueFromModule($fieldname, $module, $id); |
||
53 | // use the mod_strings for this module |
||
54 | $mod_strings = return_module_language($current_language, $module); |
||
55 | |||
56 | // set the filename for this control |
||
57 | $file = create_cache_directory('include/InlineEditing/') . $module . $view . $alt_type . $fieldname . '.tpl'; |
||
58 | |||
59 | if (!is_file($file) |
||
60 | || inDeveloperMode() |
||
61 | || !empty($_SESSION['developerMode']) |
||
62 | ) { |
||
63 | |||
64 | if (!isset($vardef)) { |
||
0 ignored issues
–
show
|
|||
65 | require_once($beanFiles[$beanList[$module]]); |
||
66 | $focus = new $beanList[$module]; |
||
67 | $vardef = $focus->getFieldDefinition($fieldname); |
||
68 | } |
||
69 | |||
70 | $displayParams = array(); |
||
71 | //$displayParams['formName'] = 'EditView'; |
||
72 | |||
73 | // if this is the id relation field, then don't have a pop-up selector. |
||
74 | if ($vardef['type'] == 'relate' && $vardef['id_name'] == $vardef['name']) { |
||
75 | $vardef['type'] = 'varchar'; |
||
76 | } |
||
77 | |||
78 | if (isset($vardef['precision'])) unset($vardef['precision']); |
||
79 | |||
80 | //$vardef['precision'] = $locale->getPrecedentPreference('default_currency_significant_digits', $current_user); |
||
81 | |||
82 | //TODO Fix datetimecomebo |
||
83 | //temp work around |
||
84 | if ($vardef['type'] == 'datetime') { |
||
85 | $vardef['type'] = 'datetimecombo'; |
||
86 | } |
||
87 | |||
88 | // trim down textbox display |
||
89 | if ($vardef['type'] == 'text') { |
||
90 | $vardef['rows'] = 2; |
||
91 | $vardef['cols'] = 32; |
||
92 | } |
||
93 | |||
94 | // create the dropdowns for the parent type fields |
||
95 | if ($vardef['type'] == 'parent_type') { |
||
96 | $vardef['type'] = 'enum'; |
||
97 | } |
||
98 | |||
99 | if ($vardef['type'] == 'link') { |
||
100 | $vardef['type'] = 'relate'; |
||
101 | $vardef['rname'] = 'name'; |
||
102 | $vardef['id_name'] = $vardef['name'] . '_id'; |
||
103 | if ((!isset($vardef['module']) || $vardef['module'] == '') && $focus->load_relationship($vardef['name'])) { |
||
104 | $vardef['module'] = $focus->{$vardef['name']}->getRelatedModuleName(); |
||
105 | } |
||
106 | |||
107 | } |
||
108 | |||
109 | //check for $alt_type |
||
110 | if ($alt_type != '') { |
||
111 | $vardef['type'] = $alt_type; |
||
112 | } |
||
113 | |||
114 | // remove the special text entry field function 'getEmailAddressWidget' |
||
115 | if (isset($vardef['function']) |
||
116 | && ($vardef['function'] == 'getEmailAddressWidget' |
||
117 | || $vardef['function']['name'] == 'getEmailAddressWidget') |
||
118 | ) |
||
119 | unset($vardef['function']); |
||
120 | |||
121 | if (isset($vardef['name']) && ($vardef['name'] == 'date_modified')) { |
||
122 | $vardef['name'] = 'aow_temp_date'; |
||
123 | } |
||
124 | |||
125 | // load SugarFieldHandler to render the field tpl file |
||
126 | static $sfh; |
||
127 | |||
128 | if (!isset($sfh)) { |
||
129 | require_once('include/SugarFields/SugarFieldHandler.php'); |
||
130 | $sfh = new SugarFieldHandler(); |
||
131 | } |
||
132 | |||
133 | $contents = $sfh->displaySmarty('fields', $vardef, $view, $displayParams); |
||
134 | |||
135 | // Remove all the copyright comments |
||
136 | $contents = preg_replace('/\{\*[^\}]*?\*\}/', '', $contents); |
||
137 | // remove extra wrong javascript which breaks auto complete on flexi relationship parent fields |
||
138 | $contents = preg_replace("/<script language=\"javascript\">if\(typeof sqs_objects == \'undefined\'\){var sqs_objects = new Array;}sqs_objects\[\'EditView_parent_name\'\].*?<\/script>/","",$contents); |
||
139 | |||
140 | |||
141 | if ($view == 'EditView' && ($vardef['type'] == 'relate' || $vardef['type'] == 'parent')) { |
||
142 | |||
143 | $contents = str_replace('"' . $vardef['id_name'] . '"', '{/literal}"{$fields.' . $vardef['name'] . '.id_name}"{literal}', $contents); |
||
144 | $contents = str_replace('"' . $vardef['name'] . '"', '{/literal}"{$fields.' . $vardef['name'] . '.name}"{literal}', $contents); |
||
145 | // regex below fixes button javascript for flexi relationship |
||
146 | if($vardef['type'] == 'parent') { |
||
147 | $contents = str_replace("onclick='open_popup(document.{\$form_name}.parent_type.value, 600, 400, \"\", true, false, {literal}{\"call_back_function\":\"set_return\",\"form_name\":\"EditView\",\"field_to_name_array\":{\"id\":{/literal}\"{\$fields.parent_name.id_name}", "onclick='open_popup(document.{\$form_name}.parent_type.value, 600, 400, \"\", true, false, {literal}{\"call_back_function\":\"set_return\",\"form_name\":\"EditView\",\"field_to_name_array\":{\"id\":{/literal}\"parent_id", $contents); |
||
148 | } |
||
149 | } |
||
150 | |||
151 | // hack to disable one of the js calls in this control |
||
152 | if (isset($vardef['function']) && ($vardef['function'] == 'getCurrencyDropDown' || $vardef['function']['name'] == 'getCurrencyDropDown')) |
||
153 | $contents .= "{literal}<script>function CurrencyConvertAll() { return; }</script>{/literal}"; |
||
154 | |||
155 | |||
156 | |||
157 | // Save it to the cache file |
||
158 | if ($fh = @sugar_fopen($file, 'w')) { |
||
159 | fputs($fh, $contents); |
||
160 | fclose($fh); |
||
161 | } |
||
162 | } |
||
163 | |||
164 | // Now render the template we received |
||
165 | $ss = new Sugar_Smarty(); |
||
166 | |||
167 | // Create Smarty variables for the Calendar picker widget |
||
168 | global $timedate; |
||
169 | $time_format = $timedate->get_user_time_format(); |
||
170 | $date_format = $timedate->get_cal_date_format(); |
||
171 | $ss->assign('USER_DATEFORMAT', $timedate->get_user_date_format()); |
||
172 | $ss->assign('TIME_FORMAT', $time_format); |
||
173 | $time_separator = ":"; |
||
174 | $match = array(); |
||
175 | if (preg_match('/\d+([^\d])\d+([^\d]*)/s', $time_format, $match)) { |
||
176 | $time_separator = $match[1]; |
||
177 | } |
||
178 | $t23 = strpos($time_format, '23') !== false ? '%H' : '%I'; |
||
179 | if (!isset($match[2]) || $match[2] == '') { |
||
180 | $ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . "%M"); |
||
181 | } else { |
||
182 | $pm = $match[2] == "pm" ? "%P" : "%p"; |
||
183 | $ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . "%M" . $pm); |
||
184 | } |
||
185 | |||
186 | $ss->assign('CALENDAR_FDOW', $current_user->get_first_day_of_week()); |
||
187 | |||
188 | $fieldlist = array(); |
||
189 | if (!isset($focus) || !($focus instanceof SugarBean)) |
||
190 | require_once($beanFiles[$beanList[$module]]); |
||
191 | $focus = new $beanList[$module]; |
||
192 | // create the dropdowns for the parent type fields |
||
193 | $vardefFields[$fieldname] = $focus->field_defs[$fieldname]; |
||
194 | if ($vardefFields[$fieldname]['type'] == 'parent') { |
||
195 | $focus->field_defs[$fieldname]['options'] = $focus->field_defs[$vardefFields[$fieldname]['group']]['options']; |
||
196 | } |
||
197 | foreach ($vardefFields as $name => $properties) { |
||
198 | $fieldlist[$name] = $properties; |
||
199 | // fill in enums |
||
200 | if (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($app_list_strings[$fieldlist[$name]['options']])) |
||
201 | $fieldlist[$name]['options'] = $app_list_strings[$fieldlist[$name]['options']]; |
||
202 | // Bug 32626: fall back on checking the mod_strings if not in the app_list_strings |
||
203 | elseif (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($mod_strings[$fieldlist[$name]['options']])) |
||
204 | $fieldlist[$name]['options'] = $mod_strings[$fieldlist[$name]['options']]; |
||
205 | } |
||
206 | |||
207 | // fill in function return values |
||
208 | if (!in_array($fieldname, array('email1', 'email2'))) { |
||
209 | if (!empty($fieldlist[$fieldname]['function']['returns']) && $fieldlist[$fieldname]['function']['returns'] == 'html') { |
||
210 | $function = $fieldlist[$fieldname]['function']['name']; |
||
211 | // include various functions required in the various vardefs |
||
212 | if (isset($fieldlist[$fieldname]['function']['include']) && is_file($fieldlist[$fieldname]['function']['include'])) |
||
213 | require_once($fieldlist[$fieldname]['function']['include']); |
||
214 | $_REQUEST[$fieldname] = $value; |
||
215 | $value = $function($focus, $fieldname, $value, $view); |
||
216 | |||
217 | $value = str_ireplace($fieldname, $aow_field, $value); |
||
218 | } |
||
219 | } |
||
220 | |||
221 | if ($fieldlist[$fieldname]['type'] == 'link') { |
||
222 | $fieldlist[$fieldname]['id_name'] = $fieldlist[$fieldname]['name'] . '_id'; |
||
223 | |||
224 | if ((!isset($fieldlist[$fieldname]['module']) || $fieldlist[$fieldname]['module'] == '') && $focus->load_relationship($fieldlist[$fieldname]['name'])) { |
||
225 | $relateField = $fieldlist[$fieldname]['name']; |
||
226 | $fieldlist[$fieldname]['module'] = $focus->$relateField->getRelatedModuleName(); |
||
227 | } |
||
228 | } |
||
229 | |||
230 | if($fieldlist[$fieldname]['type'] == 'parent'){ |
||
231 | $fieldlist['parent_id']['name'] = 'parent_id'; |
||
232 | } |
||
233 | |||
234 | if (isset($fieldlist[$fieldname]['name']) && ($fieldlist[$fieldname]['name'] == 'date_modified')) { |
||
235 | $fieldlist[$fieldname]['name'] = 'aow_temp_date'; |
||
236 | $fieldlist['aow_temp_date'] = $fieldlist[$fieldname]; |
||
237 | $fieldname = 'aow_temp_date'; |
||
238 | } |
||
239 | |||
240 | if (isset($fieldlist[$fieldname]['id_name']) && $fieldlist[$fieldname]['id_name'] != '' && $fieldlist[$fieldname]['id_name'] != $fieldlist[$fieldname]['name']) { |
||
241 | if($value){ |
||
242 | $relateIdField = $fieldlist[$fieldname]['id_name']; |
||
243 | $rel_value = $bean->$relateIdField; |
||
244 | |||
245 | } |
||
246 | $fieldlist[$fieldlist[$fieldname]['id_name']]['value'] = $rel_value; |
||
247 | $fieldlist[$fieldname]['value'] = $value; |
||
248 | $fieldlist[$fieldname]['id_name'] = $aow_field; |
||
249 | $fieldlist[$fieldname]['name'] = $aow_field . '_display'; |
||
250 | } else if (isset($fieldlist[$fieldname]['type']) && ($fieldlist[$fieldname]['type'] == 'datetimecombo' || $fieldlist[$fieldname]['type'] == 'datetime')) { |
||
251 | $value = $focus->convertField($value, $fieldlist[$fieldname]); |
||
252 | if (!$value) { |
||
253 | $value = date($timedate->get_date_time_format()); |
||
254 | } |
||
255 | $fieldlist[$fieldname]['name'] = $aow_field; |
||
256 | $fieldlist[$fieldname]['value'] = $value; |
||
257 | } else if (isset($fieldlist[$fieldname]['type']) && ($fieldlist[$fieldname]['type'] == 'date')) { |
||
258 | $value = $focus->convertField($value, $fieldlist[$fieldname]); |
||
259 | $fieldlist[$fieldname]['name'] = $aow_field; |
||
260 | if (empty($value) == "") { |
||
261 | $value = str_replace("%", "", date($date_format)); |
||
262 | } |
||
263 | $fieldlist[$fieldname]['value'] = $value; |
||
264 | } else { |
||
265 | $fieldlist[$fieldname]['value'] = $value; |
||
266 | $fieldlist[$fieldname]['name'] = $aow_field; |
||
267 | |||
268 | } |
||
269 | |||
270 | if ($fieldlist[$fieldname]['type'] == 'currency' && $view != 'EditView') { |
||
271 | static $sfh; |
||
272 | |||
273 | if (!isset($sfh)) { |
||
274 | require_once('include/SugarFields/SugarFieldHandler.php'); |
||
275 | $sfh = new SugarFieldHandler(); |
||
276 | } |
||
277 | |||
278 | if ($currency_id != '' && !stripos($fieldname, '_USD')) { |
||
279 | $userCurrencyId = $current_user->getPreference('currency'); |
||
280 | if ($currency_id != $userCurrencyId) { |
||
281 | $currency = new Currency(); |
||
282 | $currency->retrieve($currency_id); |
||
283 | $value = $currency->convertToDollar($value); |
||
284 | $currency->retrieve($userCurrencyId); |
||
285 | $value = $currency->convertFromDollar($value); |
||
286 | } |
||
287 | } |
||
288 | |||
289 | $parentfieldlist[strtoupper($fieldname)] = $value; |
||
290 | |||
291 | return ($sfh->displaySmarty($parentfieldlist, $fieldlist[$fieldname], 'ListView', $displayParams)); |
||
292 | } |
||
293 | |||
294 | $ss->assign("fields", $fieldlist); |
||
295 | $ss->assign("form_name", $view); |
||
296 | $ss->assign("bean", $focus); |
||
297 | |||
298 | $ss->assign("MOD", $mod_strings); |
||
299 | $ss->assign("APP", $app_strings); |
||
300 | |||
301 | return json_encode($ss->fetch($file)); |
||
302 | } |
||
303 | |||
304 | function saveField($field, $id, $module, $value) |
||
305 | { |
||
306 | |||
307 | $bean = BeanFactory::getBean($module, $id); |
||
308 | |||
309 | if (is_object($bean) && $bean->id != "") { |
||
310 | |||
311 | if ($bean->field_defs[$field]['type'] == "multienum") { |
||
312 | $bean->$field = encodeMultienumValue($value); |
||
313 | }else if ($bean->field_defs[$field]['type'] == "relate" || $bean->field_defs[$field]['type'] == 'parent'){ |
||
314 | $save_field = $bean->field_defs[$field]['id_name']; |
||
315 | $bean->$save_field = $value; |
||
316 | if ($bean->field_defs[$field]['type'] == 'parent') { |
||
317 | $bean->parent_type = $_REQUEST['parent_type']; |
||
318 | $bean->fill_in_additional_parent_fields(); // get up to date parent info as need it to display name |
||
319 | } |
||
320 | }else{ |
||
321 | $bean->$field = $value; |
||
322 | } |
||
323 | |||
324 | $bean->save(); |
||
325 | return getDisplayValue($bean, $field); |
||
326 | } else { |
||
327 | return false; |
||
328 | } |
||
329 | |||
330 | } |
||
331 | |||
332 | function getDisplayValue($bean, $field, $method = "save") |
||
333 | { |
||
334 | |||
335 | if (file_exists("custom/modules/Accounts/metadata/listviewdefs.php")) { |
||
336 | $metadata = require("custom/modules/Accounts/metadata/listviewdefs.php"); |
||
337 | } else { |
||
338 | $metadata = require("modules/Accounts/metadata/listviewdefs.php"); |
||
339 | } |
||
340 | |||
341 | $listViewDefs = $listViewDefs['Accounts'][strtoupper($field)]; |
||
0 ignored issues
–
show
The variable
$listViewDefs seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?
This error can happen if you refactor code and forget to move the variable initialization. Let’s take a look at a simple example: function someFunction() {
$x = 5;
echo $x;
}
The above code is perfectly fine. Now imagine that we re-order the statements: function someFunction() {
echo $x;
$x = 5;
}
In that case, ![]() |
|||
342 | |||
343 | $fieldlist[$field] = $bean->getFieldDefinition($field); |
||
344 | |||
345 | if(is_array($listViewDefs)){ |
||
346 | $fieldlist[$field] = array_merge($fieldlist[$field], $listViewDefs); |
||
347 | } |
||
348 | |||
349 | $value = formatDisplayValue($bean, $bean->$field, $fieldlist[$field], $method); |
||
350 | |||
351 | return $value; |
||
352 | } |
||
353 | |||
354 | function formatDisplayValue($bean, $value, $vardef, $method = "save") |
||
355 | { |
||
356 | |||
357 | global $app_list_strings, $timedate; |
||
358 | |||
359 | //Fake the params so we can pass the values through the sugarwidgets to get the correct display html. |
||
360 | |||
361 | $GLOBALS['focus'] = $bean; |
||
362 | $_REQUEST['record'] = $bean->id; |
||
363 | $vardef['fields']['ID'] = $bean->id; |
||
364 | $vardef['fields'][strtoupper($vardef['name'])] = $value; |
||
365 | |||
366 | // If field is of type email. |
||
367 | if ($vardef['name'] == "email1" && $vardef['group'] == "email1") { |
||
368 | |||
369 | require_once("include/generic/SugarWidgets/SugarWidgetSubPanelEmailLink.php"); |
||
370 | $SugarWidgetSubPanelEmailLink = new SugarWidgetSubPanelEmailLink($vardef); |
||
371 | $value = $SugarWidgetSubPanelEmailLink->displayList($vardef); |
||
372 | |||
373 | } |
||
374 | |||
375 | //If field is of type link and name. |
||
376 | if ($vardef['link'] && $vardef['type'] == "name" && $_REQUEST['view'] != "DetailView") { |
||
377 | |||
378 | require_once("include/generic/SugarWidgets/SugarWidgetSubPanelDetailViewLink.php"); |
||
379 | |||
380 | $vardef['module'] = $bean->module_dir; |
||
381 | |||
382 | $SugarWidgetSubPanelDetailViewLink = new SugarWidgetSubPanelDetailViewLink($vardef); |
||
383 | $value = "<b>" . $SugarWidgetSubPanelDetailViewLink->displayList($vardef) . "</b>"; |
||
384 | |||
385 | } |
||
386 | |||
387 | //If field is of type date time or datetimecombo |
||
388 | if ($vardef['type'] == "datetimecombo" || $vardef['type'] == "datetime") { |
||
389 | |||
390 | |||
391 | if ($method != "save") { |
||
392 | $value = convertDateUserToDB($value); |
||
393 | } |
||
394 | $datetime_format = $timedate->get_date_time_format(); |
||
395 | // create utc date (as it's utc in db) |
||
396 | $datetime = DateTime::createFromFormat("Y-m-d H:i:s", $value,new DateTimeZone('UTC')); |
||
397 | // convert it to timezone the user uses |
||
398 | $datetime = $timedate->tzUser($datetime); |
||
399 | |||
400 | $value = $datetime->format($datetime_format); |
||
401 | |||
402 | } |
||
403 | |||
404 | //If field is of type bool, checkbox. |
||
405 | if ($vardef['type'] == "bool") { |
||
406 | |||
407 | require_once("include/generic/LayoutManager.php"); |
||
408 | $layoutManager = new LayoutManager(); |
||
409 | |||
410 | require_once("include/generic/SugarWidgets/SugarWidgetFieldbool.php"); |
||
411 | |||
412 | $SugarWidgetFieldbool = new SugarWidgetFieldbool($layoutManager); |
||
413 | $value = $SugarWidgetFieldbool->displayListPlain($vardef); |
||
414 | |||
415 | } |
||
416 | |||
417 | //if field is of type multienum. |
||
418 | if ($vardef['type'] == "multienum") { |
||
419 | $value = str_replace("^", "", $value); |
||
420 | |||
421 | $array_values = explode(",", $value); |
||
422 | |||
423 | foreach ($array_values as $value) { |
||
424 | $values[] = $app_list_strings[$vardef['options']][$value]; |
||
425 | } |
||
426 | $value = implode(", ", $values); |
||
427 | } |
||
428 | |||
429 | //if field is of type radio. |
||
430 | if ($vardef['type'] == "radioenum" || $vardef['type'] == "enum") { |
||
431 | $value = $app_list_strings[$vardef['options']][$value]; |
||
432 | } |
||
433 | |||
434 | //if field is of type relate. |
||
435 | if ($vardef['type'] == "relate" || $vardef['type'] == "parent") { |
||
436 | |||
437 | if($vardef['source'] == "non-db"){ |
||
438 | |||
439 | if($vardef['module'] == "Employees"){ |
||
440 | $vardef['ext2'] = "Users"; |
||
441 | $vardef['rname'] = "full_name"; |
||
442 | } |
||
443 | |||
444 | } |
||
445 | if($vardef['type'] == "parent") { |
||
446 | $vardef['module'] = $bean->parent_type; |
||
447 | $name = $bean->parent_name; |
||
448 | } |
||
449 | $idName = $vardef['id_name']; |
||
450 | $record = $bean->$idName; |
||
451 | |||
452 | if($vardef['name'] != "assigned_user_name") { |
||
453 | $value = "<a class=\"listViewTdLinkS1\" href=\"index.php?action=DetailView&module=".$vardef['module']."&record=$record\">"; |
||
454 | } else { |
||
455 | $value = ""; |
||
456 | } |
||
457 | |||
458 | |||
459 | //To fix github bug 880 (the rname was null and was causing a 500 error in the getFieldValueFromModule call to $fieldname |
||
460 | $fieldName = 'name';//$vardef['name']; |
||
461 | if(!is_null($vardef['rname'])) |
||
462 | $fieldName = $vardef['rname']; |
||
463 | |||
464 | if($vardef['ext2']){ |
||
465 | |||
466 | $value .= getFieldValueFromModule($fieldName,$vardef['ext2'],$record); |
||
467 | |||
468 | }else if(!empty($vardef['rname'])){ |
||
469 | $value .= getFieldValueFromModule($fieldName,$vardef['module'],$record); |
||
470 | |||
471 | } else { |
||
472 | $value .= $name; |
||
473 | } |
||
474 | |||
475 | if($vardef['name'] != "assigned_user_name") { |
||
476 | $value .= "</a>"; |
||
477 | } |
||
478 | } |
||
479 | |||
480 | |||
481 | return $value; |
||
482 | } |
||
483 | |||
484 | function getFieldValueFromModule($fieldname, $module, $id) |
||
485 | { |
||
486 | //Github bug 880, if the fieldname is null, do no call from bean |
||
487 | if(is_null($fieldname)) |
||
488 | return ''; |
||
489 | |||
490 | $bean = BeanFactory::getBean($module, $id); |
||
491 | if (is_object($bean) && $bean->id != "") { |
||
492 | return $bean->$fieldname; |
||
493 | } |
||
494 | |||
495 | } |
||
496 | |||
497 | function convertDateUserToDB($value) |
||
498 | { |
||
499 | global $timedate; |
||
500 | |||
501 | $datetime_format = $timedate->get_date_time_format(); |
||
502 | $datetime = DateTime::createFromFormat($datetime_format, $value); |
||
503 | |||
504 | $value = $datetime->format("Y-m-d H:i:s"); |
||
505 | return $value; |
||
506 | } |
||
507 | |||
508 | function checkAccess($bean){ |
||
509 | |||
510 | if($bean->ACLAccess('EditView')) { |
||
511 | return true; |
||
512 | }else { |
||
513 | return false; |
||
514 | } |
||
515 | } |
||
516 | |||
517 |
This check marks calls to
isset(...)
orempty(...)
that are found before the variable itself is defined. These will always have the same result.This is likely the result of code being shifted around. Consider removing these calls.