@@ -281,11 +281,11 @@ discard block |
||
281 | 281 | */ |
282 | 282 | function smarty_function_sugar_button($params, &$smarty) |
283 | 283 | { |
284 | - if(empty($params['module'])) { |
|
284 | + if (empty($params['module'])) { |
|
285 | 285 | $smarty->trigger_error("sugar_button: missing required param (module)"); |
286 | - } else if(empty($params['id'])) { |
|
286 | + } else if (empty($params['id'])) { |
|
287 | 287 | $smarty->trigger_error("sugar_button: missing required param (id)"); |
288 | - } else if(empty($params['view'])) { |
|
288 | + } else if (empty($params['view'])) { |
|
289 | 289 | $smarty->trigger_error("sugar_button: missing required param (view)"); |
290 | 290 | } |
291 | 291 | |
@@ -294,10 +294,10 @@ discard block |
||
294 | 294 | $type = $params['id']; |
295 | 295 | $location = (empty($params['location'])) ? "" : "_".$params['location']; |
296 | 296 | |
297 | - if(!is_array($type)) { |
|
297 | + if (!is_array($type)) { |
|
298 | 298 | $module = $params['module']; |
299 | 299 | $view = $params['view']; |
300 | - switch(strtoupper($type)) { |
|
300 | + switch (strtoupper($type)) { |
|
301 | 301 | case "SEARCH": |
302 | 302 | $output = '<input tabindex="2" title="{$APP.LBL_SEARCH_BUTTON_TITLE}" onclick="SUGAR.savedViews.setChooser();" class="button" type="submit" name="button" value="{$APP.LBL_SEARCH_BUTTON_LABEL}" id="search_form_submit"/> '; |
303 | 303 | break; |
@@ -317,28 +317,28 @@ discard block |
||
317 | 317 | break; |
318 | 318 | |
319 | 319 | case "DELETE": |
320 | - $output = '{if $bean->aclAccess("delete")}<input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="button" onclick="'.$js_form.' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'ListView\'; _form.action.value=\'Delete\'; if(confirm(\'{$APP.NTC_DELETE_CONFIRMATION}\')) SUGAR.ajaxUI.submitForm(_form);" type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}" id="delete_button">{/if} '; |
|
320 | + $output = '{if $bean->aclAccess("delete")}<input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="button" onclick="'.$js_form.' _form.return_module.value=\''.$module.'\'; _form.return_action.value=\'ListView\'; _form.action.value=\'Delete\'; if(confirm(\'{$APP.NTC_DELETE_CONFIRMATION}\')) SUGAR.ajaxUI.submitForm(_form);" type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}" id="delete_button">{/if} '; |
|
321 | 321 | break; |
322 | 322 | |
323 | 323 | case "DUPLICATE": |
324 | - $output = '{if $bean->aclAccess("edit")}<input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="button" onclick="'.$js_form.' _form.return_module.value=\''. $module . '\'; _form.return_action.value=\'DetailView\'; _form.isDuplicate.value=true; _form.action.value=\'' . $view . '\'; _form.return_id.value=\'{$id}\';SUGAR.ajaxUI.submitForm(_form);" type="button" name="Duplicate" value="{$APP.LBL_DUPLICATE_BUTTON_LABEL}" id="duplicate_button">{/if} '; |
|
324 | + $output = '{if $bean->aclAccess("edit")}<input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="button" onclick="'.$js_form.' _form.return_module.value=\''.$module.'\'; _form.return_action.value=\'DetailView\'; _form.isDuplicate.value=true; _form.action.value=\''.$view.'\'; _form.return_id.value=\'{$id}\';SUGAR.ajaxUI.submitForm(_form);" type="button" name="Duplicate" value="{$APP.LBL_DUPLICATE_BUTTON_LABEL}" id="duplicate_button">{/if} '; |
|
325 | 325 | break; |
326 | 326 | |
327 | 327 | case "EDIT"; |
328 | - $output = '{if $bean->aclAccess("edit")}<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="button primary" onclick="'.$js_form.' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'DetailView\'; _form.return_id.value=\'{$id}\'; _form.action.value=\'EditView\';SUGAR.ajaxUI.submitForm(_form);" type="button" name="Edit" id="edit_button" value="{$APP.LBL_EDIT_BUTTON_LABEL}">{/if} '; |
|
328 | + $output = '{if $bean->aclAccess("edit")}<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="button primary" onclick="'.$js_form.' _form.return_module.value=\''.$module.'\'; _form.return_action.value=\'DetailView\'; _form.return_id.value=\'{$id}\'; _form.action.value=\'EditView\';SUGAR.ajaxUI.submitForm(_form);" type="button" name="Edit" id="edit_button" value="{$APP.LBL_EDIT_BUTTON_LABEL}">{/if} '; |
|
329 | 329 | break; |
330 | 330 | |
331 | 331 | case "FIND_DUPLICATES": |
332 | - $output = '{if $bean->aclAccess("edit") && $bean->aclAccess("delete")}<input title="{$APP.LBL_DUP_MERGE}" class="button" onclick="'.$js_form.' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'DetailView\'; _form.return_id.value=\'{$id}\'; _form.action.value=\'Step1\'; _form.module.value=\'MergeRecords\';SUGAR.ajaxUI.submitForm(_form);" type="button" name="Merge" value="{$APP.LBL_DUP_MERGE}" id="merge_duplicate_button">{/if} '; |
|
332 | + $output = '{if $bean->aclAccess("edit") && $bean->aclAccess("delete")}<input title="{$APP.LBL_DUP_MERGE}" class="button" onclick="'.$js_form.' _form.return_module.value=\''.$module.'\'; _form.return_action.value=\'DetailView\'; _form.return_id.value=\'{$id}\'; _form.action.value=\'Step1\'; _form.module.value=\'MergeRecords\';SUGAR.ajaxUI.submitForm(_form);" type="button" name="Merge" value="{$APP.LBL_DUP_MERGE}" id="merge_duplicate_button">{/if} '; |
|
333 | 333 | break; |
334 | 334 | |
335 | 335 | case "SAVE": |
336 | 336 | $view = ($_REQUEST['action'] == 'EditView') ? 'EditView' : (($view == 'EditView') ? 'EditView' : $view); |
337 | - $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button primary" onclick="'.$js_form.' {if $isDuplicate}_form.return_id.value=\'\'; {/if}_form.action.value=\'Save\'; if(check_form(\'' . $view . '\'))SUGAR.ajaxUI.submitForm(_form);return false;" type="submit" name="button" value="{$APP.LBL_SAVE_BUTTON_LABEL}" id="'.$type.$location.'">{/if} '; |
|
337 | + $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button primary" onclick="'.$js_form.' {if $isDuplicate}_form.return_id.value=\'\'; {/if}_form.action.value=\'Save\'; if(check_form(\''.$view.'\'))SUGAR.ajaxUI.submitForm(_form);return false;" type="submit" name="button" value="{$APP.LBL_SAVE_BUTTON_LABEL}" id="'.$type.$location.'">{/if} '; |
|
338 | 338 | break; |
339 | 339 | |
340 | 340 | case "SUBPANELSAVE": |
341 | - if($view == 'QuickCreate' || (isset($_REQUEST['target_action']) && strtolower($_REQUEST['target_action']) == 'quickcreate')) $view = "form_SubpanelQuickCreate_{$module}"; |
|
341 | + if ($view == 'QuickCreate' || (isset($_REQUEST['target_action']) && strtolower($_REQUEST['target_action']) == 'quickcreate')) $view = "form_SubpanelQuickCreate_{$module}"; |
|
342 | 342 | |
343 | 343 | /* BEGIN - SECURITY GROUPS - redirect a subpanel save to the detail view if select popup and user in more than 1 group*/ |
344 | 344 | /** |
@@ -355,20 +355,20 @@ discard block |
||
355 | 355 | $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" class="button" onclick="'.$js_form.' disableOnUnloadEditView(); _form.action.value=\'Save\';if(check_form(\''.$view.'\'))return SUGAR.subpanelUtils.inlineSave(_form.id, \'' . $params['module'] . '_subpanel_save_button\');return false;" type="submit" name="' . $params['module'] . '_subpanel_save_button" id="' . $params['module'] . '_subpanel_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; |
356 | 356 | |
357 | 357 | */ |
358 | - $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" class="button" onclick="'.$js_form.' disableOnUnloadEditView(); _form.action.value=\'Save\';if(check_form(\''.$view.'\'))return SUGAR.subpanelUtils.inlineSave(_form.id, \'' . $params['module'] . '_subpanel_save_button\');return false;" type="submit" name="' . $params['module'] . '_subpanel_save_button" id="' . $params['module'] . '_subpanel_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; |
|
358 | + $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" class="button" onclick="'.$js_form.' disableOnUnloadEditView(); _form.action.value=\'Save\';if(check_form(\''.$view.'\'))return SUGAR.subpanelUtils.inlineSave(_form.id, \''.$params['module'].'_subpanel_save_button\');return false;" type="submit" name="'.$params['module'].'_subpanel_save_button" id="'.$params['module'].'_subpanel_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; |
|
359 | 359 | /* END - SECURITY GROUPS */ |
360 | 360 | |
361 | 361 | break; |
362 | 362 | case "SUBPANELCANCEL": |
363 | - $output = '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" class="button" onclick="return SUGAR.subpanelUtils.cancelCreate($(this).attr(\'id\'));return false;" type="submit" name="' . $params['module'] . '_subpanel_cancel_button" id="' . $params['module'] . '_subpanel_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; |
|
363 | + $output = '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" class="button" onclick="return SUGAR.subpanelUtils.cancelCreate($(this).attr(\'id\'));return false;" type="submit" name="'.$params['module'].'_subpanel_cancel_button" id="'.$params['module'].'_subpanel_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; |
|
364 | 364 | |
365 | 365 | break; |
366 | 366 | case "SUBPANELFULLFORM": |
367 | - $output = '<input title="{$APP.LBL_FULL_FORM_BUTTON_TITLE}" class="button" onclick="'.$js_form.' disableOnUnloadEditView(_form); _form.return_action.value=\'DetailView\'; _form.action.value=\'EditView\'; if(typeof(_form.to_pdf)!=\'undefined\') _form.to_pdf.value=\'0\';" type="submit" name="' . $params['module'] . '_subpanel_full_form_button" id="' . $params['module'] . '_subpanel_full_form_button" value="{$APP.LBL_FULL_FORM_BUTTON_LABEL}"> '; |
|
367 | + $output = '<input title="{$APP.LBL_FULL_FORM_BUTTON_TITLE}" class="button" onclick="'.$js_form.' disableOnUnloadEditView(_form); _form.return_action.value=\'DetailView\'; _form.action.value=\'EditView\'; if(typeof(_form.to_pdf)!=\'undefined\') _form.to_pdf.value=\'0\';" type="submit" name="'.$params['module'].'_subpanel_full_form_button" id="'.$params['module'].'_subpanel_full_form_button" value="{$APP.LBL_FULL_FORM_BUTTON_LABEL}"> '; |
|
368 | 368 | $output .= '<input type="hidden" name="full_form" value="full_form">'; |
369 | 369 | break; |
370 | 370 | case "DCMENUCANCEL": |
371 | - $output = '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="javascript:lastLoadedMenu=undefined;DCMenu.closeOverlay();return false;" type="submit" name="' . $params['module'] . '_dcmenu_cancel_button" id="' . $params['module'] . '_dcmenu_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; |
|
371 | + $output = '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="javascript:lastLoadedMenu=undefined;DCMenu.closeOverlay();return false;" type="submit" name="'.$params['module'].'_dcmenu_cancel_button" id="'.$params['module'].'_dcmenu_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; |
|
372 | 372 | break; |
373 | 373 | case "DCMENUSAVE": |
374 | 374 | if ($view == 'QuickCreate') { |
@@ -376,10 +376,10 @@ discard block |
||
376 | 376 | } else if ($view == 'EditView') { |
377 | 377 | $view = "form_DCEditView_{$module}"; |
378 | 378 | } |
379 | - $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button primary" onclick="'.$js_form.' _form.action.value=\'Save\';if(check_form(\''.$view.'\'))return DCMenu.save(_form.id, \'' . $params['module'] . '_subpanel_save_button\');return false;" type="submit" name="' . $params['module'] . '_dcmenu_save_button" id="' . $params['module'] . '_dcmenu_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; |
|
379 | + $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button primary" onclick="'.$js_form.' _form.action.value=\'Save\';if(check_form(\''.$view.'\'))return DCMenu.save(_form.id, \''.$params['module'].'_subpanel_save_button\');return false;" type="submit" name="'.$params['module'].'_dcmenu_save_button" id="'.$params['module'].'_dcmenu_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; |
|
380 | 380 | break; |
381 | 381 | case "DCMENUFULLFORM": |
382 | - $output = '<input title="{$APP.LBL_FULL_FORM_BUTTON_TITLE}" accessKey="{$APP.LBL_FULL_FORM_BUTTON_KEY}" class="button" onclick="'.$js_form.' disableOnUnloadEditView(_form); _form.return_action.value=\'DetailView\'; _form.action.value=\'EditView\'; _form.return_module.value=\'' . $params['module'] . '\';_form.return_id.value=_form.record.value;if(typeof(_form.to_pdf)!=\'undefined\') _form.to_pdf.value=\'0\';SUGAR.ajaxUI.submitForm(_form,null,true);DCMenu.closeOverlay();" type="button" name="' . $params['module'] . '_subpanel_full_form_button" id="' . $params['module'] . '_subpanel_full_form_button" value="{$APP.LBL_FULL_FORM_BUTTON_LABEL}"> '; |
|
382 | + $output = '<input title="{$APP.LBL_FULL_FORM_BUTTON_TITLE}" accessKey="{$APP.LBL_FULL_FORM_BUTTON_KEY}" class="button" onclick="'.$js_form.' disableOnUnloadEditView(_form); _form.return_action.value=\'DetailView\'; _form.action.value=\'EditView\'; _form.return_module.value=\''.$params['module'].'\';_form.return_id.value=_form.record.value;if(typeof(_form.to_pdf)!=\'undefined\') _form.to_pdf.value=\'0\';SUGAR.ajaxUI.submitForm(_form,null,true);DCMenu.closeOverlay();" type="button" name="'.$params['module'].'_subpanel_full_form_button" id="'.$params['module'].'_subpanel_full_form_button" value="{$APP.LBL_FULL_FORM_BUTTON_LABEL}"> '; |
|
383 | 383 | $output .= '<input type="hidden" name="full_form" value="full_form">'; |
384 | 384 | $output .= '<input type="hidden" name="is_admin" value="">'; |
385 | 385 | break; |
@@ -387,15 +387,15 @@ discard block |
||
387 | 387 | $view = ($view == 'QuickCreate') ? "form_QuickCreate_{$module}" : $view; |
388 | 388 | $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" ' |
389 | 389 | . 'class="button primary" onclick="'.$js_form.' _form.action.value=\'Popup\';' |
390 | - . 'return check_form(\''.$view.'\')" type="submit" name="' . $params['module'] |
|
391 | - . '_popupcreate_save_button" id="' . $params['module'] |
|
390 | + . 'return check_form(\''.$view.'\')" type="submit" name="'.$params['module'] |
|
391 | + . '_popupcreate_save_button" id="'.$params['module'] |
|
392 | 392 | . '_popupcreate_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; |
393 | 393 | break; |
394 | 394 | case "POPUPCANCEL": |
395 | 395 | $output = '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" ' |
396 | 396 | . 'class="button" onclick="toggleDisplay(\'addform\');return false;" ' |
397 | - . 'name="' . $params['module'] . '_popup_cancel_button" type="submit"' |
|
398 | - . 'id="' . $params['module'] . '_popup_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; |
|
397 | + . 'name="'.$params['module'].'_popup_cancel_button" type="submit"' |
|
398 | + . 'id="'.$params['module'].'_popup_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; |
|
399 | 399 | break; |
400 | 400 | case "AUDIT": |
401 | 401 | $popup_request_data = array( |
@@ -407,45 +407,45 @@ discard block |
||
407 | 407 | |
408 | 408 | require_once('include/SugarFields/Parsers/MetaParser.php'); |
409 | 409 | $encoded_popup_request_data = MetaParser::parseDelimiters($json->encode($popup_request_data)); |
410 | - $audit_link = '<input id="btn_view_change_log" title="{$APP.LNK_VIEW_CHANGE_LOG}" class="button" onclick=\'open_popup("Audit", "600", "400", "&record={$fields.id.value}&module_name=' . $params['module'] . '", true, false, ' . $encoded_popup_request_data . '); return false;\' type="button" value="{$APP.LNK_VIEW_CHANGE_LOG}">'; |
|
410 | + $audit_link = '<input id="btn_view_change_log" title="{$APP.LNK_VIEW_CHANGE_LOG}" class="button" onclick=\'open_popup("Audit", "600", "400", "&record={$fields.id.value}&module_name='.$params['module'].'", true, false, '.$encoded_popup_request_data.'); return false;\' type="button" value="{$APP.LNK_VIEW_CHANGE_LOG}">'; |
|
411 | 411 | $output = '{if $bean->aclAccess("detail")}{if !empty($fields.id.value) && $isAuditEnabled}'.$audit_link.'{/if}{/if}'; |
412 | 412 | break; |
413 | 413 | |
414 | 414 | |
415 | 415 | } //switch |
416 | - if(isset($params['appendTo'])) { |
|
416 | + if (isset($params['appendTo'])) { |
|
417 | 417 | $smarty->append($params['appendTo'], $output); |
418 | 418 | return; |
419 | 419 | } |
420 | 420 | return $output; |
421 | - } else if(is_array($type) && isset($type['sugar_html'])) { |
|
421 | + } else if (is_array($type) && isset($type['sugar_html'])) { |
|
422 | 422 | require_once('include/SugarHtml/SugarHtml.php'); |
423 | 423 | |
424 | 424 | $dom_tree = SugarHtml::parseSugarHtml($type['sugar_html']); |
425 | 425 | replaceFormClick($dom_tree, $js_form); |
426 | 426 | $output = SugarHtml::createHtml($dom_tree); |
427 | 427 | |
428 | - if(isset($params['appendTo'])) { |
|
428 | + if (isset($params['appendTo'])) { |
|
429 | 429 | $smarty->append($params['appendTo'], $output); |
430 | 430 | return; |
431 | 431 | } |
432 | 432 | return $output; |
433 | - } else if(is_array($type) && isset($type['customCode'])) { |
|
433 | + } else if (is_array($type) && isset($type['customCode'])) { |
|
434 | 434 | require_once('include/SugarHtml/SugarHtml.php'); |
435 | 435 | |
436 | 436 | $dom_tree = SugarHtml::parseHtmlTag($type['customCode']); |
437 | 437 | $hidden_exists = false; |
438 | 438 | |
439 | 439 | replaceFormClick($dom_tree, $js_form, $hidden_exists); |
440 | - if($hidden_exists) { |
|
440 | + if ($hidden_exists) { |
|
441 | 441 | //If the customCode contains hidden fields, the extracted hidden fields need to append in the original form |
442 | 442 | $form = $smarty->get_template_vars('form'); |
443 | 443 | $hidden_fields = $dom_tree; |
444 | 444 | extractHiddenInputs($hidden_fields); |
445 | - if(!isset($form)) { |
|
445 | + if (!isset($form)) { |
|
446 | 446 | $form = array(); |
447 | 447 | } |
448 | - if(!isset($form['hidden'])) { |
|
448 | + if (!isset($form['hidden'])) { |
|
449 | 449 | $form['hidden'] = array(); |
450 | 450 | } |
451 | 451 | $form['hidden'][] = SugarHtml::createHtml($hidden_fields); |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | } |
454 | 454 | $output = SugarHtml::createHtml($dom_tree); |
455 | 455 | |
456 | - if(isset($params['appendTo'])) { |
|
456 | + if (isset($params['appendTo'])) { |
|
457 | 457 | $smarty->append($params['appendTo'], $output); |
458 | 458 | return; |
459 | 459 | } |
@@ -475,21 +475,21 @@ discard block |
||
475 | 475 | $set_submit = false; |
476 | 476 | $is_hidden_field = false; |
477 | 477 | //if the code is wrapped with the form element, it will escape the operation for JS replacement |
478 | - if(isset($dom_tree['tag']) && $dom_tree['tag'] == 'form') |
|
478 | + if (isset($dom_tree['tag']) && $dom_tree['tag'] == 'form') |
|
479 | 479 | return false; |
480 | 480 | |
481 | - if(isset($dom_tree['type']) && $dom_tree['type'] == 'hidden') { |
|
481 | + if (isset($dom_tree['type']) && $dom_tree['type'] == 'hidden') { |
|
482 | 482 | $is_hidden_field = true; |
483 | 483 | } |
484 | 484 | |
485 | 485 | //Replace the JS syntax where the sugar_button contains the event handler for this.form |
486 | - if(isset($dom_tree['onclick'])) { |
|
487 | - if(strpos($dom_tree['onclick'], "this.form") !== false) { |
|
486 | + if (isset($dom_tree['onclick'])) { |
|
487 | + if (strpos($dom_tree['onclick'], "this.form") !== false) { |
|
488 | 488 | $dom_tree['onclick'] = str_replace("this.form", "_form", $dom_tree['onclick']); |
489 | - if(substr($dom_tree['onclick'], -1) != ';') |
|
489 | + if (substr($dom_tree['onclick'], -1) != ';') |
|
490 | 490 | $dom_tree['onclick'] .= ";"; |
491 | 491 | //Onclick handler contains returning a variable, for example it prompts a confirm message. |
492 | - if(strpos($dom_tree['onclick'], "return ") !== false ) { |
|
492 | + if (strpos($dom_tree['onclick'], "return ") !== false) { |
|
493 | 493 | $dom_tree['onclick'] = $js_form.' var _onclick=(function(){ldelim}'.$dom_tree['onclick']."{rdelim}()); if(_onclick!==false) _form.submit();"; |
494 | 494 | } else { |
495 | 495 | $dom_tree['onclick'] = $js_form.$dom_tree['onclick']."_form.submit();"; |
@@ -498,19 +498,19 @@ discard block |
||
498 | 498 | $set_submit = true; |
499 | 499 | } |
500 | 500 | } |
501 | - foreach($dom_tree as $key => $sub_tree) { |
|
502 | - if(is_array($sub_tree)) { |
|
501 | + foreach ($dom_tree as $key => $sub_tree) { |
|
502 | + if (is_array($sub_tree)) { |
|
503 | 503 | list($_submit, $_hidden) = replaceFormClick($dom_tree[$key], $js_form, $hidden_field_exists); |
504 | 504 | $set_submit = ($set_submit) ? $set_submit : $_submit; |
505 | 505 | $is_hidden_field = ($is_hidden_field) ? $is_hidden_field : $_hidden; |
506 | 506 | } |
507 | 507 | } |
508 | 508 | |
509 | - if($set_submit && isset($dom_tree['type'])) { |
|
509 | + if ($set_submit && isset($dom_tree['type'])) { |
|
510 | 510 | $dom_tree['type'] = "button"; |
511 | 511 | $set_submit = false; |
512 | 512 | } |
513 | - if($is_hidden_field && isset($dom_tree['tag']) && $dom_tree['tag'] == 'input' ) { |
|
513 | + if ($is_hidden_field && isset($dom_tree['tag']) && $dom_tree['tag'] == 'input') { |
|
514 | 514 | $hidden_field_exists = true; |
515 | 515 | $is_hidden_field = false; |
516 | 516 | } |
@@ -527,20 +527,20 @@ discard block |
||
527 | 527 | 'hidden' |
528 | 528 | ); |
529 | 529 | //all hidden fields in the form elements must NOT attach in the original form |
530 | - if(isset($dom_tree['tag']) && $dom_tree['tag'] == 'form') { |
|
530 | + if (isset($dom_tree['tag']) && $dom_tree['tag'] == 'form') { |
|
531 | 531 | $dom_tree = array(); |
532 | 532 | } |
533 | - foreach($dom_tree as $key => $sub_tree) { |
|
534 | - if(is_numeric($key) && isset($sub_tree['tag']) && $sub_tree['tag'] == 'input') { |
|
535 | - if( !isset($sub_tree['type']) || in_array($sub_tree['type'], $allow_types) === false ) { |
|
533 | + foreach ($dom_tree as $key => $sub_tree) { |
|
534 | + if (is_numeric($key) && isset($sub_tree['tag']) && $sub_tree['tag'] == 'input') { |
|
535 | + if (!isset($sub_tree['type']) || in_array($sub_tree['type'], $allow_types) === false) { |
|
536 | 536 | unset($dom_tree[$key]); |
537 | 537 | } |
538 | - } else if(is_array($sub_tree)) { |
|
538 | + } else if (is_array($sub_tree)) { |
|
539 | 539 | extractHiddenInputs($dom_tree[$key]); |
540 | 540 | } |
541 | 541 | } |
542 | - if(isset($dom_tree['tag']) && $dom_tree['tag'] == 'input') { |
|
543 | - if( !isset($dom_tree['type']) || in_array($dom_tree['type'], $allow_types) === false ) { |
|
542 | + if (isset($dom_tree['tag']) && $dom_tree['tag'] == 'input') { |
|
543 | + if (!isset($dom_tree['type']) || in_array($dom_tree['type'], $allow_types) === false) { |
|
544 | 544 | $dom_tree = array(); |
545 | 545 | } |
546 | 546 | } |
@@ -16,14 +16,14 @@ |
||
16 | 16 | */ |
17 | 17 | function smarty_make_timestamp($string) |
18 | 18 | { |
19 | - if(empty($string)) { |
|
19 | + if (empty($string)) { |
|
20 | 20 | // use "now": |
21 | 21 | $time = time(); |
22 | 22 | |
23 | 23 | } elseif (preg_match('/^\d{14}$/', $string)) { |
24 | 24 | // it is mysql timestamp format of YYYYMMDDHHMMSS? |
25 | - $time = mktime(substr($string, 8, 2),substr($string, 10, 2),substr($string, 12, 2), |
|
26 | - substr($string, 4, 2),substr($string, 6, 2),substr($string, 0, 4)); |
|
25 | + $time = mktime(substr($string, 8, 2), substr($string, 10, 2), substr($string, 12, 2), |
|
26 | + substr($string, 4, 2), substr($string, 6, 2), substr($string, 0, 4)); |
|
27 | 27 | |
28 | 28 | } elseif (is_numeric($string)) { |
29 | 29 | // it is a numeric string, we handle it as timestamp |
@@ -45,7 +45,7 @@ |
||
45 | 45 | function smarty_modifier_in_array($needle = null, $haystack = null) |
46 | 46 | { |
47 | 47 | //Smarty barfs if Array is empty |
48 | - if($haystack == null || empty($haystack)) { |
|
48 | + if ($haystack == null || empty($haystack)) { |
|
49 | 49 | return false; |
50 | 50 | } |
51 | 51 | return in_array($needle, $haystack); |
@@ -53,9 +53,9 @@ |
||
53 | 53 | $pdfButtons = ''; |
54 | 54 | $client = $current_user->getPreference('email_link_type'); |
55 | 55 | if ($client != 'sugar') { |
56 | - $pdfButtons = '<input title="'. $app_strings["LBL_EMAIL_COMPOSE"] . '" class="button" type="submit" name="button" value="'. $app_strings["LBL_EMAIL_COMPOSE"] . '" onclick="location.href=\'mailto:\';return false;"> '; |
|
56 | + $pdfButtons = '<input title="'.$app_strings["LBL_EMAIL_COMPOSE"].'" class="button" type="submit" name="button" value="'.$app_strings["LBL_EMAIL_COMPOSE"].'" onclick="location.href=\'mailto:\';return false;"> '; |
|
57 | 57 | } else { |
58 | - $pdfButtons = '<input id="email_as_pdf_button" title="'. $app_strings["LBL_EMAIL_PDF_BUTTON_TITLE"] . '" class="button" type="submit" name="button" value="'. $app_strings["LBL_EMAIL_PDF_BUTTON_LABEL"] . '" onclick="this.form.email_action.value=\'EmailLayout\';"> '; |
|
58 | + $pdfButtons = '<input id="email_as_pdf_button" title="'.$app_strings["LBL_EMAIL_PDF_BUTTON_TITLE"].'" class="button" type="submit" name="button" value="'.$app_strings["LBL_EMAIL_PDF_BUTTON_LABEL"].'" onclick="this.form.email_action.value=\'EmailLayout\';"> '; |
|
59 | 59 | } |
60 | 60 | return $pdfButtons; |
61 | 61 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
4 | 4 | /********************************************************************************* |
5 | 5 | * SugarCRM Community Edition is a customer relationship management program developed by |
6 | 6 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | |
43 | 43 | |
44 | -function smarty_modifier_lookup($value='', $from=array()){ |
|
44 | +function smarty_modifier_lookup($value = '', $from = array()) { |
|
45 | 45 | $value = trim($value); |
46 | 46 | if (array_key_exists($value, $from)) { |
47 | 47 | return $from[$value]; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | |
34 | 34 | |
35 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
35 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
36 | 36 | /********************************************************************************* |
37 | 37 | * SugarCRM Community Edition is a customer relationship management program developed by |
38 | 38 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | function smarty_function_sugarvar_connector($params, &$smarty) { |
76 | 76 | |
77 | 77 | $displayParams = $smarty->get_template_vars('displayParams'); |
78 | - if(!isset($displayParams['module'])) { |
|
78 | + if (!isset($displayParams['module'])) { |
|
79 | 79 | $smarty->trigger_error("sugarvar_connector: missing 'module' parameter"); |
80 | 80 | $GLOBALS['log']->error("sugarvar_connector: missing 'module' parameter"); |
81 | 81 | return; |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | { |
57 | 57 | global $app_strings; |
58 | 58 | |
59 | - if(isset($params['type']) && $params['type'] == 'php') { |
|
60 | - if(!isset($params['file'])) { |
|
61 | - $smarty->trigger_error($app_strings['ERR_MISSING_REQUIRED_FIELDS'] . 'include'); |
|
59 | + if (isset($params['type']) && $params['type'] == 'php') { |
|
60 | + if (!isset($params['file'])) { |
|
61 | + $smarty->trigger_error($app_strings['ERR_MISSING_REQUIRED_FIELDS'].'include'); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | $includeFile = $params['file']; |
65 | - if(!file_exists($includeFile)) { |
|
66 | - $smarty->trigger_error($app_strings['ERR_NO_SUCH_FILE'] . ': ' . $includeFile); |
|
65 | + if (!file_exists($includeFile)) { |
|
66 | + $smarty->trigger_error($app_strings['ERR_NO_SUCH_FILE'].': '.$includeFile); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | ob_start(); |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | $output_html = ob_get_contents(); |
72 | 72 | ob_end_clean(); |
73 | 73 | echo $output_html; |
74 | - } else if(is_array($params['include'])) { |
|
74 | + } else if (is_array($params['include'])) { |
|
75 | 75 | $code = ''; |
76 | - foreach($params['include'] as $include) { |
|
77 | - if(isset($include['file'])) { |
|
76 | + foreach ($params['include'] as $include) { |
|
77 | + if (isset($include['file'])) { |
|
78 | 78 | $file = $include['file']; |
79 | - if(preg_match('/[\.]js$/si',$file)) { |
|
80 | - $code .= "<script src=\"". getJSPath($include['file']) ."\"></script>"; |
|
81 | - } else if(preg_match('/[\.]php$/si', $file)) { |
|
79 | + if (preg_match('/[\.]js$/si', $file)) { |
|
80 | + $code .= "<script src=\"".getJSPath($include['file'])."\"></script>"; |
|
81 | + } else if (preg_match('/[\.]php$/si', $file)) { |
|
82 | 82 | require_once($file); |
83 | 83 | } |
84 | 84 | } |
@@ -38,41 +38,41 @@ discard block |
||
38 | 38 | /**#@+ |
39 | 39 | * @access private |
40 | 40 | */ |
41 | - var $_folded_blocks = array(); // keeps folded template blocks |
|
42 | - var $_current_file = null; // the current template being compiled |
|
43 | - var $_current_line_no = 1; // line number for error messages |
|
44 | - var $_capture_stack = array(); // keeps track of nested capture buffers |
|
45 | - var $_plugin_info = array(); // keeps track of plugins to load |
|
46 | - var $_init_smarty_vars = false; |
|
47 | - var $_permitted_tokens = array('true','false','yes','no','on','off','null'); |
|
48 | - var $_db_qstr_regexp = null; // regexps are setup in the constructor |
|
49 | - var $_si_qstr_regexp = null; |
|
50 | - var $_qstr_regexp = null; |
|
51 | - var $_func_regexp = null; |
|
52 | - var $_reg_obj_regexp = null; |
|
53 | - var $_var_bracket_regexp = null; |
|
54 | - var $_num_const_regexp = null; |
|
55 | - var $_dvar_guts_regexp = null; |
|
56 | - var $_dvar_regexp = null; |
|
57 | - var $_cvar_regexp = null; |
|
58 | - var $_svar_regexp = null; |
|
59 | - var $_avar_regexp = null; |
|
60 | - var $_mod_regexp = null; |
|
61 | - var $_var_regexp = null; |
|
62 | - var $_parenth_param_regexp = null; |
|
63 | - var $_func_call_regexp = null; |
|
64 | - var $_obj_ext_regexp = null; |
|
65 | - var $_obj_start_regexp = null; |
|
66 | - var $_obj_params_regexp = null; |
|
67 | - var $_obj_call_regexp = null; |
|
68 | - var $_cacheable_state = 0; |
|
69 | - var $_cache_attrs_count = 0; |
|
70 | - var $_nocache_count = 0; |
|
71 | - var $_cache_serial = null; |
|
72 | - var $_cache_include = null; |
|
73 | - |
|
74 | - var $_strip_depth = 0; |
|
75 | - var $_additional_newline = "\n"; |
|
41 | + var $_folded_blocks = array(); // keeps folded template blocks |
|
42 | + var $_current_file = null; // the current template being compiled |
|
43 | + var $_current_line_no = 1; // line number for error messages |
|
44 | + var $_capture_stack = array(); // keeps track of nested capture buffers |
|
45 | + var $_plugin_info = array(); // keeps track of plugins to load |
|
46 | + var $_init_smarty_vars = false; |
|
47 | + var $_permitted_tokens = array('true', 'false', 'yes', 'no', 'on', 'off', 'null'); |
|
48 | + var $_db_qstr_regexp = null; // regexps are setup in the constructor |
|
49 | + var $_si_qstr_regexp = null; |
|
50 | + var $_qstr_regexp = null; |
|
51 | + var $_func_regexp = null; |
|
52 | + var $_reg_obj_regexp = null; |
|
53 | + var $_var_bracket_regexp = null; |
|
54 | + var $_num_const_regexp = null; |
|
55 | + var $_dvar_guts_regexp = null; |
|
56 | + var $_dvar_regexp = null; |
|
57 | + var $_cvar_regexp = null; |
|
58 | + var $_svar_regexp = null; |
|
59 | + var $_avar_regexp = null; |
|
60 | + var $_mod_regexp = null; |
|
61 | + var $_var_regexp = null; |
|
62 | + var $_parenth_param_regexp = null; |
|
63 | + var $_func_call_regexp = null; |
|
64 | + var $_obj_ext_regexp = null; |
|
65 | + var $_obj_start_regexp = null; |
|
66 | + var $_obj_params_regexp = null; |
|
67 | + var $_obj_call_regexp = null; |
|
68 | + var $_cacheable_state = 0; |
|
69 | + var $_cache_attrs_count = 0; |
|
70 | + var $_nocache_count = 0; |
|
71 | + var $_cache_serial = null; |
|
72 | + var $_cache_include = null; |
|
73 | + |
|
74 | + var $_strip_depth = 0; |
|
75 | + var $_additional_newline = "\n"; |
|
76 | 76 | |
77 | 77 | /**#@-*/ |
78 | 78 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $this->_si_qstr_regexp = '\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\''; |
92 | 92 | |
93 | 93 | // matches single or double quoted strings |
94 | - $this->_qstr_regexp = '(?:' . $this->_db_qstr_regexp . '|' . $this->_si_qstr_regexp . ')'; |
|
94 | + $this->_qstr_regexp = '(?:'.$this->_db_qstr_regexp.'|'.$this->_si_qstr_regexp.')'; |
|
95 | 95 | |
96 | 96 | // matches bracket portion of vars |
97 | 97 | // [0] |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | // $foo[5].bar[$foobar][4] |
116 | 116 | $this->_dvar_math_regexp = '(?:[\+\*\/\%]|(?:-(?!>)))'; |
117 | 117 | $this->_dvar_math_var_regexp = '[\$\w\.\+\-\*\/\%\d\>\[\]]'; |
118 | - $this->_dvar_guts_regexp = '\w+(?:' . $this->_var_bracket_regexp |
|
119 | - . ')*(?:\.\$?\w+(?:' . $this->_var_bracket_regexp . ')*)*(?:' . $this->_dvar_math_regexp . '(?:' . $this->_num_const_regexp . '|' . $this->_dvar_math_var_regexp . ')*)?'; |
|
120 | - $this->_dvar_regexp = '\$' . $this->_dvar_guts_regexp; |
|
118 | + $this->_dvar_guts_regexp = '\w+(?:'.$this->_var_bracket_regexp |
|
119 | + . ')*(?:\.\$?\w+(?:'.$this->_var_bracket_regexp.')*)*(?:'.$this->_dvar_math_regexp.'(?:'.$this->_num_const_regexp.'|'.$this->_dvar_math_var_regexp.')*)?'; |
|
120 | + $this->_dvar_regexp = '\$'.$this->_dvar_guts_regexp; |
|
121 | 121 | |
122 | 122 | // matches config vars: |
123 | 123 | // #foo# |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | $this->_svar_regexp = '\%\w+\.\w+\%'; |
130 | 130 | |
131 | 131 | // matches all valid variables (no quotes, no modifiers) |
132 | - $this->_avar_regexp = '(?:' . $this->_dvar_regexp . '|' |
|
133 | - . $this->_cvar_regexp . '|' . $this->_svar_regexp . ')'; |
|
132 | + $this->_avar_regexp = '(?:'.$this->_dvar_regexp.'|' |
|
133 | + . $this->_cvar_regexp.'|'.$this->_svar_regexp.')'; |
|
134 | 134 | |
135 | 135 | // matches valid variable syntax: |
136 | 136 | // $foo |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | // #foo# |
140 | 140 | // "text" |
141 | 141 | // "text" |
142 | - $this->_var_regexp = '(?:' . $this->_avar_regexp . '|' . $this->_qstr_regexp . ')'; |
|
142 | + $this->_var_regexp = '(?:'.$this->_avar_regexp.'|'.$this->_qstr_regexp.')'; |
|
143 | 143 | |
144 | 144 | // matches valid object call (one level of object nesting allowed in parameters): |
145 | 145 | // $foo->bar |
@@ -152,16 +152,16 @@ discard block |
||
152 | 152 | // $foo->bar($foo->bar) |
153 | 153 | // $foo->bar($foo->bar()) |
154 | 154 | // $foo->bar($foo->bar($blah,$foo,44,"foo",$foo[0].bar)) |
155 | - $this->_obj_ext_regexp = '\->(?:\$?' . $this->_dvar_guts_regexp . ')'; |
|
155 | + $this->_obj_ext_regexp = '\->(?:\$?'.$this->_dvar_guts_regexp.')'; |
|
156 | 156 | $this->_obj_restricted_param_regexp = '(?:' |
157 | - . '(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . ')(?:' . $this->_obj_ext_regexp . '(?:\((?:(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . ')' |
|
158 | - . '(?:\s*,\s*(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . '))*)?\))?)*)'; |
|
159 | - $this->_obj_single_param_regexp = '(?:\w+|' . $this->_obj_restricted_param_regexp . '(?:\s*,\s*(?:(?:\w+|' |
|
160 | - . $this->_var_regexp . $this->_obj_restricted_param_regexp . ')))*)'; |
|
161 | - $this->_obj_params_regexp = '\((?:' . $this->_obj_single_param_regexp |
|
162 | - . '(?:\s*,\s*' . $this->_obj_single_param_regexp . ')*)?\)'; |
|
163 | - $this->_obj_start_regexp = '(?:' . $this->_dvar_regexp . '(?:' . $this->_obj_ext_regexp . ')+)'; |
|
164 | - $this->_obj_call_regexp = '(?:' . $this->_obj_start_regexp . '(?:' . $this->_obj_params_regexp . ')?(?:' . $this->_dvar_math_regexp . '(?:' . $this->_num_const_regexp . '|' . $this->_dvar_math_var_regexp . ')*)?)'; |
|
157 | + . '(?:'.$this->_var_regexp.'|'.$this->_num_const_regexp.')(?:'.$this->_obj_ext_regexp.'(?:\((?:(?:'.$this->_var_regexp.'|'.$this->_num_const_regexp.')' |
|
158 | + . '(?:\s*,\s*(?:'.$this->_var_regexp.'|'.$this->_num_const_regexp.'))*)?\))?)*)'; |
|
159 | + $this->_obj_single_param_regexp = '(?:\w+|'.$this->_obj_restricted_param_regexp.'(?:\s*,\s*(?:(?:\w+|' |
|
160 | + . $this->_var_regexp.$this->_obj_restricted_param_regexp.')))*)'; |
|
161 | + $this->_obj_params_regexp = '\((?:'.$this->_obj_single_param_regexp |
|
162 | + . '(?:\s*,\s*'.$this->_obj_single_param_regexp.')*)?\)'; |
|
163 | + $this->_obj_start_regexp = '(?:'.$this->_dvar_regexp.'(?:'.$this->_obj_ext_regexp.')+)'; |
|
164 | + $this->_obj_call_regexp = '(?:'.$this->_obj_start_regexp.'(?:'.$this->_obj_params_regexp.')?(?:'.$this->_dvar_math_regexp.'(?:'.$this->_num_const_regexp.'|'.$this->_dvar_math_var_regexp.')*)?)'; |
|
165 | 165 | |
166 | 166 | // matches valid modifier syntax: |
167 | 167 | // |foo |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | // |foo:"bar":$foobar |
172 | 172 | // |foo|bar |
173 | 173 | // |foo:$foo->bar |
174 | - $this->_mod_regexp = '(?:\|@?\w+(?::(?:\w+|' . $this->_num_const_regexp . '|' |
|
175 | - . $this->_obj_call_regexp . '|' . $this->_avar_regexp . '|' . $this->_qstr_regexp .'))*)'; |
|
174 | + $this->_mod_regexp = '(?:\|@?\w+(?::(?:\w+|'.$this->_num_const_regexp.'|' |
|
175 | + . $this->_obj_call_regexp.'|'.$this->_avar_regexp.'|'.$this->_qstr_regexp.'))*)'; |
|
176 | 176 | |
177 | 177 | // matches valid function name: |
178 | 178 | // foo123 |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | // "text" |
193 | 193 | // "text"|bar |
194 | 194 | // $foo->bar |
195 | - $this->_param_regexp = '(?:\s*(?:' . $this->_obj_call_regexp . '|' |
|
196 | - . $this->_var_regexp . '|' . $this->_num_const_regexp . '|\w+)(?>' . $this->_mod_regexp . '*)\s*)'; |
|
195 | + $this->_param_regexp = '(?:\s*(?:'.$this->_obj_call_regexp.'|' |
|
196 | + . $this->_var_regexp.'|'.$this->_num_const_regexp.'|\w+)(?>'.$this->_mod_regexp.'*)\s*)'; |
|
197 | 197 | |
198 | 198 | // matches valid parenthesised function parameters: |
199 | 199 | // |
@@ -201,16 +201,16 @@ discard block |
||
201 | 201 | // $foo, $bar, "text" |
202 | 202 | // $foo|bar, "foo"|bar, $foo->bar($foo)|bar |
203 | 203 | $this->_parenth_param_regexp = '(?:\((?:\w+|' |
204 | - . $this->_param_regexp . '(?:\s*,\s*(?:(?:\w+|' |
|
205 | - . $this->_param_regexp . ')))*)?\))'; |
|
204 | + . $this->_param_regexp.'(?:\s*,\s*(?:(?:\w+|' |
|
205 | + . $this->_param_regexp.')))*)?\))'; |
|
206 | 206 | |
207 | 207 | // matches valid function call: |
208 | 208 | // foo() |
209 | 209 | // foo_bar($foo) |
210 | 210 | // _foo_bar($foo,"bar") |
211 | 211 | // foo123($foo,$foo->bar(),"foo") |
212 | - $this->_func_call_regexp = '(?:' . $this->_func_regexp . '\s*(?:' |
|
213 | - . $this->_parenth_param_regexp . '))'; |
|
212 | + $this->_func_call_regexp = '(?:'.$this->_func_regexp.'\s*(?:' |
|
213 | + . $this->_parenth_param_regexp.'))'; |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -257,13 +257,13 @@ discard block |
||
257 | 257 | /* fetch all special blocks */ |
258 | 258 | $search = "~{$ldq}\*(.*?)\*{$rdq}|{$ldq}\s*literal\s*{$rdq}(.*?){$ldq}\s*/literal\s*{$rdq}|{$ldq}\s*php\s*{$rdq}(.*?){$ldq}\s*/php\s*{$rdq}~s"; |
259 | 259 | |
260 | - preg_match_all($search, $source_content, $match, PREG_SET_ORDER); |
|
260 | + preg_match_all($search, $source_content, $match, PREG_SET_ORDER); |
|
261 | 261 | $this->_folded_blocks = $match; |
262 | 262 | reset($this->_folded_blocks); |
263 | 263 | |
264 | 264 | /* replace special blocks by "{php}" */ |
265 | - $source_content = preg_replace_callback($search, create_function ('$matches', "return '" |
|
266 | - . $this->_quote_replace($this->left_delimiter) . 'php' |
|
265 | + $source_content = preg_replace_callback($search, create_function('$matches', "return '" |
|
266 | + . $this->_quote_replace($this->left_delimiter).'php' |
|
267 | 267 | . "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'" |
268 | 268 | . $this->_quote_replace($this->right_delimiter) |
269 | 269 | . "';") |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | $sp_match[1] = array_unique($sp_match[1]); |
284 | 284 | usort($sp_match[1], '_smarty_sort_length'); |
285 | 285 | for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) { |
286 | - $text_blocks[$curr_tb] = str_replace($sp_match[1][$curr_sp],'%%%SMARTYSP'.$curr_sp.'%%%',$text_blocks[$curr_tb]); |
|
286 | + $text_blocks[$curr_tb] = str_replace($sp_match[1][$curr_sp], '%%%SMARTYSP'.$curr_sp.'%%%', $text_blocks[$curr_tb]); |
|
287 | 287 | } |
288 | 288 | /* process each one */ |
289 | 289 | for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) { |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | $compiled_tags[] = $this->_compile_tag($template_tags[$i]); |
313 | 313 | $this->_current_line_no += substr_count($template_tags[$i], "\n"); |
314 | 314 | } |
315 | - if (count($this->_tag_stack)>0) { |
|
315 | + if (count($this->_tag_stack) > 0) { |
|
316 | 316 | list($_open_tag, $_line_no) = end($this->_tag_stack); |
317 | 317 | $this->_syntax_error("unclosed tag \{$_open_tag} (opened line $_line_no).", E_USER_ERROR, __FILE__, __LINE__); |
318 | 318 | return; |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | /* remove trailing whitespaces from the last text_block */ |
338 | 338 | $text_blocks[$j] = rtrim($text_blocks[$j]); |
339 | 339 | } |
340 | - $text_blocks[$j] = "<?php echo '" . strtr($text_blocks[$j], array("'"=>"\'", "\\"=>"\\\\")) . "'; ?>"; |
|
340 | + $text_blocks[$j] = "<?php echo '".strtr($text_blocks[$j], array("'"=>"\'", "\\"=>"\\\\"))."'; ?>"; |
|
341 | 341 | if ($compiled_tags[$j] == '{/strip}') { |
342 | 342 | $compiled_tags[$j] = "\n"; /* slurped by php, but necessary |
343 | 343 | if a newline is following the closing strip-tag */ |
@@ -350,19 +350,19 @@ discard block |
||
350 | 350 | } |
351 | 351 | $compiled_content = ''; |
352 | 352 | |
353 | - $tag_guard = '%%%SMARTYOTG' . md5(uniqid(rand(), true)) . '%%%'; |
|
353 | + $tag_guard = '%%%SMARTYOTG'.md5(uniqid(rand(), true)).'%%%'; |
|
354 | 354 | |
355 | 355 | /* Interleave the compiled contents and text blocks to get the final result. */ |
356 | 356 | for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) { |
357 | 357 | if ($compiled_tags[$i] == '') { |
358 | 358 | // tag result empty, remove first newline from following text block |
359 | - $text_blocks[$i+1] = preg_replace('~^(\r\n|\r|\n)~', '', $text_blocks[$i+1]); |
|
359 | + $text_blocks[$i + 1] = preg_replace('~^(\r\n|\r|\n)~', '', $text_blocks[$i + 1]); |
|
360 | 360 | } |
361 | 361 | // replace legit PHP tags with placeholder |
362 | 362 | $text_blocks[$i] = str_replace('<?', $tag_guard, $text_blocks[$i]); |
363 | 363 | $compiled_tags[$i] = str_replace('<?', $tag_guard, $compiled_tags[$i]); |
364 | 364 | |
365 | - $compiled_content .= $text_blocks[$i] . $compiled_tags[$i]; |
|
365 | + $compiled_content .= $text_blocks[$i].$compiled_tags[$i]; |
|
366 | 366 | } |
367 | 367 | $compiled_content .= str_replace('<?', $tag_guard, $text_blocks[$i]); |
368 | 368 | |
@@ -374,12 +374,12 @@ discard block |
||
374 | 374 | $compiled_content = str_replace($tag_guard, '<?', $compiled_content); |
375 | 375 | |
376 | 376 | // remove \n from the end of the file, if any |
377 | - if (strlen($compiled_content) && (substr($compiled_content, -1) == "\n") ) { |
|
377 | + if (strlen($compiled_content) && (substr($compiled_content, -1) == "\n")) { |
|
378 | 378 | $compiled_content = substr($compiled_content, 0, -1); |
379 | 379 | } |
380 | 380 | |
381 | 381 | if (!empty($this->_cache_serial)) { |
382 | - $compiled_content = "<?php \$this->_cache_serials['".$this->_cache_include."'] = '".$this->_cache_serial."'; ?>" . $compiled_content; |
|
382 | + $compiled_content = "<?php \$this->_cache_serials['".$this->_cache_include."'] = '".$this->_cache_serial."'; ?>".$compiled_content; |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | // run compiled template through postfilter functions |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | $_plugins_params = "array('plugins' => array("; |
407 | 407 | foreach ($this->_plugin_info as $plugin_type => $plugins) { |
408 | 408 | foreach ($plugins as $plugin_name => $plugin_info) { |
409 | - $_plugins_params .= "array('$plugin_type', '$plugin_name', '" . strtr($plugin_info[0], array("'" => "\\'", "\\" => "\\\\")) . "', $plugin_info[1], "; |
|
409 | + $_plugins_params .= "array('$plugin_type', '$plugin_name', '".strtr($plugin_info[0], array("'" => "\\'", "\\" => "\\\\"))."', $plugin_info[1], "; |
|
410 | 410 | $_plugins_params .= $plugin_info[2] ? 'true),' : 'false),'; |
411 | 411 | } |
412 | 412 | } |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | $this->_init_smarty_vars = false; |
423 | 423 | } |
424 | 424 | |
425 | - $compiled_content = $template_header . $compiled_content; |
|
425 | + $compiled_content = $template_header.$compiled_content; |
|
426 | 426 | return true; |
427 | 427 | } |
428 | 428 | |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | return ''; |
440 | 440 | |
441 | 441 | /* Split tag into two three parts: command, command modifiers and the arguments. */ |
442 | - if(! preg_match('~^(?:(' . $this->_num_const_regexp . '|' . $this->_obj_call_regexp . '|' . $this->_var_regexp |
|
443 | - . '|\/?' . $this->_reg_obj_regexp . '|\/?' . $this->_func_regexp . ')(' . $this->_mod_regexp . '*)) |
|
442 | + if (!preg_match('~^(?:('.$this->_num_const_regexp.'|'.$this->_obj_call_regexp.'|'.$this->_var_regexp |
|
443 | + . '|\/?'.$this->_reg_obj_regexp.'|\/?'.$this->_func_regexp.')('.$this->_mod_regexp.'*)) |
|
444 | 444 | (?:\s+(.*))?$ |
445 | 445 | ~xs', $template_tag, $match)) { |
446 | 446 | $this->_syntax_error("unrecognized tag: $template_tag", E_USER_ERROR, __FILE__, __LINE__); |
@@ -450,14 +450,14 @@ discard block |
||
450 | 450 | $tag_modifier = isset($match[2]) ? $match[2] : null; |
451 | 451 | $tag_args = isset($match[3]) ? $match[3] : null; |
452 | 452 | |
453 | - if (preg_match('~^' . $this->_num_const_regexp . '|' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '$~', $tag_command)) { |
|
453 | + if (preg_match('~^'.$this->_num_const_regexp.'|'.$this->_obj_call_regexp.'|'.$this->_var_regexp.'$~', $tag_command)) { |
|
454 | 454 | /* tag name is a variable or object */ |
455 | - $_return = $this->_parse_var_props($tag_command . $tag_modifier); |
|
456 | - return "<?php echo $_return; ?>" . $this->_additional_newline; |
|
455 | + $_return = $this->_parse_var_props($tag_command.$tag_modifier); |
|
456 | + return "<?php echo $_return; ?>".$this->_additional_newline; |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | /* If the tag name is a registered object, we process it. */ |
460 | - if (preg_match('~^\/?' . $this->_reg_obj_regexp . '$~', $tag_command)) { |
|
460 | + if (preg_match('~^\/?'.$this->_reg_obj_regexp.'$~', $tag_command)) { |
|
461 | 461 | return $this->_compile_registered_object_tag($tag_command, $this->_parse_attrs($tag_args), $tag_modifier); |
462 | 462 | } |
463 | 463 | |
@@ -539,17 +539,17 @@ discard block |
||
539 | 539 | |
540 | 540 | case 'strip': |
541 | 541 | case '/strip': |
542 | - if (substr($tag_command, 0, 1)=='/') { |
|
542 | + if (substr($tag_command, 0, 1) == '/') { |
|
543 | 543 | $this->_pop_tag('strip'); |
544 | - if (--$this->_strip_depth==0) { /* outermost closing {/strip} */ |
|
544 | + if (--$this->_strip_depth == 0) { /* outermost closing {/strip} */ |
|
545 | 545 | $this->_additional_newline = "\n"; |
546 | - return '{' . $tag_command . '}'; |
|
546 | + return '{'.$tag_command.'}'; |
|
547 | 547 | } |
548 | 548 | } else { |
549 | 549 | $this->_push_tag('strip'); |
550 | - if ($this->_strip_depth++==0) { /* outermost opening {strip} */ |
|
550 | + if ($this->_strip_depth++ == 0) { /* outermost opening {strip} */ |
|
551 | 551 | $this->_additional_newline = ""; |
552 | - return '{' . $tag_command . '}'; |
|
552 | + return '{'.$tag_command.'}'; |
|
553 | 553 | } |
554 | 554 | } |
555 | 555 | return ''; |
@@ -565,14 +565,14 @@ discard block |
||
565 | 565 | return ''; |
566 | 566 | |
567 | 567 | case 3: /* literal */ |
568 | - return "<?php echo '" . strtr($block[2], array("'"=>"\'", "\\"=>"\\\\")) . "'; ?>" . $this->_additional_newline; |
|
568 | + return "<?php echo '".strtr($block[2], array("'"=>"\'", "\\"=>"\\\\"))."'; ?>".$this->_additional_newline; |
|
569 | 569 | |
570 | 570 | case 4: /* php */ |
571 | 571 | if ($this->security && !$this->security_settings['PHP_TAGS']) { |
572 | 572 | $this->_syntax_error("(secure mode) php tags not permitted", E_USER_WARNING, __FILE__, __LINE__); |
573 | 573 | return; |
574 | 574 | } |
575 | - return '<?php ' . $block[3] .' ?>'; |
|
575 | + return '<?php '.$block[3].' ?>'; |
|
576 | 576 | } |
577 | 577 | break; |
578 | 578 | |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | |
630 | 630 | include_once $plugin_file; |
631 | 631 | |
632 | - $plugin_func = 'smarty_compiler_' . $tag_command; |
|
632 | + $plugin_func = 'smarty_compiler_'.$tag_command; |
|
633 | 633 | if (!is_callable($plugin_func)) { |
634 | 634 | $message = "plugin function $plugin_func() not found in $plugin_file\n"; |
635 | 635 | $have_function = false; |
@@ -647,10 +647,10 @@ discard block |
||
647 | 647 | if ($found) { |
648 | 648 | if ($have_function) { |
649 | 649 | $output = call_user_func_array($plugin_func, array($tag_args, &$this)); |
650 | - if($output != '') { |
|
651 | - $output = '<?php ' . $this->_push_cacheable_state('compiler', $tag_command) |
|
650 | + if ($output != '') { |
|
651 | + $output = '<?php '.$this->_push_cacheable_state('compiler', $tag_command) |
|
652 | 652 | . $output |
653 | - . $this->_pop_cacheable_state('compiler', $tag_command) . ' ?>'; |
|
653 | + . $this->_pop_cacheable_state('compiler', $tag_command).' ?>'; |
|
654 | 654 | } |
655 | 655 | } else { |
656 | 656 | $this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__); |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | |
705 | 705 | include_once $plugin_file; |
706 | 706 | |
707 | - $plugin_func = 'smarty_block_' . $tag_command; |
|
707 | + $plugin_func = 'smarty_block_'.$tag_command; |
|
708 | 708 | if (!function_exists($plugin_func)) { |
709 | 709 | $message = "plugin function $plugin_func() not found in $plugin_file\n"; |
710 | 710 | $have_function = false; |
@@ -734,12 +734,12 @@ discard block |
||
734 | 734 | $this->_pop_tag($tag_command); |
735 | 735 | |
736 | 736 | if ($start_tag) { |
737 | - $output = '<?php ' . $this->_push_cacheable_state('block', $tag_command); |
|
737 | + $output = '<?php '.$this->_push_cacheable_state('block', $tag_command); |
|
738 | 738 | $attrs = $this->_parse_attrs($tag_args); |
739 | - $_cache_attrs=''; |
|
739 | + $_cache_attrs = ''; |
|
740 | 740 | $arg_list = $this->_compile_arg_list('block', $tag_command, $attrs, $_cache_attrs); |
741 | 741 | $output .= "$_cache_attrs\$this->_tag_stack[] = array('$tag_command', array(".implode(',', $arg_list).')); '; |
742 | - $output .= '$_block_repeat=true;' . $this->_compile_plugin_call('block', $tag_command).'($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat);'; |
|
742 | + $output .= '$_block_repeat=true;'.$this->_compile_plugin_call('block', $tag_command).'($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat);'; |
|
743 | 743 | $output .= 'while ($_block_repeat) { ob_start(); ?>'; |
744 | 744 | } else { |
745 | 745 | $output = '<?php $_block_content = ob_get_contents(); ob_end_clean(); '; |
@@ -747,8 +747,8 @@ discard block |
||
747 | 747 | if ($tag_modifier != '') { |
748 | 748 | $this->_parse_modifiers($_out_tag_text, $tag_modifier); |
749 | 749 | } |
750 | - $output .= '$_block_repeat=false;echo ' . $_out_tag_text . '; } '; |
|
751 | - $output .= " array_pop(\$this->_tag_stack); " . $this->_pop_cacheable_state('block', $tag_command) . '?>'; |
|
750 | + $output .= '$_block_repeat=false;echo '.$_out_tag_text.'; } '; |
|
751 | + $output .= " array_pop(\$this->_tag_stack); ".$this->_pop_cacheable_state('block', $tag_command).'?>'; |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | return true; |
@@ -789,7 +789,7 @@ discard block |
||
789 | 789 | |
790 | 790 | include_once $plugin_file; |
791 | 791 | |
792 | - $plugin_func = 'smarty_function_' . $tag_command; |
|
792 | + $plugin_func = 'smarty_function_'.$tag_command; |
|
793 | 793 | if (!function_exists($plugin_func)) { |
794 | 794 | $message = "plugin function $plugin_func() not found in $plugin_file\n"; |
795 | 795 | $have_function = false; |
@@ -816,13 +816,13 @@ discard block |
||
816 | 816 | $arg_list = $this->_compile_arg_list('function', $tag_command, $attrs, $_cache_attrs); |
817 | 817 | |
818 | 818 | $output = $this->_compile_plugin_call('function', $tag_command).'(array('.implode(',', $arg_list)."), \$this)"; |
819 | - if($tag_modifier != '') { |
|
819 | + if ($tag_modifier != '') { |
|
820 | 820 | $this->_parse_modifiers($output, $tag_modifier); |
821 | 821 | } |
822 | 822 | |
823 | - if($output != '') { |
|
824 | - $output = '<?php ' . $_cacheable_state . $_cache_attrs . 'echo ' . $output . ';' |
|
825 | - . $this->_pop_cacheable_state('function', $tag_command) . "?>" . $this->_additional_newline; |
|
823 | + if ($output != '') { |
|
824 | + $output = '<?php '.$_cacheable_state.$_cache_attrs.'echo '.$output.';' |
|
825 | + . $this->_pop_cacheable_state('function', $tag_command)."?>".$this->_additional_newline; |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | return true; |
@@ -848,10 +848,10 @@ discard block |
||
848 | 848 | list($object, $obj_comp) = explode('->', $tag_command); |
849 | 849 | |
850 | 850 | $arg_list = array(); |
851 | - if(count($attrs)) { |
|
851 | + if (count($attrs)) { |
|
852 | 852 | $_assign_var = false; |
853 | 853 | foreach ($attrs as $arg_name => $arg_value) { |
854 | - if($arg_name == 'assign') { |
|
854 | + if ($arg_name == 'assign') { |
|
855 | 855 | $_assign_var = $arg_value; |
856 | 856 | unset($attrs['assign']); |
857 | 857 | continue; |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | } |
863 | 863 | } |
864 | 864 | |
865 | - if($this->_reg_objects[$object][2]) { |
|
865 | + if ($this->_reg_objects[$object][2]) { |
|
866 | 866 | // smarty object argument format |
867 | 867 | $args = "array(".implode(',', (array)$arg_list)."), \$this"; |
868 | 868 | } else { |
@@ -876,13 +876,13 @@ discard block |
||
876 | 876 | $prefix = ''; |
877 | 877 | $postfix = ''; |
878 | 878 | $newline = ''; |
879 | - if(!is_object($this->_reg_objects[$object][0])) { |
|
880 | - $this->_trigger_fatal_error("registered '$object' is not an object" , $this->_current_file, $this->_current_line_no, __FILE__, __LINE__); |
|
881 | - } elseif(!empty($this->_reg_objects[$object][1]) && !in_array($obj_comp, $this->_reg_objects[$object][1])) { |
|
879 | + if (!is_object($this->_reg_objects[$object][0])) { |
|
880 | + $this->_trigger_fatal_error("registered '$object' is not an object", $this->_current_file, $this->_current_line_no, __FILE__, __LINE__); |
|
881 | + } elseif (!empty($this->_reg_objects[$object][1]) && !in_array($obj_comp, $this->_reg_objects[$object][1])) { |
|
882 | 882 | $this->_trigger_fatal_error("'$obj_comp' is not a registered component of object '$object'", $this->_current_file, $this->_current_line_no, __FILE__, __LINE__); |
883 | - } elseif(method_exists($this->_reg_objects[$object][0], $obj_comp)) { |
|
883 | + } elseif (method_exists($this->_reg_objects[$object][0], $obj_comp)) { |
|
884 | 884 | // method |
885 | - if(in_array($obj_comp, $this->_reg_objects[$object][3])) { |
|
885 | + if (in_array($obj_comp, $this->_reg_objects[$object][3])) { |
|
886 | 886 | // block method |
887 | 887 | if ($start_tag) { |
888 | 888 | $prefix = "\$this->_tag_stack[] = array('$obj_comp', $args); "; |
@@ -904,22 +904,22 @@ discard block |
||
904 | 904 | $return = "\$this->_reg_objects['$object'][0]->$obj_comp"; |
905 | 905 | } |
906 | 906 | |
907 | - if($return != null) { |
|
908 | - if($tag_modifier != '') { |
|
907 | + if ($return != null) { |
|
908 | + if ($tag_modifier != '') { |
|
909 | 909 | $this->_parse_modifiers($return, $tag_modifier); |
910 | 910 | } |
911 | 911 | |
912 | - if(!empty($_assign_var)) { |
|
913 | - $output = "\$this->assign('" . $this->_dequote($_assign_var) ."', $return);"; |
|
912 | + if (!empty($_assign_var)) { |
|
913 | + $output = "\$this->assign('".$this->_dequote($_assign_var)."', $return);"; |
|
914 | 914 | } else { |
915 | - $output = 'echo ' . $return . ';'; |
|
915 | + $output = 'echo '.$return.';'; |
|
916 | 916 | $newline = $this->_additional_newline; |
917 | 917 | } |
918 | 918 | } else { |
919 | 919 | $output = ''; |
920 | 920 | } |
921 | 921 | |
922 | - return '<?php ' . $prefix . $output . $postfix . "?>" . $newline; |
|
922 | + return '<?php '.$prefix.$output.$postfix."?>".$newline; |
|
923 | 923 | } |
924 | 924 | |
925 | 925 | /** |
@@ -957,7 +957,7 @@ discard block |
||
957 | 957 | |
958 | 958 | $_params = "array('args' => array(".implode(', ', (array)$arg_list)."))"; |
959 | 959 | |
960 | - return "<?php require_once(SMARTY_CORE_DIR . 'core.run_insert_handler.php');\necho smarty_core_run_insert_handler($_params, \$this); ?>" . $this->_additional_newline; |
|
960 | + return "<?php require_once(SMARTY_CORE_DIR . 'core.run_insert_handler.php');\necho smarty_core_run_insert_handler($_params, \$this); ?>".$this->_additional_newline; |
|
961 | 961 | } |
962 | 962 | |
963 | 963 | /** |
@@ -992,8 +992,8 @@ discard block |
||
992 | 992 | $arg_list[] = "'$arg_name' => $arg_value"; |
993 | 993 | } |
994 | 994 | |
995 | - if ( $theme_template == 'true' ) |
|
996 | - $include_file = '"'.SugarThemeRegistry::current()->getTemplate(str_replace(array('"',"'"),'',$include_file)).'"'; |
|
995 | + if ($theme_template == 'true') |
|
996 | + $include_file = '"'.SugarThemeRegistry::current()->getTemplate(str_replace(array('"', "'"), '', $include_file)).'"'; |
|
997 | 997 | |
998 | 998 | $output = '<?php '; |
999 | 999 | |
@@ -1005,13 +1005,13 @@ discard block |
||
1005 | 1005 | "\$_smarty_tpl_vars = \$this->_tpl_vars;\n"; |
1006 | 1006 | |
1007 | 1007 | |
1008 | - $_params = "array('smarty_include_tpl_file' => " . $include_file . ", 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))"; |
|
1009 | - $output .= "\$this->_smarty_include($_params);\n" . |
|
1010 | - "\$this->_tpl_vars = \$_smarty_tpl_vars;\n" . |
|
1008 | + $_params = "array('smarty_include_tpl_file' => ".$include_file.", 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))"; |
|
1009 | + $output .= "\$this->_smarty_include($_params);\n". |
|
1010 | + "\$this->_tpl_vars = \$_smarty_tpl_vars;\n". |
|
1011 | 1011 | "unset(\$_smarty_tpl_vars);\n"; |
1012 | 1012 | |
1013 | 1013 | if (isset($assign_var)) { |
1014 | - $output .= "\$this->assign(" . $assign_var . ", ob_get_contents()); ob_end_clean();\n"; |
|
1014 | + $output .= "\$this->assign(".$assign_var.", ob_get_contents()); ob_end_clean();\n"; |
|
1015 | 1015 | } |
1016 | 1016 | |
1017 | 1017 | $output .= ' ?>'; |
@@ -1035,20 +1035,20 @@ discard block |
||
1035 | 1035 | } |
1036 | 1036 | |
1037 | 1037 | $assign_var = (empty($attrs['assign'])) ? '' : $this->_dequote($attrs['assign']); |
1038 | - $once_var = (empty($attrs['once']) || $attrs['once']=='false') ? 'false' : 'true'; |
|
1038 | + $once_var = (empty($attrs['once']) || $attrs['once'] == 'false') ? 'false' : 'true'; |
|
1039 | 1039 | |
1040 | 1040 | $arg_list = array(); |
1041 | - foreach($attrs as $arg_name => $arg_value) { |
|
1042 | - if($arg_name != 'file' AND $arg_name != 'once' AND $arg_name != 'assign') { |
|
1043 | - if(is_bool($arg_value)) |
|
1041 | + foreach ($attrs as $arg_name => $arg_value) { |
|
1042 | + if ($arg_name != 'file' AND $arg_name != 'once' AND $arg_name != 'assign') { |
|
1043 | + if (is_bool($arg_value)) |
|
1044 | 1044 | $arg_value = $arg_value ? 'true' : 'false'; |
1045 | 1045 | $arg_list[] = "'$arg_name' => $arg_value"; |
1046 | 1046 | } |
1047 | 1047 | } |
1048 | 1048 | |
1049 | - $_params = "array('smarty_file' => " . $attrs['file'] . ", 'smarty_assign' => '$assign_var', 'smarty_once' => $once_var, 'smarty_include_vars' => array(".implode(',', $arg_list)."))"; |
|
1049 | + $_params = "array('smarty_file' => ".$attrs['file'].", 'smarty_assign' => '$assign_var', 'smarty_once' => $once_var, 'smarty_include_vars' => array(".implode(',', $arg_list)."))"; |
|
1050 | 1050 | |
1051 | - return "<?php require_once(SMARTY_CORE_DIR . 'core.smarty_include_php.php');\nsmarty_core_smarty_include_php($_params, \$this); ?>" . $this->_additional_newline; |
|
1051 | + return "<?php require_once(SMARTY_CORE_DIR . 'core.smarty_include_php.php');\nsmarty_core_smarty_include_php($_params, \$this); ?>".$this->_additional_newline; |
|
1052 | 1052 | } |
1053 | 1053 | |
1054 | 1054 | |
@@ -1114,7 +1114,7 @@ discard block |
||
1114 | 1114 | if (!isset($attrs['max'])) |
1115 | 1115 | $output .= "{$section_props}['max'] = {$section_props}['loop'];\n"; |
1116 | 1116 | else |
1117 | - $output .= "if ({$section_props}['max'] < 0)\n" . |
|
1117 | + $output .= "if ({$section_props}['max'] < 0)\n". |
|
1118 | 1118 | " {$section_props}['max'] = {$section_props}['loop'];\n"; |
1119 | 1119 | |
1120 | 1120 | if (!isset($attrs['step'])) |
@@ -1123,9 +1123,9 @@ discard block |
||
1123 | 1123 | if (!isset($attrs['start'])) |
1124 | 1124 | $output .= "{$section_props}['start'] = {$section_props}['step'] > 0 ? 0 : {$section_props}['loop']-1;\n"; |
1125 | 1125 | else { |
1126 | - $output .= "if ({$section_props}['start'] < 0)\n" . |
|
1127 | - " {$section_props}['start'] = max({$section_props}['step'] > 0 ? 0 : -1, {$section_props}['loop'] + {$section_props}['start']);\n" . |
|
1128 | - "else\n" . |
|
1126 | + $output .= "if ({$section_props}['start'] < 0)\n". |
|
1127 | + " {$section_props}['start'] = max({$section_props}['step'] > 0 ? 0 : -1, {$section_props}['loop'] + {$section_props}['start']);\n". |
|
1128 | + "else\n". |
|
1129 | 1129 | " {$section_props}['start'] = min({$section_props}['start'], {$section_props}['step'] > 0 ? {$section_props}['loop'] : {$section_props}['loop']-1);\n"; |
1130 | 1130 | } |
1131 | 1131 | |
@@ -1135,9 +1135,9 @@ discard block |
||
1135 | 1135 | } else { |
1136 | 1136 | $output .= " {$section_props}['total'] = min(ceil(({$section_props}['step'] > 0 ? {$section_props}['loop'] - {$section_props}['start'] : {$section_props}['start']+1)/abs({$section_props}['step'])), {$section_props}['max']);\n"; |
1137 | 1137 | } |
1138 | - $output .= " if ({$section_props}['total'] == 0)\n" . |
|
1139 | - " {$section_props}['show'] = false;\n" . |
|
1140 | - "} else\n" . |
|
1138 | + $output .= " if ({$section_props}['total'] == 0)\n". |
|
1139 | + " {$section_props}['show'] = false;\n". |
|
1140 | + "} else\n". |
|
1141 | 1141 | " {$section_props}['total'] = 0;\n"; |
1142 | 1142 | |
1143 | 1143 | $output .= "if ({$section_props}['show']):\n"; |
@@ -1182,7 +1182,7 @@ discard block |
||
1182 | 1182 | } |
1183 | 1183 | |
1184 | 1184 | if (isset($attrs['key'])) { |
1185 | - $key = $this->_dequote($attrs['key']); |
|
1185 | + $key = $this->_dequote($attrs['key']); |
|
1186 | 1186 | if (!preg_match('~^\w+$~', $key)) { |
1187 | 1187 | return $this->_syntax_error("foreach: 'key' must to be a variable name (literal string)", E_USER_ERROR, __FILE__, __LINE__); |
1188 | 1188 | } |
@@ -1262,8 +1262,8 @@ discard block |
||
1262 | 1262 | |
1263 | 1263 | /* Tokenize args for 'if' tag. */ |
1264 | 1264 | preg_match_all('~(?> |
1265 | - ' . $this->_obj_call_regexp . '(?:' . $this->_mod_regexp . '*)? | # valid object call |
|
1266 | - ' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*)? | # var or quoted string |
|
1265 | + ' . $this->_obj_call_regexp.'(?:'.$this->_mod_regexp.'*)? | # valid object call |
|
1266 | + ' . $this->_var_regexp.'(?:'.$this->_mod_regexp.'*)? | # var or quoted string |
|
1267 | 1267 | \-?0[xX][0-9a-fA-F]+|\-?\d+(?:\.\d+)?|\.\d+|!==|===|==|!=|<>|<<|>>|<=|>=|\&\&|\|\||\(|\)|,|\!|\^|=|\&|\~|<|>|\||\%|\+|\-|\/|\*|\@ | # valid non-word token |
1268 | 1268 | \b\w+\b | # valid word token |
1269 | 1269 | \S+ # anything else |
@@ -1271,7 +1271,7 @@ discard block |
||
1271 | 1271 | |
1272 | 1272 | $tokens = $match[0]; |
1273 | 1273 | |
1274 | - if(empty($tokens)) { |
|
1274 | + if (empty($tokens)) { |
|
1275 | 1275 | $_error_msg = $elseif ? "'elseif'" : "'if'"; |
1276 | 1276 | $_error_msg .= ' statement requires arguments'; |
1277 | 1277 | $this->_syntax_error($_error_msg, E_USER_ERROR, __FILE__, __LINE__); |
@@ -1280,7 +1280,7 @@ discard block |
||
1280 | 1280 | |
1281 | 1281 | // make sure we have balanced parenthesis |
1282 | 1282 | $token_count = array_count_values($tokens); |
1283 | - if(isset($token_count['(']) && $token_count['('] != $token_count[')']) { |
|
1283 | + if (isset($token_count['(']) && $token_count['('] != $token_count[')']) { |
|
1284 | 1284 | $this->_syntax_error("unbalanced parenthesis in if statement", E_USER_ERROR, __FILE__, __LINE__); |
1285 | 1285 | } |
1286 | 1286 | |
@@ -1370,15 +1370,15 @@ discard block |
||
1370 | 1370 | /* If last token was a ')', we operate on the parenthesized |
1371 | 1371 | expression. The start of the expression is on the stack. |
1372 | 1372 | Otherwise, we operate on the last encountered token. */ |
1373 | - if ($tokens[$i-1] == ')') { |
|
1373 | + if ($tokens[$i - 1] == ')') { |
|
1374 | 1374 | $is_arg_start = array_pop($is_arg_stack); |
1375 | 1375 | if ($is_arg_start != 0) { |
1376 | - if (preg_match('~^' . $this->_func_regexp . '$~', $tokens[$is_arg_start-1])) { |
|
1376 | + if (preg_match('~^'.$this->_func_regexp.'$~', $tokens[$is_arg_start - 1])) { |
|
1377 | 1377 | $is_arg_start--; |
1378 | 1378 | } |
1379 | 1379 | } |
1380 | 1380 | } else |
1381 | - $is_arg_start = $i-1; |
|
1381 | + $is_arg_start = $i - 1; |
|
1382 | 1382 | /* Construct the argument for 'is' expression, so it knows |
1383 | 1383 | what to operate on. */ |
1384 | 1384 | $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start)); |
@@ -1388,7 +1388,7 @@ discard block |
||
1388 | 1388 | return modified tokens, where the first one is the result |
1389 | 1389 | of the 'is' expression and the rest are the tokens it |
1390 | 1390 | didn't touch. */ |
1391 | - $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1)); |
|
1391 | + $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i + 1)); |
|
1392 | 1392 | |
1393 | 1393 | /* Replace the old tokens with the new ones. */ |
1394 | 1394 | array_splice($tokens, $is_arg_start, count($tokens), $new_tokens); |
@@ -1399,19 +1399,19 @@ discard block |
||
1399 | 1399 | break; |
1400 | 1400 | |
1401 | 1401 | default: |
1402 | - if(preg_match('~^' . $this->_func_regexp . '$~', $token) ) { |
|
1402 | + if (preg_match('~^'.$this->_func_regexp.'$~', $token)) { |
|
1403 | 1403 | // function call |
1404 | - if($this->security && |
|
1404 | + if ($this->security && |
|
1405 | 1405 | !in_array($token, $this->security_settings['IF_FUNCS'])) { |
1406 | 1406 | $this->_syntax_error("(secure mode) '$token' not allowed in if statement", E_USER_ERROR, __FILE__, __LINE__); |
1407 | 1407 | } |
1408 | - } elseif(preg_match('~^' . $this->_var_regexp . '$~', $token) && (strpos('+-*/^%&|', substr($token, -1)) === false) && isset($tokens[$i+1]) && $tokens[$i+1] == '(') { |
|
1408 | + } elseif (preg_match('~^'.$this->_var_regexp.'$~', $token) && (strpos('+-*/^%&|', substr($token, -1)) === false) && isset($tokens[$i + 1]) && $tokens[$i + 1] == '(') { |
|
1409 | 1409 | // variable function call |
1410 | 1410 | $this->_syntax_error("variable function call '$token' not allowed in if statement", E_USER_ERROR, __FILE__, __LINE__); |
1411 | - } elseif(preg_match('~^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*)$~', $token)) { |
|
1411 | + } elseif (preg_match('~^'.$this->_obj_call_regexp.'|'.$this->_var_regexp.'(?:'.$this->_mod_regexp.'*)$~', $token)) { |
|
1412 | 1412 | // object or variable |
1413 | 1413 | $token = $this->_parse_var_props($token); |
1414 | - } elseif(is_numeric($token)) { |
|
1414 | + } elseif (is_numeric($token)) { |
|
1415 | 1415 | // number, skip it |
1416 | 1416 | } else { |
1417 | 1417 | $this->_syntax_error("unidentified token '$token'", E_USER_ERROR, __FILE__, __LINE__); |
@@ -1483,7 +1483,7 @@ discard block |
||
1483 | 1483 | if (isset($tokens[$expr_end]) && $tokens[$expr_end] == 'by') { |
1484 | 1484 | $expr_end++; |
1485 | 1485 | $expr_arg = $tokens[$expr_end++]; |
1486 | - $expr = "!(1 & ($is_arg / " . $this->_parse_var_props($expr_arg) . "))"; |
|
1486 | + $expr = "!(1 & ($is_arg / ".$this->_parse_var_props($expr_arg)."))"; |
|
1487 | 1487 | } else |
1488 | 1488 | $expr = "!(1 & $is_arg)"; |
1489 | 1489 | break; |
@@ -1492,7 +1492,7 @@ discard block |
||
1492 | 1492 | if (isset($tokens[$expr_end]) && $tokens[$expr_end] == 'by') { |
1493 | 1493 | $expr_end++; |
1494 | 1494 | $expr_arg = $tokens[$expr_end++]; |
1495 | - $expr = "(1 & ($is_arg / " . $this->_parse_var_props($expr_arg) . "))"; |
|
1495 | + $expr = "(1 & ($is_arg / ".$this->_parse_var_props($expr_arg)."))"; |
|
1496 | 1496 | } else |
1497 | 1497 | $expr = "(1 & $is_arg)"; |
1498 | 1498 | break; |
@@ -1501,7 +1501,7 @@ discard block |
||
1501 | 1501 | if (@$tokens[$expr_end] == 'by') { |
1502 | 1502 | $expr_end++; |
1503 | 1503 | $expr_arg = $tokens[$expr_end++]; |
1504 | - $expr = "!($is_arg % " . $this->_parse_var_props($expr_arg) . ")"; |
|
1504 | + $expr = "!($is_arg % ".$this->_parse_var_props($expr_arg).")"; |
|
1505 | 1505 | } else { |
1506 | 1506 | $this->_syntax_error("expecting 'by' after 'div'", E_USER_ERROR, __FILE__, __LINE__); |
1507 | 1507 | } |
@@ -1532,11 +1532,11 @@ discard block |
||
1532 | 1532 | { |
1533 | 1533 | |
1534 | 1534 | /* Tokenize tag attributes. */ |
1535 | - preg_match_all('~(?:' . $this->_obj_call_regexp . '|' . $this->_qstr_regexp . ' | (?>[^"\'=\s]+) |
|
1535 | + preg_match_all('~(?:'.$this->_obj_call_regexp.'|'.$this->_qstr_regexp.' | (?>[^"\'=\s]+) |
|
1536 | 1536 | )+ | |
1537 | 1537 | [=] |
1538 | 1538 | ~x', $tag_args, $match); |
1539 | - $tokens = $match[0]; |
|
1539 | + $tokens = $match[0]; |
|
1540 | 1540 | |
1541 | 1541 | $attrs = array(); |
1542 | 1542 | /* Parse state: |
@@ -1577,9 +1577,9 @@ discard block |
||
1577 | 1577 | $token = 'false'; |
1578 | 1578 | } else if ($token == 'null') { |
1579 | 1579 | $token = 'null'; |
1580 | - } else if (preg_match('~^' . $this->_num_const_regexp . '|0[xX][0-9a-fA-F]+$~', $token)) { |
|
1580 | + } else if (preg_match('~^'.$this->_num_const_regexp.'|0[xX][0-9a-fA-F]+$~', $token)) { |
|
1581 | 1581 | /* treat integer literally */ |
1582 | - } else if (!preg_match('~^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . ')*$~', $token)) { |
|
1582 | + } else if (!preg_match('~^'.$this->_obj_call_regexp.'|'.$this->_var_regexp.'(?:'.$this->_mod_regexp.')*$~', $token)) { |
|
1583 | 1583 | /* treat as a string, double-quote it escaping quotes */ |
1584 | 1584 | $token = '"'.addslashes($token).'"'; |
1585 | 1585 | } |
@@ -1593,8 +1593,8 @@ discard block |
||
1593 | 1593 | $last_token = $token; |
1594 | 1594 | } |
1595 | 1595 | |
1596 | - if($state != 0) { |
|
1597 | - if($state == 1) { |
|
1596 | + if ($state != 0) { |
|
1597 | + if ($state == 1) { |
|
1598 | 1598 | $this->_syntax_error("expecting '=' after attribute name '$last_token'", E_USER_ERROR, __FILE__, __LINE__); |
1599 | 1599 | } else { |
1600 | 1600 | $this->_syntax_error("missing attribute value", E_USER_ERROR, __FILE__, __LINE__); |
@@ -1614,7 +1614,7 @@ discard block |
||
1614 | 1614 | */ |
1615 | 1615 | function _parse_vars_props(&$tokens) |
1616 | 1616 | { |
1617 | - foreach($tokens as $key => $val) { |
|
1617 | + foreach ($tokens as $key => $val) { |
|
1618 | 1618 | $tokens[$key] = $this->_parse_var_props($val); |
1619 | 1619 | } |
1620 | 1620 | } |
@@ -1631,52 +1631,52 @@ discard block |
||
1631 | 1631 | { |
1632 | 1632 | $val = trim($val); |
1633 | 1633 | |
1634 | - if(preg_match('~^(' . $this->_obj_call_regexp . '|' . $this->_dvar_regexp . ')(' . $this->_mod_regexp . '*)$~', $val, $match)) { |
|
1634 | + if (preg_match('~^('.$this->_obj_call_regexp.'|'.$this->_dvar_regexp.')('.$this->_mod_regexp.'*)$~', $val, $match)) { |
|
1635 | 1635 | // $ variable or object |
1636 | 1636 | $return = $this->_parse_var($match[1]); |
1637 | 1637 | $modifiers = $match[2]; |
1638 | - if (!empty($this->default_modifiers) && !preg_match('~(^|\|)smarty:nodefaults($|\|)~',$modifiers)) { |
|
1639 | - $_default_mod_string = implode('|',(array)$this->default_modifiers); |
|
1640 | - $modifiers = empty($modifiers) ? $_default_mod_string : $_default_mod_string . '|' . $modifiers; |
|
1638 | + if (!empty($this->default_modifiers) && !preg_match('~(^|\|)smarty:nodefaults($|\|)~', $modifiers)) { |
|
1639 | + $_default_mod_string = implode('|', (array)$this->default_modifiers); |
|
1640 | + $modifiers = empty($modifiers) ? $_default_mod_string : $_default_mod_string.'|'.$modifiers; |
|
1641 | 1641 | } |
1642 | 1642 | $this->_parse_modifiers($return, $modifiers); |
1643 | 1643 | return $return; |
1644 | - } elseif (preg_match('~^' . $this->_db_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) { |
|
1644 | + } elseif (preg_match('~^'.$this->_db_qstr_regexp.'(?:'.$this->_mod_regexp.'*)$~', $val)) { |
|
1645 | 1645 | // double quoted text |
1646 | - preg_match('~^(' . $this->_db_qstr_regexp . ')('. $this->_mod_regexp . '*)$~', $val, $match); |
|
1646 | + preg_match('~^('.$this->_db_qstr_regexp.')('.$this->_mod_regexp.'*)$~', $val, $match); |
|
1647 | 1647 | $return = $this->_expand_quoted_text($match[1]); |
1648 | - if($match[2] != '') { |
|
1648 | + if ($match[2] != '') { |
|
1649 | 1649 | $this->_parse_modifiers($return, $match[2]); |
1650 | 1650 | } |
1651 | 1651 | return $return; |
1652 | 1652 | } |
1653 | - elseif(preg_match('~^' . $this->_num_const_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) { |
|
1653 | + elseif (preg_match('~^'.$this->_num_const_regexp.'(?:'.$this->_mod_regexp.'*)$~', $val)) { |
|
1654 | 1654 | // numerical constant |
1655 | - preg_match('~^(' . $this->_num_const_regexp . ')('. $this->_mod_regexp . '*)$~', $val, $match); |
|
1656 | - if($match[2] != '') { |
|
1655 | + preg_match('~^('.$this->_num_const_regexp.')('.$this->_mod_regexp.'*)$~', $val, $match); |
|
1656 | + if ($match[2] != '') { |
|
1657 | 1657 | $this->_parse_modifiers($match[1], $match[2]); |
1658 | 1658 | return $match[1]; |
1659 | 1659 | } |
1660 | 1660 | } |
1661 | - elseif(preg_match('~^' . $this->_si_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) { |
|
1661 | + elseif (preg_match('~^'.$this->_si_qstr_regexp.'(?:'.$this->_mod_regexp.'*)$~', $val)) { |
|
1662 | 1662 | // single quoted text |
1663 | - preg_match('~^(' . $this->_si_qstr_regexp . ')('. $this->_mod_regexp . '*)$~', $val, $match); |
|
1664 | - if($match[2] != '') { |
|
1663 | + preg_match('~^('.$this->_si_qstr_regexp.')('.$this->_mod_regexp.'*)$~', $val, $match); |
|
1664 | + if ($match[2] != '') { |
|
1665 | 1665 | $this->_parse_modifiers($match[1], $match[2]); |
1666 | 1666 | return $match[1]; |
1667 | 1667 | } |
1668 | 1668 | } |
1669 | - elseif(preg_match('~^' . $this->_cvar_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) { |
|
1669 | + elseif (preg_match('~^'.$this->_cvar_regexp.'(?:'.$this->_mod_regexp.'*)$~', $val)) { |
|
1670 | 1670 | // config var |
1671 | 1671 | return $this->_parse_conf_var($val); |
1672 | 1672 | } |
1673 | - elseif(preg_match('~^' . $this->_svar_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) { |
|
1673 | + elseif (preg_match('~^'.$this->_svar_regexp.'(?:'.$this->_mod_regexp.'*)$~', $val)) { |
|
1674 | 1674 | // section var |
1675 | 1675 | return $this->_parse_section_prop($val); |
1676 | 1676 | } |
1677 | - elseif(!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) { |
|
1677 | + elseif (!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) { |
|
1678 | 1678 | // literal string |
1679 | - return $this->_expand_quoted_text('"' . strtr($val, array('\\' => '\\\\', '"' => '\\"')) .'"'); |
|
1679 | + return $this->_expand_quoted_text('"'.strtr($val, array('\\' => '\\\\', '"' => '\\"')).'"'); |
|
1680 | 1680 | } |
1681 | 1681 | return $val; |
1682 | 1682 | } |
@@ -1690,11 +1690,11 @@ discard block |
||
1690 | 1690 | function _expand_quoted_text($var_expr) |
1691 | 1691 | { |
1692 | 1692 | // if contains unescaped $, expand it |
1693 | - if(preg_match_all('~(?:\`(?<!\\\\)\$' . $this->_dvar_guts_regexp . '(?:' . $this->_obj_ext_regexp . ')*\`)|(?:(?<!\\\\)\$\w+(\[[a-zA-Z0-9]+\])*)~', $var_expr, $_match)) { |
|
1693 | + if (preg_match_all('~(?:\`(?<!\\\\)\$'.$this->_dvar_guts_regexp.'(?:'.$this->_obj_ext_regexp.')*\`)|(?:(?<!\\\\)\$\w+(\[[a-zA-Z0-9]+\])*)~', $var_expr, $_match)) { |
|
1694 | 1694 | $_match = $_match[0]; |
1695 | 1695 | $_replace = array(); |
1696 | - foreach($_match as $_var) { |
|
1697 | - $_replace[$_var] = '".(' . $this->_parse_var(str_replace('`','',$_var)) . ')."'; |
|
1696 | + foreach ($_match as $_var) { |
|
1697 | + $_replace[$_var] = '".('.$this->_parse_var(str_replace('`', '', $_var)).')."'; |
|
1698 | 1698 | } |
1699 | 1699 | $var_expr = strtr($var_expr, $_replace); |
1700 | 1700 | $_return = preg_replace('~\.""|(?<!\\\\)""\.~', '', $var_expr); |
@@ -1702,7 +1702,7 @@ discard block |
||
1702 | 1702 | $_return = $var_expr; |
1703 | 1703 | } |
1704 | 1704 | // replace double quoted literal string with single quotes |
1705 | - $_return = preg_replace('~^"([\s\w]+)"$~',"'\\1'",$_return); |
|
1705 | + $_return = preg_replace('~^"([\s\w]+)"$~', "'\\1'", $_return); |
|
1706 | 1706 | return $_return; |
1707 | 1707 | } |
1708 | 1708 | |
@@ -1718,26 +1718,26 @@ discard block |
||
1718 | 1718 | $_has_math = false; |
1719 | 1719 | $_math_vars = preg_split('~('.$this->_dvar_math_regexp.'|'.$this->_qstr_regexp.')~', $var_expr, -1, PREG_SPLIT_DELIM_CAPTURE); |
1720 | 1720 | |
1721 | - if(count($_math_vars) > 1) { |
|
1721 | + if (count($_math_vars) > 1) { |
|
1722 | 1722 | $_first_var = ""; |
1723 | 1723 | $_complete_var = ""; |
1724 | 1724 | $_output = ""; |
1725 | 1725 | // simple check if there is any math, to stop recursion (due to modifiers with "xx % yy" as parameter) |
1726 | - foreach($_math_vars as $_k => $_math_var) { |
|
1726 | + foreach ($_math_vars as $_k => $_math_var) { |
|
1727 | 1727 | $_math_var = $_math_vars[$_k]; |
1728 | 1728 | |
1729 | - if(!empty($_math_var) || is_numeric($_math_var)) { |
|
1729 | + if (!empty($_math_var) || is_numeric($_math_var)) { |
|
1730 | 1730 | // hit a math operator, so process the stuff which came before it |
1731 | - if(preg_match('~^' . $this->_dvar_math_regexp . '$~', $_math_var)) { |
|
1731 | + if (preg_match('~^'.$this->_dvar_math_regexp.'$~', $_math_var)) { |
|
1732 | 1732 | $_has_math = true; |
1733 | - if(!empty($_complete_var) || is_numeric($_complete_var)) { |
|
1733 | + if (!empty($_complete_var) || is_numeric($_complete_var)) { |
|
1734 | 1734 | $_output .= $this->_parse_var($_complete_var); |
1735 | 1735 | } |
1736 | 1736 | |
1737 | 1737 | // just output the math operator to php |
1738 | 1738 | $_output .= $_math_var; |
1739 | 1739 | |
1740 | - if(empty($_first_var)) |
|
1740 | + if (empty($_first_var)) |
|
1741 | 1741 | $_first_var = $_complete_var; |
1742 | 1742 | |
1743 | 1743 | $_complete_var = ""; |
@@ -1746,8 +1746,8 @@ discard block |
||
1746 | 1746 | } |
1747 | 1747 | } |
1748 | 1748 | } |
1749 | - if($_has_math) { |
|
1750 | - if(!empty($_complete_var) || is_numeric($_complete_var)) |
|
1749 | + if ($_has_math) { |
|
1750 | + if (!empty($_complete_var) || is_numeric($_complete_var)) |
|
1751 | 1751 | $_output .= $this->_parse_var($_complete_var); |
1752 | 1752 | |
1753 | 1753 | // get the modifiers working (only the last var from math + modifier is left) |
@@ -1756,15 +1756,15 @@ discard block |
||
1756 | 1756 | } |
1757 | 1757 | |
1758 | 1758 | // prevent cutting of first digit in the number (we _definitly_ got a number if the first char is a digit) |
1759 | - if(is_numeric(substr($var_expr, 0, 1))) |
|
1759 | + if (is_numeric(substr($var_expr, 0, 1))) |
|
1760 | 1760 | $_var_ref = $var_expr; |
1761 | 1761 | else |
1762 | 1762 | $_var_ref = substr($var_expr, 1); |
1763 | 1763 | |
1764 | - if(!$_has_math) { |
|
1764 | + if (!$_has_math) { |
|
1765 | 1765 | |
1766 | 1766 | // get [foo] and .foo and ->foo and (...) pieces |
1767 | - preg_match_all('~(?:^\w+)|' . $this->_obj_params_regexp . '|(?:' . $this->_var_bracket_regexp . ')|->\$?\w+|\.\$?\w+|\S+~', $_var_ref, $match); |
|
1767 | + preg_match_all('~(?:^\w+)|'.$this->_obj_params_regexp.'|(?:'.$this->_var_bracket_regexp.')|->\$?\w+|\.\$?\w+|\S+~', $_var_ref, $match); |
|
1768 | 1768 | |
1769 | 1769 | $_indexes = $match[0]; |
1770 | 1770 | $_var_name = array_shift($_indexes); |
@@ -1782,9 +1782,9 @@ discard block |
||
1782 | 1782 | $_var_name = substr(array_shift($_indexes), 1); |
1783 | 1783 | $_output = "\$this->_smarty_vars['$_var_name']"; |
1784 | 1784 | } |
1785 | - } elseif(is_numeric($_var_name) && is_numeric(substr($var_expr, 0, 1))) { |
|
1785 | + } elseif (is_numeric($_var_name) && is_numeric(substr($var_expr, 0, 1))) { |
|
1786 | 1786 | // because . is the operator for accessing arrays thru inidizes we need to put it together again for floating point numbers |
1787 | - if(count($_indexes) > 0) |
|
1787 | + if (count($_indexes) > 0) |
|
1788 | 1788 | { |
1789 | 1789 | $_var_name .= implode("", $_indexes); |
1790 | 1790 | $_indexes = array(); |
@@ -1801,9 +1801,9 @@ discard block |
||
1801 | 1801 | $_output .= "[$_index]"; |
1802 | 1802 | } elseif (substr($_index, 0, 1) == '$') { |
1803 | 1803 | if (strpos($_index, '.') !== false) { |
1804 | - $_output .= '[' . $this->_parse_var($_index) . ']'; |
|
1804 | + $_output .= '['.$this->_parse_var($_index).']'; |
|
1805 | 1805 | } else { |
1806 | - $_output .= "[\$this->_tpl_vars['" . substr($_index, 1) . "']]"; |
|
1806 | + $_output .= "[\$this->_tpl_vars['".substr($_index, 1)."']]"; |
|
1807 | 1807 | } |
1808 | 1808 | } else { |
1809 | 1809 | $_var_parts = explode('.', $_index); |
@@ -1813,19 +1813,19 @@ discard block |
||
1813 | 1813 | } |
1814 | 1814 | } else if (substr($_index, 0, 1) == '.') { |
1815 | 1815 | if (substr($_index, 1, 1) == '$') |
1816 | - $_output .= "[\$this->_tpl_vars['" . substr($_index, 2) . "']]"; |
|
1816 | + $_output .= "[\$this->_tpl_vars['".substr($_index, 2)."']]"; |
|
1817 | 1817 | else |
1818 | - $_output .= "['" . substr($_index, 1) . "']"; |
|
1819 | - } else if (substr($_index,0,2) == '->') { |
|
1820 | - if(substr($_index,2,2) == '__') { |
|
1818 | + $_output .= "['".substr($_index, 1)."']"; |
|
1819 | + } else if (substr($_index, 0, 2) == '->') { |
|
1820 | + if (substr($_index, 2, 2) == '__') { |
|
1821 | 1821 | $this->_syntax_error('call to internal object members is not allowed', E_USER_ERROR, __FILE__, __LINE__); |
1822 | - } elseif($this->security && substr($_index, 2, 1) == '_') { |
|
1822 | + } elseif ($this->security && substr($_index, 2, 1) == '_') { |
|
1823 | 1823 | $this->_syntax_error('(secure) call to private object member is not allowed', E_USER_ERROR, __FILE__, __LINE__); |
1824 | 1824 | } elseif (substr($_index, 2, 1) == '$') { |
1825 | 1825 | if ($this->security) { |
1826 | 1826 | $this->_syntax_error('(secure) call to dynamic object member is not allowed', E_USER_ERROR, __FILE__, __LINE__); |
1827 | 1827 | } else { |
1828 | - $_output .= '->{(($_var=$this->_tpl_vars[\''.substr($_index,3).'\']) && substr($_var,0,2)!=\'__\') ? $_var : $this->trigger_error("cannot access property \\"$_var\\"")}'; |
|
1828 | + $_output .= '->{(($_var=$this->_tpl_vars[\''.substr($_index, 3).'\']) && substr($_var,0,2)!=\'__\') ? $_var : $this->trigger_error("cannot access property \\"$_var\\"")}'; |
|
1829 | 1829 | } |
1830 | 1830 | } else { |
1831 | 1831 | $_output .= $_index; |
@@ -1850,7 +1850,7 @@ discard block |
||
1850 | 1850 | */ |
1851 | 1851 | function _parse_parenth_args($parenth_args) |
1852 | 1852 | { |
1853 | - preg_match_all('~' . $this->_param_regexp . '~',$parenth_args, $match); |
|
1853 | + preg_match_all('~'.$this->_param_regexp.'~', $parenth_args, $match); |
|
1854 | 1854 | $orig_vals = $match = $match[0]; |
1855 | 1855 | $this->_parse_vars_props($match); |
1856 | 1856 | $replace = array(); |
@@ -1913,18 +1913,18 @@ discard block |
||
1913 | 1913 | */ |
1914 | 1914 | function _parse_modifiers(&$output, $modifier_string) |
1915 | 1915 | { |
1916 | - preg_match_all('~\|(@?\w+)((?>:(?:'. $this->_qstr_regexp . '|[^|]+))*)~', '|' . $modifier_string, $_match); |
|
1916 | + preg_match_all('~\|(@?\w+)((?>:(?:'.$this->_qstr_regexp.'|[^|]+))*)~', '|'.$modifier_string, $_match); |
|
1917 | 1917 | list(, $_modifiers, $modifier_arg_strings) = $_match; |
1918 | 1918 | |
1919 | 1919 | for ($_i = 0, $_for_max = count($_modifiers); $_i < $_for_max; $_i++) { |
1920 | 1920 | $_modifier_name = $_modifiers[$_i]; |
1921 | 1921 | |
1922 | - if($_modifier_name == 'smarty') { |
|
1922 | + if ($_modifier_name == 'smarty') { |
|
1923 | 1923 | // skip smarty modifier |
1924 | 1924 | continue; |
1925 | 1925 | } |
1926 | 1926 | |
1927 | - preg_match_all('~:(' . $this->_qstr_regexp . '|[^:]+)~', $modifier_arg_strings[$_i], $_match); |
|
1927 | + preg_match_all('~:('.$this->_qstr_regexp.'|[^:]+)~', $modifier_arg_strings[$_i], $_match); |
|
1928 | 1928 | $_modifier_args = $_match[1]; |
1929 | 1929 | |
1930 | 1930 | if (substr($_modifier_name, 0, 1) == '@') { |
@@ -1938,22 +1938,22 @@ discard block |
||
1938 | 1938 | && !$this->_get_plugin_filepath('modifier', $_modifier_name) |
1939 | 1939 | && function_exists($_modifier_name)) { |
1940 | 1940 | if ($this->security && !in_array($_modifier_name, $this->security_settings['MODIFIER_FUNCS'])) { |
1941 | - $this->_trigger_fatal_error("[plugin] (secure mode) modifier '$_modifier_name' is not allowed" , $this->_current_file, $this->_current_line_no, __FILE__, __LINE__); |
|
1941 | + $this->_trigger_fatal_error("[plugin] (secure mode) modifier '$_modifier_name' is not allowed", $this->_current_file, $this->_current_line_no, __FILE__, __LINE__); |
|
1942 | 1942 | } else { |
1943 | - $this->_plugins['modifier'][$_modifier_name] = array($_modifier_name, null, null, false); |
|
1943 | + $this->_plugins['modifier'][$_modifier_name] = array($_modifier_name, null, null, false); |
|
1944 | 1944 | } |
1945 | 1945 | } |
1946 | 1946 | $this->_add_plugin('modifier', $_modifier_name); |
1947 | 1947 | |
1948 | 1948 | $this->_parse_vars_props($_modifier_args); |
1949 | 1949 | |
1950 | - if($_modifier_name == 'default') { |
|
1950 | + if ($_modifier_name == 'default') { |
|
1951 | 1951 | // supress notifications of default modifier vars and args |
1952 | - if(substr($output, 0, 1) == '$') { |
|
1953 | - $output = '@' . $output; |
|
1952 | + if (substr($output, 0, 1) == '$') { |
|
1953 | + $output = '@'.$output; |
|
1954 | 1954 | } |
1955 | - if(isset($_modifier_args[0]) && substr($_modifier_args[0], 0, 1) == '$') { |
|
1956 | - $_modifier_args[0] = '@' . $_modifier_args[0]; |
|
1955 | + if (isset($_modifier_args[0]) && substr($_modifier_args[0], 0, 1) == '$') { |
|
1956 | + $_modifier_args[0] = '@'.$_modifier_args[0]; |
|
1957 | 1957 | } |
1958 | 1958 | } |
1959 | 1959 | if (count($_modifier_args) > 0) |
@@ -1962,7 +1962,7 @@ discard block |
||
1962 | 1962 | $_modifier_args = ''; |
1963 | 1963 | |
1964 | 1964 | if ($_map_array) { |
1965 | - $output = "((is_array(\$_tmp=$output)) ? \$this->_run_mod_handler('$_modifier_name', true, \$_tmp$_modifier_args) : " . $this->_compile_plugin_call('modifier', $_modifier_name) . "(\$_tmp$_modifier_args))"; |
|
1965 | + $output = "((is_array(\$_tmp=$output)) ? \$this->_run_mod_handler('$_modifier_name', true, \$_tmp$_modifier_args) : ".$this->_compile_plugin_call('modifier', $_modifier_name)."(\$_tmp$_modifier_args))"; |
|
1966 | 1966 | |
1967 | 1967 | } else { |
1968 | 1968 | |
@@ -2003,9 +2003,9 @@ discard block |
||
2003 | 2003 | { |
2004 | 2004 | /* Extract the reference name. */ |
2005 | 2005 | $_ref = substr($indexes[0], 1); |
2006 | - foreach($indexes as $_index_no=>$_index) { |
|
2007 | - if (substr($_index, 0, 1) != '.' && $_index_no<2 || !preg_match('~^(\.|\[|->)~', $_index)) { |
|
2008 | - $this->_syntax_error('$smarty' . implode('', array_slice($indexes, 0, 2)) . ' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__); |
|
2006 | + foreach ($indexes as $_index_no=>$_index) { |
|
2007 | + if (substr($_index, 0, 1) != '.' && $_index_no < 2 || !preg_match('~^(\.|\[|->)~', $_index)) { |
|
2008 | + $this->_syntax_error('$smarty'.implode('', array_slice($indexes, 0, 2)).' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__); |
|
2009 | 2009 | } |
2010 | 2010 | } |
2011 | 2011 | |
@@ -2129,7 +2129,7 @@ discard block |
||
2129 | 2129 | return null; |
2130 | 2130 | |
2131 | 2131 | case 'template': |
2132 | - $compiled_ref = "'" . addslashes($this->_current_file) . "'"; |
|
2132 | + $compiled_ref = "'".addslashes($this->_current_file)."'"; |
|
2133 | 2133 | $_max_index = 1; |
2134 | 2134 | break; |
2135 | 2135 | |
@@ -2146,10 +2146,10 @@ discard block |
||
2146 | 2146 | } |
2147 | 2147 | array_shift($indexes); |
2148 | 2148 | if (preg_match('!^\.\w+$!', $indexes[0])) { |
2149 | - $compiled_ref = '@' . substr($indexes[0], 1); |
|
2149 | + $compiled_ref = '@'.substr($indexes[0], 1); |
|
2150 | 2150 | } else { |
2151 | 2151 | $_val = $this->_parse_var_props(substr($indexes[0], 1)); |
2152 | - $compiled_ref = '@constant(' . $_val . ')'; |
|
2152 | + $compiled_ref = '@constant('.$_val.')'; |
|
2153 | 2153 | } |
2154 | 2154 | $_max_index = 1; |
2155 | 2155 | break; |
@@ -2168,12 +2168,12 @@ discard block |
||
2168 | 2168 | break; |
2169 | 2169 | |
2170 | 2170 | default: |
2171 | - $this->_syntax_error('$smarty.' . $_ref . ' is an unknown reference', E_USER_ERROR, __FILE__, __LINE__); |
|
2171 | + $this->_syntax_error('$smarty.'.$_ref.' is an unknown reference', E_USER_ERROR, __FILE__, __LINE__); |
|
2172 | 2172 | break; |
2173 | 2173 | } |
2174 | 2174 | |
2175 | 2175 | if (isset($_max_index) && count($indexes) > $_max_index) { |
2176 | - $this->_syntax_error('$smarty' . implode('', $indexes) .' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__); |
|
2176 | + $this->_syntax_error('$smarty'.implode('', $indexes).' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__); |
|
2177 | 2177 | } |
2178 | 2178 | |
2179 | 2179 | array_shift($indexes); |
@@ -2197,7 +2197,7 @@ discard block |
||
2197 | 2197 | return ((is_object($this->_plugins[$type][$name][0][0])) ? |
2198 | 2198 | "\$this->_plugins['$type']['$name'][0][0]->" /* method callback */ |
2199 | 2199 | : (string)($this->_plugins[$type][$name][0][0]).'::' /* class callback */ |
2200 | - ). $this->_plugins[$type][$name][0][1]; |
|
2200 | + ).$this->_plugins[$type][$name][0][1]; |
|
2201 | 2201 | |
2202 | 2202 | } else { |
2203 | 2203 | /* function callback */ |
@@ -2221,7 +2221,7 @@ discard block |
||
2221 | 2221 | if ($prefilter === false) { |
2222 | 2222 | unset($this->_plugins['prefilter'][$filter_name]); |
2223 | 2223 | $_params = array('plugins' => array(array('prefilter', $filter_name, null, null, false))); |
2224 | - require_once(SMARTY_CORE_DIR . 'core.load_plugins.php'); |
|
2224 | + require_once(SMARTY_CORE_DIR.'core.load_plugins.php'); |
|
2225 | 2225 | smarty_core_load_plugins($_params, $this); |
2226 | 2226 | } |
2227 | 2227 | } |
@@ -2231,7 +2231,7 @@ discard block |
||
2231 | 2231 | if ($postfilter === false) { |
2232 | 2232 | unset($this->_plugins['postfilter'][$filter_name]); |
2233 | 2233 | $_params = array('plugins' => array(array('postfilter', $filter_name, null, null, false))); |
2234 | - require_once(SMARTY_CORE_DIR . 'core.load_plugins.php'); |
|
2234 | + require_once(SMARTY_CORE_DIR.'core.load_plugins.php'); |
|
2235 | 2235 | smarty_core_load_plugins($_params, $this); |
2236 | 2236 | } |
2237 | 2237 | } |
@@ -2258,7 +2258,7 @@ discard block |
||
2258 | 2258 | * @param string $file |
2259 | 2259 | * @param integer $line |
2260 | 2260 | */ |
2261 | - function _syntax_error($error_msg, $error_type = E_USER_ERROR, $file=null, $line=null) |
|
2261 | + function _syntax_error($error_msg, $error_type = E_USER_ERROR, $file = null, $line = null) |
|
2262 | 2262 | { |
2263 | 2263 | $this->_trigger_fatal_error("syntax error: $error_msg", $this->_current_file, $this->_current_line_no, $file, $line, $error_type); |
2264 | 2264 | } |
@@ -2273,10 +2273,10 @@ discard block |
||
2273 | 2273 | function _push_cacheable_state($type, $name) { |
2274 | 2274 | $_cacheable = !isset($this->_plugins[$type][$name]) || $this->_plugins[$type][$name][4]; |
2275 | 2275 | if ($_cacheable |
2276 | - || 0<$this->_cacheable_state++) return ''; |
|
2276 | + || 0 < $this->_cacheable_state++) return ''; |
|
2277 | 2277 | if (!isset($this->_cache_serial)) $this->_cache_serial = md5(uniqid('Smarty')); |
2278 | 2278 | $_ret = 'if ($this->caching && !$this->_cache_including): echo \'{nocache:' |
2279 | - . $this->_cache_serial . '#' . $this->_nocache_count |
|
2279 | + . $this->_cache_serial.'#'.$this->_nocache_count |
|
2280 | 2280 | . '}\'; endif;'; |
2281 | 2281 | return $_ret; |
2282 | 2282 | } |
@@ -2291,9 +2291,9 @@ discard block |
||
2291 | 2291 | function _pop_cacheable_state($type, $name) { |
2292 | 2292 | $_cacheable = !isset($this->_plugins[$type][$name]) || $this->_plugins[$type][$name][4]; |
2293 | 2293 | if ($_cacheable |
2294 | - || --$this->_cacheable_state>0) return ''; |
|
2294 | + || --$this->_cacheable_state > 0) return ''; |
|
2295 | 2295 | return 'if ($this->caching && !$this->_cache_including): echo \'{/nocache:' |
2296 | - . $this->_cache_serial . '#' . ($this->_nocache_count++) |
|
2296 | + . $this->_cache_serial.'#'.($this->_nocache_count++) |
|
2297 | 2297 | . '}\'; endif;'; |
2298 | 2298 | } |
2299 | 2299 | |
@@ -2316,12 +2316,12 @@ discard block |
||
2316 | 2316 | function _pop_tag($close_tag) |
2317 | 2317 | { |
2318 | 2318 | $message = ''; |
2319 | - if (count($this->_tag_stack)>0) { |
|
2319 | + if (count($this->_tag_stack) > 0) { |
|
2320 | 2320 | list($_open_tag, $_line_no) = array_pop($this->_tag_stack); |
2321 | 2321 | if ($close_tag == $_open_tag) { |
2322 | 2322 | return $_open_tag; |
2323 | 2323 | } |
2324 | - if ($close_tag == 'if' && ($_open_tag == 'else' || $_open_tag == 'elseif' )) { |
|
2324 | + if ($close_tag == 'if' && ($_open_tag == 'else' || $_open_tag == 'elseif')) { |
|
2325 | 2325 | return $this->_pop_tag($close_tag); |
2326 | 2326 | } |
2327 | 2327 | if ($close_tag == 'section' && $_open_tag == 'sectionelse') { |
@@ -2357,10 +2357,10 @@ discard block |
||
2357 | 2357 | */ |
2358 | 2358 | function _smarty_sort_length($a, $b) |
2359 | 2359 | { |
2360 | - if($a == $b) |
|
2360 | + if ($a == $b) |
|
2361 | 2361 | return 0; |
2362 | 2362 | |
2363 | - if(strlen($a) == strlen($b)) |
|
2363 | + if (strlen($a) == strlen($b)) |
|
2364 | 2364 | return ($a > $b) ? -1 : 1; |
2365 | 2365 | |
2366 | 2366 | return (strlen($a) > strlen($b)) ? -1 : 1; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @var BOOL |
131 | 131 | */ |
132 | - var $process_save_dates =true; |
|
132 | + var $process_save_dates = true; |
|
133 | 133 | |
134 | 134 | /** |
135 | 135 | * This signals to the bean that it is being saved in a mass mode. |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | /** Set this to true if you query contains a sub-select and bean is converting both select statements |
211 | 211 | * into count queries. |
212 | 212 | */ |
213 | - var $ungreedy_count=false; |
|
213 | + var $ungreedy_count = false; |
|
214 | 214 | |
215 | 215 | /** |
216 | 216 | * The name of the module folder for this type of bean. |
@@ -227,14 +227,14 @@ discard block |
||
227 | 227 | var $additional_column_fields = array(); |
228 | 228 | var $relationship_fields = array(); |
229 | 229 | var $current_notify_user; |
230 | - var $fetched_row=false; |
|
230 | + var $fetched_row = false; |
|
231 | 231 | var $fetched_rel_row = array(); |
232 | 232 | var $layout_def; |
233 | 233 | var $force_load_details = false; |
234 | 234 | var $optimistic_lock = false; |
235 | 235 | var $disable_custom_fields = false; |
236 | 236 | var $number_formatting_done = false; |
237 | - var $process_field_encrypted=false; |
|
237 | + var $process_field_encrypted = false; |
|
238 | 238 | /* |
239 | 239 | * The default ACL type |
240 | 240 | */ |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | $this->db = DBManagerFactory::getInstance(); |
318 | 318 | if (empty($this->module_name)) |
319 | 319 | $this->module_name = $this->module_dir; |
320 | - if((false == $this->disable_vardefs && empty($loaded_defs[$this->object_name])) || !empty($GLOBALS['reload_vardefs'])) |
|
320 | + if ((false == $this->disable_vardefs && empty($loaded_defs[$this->object_name])) || !empty($GLOBALS['reload_vardefs'])) |
|
321 | 321 | { |
322 | 322 | VardefManager::loadVardef($this->module_dir, $this->object_name); |
323 | 323 | |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | if (!empty($dictionary[$this->object_name]['fields'])) { |
326 | 326 | foreach ($dictionary[$this->object_name]['fields'] as $key=>$value_array) { |
327 | 327 | $column_fields[] = $key; |
328 | - if(!empty($value_array['required']) && !empty($value_array['name'])) { |
|
328 | + if (!empty($value_array['required']) && !empty($value_array['name'])) { |
|
329 | 329 | $this->required_fields[$value_array['name']] = 1; |
330 | 330 | } |
331 | 331 | } |
@@ -333,57 +333,57 @@ discard block |
||
333 | 333 | } |
334 | 334 | |
335 | 335 | //setup custom fields |
336 | - if(!isset($this->custom_fields) && |
|
336 | + if (!isset($this->custom_fields) && |
|
337 | 337 | empty($this->disable_custom_fields)) |
338 | 338 | { |
339 | 339 | $this->setupCustomFields($this->module_dir); |
340 | 340 | } |
341 | 341 | //load up field_arrays from CacheHandler; |
342 | - if(empty($this->list_fields)) |
|
342 | + if (empty($this->list_fields)) |
|
343 | 343 | $this->list_fields = $this->_loadCachedArray($this->module_dir, $this->object_name, 'list_fields'); |
344 | - if(empty($this->column_fields)) |
|
344 | + if (empty($this->column_fields)) |
|
345 | 345 | $this->column_fields = $this->_loadCachedArray($this->module_dir, $this->object_name, 'column_fields'); |
346 | - if(empty($this->required_fields)) |
|
346 | + if (empty($this->required_fields)) |
|
347 | 347 | $this->required_fields = $this->_loadCachedArray($this->module_dir, $this->object_name, 'required_fields'); |
348 | 348 | |
349 | - if(isset($GLOBALS['dictionary'][$this->object_name]) && !$this->disable_vardefs) |
|
349 | + if (isset($GLOBALS['dictionary'][$this->object_name]) && !$this->disable_vardefs) |
|
350 | 350 | { |
351 | 351 | $this->field_name_map = $dictionary[$this->object_name]['fields']; |
352 | - $this->field_defs = $dictionary[$this->object_name]['fields']; |
|
352 | + $this->field_defs = $dictionary[$this->object_name]['fields']; |
|
353 | 353 | |
354 | - if(!empty($dictionary[$this->object_name]['optimistic_locking'])) |
|
354 | + if (!empty($dictionary[$this->object_name]['optimistic_locking'])) |
|
355 | 355 | { |
356 | - $this->optimistic_lock=true; |
|
356 | + $this->optimistic_lock = true; |
|
357 | 357 | } |
358 | 358 | } |
359 | - $loaded_defs[$this->object_name]['column_fields'] =& $this->column_fields; |
|
360 | - $loaded_defs[$this->object_name]['list_fields'] =& $this->list_fields; |
|
361 | - $loaded_defs[$this->object_name]['required_fields'] =& $this->required_fields; |
|
362 | - $loaded_defs[$this->object_name]['field_name_map'] =& $this->field_name_map; |
|
363 | - $loaded_defs[$this->object_name]['field_defs'] =& $this->field_defs; |
|
359 | + $loaded_defs[$this->object_name]['column_fields'] = & $this->column_fields; |
|
360 | + $loaded_defs[$this->object_name]['list_fields'] = & $this->list_fields; |
|
361 | + $loaded_defs[$this->object_name]['required_fields'] = & $this->required_fields; |
|
362 | + $loaded_defs[$this->object_name]['field_name_map'] = & $this->field_name_map; |
|
363 | + $loaded_defs[$this->object_name]['field_defs'] = & $this->field_defs; |
|
364 | 364 | } |
365 | 365 | else |
366 | 366 | { |
367 | - $this->column_fields =& $loaded_defs[$this->object_name]['column_fields'] ; |
|
368 | - $this->list_fields =& $loaded_defs[$this->object_name]['list_fields']; |
|
369 | - $this->required_fields =& $loaded_defs[$this->object_name]['required_fields']; |
|
370 | - $this->field_name_map =& $loaded_defs[$this->object_name]['field_name_map']; |
|
371 | - $this->field_defs =& $loaded_defs[$this->object_name]['field_defs']; |
|
367 | + $this->column_fields = & $loaded_defs[$this->object_name]['column_fields']; |
|
368 | + $this->list_fields = & $loaded_defs[$this->object_name]['list_fields']; |
|
369 | + $this->required_fields = & $loaded_defs[$this->object_name]['required_fields']; |
|
370 | + $this->field_name_map = & $loaded_defs[$this->object_name]['field_name_map']; |
|
371 | + $this->field_defs = & $loaded_defs[$this->object_name]['field_defs']; |
|
372 | 372 | $this->added_custom_field_defs = true; |
373 | 373 | |
374 | - if(!isset($this->custom_fields) && |
|
374 | + if (!isset($this->custom_fields) && |
|
375 | 375 | empty($this->disable_custom_fields)) |
376 | 376 | { |
377 | 377 | $this->setupCustomFields($this->module_dir, false); |
378 | 378 | } |
379 | - if(!empty($dictionary[$this->object_name]['optimistic_locking'])) |
|
379 | + if (!empty($dictionary[$this->object_name]['optimistic_locking'])) |
|
380 | 380 | { |
381 | - $this->optimistic_lock=true; |
|
381 | + $this->optimistic_lock = true; |
|
382 | 382 | } |
383 | 383 | } |
384 | 384 | |
385 | - if($this->bean_implements('ACL') && !empty($GLOBALS['current_user'])){ |
|
386 | - $this->acl_fields = (isset($dictionary[$this->object_name]['acl_fields']) && $dictionary[$this->object_name]['acl_fields'] === false)?false:true; |
|
385 | + if ($this->bean_implements('ACL') && !empty($GLOBALS['current_user'])) { |
|
386 | + $this->acl_fields = (isset($dictionary[$this->object_name]['acl_fields']) && $dictionary[$this->object_name]['acl_fields'] === false) ? false : true; |
|
387 | 387 | } |
388 | 388 | $this->populateDefaultValues(); |
389 | 389 | } |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | if (!isset($this->audit_enabled_fields)) |
428 | 428 | { |
429 | 429 | |
430 | - $this->audit_enabled_fields=array(); |
|
430 | + $this->audit_enabled_fields = array(); |
|
431 | 431 | foreach ($this->field_defs as $field => $properties) |
432 | 432 | { |
433 | 433 | |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | ) |
438 | 438 | { |
439 | 439 | |
440 | - $this->audit_enabled_fields[$field]=$properties; |
|
440 | + $this->audit_enabled_fields[$field] = $properties; |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
@@ -504,12 +504,12 @@ discard block |
||
504 | 504 | function create_audit_table() |
505 | 505 | { |
506 | 506 | global $dictionary; |
507 | - $table_name=$this->get_audit_table_name(); |
|
507 | + $table_name = $this->get_audit_table_name(); |
|
508 | 508 | |
509 | 509 | require('metadata/audit_templateMetaData.php'); |
510 | 510 | |
511 | 511 | // Bug: 52583 Need ability to customize template for audit tables |
512 | - $custom = 'custom/metadata/audit_templateMetaData_' . $this->getTableName() . '.php'; |
|
512 | + $custom = 'custom/metadata/audit_templateMetaData_'.$this->getTableName().'.php'; |
|
513 | 513 | if (file_exists($custom)) |
514 | 514 | { |
515 | 515 | require($custom); |
@@ -519,14 +519,14 @@ discard block |
||
519 | 519 | $indices = $dictionary['audit']['indices']; |
520 | 520 | |
521 | 521 | // Renaming template indexes to fit the particular audit table (removed the brittle hard coding) |
522 | - foreach($indices as $nr => $properties){ |
|
523 | - $indices[$nr]['name'] = 'idx_' . strtolower($this->getTableName()) . '_' . $properties['name']; |
|
522 | + foreach ($indices as $nr => $properties) { |
|
523 | + $indices[$nr]['name'] = 'idx_'.strtolower($this->getTableName()).'_'.$properties['name']; |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | $engine = null; |
527 | - if(isset($dictionary['audit']['engine'])) { |
|
527 | + if (isset($dictionary['audit']['engine'])) { |
|
528 | 528 | $engine = $dictionary['audit']['engine']; |
529 | - } else if(isset($dictionary[$this->getObjectName()]['engine'])) { |
|
529 | + } else if (isset($dictionary[$this->getObjectName()]['engine'])) { |
|
530 | 530 | $engine = $dictionary[$this->getObjectName()]['engine']; |
531 | 531 | } |
532 | 532 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | */ |
546 | 546 | public function getTableName() |
547 | 547 | { |
548 | - if(isset($this->table_name)) |
|
548 | + if (isset($this->table_name)) |
|
549 | 549 | { |
550 | 550 | return $this->table_name; |
551 | 551 | } |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | function getIndices() |
580 | 580 | { |
581 | 581 | global $dictionary; |
582 | - if(isset($dictionary[$this->getObjectName()]['indices'])) |
|
582 | + if (isset($dictionary[$this->getObjectName()]['indices'])) |
|
583 | 583 | { |
584 | 584 | return $dictionary[$this->getObjectName()]['indices']; |
585 | 585 | } |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | */ |
599 | 599 | function getFieldDefinition($name) |
600 | 600 | { |
601 | - if ( !isset($this->field_defs[$name]) ) |
|
601 | + if (!isset($this->field_defs[$name])) |
|
602 | 602 | return false; |
603 | 603 | |
604 | 604 | return $this->field_defs[$name]; |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | function getPrimaryFieldDefinition() |
617 | 617 | { |
618 | 618 | $def = $this->getFieldDefinition("id"); |
619 | - if(empty($def)) { |
|
619 | + if (empty($def)) { |
|
620 | 620 | $def = $this->getFieldDefinition(0); |
621 | 621 | } |
622 | 622 | if (empty($def)) { |
@@ -639,13 +639,13 @@ discard block |
||
639 | 639 | */ |
640 | 640 | function getFieldValue($name) |
641 | 641 | { |
642 | - if (!isset($this->$name)){ |
|
642 | + if (!isset($this->$name)) { |
|
643 | 643 | return FALSE; |
644 | 644 | } |
645 | - if($this->$name === TRUE){ |
|
645 | + if ($this->$name === TRUE) { |
|
646 | 646 | return 1; |
647 | 647 | } |
648 | - if($this->$name === FALSE){ |
|
648 | + if ($this->$name === FALSE) { |
|
649 | 649 | return 0; |
650 | 650 | } |
651 | 651 | return $this->$name; |
@@ -657,17 +657,17 @@ discard block |
||
657 | 657 | */ |
658 | 658 | public function unPopulateDefaultValues() |
659 | 659 | { |
660 | - if ( !is_array($this->field_defs) ) |
|
660 | + if (!is_array($this->field_defs)) |
|
661 | 661 | return; |
662 | 662 | |
663 | 663 | foreach ($this->field_defs as $field => $value) { |
664 | - if( !empty($this->$field) |
|
664 | + if (!empty($this->$field) |
|
665 | 665 | && ((isset($value['default']) && $this->$field == $value['default']) || (!empty($value['display_default']) && $this->$field == $value['display_default'])) |
666 | 666 | ) { |
667 | 667 | $this->$field = null; |
668 | 668 | continue; |
669 | 669 | } |
670 | - if(!empty($this->$field) && !empty($value['display_default']) && in_array($value['type'], array('date', 'datetime', 'datetimecombo')) && |
|
670 | + if (!empty($this->$field) && !empty($value['display_default']) && in_array($value['type'], array('date', 'datetime', 'datetimecombo')) && |
|
671 | 671 | $this->$field == $this->parseDateDefault($value['display_default'], ($value['type'] != 'date'))) { |
672 | 672 | $this->$field = null; |
673 | 673 | } |
@@ -684,10 +684,10 @@ discard block |
||
684 | 684 | protected function parseDateDefault($value, $time = false) |
685 | 685 | { |
686 | 686 | global $timedate; |
687 | - if($time) { |
|
687 | + if ($time) { |
|
688 | 688 | $dtAry = explode('&', $value, 2); |
689 | 689 | $dateValue = $timedate->getNow(true)->modify($dtAry[0]); |
690 | - if(!empty($dtAry[1])) { |
|
690 | + if (!empty($dtAry[1])) { |
|
691 | 691 | $timeValue = $timedate->fromString($dtAry[1]); |
692 | 692 | $dateValue->setTime($timeValue->hour, $timeValue->min, $timeValue->sec); |
693 | 693 | } |
@@ -697,37 +697,37 @@ discard block |
||
697 | 697 | } |
698 | 698 | } |
699 | 699 | |
700 | - function populateDefaultValues($force=false){ |
|
701 | - if ( !is_array($this->field_defs) ) |
|
700 | + function populateDefaultValues($force = false) { |
|
701 | + if (!is_array($this->field_defs)) |
|
702 | 702 | return; |
703 | - foreach($this->field_defs as $field=>$value){ |
|
704 | - if((isset($value['default']) || !empty($value['display_default'])) && ($force || empty($this->$field))){ |
|
703 | + foreach ($this->field_defs as $field=>$value) { |
|
704 | + if ((isset($value['default']) || !empty($value['display_default'])) && ($force || empty($this->$field))) { |
|
705 | 705 | $type = $value['type']; |
706 | 706 | |
707 | - switch($type){ |
|
707 | + switch ($type) { |
|
708 | 708 | case 'date': |
709 | - if(!empty($value['display_default'])){ |
|
709 | + if (!empty($value['display_default'])) { |
|
710 | 710 | $this->$field = $this->parseDateDefault($value['display_default']); |
711 | 711 | } |
712 | 712 | break; |
713 | 713 | case 'datetime': |
714 | 714 | case 'datetimecombo': |
715 | - if(!empty($value['display_default'])){ |
|
715 | + if (!empty($value['display_default'])) { |
|
716 | 716 | $this->$field = $this->parseDateDefault($value['display_default'], true); |
717 | 717 | } |
718 | 718 | break; |
719 | 719 | case 'multienum': |
720 | - if(empty($value['default']) && !empty($value['display_default'])) |
|
720 | + if (empty($value['default']) && !empty($value['display_default'])) |
|
721 | 721 | $this->$field = $value['display_default']; |
722 | 722 | else |
723 | 723 | $this->$field = $value['default']; |
724 | 724 | break; |
725 | 725 | case 'bool': |
726 | - if(isset($this->$field)){ |
|
726 | + if (isset($this->$field)) { |
|
727 | 727 | break; |
728 | 728 | } |
729 | 729 | default: |
730 | - if ( isset($value['default']) && $value['default'] !== '' ) { |
|
730 | + if (isset($value['default']) && $value['default'] !== '') { |
|
731 | 731 | $this->$field = htmlentities($value['default'], ENT_QUOTES, 'UTF-8'); |
732 | 732 | } else { |
733 | 733 | $this->$field = ''; |
@@ -755,20 +755,20 @@ discard block |
||
755 | 755 | * |
756 | 756 | * Internal function, do not override. |
757 | 757 | */ |
758 | - static function removeRelationshipMeta($key,$db,$tablename,$dictionary,$module_dir) |
|
758 | + static function removeRelationshipMeta($key, $db, $tablename, $dictionary, $module_dir) |
|
759 | 759 | { |
760 | 760 | //load the module dictionary if not supplied. |
761 | 761 | if ((!isset($dictionary) or empty($dictionary)) && !empty($module_dir)) |
762 | 762 | { |
763 | - $filename='modules/'. $module_dir . '/vardefs.php'; |
|
764 | - if(file_exists($filename)) |
|
763 | + $filename = 'modules/'.$module_dir.'/vardefs.php'; |
|
764 | + if (file_exists($filename)) |
|
765 | 765 | { |
766 | 766 | include($filename); |
767 | 767 | } |
768 | 768 | } |
769 | 769 | if (!is_array($dictionary) or !array_key_exists($key, $dictionary)) |
770 | 770 | { |
771 | - $GLOBALS['log']->fatal("removeRelationshipMeta: Metadata for table ".$tablename. " does not exist"); |
|
771 | + $GLOBALS['log']->fatal("removeRelationshipMeta: Metadata for table ".$tablename." does not exist"); |
|
772 | 772 | display_notice("meta data absent for table ".$tablename." keyed to $key "); |
773 | 773 | } |
774 | 774 | else |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | $RelationshipDefs = $dictionary[$key]['relationships']; |
779 | 779 | foreach ($RelationshipDefs as $rel_name) |
780 | 780 | { |
781 | - Relationship::delete($rel_name,$db); |
|
781 | + Relationship::delete($rel_name, $db); |
|
782 | 782 | } |
783 | 783 | } |
784 | 784 | } |
@@ -792,9 +792,9 @@ discard block |
||
792 | 792 | * @deprecated 4.5.1 - Nov 14, 2006 |
793 | 793 | * @static |
794 | 794 | */ |
795 | - static function remove_relationship_meta($key,$db,$log,$tablename,$dictionary,$module_dir) |
|
795 | + static function remove_relationship_meta($key, $db, $log, $tablename, $dictionary, $module_dir) |
|
796 | 796 | { |
797 | - SugarBean::removeRelationshipMeta($key,$db,$tablename,$dictionary,$module_dir); |
|
797 | + SugarBean::removeRelationshipMeta($key, $db, $tablename, $dictionary, $module_dir); |
|
798 | 798 | } |
799 | 799 | |
800 | 800 | |
@@ -813,14 +813,14 @@ discard block |
||
813 | 813 | * |
814 | 814 | * Internal function, do not override. |
815 | 815 | */ |
816 | - static function createRelationshipMeta($key,$db,$tablename,$dictionary,$module_dir,$iscustom=false) |
|
816 | + static function createRelationshipMeta($key, $db, $tablename, $dictionary, $module_dir, $iscustom = false) |
|
817 | 817 | { |
818 | 818 | //load the module dictionary if not supplied. |
819 | 819 | if (empty($dictionary) && !empty($module_dir)) |
820 | 820 | { |
821 | - if($iscustom) |
|
821 | + if ($iscustom) |
|
822 | 822 | { |
823 | - $filename='custom/modules/' . $module_dir . '/Ext/Vardefs/vardefs.ext.php'; |
|
823 | + $filename = 'custom/modules/'.$module_dir.'/Ext/Vardefs/vardefs.ext.php'; |
|
824 | 824 | } |
825 | 825 | else |
826 | 826 | { |
@@ -829,33 +829,33 @@ discard block |
||
829 | 829 | // a very special case for the Employees module |
830 | 830 | // this must be done because the Employees/vardefs.php does an include_once on |
831 | 831 | // Users/vardefs.php |
832 | - $filename='modules/Users/vardefs.php'; |
|
832 | + $filename = 'modules/Users/vardefs.php'; |
|
833 | 833 | } |
834 | 834 | else |
835 | 835 | { |
836 | - $filename='modules/'. $module_dir . '/vardefs.php'; |
|
836 | + $filename = 'modules/'.$module_dir.'/vardefs.php'; |
|
837 | 837 | } |
838 | 838 | } |
839 | 839 | |
840 | - if(file_exists($filename)) |
|
840 | + if (file_exists($filename)) |
|
841 | 841 | { |
842 | 842 | include($filename); |
843 | 843 | // cn: bug 7679 - dictionary entries defined as $GLOBALS['name'] not found |
844 | - if(empty($dictionary) || !empty($GLOBALS['dictionary'][$key])) |
|
844 | + if (empty($dictionary) || !empty($GLOBALS['dictionary'][$key])) |
|
845 | 845 | { |
846 | 846 | $dictionary = $GLOBALS['dictionary']; |
847 | 847 | } |
848 | 848 | } |
849 | 849 | else |
850 | 850 | { |
851 | - $GLOBALS['log']->debug("createRelationshipMeta: no metadata file found" . $filename); |
|
851 | + $GLOBALS['log']->debug("createRelationshipMeta: no metadata file found".$filename); |
|
852 | 852 | return; |
853 | 853 | } |
854 | 854 | } |
855 | 855 | |
856 | 856 | if (!is_array($dictionary) or !array_key_exists($key, $dictionary)) |
857 | 857 | { |
858 | - $GLOBALS['log']->fatal("createRelationshipMeta: Metadata for table ".$tablename. " does not exist"); |
|
858 | + $GLOBALS['log']->fatal("createRelationshipMeta: Metadata for table ".$tablename." does not exist"); |
|
859 | 859 | display_notice("meta data absent for table ".$tablename." keyed to $key "); |
860 | 860 | } |
861 | 861 | else |
@@ -865,23 +865,23 @@ discard block |
||
865 | 865 | |
866 | 866 | $RelationshipDefs = $dictionary[$key]['relationships']; |
867 | 867 | |
868 | - $delimiter=','; |
|
868 | + $delimiter = ','; |
|
869 | 869 | global $beanList; |
870 | - $beanList_ucase=array_change_key_case ( $beanList ,CASE_UPPER); |
|
870 | + $beanList_ucase = array_change_key_case($beanList, CASE_UPPER); |
|
871 | 871 | foreach ($RelationshipDefs as $rel_name=>$rel_def) |
872 | 872 | { |
873 | 873 | if (isset($rel_def['lhs_module']) and !isset($beanList_ucase[strtoupper($rel_def['lhs_module'])])) { |
874 | - $GLOBALS['log']->debug('skipping orphaned relationship record ' . $rel_name . ' lhs module is missing ' . $rel_def['lhs_module']); |
|
874 | + $GLOBALS['log']->debug('skipping orphaned relationship record '.$rel_name.' lhs module is missing '.$rel_def['lhs_module']); |
|
875 | 875 | continue; |
876 | 876 | } |
877 | 877 | if (isset($rel_def['rhs_module']) and !isset($beanList_ucase[strtoupper($rel_def['rhs_module'])])) { |
878 | - $GLOBALS['log']->debug('skipping orphaned relationship record ' . $rel_name . ' rhs module is missing ' . $rel_def['rhs_module']); |
|
878 | + $GLOBALS['log']->debug('skipping orphaned relationship record '.$rel_name.' rhs module is missing '.$rel_def['rhs_module']); |
|
879 | 879 | continue; |
880 | 880 | } |
881 | 881 | |
882 | 882 | |
883 | 883 | //check whether relationship exists or not first. |
884 | - if (Relationship::exists($rel_name,$db)) |
|
884 | + if (Relationship::exists($rel_name, $db)) |
|
885 | 885 | { |
886 | 886 | $GLOBALS['log']->debug('Skipping, reltionship already exists '.$rel_name); |
887 | 887 | } |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | $seed = BeanFactory::getBean("Relationships"); |
891 | 891 | $keys = array_keys($seed->field_defs); |
892 | 892 | $toInsert = array(); |
893 | - foreach($keys as $key) |
|
893 | + foreach ($keys as $key) |
|
894 | 894 | { |
895 | 895 | if ($key == "id") |
896 | 896 | { |
@@ -909,10 +909,10 @@ discard block |
||
909 | 909 | |
910 | 910 | |
911 | 911 | $column_list = implode(",", array_keys($toInsert)); |
912 | - $value_list = "'" . implode("','", array_values($toInsert)) . "'"; |
|
912 | + $value_list = "'".implode("','", array_values($toInsert))."'"; |
|
913 | 913 | |
914 | 914 | //create the record. todo add error check. |
915 | - $insert_string = "INSERT into relationships (" .$column_list. ") values (".$value_list.")"; |
|
915 | + $insert_string = "INSERT into relationships (".$column_list.") values (".$value_list.")"; |
|
916 | 916 | $db->query($insert_string, true); |
917 | 917 | } |
918 | 918 | } |
@@ -931,9 +931,9 @@ discard block |
||
931 | 931 | * @deprecated 4.5.1 - Nov 14, 2006 |
932 | 932 | * @static |
933 | 933 | */ |
934 | - static function create_relationship_meta($key,&$db,&$log,$tablename,$dictionary,$module_dir) |
|
934 | + static function create_relationship_meta($key, &$db, &$log, $tablename, $dictionary, $module_dir) |
|
935 | 935 | { |
936 | - SugarBean::createRelationshipMeta($key,$db,$tablename,$dictionary,$module_dir); |
|
936 | + SugarBean::createRelationshipMeta($key, $db, $tablename, $dictionary, $module_dir); |
|
937 | 937 | } |
938 | 938 | |
939 | 939 | |
@@ -946,8 +946,8 @@ discard block |
||
946 | 946 | */ |
947 | 947 | public function __clone() |
948 | 948 | { |
949 | - if(!empty($this->loaded_relationships)) { |
|
950 | - foreach($this->loaded_relationships as $rel) { |
|
949 | + if (!empty($this->loaded_relationships)) { |
|
950 | + foreach ($this->loaded_relationships as $rel) { |
|
951 | 951 | unset($this->$rel); |
952 | 952 | } |
953 | 953 | } |
@@ -1021,8 +1021,8 @@ discard block |
||
1021 | 1021 | function load_relationships() |
1022 | 1022 | { |
1023 | 1023 | $GLOBALS['log']->debug("SugarBean.load_relationships, Loading all relationships of type link."); |
1024 | - $linked_fields=$this->get_linked_fields(); |
|
1025 | - foreach($linked_fields as $name=>$properties) |
|
1024 | + $linked_fields = $this->get_linked_fields(); |
|
1025 | + foreach ($linked_fields as $name=>$properties) |
|
1026 | 1026 | { |
1027 | 1027 | $this->load_relationship($name); |
1028 | 1028 | } |
@@ -1045,13 +1045,13 @@ discard block |
||
1045 | 1045 | * |
1046 | 1046 | * Internal function, do not override. |
1047 | 1047 | */ |
1048 | - function get_linked_beans($field_name,$bean_name = '', $order_by = '', $begin_index = 0, $end_index = -1, $deleted=0, $optional_where="") |
|
1048 | + function get_linked_beans($field_name, $bean_name = '', $order_by = '', $begin_index = 0, $end_index = -1, $deleted = 0, $optional_where = "") |
|
1049 | 1049 | { |
1050 | 1050 | //if bean_name is Case then use aCase |
1051 | - if($bean_name=="Case") |
|
1051 | + if ($bean_name == "Case") |
|
1052 | 1052 | $bean_name = "aCase"; |
1053 | 1053 | |
1054 | - if($this->load_relationship($field_name)) { |
|
1054 | + if ($this->load_relationship($field_name)) { |
|
1055 | 1055 | if ($this->$field_name instanceof Link) { |
1056 | 1056 | // some classes are still based on Link, e.g. TeamSetLink |
1057 | 1057 | return array_values($this->$field_name->getBeans(new $bean_name(), $order_by, $begin_index, $end_index, $deleted, $optional_where)); |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | function get_linked_fields() |
1083 | 1083 | { |
1084 | 1084 | |
1085 | - $linked_fields=array(); |
|
1085 | + $linked_fields = array(); |
|
1086 | 1086 | |
1087 | 1087 | // require_once('data/Link.php'); |
1088 | 1088 | |
@@ -1093,9 +1093,9 @@ discard block |
||
1093 | 1093 | { |
1094 | 1094 | foreach ($fieldDefs as $name=>$properties) |
1095 | 1095 | { |
1096 | - if (array_search('link',$properties) === 'type') |
|
1096 | + if (array_search('link', $properties) === 'type') |
|
1097 | 1097 | { |
1098 | - $linked_fields[$name]=$properties; |
|
1098 | + $linked_fields[$name] = $properties; |
|
1099 | 1099 | } |
1100 | 1100 | } |
1101 | 1101 | } |
@@ -1115,38 +1115,38 @@ discard block |
||
1115 | 1115 | { |
1116 | 1116 | $importableFields = array(); |
1117 | 1117 | |
1118 | - $fieldDefs= $this->getFieldDefinitions(); |
|
1118 | + $fieldDefs = $this->getFieldDefinitions(); |
|
1119 | 1119 | |
1120 | 1120 | if (!empty($fieldDefs)) { |
1121 | 1121 | foreach ($fieldDefs as $key=>$value_array) { |
1122 | - if ( (isset($value_array['importable']) |
|
1122 | + if ((isset($value_array['importable']) |
|
1123 | 1123 | && (is_string($value_array['importable']) && $value_array['importable'] == 'false' |
1124 | 1124 | || is_bool($value_array['importable']) && $value_array['importable'] == false)) |
1125 | 1125 | || (isset($value_array['type']) && $value_array['type'] == 'link') |
1126 | 1126 | || (isset($value_array['auto_increment']) |
1127 | - && ($value_array['type'] == true || $value_array['type'] == 'true')) ) { |
|
1127 | + && ($value_array['type'] == true || $value_array['type'] == 'true'))) { |
|
1128 | 1128 | // only allow import if we force it |
1129 | 1129 | if (isset($value_array['importable']) |
1130 | 1130 | && (is_string($value_array['importable']) && $value_array['importable'] == 'true' |
1131 | 1131 | || is_bool($value_array['importable']) && $value_array['importable'] == true)) { |
1132 | - $importableFields[$key]=$value_array; |
|
1132 | + $importableFields[$key] = $value_array; |
|
1133 | 1133 | } |
1134 | 1134 | } |
1135 | 1135 | else { |
1136 | 1136 | |
1137 | 1137 | //Expose the cooresponding id field of a relate field if it is only defined as a link so that users can relate records by id during import |
1138 | - if( isset($value_array['type']) && ($value_array['type'] == 'relate') && isset($value_array['id_name']) ) |
|
1138 | + if (isset($value_array['type']) && ($value_array['type'] == 'relate') && isset($value_array['id_name'])) |
|
1139 | 1139 | { |
1140 | 1140 | $idField = $value_array['id_name']; |
1141 | - if( isset($fieldDefs[$idField]) && isset($fieldDefs[$idField]['type'] ) && $fieldDefs[$idField]['type'] == 'link' ) |
|
1141 | + if (isset($fieldDefs[$idField]) && isset($fieldDefs[$idField]['type']) && $fieldDefs[$idField]['type'] == 'link') |
|
1142 | 1142 | { |
1143 | 1143 | $tmpFieldDefs = $fieldDefs[$idField]; |
1144 | - $tmpFieldDefs['vname'] = translate($value_array['vname'], $this->module_dir) . " " . $GLOBALS['app_strings']['LBL_ID']; |
|
1145 | - $importableFields[$idField]=$tmpFieldDefs; |
|
1144 | + $tmpFieldDefs['vname'] = translate($value_array['vname'], $this->module_dir)." ".$GLOBALS['app_strings']['LBL_ID']; |
|
1145 | + $importableFields[$idField] = $tmpFieldDefs; |
|
1146 | 1146 | } |
1147 | 1147 | } |
1148 | 1148 | |
1149 | - $importableFields[$key]=$value_array; |
|
1149 | + $importableFields[$key] = $value_array; |
|
1150 | 1150 | } |
1151 | 1151 | } |
1152 | 1152 | } |
@@ -1164,7 +1164,7 @@ discard block |
||
1164 | 1164 | function get_related_fields() |
1165 | 1165 | { |
1166 | 1166 | |
1167 | - $related_fields=array(); |
|
1167 | + $related_fields = array(); |
|
1168 | 1168 | |
1169 | 1169 | // require_once('data/Link.php'); |
1170 | 1170 | |
@@ -1175,9 +1175,9 @@ discard block |
||
1175 | 1175 | { |
1176 | 1176 | foreach ($fieldDefs as $name=>$properties) |
1177 | 1177 | { |
1178 | - if (array_search('relate',$properties) === 'type') |
|
1178 | + if (array_search('relate', $properties) === 'type') |
|
1179 | 1179 | { |
1180 | - $related_fields[$name]=$properties; |
|
1180 | + $related_fields[$name] = $properties; |
|
1181 | 1181 | } |
1182 | 1182 | } |
1183 | 1183 | } |
@@ -1195,8 +1195,8 @@ discard block |
||
1195 | 1195 | $importable_fields = $this->get_importable_fields(); |
1196 | 1196 | $required_fields = array(); |
1197 | 1197 | |
1198 | - foreach ( $importable_fields as $name => $properties ) { |
|
1199 | - if ( isset($properties['importable']) && is_string($properties['importable']) && $properties['importable'] == 'required' ) { |
|
1198 | + foreach ($importable_fields as $name => $properties) { |
|
1199 | + if (isset($properties['importable']) && is_string($properties['importable']) && $properties['importable'] == 'required') { |
|
1200 | 1200 | $required_fields[$name] = $properties; |
1201 | 1201 | } |
1202 | 1202 | } |
@@ -1211,7 +1211,7 @@ discard block |
||
1211 | 1211 | */ |
1212 | 1212 | function delete_linked($id) |
1213 | 1213 | { |
1214 | - $linked_fields=$this->get_linked_fields(); |
|
1214 | + $linked_fields = $this->get_linked_fields(); |
|
1215 | 1215 | foreach ($linked_fields as $name => $value) |
1216 | 1216 | { |
1217 | 1217 | if ($this->load_relationship($name)) |
@@ -1237,18 +1237,18 @@ discard block |
||
1237 | 1237 | $key = $this->getObjectName(); |
1238 | 1238 | if (!array_key_exists($key, $dictionary)) |
1239 | 1239 | { |
1240 | - $GLOBALS['log']->fatal("create_tables: Metadata for table ".$this->table_name. " does not exist"); |
|
1240 | + $GLOBALS['log']->fatal("create_tables: Metadata for table ".$this->table_name." does not exist"); |
|
1241 | 1241 | display_notice("meta data absent for table ".$this->table_name." keyed to $key "); |
1242 | 1242 | } |
1243 | 1243 | else |
1244 | 1244 | { |
1245 | - if(!$this->db->tableExists($this->table_name)) |
|
1245 | + if (!$this->db->tableExists($this->table_name)) |
|
1246 | 1246 | { |
1247 | 1247 | $this->db->createTable($this); |
1248 | - if($this->bean_implements('ACL')){ |
|
1249 | - if(!empty($this->acltype)){ |
|
1248 | + if ($this->bean_implements('ACL')) { |
|
1249 | + if (!empty($this->acltype)) { |
|
1250 | 1250 | ACLAction::addActions($this->getACLCategory(), $this->acltype); |
1251 | - }else{ |
|
1251 | + } else { |
|
1252 | 1252 | ACLAction::addActions($this->getACLCategory()); |
1253 | 1253 | } |
1254 | 1254 | } |
@@ -1257,7 +1257,7 @@ discard block |
||
1257 | 1257 | { |
1258 | 1258 | echo "Table already exists : $this->table_name<br>"; |
1259 | 1259 | } |
1260 | - if($this->is_AuditEnabled()){ |
|
1260 | + if ($this->is_AuditEnabled()) { |
|
1261 | 1261 | if (!$this->db->tableExists($this->get_audit_table_name())) { |
1262 | 1262 | $this->create_audit_table(); |
1263 | 1263 | } |
@@ -1278,16 +1278,16 @@ discard block |
||
1278 | 1278 | $key = $this->getObjectName(); |
1279 | 1279 | if (!array_key_exists($key, $dictionary)) |
1280 | 1280 | { |
1281 | - $GLOBALS['log']->fatal("drop_tables: Metadata for table ".$this->table_name. " does not exist"); |
|
1281 | + $GLOBALS['log']->fatal("drop_tables: Metadata for table ".$this->table_name." does not exist"); |
|
1282 | 1282 | echo "meta data absent for table ".$this->table_name."<br>\n"; |
1283 | 1283 | } else { |
1284 | - if(empty($this->table_name))return; |
|
1284 | + if (empty($this->table_name))return; |
|
1285 | 1285 | if ($this->db->tableExists($this->table_name)) |
1286 | 1286 | |
1287 | 1287 | $this->db->dropTable($this); |
1288 | - if ($this->db->tableExists($this->table_name. '_cstm')) |
|
1288 | + if ($this->db->tableExists($this->table_name.'_cstm')) |
|
1289 | 1289 | { |
1290 | - $this->db->dropTableName($this->table_name. '_cstm'); |
|
1290 | + $this->db->dropTableName($this->table_name.'_cstm'); |
|
1291 | 1291 | DynamicField::deleteCache(); |
1292 | 1292 | } |
1293 | 1293 | if ($this->db->tableExists($this->get_audit_table_name())) { |
@@ -1306,7 +1306,7 @@ discard block |
||
1306 | 1306 | * @param string $module_name setting up custom fields for this module. |
1307 | 1307 | * @param boolean $clean_load Optional, default true, rebuilds the cache if set to true. |
1308 | 1308 | */ |
1309 | - function setupCustomFields($module_name, $clean_load=true) |
|
1309 | + function setupCustomFields($module_name, $clean_load = true) |
|
1310 | 1310 | { |
1311 | 1311 | $this->custom_fields = new DynamicField($module_name); |
1312 | 1312 | $this->custom_fields->setup($this); |
@@ -1317,17 +1317,17 @@ discard block |
||
1317 | 1317 | * Cleans char, varchar, text, etc. fields of XSS type materials |
1318 | 1318 | */ |
1319 | 1319 | function cleanBean() { |
1320 | - foreach($this->field_defs as $key => $def) { |
|
1320 | + foreach ($this->field_defs as $key => $def) { |
|
1321 | 1321 | |
1322 | 1322 | if (isset($def['type'])) { |
1323 | - $type=$def['type']; |
|
1323 | + $type = $def['type']; |
|
1324 | 1324 | } |
1325 | - if(isset($def['dbType'])) |
|
1325 | + if (isset($def['dbType'])) |
|
1326 | 1326 | $type .= $def['dbType']; |
1327 | 1327 | |
1328 | - if($def['type'] == 'html' || $def['type'] == 'longhtml') { |
|
1328 | + if ($def['type'] == 'html' || $def['type'] == 'longhtml') { |
|
1329 | 1329 | $this->$key = SugarCleaner::cleanHtml($this->$key, true); |
1330 | - } elseif((strpos($type, 'char') !== false || |
|
1330 | + } elseif ((strpos($type, 'char') !== false || |
|
1331 | 1331 | strpos($type, 'text') !== false || |
1332 | 1332 | $type == 'enum') && |
1333 | 1333 | !empty($this->$key) |
@@ -1357,24 +1357,24 @@ discard block |
||
1357 | 1357 | global $current_user, $action; |
1358 | 1358 | |
1359 | 1359 | $isUpdate = true; |
1360 | - if(empty($this->id)) |
|
1360 | + if (empty($this->id)) |
|
1361 | 1361 | { |
1362 | 1362 | $isUpdate = false; |
1363 | 1363 | } |
1364 | 1364 | |
1365 | - if ( $this->new_with_id == true ) |
|
1365 | + if ($this->new_with_id == true) |
|
1366 | 1366 | { |
1367 | 1367 | $isUpdate = false; |
1368 | 1368 | } |
1369 | - if(empty($this->date_modified) || $this->update_date_modified) |
|
1369 | + if (empty($this->date_modified) || $this->update_date_modified) |
|
1370 | 1370 | { |
1371 | 1371 | $this->date_modified = $GLOBALS['timedate']->nowDb(); |
1372 | 1372 | } |
1373 | 1373 | |
1374 | 1374 | $this->_checkOptimisticLocking($action, $isUpdate); |
1375 | 1375 | |
1376 | - if(!empty($this->modified_by_name)) $this->old_modified_by_name = $this->modified_by_name; |
|
1377 | - if($this->update_modified_by) |
|
1376 | + if (!empty($this->modified_by_name)) $this->old_modified_by_name = $this->modified_by_name; |
|
1377 | + if ($this->update_modified_by) |
|
1378 | 1378 | { |
1379 | 1379 | $this->modified_user_id = 1; |
1380 | 1380 | |
@@ -1386,18 +1386,18 @@ discard block |
||
1386 | 1386 | } |
1387 | 1387 | if ($this->deleted != 1) |
1388 | 1388 | $this->deleted = 0; |
1389 | - if(!$isUpdate) |
|
1389 | + if (!$isUpdate) |
|
1390 | 1390 | { |
1391 | 1391 | if (empty($this->date_entered)) |
1392 | 1392 | { |
1393 | 1393 | $this->date_entered = $this->date_modified; |
1394 | 1394 | } |
1395 | - if($this->set_created_by == true) |
|
1395 | + if ($this->set_created_by == true) |
|
1396 | 1396 | { |
1397 | 1397 | // created by should always be this user |
1398 | 1398 | $this->created_by = (isset($current_user)) ? $current_user->id : ""; |
1399 | 1399 | } |
1400 | - if( $this->new_with_id == false) |
|
1400 | + if ($this->new_with_id == false) |
|
1401 | 1401 | { |
1402 | 1402 | $this->id = create_guid(); |
1403 | 1403 | } |
@@ -1415,7 +1415,7 @@ discard block |
||
1415 | 1415 | $this->save_relationship_changes($isUpdate); |
1416 | 1416 | $GLOBALS['saving_relationships'] = false; |
1417 | 1417 | } |
1418 | - if($isUpdate && !$this->update_date_entered) |
|
1418 | + if ($isUpdate && !$this->update_date_entered) |
|
1419 | 1419 | { |
1420 | 1420 | unset($this->date_entered); |
1421 | 1421 | } |
@@ -1437,7 +1437,7 @@ discard block |
||
1437 | 1437 | $this->emailAddress->save($this->id, $this->module_dir); |
1438 | 1438 | } |
1439 | 1439 | |
1440 | - if(isset($this->custom_fields)) |
|
1440 | + if (isset($this->custom_fields)) |
|
1441 | 1441 | { |
1442 | 1442 | $this->custom_fields->bean = $this; |
1443 | 1443 | $this->custom_fields->save($isUpdate); |
@@ -1447,12 +1447,12 @@ discard block |
||
1447 | 1447 | $this->preprocess_fields_on_save(); |
1448 | 1448 | |
1449 | 1449 | //construct the SQL to create the audit record if auditing is enabled. |
1450 | - $auditDataChanges=array(); |
|
1450 | + $auditDataChanges = array(); |
|
1451 | 1451 | if ($this->is_AuditEnabled()) { |
1452 | 1452 | if ($isUpdate && !isset($this->fetched_row)) { |
1453 | 1453 | $GLOBALS['log']->debug('Auditing: Retrieve was not called, audit record will not be created.'); |
1454 | 1454 | } else { |
1455 | - $auditDataChanges=$this->db->getAuditDataChanges($this); |
|
1455 | + $auditDataChanges = $this->db->getAuditDataChanges($this); |
|
1456 | 1456 | } |
1457 | 1457 | } |
1458 | 1458 | |
@@ -1468,12 +1468,12 @@ discard block |
||
1468 | 1468 | { |
1469 | 1469 | foreach ($auditDataChanges as $change) |
1470 | 1470 | { |
1471 | - $this->db->save_audit_records($this,$change); |
|
1471 | + $this->db->save_audit_records($this, $change); |
|
1472 | 1472 | } |
1473 | 1473 | } |
1474 | 1474 | |
1475 | 1475 | |
1476 | - if (empty($GLOBALS['resavingRelatedBeans'])){ |
|
1476 | + if (empty($GLOBALS['resavingRelatedBeans'])) { |
|
1477 | 1477 | SugarRelationship::resaveRelatedBeans(); |
1478 | 1478 | } |
1479 | 1479 | |
@@ -1485,10 +1485,10 @@ discard block |
||
1485 | 1485 | |
1486 | 1486 | /* BEGIN - SECURITY GROUPS - inheritance */ |
1487 | 1487 | require_once('modules/SecurityGroups/SecurityGroup.php'); |
1488 | - SecurityGroup::inherit($this,$isUpdate); |
|
1488 | + SecurityGroup::inherit($this, $isUpdate); |
|
1489 | 1489 | /* END - SECURITY GROUPS */ |
1490 | 1490 | //If we aren't in setup mode and we have a current user and module, then we track |
1491 | - if(isset($GLOBALS['current_user']) && isset($this->module_dir)) |
|
1491 | + if (isset($GLOBALS['current_user']) && isset($this->module_dir)) |
|
1492 | 1492 | { |
1493 | 1493 | $this->track_view($current_user->id, $this->module_dir, 'save'); |
1494 | 1494 | } |
@@ -1518,7 +1518,7 @@ discard block |
||
1518 | 1518 | AND (modified_user_id != '$modified_user_id' OR date_modified > $date)"; |
1519 | 1519 | $result = $this->db->query($query); |
1520 | 1520 | |
1521 | - if($this->db->fetchByAssoc($result)) |
|
1521 | + if ($this->db->fetchByAssoc($result)) |
|
1522 | 1522 | { |
1523 | 1523 | return true; |
1524 | 1524 | } |
@@ -1554,11 +1554,11 @@ discard block |
||
1554 | 1554 | { |
1555 | 1555 | global $current_user; |
1556 | 1556 | |
1557 | - if(($this->object_name == 'Meeting' || $this->object_name == 'Call') || $notify_user->receive_notifications) |
|
1557 | + if (($this->object_name == 'Meeting' || $this->object_name == 'Call') || $notify_user->receive_notifications) |
|
1558 | 1558 | { |
1559 | 1559 | $sendToEmail = $notify_user->emailAddress->getPrimaryAddress($notify_user); |
1560 | 1560 | $sendEmail = TRUE; |
1561 | - if(empty($sendToEmail)) { |
|
1561 | + if (empty($sendToEmail)) { |
|
1562 | 1562 | $GLOBALS['log']->warn("Notifications: no e-mail address set for user {$notify_user->user_name}, cancelling send"); |
1563 | 1563 | $sendEmail = FALSE; |
1564 | 1564 | } |
@@ -1566,7 +1566,7 @@ discard block |
||
1566 | 1566 | $notify_mail = $this->create_notification_email($notify_user); |
1567 | 1567 | $notify_mail->setMailerForSystem(); |
1568 | 1568 | |
1569 | - if(empty($admin->settings['notify_send_from_assigning_user'])) { |
|
1569 | + if (empty($admin->settings['notify_send_from_assigning_user'])) { |
|
1570 | 1570 | $notify_mail->From = $admin->settings['notify_fromaddress']; |
1571 | 1571 | $notify_mail->FromName = (empty($admin->settings['notify_fromname'])) ? "" : $admin->settings['notify_fromname']; |
1572 | 1572 | } else { |
@@ -1583,31 +1583,31 @@ discard block |
||
1583 | 1583 | $oe = new OutboundEmail(); |
1584 | 1584 | $oe = $oe->getUserMailerSettings($current_user); |
1585 | 1585 | //only send if smtp server is defined |
1586 | - if($sendEmail){ |
|
1586 | + if ($sendEmail) { |
|
1587 | 1587 | $smtpVerified = false; |
1588 | 1588 | |
1589 | 1589 | //first check the user settings |
1590 | - if(!empty($oe->mail_smtpserver)){ |
|
1590 | + if (!empty($oe->mail_smtpserver)) { |
|
1591 | 1591 | $smtpVerified = true; |
1592 | 1592 | } |
1593 | 1593 | |
1594 | 1594 | //if still not verified, check against the system settings |
1595 | - if (!$smtpVerified){ |
|
1595 | + if (!$smtpVerified) { |
|
1596 | 1596 | $oe = $oe->getSystemMailerSettings(); |
1597 | - if(!empty($oe->mail_smtpserver)){ |
|
1597 | + if (!empty($oe->mail_smtpserver)) { |
|
1598 | 1598 | $smtpVerified = true; |
1599 | 1599 | } |
1600 | 1600 | } |
1601 | 1601 | //if smtp was not verified against user or system, then do not send out email |
1602 | - if (!$smtpVerified){ |
|
1602 | + if (!$smtpVerified) { |
|
1603 | 1603 | $GLOBALS['log']->fatal("Notifications: error sending e-mail, smtp server was not found "); |
1604 | 1604 | //break out |
1605 | 1605 | return; |
1606 | 1606 | } |
1607 | 1607 | |
1608 | - if(!$notify_mail->Send()) { |
|
1608 | + if (!$notify_mail->Send()) { |
|
1609 | 1609 | $GLOBALS['log']->fatal("Notifications: error sending e-mail (method: {$notify_mail->Mailer}), (error: {$notify_mail->ErrorInfo})"); |
1610 | - }else{ |
|
1610 | + } else { |
|
1611 | 1611 | $GLOBALS['log']->info("Notifications: e-mail successfully sent"); |
1612 | 1612 | } |
1613 | 1613 | } |
@@ -1636,15 +1636,15 @@ discard block |
||
1636 | 1636 | $GLOBALS['log']->debug("Notifications: user has e-mail defined"); |
1637 | 1637 | |
1638 | 1638 | $notify_mail = new SugarPHPMailer(); |
1639 | - $notify_mail->AddAddress($notify_address,$locale->translateCharsetMIME(trim($notify_name), 'UTF-8', $OBCharset)); |
|
1639 | + $notify_mail->AddAddress($notify_address, $locale->translateCharsetMIME(trim($notify_name), 'UTF-8', $OBCharset)); |
|
1640 | 1640 | |
1641 | - if(empty($_SESSION['authenticated_user_language'])) { |
|
1641 | + if (empty($_SESSION['authenticated_user_language'])) { |
|
1642 | 1642 | $current_language = $sugar_config['default_language']; |
1643 | 1643 | } else { |
1644 | 1644 | $current_language = $_SESSION['authenticated_user_language']; |
1645 | 1645 | } |
1646 | 1646 | $xtpl = new XTemplate(get_notify_template_file($current_language)); |
1647 | - if($this->module_dir == "Cases") { |
|
1647 | + if ($this->module_dir == "Cases") { |
|
1648 | 1648 | $template_name = "Case"; //we should use Case, you can refer to the en_us.notify_template.html. |
1649 | 1649 | } |
1650 | 1650 | else { |
@@ -1653,23 +1653,23 @@ discard block |
||
1653 | 1653 | |
1654 | 1654 | $this->current_notify_user = $notify_user; |
1655 | 1655 | |
1656 | - if(in_array('set_notification_body', get_class_methods($this))) { |
|
1656 | + if (in_array('set_notification_body', get_class_methods($this))) { |
|
1657 | 1657 | $xtpl = $this->set_notification_body($xtpl, $this); |
1658 | 1658 | } else { |
1659 | 1659 | $xtpl->assign("OBJECT", translate('LBL_MODULE_NAME')); |
1660 | 1660 | $template_name = "Default"; |
1661 | 1661 | } |
1662 | - if(!empty($_SESSION["special_notification"]) && $_SESSION["special_notification"]) { |
|
1662 | + if (!empty($_SESSION["special_notification"]) && $_SESSION["special_notification"]) { |
|
1663 | 1663 | $template_name = $beanList[$this->module_dir].'Special'; |
1664 | 1664 | } |
1665 | - if($this->special_notification) { |
|
1665 | + if ($this->special_notification) { |
|
1666 | 1666 | $template_name = $beanList[$this->module_dir].'Special'; |
1667 | 1667 | } |
1668 | 1668 | $xtpl->assign("ASSIGNED_USER", $this->new_assigned_user_name); |
1669 | 1669 | $xtpl->assign("ASSIGNER", $current_user->name); |
1670 | 1670 | $port = ''; |
1671 | 1671 | |
1672 | - if(isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) { |
|
1672 | + if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) { |
|
1673 | 1673 | $port = $_SERVER['SERVER_PORT']; |
1674 | 1674 | } |
1675 | 1675 | |
@@ -1679,27 +1679,27 @@ discard block |
||
1679 | 1679 | |
1680 | 1680 | $httpHost = $_SERVER['HTTP_HOST']; |
1681 | 1681 | |
1682 | - if($colon = strpos($httpHost, ':')) { |
|
1683 | - $httpHost = substr($httpHost, 0, $colon); |
|
1682 | + if ($colon = strpos($httpHost, ':')) { |
|
1683 | + $httpHost = substr($httpHost, 0, $colon); |
|
1684 | 1684 | } |
1685 | 1685 | |
1686 | 1686 | $parsedSiteUrl = parse_url($sugar_config['site_url']); |
1687 | 1687 | $host = $parsedSiteUrl['host']; |
1688 | - if(!isset($parsedSiteUrl['port'])) { |
|
1688 | + if (!isset($parsedSiteUrl['port'])) { |
|
1689 | 1689 | $parsedSiteUrl['port'] = 80; |
1690 | 1690 | } |
1691 | 1691 | |
1692 | 1692 | $port = ($parsedSiteUrl['port'] != 80) ? ":".$parsedSiteUrl['port'] : ''; |
1693 | 1693 | $path = !empty($parsedSiteUrl['path']) ? $parsedSiteUrl['path'] : ""; |
1694 | - $cleanUrl = "{$parsedSiteUrl['scheme']}://{$host}{$port}{$path}"; |
|
1694 | + $cleanUrl = "{$parsedSiteUrl['scheme']}://{$host}{$port}{$path}"; |
|
1695 | 1695 | |
1696 | 1696 | $xtpl->assign("URL", $cleanUrl."/index.php?module={$this->module_dir}&action=DetailView&record={$this->id}"); |
1697 | 1697 | $xtpl->assign("SUGAR", "Sugar v{$sugar_version}"); |
1698 | 1698 | $xtpl->parse($template_name); |
1699 | - $xtpl->parse($template_name . "_Subject"); |
|
1699 | + $xtpl->parse($template_name."_Subject"); |
|
1700 | 1700 | |
1701 | 1701 | $notify_mail->Body = from_html(trim($xtpl->text($template_name))); |
1702 | - $notify_mail->Subject = from_html($xtpl->text($template_name . "_Subject")); |
|
1702 | + $notify_mail->Subject = from_html($xtpl->text($template_name."_Subject")); |
|
1703 | 1703 | |
1704 | 1704 | // cn: bug 8568 encode notify email in User's outbound email encoding |
1705 | 1705 | $notify_mail->prepForOutbound(); |
@@ -1762,7 +1762,7 @@ discard block |
||
1762 | 1762 | // $rel_id and $rel_link are not emty - request is from subpanel |
1763 | 1763 | // $rel_link contains relationship name - checked by call load_relationship |
1764 | 1764 | $isRelationshipLoaded = $this->load_relationship($rel_link); |
1765 | - if ($isRelationshipLoaded && !empty($this->$rel_link) && $this->$rel_link->getRelationshipObject() && $this->$rel_link->getRelationshipObject()->getLHSModule() == $this->$rel_link->getRelationshipObject()->getRHSModule() ) |
|
1765 | + if ($isRelationshipLoaded && !empty($this->$rel_link) && $this->$rel_link->getRelationshipObject() && $this->$rel_link->getRelationshipObject()->getLHSModule() == $this->$rel_link->getRelationshipObject()->getRHSModule()) |
|
1766 | 1766 | { |
1767 | 1767 | $new_rel_link = $this->$rel_link->getRelationshipObject()->getLHSLink(); |
1768 | 1768 | } |
@@ -1802,14 +1802,14 @@ discard block |
||
1802 | 1802 | |
1803 | 1803 | if (in_array($id, $exclude)) continue; |
1804 | 1804 | |
1805 | - if(!empty($this->$id)) |
|
1805 | + if (!empty($this->$id)) |
|
1806 | 1806 | { |
1807 | 1807 | // Bug #44930 We do not need to update main related field if it is changed from sub-panel. |
1808 | 1808 | if ($rel_name == $new_rel_link && $this->$id != $new_rel_id) |
1809 | 1809 | { |
1810 | 1810 | $new_rel_id = ''; |
1811 | 1811 | } |
1812 | - $GLOBALS['log']->debug('save_relationship_changes(): From relationship_field array - adding a relationship record: '.$rel_name . ' = ' . $this->$id); |
|
1812 | + $GLOBALS['log']->debug('save_relationship_changes(): From relationship_field array - adding a relationship record: '.$rel_name.' = '.$this->$id); |
|
1813 | 1813 | //already related the new relationship id so let's set it to false so we don't add it again using the _REQUEST['relate_i'] mechanism in a later block |
1814 | 1814 | $this->load_relationship($rel_name); |
1815 | 1815 | $rel_add = $this->$rel_name->add($this->$id); |
@@ -1820,7 +1820,7 @@ discard block |
||
1820 | 1820 | } else { |
1821 | 1821 | //if before value is not empty then attempt to delete relationship |
1822 | 1822 | if (!empty($this->rel_fields_before_value[$id])) { |
1823 | - $GLOBALS['log']->debug('save_relationship_changes(): From relationship_field array - attempting to remove the relationship record, using relationship attribute' . $rel_name); |
|
1823 | + $GLOBALS['log']->debug('save_relationship_changes(): From relationship_field array - attempting to remove the relationship record, using relationship attribute'.$rel_name); |
|
1824 | 1824 | $this->load_relationship($rel_name); |
1825 | 1825 | $this->$rel_name->delete($this->id, $this->rel_fields_before_value[$id]); |
1826 | 1826 | } |
@@ -1863,30 +1863,30 @@ discard block |
||
1863 | 1863 | |
1864 | 1864 | if (!empty($this->rel_fields_before_value[$idName]) && empty($this->$idName)) { |
1865 | 1865 | //if before value is not empty then attempt to delete relationship |
1866 | - $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - attempting to remove the relationship record: {$def [ 'link' ]} = {$this->rel_fields_before_value[$def [ 'id_name' ]]}"); |
|
1866 | + $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - attempting to remove the relationship record: {$def ['link']} = {$this->rel_fields_before_value[$def ['id_name']]}"); |
|
1867 | 1867 | $success = $this->$def ['link']->delete($this->id, $this->rel_fields_before_value[$def ['id_name']]); |
1868 | 1868 | // just need to make sure it's true and not an array as it's possible to return an array |
1869 | - if($success == true) { |
|
1869 | + if ($success == true) { |
|
1870 | 1870 | $modified_relationships['remove']['success'][] = $def['link']; |
1871 | 1871 | } else { |
1872 | 1872 | $modified_relationships['remove']['failure'][] = $def['link']; |
1873 | 1873 | } |
1874 | - $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - attempting to remove the relationship record returned " . var_export($success, true)); |
|
1874 | + $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - attempting to remove the relationship record returned ".var_export($success, true)); |
|
1875 | 1875 | } |
1876 | 1876 | |
1877 | 1877 | if (!empty($this->$idName) && is_string($this->$idName)) { |
1878 | - $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - attempting to add a relationship record - {$def [ 'link' ]} = {$this->$def [ 'id_name' ]}"); |
|
1878 | + $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - attempting to add a relationship record - {$def ['link']} = {$this->$def ['id_name']}"); |
|
1879 | 1879 | |
1880 | 1880 | $success = $this->$linkField->add($this->$idName); |
1881 | 1881 | |
1882 | 1882 | // just need to make sure it's true and not an array as it's possible to return an array |
1883 | - if($success == true) { |
|
1883 | + if ($success == true) { |
|
1884 | 1884 | $modified_relationships['add']['success'][] = $linkField; |
1885 | 1885 | } else { |
1886 | 1886 | $modified_relationships['add']['failure'][] = $linkField; |
1887 | 1887 | } |
1888 | 1888 | |
1889 | - $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - add a relationship record returned " . var_export($success, true)); |
|
1889 | + $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - add a relationship record returned ".var_export($success, true)); |
|
1890 | 1890 | } |
1891 | 1891 | } else { |
1892 | 1892 | $GLOBALS['log']->fatal("Failed to load relationship {$linkField} while saving {$this->module_dir}"); |
@@ -2040,48 +2040,48 @@ discard block |
||
2040 | 2040 | global $disable_date_format; |
2041 | 2041 | global $timedate; |
2042 | 2042 | if (empty($timedate)) |
2043 | - $timedate=TimeDate::getInstance(); |
|
2043 | + $timedate = TimeDate::getInstance(); |
|
2044 | 2044 | |
2045 | - if(empty($this->field_defs)) |
|
2045 | + if (empty($this->field_defs)) |
|
2046 | 2046 | { |
2047 | 2047 | return; |
2048 | 2048 | } |
2049 | - foreach($this->field_defs as $fieldDef) |
|
2049 | + foreach ($this->field_defs as $fieldDef) |
|
2050 | 2050 | { |
2051 | 2051 | $field = $fieldDef['name']; |
2052 | - if(!isset($this->processed_dates_times[$field])) |
|
2052 | + if (!isset($this->processed_dates_times[$field])) |
|
2053 | 2053 | { |
2054 | 2054 | $this->processed_dates_times[$field] = '1'; |
2055 | - if(empty($this->$field)) continue; |
|
2056 | - if($field == 'date_modified' || $field == 'date_entered') |
|
2055 | + if (empty($this->$field)) continue; |
|
2056 | + if ($field == 'date_modified' || $field == 'date_entered') |
|
2057 | 2057 | { |
2058 | 2058 | $this->$field = $this->db->fromConvert($this->$field, 'datetime'); |
2059 | - if(empty($disable_date_format)) { |
|
2059 | + if (empty($disable_date_format)) { |
|
2060 | 2060 | $this->$field = $timedate->to_display_date_time($this->$field); |
2061 | 2061 | } |
2062 | 2062 | } |
2063 | - elseif(isset($this->field_name_map[$field]['type'])) |
|
2063 | + elseif (isset($this->field_name_map[$field]['type'])) |
|
2064 | 2064 | { |
2065 | 2065 | $type = $this->field_name_map[$field]['type']; |
2066 | 2066 | |
2067 | - if($type == 'relate' && isset($this->field_name_map[$field]['custom_module'])) |
|
2067 | + if ($type == 'relate' && isset($this->field_name_map[$field]['custom_module'])) |
|
2068 | 2068 | { |
2069 | 2069 | $type = $this->field_name_map[$field]['type']; |
2070 | 2070 | } |
2071 | 2071 | |
2072 | - if($type == 'date') |
|
2072 | + if ($type == 'date') |
|
2073 | 2073 | { |
2074 | - if($this->$field == '0000-00-00') |
|
2074 | + if ($this->$field == '0000-00-00') |
|
2075 | 2075 | { |
2076 | 2076 | $this->$field = ''; |
2077 | - } elseif(!empty($this->field_name_map[$field]['rel_field'])) |
|
2077 | + } elseif (!empty($this->field_name_map[$field]['rel_field'])) |
|
2078 | 2078 | { |
2079 | 2079 | $rel_field = $this->field_name_map[$field]['rel_field']; |
2080 | 2080 | |
2081 | - if(!empty($this->$rel_field)) |
|
2081 | + if (!empty($this->$rel_field)) |
|
2082 | 2082 | { |
2083 | - if(empty($disable_date_format)) { |
|
2084 | - $mergetime = $timedate->merge_date_time($this->$field,$this->$rel_field); |
|
2083 | + if (empty($disable_date_format)) { |
|
2084 | + $mergetime = $timedate->merge_date_time($this->$field, $this->$rel_field); |
|
2085 | 2085 | $this->$field = $timedate->to_display_date($mergetime); |
2086 | 2086 | $this->$rel_field = $timedate->to_display_time($mergetime); |
2087 | 2087 | } |
@@ -2089,36 +2089,36 @@ discard block |
||
2089 | 2089 | } |
2090 | 2090 | else |
2091 | 2091 | { |
2092 | - if(empty($disable_date_format)) { |
|
2092 | + if (empty($disable_date_format)) { |
|
2093 | 2093 | $this->$field = $timedate->to_display_date($this->$field, false); |
2094 | 2094 | } |
2095 | 2095 | } |
2096 | - } elseif($type == 'datetime' || $type == 'datetimecombo') |
|
2096 | + } elseif ($type == 'datetime' || $type == 'datetimecombo') |
|
2097 | 2097 | { |
2098 | - if($this->$field == '0000-00-00 00:00:00') |
|
2098 | + if ($this->$field == '0000-00-00 00:00:00') |
|
2099 | 2099 | { |
2100 | 2100 | $this->$field = ''; |
2101 | 2101 | } |
2102 | 2102 | else |
2103 | 2103 | { |
2104 | - if(empty($disable_date_format)) { |
|
2104 | + if (empty($disable_date_format)) { |
|
2105 | 2105 | $this->$field = $timedate->to_display_date_time($this->$field, true, true); |
2106 | 2106 | } |
2107 | 2107 | } |
2108 | - } elseif($type == 'time') |
|
2108 | + } elseif ($type == 'time') |
|
2109 | 2109 | { |
2110 | - if($this->$field == '00:00:00') |
|
2110 | + if ($this->$field == '00:00:00') |
|
2111 | 2111 | { |
2112 | 2112 | $this->$field = ''; |
2113 | 2113 | } else |
2114 | 2114 | { |
2115 | 2115 | //$this->$field = from_db_convert($this->$field, 'time'); |
2116 | - if(empty($this->field_name_map[$field]['rel_field']) && empty($disable_date_format)) |
|
2116 | + if (empty($this->field_name_map[$field]['rel_field']) && empty($disable_date_format)) |
|
2117 | 2117 | { |
2118 | - $this->$field = $timedate->to_display_time($this->$field,true, false); |
|
2118 | + $this->$field = $timedate->to_display_time($this->$field, true, false); |
|
2119 | 2119 | } |
2120 | 2120 | } |
2121 | - } elseif($type == 'encrypt' && empty($disable_date_format)){ |
|
2121 | + } elseif ($type == 'encrypt' && empty($disable_date_format)) { |
|
2122 | 2122 | $this->$field = $this->decrypt_after_retrieve($this->$field); |
2123 | 2123 | } |
2124 | 2124 | } |
@@ -2172,52 +2172,52 @@ discard block |
||
2172 | 2172 | static $boolean_false_values = array('off', 'false', '0', 'no'); |
2173 | 2173 | |
2174 | 2174 | |
2175 | - foreach($this->field_defs as $field=>$def) |
|
2175 | + foreach ($this->field_defs as $field=>$def) |
|
2176 | 2176 | { |
2177 | - if ( !isset($this->$field) ) { |
|
2177 | + if (!isset($this->$field)) { |
|
2178 | 2178 | continue; |
2179 | 2179 | } |
2180 | - if ( (isset($def['source'])&&$def['source']=='non-db') || $field == 'deleted' ) { |
|
2180 | + if ((isset($def['source']) && $def['source'] == 'non-db') || $field == 'deleted') { |
|
2181 | 2181 | continue; |
2182 | 2182 | } |
2183 | - if ( isset($this->fetched_row[$field]) && $this->$field == $this->fetched_row[$field] ) { |
|
2183 | + if (isset($this->fetched_row[$field]) && $this->$field == $this->fetched_row[$field]) { |
|
2184 | 2184 | // Don't hand out warnings because the field was untouched between retrieval and saving, most database drivers hand pretty much everything back as strings. |
2185 | 2185 | continue; |
2186 | 2186 | } |
2187 | 2187 | $reformatted = false; |
2188 | - switch($def['type']) { |
|
2188 | + switch ($def['type']) { |
|
2189 | 2189 | case 'datetime': |
2190 | 2190 | case 'datetimecombo': |
2191 | - if(empty($this->$field)) break; |
|
2191 | + if (empty($this->$field)) break; |
|
2192 | 2192 | if ($this->$field == 'NULL') { |
2193 | 2193 | $this->$field = ''; |
2194 | 2194 | break; |
2195 | 2195 | } |
2196 | - if ( ! preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/',$this->$field) ) { |
|
2196 | + if (!preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/', $this->$field)) { |
|
2197 | 2197 | // This appears to be formatted in user date/time |
2198 | 2198 | $this->$field = $timedate->to_db($this->$field); |
2199 | 2199 | $reformatted = true; |
2200 | 2200 | } |
2201 | 2201 | break; |
2202 | 2202 | case 'date': |
2203 | - if(empty($this->$field)) break; |
|
2203 | + if (empty($this->$field)) break; |
|
2204 | 2204 | if ($this->$field == 'NULL') { |
2205 | 2205 | $this->$field = ''; |
2206 | 2206 | break; |
2207 | 2207 | } |
2208 | - if ( ! preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/',$this->$field) ) { |
|
2208 | + if (!preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $this->$field)) { |
|
2209 | 2209 | // This date appears to be formatted in the user's format |
2210 | 2210 | $this->$field = $timedate->to_db_date($this->$field, false); |
2211 | 2211 | $reformatted = true; |
2212 | 2212 | } |
2213 | 2213 | break; |
2214 | 2214 | case 'time': |
2215 | - if(empty($this->$field)) break; |
|
2215 | + if (empty($this->$field)) break; |
|
2216 | 2216 | if ($this->$field == 'NULL') { |
2217 | 2217 | $this->$field = ''; |
2218 | 2218 | break; |
2219 | 2219 | } |
2220 | - if ( preg_match('/(am|pm)/i',$this->$field) ) { |
|
2220 | + if (preg_match('/(am|pm)/i', $this->$field)) { |
|
2221 | 2221 | // This time appears to be formatted in the user's format |
2222 | 2222 | $this->$field = $timedate->fromUserTime($this->$field)->format(TimeDate::DB_TIME_FORMAT); |
2223 | 2223 | $reformatted = true; |
@@ -2227,10 +2227,10 @@ discard block |
||
2227 | 2227 | case 'decimal': |
2228 | 2228 | case 'currency': |
2229 | 2229 | case 'float': |
2230 | - if ( $this->$field === '' || $this->$field == NULL || $this->$field == 'NULL') { |
|
2230 | + if ($this->$field === '' || $this->$field == NULL || $this->$field == 'NULL') { |
|
2231 | 2231 | continue; |
2232 | 2232 | } |
2233 | - if ( is_string($this->$field) ) { |
|
2233 | + if (is_string($this->$field)) { |
|
2234 | 2234 | $this->$field = (float)unformat_number($this->$field); |
2235 | 2235 | $reformatted = true; |
2236 | 2236 | } |
@@ -2241,10 +2241,10 @@ discard block |
||
2241 | 2241 | case 'short': |
2242 | 2242 | case 'tinyint': |
2243 | 2243 | case 'int': |
2244 | - if ( $this->$field === '' || $this->$field == NULL || $this->$field == 'NULL') { |
|
2244 | + if ($this->$field === '' || $this->$field == NULL || $this->$field == 'NULL') { |
|
2245 | 2245 | continue; |
2246 | 2246 | } |
2247 | - if ( is_string($this->$field) ) { |
|
2247 | + if (is_string($this->$field)) { |
|
2248 | 2248 | $this->$field = (int)unformat_number($this->$field); |
2249 | 2249 | $reformatted = true; |
2250 | 2250 | } |
@@ -2252,9 +2252,9 @@ discard block |
||
2252 | 2252 | case 'bool': |
2253 | 2253 | if (empty($this->$field)) { |
2254 | 2254 | $this->$field = false; |
2255 | - } else if(true === $this->$field || 1 == $this->$field) { |
|
2255 | + } else if (true === $this->$field || 1 == $this->$field) { |
|
2256 | 2256 | $this->$field = true; |
2257 | - } else if(in_array(strval($this->$field), $boolean_false_values)) { |
|
2257 | + } else if (in_array(strval($this->$field), $boolean_false_values)) { |
|
2258 | 2258 | $this->$field = false; |
2259 | 2259 | $reformatted = true; |
2260 | 2260 | } else { |
@@ -2266,7 +2266,7 @@ discard block |
||
2266 | 2266 | $this->$field = $this->encrpyt_before_save($this->$field); |
2267 | 2267 | break; |
2268 | 2268 | } |
2269 | - if ( $reformatted ) { |
|
2269 | + if ($reformatted) { |
|
2270 | 2270 | $GLOBALS['log']->deprecated('Formatting correction: '.$this->module_dir.'->'.$field.' had formatting automatically corrected. This will be removed in the future, please upgrade your external code'); |
2271 | 2271 | } |
2272 | 2272 | } |
@@ -2285,7 +2285,7 @@ discard block |
||
2285 | 2285 | * |
2286 | 2286 | * Internal function, do not override. |
2287 | 2287 | */ |
2288 | - function retrieve($id = -1, $encode=true,$deleted=true) |
|
2288 | + function retrieve($id = -1, $encode = true, $deleted = true) |
|
2289 | 2289 | { |
2290 | 2290 | |
2291 | 2291 | $custom_logic_arguments['id'] = $id; |
@@ -2297,27 +2297,27 @@ discard block |
||
2297 | 2297 | } |
2298 | 2298 | $custom_join = $this->getCustomJoin(); |
2299 | 2299 | |
2300 | - $query = "SELECT $this->table_name.*". $custom_join['select']. " FROM $this->table_name "; |
|
2300 | + $query = "SELECT $this->table_name.*".$custom_join['select']." FROM $this->table_name "; |
|
2301 | 2301 | |
2302 | 2302 | $query .= $custom_join['join']; |
2303 | 2303 | $query .= " WHERE $this->table_name.id = ".$this->db->quoted($id); |
2304 | 2304 | if ($deleted) $query .= " AND $this->table_name.deleted=0"; |
2305 | 2305 | $GLOBALS['log']->debug("Retrieve $this->object_name : ".$query); |
2306 | - $result = $this->db->limitQuery($query,0,1,true, "Retrieving record by id $this->table_name:$id found "); |
|
2307 | - if(empty($result)) |
|
2306 | + $result = $this->db->limitQuery($query, 0, 1, true, "Retrieving record by id $this->table_name:$id found "); |
|
2307 | + if (empty($result)) |
|
2308 | 2308 | { |
2309 | 2309 | return null; |
2310 | 2310 | } |
2311 | 2311 | |
2312 | 2312 | $row = $this->db->fetchByAssoc($result, $encode); |
2313 | - if(empty($row)) |
|
2313 | + if (empty($row)) |
|
2314 | 2314 | { |
2315 | 2315 | return null; |
2316 | 2316 | } |
2317 | 2317 | |
2318 | 2318 | //make copy of the fetched row for construction of audit record and for business logic/workflow |
2319 | 2319 | $row = $this->convertRow($row); |
2320 | - $this->fetched_row=$row; |
|
2320 | + $this->fetched_row = $row; |
|
2321 | 2321 | $this->populateFromRow($row); |
2322 | 2322 | |
2323 | 2323 | // fix defect #52438. implement the same logic as sugar_currency_format |
@@ -2326,16 +2326,16 @@ discard block |
||
2326 | 2326 | |
2327 | 2327 | global $module, $action; |
2328 | 2328 | //Just to get optimistic locking working for this release |
2329 | - if($this->optimistic_lock && $module == $this->module_dir && $action =='EditView' ) |
|
2329 | + if ($this->optimistic_lock && $module == $this->module_dir && $action == 'EditView') |
|
2330 | 2330 | { |
2331 | - $_SESSION['o_lock_id']= $id; |
|
2332 | - $_SESSION['o_lock_dm']= $this->date_modified; |
|
2331 | + $_SESSION['o_lock_id'] = $id; |
|
2332 | + $_SESSION['o_lock_dm'] = $this->date_modified; |
|
2333 | 2333 | $_SESSION['o_lock_on'] = $this->object_name; |
2334 | 2334 | } |
2335 | 2335 | $this->processed_dates_times = array(); |
2336 | 2336 | $this->check_date_relationships_load(); |
2337 | 2337 | |
2338 | - if(isset($this->custom_fields)) |
|
2338 | + if (isset($this->custom_fields)) |
|
2339 | 2339 | { |
2340 | 2340 | $this->custom_fields->fill_relationships(); |
2341 | 2341 | } |
@@ -2346,23 +2346,23 @@ discard block |
||
2346 | 2346 | // save related fields values for audit |
2347 | 2347 | foreach ($this->get_related_fields() as $rel_field_name) |
2348 | 2348 | { |
2349 | - if (! empty($this->$rel_field_name['name'])) |
|
2349 | + if (!empty($this->$rel_field_name['name'])) |
|
2350 | 2350 | { |
2351 | 2351 | $this->fetched_rel_row[$rel_field_name['name']] = $this->$rel_field_name['name']; |
2352 | 2352 | } |
2353 | 2353 | } |
2354 | 2354 | //make a copy of fields in the relationship_fields array. These field values will be used to |
2355 | 2355 | //clear relationship. |
2356 | - foreach ( $this->field_defs as $key => $def ) |
|
2356 | + foreach ($this->field_defs as $key => $def) |
|
2357 | 2357 | { |
2358 | - if ($def [ 'type' ] == 'relate' && isset ( $def [ 'id_name'] ) && isset ( $def [ 'link'] ) && isset ( $def[ 'save' ])) { |
|
2358 | + if ($def ['type'] == 'relate' && isset ($def ['id_name']) && isset ($def ['link']) && isset ($def['save'])) { |
|
2359 | 2359 | if (isset($this->$key)) { |
2360 | - $this->rel_fields_before_value[$key]=$this->$key; |
|
2361 | - if (isset($this->$def [ 'id_name'])) |
|
2362 | - $this->rel_fields_before_value[$def [ 'id_name']]=$this->$def [ 'id_name']; |
|
2360 | + $this->rel_fields_before_value[$key] = $this->$key; |
|
2361 | + if (isset($this->$def ['id_name'])) |
|
2362 | + $this->rel_fields_before_value[$def ['id_name']] = $this->$def ['id_name']; |
|
2363 | 2363 | } |
2364 | 2364 | else |
2365 | - $this->rel_fields_before_value[$key]=null; |
|
2365 | + $this->rel_fields_before_value[$key] = null; |
|
2366 | 2366 | } |
2367 | 2367 | } |
2368 | 2368 | if (isset($this->relationship_fields) && is_array($this->relationship_fields)) |
@@ -2370,9 +2370,9 @@ discard block |
||
2370 | 2370 | foreach ($this->relationship_fields as $rel_id=>$rel_name) |
2371 | 2371 | { |
2372 | 2372 | if (isset($this->$rel_id)) |
2373 | - $this->rel_fields_before_value[$rel_id]=$this->$rel_id; |
|
2373 | + $this->rel_fields_before_value[$rel_id] = $this->$rel_id; |
|
2374 | 2374 | else |
2375 | - $this->rel_fields_before_value[$rel_id]=null; |
|
2375 | + $this->rel_fields_before_value[$rel_id] = null; |
|
2376 | 2376 | } |
2377 | 2377 | } |
2378 | 2378 | |
@@ -2395,16 +2395,16 @@ discard block |
||
2395 | 2395 | */ |
2396 | 2396 | function populateFromRow($row) |
2397 | 2397 | { |
2398 | - $nullvalue=''; |
|
2399 | - foreach($this->field_defs as $field=>$field_value) |
|
2398 | + $nullvalue = ''; |
|
2399 | + foreach ($this->field_defs as $field=>$field_value) |
|
2400 | 2400 | { |
2401 | - if($field == 'user_preferences' && $this->module_dir == 'Users') |
|
2401 | + if ($field == 'user_preferences' && $this->module_dir == 'Users') |
|
2402 | 2402 | continue; |
2403 | - if(isset($row[$field])) |
|
2403 | + if (isset($row[$field])) |
|
2404 | 2404 | { |
2405 | 2405 | $this->$field = $row[$field]; |
2406 | - $owner = $field . '_owner'; |
|
2407 | - if(!empty($row[$owner])){ |
|
2406 | + $owner = $field.'_owner'; |
|
2407 | + if (!empty($row[$owner])) { |
|
2408 | 2408 | $this->$owner = $row[$owner]; |
2409 | 2409 | } |
2410 | 2410 | } |
@@ -2446,48 +2446,48 @@ discard block |
||
2446 | 2446 | function create_list_count_query($query) |
2447 | 2447 | { |
2448 | 2448 | // remove the 'order by' clause which is expected to be at the end of the query |
2449 | - $pattern = '/\sORDER BY.*/is'; // ignores the case |
|
2449 | + $pattern = '/\sORDER BY.*/is'; // ignores the case |
|
2450 | 2450 | $replacement = ''; |
2451 | 2451 | $query = preg_replace($pattern, $replacement, $query); |
2452 | 2452 | //handle distinct clause |
2453 | 2453 | $star = '*'; |
2454 | - if(substr_count(strtolower($query), 'distinct')){ |
|
2455 | - if (!empty($this->seed) && !empty($this->seed->table_name )) |
|
2456 | - $star = 'DISTINCT ' . $this->seed->table_name . '.id'; |
|
2454 | + if (substr_count(strtolower($query), 'distinct')) { |
|
2455 | + if (!empty($this->seed) && !empty($this->seed->table_name)) |
|
2456 | + $star = 'DISTINCT '.$this->seed->table_name.'.id'; |
|
2457 | 2457 | else |
2458 | - $star = 'DISTINCT ' . $this->table_name . '.id'; |
|
2458 | + $star = 'DISTINCT '.$this->table_name.'.id'; |
|
2459 | 2459 | |
2460 | 2460 | } |
2461 | 2461 | |
2462 | 2462 | // change the select expression to 'count(*)' |
2463 | - $pattern = '/SELECT(.*?)(\s){1}FROM(\s){1}/is'; // ignores the case |
|
2464 | - $replacement = 'SELECT count(' . $star . ') c FROM '; |
|
2463 | + $pattern = '/SELECT(.*?)(\s){1}FROM(\s){1}/is'; // ignores the case |
|
2464 | + $replacement = 'SELECT count('.$star.') c FROM '; |
|
2465 | 2465 | |
2466 | 2466 | //if the passed query has union clause then replace all instances of the pattern. |
2467 | 2467 | //this is very rare. I have seen this happening only from projects module. |
2468 | 2468 | //in addition to this added a condition that has union clause and uses |
2469 | 2469 | //sub-selects. |
2470 | - if (strstr($query," UNION ALL ") !== false) { |
|
2470 | + if (strstr($query, " UNION ALL ") !== false) { |
|
2471 | 2471 | |
2472 | 2472 | //separate out all the queries. |
2473 | - $union_qs=explode(" UNION ALL ", $query); |
|
2473 | + $union_qs = explode(" UNION ALL ", $query); |
|
2474 | 2474 | foreach ($union_qs as $key=>$union_query) { |
2475 | 2475 | $star = '*'; |
2476 | 2476 | preg_match($pattern, $union_query, $matches); |
2477 | 2477 | if (!empty($matches)) { |
2478 | 2478 | if (stristr($matches[0], "distinct")) { |
2479 | - if (!empty($this->seed) && !empty($this->seed->table_name )) |
|
2480 | - $star = 'DISTINCT ' . $this->seed->table_name . '.id'; |
|
2479 | + if (!empty($this->seed) && !empty($this->seed->table_name)) |
|
2480 | + $star = 'DISTINCT '.$this->seed->table_name.'.id'; |
|
2481 | 2481 | else |
2482 | - $star = 'DISTINCT ' . $this->table_name . '.id'; |
|
2482 | + $star = 'DISTINCT '.$this->table_name.'.id'; |
|
2483 | 2483 | } |
2484 | 2484 | } // if |
2485 | - $replacement = 'SELECT count(' . $star . ') c FROM '; |
|
2486 | - $union_qs[$key] = preg_replace($pattern, $replacement, $union_query,1); |
|
2485 | + $replacement = 'SELECT count('.$star.') c FROM '; |
|
2486 | + $union_qs[$key] = preg_replace($pattern, $replacement, $union_query, 1); |
|
2487 | 2487 | } |
2488 | - $modified_select_query=implode(" UNION ALL ",$union_qs); |
|
2488 | + $modified_select_query = implode(" UNION ALL ", $union_qs); |
|
2489 | 2489 | } else { |
2490 | - $modified_select_query = preg_replace($pattern, $replacement, $query,1); |
|
2490 | + $modified_select_query = preg_replace($pattern, $replacement, $query, 1); |
|
2491 | 2491 | } |
2492 | 2492 | |
2493 | 2493 | |
@@ -2510,15 +2510,15 @@ discard block |
||
2510 | 2510 | * Internal function, do not override. |
2511 | 2511 | * |
2512 | 2512 | */ |
2513 | - function get_list($order_by = "", $where = "", $row_offset = 0, $limit=-1, $max=-1, $show_deleted = 0, $singleSelect=false, $select_fields = array()) |
|
2513 | + function get_list($order_by = "", $where = "", $row_offset = 0, $limit = -1, $max = -1, $show_deleted = 0, $singleSelect = false, $select_fields = array()) |
|
2514 | 2514 | { |
2515 | 2515 | $GLOBALS['log']->debug("get_list: order_by = '$order_by' and where = '$where' and limit = '$limit'"); |
2516 | - if(isset($_SESSION['show_deleted'])) |
|
2516 | + if (isset($_SESSION['show_deleted'])) |
|
2517 | 2517 | { |
2518 | 2518 | $show_deleted = 1; |
2519 | 2519 | } |
2520 | 2520 | |
2521 | - if($this->bean_implements('ACL') && ACLController::requireOwner($this->module_dir, 'list') ) |
|
2521 | + if ($this->bean_implements('ACL') && ACLController::requireOwner($this->module_dir, 'list')) |
|
2522 | 2522 | { |
2523 | 2523 | global $current_user; |
2524 | 2524 | $owner_where = $this->getOwnerWhere($current_user->id); |
@@ -2526,15 +2526,15 @@ discard block |
||
2526 | 2526 | //rrs - because $this->getOwnerWhere() can return '' we need to be sure to check for it and |
2527 | 2527 | //handle it properly else you could get into a situation where you are create a where stmt like |
2528 | 2528 | //WHERE .. AND '' |
2529 | - if(!empty($owner_where)){ |
|
2530 | - if(empty($where)){ |
|
2529 | + if (!empty($owner_where)) { |
|
2530 | + if (empty($where)) { |
|
2531 | 2531 | $where = $owner_where; |
2532 | - }else{ |
|
2533 | - $where .= ' AND '. $owner_where; |
|
2532 | + } else { |
|
2533 | + $where .= ' AND '.$owner_where; |
|
2534 | 2534 | } |
2535 | 2535 | } |
2536 | 2536 | } |
2537 | - $query = $this->create_new_list_query($order_by, $where,$select_fields,array(), $show_deleted,'',false,null,$singleSelect); |
|
2537 | + $query = $this->create_new_list_query($order_by, $where, $select_fields, array(), $show_deleted, '', false, null, $singleSelect); |
|
2538 | 2538 | return $this->process_list_query($query, $row_offset, $limit, $max, $where); |
2539 | 2539 | } |
2540 | 2540 | |
@@ -2580,9 +2580,9 @@ discard block |
||
2580 | 2580 | |
2581 | 2581 | if (empty($field_defs['table']) && !$suppress_table_name) { |
2582 | 2582 | if ($source == 'db') { |
2583 | - $list_column[0] = $bean_queried->table_name . '.' . $list_column[0] ; |
|
2583 | + $list_column[0] = $bean_queried->table_name.'.'.$list_column[0]; |
|
2584 | 2584 | } elseif ($source == 'custom_fields') { |
2585 | - $list_column[0] = $bean_queried->table_name . '_cstm.' . $list_column[0] ; |
|
2585 | + $list_column[0] = $bean_queried->table_name.'_cstm.'.$list_column[0]; |
|
2586 | 2586 | } |
2587 | 2587 | } |
2588 | 2588 | |
@@ -2636,49 +2636,49 @@ discard block |
||
2636 | 2636 | * |
2637 | 2637 | * Internal function, do not override. |
2638 | 2638 | */ |
2639 | - function get_detail($order_by = "", $where = "", $offset = 0, $row_offset = 0, $limit=-1, $max=-1, $show_deleted = 0) |
|
2639 | + function get_detail($order_by = "", $where = "", $offset = 0, $row_offset = 0, $limit = -1, $max = -1, $show_deleted = 0) |
|
2640 | 2640 | { |
2641 | 2641 | $GLOBALS['log']->debug("get_detail: order_by = '$order_by' and where = '$where' and limit = '$limit' and offset = '$offset'"); |
2642 | - if(isset($_SESSION['show_deleted'])) |
|
2642 | + if (isset($_SESSION['show_deleted'])) |
|
2643 | 2643 | { |
2644 | 2644 | $show_deleted = 1; |
2645 | 2645 | } |
2646 | 2646 | |
2647 | - if($this->bean_implements('ACL') && ACLController::requireOwner($this->module_dir, 'list') ) |
|
2647 | + if ($this->bean_implements('ACL') && ACLController::requireOwner($this->module_dir, 'list')) |
|
2648 | 2648 | { |
2649 | 2649 | global $current_user; |
2650 | 2650 | $owner_where = $this->getOwnerWhere($current_user->id); |
2651 | 2651 | |
2652 | - if(empty($where)) |
|
2652 | + if (empty($where)) |
|
2653 | 2653 | { |
2654 | 2654 | $where = $owner_where; |
2655 | 2655 | } |
2656 | 2656 | else |
2657 | 2657 | { |
2658 | - $where .= ' AND '. $owner_where; |
|
2658 | + $where .= ' AND '.$owner_where; |
|
2659 | 2659 | } |
2660 | 2660 | } |
2661 | 2661 | |
2662 | 2662 | /* BEGIN - SECURITY GROUPS */ |
2663 | - if($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list') ) |
|
2663 | + if ($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list')) |
|
2664 | 2664 | { |
2665 | 2665 | require_once('modules/SecurityGroups/SecurityGroup.php'); |
2666 | 2666 | global $current_user; |
2667 | 2667 | $owner_where = $this->getOwnerWhere($current_user->id); |
2668 | - $group_where = SecurityGroup::getGroupWhere($this->table_name,$this->module_dir,$current_user->id); |
|
2669 | - if(!empty($owner_where)){ |
|
2670 | - if(empty($where)) |
|
2668 | + $group_where = SecurityGroup::getGroupWhere($this->table_name, $this->module_dir, $current_user->id); |
|
2669 | + if (!empty($owner_where)) { |
|
2670 | + if (empty($where)) |
|
2671 | 2671 | { |
2672 | - $where = " (". $owner_where." or ".$group_where.") "; |
|
2672 | + $where = " (".$owner_where." or ".$group_where.") "; |
|
2673 | 2673 | } else { |
2674 | - $where .= " AND (". $owner_where." or ".$group_where.") "; |
|
2674 | + $where .= " AND (".$owner_where." or ".$group_where.") "; |
|
2675 | 2675 | } |
2676 | 2676 | } else { |
2677 | - $where .= ' AND '. $group_where; |
|
2677 | + $where .= ' AND '.$group_where; |
|
2678 | 2678 | } |
2679 | 2679 | } |
2680 | 2680 | /* END - SECURITY GROUPS */ |
2681 | - $query = $this->create_new_list_query($order_by, $where,array(),array(), $show_deleted, $offset); |
|
2681 | + $query = $this->create_new_list_query($order_by, $where, array(), array(), $show_deleted, $offset); |
|
2682 | 2682 | |
2683 | 2683 | //Add Limit and Offset to query |
2684 | 2684 | //$query .= " LIMIT 1 OFFSET $offset"; |
@@ -2697,13 +2697,13 @@ discard block |
||
2697 | 2697 | * |
2698 | 2698 | * Internal function, do not override. |
2699 | 2699 | */ |
2700 | - function get_related_list($child_seed,$related_field_name, $order_by = "", $where = "", |
|
2701 | - $row_offset = 0, $limit=-1, $max=-1, $show_deleted = 0) |
|
2700 | + function get_related_list($child_seed, $related_field_name, $order_by = "", $where = "", |
|
2701 | + $row_offset = 0, $limit = -1, $max = -1, $show_deleted = 0) |
|
2702 | 2702 | { |
2703 | 2703 | global $layout_edit_mode; |
2704 | 2704 | $query_array = array(); |
2705 | 2705 | |
2706 | - if(isset($layout_edit_mode) && $layout_edit_mode) |
|
2706 | + if (isset($layout_edit_mode) && $layout_edit_mode) |
|
2707 | 2707 | { |
2708 | 2708 | $response = array(); |
2709 | 2709 | $child_seed->assign_display_fields($child_seed->module_dir); |
@@ -2715,7 +2715,7 @@ discard block |
||
2715 | 2715 | return $response; |
2716 | 2716 | } |
2717 | 2717 | $GLOBALS['log']->debug("get_related_list: order_by = '$order_by' and where = '$where' and limit = '$limit'"); |
2718 | - if(isset($_SESSION['show_deleted'])) |
|
2718 | + if (isset($_SESSION['show_deleted'])) |
|
2719 | 2719 | { |
2720 | 2720 | $show_deleted = 1; |
2721 | 2721 | } |
@@ -2734,22 +2734,22 @@ discard block |
||
2734 | 2734 | } |
2735 | 2735 | |
2736 | 2736 | $entire_where = $query_array['where']; |
2737 | - if(!empty($where)) |
|
2737 | + if (!empty($where)) |
|
2738 | 2738 | { |
2739 | - if(empty($entire_where)) |
|
2739 | + if (empty($entire_where)) |
|
2740 | 2740 | { |
2741 | - $entire_where = ' WHERE ' . $where; |
|
2741 | + $entire_where = ' WHERE '.$where; |
|
2742 | 2742 | } |
2743 | 2743 | else |
2744 | 2744 | { |
2745 | - $entire_where .= ' AND ' . $where; |
|
2745 | + $entire_where .= ' AND '.$where; |
|
2746 | 2746 | } |
2747 | 2747 | } |
2748 | 2748 | |
2749 | - $query = 'SELECT '.$child_seed->table_name.'.* ' . $query_array['from'] . ' ' . $entire_where; |
|
2750 | - if(!empty($order_by)) |
|
2749 | + $query = 'SELECT '.$child_seed->table_name.'.* '.$query_array['from'].' '.$entire_where; |
|
2750 | + if (!empty($order_by)) |
|
2751 | 2751 | { |
2752 | - $query .= " ORDER BY " . $order_by; |
|
2752 | + $query .= " ORDER BY ".$order_by; |
|
2753 | 2753 | } |
2754 | 2754 | |
2755 | 2755 | return $child_seed->process_list_query($query, $row_offset, $limit, $max, $where); |
@@ -2760,27 +2760,27 @@ discard block |
||
2760 | 2760 | { |
2761 | 2761 | global $layout_edit_mode, $beanFiles, $beanList; |
2762 | 2762 | $subqueries = array(); |
2763 | - foreach($subpanel_list as $this_subpanel) |
|
2763 | + foreach ($subpanel_list as $this_subpanel) |
|
2764 | 2764 | { |
2765 | - if(!$this_subpanel->isDatasourceFunction() || ($this_subpanel->isDatasourceFunction() |
|
2765 | + if (!$this_subpanel->isDatasourceFunction() || ($this_subpanel->isDatasourceFunction() |
|
2766 | 2766 | && isset($this_subpanel->_instance_properties['generate_select']) |
2767 | - && $this_subpanel->_instance_properties['generate_select']==true)) |
|
2767 | + && $this_subpanel->_instance_properties['generate_select'] == true)) |
|
2768 | 2768 | { |
2769 | 2769 | //the custom query function must return an array with |
2770 | 2770 | if ($this_subpanel->isDatasourceFunction()) { |
2771 | 2771 | $shortcut_function_name = $this_subpanel->get_data_source_name(); |
2772 | - $parameters=$this_subpanel->get_function_parameters(); |
|
2772 | + $parameters = $this_subpanel->get_function_parameters(); |
|
2773 | 2773 | if (!empty($parameters)) |
2774 | 2774 | { |
2775 | 2775 | //if the import file function is set, then import the file to call the custom function from |
2776 | - if (is_array($parameters) && isset($parameters['import_function_file'])){ |
|
2776 | + if (is_array($parameters) && isset($parameters['import_function_file'])) { |
|
2777 | 2777 | //this call may happen multiple times, so only require if function does not exist |
2778 | - if(!function_exists($shortcut_function_name)){ |
|
2778 | + if (!function_exists($shortcut_function_name)) { |
|
2779 | 2779 | require_once($parameters['import_function_file']); |
2780 | 2780 | } |
2781 | 2781 | //call function from required file |
2782 | 2782 | $query_array = $shortcut_function_name($parameters); |
2783 | - }else{ |
|
2783 | + } else { |
|
2784 | 2784 | //call function from parent bean |
2785 | 2785 | $query_array = $parentbean->$shortcut_function_name($parameters); |
2786 | 2786 | } |
@@ -2789,9 +2789,9 @@ discard block |
||
2789 | 2789 | { |
2790 | 2790 | $query_array = $parentbean->$shortcut_function_name(); |
2791 | 2791 | } |
2792 | - } else { |
|
2792 | + } else { |
|
2793 | 2793 | $related_field_name = $this_subpanel->get_data_source_name(); |
2794 | - if (!$parentbean->load_relationship($related_field_name)){ |
|
2794 | + if (!$parentbean->load_relationship($related_field_name)) { |
|
2795 | 2795 | unset ($parentbean->$related_field_name); |
2796 | 2796 | continue; |
2797 | 2797 | } |
@@ -2800,15 +2800,15 @@ discard block |
||
2800 | 2800 | $table_where = preg_replace('/^\s*WHERE/i', '', $this_subpanel->get_where()); |
2801 | 2801 | $where_definition = preg_replace('/^\s*WHERE/i', '', $query_array['where']); |
2802 | 2802 | |
2803 | - if(!empty($table_where)) |
|
2803 | + if (!empty($table_where)) |
|
2804 | 2804 | { |
2805 | - if(empty($where_definition)) |
|
2805 | + if (empty($where_definition)) |
|
2806 | 2806 | { |
2807 | 2807 | $where_definition = $table_where; |
2808 | 2808 | } |
2809 | 2809 | else |
2810 | 2810 | { |
2811 | - $where_definition .= ' AND ' . $table_where; |
|
2811 | + $where_definition .= ' AND '.$table_where; |
|
2812 | 2812 | } |
2813 | 2813 | } |
2814 | 2814 | |
@@ -2823,21 +2823,21 @@ discard block |
||
2823 | 2823 | |
2824 | 2824 | |
2825 | 2825 | $list_fields = $this_subpanel->get_list_fields(); |
2826 | - foreach($list_fields as $list_key=>$list_field) |
|
2826 | + foreach ($list_fields as $list_key=>$list_field) |
|
2827 | 2827 | { |
2828 | - if(isset($list_field['usage']) && $list_field['usage'] == 'display_only') |
|
2828 | + if (isset($list_field['usage']) && $list_field['usage'] == 'display_only') |
|
2829 | 2829 | { |
2830 | 2830 | unset($list_fields[$list_key]); |
2831 | 2831 | } |
2832 | 2832 | } |
2833 | 2833 | |
2834 | 2834 | |
2835 | - if(!$subpanel_def->isCollection() && isset($list_fields[$order_by]) && isset($submodule->field_defs[$order_by])&& (!isset($submodule->field_defs[$order_by]['source']) || $submodule->field_defs[$order_by]['source'] == 'db')) |
|
2835 | + if (!$subpanel_def->isCollection() && isset($list_fields[$order_by]) && isset($submodule->field_defs[$order_by]) && (!isset($submodule->field_defs[$order_by]['source']) || $submodule->field_defs[$order_by]['source'] == 'db')) |
|
2836 | 2836 | { |
2837 | - $order_by = $submodule->table_name .'.'. $order_by; |
|
2837 | + $order_by = $submodule->table_name.'.'.$order_by; |
|
2838 | 2838 | } |
2839 | 2839 | $table_name = $this_subpanel->table_name; |
2840 | - $panel_name=$this_subpanel->name; |
|
2840 | + $panel_name = $this_subpanel->name; |
|
2841 | 2841 | $params = array(); |
2842 | 2842 | $params['distinct'] = $this_subpanel->distinct_query(); |
2843 | 2843 | |
@@ -2848,7 +2848,7 @@ discard block |
||
2848 | 2848 | // use single select in case when sorting by relate field |
2849 | 2849 | $singleSelect = $submodule->is_relate_field($order_by); |
2850 | 2850 | |
2851 | - $subquery = $submodule->create_new_list_query('',$subwhere ,$list_fields,$params, 0,'', true,$parentbean, $singleSelect); |
|
2851 | + $subquery = $submodule->create_new_list_query('', $subwhere, $list_fields, $params, 0, '', true, $parentbean, $singleSelect); |
|
2852 | 2852 | |
2853 | 2853 | $subquery['select'] = $subquery['select']." , '$panel_name' panel_name "; |
2854 | 2854 | $subquery['from'] = $subquery['from'].$query_array['join']; |
@@ -2880,27 +2880,27 @@ discard block |
||
2880 | 2880 | * |
2881 | 2881 | * Internal Function, do not overide. |
2882 | 2882 | */ |
2883 | - static function get_union_related_list($parentbean, $order_by = "", $sort_order='', $where = "", |
|
2884 | - $row_offset = 0, $limit=-1, $max=-1, $show_deleted = 0, $subpanel_def) |
|
2883 | + static function get_union_related_list($parentbean, $order_by = "", $sort_order = '', $where = "", |
|
2884 | + $row_offset = 0, $limit = -1, $max = -1, $show_deleted = 0, $subpanel_def) |
|
2885 | 2885 | { |
2886 | 2886 | $secondary_queries = array(); |
2887 | 2887 | global $layout_edit_mode, $beanFiles, $beanList; |
2888 | 2888 | |
2889 | - if(isset($_SESSION['show_deleted'])) |
|
2889 | + if (isset($_SESSION['show_deleted'])) |
|
2890 | 2890 | { |
2891 | 2891 | $show_deleted = 1; |
2892 | 2892 | } |
2893 | 2893 | $final_query = ''; |
2894 | 2894 | $final_query_rows = ''; |
2895 | - $subpanel_list=array(); |
|
2895 | + $subpanel_list = array(); |
|
2896 | 2896 | if ($subpanel_def->isCollection()) |
2897 | 2897 | { |
2898 | 2898 | $subpanel_def->load_sub_subpanels(); |
2899 | - $subpanel_list=$subpanel_def->sub_subpanels; |
|
2899 | + $subpanel_list = $subpanel_def->sub_subpanels; |
|
2900 | 2900 | } |
2901 | 2901 | else |
2902 | 2902 | { |
2903 | - $subpanel_list[]=$subpanel_def; |
|
2903 | + $subpanel_list[] = $subpanel_def; |
|
2904 | 2904 | } |
2905 | 2905 | |
2906 | 2906 | $first = true; |
@@ -2909,36 +2909,36 @@ discard block |
||
2909 | 2909 | //The second loop merges the queries and forces them to select the same number of columns |
2910 | 2910 | //All columns in a sub-subpanel group must have the same aliases |
2911 | 2911 | //If the subpanel is a datasource function, it can't be a collection so we just poll that function for the and return that |
2912 | - foreach($subpanel_list as $this_subpanel) |
|
2912 | + foreach ($subpanel_list as $this_subpanel) |
|
2913 | 2913 | { |
2914 | - if($this_subpanel->isDatasourceFunction() && empty($this_subpanel->_instance_properties['generate_select'])) |
|
2914 | + if ($this_subpanel->isDatasourceFunction() && empty($this_subpanel->_instance_properties['generate_select'])) |
|
2915 | 2915 | { |
2916 | 2916 | $shortcut_function_name = $this_subpanel->get_data_source_name(); |
2917 | - $parameters=$this_subpanel->get_function_parameters(); |
|
2917 | + $parameters = $this_subpanel->get_function_parameters(); |
|
2918 | 2918 | if (!empty($parameters)) |
2919 | 2919 | { |
2920 | 2920 | //if the import file function is set, then import the file to call the custom function from |
2921 | - if (is_array($parameters) && isset($parameters['import_function_file'])){ |
|
2921 | + if (is_array($parameters) && isset($parameters['import_function_file'])) { |
|
2922 | 2922 | //this call may happen multiple times, so only require if function does not exist |
2923 | - if(!function_exists($shortcut_function_name)){ |
|
2923 | + if (!function_exists($shortcut_function_name)) { |
|
2924 | 2924 | require_once($parameters['import_function_file']); |
2925 | 2925 | } |
2926 | 2926 | //call function from required file |
2927 | - $tmp_final_query = $shortcut_function_name($parameters); |
|
2928 | - }else{ |
|
2927 | + $tmp_final_query = $shortcut_function_name($parameters); |
|
2928 | + } else { |
|
2929 | 2929 | //call function from parent bean |
2930 | - $tmp_final_query = $parentbean->$shortcut_function_name($parameters); |
|
2930 | + $tmp_final_query = $parentbean->$shortcut_function_name($parameters); |
|
2931 | 2931 | } |
2932 | 2932 | } else { |
2933 | 2933 | $tmp_final_query = $parentbean->$shortcut_function_name(); |
2934 | 2934 | } |
2935 | - if(!$first) |
|
2935 | + if (!$first) |
|
2936 | 2936 | { |
2937 | - $final_query_rows .= ' UNION ALL ( '.$parentbean->create_list_count_query($tmp_final_query, $parameters) . ' )'; |
|
2938 | - $final_query .= ' UNION ALL ( '.$tmp_final_query . ' )'; |
|
2937 | + $final_query_rows .= ' UNION ALL ( '.$parentbean->create_list_count_query($tmp_final_query, $parameters).' )'; |
|
2938 | + $final_query .= ' UNION ALL ( '.$tmp_final_query.' )'; |
|
2939 | 2939 | } else { |
2940 | - $final_query_rows = '(' . $parentbean->create_list_count_query($tmp_final_query, $parameters) . ')'; |
|
2941 | - $final_query = '(' . $tmp_final_query . ')'; |
|
2940 | + $final_query_rows = '('.$parentbean->create_list_count_query($tmp_final_query, $parameters).')'; |
|
2941 | + $final_query = '('.$tmp_final_query.')'; |
|
2942 | 2942 | $first = false; |
2943 | 2943 | } |
2944 | 2944 | } |
@@ -2948,10 +2948,10 @@ discard block |
||
2948 | 2948 | { |
2949 | 2949 | $subqueries = SugarBean::build_sub_queries_for_union($subpanel_list, $subpanel_def, $parentbean, $order_by); |
2950 | 2950 | $all_fields = array(); |
2951 | - foreach($subqueries as $i => $subquery) |
|
2951 | + foreach ($subqueries as $i => $subquery) |
|
2952 | 2952 | { |
2953 | 2953 | $query_fields = $GLOBALS['db']->getSelectFieldsFromQuery($subquery['select']); |
2954 | - foreach($query_fields as $field => $select) |
|
2954 | + foreach ($query_fields as $field => $select) |
|
2955 | 2955 | { |
2956 | 2956 | if (!in_array($field, $all_fields)) |
2957 | 2957 | $all_fields[] = $field; |
@@ -2960,10 +2960,10 @@ discard block |
||
2960 | 2960 | } |
2961 | 2961 | $first = true; |
2962 | 2962 | //Now ensure the queries have the same set of fields in the same order. |
2963 | - foreach($subqueries as $subquery) |
|
2963 | + foreach ($subqueries as $subquery) |
|
2964 | 2964 | { |
2965 | 2965 | $subquery['select'] = "SELECT"; |
2966 | - foreach($all_fields as $field) |
|
2966 | + foreach ($all_fields as $field) |
|
2967 | 2967 | { |
2968 | 2968 | if (!isset($subquery['query_fields'][$field])) |
2969 | 2969 | { |
@@ -2974,56 +2974,56 @@ discard block |
||
2974 | 2974 | $subquery['select'] .= " {$subquery['query_fields'][$field]},"; |
2975 | 2975 | } |
2976 | 2976 | } |
2977 | - $subquery['select'] = substr($subquery['select'], 0 , strlen($subquery['select']) - 1); |
|
2977 | + $subquery['select'] = substr($subquery['select'], 0, strlen($subquery['select']) - 1); |
|
2978 | 2978 | //Put the query into the final_query |
2979 | - $query = $subquery['select'] . " " . $subquery['from'] . " " . $subquery['where']; |
|
2980 | - if(!$first) |
|
2979 | + $query = $subquery['select']." ".$subquery['from']." ".$subquery['where']; |
|
2980 | + if (!$first) |
|
2981 | 2981 | { |
2982 | - $query = ' UNION ALL ( '.$query . ' )'; |
|
2982 | + $query = ' UNION ALL ( '.$query.' )'; |
|
2983 | 2983 | $final_query_rows .= " UNION ALL "; |
2984 | 2984 | } else { |
2985 | - $query = '(' . $query . ')'; |
|
2985 | + $query = '('.$query.')'; |
|
2986 | 2986 | $first = false; |
2987 | 2987 | } |
2988 | 2988 | $query_array = $subquery['query_array']; |
2989 | - $select_position=strpos($query_array['select'],"SELECT"); |
|
2990 | - $distinct_position=strpos($query_array['select'],"DISTINCT"); |
|
2989 | + $select_position = strpos($query_array['select'], "SELECT"); |
|
2990 | + $distinct_position = strpos($query_array['select'], "DISTINCT"); |
|
2991 | 2991 | if (!empty($subquery['params']['distinct']) && !empty($subpanel_def->table_name)) |
2992 | 2992 | { |
2993 | - $query_rows = "( SELECT count(DISTINCT ". $subpanel_def->table_name . ".id)". $subquery['from_min'].$query_array['join']. $subquery['where'].' )'; |
|
2993 | + $query_rows = "( SELECT count(DISTINCT ".$subpanel_def->table_name.".id)".$subquery['from_min'].$query_array['join'].$subquery['where'].' )'; |
|
2994 | 2994 | } |
2995 | - elseif ($select_position !== false && $distinct_position!= false) |
|
2995 | + elseif ($select_position !== false && $distinct_position != false) |
|
2996 | 2996 | { |
2997 | - $query_rows = "( ".substr_replace($query_array['select'],"SELECT count(",$select_position,6). ")" . $subquery['from_min'].$query_array['join']. $subquery['where'].' )'; |
|
2997 | + $query_rows = "( ".substr_replace($query_array['select'], "SELECT count(", $select_position, 6).")".$subquery['from_min'].$query_array['join'].$subquery['where'].' )'; |
|
2998 | 2998 | } |
2999 | 2999 | else |
3000 | 3000 | { |
3001 | 3001 | //resort to default behavior. |
3002 | - $query_rows = "( SELECT count(*)". $subquery['from_min'].$query_array['join']. $subquery['where'].' )'; |
|
3002 | + $query_rows = "( SELECT count(*)".$subquery['from_min'].$query_array['join'].$subquery['where'].' )'; |
|
3003 | 3003 | } |
3004 | - if(!empty($subquery['secondary_select'])) |
|
3004 | + if (!empty($subquery['secondary_select'])) |
|
3005 | 3005 | { |
3006 | 3006 | |
3007 | - $subquerystring= $subquery['secondary_select'] . $subquery['secondary_from'].$query_array['join']. $subquery['where']; |
|
3007 | + $subquerystring = $subquery['secondary_select'].$subquery['secondary_from'].$query_array['join'].$subquery['where']; |
|
3008 | 3008 | if (!empty($subquery['secondary_where'])) |
3009 | 3009 | { |
3010 | 3010 | if (empty($subquery['where'])) |
3011 | 3011 | { |
3012 | - $subquerystring.=" WHERE " .$subquery['secondary_where']; |
|
3012 | + $subquerystring .= " WHERE ".$subquery['secondary_where']; |
|
3013 | 3013 | } |
3014 | 3014 | else |
3015 | 3015 | { |
3016 | - $subquerystring.=" AND " .$subquery['secondary_where']; |
|
3016 | + $subquerystring .= " AND ".$subquery['secondary_where']; |
|
3017 | 3017 | } |
3018 | 3018 | } |
3019 | - $secondary_queries[]=$subquerystring; |
|
3019 | + $secondary_queries[] = $subquerystring; |
|
3020 | 3020 | } |
3021 | 3021 | $final_query .= $query; |
3022 | 3022 | $final_query_rows .= $query_rows; |
3023 | 3023 | } |
3024 | 3024 | } |
3025 | 3025 | |
3026 | - if(!empty($order_by)) |
|
3026 | + if (!empty($order_by)) |
|
3027 | 3027 | { |
3028 | 3028 | $isCollection = $subpanel_def->isCollection(); |
3029 | 3029 | if ($isCollection) { |
@@ -3037,20 +3037,20 @@ discard block |
||
3037 | 3037 | } |
3038 | 3038 | |
3039 | 3039 | if (!empty($sort_order)) { |
3040 | - $order_by .= ' ' . $sort_order; |
|
3040 | + $order_by .= ' '.$sort_order; |
|
3041 | 3041 | } |
3042 | 3042 | |
3043 | 3043 | $order_by = $parentbean->process_order_by($order_by, $submodule, $suppress_table_name); |
3044 | 3044 | if (!empty($order_by)) { |
3045 | - $final_query .= ' ORDER BY ' . $order_by; |
|
3045 | + $final_query .= ' ORDER BY '.$order_by; |
|
3046 | 3046 | } |
3047 | 3047 | } |
3048 | 3048 | |
3049 | 3049 | |
3050 | - if(isset($layout_edit_mode) && $layout_edit_mode) |
|
3050 | + if (isset($layout_edit_mode) && $layout_edit_mode) |
|
3051 | 3051 | { |
3052 | 3052 | $response = array(); |
3053 | - if(!empty($submodule)) |
|
3053 | + if (!empty($submodule)) |
|
3054 | 3054 | { |
3055 | 3055 | $submodule->assign_display_fields($submodule->module_dir); |
3056 | 3056 | $response['list'] = array($submodule); |
@@ -3067,7 +3067,7 @@ discard block |
||
3067 | 3067 | return $response; |
3068 | 3068 | } |
3069 | 3069 | |
3070 | - return $parentbean->process_union_list_query($parentbean, $final_query, $row_offset, $limit, $max, '',$subpanel_def, $final_query_rows, $secondary_queries); |
|
3070 | + return $parentbean->process_union_list_query($parentbean, $final_query, $row_offset, $limit, $max, '', $subpanel_def, $final_query_rows, $secondary_queries); |
|
3071 | 3071 | } |
3072 | 3072 | |
3073 | 3073 | |
@@ -3079,14 +3079,14 @@ discard block |
||
3079 | 3079 | * @param boolean $check_dates. defaults to false |
3080 | 3080 | * @param int $show_deleted show deleted records. defaults to 0 |
3081 | 3081 | */ |
3082 | - function get_full_list($order_by = "", $where = "", $check_dates=false, $show_deleted = 0) |
|
3082 | + function get_full_list($order_by = "", $where = "", $check_dates = false, $show_deleted = 0) |
|
3083 | 3083 | { |
3084 | 3084 | $GLOBALS['log']->debug("get_full_list: order_by = '$order_by' and where = '$where'"); |
3085 | - if(isset($_SESSION['show_deleted'])) |
|
3085 | + if (isset($_SESSION['show_deleted'])) |
|
3086 | 3086 | { |
3087 | 3087 | $show_deleted = 1; |
3088 | 3088 | } |
3089 | - $query = $this->create_new_list_query($order_by, $where,array(),array(), $show_deleted); |
|
3089 | + $query = $this->create_new_list_query($order_by, $where, array(), array(), $show_deleted); |
|
3090 | 3090 | return $this->process_full_list_query($query, $check_dates); |
3091 | 3091 | } |
3092 | 3092 | |
@@ -3106,29 +3106,29 @@ discard block |
||
3106 | 3106 | * @param boolean $singleSelect Optional, default false. |
3107 | 3107 | * @return String select query string, optionally an array value will be returned if $return_array= true. |
3108 | 3108 | */ |
3109 | - function create_new_list_query($order_by, $where,$filter=array(),$params=array(), $show_deleted = 0,$join_type='', $return_array = false,$parentbean=null, $singleSelect = false, $ifListForExport = false) |
|
3109 | + function create_new_list_query($order_by, $where, $filter = array(), $params = array(), $show_deleted = 0, $join_type = '', $return_array = false, $parentbean = null, $singleSelect = false, $ifListForExport = false) |
|
3110 | 3110 | { |
3111 | 3111 | global $beanFiles, $beanList; |
3112 | 3112 | $selectedFields = array(); |
3113 | 3113 | $secondarySelectedFields = array(); |
3114 | 3114 | $ret_array = array(); |
3115 | 3115 | $distinct = ''; |
3116 | - if($this->bean_implements('ACL') && ACLController::requireOwner($this->module_dir, 'list') ) |
|
3116 | + if ($this->bean_implements('ACL') && ACLController::requireOwner($this->module_dir, 'list')) |
|
3117 | 3117 | { |
3118 | 3118 | global $current_user; |
3119 | 3119 | $owner_where = $this->getOwnerWhere($current_user->id); |
3120 | - if(empty($where)) |
|
3120 | + if (empty($where)) |
|
3121 | 3121 | { |
3122 | 3122 | $where = $owner_where; |
3123 | 3123 | } |
3124 | 3124 | else |
3125 | 3125 | { |
3126 | - $where .= ' AND '. $owner_where; |
|
3126 | + $where .= ' AND '.$owner_where; |
|
3127 | 3127 | } |
3128 | 3128 | } |
3129 | 3129 | /* BEGIN - SECURITY GROUPS */ |
3130 | 3130 | global $current_user, $sugar_config; |
3131 | - if($this->module_dir == 'Users' && !is_admin($current_user) |
|
3131 | + if ($this->module_dir == 'Users' && !is_admin($current_user) |
|
3132 | 3132 | && isset($sugar_config['securitysuite_filter_user_list']) |
3133 | 3133 | && $sugar_config['securitysuite_filter_user_list'] == true |
3134 | 3134 | ) { |
@@ -3136,36 +3136,36 @@ discard block |
||
3136 | 3136 | global $current_user; |
3137 | 3137 | $group_where = SecurityGroup::getGroupUsersWhere($current_user->id); |
3138 | 3138 | //$group_where = "user_name = 'admin'"; |
3139 | - if(empty($where)) |
|
3139 | + if (empty($where)) |
|
3140 | 3140 | { |
3141 | 3141 | $where = " (".$group_where.") "; |
3142 | 3142 | } else { |
3143 | 3143 | $where .= " AND (".$group_where.") "; |
3144 | 3144 | } |
3145 | 3145 | } else |
3146 | - if($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list') ) |
|
3146 | + if ($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list')) |
|
3147 | 3147 | { |
3148 | 3148 | require_once('modules/SecurityGroups/SecurityGroup.php'); |
3149 | 3149 | global $current_user; |
3150 | 3150 | $owner_where = $this->getOwnerWhere($current_user->id); |
3151 | - $group_where = SecurityGroup::getGroupWhere($this->table_name,$this->module_dir,$current_user->id); |
|
3152 | - if(!empty($owner_where)){ |
|
3153 | - if(empty($where)) |
|
3151 | + $group_where = SecurityGroup::getGroupWhere($this->table_name, $this->module_dir, $current_user->id); |
|
3152 | + if (!empty($owner_where)) { |
|
3153 | + if (empty($where)) |
|
3154 | 3154 | { |
3155 | - $where = " (". $owner_where." or ".$group_where.") "; |
|
3155 | + $where = " (".$owner_where." or ".$group_where.") "; |
|
3156 | 3156 | } else { |
3157 | - $where .= " AND (". $owner_where." or ".$group_where.") "; |
|
3157 | + $where .= " AND (".$owner_where." or ".$group_where.") "; |
|
3158 | 3158 | } |
3159 | 3159 | } else { |
3160 | - $where .= ' AND '. $group_where; |
|
3160 | + $where .= ' AND '.$group_where; |
|
3161 | 3161 | } |
3162 | 3162 | } |
3163 | 3163 | /* END - SECURITY GROUPS */ |
3164 | - if(!empty($params['distinct'])) |
|
3164 | + if (!empty($params['distinct'])) |
|
3165 | 3165 | { |
3166 | 3166 | $distinct = ' DISTINCT '; |
3167 | 3167 | } |
3168 | - if(empty($filter)) |
|
3168 | + if (empty($filter)) |
|
3169 | 3169 | { |
3170 | 3170 | $ret_array['select'] = " SELECT $distinct $this->table_name.* "; |
3171 | 3171 | } |
@@ -3175,21 +3175,21 @@ discard block |
||
3175 | 3175 | } |
3176 | 3176 | $ret_array['from'] = " FROM $this->table_name "; |
3177 | 3177 | $ret_array['from_min'] = $ret_array['from']; |
3178 | - $ret_array['secondary_from'] = $ret_array['from'] ; |
|
3178 | + $ret_array['secondary_from'] = $ret_array['from']; |
|
3179 | 3179 | $ret_array['where'] = ''; |
3180 | 3180 | $ret_array['order_by'] = ''; |
3181 | 3181 | //secondary selects are selects that need to be run after the primary query to retrieve additional info on main |
3182 | - if($singleSelect) |
|
3182 | + if ($singleSelect) |
|
3183 | 3183 | { |
3184 | - $ret_array['secondary_select']=& $ret_array['select']; |
|
3184 | + $ret_array['secondary_select'] = & $ret_array['select']; |
|
3185 | 3185 | $ret_array['secondary_from'] = & $ret_array['from']; |
3186 | 3186 | } |
3187 | 3187 | else |
3188 | 3188 | { |
3189 | 3189 | $ret_array['secondary_select'] = ''; |
3190 | 3190 | } |
3191 | - $custom_join = $this->getCustomJoin( empty($filter)? true: $filter ); |
|
3192 | - if((!isset($params['include_custom_fields']) || $params['include_custom_fields'])) |
|
3191 | + $custom_join = $this->getCustomJoin(empty($filter) ? true : $filter); |
|
3192 | + if ((!isset($params['include_custom_fields']) || $params['include_custom_fields'])) |
|
3193 | 3193 | { |
3194 | 3194 | $ret_array['select'] .= $custom_join['select']; |
3195 | 3195 | } |
@@ -3205,43 +3205,43 @@ discard block |
||
3205 | 3205 | } |
3206 | 3206 | |
3207 | 3207 | $joined_tables = array(); |
3208 | - if(!empty($params['joined_tables'])) |
|
3208 | + if (!empty($params['joined_tables'])) |
|
3209 | 3209 | { |
3210 | - foreach($params['joined_tables'] as $table) |
|
3210 | + foreach ($params['joined_tables'] as $table) |
|
3211 | 3211 | { |
3212 | 3212 | $joined_tables[$table] = 1; |
3213 | 3213 | } |
3214 | 3214 | } |
3215 | 3215 | |
3216 | - if(!empty($filter)) |
|
3216 | + if (!empty($filter)) |
|
3217 | 3217 | { |
3218 | 3218 | $filterKeys = array_keys($filter); |
3219 | - if(is_numeric($filterKeys[0])) |
|
3219 | + if (is_numeric($filterKeys[0])) |
|
3220 | 3220 | { |
3221 | 3221 | $fields = array(); |
3222 | - foreach($filter as $field) |
|
3222 | + foreach ($filter as $field) |
|
3223 | 3223 | { |
3224 | 3224 | $field = strtolower($field); |
3225 | 3225 | //remove out id field so we don't duplicate it |
3226 | - if ( $field == 'id' && !empty($filter) ) { |
|
3226 | + if ($field == 'id' && !empty($filter)) { |
|
3227 | 3227 | continue; |
3228 | 3228 | } |
3229 | - if(isset($this->field_defs[$field])) |
|
3229 | + if (isset($this->field_defs[$field])) |
|
3230 | 3230 | { |
3231 | - $fields[$field]= $this->field_defs[$field]; |
|
3231 | + $fields[$field] = $this->field_defs[$field]; |
|
3232 | 3232 | } |
3233 | 3233 | else |
3234 | 3234 | { |
3235 | 3235 | $fields[$field] = array('force_exists'=>true); |
3236 | 3236 | } |
3237 | 3237 | } |
3238 | - }else{ |
|
3239 | - $fields = $filter; |
|
3238 | + } else { |
|
3239 | + $fields = $filter; |
|
3240 | 3240 | } |
3241 | 3241 | } |
3242 | 3242 | else |
3243 | 3243 | { |
3244 | - $fields = $this->field_defs; |
|
3244 | + $fields = $this->field_defs; |
|
3245 | 3245 | } |
3246 | 3246 | |
3247 | 3247 | $used_join_key = array(); |
@@ -3249,7 +3249,7 @@ discard block |
||
3249 | 3249 | //walk through the fields and for every relationship field add their relationship_info field |
3250 | 3250 | //relationshipfield-aliases are resolved in SugarBean::create_new_list_query through their relationship_info field |
3251 | 3251 | $addrelate = array(); |
3252 | - foreach($fields as $field=>$value) |
|
3252 | + foreach ($fields as $field=>$value) |
|
3253 | 3253 | { |
3254 | 3254 | if (isset($this->field_defs[$field]) && isset($this->field_defs[$field]['source']) && |
3255 | 3255 | $this->field_defs[$field]['source'] == 'non-db') |
@@ -3258,27 +3258,27 @@ discard block |
||
3258 | 3258 | if ($addrelatefield) |
3259 | 3259 | $addrelate[$addrelatefield] = true; |
3260 | 3260 | } |
3261 | - if(!empty($this->field_defs[$field]['id_name'])){ |
|
3261 | + if (!empty($this->field_defs[$field]['id_name'])) { |
|
3262 | 3262 | $addrelate[$this->field_defs[$field]['id_name']] = true; |
3263 | 3263 | } |
3264 | 3264 | } |
3265 | 3265 | |
3266 | 3266 | $fields = array_merge($addrelate, $fields); |
3267 | 3267 | |
3268 | - foreach($fields as $field=>$value) |
|
3268 | + foreach ($fields as $field=>$value) |
|
3269 | 3269 | { |
3270 | 3270 | //alias is used to alias field names |
3271 | - $alias=''; |
|
3272 | - if (isset($value['alias'])) |
|
3271 | + $alias = ''; |
|
3272 | + if (isset($value['alias'])) |
|
3273 | 3273 | { |
3274 | - $alias =' as ' . $value['alias'] . ' '; |
|
3274 | + $alias = ' as '.$value['alias'].' '; |
|
3275 | 3275 | } |
3276 | 3276 | |
3277 | - if(empty($this->field_defs[$field]) || !empty($value['force_blank']) ) |
|
3277 | + if (empty($this->field_defs[$field]) || !empty($value['force_blank'])) |
|
3278 | 3278 | { |
3279 | - if(!empty($filter) && isset($filter[$field]['force_exists']) && $filter[$field]['force_exists']) |
|
3279 | + if (!empty($filter) && isset($filter[$field]['force_exists']) && $filter[$field]['force_exists']) |
|
3280 | 3280 | { |
3281 | - if ( isset($filter[$field]['force_default']) ) |
|
3281 | + if (isset($filter[$field]['force_default'])) |
|
3282 | 3282 | $ret_array['select'] .= ", {$filter[$field]['force_default']} $field "; |
3283 | 3283 | else |
3284 | 3284 | //spaces are a fix for length issue problem with unions. The union only returns the maximum number of characters from the first select statement. |
@@ -3310,14 +3310,14 @@ discard block |
||
3310 | 3310 | continue; |
3311 | 3311 | } |
3312 | 3312 | |
3313 | - if( (!isset($data['source']) || $data['source'] == 'db') && (!empty($alias) || !empty($filter) )) |
|
3313 | + if ((!isset($data['source']) || $data['source'] == 'db') && (!empty($alias) || !empty($filter))) |
|
3314 | 3314 | { |
3315 | 3315 | $ret_array['select'] .= ", $this->table_name.$field $alias"; |
3316 | 3316 | $selectedFields["$this->table_name.$field"] = true; |
3317 | - } else if( (!isset($data['source']) || $data['source'] == 'custom_fields') && (!empty($alias) || !empty($filter) )) { |
|
3317 | + } else if ((!isset($data['source']) || $data['source'] == 'custom_fields') && (!empty($alias) || !empty($filter))) { |
|
3318 | 3318 | //add this column only if it has NOT already been added to select statement string |
3319 | - $colPos = strpos($ret_array['select'],"$this->table_name"."_cstm".".$field"); |
|
3320 | - if(!$colPos || $colPos<0) |
|
3319 | + $colPos = strpos($ret_array['select'], "$this->table_name"."_cstm".".$field"); |
|
3320 | + if (!$colPos || $colPos < 0) |
|
3321 | 3321 | { |
3322 | 3322 | $ret_array['select'] .= ", $this->table_name"."_cstm".".$field $alias"; |
3323 | 3323 | } |
@@ -3325,22 +3325,22 @@ discard block |
||
3325 | 3325 | $selectedFields["$this->table_name.$field"] = true; |
3326 | 3326 | } |
3327 | 3327 | |
3328 | - if($data['type'] != 'relate' && isset($data['db_concat_fields'])) |
|
3328 | + if ($data['type'] != 'relate' && isset($data['db_concat_fields'])) |
|
3329 | 3329 | { |
3330 | - $ret_array['select'] .= ", " . $this->db->concat($this->table_name, $data['db_concat_fields']) . " as $field"; |
|
3330 | + $ret_array['select'] .= ", ".$this->db->concat($this->table_name, $data['db_concat_fields'])." as $field"; |
|
3331 | 3331 | $selectedFields[$this->db->concat($this->table_name, $data['db_concat_fields'])] = true; |
3332 | 3332 | } |
3333 | 3333 | //Custom relate field or relate fields built in module builder which have no link field associated. |
3334 | 3334 | if ($data['type'] == 'relate' && (isset($data['custom_module']) || isset($data['ext2']))) { |
3335 | - $joinTableAlias = 'jt' . $jtcount; |
|
3335 | + $joinTableAlias = 'jt'.$jtcount; |
|
3336 | 3336 | $relateJoinInfo = $this->custom_fields->getRelateJoin($data, $joinTableAlias, false); |
3337 | 3337 | $ret_array['select'] .= $relateJoinInfo['select']; |
3338 | 3338 | $ret_array['from'] .= $relateJoinInfo['from']; |
3339 | 3339 | //Replace any references to the relationship in the where clause with the new alias |
3340 | 3340 | //If the link isn't set, assume that search used the local table for the field |
3341 | 3341 | $searchTable = isset($data['link']) ? $relateJoinInfo['rel_table'] : $this->table_name; |
3342 | - $field_name = $relateJoinInfo['rel_table'] . '.' . !empty($data['name'])?$data['name']:'name'; |
|
3343 | - $where = preg_replace('/(^|[\s(])' . $field_name . '/' , '${1}' . $relateJoinInfo['name_field'], $where); |
|
3342 | + $field_name = $relateJoinInfo['rel_table'].'.'.!empty($data['name']) ? $data['name'] : 'name'; |
|
3343 | + $where = preg_replace('/(^|[\s(])'.$field_name.'/', '${1}'.$relateJoinInfo['name_field'], $where); |
|
3344 | 3344 | $jtcount++; |
3345 | 3345 | } |
3346 | 3346 | //Parent Field |
@@ -3348,7 +3348,7 @@ discard block |
||
3348 | 3348 | //See if we need to join anything by inspecting the where clause |
3349 | 3349 | $match = preg_match('/(^|[\s(])parent_(\w+)_(\w+)\.name/', $where, $matches); |
3350 | 3350 | if ($match) { |
3351 | - $joinTableAlias = 'jt' . $jtcount; |
|
3351 | + $joinTableAlias = 'jt'.$jtcount; |
|
3352 | 3352 | $joinModule = $matches[2]; |
3353 | 3353 | $joinTable = $matches[3]; |
3354 | 3354 | $localTable = $this->table_name; |
@@ -3362,7 +3362,7 @@ discard block |
||
3362 | 3362 | if (isset($rel_mod->field_defs['name'])) |
3363 | 3363 | { |
3364 | 3364 | $name_field_def = $rel_mod->field_defs['name']; |
3365 | - if(isset($name_field_def['db_concat_fields'])) |
|
3365 | + if (isset($name_field_def['db_concat_fields'])) |
|
3366 | 3366 | { |
3367 | 3367 | $nameField = $this->db->concat($joinTableAlias, $name_field_def['db_concat_fields']); |
3368 | 3368 | } |
@@ -3371,7 +3371,7 @@ discard block |
||
3371 | 3371 | $ret_array['from'] .= " LEFT JOIN $joinTable $joinTableAlias |
3372 | 3372 | ON $localTable.{$data['id_name']} = $joinTableAlias.id"; |
3373 | 3373 | //Replace any references to the relationship in the where clause with the new alias |
3374 | - $where = preg_replace('/(^|[\s(])parent_' . $joinModule . '_' . $joinTable . '\.name/', '${1}' . $nameField, $where); |
|
3374 | + $where = preg_replace('/(^|[\s(])parent_'.$joinModule.'_'.$joinTable.'\.name/', '${1}'.$nameField, $where); |
|
3375 | 3375 | $jtcount++; |
3376 | 3376 | } |
3377 | 3377 | } |
@@ -3379,10 +3379,10 @@ discard block |
||
3379 | 3379 | if ($this->is_relate_field($field)) |
3380 | 3380 | { |
3381 | 3381 | $this->load_relationship($data['link']); |
3382 | - if(!empty($this->$data['link'])) |
|
3382 | + if (!empty($this->$data['link'])) |
|
3383 | 3383 | { |
3384 | 3384 | $params = array(); |
3385 | - if(empty($join_type)) |
|
3385 | + if (empty($join_type)) |
|
3386 | 3386 | { |
3387 | 3387 | $params['join_type'] = ' LEFT JOIN '; |
3388 | 3388 | } |
@@ -3390,22 +3390,22 @@ discard block |
||
3390 | 3390 | { |
3391 | 3391 | $params['join_type'] = $join_type; |
3392 | 3392 | } |
3393 | - if(isset($data['join_name'])) |
|
3393 | + if (isset($data['join_name'])) |
|
3394 | 3394 | { |
3395 | 3395 | $params['join_table_alias'] = $data['join_name']; |
3396 | 3396 | } |
3397 | 3397 | else |
3398 | 3398 | { |
3399 | - $params['join_table_alias'] = 'jt' . $jtcount; |
|
3399 | + $params['join_table_alias'] = 'jt'.$jtcount; |
|
3400 | 3400 | |
3401 | 3401 | } |
3402 | - if(isset($data['join_link_name'])) |
|
3402 | + if (isset($data['join_link_name'])) |
|
3403 | 3403 | { |
3404 | 3404 | $params['join_table_link_alias'] = $data['join_link_name']; |
3405 | 3405 | } |
3406 | 3406 | else |
3407 | 3407 | { |
3408 | - $params['join_table_link_alias'] = 'jtl' . $jtcount; |
|
3408 | + $params['join_table_link_alias'] = 'jtl'.$jtcount; |
|
3409 | 3409 | } |
3410 | 3410 | $join_primary = !isset($data['join_primary']) || $data['join_primary']; |
3411 | 3411 | |
@@ -3418,126 +3418,126 @@ discard block |
||
3418 | 3418 | global $beanFiles, $beanList; |
3419 | 3419 | // °3/21/2014 FIX NS-TEAM - Relationship fields could not be displayed in subpanels |
3420 | 3420 | //if($data['rname'] && !empty($beanFiles[$beanList[$rel_module]])) { |
3421 | - if(isset($data['rname']) && $data['rname'] == 'name' && !empty($beanFiles[$beanList[$rel_module]])) { |
|
3421 | + if (isset($data['rname']) && $data['rname'] == 'name' && !empty($beanFiles[$beanList[$rel_module]])) { |
|
3422 | 3422 | |
3423 | 3423 | //create an instance of the related bean |
3424 | 3424 | require_once($beanFiles[$beanList[$rel_module]]); |
3425 | 3425 | $rel_mod = new $beanList[$rel_module](); |
3426 | 3426 | //if bean has first and last name fields, then name should be concatenated |
3427 | - if(isset($rel_mod->field_name_map['first_name']) && isset($rel_mod->field_name_map['last_name'])){ |
|
3427 | + if (isset($rel_mod->field_name_map['first_name']) && isset($rel_mod->field_name_map['last_name'])) { |
|
3428 | 3428 | $data['db_concat_fields'] = array(0=>'first_name', 1=>'last_name'); |
3429 | 3429 | } |
3430 | 3430 | } |
3431 | 3431 | |
3432 | 3432 | |
3433 | - if($join['type'] == 'many-to-many') |
|
3433 | + if ($join['type'] == 'many-to-many') |
|
3434 | 3434 | { |
3435 | - if(empty($ret_array['secondary_select'])) |
|
3435 | + if (empty($ret_array['secondary_select'])) |
|
3436 | 3436 | { |
3437 | 3437 | $ret_array['secondary_select'] = " SELECT $this->table_name.id ref_id "; |
3438 | 3438 | |
3439 | - if(!empty($beanFiles[$beanList[$rel_module]]) && $join_primary) |
|
3439 | + if (!empty($beanFiles[$beanList[$rel_module]]) && $join_primary) |
|
3440 | 3440 | { |
3441 | 3441 | require_once($beanFiles[$beanList[$rel_module]]); |
3442 | 3442 | $rel_mod = new $beanList[$rel_module](); |
3443 | - if(isset($rel_mod->field_defs['assigned_user_id'])) |
|
3443 | + if (isset($rel_mod->field_defs['assigned_user_id'])) |
|
3444 | 3444 | { |
3445 | - $ret_array['secondary_select'].= " , ". $params['join_table_alias'] . ".assigned_user_id {$field}_owner, '$rel_module' {$field}_mod"; |
|
3445 | + $ret_array['secondary_select'] .= " , ".$params['join_table_alias'].".assigned_user_id {$field}_owner, '$rel_module' {$field}_mod"; |
|
3446 | 3446 | } |
3447 | 3447 | else |
3448 | 3448 | { |
3449 | - if(isset($rel_mod->field_defs['created_by'])) |
|
3449 | + if (isset($rel_mod->field_defs['created_by'])) |
|
3450 | 3450 | { |
3451 | - $ret_array['secondary_select'].= " , ". $params['join_table_alias'] . ".created_by {$field}_owner , '$rel_module' {$field}_mod"; |
|
3451 | + $ret_array['secondary_select'] .= " , ".$params['join_table_alias'].".created_by {$field}_owner , '$rel_module' {$field}_mod"; |
|
3452 | 3452 | } |
3453 | 3453 | } |
3454 | 3454 | } |
3455 | 3455 | } |
3456 | 3456 | |
3457 | - if(isset($data['db_concat_fields'])) |
|
3457 | + if (isset($data['db_concat_fields'])) |
|
3458 | 3458 | { |
3459 | - $ret_array['secondary_select'] .= ' , ' . $this->db->concat($params['join_table_alias'], $data['db_concat_fields']) . ' ' . $field; |
|
3459 | + $ret_array['secondary_select'] .= ' , '.$this->db->concat($params['join_table_alias'], $data['db_concat_fields']).' '.$field; |
|
3460 | 3460 | } |
3461 | 3461 | else |
3462 | 3462 | { |
3463 | - if(!isset($data['relationship_fields'])) |
|
3463 | + if (!isset($data['relationship_fields'])) |
|
3464 | 3464 | { |
3465 | - $ret_array['secondary_select'] .= ' , ' . $params['join_table_alias'] . '.' . $data['rname'] . ' ' . $field; |
|
3465 | + $ret_array['secondary_select'] .= ' , '.$params['join_table_alias'].'.'.$data['rname'].' '.$field; |
|
3466 | 3466 | } |
3467 | 3467 | } |
3468 | - if(!$singleSelect) |
|
3468 | + if (!$singleSelect) |
|
3469 | 3469 | { |
3470 | 3470 | $ret_array['select'] .= ", ' ' $field "; |
3471 | 3471 | } |
3472 | - $count_used =0; |
|
3473 | - foreach($used_join_key as $used_key) { |
|
3474 | - if($used_key == $join['rel_key']) $count_used++; |
|
3472 | + $count_used = 0; |
|
3473 | + foreach ($used_join_key as $used_key) { |
|
3474 | + if ($used_key == $join['rel_key']) $count_used++; |
|
3475 | 3475 | } |
3476 | - if($count_used <= 1) {//27416, the $ret_array['secondary_select'] should always generate, regardless the dbtype |
|
3476 | + if ($count_used <= 1) {//27416, the $ret_array['secondary_select'] should always generate, regardless the dbtype |
|
3477 | 3477 | // add rel_key only if it was not aready added |
3478 | - if(!$singleSelect) |
|
3478 | + if (!$singleSelect) |
|
3479 | 3479 | { |
3480 | - $ret_array['select'] .= ", ' ' " . $join['rel_key'] . ' '; |
|
3480 | + $ret_array['select'] .= ", ' ' ".$join['rel_key'].' '; |
|
3481 | 3481 | } |
3482 | - $ret_array['secondary_select'] .= ', ' . $params['join_table_link_alias'].'.'. $join['rel_key'] .' ' . $join['rel_key']; |
|
3482 | + $ret_array['secondary_select'] .= ', '.$params['join_table_link_alias'].'.'.$join['rel_key'].' '.$join['rel_key']; |
|
3483 | 3483 | } |
3484 | - if(isset($data['relationship_fields'])) |
|
3484 | + if (isset($data['relationship_fields'])) |
|
3485 | 3485 | { |
3486 | - foreach($data['relationship_fields'] as $r_name=>$alias_name) |
|
3486 | + foreach ($data['relationship_fields'] as $r_name=>$alias_name) |
|
3487 | 3487 | { |
3488 | - if(!empty( $secondarySelectedFields[$alias_name]))continue; |
|
3489 | - $ret_array['secondary_select'] .= ', ' . $params['join_table_link_alias'].'.'. $r_name .' ' . $alias_name; |
|
3488 | + if (!empty($secondarySelectedFields[$alias_name]))continue; |
|
3489 | + $ret_array['secondary_select'] .= ', '.$params['join_table_link_alias'].'.'.$r_name.' '.$alias_name; |
|
3490 | 3490 | $secondarySelectedFields[$alias_name] = true; |
3491 | 3491 | } |
3492 | 3492 | } |
3493 | - if(!$table_joined) |
|
3493 | + if (!$table_joined) |
|
3494 | 3494 | { |
3495 | - $ret_array['secondary_from'] .= ' ' . $join['join']. ' AND ' . $params['join_table_alias'].'.deleted=0'; |
|
3495 | + $ret_array['secondary_from'] .= ' '.$join['join'].' AND '.$params['join_table_alias'].'.deleted=0'; |
|
3496 | 3496 | if (isset($data['link_type']) && $data['link_type'] == 'relationship_info' && ($parentbean instanceOf SugarBean)) |
3497 | 3497 | { |
3498 | - $ret_array['secondary_where'] = $params['join_table_link_alias'] . '.' . $join['rel_key']. "='" .$parentbean->id . "'"; |
|
3498 | + $ret_array['secondary_where'] = $params['join_table_link_alias'].'.'.$join['rel_key']."='".$parentbean->id."'"; |
|
3499 | 3499 | } |
3500 | 3500 | } |
3501 | 3501 | } |
3502 | 3502 | else |
3503 | 3503 | { |
3504 | - if(isset($data['db_concat_fields'])) |
|
3504 | + if (isset($data['db_concat_fields'])) |
|
3505 | 3505 | { |
3506 | - $ret_array['select'] .= ' , ' . $this->db->concat($params['join_table_alias'], $data['db_concat_fields']) . ' ' . $field; |
|
3506 | + $ret_array['select'] .= ' , '.$this->db->concat($params['join_table_alias'], $data['db_concat_fields']).' '.$field; |
|
3507 | 3507 | } |
3508 | 3508 | else |
3509 | 3509 | { |
3510 | - $ret_array['select'] .= ' , ' . $params['join_table_alias'] . '.' . $data['rname'] . ' ' . $field; |
|
3510 | + $ret_array['select'] .= ' , '.$params['join_table_alias'].'.'.$data['rname'].' '.$field; |
|
3511 | 3511 | } |
3512 | - if(isset($data['additionalFields'])){ |
|
3513 | - foreach($data['additionalFields'] as $k=>$v){ |
|
3512 | + if (isset($data['additionalFields'])) { |
|
3513 | + foreach ($data['additionalFields'] as $k=>$v) { |
|
3514 | 3514 | if (!empty($data['id_name']) && $data['id_name'] == $v && !empty($fields[$data['id_name']])) { |
3515 | 3515 | continue; |
3516 | 3516 | } |
3517 | - $ret_array['select'] .= ' , ' . $params['join_table_alias'] . '.' . $k . ' ' . $v; |
|
3517 | + $ret_array['select'] .= ' , '.$params['join_table_alias'].'.'.$k.' '.$v; |
|
3518 | 3518 | } |
3519 | 3519 | } |
3520 | - if(!$table_joined) |
|
3520 | + if (!$table_joined) |
|
3521 | 3521 | { |
3522 | - $ret_array['from'] .= ' ' . $join['join']. ' AND ' . $params['join_table_alias'].'.deleted=0'; |
|
3523 | - if(!empty($beanList[$rel_module]) && !empty($beanFiles[$beanList[$rel_module]])) |
|
3522 | + $ret_array['from'] .= ' '.$join['join'].' AND '.$params['join_table_alias'].'.deleted=0'; |
|
3523 | + if (!empty($beanList[$rel_module]) && !empty($beanFiles[$beanList[$rel_module]])) |
|
3524 | 3524 | { |
3525 | 3525 | require_once($beanFiles[$beanList[$rel_module]]); |
3526 | 3526 | $rel_mod = new $beanList[$rel_module](); |
3527 | - if(isset($value['target_record_key']) && !empty($filter)) |
|
3527 | + if (isset($value['target_record_key']) && !empty($filter)) |
|
3528 | 3528 | { |
3529 | 3529 | $selectedFields[$this->table_name.'.'.$value['target_record_key']] = true; |
3530 | 3530 | $ret_array['select'] .= " , $this->table_name.{$value['target_record_key']} "; |
3531 | 3531 | } |
3532 | - if(isset($rel_mod->field_defs['assigned_user_id'])) |
|
3532 | + if (isset($rel_mod->field_defs['assigned_user_id'])) |
|
3533 | 3533 | { |
3534 | - $ret_array['select'] .= ' , ' .$params['join_table_alias'] . '.assigned_user_id ' . $field . '_owner'; |
|
3534 | + $ret_array['select'] .= ' , '.$params['join_table_alias'].'.assigned_user_id '.$field.'_owner'; |
|
3535 | 3535 | } |
3536 | 3536 | else |
3537 | 3537 | { |
3538 | - $ret_array['select'] .= ' , ' .$params['join_table_alias'] . '.created_by ' . $field . '_owner'; |
|
3538 | + $ret_array['select'] .= ' , '.$params['join_table_alias'].'.created_by '.$field.'_owner'; |
|
3539 | 3539 | } |
3540 | - $ret_array['select'] .= " , '".$rel_module ."' " . $field . '_mod'; |
|
3540 | + $ret_array['select'] .= " , '".$rel_module."' ".$field.'_mod'; |
|
3541 | 3541 | |
3542 | 3542 | } |
3543 | 3543 | } |
@@ -3545,65 +3545,65 @@ discard block |
||
3545 | 3545 | // To fix SOAP stuff where we are trying to retrieve all the accounts data where accounts.id = .. |
3546 | 3546 | // and this code changes accounts to jt4 as there is a self join with the accounts table. |
3547 | 3547 | //Martin fix #27494 |
3548 | - if(isset($data['db_concat_fields'])){ |
|
3548 | + if (isset($data['db_concat_fields'])) { |
|
3549 | 3549 | $buildWhere = false; |
3550 | - if(in_array('first_name', $data['db_concat_fields']) && in_array('last_name', $data['db_concat_fields'])) |
|
3550 | + if (in_array('first_name', $data['db_concat_fields']) && in_array('last_name', $data['db_concat_fields'])) |
|
3551 | 3551 | { |
3552 | 3552 | $exp = '/\(\s*?'.$data['name'].'.*?\%\'\s*?\)/'; |
3553 | - if(preg_match($exp, $where, $matches)) |
|
3553 | + if (preg_match($exp, $where, $matches)) |
|
3554 | 3554 | { |
3555 | 3555 | $search_expression = $matches[0]; |
3556 | 3556 | //Create three search conditions - first + last, first, last |
3557 | - $first_name_search = str_replace($data['name'], $params['join_table_alias'] . '.first_name', $search_expression); |
|
3558 | - $last_name_search = str_replace($data['name'], $params['join_table_alias'] . '.last_name', $search_expression); |
|
3557 | + $first_name_search = str_replace($data['name'], $params['join_table_alias'].'.first_name', $search_expression); |
|
3558 | + $last_name_search = str_replace($data['name'], $params['join_table_alias'].'.last_name', $search_expression); |
|
3559 | 3559 | $full_name_search = str_replace($data['name'], $this->db->concat($params['join_table_alias'], $data['db_concat_fields']), $search_expression); |
3560 | 3560 | $buildWhere = true; |
3561 | - $where = str_replace($search_expression, '(' . $full_name_search . ' OR ' . $first_name_search . ' OR ' . $last_name_search . ')', $where); |
|
3561 | + $where = str_replace($search_expression, '('.$full_name_search.' OR '.$first_name_search.' OR '.$last_name_search.')', $where); |
|
3562 | 3562 | } |
3563 | 3563 | } |
3564 | 3564 | |
3565 | - if(!$buildWhere) |
|
3565 | + if (!$buildWhere) |
|
3566 | 3566 | { |
3567 | 3567 | $db_field = $this->db->concat($params['join_table_alias'], $data['db_concat_fields']); |
3568 | 3568 | $where = preg_replace('/'.$data['name'].'/', $db_field, $where); |
3569 | 3569 | |
3570 | 3570 | // For relationship fields replace their alias by the corresponsding link table and r_name |
3571 | - if(isset($data['relationship_fields'])) |
|
3572 | - foreach($data['relationship_fields'] as $r_name=>$alias_name) |
|
3571 | + if (isset($data['relationship_fields'])) |
|
3572 | + foreach ($data['relationship_fields'] as $r_name=>$alias_name) |
|
3573 | 3573 | { |
3574 | 3574 | $db_field = $this->db->concat($params['join_table_link_alias'], $r_name); |
3575 | - $where = preg_replace('/' . $alias_name . '/', $db_field, $where); |
|
3575 | + $where = preg_replace('/'.$alias_name.'/', $db_field, $where); |
|
3576 | 3576 | } |
3577 | 3577 | } |
3578 | - }else{ |
|
3579 | - $where = preg_replace('/(^|[\s(])' . $data['name'] . '/', '${1}' . $params['join_table_alias'] . '.'.$data['rname'], $where); |
|
3578 | + } else { |
|
3579 | + $where = preg_replace('/(^|[\s(])'.$data['name'].'/', '${1}'.$params['join_table_alias'].'.'.$data['rname'], $where); |
|
3580 | 3580 | |
3581 | 3581 | // For relationship fields replace their alias by the corresponsding link table and r_name |
3582 | - if(isset($data['relationship_fields'])) |
|
3583 | - foreach($data['relationship_fields'] as $r_name=>$alias_name) |
|
3584 | - $where = preg_replace('/(^|[\s(])' . $alias_name . '/', '${1}' . $params['join_table_link_alias'] . '.'.$r_name, $where); |
|
3582 | + if (isset($data['relationship_fields'])) |
|
3583 | + foreach ($data['relationship_fields'] as $r_name=>$alias_name) |
|
3584 | + $where = preg_replace('/(^|[\s(])'.$alias_name.'/', '${1}'.$params['join_table_link_alias'].'.'.$r_name, $where); |
|
3585 | 3585 | } |
3586 | - if(!$table_joined) |
|
3586 | + if (!$table_joined) |
|
3587 | 3587 | { |
3588 | - $joined_tables[$params['join_table_alias']]=1; |
|
3589 | - $joined_tables[$params['join_table_link_alias']]=1; |
|
3588 | + $joined_tables[$params['join_table_alias']] = 1; |
|
3589 | + $joined_tables[$params['join_table_link_alias']] = 1; |
|
3590 | 3590 | } |
3591 | 3591 | |
3592 | 3592 | $jtcount++; |
3593 | 3593 | } |
3594 | 3594 | } |
3595 | 3595 | } |
3596 | - if(!empty($filter)) |
|
3596 | + if (!empty($filter)) |
|
3597 | 3597 | { |
3598 | - if(isset($this->field_defs['assigned_user_id']) && empty($selectedFields[$this->table_name.'.assigned_user_id'])) |
|
3598 | + if (isset($this->field_defs['assigned_user_id']) && empty($selectedFields[$this->table_name.'.assigned_user_id'])) |
|
3599 | 3599 | { |
3600 | 3600 | $ret_array['select'] .= ", $this->table_name.assigned_user_id "; |
3601 | 3601 | } |
3602 | - else if(isset($this->field_defs['created_by']) && empty($selectedFields[$this->table_name.'.created_by'])) |
|
3602 | + else if (isset($this->field_defs['created_by']) && empty($selectedFields[$this->table_name.'.created_by'])) |
|
3603 | 3603 | { |
3604 | 3604 | $ret_array['select'] .= ", $this->table_name.created_by "; |
3605 | 3605 | } |
3606 | - if(isset($this->field_defs['system_id']) && empty($selectedFields[$this->table_name.'.system_id'])) |
|
3606 | + if (isset($this->field_defs['system_id']) && empty($selectedFields[$this->table_name.'.system_id'])) |
|
3607 | 3607 | { |
3608 | 3608 | $ret_array['select'] .= ", $this->table_name.system_id "; |
3609 | 3609 | } |
@@ -3611,21 +3611,21 @@ discard block |
||
3611 | 3611 | } |
3612 | 3612 | |
3613 | 3613 | if ($ifListForExport) { |
3614 | - if(isset($this->field_defs['email1'])) { |
|
3615 | - $ret_array['select'].= " ,email_addresses.email_address email1"; |
|
3616 | - $ret_array['from'].= " LEFT JOIN email_addr_bean_rel on {$this->table_name}.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='{$this->module_dir}' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1 LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id "; |
|
3614 | + if (isset($this->field_defs['email1'])) { |
|
3615 | + $ret_array['select'] .= " ,email_addresses.email_address email1"; |
|
3616 | + $ret_array['from'] .= " LEFT JOIN email_addr_bean_rel on {$this->table_name}.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='{$this->module_dir}' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1 LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id "; |
|
3617 | 3617 | } |
3618 | 3618 | } |
3619 | 3619 | |
3620 | 3620 | $where_auto = '1=1'; |
3621 | - if($show_deleted == 0) |
|
3621 | + if ($show_deleted == 0) |
|
3622 | 3622 | { |
3623 | 3623 | $where_auto = "$this->table_name.deleted=0"; |
3624 | - }else if($show_deleted == 1) |
|
3624 | + } else if ($show_deleted == 1) |
|
3625 | 3625 | { |
3626 | 3626 | $where_auto = "$this->table_name.deleted=1"; |
3627 | 3627 | } |
3628 | - if($where != "") |
|
3628 | + if ($where != "") |
|
3629 | 3629 | $ret_array['where'] = " where ($where) AND $where_auto"; |
3630 | 3630 | else |
3631 | 3631 | $ret_array['where'] = " where $where_auto"; |
@@ -3633,21 +3633,21 @@ discard block |
||
3633 | 3633 | //make call to process the order by clause |
3634 | 3634 | $order_by = $this->process_order_by($order_by); |
3635 | 3635 | if (!empty($order_by)) { |
3636 | - $ret_array['order_by'] = " ORDER BY " . $order_by; |
|
3636 | + $ret_array['order_by'] = " ORDER BY ".$order_by; |
|
3637 | 3637 | } |
3638 | - if($singleSelect) |
|
3638 | + if ($singleSelect) |
|
3639 | 3639 | { |
3640 | 3640 | unset($ret_array['secondary_where']); |
3641 | 3641 | unset($ret_array['secondary_from']); |
3642 | 3642 | unset($ret_array['secondary_select']); |
3643 | 3643 | } |
3644 | 3644 | |
3645 | - if($return_array) |
|
3645 | + if ($return_array) |
|
3646 | 3646 | { |
3647 | 3647 | return $ret_array; |
3648 | 3648 | } |
3649 | 3649 | |
3650 | - return $ret_array['select'] . $ret_array['from'] . $ret_array['where']. $ret_array['order_by']; |
|
3650 | + return $ret_array['select'].$ret_array['from'].$ret_array['where'].$ret_array['order_by']; |
|
3651 | 3651 | } |
3652 | 3652 | |
3653 | 3653 | // Check if field is defined through a relationship_info field, add this field when not present |
@@ -3656,7 +3656,7 @@ discard block |
||
3656 | 3656 | foreach ($this->field_defs as $field_def => $value) |
3657 | 3657 | { |
3658 | 3658 | if (isset($value['relationship_fields']) && |
3659 | - in_array($field, $value['relationship_fields']) ) |
|
3659 | + in_array($field, $value['relationship_fields'])) |
|
3660 | 3660 | return $field_def; |
3661 | 3661 | } |
3662 | 3662 | |
@@ -3676,13 +3676,13 @@ discard block |
||
3676 | 3676 | global $beanList, $beanFiles; |
3677 | 3677 | $templates = array(); |
3678 | 3678 | $parent_child_map = array(); |
3679 | - foreach($type_info as $children_info) |
|
3679 | + foreach ($type_info as $children_info) |
|
3680 | 3680 | { |
3681 | - foreach($children_info as $child_info) |
|
3681 | + foreach ($children_info as $child_info) |
|
3682 | 3682 | { |
3683 | - if($child_info['type'] == 'parent') |
|
3683 | + if ($child_info['type'] == 'parent') |
|
3684 | 3684 | { |
3685 | - if(empty($templates[$child_info['parent_type']])) |
|
3685 | + if (empty($templates[$child_info['parent_type']])) |
|
3686 | 3686 | { |
3687 | 3687 | //Test emails will have an invalid parent_type, don't try to load the non-existent parent bean |
3688 | 3688 | if ($child_info['parent_type'] == 'test') { |
@@ -3690,7 +3690,7 @@ discard block |
||
3690 | 3690 | } |
3691 | 3691 | $class = $beanList[$child_info['parent_type']]; |
3692 | 3692 | // Added to avoid error below; just silently fail and write message to log |
3693 | - if ( empty($beanFiles[$class]) ) { |
|
3693 | + if (empty($beanFiles[$class])) { |
|
3694 | 3694 | $GLOBALS['log']->error($this->object_name.'::retrieve_parent_fields() - cannot load class "'.$class.'", skip loading.'); |
3695 | 3695 | continue; |
3696 | 3696 | } |
@@ -3698,30 +3698,30 @@ discard block |
||
3698 | 3698 | $templates[$child_info['parent_type']] = new $class(); |
3699 | 3699 | } |
3700 | 3700 | |
3701 | - if(empty($queries[$child_info['parent_type']])) |
|
3701 | + if (empty($queries[$child_info['parent_type']])) |
|
3702 | 3702 | { |
3703 | 3703 | $queries[$child_info['parent_type']] = "SELECT id "; |
3704 | 3704 | $field_def = $templates[$child_info['parent_type']]->field_defs['name']; |
3705 | - if(isset($field_def['db_concat_fields'])) |
|
3705 | + if (isset($field_def['db_concat_fields'])) |
|
3706 | 3706 | { |
3707 | - $queries[$child_info['parent_type']] .= ' , ' . $this->db->concat($templates[$child_info['parent_type']]->table_name, $field_def['db_concat_fields']) . ' parent_name'; |
|
3707 | + $queries[$child_info['parent_type']] .= ' , '.$this->db->concat($templates[$child_info['parent_type']]->table_name, $field_def['db_concat_fields']).' parent_name'; |
|
3708 | 3708 | } |
3709 | 3709 | else |
3710 | 3710 | { |
3711 | 3711 | $queries[$child_info['parent_type']] .= ' , name parent_name'; |
3712 | 3712 | } |
3713 | - if(isset($templates[$child_info['parent_type']]->field_defs['assigned_user_id'])) |
|
3713 | + if (isset($templates[$child_info['parent_type']]->field_defs['assigned_user_id'])) |
|
3714 | 3714 | { |
3715 | - $queries[$child_info['parent_type']] .= ", assigned_user_id parent_name_owner , '{$child_info['parent_type']}' parent_name_mod";; |
|
3716 | - }else if(isset($templates[$child_info['parent_type']]->field_defs['created_by'])) |
|
3715 | + $queries[$child_info['parent_type']] .= ", assigned_user_id parent_name_owner , '{$child_info['parent_type']}' parent_name_mod"; ; |
|
3716 | + } else if (isset($templates[$child_info['parent_type']]->field_defs['created_by'])) |
|
3717 | 3717 | { |
3718 | 3718 | $queries[$child_info['parent_type']] .= ", created_by parent_name_owner, '{$child_info['parent_type']}' parent_name_mod"; |
3719 | 3719 | } |
3720 | - $queries[$child_info['parent_type']] .= " FROM " . $templates[$child_info['parent_type']]->table_name ." WHERE id IN ('{$child_info['parent_id']}'"; |
|
3720 | + $queries[$child_info['parent_type']] .= " FROM ".$templates[$child_info['parent_type']]->table_name." WHERE id IN ('{$child_info['parent_id']}'"; |
|
3721 | 3721 | } |
3722 | 3722 | else |
3723 | 3723 | { |
3724 | - if(empty($parent_child_map[$child_info['parent_id']])) |
|
3724 | + if (empty($parent_child_map[$child_info['parent_id']])) |
|
3725 | 3725 | $queries[$child_info['parent_type']] .= " ,'{$child_info['parent_id']}'"; |
3726 | 3726 | } |
3727 | 3727 | $parent_child_map[$child_info['parent_id']][] = $child_info['child_id']; |
@@ -3729,21 +3729,21 @@ discard block |
||
3729 | 3729 | } |
3730 | 3730 | } |
3731 | 3731 | $results = array(); |
3732 | - foreach($queries as $query) |
|
3732 | + foreach ($queries as $query) |
|
3733 | 3733 | { |
3734 | - $result = $this->db->query($query . ')'); |
|
3735 | - while($row = $this->db->fetchByAssoc($result)) |
|
3734 | + $result = $this->db->query($query.')'); |
|
3735 | + while ($row = $this->db->fetchByAssoc($result)) |
|
3736 | 3736 | { |
3737 | 3737 | $results[$row['id']] = $row; |
3738 | 3738 | } |
3739 | 3739 | } |
3740 | 3740 | |
3741 | 3741 | $child_results = array(); |
3742 | - foreach($parent_child_map as $parent_key=>$parent_child) |
|
3742 | + foreach ($parent_child_map as $parent_key=>$parent_child) |
|
3743 | 3743 | { |
3744 | - foreach($parent_child as $child) |
|
3744 | + foreach ($parent_child as $child) |
|
3745 | 3745 | { |
3746 | - if(isset( $results[$parent_key])) |
|
3746 | + if (isset($results[$parent_key])) |
|
3747 | 3747 | { |
3748 | 3748 | $child_results[$child] = $results[$parent_key]; |
3749 | 3749 | } |
@@ -3763,7 +3763,7 @@ discard block |
||
3763 | 3763 | * @param string $where Optional, additional filter criteria. |
3764 | 3764 | * @return array Fetched data |
3765 | 3765 | */ |
3766 | - function process_list_query($query, $row_offset, $limit= -1, $max_per_page = -1, $where = '') |
|
3766 | + function process_list_query($query, $row_offset, $limit = -1, $max_per_page = -1, $where = '') |
|
3767 | 3767 | { |
3768 | 3768 | global $sugar_config; |
3769 | 3769 | $db = DBManagerFactory::getInstance('listviews'); |
@@ -3772,33 +3772,33 @@ discard block |
||
3772 | 3772 | */ |
3773 | 3773 | $toEnd = strval($row_offset) == 'end'; |
3774 | 3774 | $GLOBALS['log']->debug("process_list_query: ".$query); |
3775 | - if($max_per_page == -1) |
|
3775 | + if ($max_per_page == -1) |
|
3776 | 3776 | { |
3777 | - $max_per_page = $sugar_config['list_max_entries_per_page']; |
|
3777 | + $max_per_page = $sugar_config['list_max_entries_per_page']; |
|
3778 | 3778 | } |
3779 | 3779 | // Check to see if we have a count query available. |
3780 | - if(empty($sugar_config['disable_count_query']) || $toEnd) |
|
3780 | + if (empty($sugar_config['disable_count_query']) || $toEnd) |
|
3781 | 3781 | { |
3782 | 3782 | $count_query = $this->create_list_count_query($query); |
3783 | - if(!empty($count_query) && (empty($limit) || $limit == -1)) |
|
3783 | + if (!empty($count_query) && (empty($limit) || $limit == -1)) |
|
3784 | 3784 | { |
3785 | 3785 | // We have a count query. Run it and get the results. |
3786 | 3786 | $result = $db->query($count_query, true, "Error running count query for $this->object_name List: "); |
3787 | 3787 | $assoc = $db->fetchByAssoc($result); |
3788 | - if(!empty($assoc['c'])) |
|
3788 | + if (!empty($assoc['c'])) |
|
3789 | 3789 | { |
3790 | 3790 | $rows_found = $assoc['c']; |
3791 | 3791 | $limit = $sugar_config['list_max_entries_per_page']; |
3792 | 3792 | } |
3793 | - if( $toEnd) |
|
3793 | + if ($toEnd) |
|
3794 | 3794 | { |
3795 | - $row_offset = (floor(($rows_found -1) / $limit)) * $limit; |
|
3795 | + $row_offset = (floor(($rows_found - 1) / $limit)) * $limit; |
|
3796 | 3796 | } |
3797 | 3797 | } |
3798 | 3798 | } |
3799 | 3799 | else |
3800 | 3800 | { |
3801 | - if((empty($limit) || $limit == -1)) |
|
3801 | + if ((empty($limit) || $limit == -1)) |
|
3802 | 3802 | { |
3803 | 3803 | $limit = $max_per_page + 1; |
3804 | 3804 | $max_per_page = $limit; |
@@ -3806,17 +3806,17 @@ discard block |
||
3806 | 3806 | |
3807 | 3807 | } |
3808 | 3808 | |
3809 | - if(empty($row_offset)) |
|
3809 | + if (empty($row_offset)) |
|
3810 | 3810 | { |
3811 | 3811 | $row_offset = 0; |
3812 | 3812 | } |
3813 | - if(!empty($limit) && $limit != -1 && $limit != -99) |
|
3813 | + if (!empty($limit) && $limit != -1 && $limit != -99) |
|
3814 | 3814 | { |
3815 | - $result = $db->limitQuery($query, $row_offset, $limit,true,"Error retrieving $this->object_name list: "); |
|
3815 | + $result = $db->limitQuery($query, $row_offset, $limit, true, "Error retrieving $this->object_name list: "); |
|
3816 | 3816 | } |
3817 | 3817 | else |
3818 | 3818 | { |
3819 | - $result = $db->query($query,true,"Error retrieving $this->object_name list: "); |
|
3819 | + $result = $db->query($query, true, "Error retrieving $this->object_name list: "); |
|
3820 | 3820 | } |
3821 | 3821 | |
3822 | 3822 | $list = Array(); |
@@ -3839,21 +3839,21 @@ discard block |
||
3839 | 3839 | /** @var SugarBean $temp */ |
3840 | 3840 | $temp = new $class(); |
3841 | 3841 | |
3842 | - foreach($this->field_defs as $field=>$value) |
|
3842 | + foreach ($this->field_defs as $field=>$value) |
|
3843 | 3843 | { |
3844 | 3844 | if (isset($row[$field])) |
3845 | 3845 | { |
3846 | 3846 | $temp->$field = $row[$field]; |
3847 | - $owner_field = $field . '_owner'; |
|
3848 | - if(isset($row[$owner_field])) |
|
3847 | + $owner_field = $field.'_owner'; |
|
3848 | + if (isset($row[$owner_field])) |
|
3849 | 3849 | { |
3850 | 3850 | $temp->$owner_field = $row[$owner_field]; |
3851 | 3851 | } |
3852 | 3852 | |
3853 | 3853 | $GLOBALS['log']->debug("$temp->object_name({$row['id']}): ".$field." = ".$temp->$field); |
3854 | - }else if (isset($row[$this->table_name .'.'.$field])) |
|
3854 | + } else if (isset($row[$this->table_name.'.'.$field])) |
|
3855 | 3855 | { |
3856 | - $temp->$field = $row[$this->table_name .'.'.$field]; |
|
3856 | + $temp->$field = $row[$this->table_name.'.'.$field]; |
|
3857 | 3857 | } |
3858 | 3858 | else |
3859 | 3859 | { |
@@ -3863,7 +3863,7 @@ discard block |
||
3863 | 3863 | |
3864 | 3864 | $temp->check_date_relationships_load(); |
3865 | 3865 | $temp->fill_in_additional_list_fields(); |
3866 | - if($temp->hasCustomFields()) $temp->custom_fields->fill_relationships(); |
|
3866 | + if ($temp->hasCustomFields()) $temp->custom_fields->fill_relationships(); |
|
3867 | 3867 | $temp->call_custom_logic("process_record"); |
3868 | 3868 | |
3869 | 3869 | // fix defect #44206. implement the same logic as sugar_currency_format |
@@ -3873,17 +3873,17 @@ discard block |
||
3873 | 3873 | |
3874 | 3874 | $index++; |
3875 | 3875 | } |
3876 | - if(!empty($sugar_config['disable_count_query']) && !empty($limit)) |
|
3876 | + if (!empty($sugar_config['disable_count_query']) && !empty($limit)) |
|
3877 | 3877 | { |
3878 | 3878 | |
3879 | 3879 | $rows_found = $row_offset + count($list); |
3880 | 3880 | |
3881 | - if(!$toEnd) |
|
3881 | + if (!$toEnd) |
|
3882 | 3882 | { |
3883 | 3883 | $next_offset--; |
3884 | 3884 | $previous_offset++; |
3885 | 3885 | } |
3886 | - } else if(!isset($rows_found)){ |
|
3886 | + } else if (!isset($rows_found)) { |
|
3887 | 3887 | $rows_found = $row_offset + count($list); |
3888 | 3888 | } |
3889 | 3889 | |
@@ -3892,7 +3892,7 @@ discard block |
||
3892 | 3892 | $response['row_count'] = $rows_found; |
3893 | 3893 | $response['next_offset'] = $next_offset; |
3894 | 3894 | $response['previous_offset'] = $previous_offset; |
3895 | - $response['current_offset'] = $row_offset ; |
|
3895 | + $response['current_offset'] = $row_offset; |
|
3896 | 3896 | return $response; |
3897 | 3897 | } |
3898 | 3898 | |
@@ -3904,18 +3904,18 @@ discard block |
||
3904 | 3904 | * @param boolean $is_count_query Optional, Default false, set to true if passed query is a count query. |
3905 | 3905 | * @return int count of rows found |
3906 | 3906 | */ |
3907 | - function _get_num_rows_in_query($query, $is_count_query=false) |
|
3907 | + function _get_num_rows_in_query($query, $is_count_query = false) |
|
3908 | 3908 | { |
3909 | 3909 | $num_rows_in_query = 0; |
3910 | 3910 | if (!$is_count_query) |
3911 | 3911 | { |
3912 | 3912 | $count_query = SugarBean::create_list_count_query($query); |
3913 | 3913 | } else |
3914 | - $count_query=$query; |
|
3914 | + $count_query = $query; |
|
3915 | 3915 | |
3916 | 3916 | $result = $this->db->query($count_query, true, "Error running count query for $this->object_name List: "); |
3917 | 3917 | $row_num = 0; |
3918 | - while($row = $this->db->fetchByAssoc($result, true)) |
|
3918 | + while ($row = $this->db->fetchByAssoc($result, true)) |
|
3919 | 3919 | { |
3920 | 3920 | $num_rows_in_query += current($row); |
3921 | 3921 | } |
@@ -3940,7 +3940,7 @@ discard block |
||
3940 | 3940 | * @return array Fetched data. |
3941 | 3941 | */ |
3942 | 3942 | function process_union_list_query($parent_bean, $query, |
3943 | - $row_offset, $limit= -1, $max_per_page = -1, $where = '', $subpanel_def, $query_row_count='', $secondary_queries = array()) |
|
3943 | + $row_offset, $limit = -1, $max_per_page = -1, $where = '', $subpanel_def, $query_row_count = '', $secondary_queries = array()) |
|
3944 | 3944 | |
3945 | 3945 | { |
3946 | 3946 | $db = DBManagerFactory::getInstance('listviews'); |
@@ -3949,52 +3949,52 @@ discard block |
||
3949 | 3949 | */ |
3950 | 3950 | $toEnd = strval($row_offset) == 'end'; |
3951 | 3951 | global $sugar_config; |
3952 | - $use_count_query=false; |
|
3953 | - $processing_collection=$subpanel_def->isCollection(); |
|
3952 | + $use_count_query = false; |
|
3953 | + $processing_collection = $subpanel_def->isCollection(); |
|
3954 | 3954 | |
3955 | 3955 | $GLOBALS['log']->debug("process_union_list_query: ".$query); |
3956 | - if($max_per_page == -1) |
|
3956 | + if ($max_per_page == -1) |
|
3957 | 3957 | { |
3958 | - $max_per_page = $sugar_config['list_max_entries_per_subpanel']; |
|
3958 | + $max_per_page = $sugar_config['list_max_entries_per_subpanel']; |
|
3959 | 3959 | } |
3960 | - if(empty($query_row_count)) |
|
3960 | + if (empty($query_row_count)) |
|
3961 | 3961 | { |
3962 | 3962 | $query_row_count = $query; |
3963 | 3963 | } |
3964 | - $distinct_position=strpos($query_row_count,"DISTINCT"); |
|
3964 | + $distinct_position = strpos($query_row_count, "DISTINCT"); |
|
3965 | 3965 | |
3966 | - if ($distinct_position!= false) |
|
3966 | + if ($distinct_position != false) |
|
3967 | 3967 | { |
3968 | - $use_count_query=true; |
|
3968 | + $use_count_query = true; |
|
3969 | 3969 | } |
3970 | 3970 | $performSecondQuery = true; |
3971 | - if(empty($sugar_config['disable_count_query']) || $toEnd) |
|
3971 | + if (empty($sugar_config['disable_count_query']) || $toEnd) |
|
3972 | 3972 | { |
3973 | - $rows_found = $this->_get_num_rows_in_query($query_row_count,$use_count_query); |
|
3974 | - if($rows_found < 1) |
|
3973 | + $rows_found = $this->_get_num_rows_in_query($query_row_count, $use_count_query); |
|
3974 | + if ($rows_found < 1) |
|
3975 | 3975 | { |
3976 | 3976 | $performSecondQuery = false; |
3977 | 3977 | } |
3978 | - if(!empty($rows_found) && (empty($limit) || $limit == -1)) |
|
3978 | + if (!empty($rows_found) && (empty($limit) || $limit == -1)) |
|
3979 | 3979 | { |
3980 | 3980 | $limit = $sugar_config['list_max_entries_per_subpanel']; |
3981 | 3981 | } |
3982 | - if( $toEnd) |
|
3982 | + if ($toEnd) |
|
3983 | 3983 | { |
3984 | - $row_offset = (floor(($rows_found -1) / $limit)) * $limit; |
|
3984 | + $row_offset = (floor(($rows_found - 1) / $limit)) * $limit; |
|
3985 | 3985 | |
3986 | 3986 | } |
3987 | 3987 | } |
3988 | 3988 | else |
3989 | 3989 | { |
3990 | - if((empty($limit) || $limit == -1)) |
|
3990 | + if ((empty($limit) || $limit == -1)) |
|
3991 | 3991 | { |
3992 | 3992 | $limit = $max_per_page + 1; |
3993 | 3993 | $max_per_page = $limit; |
3994 | 3994 | } |
3995 | 3995 | } |
3996 | 3996 | |
3997 | - if(empty($row_offset)) |
|
3997 | + if (empty($row_offset)) |
|
3998 | 3998 | { |
3999 | 3999 | $row_offset = 0; |
4000 | 4000 | } |
@@ -4002,15 +4002,15 @@ discard block |
||
4002 | 4002 | $previous_offset = $row_offset - $max_per_page; |
4003 | 4003 | $next_offset = $row_offset + $max_per_page; |
4004 | 4004 | |
4005 | - if($performSecondQuery) |
|
4005 | + if ($performSecondQuery) |
|
4006 | 4006 | { |
4007 | - if(!empty($limit) && $limit != -1 && $limit != -99) |
|
4007 | + if (!empty($limit) && $limit != -1 && $limit != -99) |
|
4008 | 4008 | { |
4009 | - $result = $db->limitQuery($query, $row_offset, $limit,true,"Error retrieving $parent_bean->object_name list: "); |
|
4009 | + $result = $db->limitQuery($query, $row_offset, $limit, true, "Error retrieving $parent_bean->object_name list: "); |
|
4010 | 4010 | } |
4011 | 4011 | else |
4012 | 4012 | { |
4013 | - $result = $db->query($query,true,"Error retrieving $this->object_name list: "); |
|
4013 | + $result = $db->query($query, true, "Error retrieving $this->object_name list: "); |
|
4014 | 4014 | } |
4015 | 4015 | //use -99 to return all |
4016 | 4016 | |
@@ -4020,22 +4020,22 @@ discard block |
||
4020 | 4020 | |
4021 | 4021 | $post_retrieve = array(); |
4022 | 4022 | $isFirstTime = true; |
4023 | - while($row) |
|
4023 | + while ($row) |
|
4024 | 4024 | { |
4025 | 4025 | $function_fields = array(); |
4026 | - if(($index < $row_offset + $max_per_page || $max_per_page == -99)) |
|
4026 | + if (($index < $row_offset + $max_per_page || $max_per_page == -99)) |
|
4027 | 4027 | { |
4028 | 4028 | if ($processing_collection) |
4029 | 4029 | { |
4030 | - $current_bean =$subpanel_def->sub_subpanels[$row['panel_name']]->template_instance; |
|
4031 | - if(!$isFirstTime) |
|
4030 | + $current_bean = $subpanel_def->sub_subpanels[$row['panel_name']]->template_instance; |
|
4031 | + if (!$isFirstTime) |
|
4032 | 4032 | { |
4033 | 4033 | $class = get_class($subpanel_def->sub_subpanels[$row['panel_name']]->template_instance); |
4034 | 4034 | $current_bean = new $class(); |
4035 | 4035 | } |
4036 | 4036 | } else { |
4037 | - $current_bean=$subpanel_def->template_instance; |
|
4038 | - if(!$isFirstTime) |
|
4037 | + $current_bean = $subpanel_def->template_instance; |
|
4038 | + if (!$isFirstTime) |
|
4039 | 4039 | { |
4040 | 4040 | $class = get_class($subpanel_def->template_instance); |
4041 | 4041 | $current_bean = new $class(); |
@@ -4045,9 +4045,9 @@ discard block |
||
4045 | 4045 | //set the panel name in the bean instance. |
4046 | 4046 | if (isset($row['panel_name'])) |
4047 | 4047 | { |
4048 | - $current_bean->panel_name=$row['panel_name']; |
|
4048 | + $current_bean->panel_name = $row['panel_name']; |
|
4049 | 4049 | } |
4050 | - foreach($current_bean->field_defs as $field=>$value) |
|
4050 | + foreach ($current_bean->field_defs as $field=>$value) |
|
4051 | 4051 | { |
4052 | 4052 | |
4053 | 4053 | if (isset($row[$field])) |
@@ -4055,60 +4055,60 @@ discard block |
||
4055 | 4055 | $current_bean->$field = $this->convertField($row[$field], $value); |
4056 | 4056 | unset($row[$field]); |
4057 | 4057 | } |
4058 | - else if (isset($row[$this->table_name .'.'.$field])) |
|
4058 | + else if (isset($row[$this->table_name.'.'.$field])) |
|
4059 | 4059 | { |
4060 | - $current_bean->$field = $this->convertField($row[$this->table_name .'.'.$field], $value); |
|
4061 | - unset($row[$this->table_name .'.'.$field]); |
|
4060 | + $current_bean->$field = $this->convertField($row[$this->table_name.'.'.$field], $value); |
|
4061 | + unset($row[$this->table_name.'.'.$field]); |
|
4062 | 4062 | } |
4063 | 4063 | else |
4064 | 4064 | { |
4065 | 4065 | $current_bean->$field = ""; |
4066 | 4066 | unset($row[$field]); |
4067 | 4067 | } |
4068 | - if(isset($value['source']) && $value['source'] == 'function') |
|
4068 | + if (isset($value['source']) && $value['source'] == 'function') |
|
4069 | 4069 | { |
4070 | - $function_fields[]=$field; |
|
4070 | + $function_fields[] = $field; |
|
4071 | 4071 | } |
4072 | 4072 | } |
4073 | - foreach($row as $key=>$value) |
|
4073 | + foreach ($row as $key=>$value) |
|
4074 | 4074 | { |
4075 | 4075 | $current_bean->$key = $value; |
4076 | 4076 | } |
4077 | - foreach($function_fields as $function_field) |
|
4077 | + foreach ($function_fields as $function_field) |
|
4078 | 4078 | { |
4079 | 4079 | $value = $current_bean->field_defs[$function_field]; |
4080 | 4080 | $can_execute = true; |
4081 | 4081 | $execute_params = array(); |
4082 | 4082 | $execute_function = array(); |
4083 | - if(!empty($value['function_class'])) |
|
4083 | + if (!empty($value['function_class'])) |
|
4084 | 4084 | { |
4085 | - $execute_function[] = $value['function_class']; |
|
4086 | - $execute_function[] = $value['function_name']; |
|
4085 | + $execute_function[] = $value['function_class']; |
|
4086 | + $execute_function[] = $value['function_name']; |
|
4087 | 4087 | } |
4088 | 4088 | else |
4089 | 4089 | { |
4090 | - $execute_function = $value['function_name']; |
|
4090 | + $execute_function = $value['function_name']; |
|
4091 | 4091 | } |
4092 | - foreach($value['function_params'] as $param ) |
|
4092 | + foreach ($value['function_params'] as $param) |
|
4093 | 4093 | { |
4094 | - if (empty($value['function_params_source']) or $value['function_params_source']=='parent') |
|
4094 | + if (empty($value['function_params_source']) or $value['function_params_source'] == 'parent') |
|
4095 | 4095 | { |
4096 | - if(empty($this->$param)) |
|
4096 | + if (empty($this->$param)) |
|
4097 | 4097 | { |
4098 | 4098 | $can_execute = false; |
4099 | - } else if($param == '$this') { |
|
4099 | + } else if ($param == '$this') { |
|
4100 | 4100 | $execute_params[] = $this; |
4101 | 4101 | } |
4102 | 4102 | else |
4103 | 4103 | { |
4104 | 4104 | $execute_params[] = $this->$param; |
4105 | 4105 | } |
4106 | - } else if ($value['function_params_source']=='this') |
|
4106 | + } else if ($value['function_params_source'] == 'this') |
|
4107 | 4107 | { |
4108 | - if(empty($current_bean->$param)) |
|
4108 | + if (empty($current_bean->$param)) |
|
4109 | 4109 | { |
4110 | 4110 | $can_execute = false; |
4111 | - } else if($param == '$this') { |
|
4111 | + } else if ($param == '$this') { |
|
4112 | 4112 | $execute_params[] = $current_bean; |
4113 | 4113 | } |
4114 | 4114 | else |
@@ -4122,18 +4122,18 @@ discard block |
||
4122 | 4122 | } |
4123 | 4123 | |
4124 | 4124 | } |
4125 | - if($can_execute) |
|
4125 | + if ($can_execute) |
|
4126 | 4126 | { |
4127 | - if(!empty($value['function_require'])) |
|
4127 | + if (!empty($value['function_require'])) |
|
4128 | 4128 | { |
4129 | 4129 | require_once($value['function_require']); |
4130 | 4130 | } |
4131 | 4131 | $current_bean->$function_field = call_user_func_array($execute_function, $execute_params); |
4132 | 4132 | } |
4133 | 4133 | } |
4134 | - if(!empty($current_bean->parent_type) && !empty($current_bean->parent_id)) |
|
4134 | + if (!empty($current_bean->parent_type) && !empty($current_bean->parent_id)) |
|
4135 | 4135 | { |
4136 | - if(!isset($post_retrieve[$current_bean->parent_type])) |
|
4136 | + if (!isset($post_retrieve[$current_bean->parent_type])) |
|
4137 | 4137 | { |
4138 | 4138 | $post_retrieve[$current_bean->parent_type] = array(); |
4139 | 4139 | } |
@@ -4147,22 +4147,22 @@ discard block |
||
4147 | 4147 | $row = $db->fetchByAssoc($result); |
4148 | 4148 | } |
4149 | 4149 | //now handle retrieving many-to-many relationships |
4150 | - if(!empty($list)) |
|
4150 | + if (!empty($list)) |
|
4151 | 4151 | { |
4152 | - foreach($secondary_queries as $query2) |
|
4152 | + foreach ($secondary_queries as $query2) |
|
4153 | 4153 | { |
4154 | 4154 | $result2 = $db->query($query2); |
4155 | 4155 | |
4156 | 4156 | $row2 = $db->fetchByAssoc($result2); |
4157 | - while($row2) |
|
4157 | + while ($row2) |
|
4158 | 4158 | { |
4159 | 4159 | $id_ref = $row2['ref_id']; |
4160 | 4160 | |
4161 | - if(isset($list[$id_ref])) |
|
4161 | + if (isset($list[$id_ref])) |
|
4162 | 4162 | { |
4163 | - foreach($row2 as $r2key=>$r2value) |
|
4163 | + foreach ($row2 as $r2key=>$r2value) |
|
4164 | 4164 | { |
4165 | - if($r2key != 'ref_id') |
|
4165 | + if ($r2key != 'ref_id') |
|
4166 | 4166 | { |
4167 | 4167 | $list[$id_ref]->$r2key = $r2value; |
4168 | 4168 | } |
@@ -4174,7 +4174,7 @@ discard block |
||
4174 | 4174 | |
4175 | 4175 | } |
4176 | 4176 | |
4177 | - if(isset($post_retrieve)) |
|
4177 | + if (isset($post_retrieve)) |
|
4178 | 4178 | { |
4179 | 4179 | $parent_fields = $this->retrieve_parent_fields($post_retrieve); |
4180 | 4180 | } |
@@ -4182,16 +4182,16 @@ discard block |
||
4182 | 4182 | { |
4183 | 4183 | $parent_fields = array(); |
4184 | 4184 | } |
4185 | - if(!empty($sugar_config['disable_count_query']) && !empty($limit)) |
|
4185 | + if (!empty($sugar_config['disable_count_query']) && !empty($limit)) |
|
4186 | 4186 | { |
4187 | 4187 | //C.L. Bug 43535 - Use the $index value to set the $rows_found value here |
4188 | 4188 | $rows_found = isset($index) ? $index : $row_offset + count($list); |
4189 | 4189 | |
4190 | - if(count($list) >= $limit) |
|
4190 | + if (count($list) >= $limit) |
|
4191 | 4191 | { |
4192 | 4192 | array_pop($list); |
4193 | 4193 | } |
4194 | - if(!$toEnd) |
|
4194 | + if (!$toEnd) |
|
4195 | 4195 | { |
4196 | 4196 | $next_offset--; |
4197 | 4197 | $previous_offset++; |
@@ -4200,7 +4200,7 @@ discard block |
||
4200 | 4200 | } |
4201 | 4201 | else |
4202 | 4202 | { |
4203 | - $row_found = 0; |
|
4203 | + $row_found = 0; |
|
4204 | 4204 | $parent_fields = array(); |
4205 | 4205 | } |
4206 | 4206 | $response = array(); |
@@ -4209,7 +4209,7 @@ discard block |
||
4209 | 4209 | $response['row_count'] = $rows_found; |
4210 | 4210 | $response['next_offset'] = $next_offset; |
4211 | 4211 | $response['previous_offset'] = $previous_offset; |
4212 | - $response['current_offset'] = $row_offset ; |
|
4212 | + $response['current_offset'] = $row_offset; |
|
4213 | 4213 | $response['query'] = $query; |
4214 | 4214 | |
4215 | 4215 | return $response; |
@@ -4229,35 +4229,35 @@ discard block |
||
4229 | 4229 | * @return array Fetched data. |
4230 | 4230 | * |
4231 | 4231 | */ |
4232 | - function process_detail_query($query, $row_offset, $limit= -1, $max_per_page = -1, $where = '', $offset = 0) |
|
4232 | + function process_detail_query($query, $row_offset, $limit = -1, $max_per_page = -1, $where = '', $offset = 0) |
|
4233 | 4233 | { |
4234 | 4234 | global $sugar_config; |
4235 | 4235 | $GLOBALS['log']->debug("process_detail_query: ".$query); |
4236 | - if($max_per_page == -1) |
|
4236 | + if ($max_per_page == -1) |
|
4237 | 4237 | { |
4238 | - $max_per_page = $sugar_config['list_max_entries_per_page']; |
|
4238 | + $max_per_page = $sugar_config['list_max_entries_per_page']; |
|
4239 | 4239 | } |
4240 | 4240 | |
4241 | 4241 | // Check to see if we have a count query available. |
4242 | 4242 | $count_query = $this->create_list_count_query($query); |
4243 | 4243 | |
4244 | - if(!empty($count_query) && (empty($limit) || $limit == -1)) |
|
4244 | + if (!empty($count_query) && (empty($limit) || $limit == -1)) |
|
4245 | 4245 | { |
4246 | 4246 | // We have a count query. Run it and get the results. |
4247 | 4247 | $result = $this->db->query($count_query, true, "Error running count query for $this->object_name List: "); |
4248 | 4248 | $assoc = $this->db->fetchByAssoc($result); |
4249 | - if(!empty($assoc['c'])) |
|
4249 | + if (!empty($assoc['c'])) |
|
4250 | 4250 | { |
4251 | 4251 | $total_rows = $assoc['c']; |
4252 | 4252 | } |
4253 | 4253 | } |
4254 | 4254 | |
4255 | - if(empty($row_offset)) |
|
4255 | + if (empty($row_offset)) |
|
4256 | 4256 | { |
4257 | 4257 | $row_offset = 0; |
4258 | 4258 | } |
4259 | 4259 | |
4260 | - $result = $this->db->limitQuery($query, $offset, 1, true,"Error retrieving $this->object_name list: "); |
|
4260 | + $result = $this->db->limitQuery($query, $offset, 1, true, "Error retrieving $this->object_name list: "); |
|
4261 | 4261 | |
4262 | 4262 | $previous_offset = $row_offset - $max_per_page; |
4263 | 4263 | $next_offset = $row_offset + $max_per_page; |
@@ -4268,7 +4268,7 @@ discard block |
||
4268 | 4268 | $response = Array(); |
4269 | 4269 | $response['bean'] = $this; |
4270 | 4270 | if (empty($total_rows)) |
4271 | - $total_rows=0; |
|
4271 | + $total_rows = 0; |
|
4272 | 4272 | $response['row_count'] = $total_rows; |
4273 | 4273 | $response['next_offset'] = $next_offset; |
4274 | 4274 | $response['previous_offset'] = $previous_offset; |
@@ -4285,12 +4285,12 @@ discard block |
||
4285 | 4285 | * @return array Fetched data. |
4286 | 4286 | * |
4287 | 4287 | */ |
4288 | - function process_full_list_query($query, $check_date=false) |
|
4288 | + function process_full_list_query($query, $check_date = false) |
|
4289 | 4289 | { |
4290 | 4290 | |
4291 | 4291 | $GLOBALS['log']->debug("process_full_list_query: query is ".$query); |
4292 | 4292 | $result = $this->db->query($query, false); |
4293 | - $GLOBALS['log']->debug("process_full_list_query: result is ".print_r($result,true)); |
|
4293 | + $GLOBALS['log']->debug("process_full_list_query: result is ".print_r($result, true)); |
|
4294 | 4294 | $class = get_class($this); |
4295 | 4295 | $isFirstTime = true; |
4296 | 4296 | $bean = new $class(); |
@@ -4299,13 +4299,13 @@ discard block |
||
4299 | 4299 | while (($row = $bean->db->fetchByAssoc($result)) != null) |
4300 | 4300 | { |
4301 | 4301 | $row = $this->convertRow($row); |
4302 | - if(!$isFirstTime) |
|
4302 | + if (!$isFirstTime) |
|
4303 | 4303 | { |
4304 | 4304 | $bean = new $class(); |
4305 | 4305 | } |
4306 | 4306 | $isFirstTime = false; |
4307 | 4307 | |
4308 | - foreach($bean->field_defs as $field=>$value) |
|
4308 | + foreach ($bean->field_defs as $field=>$value) |
|
4309 | 4309 | { |
4310 | 4310 | if (isset($row[$field])) |
4311 | 4311 | { |
@@ -4317,7 +4317,7 @@ discard block |
||
4317 | 4317 | $bean->$field = ''; |
4318 | 4318 | } |
4319 | 4319 | } |
4320 | - if($check_date) |
|
4320 | + if ($check_date) |
|
4321 | 4321 | { |
4322 | 4322 | $bean->processed_dates_times = array(); |
4323 | 4323 | $bean->check_date_relationships_load(); |
@@ -4342,10 +4342,10 @@ discard block |
||
4342 | 4342 | * @param string $current_module - String value of the module being processed. |
4343 | 4343 | * @param string $current_view - String value of the current view |
4344 | 4344 | */ |
4345 | - function track_view($user_id, $current_module, $current_view='') |
|
4345 | + function track_view($user_id, $current_module, $current_view = '') |
|
4346 | 4346 | { |
4347 | 4347 | $trackerManager = TrackerManager::getInstance(); |
4348 | - if($monitor = $trackerManager->getMonitor('tracker')){ |
|
4348 | + if ($monitor = $trackerManager->getMonitor('tracker')) { |
|
4349 | 4349 | $monitor->setValue('date_modified', $GLOBALS['timedate']->nowDb()); |
4350 | 4350 | $monitor->setValue('user_id', $user_id); |
4351 | 4351 | $monitor->setValue('module_name', $current_module); |
@@ -4374,8 +4374,8 @@ discard block |
||
4374 | 4374 | * account for instance. This method is only used for populating extra fields |
4375 | 4375 | * in lists. |
4376 | 4376 | */ |
4377 | - function fill_in_additional_list_fields(){ |
|
4378 | - if(!empty($this->field_defs['parent_name']) && empty($this->parent_name)){ |
|
4377 | + function fill_in_additional_list_fields() { |
|
4378 | + if (!empty($this->field_defs['parent_name']) && empty($this->parent_name)) { |
|
4379 | 4379 | $this->fill_in_additional_parent_fields(); |
4380 | 4380 | } |
4381 | 4381 | } |
@@ -4389,17 +4389,17 @@ discard block |
||
4389 | 4389 | */ |
4390 | 4390 | function fill_in_additional_detail_fields() |
4391 | 4391 | { |
4392 | - if(!empty($this->field_defs['assigned_user_name']) && !empty($this->assigned_user_id)){ |
|
4392 | + if (!empty($this->field_defs['assigned_user_name']) && !empty($this->assigned_user_id)) { |
|
4393 | 4393 | |
4394 | 4394 | $this->assigned_user_name = get_assigned_user_name($this->assigned_user_id); |
4395 | 4395 | |
4396 | 4396 | } |
4397 | - if(!empty($this->field_defs['created_by']) && !empty($this->created_by)) |
|
4397 | + if (!empty($this->field_defs['created_by']) && !empty($this->created_by)) |
|
4398 | 4398 | $this->created_by_name = get_assigned_user_name($this->created_by); |
4399 | - if(!empty($this->field_defs['modified_user_id']) && !empty($this->modified_user_id)) |
|
4399 | + if (!empty($this->field_defs['modified_user_id']) && !empty($this->modified_user_id)) |
|
4400 | 4400 | $this->modified_by_name = get_assigned_user_name($this->modified_user_id); |
4401 | 4401 | |
4402 | - if(!empty($this->field_defs['parent_name'])){ |
|
4402 | + if (!empty($this->field_defs['parent_name'])) { |
|
4403 | 4403 | $this->fill_in_additional_parent_fields(); |
4404 | 4404 | } |
4405 | 4405 | } |
@@ -4410,17 +4410,17 @@ discard block |
||
4410 | 4410 | */ |
4411 | 4411 | function fill_in_additional_parent_fields() { |
4412 | 4412 | |
4413 | - if(!empty($this->parent_id) && !empty($this->last_parent_id) && $this->last_parent_id == $this->parent_id){ |
|
4413 | + if (!empty($this->parent_id) && !empty($this->last_parent_id) && $this->last_parent_id == $this->parent_id) { |
|
4414 | 4414 | return false; |
4415 | - }else{ |
|
4415 | + } else { |
|
4416 | 4416 | $this->parent_name = ''; |
4417 | 4417 | } |
4418 | - if(!empty($this->parent_type)) { |
|
4418 | + if (!empty($this->parent_type)) { |
|
4419 | 4419 | $this->last_parent_id = $this->parent_id; |
4420 | 4420 | $this->getRelatedFields($this->parent_type, $this->parent_id, array('name'=>'parent_name', 'document_name' => 'parent_document_name', 'first_name'=>'parent_first_name', 'last_name'=>'parent_last_name')); |
4421 | - if(!empty($this->parent_first_name) || !empty($this->parent_last_name) ){ |
|
4421 | + if (!empty($this->parent_first_name) || !empty($this->parent_last_name)) { |
|
4422 | 4422 | $this->parent_name = $GLOBALS['locale']->getLocaleFormattedName($this->parent_first_name, $this->parent_last_name); |
4423 | - } else if(!empty($this->parent_document_name)){ |
|
4423 | + } else if (!empty($this->parent_document_name)) { |
|
4424 | 4424 | $this->parent_name = $this->parent_document_name; |
4425 | 4425 | } |
4426 | 4426 | } |
@@ -4430,7 +4430,7 @@ discard block |
||
4430 | 4430 | * Fill in a link field |
4431 | 4431 | */ |
4432 | 4432 | |
4433 | - function fill_in_link_field( $linkFieldName , $def) |
|
4433 | + function fill_in_link_field($linkFieldName, $def) |
|
4434 | 4434 | { |
4435 | 4435 | $idField = $linkFieldName; |
4436 | 4436 | //If the id_name provided really was an ID, don't try to load it as a link. Use the normal link |
@@ -4440,8 +4440,8 @@ discard block |
||
4440 | 4440 | } |
4441 | 4441 | if ($this->load_relationship($linkFieldName)) |
4442 | 4442 | { |
4443 | - $list=$this->$linkFieldName->get(); |
|
4444 | - $this->$idField = '' ; // match up with null value in $this->populateFromRow() |
|
4443 | + $list = $this->$linkFieldName->get(); |
|
4444 | + $this->$idField = ''; // match up with null value in $this->populateFromRow() |
|
4445 | 4445 | if (!empty($list)) |
4446 | 4446 | $this->$idField = $list[0]; |
4447 | 4447 | } |
@@ -4450,22 +4450,22 @@ discard block |
||
4450 | 4450 | /** |
4451 | 4451 | * Fill in fields where type = relate |
4452 | 4452 | */ |
4453 | - function fill_in_relationship_fields(){ |
|
4453 | + function fill_in_relationship_fields() { |
|
4454 | 4454 | global $fill_in_rel_depth; |
4455 | - if(empty($fill_in_rel_depth) || $fill_in_rel_depth < 0) |
|
4455 | + if (empty($fill_in_rel_depth) || $fill_in_rel_depth < 0) |
|
4456 | 4456 | $fill_in_rel_depth = 0; |
4457 | 4457 | |
4458 | - if($fill_in_rel_depth > 1) |
|
4458 | + if ($fill_in_rel_depth > 1) |
|
4459 | 4459 | return; |
4460 | 4460 | |
4461 | 4461 | $fill_in_rel_depth++; |
4462 | 4462 | |
4463 | - foreach($this->field_defs as $field) |
|
4463 | + foreach ($this->field_defs as $field) |
|
4464 | 4464 | { |
4465 | - if(0 == strcmp($field['type'],'relate') && !empty($field['module'])) |
|
4465 | + if (0 == strcmp($field['type'], 'relate') && !empty($field['module'])) |
|
4466 | 4466 | { |
4467 | 4467 | $name = $field['name']; |
4468 | - if(empty($this->$name)) |
|
4468 | + if (empty($this->$name)) |
|
4469 | 4469 | { |
4470 | 4470 | // set the value of this relate field in this bean ($this->$field['name']) to the value of the 'name' field in the related module for the record identified by the value of $this->$field['id_name'] |
4471 | 4471 | $related_module = $field['module']; |
@@ -4475,11 +4475,11 @@ discard block |
||
4475 | 4475 | { |
4476 | 4476 | $this->fill_in_link_field($id_name, $field); |
4477 | 4477 | } |
4478 | - if(!empty($this->$id_name) && ( $this->object_name != $related_module || ( $this->object_name == $related_module && $this->$id_name != $this->id ))){ |
|
4479 | - if(isset($GLOBALS['beanList'][ $related_module])){ |
|
4478 | + if (!empty($this->$id_name) && ($this->object_name != $related_module || ($this->object_name == $related_module && $this->$id_name != $this->id))) { |
|
4479 | + if (isset($GLOBALS['beanList'][$related_module])) { |
|
4480 | 4480 | $class = $GLOBALS['beanList'][$related_module]; |
4481 | 4481 | |
4482 | - if(!empty($this->$id_name) && file_exists($GLOBALS['beanFiles'][$class]) && isset($this->$name)){ |
|
4482 | + if (!empty($this->$id_name) && file_exists($GLOBALS['beanFiles'][$class]) && isset($this->$name)) { |
|
4483 | 4483 | require_once($GLOBALS['beanFiles'][$class]); |
4484 | 4484 | $mod = new $class(); |
4485 | 4485 | |
@@ -4496,17 +4496,17 @@ discard block |
||
4496 | 4496 | } |
4497 | 4497 | } |
4498 | 4498 | } |
4499 | - if(!empty($this->$id_name) && isset($this->$name)) |
|
4499 | + if (!empty($this->$id_name) && isset($this->$name)) |
|
4500 | 4500 | { |
4501 | - if(!isset($field['additionalFields'])) |
|
4501 | + if (!isset($field['additionalFields'])) |
|
4502 | 4502 | $field['additionalFields'] = array(); |
4503 | - if(!empty($field['rname'])) |
|
4503 | + if (!empty($field['rname'])) |
|
4504 | 4504 | { |
4505 | - $field['additionalFields'][$field['rname']]= $name; |
|
4505 | + $field['additionalFields'][$field['rname']] = $name; |
|
4506 | 4506 | } |
4507 | 4507 | else |
4508 | 4508 | { |
4509 | - $field['additionalFields']['name']= $name; |
|
4509 | + $field['additionalFields']['name'] = $name; |
|
4510 | 4510 | } |
4511 | 4511 | $this->getRelatedFields($related_module, $this->$id_name, $field['additionalFields']); |
4512 | 4512 | } |
@@ -4536,7 +4536,7 @@ discard block |
||
4536 | 4536 | global $current_user; |
4537 | 4537 | $date_modified = $GLOBALS['timedate']->nowDb(); |
4538 | 4538 | $id = $this->db->quote($id); |
4539 | - if(isset($_SESSION['show_deleted'])) |
|
4539 | + if (isset($_SESSION['show_deleted'])) |
|
4540 | 4540 | { |
4541 | 4541 | $this->mark_undeleted($id); |
4542 | 4542 | } |
@@ -4547,7 +4547,7 @@ discard block |
||
4547 | 4547 | $this->call_custom_logic("before_delete", $custom_logic_arguments); |
4548 | 4548 | $this->deleted = 1; |
4549 | 4549 | $this->mark_relationships_deleted($id); |
4550 | - if ( isset($this->field_defs['modified_user_id']) ) { |
|
4550 | + if (isset($this->field_defs['modified_user_id'])) { |
|
4551 | 4551 | if (!empty($current_user)) { |
4552 | 4552 | $this->modified_user_id = $current_user->id; |
4553 | 4553 | } else { |
@@ -4557,7 +4557,7 @@ discard block |
||
4557 | 4557 | } else { |
4558 | 4558 | $query = "UPDATE $this->table_name set deleted=1 , date_modified = '$date_modified' where id='$id'"; |
4559 | 4559 | } |
4560 | - $this->db->query($query, true,"Error marking record deleted: "); |
|
4560 | + $this->db->query($query, true, "Error marking record deleted: "); |
|
4561 | 4561 | |
4562 | 4562 | SugarRelationship::resaveRelatedBeans(); |
4563 | 4563 | |
@@ -4585,8 +4585,8 @@ discard block |
||
4585 | 4585 | $this->call_custom_logic("before_restore", $custom_logic_arguments); |
4586 | 4586 | |
4587 | 4587 | $date_modified = $GLOBALS['timedate']->nowDb(); |
4588 | - $query = "UPDATE $this->table_name set deleted=0 , date_modified = '$date_modified' where id='" . $this->db->quote($id) ."'"; |
|
4589 | - $this->db->query($query, true,"Error marking record undeleted: "); |
|
4588 | + $query = "UPDATE $this->table_name set deleted=0 , date_modified = '$date_modified' where id='".$this->db->quote($id)."'"; |
|
4589 | + $this->db->query($query, true, "Error marking record undeleted: "); |
|
4590 | 4590 | |
4591 | 4591 | $this->restoreFiles(); |
4592 | 4592 | |
@@ -4639,19 +4639,19 @@ discard block |
||
4639 | 4639 | |
4640 | 4640 | $directory = $this->deleteFileDirectory(); |
4641 | 4641 | |
4642 | - $isCreated = sugar_is_dir('upload://deleted/' . $directory); |
|
4642 | + $isCreated = sugar_is_dir('upload://deleted/'.$directory); |
|
4643 | 4643 | if (!$isCreated) { |
4644 | - sugar_mkdir('upload://deleted/' . $directory, 0777, true); |
|
4645 | - $isCreated = sugar_is_dir('upload://deleted/' . $directory); |
|
4644 | + sugar_mkdir('upload://deleted/'.$directory, 0777, true); |
|
4645 | + $isCreated = sugar_is_dir('upload://deleted/'.$directory); |
|
4646 | 4646 | } |
4647 | 4647 | if (!$isCreated) { |
4648 | 4648 | return false; |
4649 | 4649 | } |
4650 | 4650 | |
4651 | 4651 | foreach ($files as $file) { |
4652 | - if (file_exists('upload://' . $file)) { |
|
4653 | - if (!sugar_rename('upload://' . $file, 'upload://deleted/' . $directory . '/' . $file)) { |
|
4654 | - $GLOBALS['log']->error('Could not move file ' . $file . ' to deleted directory'); |
|
4652 | + if (file_exists('upload://'.$file)) { |
|
4653 | + if (!sugar_rename('upload://'.$file, 'upload://deleted/'.$directory.'/'.$file)) { |
|
4654 | + $GLOBALS['log']->error('Could not move file '.$file.' to deleted directory'); |
|
4655 | 4655 | } |
4656 | 4656 | } |
4657 | 4657 | } |
@@ -4671,7 +4671,7 @@ discard block |
||
4671 | 4671 | } |
4672 | 4672 | if (empty($record['id'])) { |
4673 | 4673 | $record['id'] = $db->quoted(create_guid()); |
4674 | - $db->query('INSERT INTO cron_remove_documents (' . implode(', ', array_keys($record)) . ') VALUES(' . implode(', ', $record) . ')'); |
|
4674 | + $db->query('INSERT INTO cron_remove_documents ('.implode(', ', array_keys($record)).') VALUES('.implode(', ', $record).')'); |
|
4675 | 4675 | } else { |
4676 | 4676 | $db->query("UPDATE cron_remove_documents SET date_modified={$record['date_modified']} WHERE id={$record['id']}"); |
4677 | 4677 | } |
@@ -4700,9 +4700,9 @@ discard block |
||
4700 | 4700 | $directory = $this->deleteFileDirectory(); |
4701 | 4701 | |
4702 | 4702 | foreach ($files as $file) { |
4703 | - if (sugar_is_file('upload://deleted/' . $directory . '/' . $file)) { |
|
4704 | - if (!sugar_rename('upload://deleted/' . $directory . '/' . $file, 'upload://' . $file)) { |
|
4705 | - $GLOBALS['log']->error('Could not move file ' . $directory . '/' . $file . ' from deleted directory'); |
|
4703 | + if (sugar_is_file('upload://deleted/'.$directory.'/'.$file)) { |
|
4704 | + if (!sugar_rename('upload://deleted/'.$directory.'/'.$file, 'upload://'.$file)) { |
|
4705 | + $GLOBALS['log']->error('Could not move file '.$directory.'/'.$file.' from deleted directory'); |
|
4706 | 4706 | } |
4707 | 4707 | } |
4708 | 4708 | } |
@@ -4711,7 +4711,7 @@ discard block |
||
4711 | 4711 | * @var DBManager $db |
4712 | 4712 | */ |
4713 | 4713 | global $db; |
4714 | - $db->query('DELETE FROM cron_remove_documents WHERE bean_id=' . $db->quoted($this->id)); |
|
4714 | + $db->query('DELETE FROM cron_remove_documents WHERE bean_id='.$db->quoted($this->id)); |
|
4715 | 4715 | |
4716 | 4716 | return true; |
4717 | 4717 | } |
@@ -4799,9 +4799,9 @@ discard block |
||
4799 | 4799 | $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
4800 | 4800 | $db = DBManagerFactory::getInstance('listviews'); |
4801 | 4801 | |
4802 | - if(!empty($row_offset) && $row_offset != 0 && !empty($limit) && $limit != -1) |
|
4802 | + if (!empty($row_offset) && $row_offset != 0 && !empty($limit) && $limit != -1) |
|
4803 | 4803 | { |
4804 | - $result = $db->limitQuery($query, $row_offset, $limit,true,"Error retrieving $template->object_name list: "); |
|
4804 | + $result = $db->limitQuery($query, $row_offset, $limit, true, "Error retrieving $template->object_name list: "); |
|
4805 | 4805 | } |
4806 | 4806 | else |
4807 | 4807 | { |
@@ -4811,16 +4811,16 @@ discard block |
||
4811 | 4811 | $list = Array(); |
4812 | 4812 | $isFirstTime = true; |
4813 | 4813 | $class = get_class($template); |
4814 | - while($row = $this->db->fetchByAssoc($result)) |
|
4814 | + while ($row = $this->db->fetchByAssoc($result)) |
|
4815 | 4815 | { |
4816 | - if(!$isFirstTime) |
|
4816 | + if (!$isFirstTime) |
|
4817 | 4817 | { |
4818 | 4818 | $template = new $class(); |
4819 | 4819 | } |
4820 | 4820 | $isFirstTime = false; |
4821 | 4821 | $record = $template->retrieve($row['id']); |
4822 | 4822 | |
4823 | - if($record != null) |
|
4823 | + if ($record != null) |
|
4824 | 4824 | { |
4825 | 4825 | // this copies the object into the array |
4826 | 4826 | $list[] = $template; |
@@ -4838,12 +4838,12 @@ discard block |
||
4838 | 4838 | * @param string $query - the query that should be executed to build the list |
4839 | 4839 | * @param object $template - The object that should be used to copy the records. |
4840 | 4840 | */ |
4841 | - function build_related_list_where($query, &$template, $where='', $in='', $order_by, $limit='', $row_offset = 0) |
|
4841 | + function build_related_list_where($query, &$template, $where = '', $in = '', $order_by, $limit = '', $row_offset = 0) |
|
4842 | 4842 | { |
4843 | 4843 | $db = DBManagerFactory::getInstance('listviews'); |
4844 | 4844 | // No need to do an additional query |
4845 | 4845 | $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
4846 | - if(empty($in) && !empty($query)) |
|
4846 | + if (empty($in) && !empty($query)) |
|
4847 | 4847 | { |
4848 | 4848 | $idList = $this->build_related_in($query); |
4849 | 4849 | $in = $idList['in']; |
@@ -4859,19 +4859,19 @@ discard block |
||
4859 | 4859 | $query .= $custom_join['join']; |
4860 | 4860 | |
4861 | 4861 | $query .= " WHERE deleted=0 AND id IN $in"; |
4862 | - if(!empty($where)) |
|
4862 | + if (!empty($where)) |
|
4863 | 4863 | { |
4864 | 4864 | $query .= " AND $where"; |
4865 | 4865 | } |
4866 | 4866 | |
4867 | 4867 | |
4868 | - if(!empty($order_by)) |
|
4868 | + if (!empty($order_by)) |
|
4869 | 4869 | { |
4870 | 4870 | $query .= "ORDER BY $order_by"; |
4871 | 4871 | } |
4872 | 4872 | if (!empty($limit)) |
4873 | 4873 | { |
4874 | - $result = $db->limitQuery($query, $row_offset, $limit,true,"Error retrieving $this->object_name list: "); |
|
4874 | + $result = $db->limitQuery($query, $row_offset, $limit, true, "Error retrieving $this->object_name list: "); |
|
4875 | 4875 | } |
4876 | 4876 | else |
4877 | 4877 | { |
@@ -4883,16 +4883,16 @@ discard block |
||
4883 | 4883 | $class = get_class($template); |
4884 | 4884 | |
4885 | 4885 | $disable_security_flag = ($template->disable_row_level_security) ? true : false; |
4886 | - while($row = $db->fetchByAssoc($result)) |
|
4886 | + while ($row = $db->fetchByAssoc($result)) |
|
4887 | 4887 | { |
4888 | - if(!$isFirstTime) |
|
4888 | + if (!$isFirstTime) |
|
4889 | 4889 | { |
4890 | 4890 | $template = new $class(); |
4891 | 4891 | $template->disable_row_level_security = $disable_security_flag; |
4892 | 4892 | } |
4893 | 4893 | $isFirstTime = false; |
4894 | 4894 | $record = $template->retrieve($row['id']); |
4895 | - if($record != null) |
|
4895 | + if ($record != null) |
|
4896 | 4896 | { |
4897 | 4897 | // this copies the object into the array |
4898 | 4898 | $list[] = $template; |
@@ -4913,22 +4913,22 @@ discard block |
||
4913 | 4913 | $idList = array(); |
4914 | 4914 | $result = $this->db->query($query, true); |
4915 | 4915 | $ids = ''; |
4916 | - while($row = $this->db->fetchByAssoc($result)) |
|
4916 | + while ($row = $this->db->fetchByAssoc($result)) |
|
4917 | 4917 | { |
4918 | 4918 | $idList[] = $row['id']; |
4919 | - if(empty($ids)) |
|
4919 | + if (empty($ids)) |
|
4920 | 4920 | { |
4921 | - $ids = "('" . $row['id'] . "'"; |
|
4921 | + $ids = "('".$row['id']."'"; |
|
4922 | 4922 | } |
4923 | 4923 | else |
4924 | 4924 | { |
4925 | - $ids .= ",'" . $row['id'] . "'"; |
|
4925 | + $ids .= ",'".$row['id']."'"; |
|
4926 | 4926 | } |
4927 | 4927 | } |
4928 | - if(empty($ids)) |
|
4928 | + if (empty($ids)) |
|
4929 | 4929 | { |
4930 | 4930 | $ids = "('')"; |
4931 | - }else{ |
|
4931 | + } else { |
|
4932 | 4932 | $ids .= ')'; |
4933 | 4933 | } |
4934 | 4934 | |
@@ -4954,16 +4954,16 @@ discard block |
||
4954 | 4954 | $list = Array(); |
4955 | 4955 | $isFirstTime = true; |
4956 | 4956 | $class = get_class($template); |
4957 | - while($row = $this->db->fetchByAssoc($result)) |
|
4957 | + while ($row = $this->db->fetchByAssoc($result)) |
|
4958 | 4958 | { |
4959 | 4959 | // Create a blank copy |
4960 | 4960 | $copy = $template; |
4961 | - if(!$isFirstTime) |
|
4961 | + if (!$isFirstTime) |
|
4962 | 4962 | { |
4963 | 4963 | $copy = new $class(); |
4964 | 4964 | } |
4965 | 4965 | $isFirstTime = false; |
4966 | - foreach($field_list as $field) |
|
4966 | + foreach ($field_list as $field) |
|
4967 | 4967 | { |
4968 | 4968 | // Copy the relevant fields |
4969 | 4969 | $copy->$field = $row[$field]; |
@@ -4995,14 +4995,14 @@ discard block |
||
4995 | 4995 | |
4996 | 4996 | $return_array = Array(); |
4997 | 4997 | global $app_list_strings, $mod_strings; |
4998 | - foreach($this->field_defs as $field=>$value){ |
|
4998 | + foreach ($this->field_defs as $field=>$value) { |
|
4999 | 4999 | |
5000 | - if(isset($this->$field)){ |
|
5000 | + if (isset($this->$field)) { |
|
5001 | 5001 | |
5002 | 5002 | // cn: bug 12270 - sensitive fields being passed arbitrarily in listViews |
5003 | - if(isset($sensitiveFields[$field])) |
|
5003 | + if (isset($sensitiveFields[$field])) |
|
5004 | 5004 | continue; |
5005 | - if(!isset($cache[$field])) |
|
5005 | + if (!isset($cache[$field])) |
|
5006 | 5006 | $cache[$field] = strtoupper($field); |
5007 | 5007 | |
5008 | 5008 | //Fields hidden by Dependent Fields |
@@ -5012,30 +5012,30 @@ discard block |
||
5012 | 5012 | } |
5013 | 5013 | //cn: if $field is a _dom, detect and return VALUE not KEY |
5014 | 5014 | //cl: empty function check for meta-data enum types that have values loaded from a function |
5015 | - else if (((!empty($value['type']) && ($value['type'] == 'enum' || $value['type'] == 'radioenum') )) && empty($value['function'])){ |
|
5016 | - if(!empty($value['options']) && !empty($app_list_strings[$value['options']][$this->$field])){ |
|
5015 | + else if (((!empty($value['type']) && ($value['type'] == 'enum' || $value['type'] == 'radioenum'))) && empty($value['function'])) { |
|
5016 | + if (!empty($value['options']) && !empty($app_list_strings[$value['options']][$this->$field])) { |
|
5017 | 5017 | $return_array[$cache[$field]] = $app_list_strings[$value['options']][$this->$field]; |
5018 | 5018 | } |
5019 | 5019 | //nsingh- bug 21672. some modules such as manufacturers, Releases do not have a listing for select fields in the $app_list_strings. Must also check $mod_strings to localize. |
5020 | - elseif(!empty($value['options']) && !empty($mod_strings[$value['options']][$this->$field])) |
|
5020 | + elseif (!empty($value['options']) && !empty($mod_strings[$value['options']][$this->$field])) |
|
5021 | 5021 | { |
5022 | 5022 | $return_array[$cache[$field]] = $mod_strings[$value['options']][$this->$field]; |
5023 | 5023 | } |
5024 | - else{ |
|
5024 | + else { |
|
5025 | 5025 | $return_array[$cache[$field]] = $this->$field; |
5026 | 5026 | } |
5027 | 5027 | //end bug 21672 |
5028 | 5028 | // tjy: no need to do this str_replace as the changes in 29994 for ListViewGeneric.tpl for translation handle this now |
5029 | 5029 | // }elseif(!empty($value['type']) && $value['type'] == 'multienum'&& empty($value['function'])){ |
5030 | 5030 | // $return_array[strtoupper($field)] = str_replace('^,^', ', ', $this->$field ); |
5031 | - }elseif(!empty($value['custom_module']) && $value['type'] != 'currency'){ |
|
5031 | + }elseif (!empty($value['custom_module']) && $value['type'] != 'currency') { |
|
5032 | 5032 | // $this->format_field($value); |
5033 | 5033 | $return_array[$cache[$field]] = $this->$field; |
5034 | - }else{ |
|
5034 | + } else { |
|
5035 | 5035 | $return_array[$cache[$field]] = $this->$field; |
5036 | 5036 | } |
5037 | 5037 | // handle "Assigned User Name" |
5038 | - if($field == 'assigned_user_name'){ |
|
5038 | + if ($field == 'assigned_user_name') { |
|
5039 | 5039 | $return_array['ASSIGNED_USER_NAME'] = get_assigned_user_name($this->assigned_user_id); |
5040 | 5040 | } |
5041 | 5041 | } |
@@ -5057,7 +5057,7 @@ discard block |
||
5057 | 5057 | * @param boolean $deleted Optional, default true, if set to false deleted filter will not be added. |
5058 | 5058 | * @return string The WHERE clause |
5059 | 5059 | */ |
5060 | - function get_where($fields_array, $deleted=true) |
|
5060 | + function get_where($fields_array, $deleted = true) |
|
5061 | 5061 | { |
5062 | 5062 | $where_clause = ""; |
5063 | 5063 | foreach ($fields_array as $name=>$value) |
@@ -5067,10 +5067,10 @@ discard block |
||
5067 | 5067 | } |
5068 | 5068 | $name = $this->db->getValidDBName($name); |
5069 | 5069 | |
5070 | - $where_clause .= "$name = ".$this->db->quoted($value,false); |
|
5070 | + $where_clause .= "$name = ".$this->db->quoted($value, false); |
|
5071 | 5071 | } |
5072 | - if(!empty($where_clause)) { |
|
5073 | - if($deleted) { |
|
5072 | + if (!empty($where_clause)) { |
|
5073 | + if ($deleted) { |
|
5074 | 5074 | return "WHERE $where_clause AND deleted=0"; |
5075 | 5075 | } else { |
5076 | 5076 | return "WHERE $where_clause"; |
@@ -5090,24 +5090,24 @@ discard block |
||
5090 | 5090 | * @param boolean $deleted Optional, default true, if set to false deleted filter will not be added. |
5091 | 5091 | * @return object Instance of this bean with fetched data. |
5092 | 5092 | */ |
5093 | - function retrieve_by_string_fields($fields_array, $encode=true, $deleted=true) |
|
5093 | + function retrieve_by_string_fields($fields_array, $encode = true, $deleted = true) |
|
5094 | 5094 | { |
5095 | 5095 | $where_clause = $this->get_where($fields_array, $deleted); |
5096 | 5096 | $custom_join = $this->getCustomJoin(); |
5097 | - $query = "SELECT $this->table_name.*". $custom_join['select']. " FROM $this->table_name " . $custom_join['join']; |
|
5097 | + $query = "SELECT $this->table_name.*".$custom_join['select']." FROM $this->table_name ".$custom_join['join']; |
|
5098 | 5098 | $query .= " $where_clause"; |
5099 | 5099 | $GLOBALS['log']->debug("Retrieve $this->object_name: ".$query); |
5100 | 5100 | //requireSingleResult has been deprecated. |
5101 | 5101 | //$result = $this->db->requireSingleResult($query, true, "Retrieving record $where_clause:"); |
5102 | - $result = $this->db->limitQuery($query,0,1,true, "Retrieving record $where_clause:"); |
|
5102 | + $result = $this->db->limitQuery($query, 0, 1, true, "Retrieving record $where_clause:"); |
|
5103 | 5103 | |
5104 | 5104 | |
5105 | - if( empty($result)) |
|
5105 | + if (empty($result)) |
|
5106 | 5106 | { |
5107 | 5107 | return null; |
5108 | 5108 | } |
5109 | 5109 | $row = $this->db->fetchByAssoc($result, $encode); |
5110 | - if(empty($row)) |
|
5110 | + if (empty($row)) |
|
5111 | 5111 | { |
5112 | 5112 | return null; |
5113 | 5113 | } |
@@ -5134,7 +5134,7 @@ discard block |
||
5134 | 5134 | { |
5135 | 5135 | foreach ($this->special_functions as $func_name) |
5136 | 5136 | { |
5137 | - if ( method_exists($this,$func_name) ) |
|
5137 | + if (method_exists($this, $func_name)) |
|
5138 | 5138 | { |
5139 | 5139 | $this->$func_name(); |
5140 | 5140 | } |
@@ -5149,52 +5149,52 @@ discard block |
||
5149 | 5149 | { |
5150 | 5150 | } |
5151 | 5151 | |
5152 | - function getRelatedFields($module, $id, $fields, $return_array = false){ |
|
5153 | - if(empty($GLOBALS['beanList'][$module]))return ''; |
|
5152 | + function getRelatedFields($module, $id, $fields, $return_array = false) { |
|
5153 | + if (empty($GLOBALS['beanList'][$module]))return ''; |
|
5154 | 5154 | $object = BeanFactory::getObjectName($module); |
5155 | 5155 | |
5156 | 5156 | VardefManager::loadVardef($module, $object); |
5157 | - if(empty($GLOBALS['dictionary'][$object]['table']))return ''; |
|
5157 | + if (empty($GLOBALS['dictionary'][$object]['table']))return ''; |
|
5158 | 5158 | $table = $GLOBALS['dictionary'][$object]['table']; |
5159 | - $query = 'SELECT id'; |
|
5160 | - foreach($fields as $field=>$alias){ |
|
5161 | - if(!empty($GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields'])){ |
|
5162 | - $query .= ' ,' .$this->db->concat($table, $GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields']) . ' as ' . $alias ; |
|
5163 | - }else if(!empty($GLOBALS['dictionary'][$object]['fields'][$field]) && |
|
5159 | + $query = 'SELECT id'; |
|
5160 | + foreach ($fields as $field=>$alias) { |
|
5161 | + if (!empty($GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields'])) { |
|
5162 | + $query .= ' ,'.$this->db->concat($table, $GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields']).' as '.$alias; |
|
5163 | + } else if (!empty($GLOBALS['dictionary'][$object]['fields'][$field]) && |
|
5164 | 5164 | (empty($GLOBALS['dictionary'][$object]['fields'][$field]['source']) || |
5165 | 5165 | $GLOBALS['dictionary'][$object]['fields'][$field]['source'] != "non-db")) |
5166 | 5166 | { |
5167 | - $query .= ' ,' .$table . '.' . $field . ' as ' . $alias; |
|
5167 | + $query .= ' ,'.$table.'.'.$field.' as '.$alias; |
|
5168 | 5168 | } |
5169 | - if(!$return_array)$this->$alias = ''; |
|
5169 | + if (!$return_array)$this->$alias = ''; |
|
5170 | 5170 | } |
5171 | - if($query == 'SELECT id' || empty($id)){ |
|
5171 | + if ($query == 'SELECT id' || empty($id)) { |
|
5172 | 5172 | return ''; |
5173 | 5173 | } |
5174 | 5174 | |
5175 | 5175 | |
5176 | - if(isset($GLOBALS['dictionary'][$object]['fields']['assigned_user_id'])) |
|
5176 | + if (isset($GLOBALS['dictionary'][$object]['fields']['assigned_user_id'])) |
|
5177 | 5177 | { |
5178 | - $query .= " , ". $table . ".assigned_user_id owner"; |
|
5178 | + $query .= " , ".$table.".assigned_user_id owner"; |
|
5179 | 5179 | |
5180 | 5180 | } |
5181 | - else if(isset($GLOBALS['dictionary'][$object]['fields']['created_by'])) |
|
5181 | + else if (isset($GLOBALS['dictionary'][$object]['fields']['created_by'])) |
|
5182 | 5182 | { |
5183 | - $query .= " , ". $table . ".created_by owner"; |
|
5183 | + $query .= " , ".$table.".created_by owner"; |
|
5184 | 5184 | |
5185 | 5185 | } |
5186 | - $query .= ' FROM ' . $table . ' WHERE deleted=0 AND id='; |
|
5187 | - $result = $GLOBALS['db']->query($query . "'$id'" ); |
|
5186 | + $query .= ' FROM '.$table.' WHERE deleted=0 AND id='; |
|
5187 | + $result = $GLOBALS['db']->query($query."'$id'"); |
|
5188 | 5188 | $row = $GLOBALS['db']->fetchByAssoc($result); |
5189 | - if($return_array){ |
|
5189 | + if ($return_array) { |
|
5190 | 5190 | return $row; |
5191 | 5191 | } |
5192 | - $owner = (empty($row['owner']))?'':$row['owner']; |
|
5193 | - foreach($fields as $alias){ |
|
5194 | - $this->$alias = (!empty($row[$alias]))? $row[$alias]: ''; |
|
5195 | - $alias = $alias .'_owner'; |
|
5192 | + $owner = (empty($row['owner'])) ? '' : $row['owner']; |
|
5193 | + foreach ($fields as $alias) { |
|
5194 | + $this->$alias = (!empty($row[$alias])) ? $row[$alias] : ''; |
|
5195 | + $alias = $alias.'_owner'; |
|
5196 | 5196 | $this->$alias = $owner; |
5197 | - $a_mod = $alias .'_mod'; |
|
5197 | + $a_mod = $alias.'_mod'; |
|
5198 | 5198 | $this->$a_mod = $module; |
5199 | 5199 | } |
5200 | 5200 | |
@@ -5210,39 +5210,39 @@ discard block |
||
5210 | 5210 | function assign_display_fields($currentModule) |
5211 | 5211 | { |
5212 | 5212 | global $timedate; |
5213 | - foreach($this->column_fields as $field) |
|
5213 | + foreach ($this->column_fields as $field) |
|
5214 | 5214 | { |
5215 | - if(isset($this->field_name_map[$field]) && empty($this->$field)) |
|
5215 | + if (isset($this->field_name_map[$field]) && empty($this->$field)) |
|
5216 | 5216 | { |
5217 | - if($this->field_name_map[$field]['type'] != 'date' && $this->field_name_map[$field]['type'] != 'enum') |
|
5217 | + if ($this->field_name_map[$field]['type'] != 'date' && $this->field_name_map[$field]['type'] != 'enum') |
|
5218 | 5218 | $this->$field = $field; |
5219 | - if($this->field_name_map[$field]['type'] == 'date') |
|
5219 | + if ($this->field_name_map[$field]['type'] == 'date') |
|
5220 | 5220 | { |
5221 | 5221 | $this->$field = $timedate->to_display_date('1980-07-09'); |
5222 | 5222 | } |
5223 | - if($this->field_name_map[$field]['type'] == 'enum') |
|
5223 | + if ($this->field_name_map[$field]['type'] == 'enum') |
|
5224 | 5224 | { |
5225 | 5225 | $dom = $this->field_name_map[$field]['options']; |
5226 | 5226 | global $current_language, $app_list_strings; |
5227 | 5227 | $mod_strings = return_module_language($current_language, $currentModule); |
5228 | 5228 | |
5229 | - if(isset($mod_strings[$dom])) |
|
5229 | + if (isset($mod_strings[$dom])) |
|
5230 | 5230 | { |
5231 | 5231 | $options = $mod_strings[$dom]; |
5232 | - foreach($options as $key=>$value) |
|
5232 | + foreach ($options as $key=>$value) |
|
5233 | 5233 | { |
5234 | - if(!empty($key) && empty($this->$field )) |
|
5234 | + if (!empty($key) && empty($this->$field)) |
|
5235 | 5235 | { |
5236 | 5236 | $this->$field = $key; |
5237 | 5237 | } |
5238 | 5238 | } |
5239 | 5239 | } |
5240 | - if(isset($app_list_strings[$dom])) |
|
5240 | + if (isset($app_list_strings[$dom])) |
|
5241 | 5241 | { |
5242 | 5242 | $options = $app_list_strings[$dom]; |
5243 | - foreach($options as $key=>$value) |
|
5243 | + foreach ($options as $key=>$value) |
|
5244 | 5244 | { |
5245 | - if(!empty($key) && empty($this->$field )) |
|
5245 | + if (!empty($key) && empty($this->$field)) |
|
5246 | 5246 | { |
5247 | 5247 | $this->$field = $key; |
5248 | 5248 | } |
@@ -5259,61 +5259,61 @@ discard block |
||
5259 | 5259 | * RELATIONSHIP HANDLING |
5260 | 5260 | */ |
5261 | 5261 | |
5262 | - function set_relationship($table, $relate_values, $check_duplicates = true,$do_update=false,$data_values=null) |
|
5262 | + function set_relationship($table, $relate_values, $check_duplicates = true, $do_update = false, $data_values = null) |
|
5263 | 5263 | { |
5264 | 5264 | $where = ''; |
5265 | 5265 | |
5266 | 5266 | // make sure there is a date modified |
5267 | 5267 | $date_modified = $this->db->convert("'".$GLOBALS['timedate']->nowDb()."'", 'datetime'); |
5268 | 5268 | |
5269 | - $row=null; |
|
5270 | - if($check_duplicates) |
|
5269 | + $row = null; |
|
5270 | + if ($check_duplicates) |
|
5271 | 5271 | { |
5272 | 5272 | $query = "SELECT * FROM $table "; |
5273 | 5273 | $where = "WHERE deleted = '0' "; |
5274 | - foreach($relate_values as $name=>$value) |
|
5274 | + foreach ($relate_values as $name=>$value) |
|
5275 | 5275 | { |
5276 | 5276 | $where .= " AND $name = '$value' "; |
5277 | 5277 | } |
5278 | 5278 | $query .= $where; |
5279 | - $result = $this->db->query($query, false, "Looking For Duplicate Relationship:" . $query); |
|
5280 | - $row=$this->db->fetchByAssoc($result); |
|
5279 | + $result = $this->db->query($query, false, "Looking For Duplicate Relationship:".$query); |
|
5280 | + $row = $this->db->fetchByAssoc($result); |
|
5281 | 5281 | } |
5282 | 5282 | |
5283 | - if(!$check_duplicates || empty($row) ) |
|
5283 | + if (!$check_duplicates || empty($row)) |
|
5284 | 5284 | { |
5285 | 5285 | unset($relate_values['id']); |
5286 | - if ( isset($data_values)) |
|
5286 | + if (isset($data_values)) |
|
5287 | 5287 | { |
5288 | - $relate_values = array_merge($relate_values,$data_values); |
|
5288 | + $relate_values = array_merge($relate_values, $data_values); |
|
5289 | 5289 | } |
5290 | - $query = "INSERT INTO $table (id, ". implode(',', array_keys($relate_values)) . ", date_modified) VALUES ('" . create_guid() . "', " . "'" . implode("', '", $relate_values) . "', ".$date_modified.")" ; |
|
5290 | + $query = "INSERT INTO $table (id, ".implode(',', array_keys($relate_values)).", date_modified) VALUES ('".create_guid()."', "."'".implode("', '", $relate_values)."', ".$date_modified.")"; |
|
5291 | 5291 | |
5292 | - $this->db->query($query, false, "Creating Relationship:" . $query); |
|
5292 | + $this->db->query($query, false, "Creating Relationship:".$query); |
|
5293 | 5293 | } |
5294 | 5294 | else if ($do_update) |
5295 | 5295 | { |
5296 | 5296 | $conds = array(); |
5297 | - foreach($data_values as $key=>$value) |
|
5297 | + foreach ($data_values as $key=>$value) |
|
5298 | 5298 | { |
5299 | - array_push($conds,$key."='".$this->db->quote($value)."'"); |
|
5299 | + array_push($conds, $key."='".$this->db->quote($value)."'"); |
|
5300 | 5300 | } |
5301 | - $query = "UPDATE $table SET ". implode(',', $conds).",date_modified=".$date_modified." ".$where; |
|
5302 | - $this->db->query($query, false, "Updating Relationship:" . $query); |
|
5301 | + $query = "UPDATE $table SET ".implode(',', $conds).",date_modified=".$date_modified." ".$where; |
|
5302 | + $this->db->query($query, false, "Updating Relationship:".$query); |
|
5303 | 5303 | } |
5304 | 5304 | } |
5305 | 5305 | |
5306 | 5306 | function retrieve_relationships($table, $values, $select_id) |
5307 | 5307 | { |
5308 | 5308 | $query = "SELECT $select_id FROM $table WHERE deleted = 0 "; |
5309 | - foreach($values as $name=>$value) |
|
5309 | + foreach ($values as $name=>$value) |
|
5310 | 5310 | { |
5311 | 5311 | $query .= " AND $name = '$value' "; |
5312 | 5312 | } |
5313 | 5313 | $query .= " ORDER BY $select_id "; |
5314 | - $result = $this->db->query($query, false, "Retrieving Relationship:" . $query); |
|
5314 | + $result = $this->db->query($query, false, "Retrieving Relationship:".$query); |
|
5315 | 5315 | $ids = array(); |
5316 | - while($row = $this->db->fetchByAssoc($result)) |
|
5316 | + while ($row = $this->db->fetchByAssoc($result)) |
|
5317 | 5317 | { |
5318 | 5318 | $ids[] = $row; |
5319 | 5319 | } |
@@ -5324,16 +5324,16 @@ discard block |
||
5324 | 5324 | function loadLayoutDefs() |
5325 | 5325 | { |
5326 | 5326 | global $layout_defs; |
5327 | - if(empty( $this->layout_def) && file_exists('modules/'. $this->module_dir . '/layout_defs.php')) |
|
5327 | + if (empty($this->layout_def) && file_exists('modules/'.$this->module_dir.'/layout_defs.php')) |
|
5328 | 5328 | { |
5329 | - include_once('modules/'. $this->module_dir . '/layout_defs.php'); |
|
5330 | - if(file_exists('custom/modules/'. $this->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php')) |
|
5329 | + include_once('modules/'.$this->module_dir.'/layout_defs.php'); |
|
5330 | + if (file_exists('custom/modules/'.$this->module_dir.'/Ext/Layoutdefs/layoutdefs.ext.php')) |
|
5331 | 5331 | { |
5332 | - include_once('custom/modules/'. $this->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php'); |
|
5332 | + include_once('custom/modules/'.$this->module_dir.'/Ext/Layoutdefs/layoutdefs.ext.php'); |
|
5333 | 5333 | } |
5334 | - if ( empty( $layout_defs[get_class($this)])) |
|
5334 | + if (empty($layout_defs[get_class($this)])) |
|
5335 | 5335 | { |
5336 | - echo "\$layout_defs[" . get_class($this) . "]; does not exist"; |
|
5336 | + echo "\$layout_defs[".get_class($this)."]; does not exist"; |
|
5337 | 5337 | } |
5338 | 5338 | |
5339 | 5339 | $this->layout_def = $layout_defs[get_class($this)]; |
@@ -5367,12 +5367,12 @@ discard block |
||
5367 | 5367 | */ |
5368 | 5368 | function call_custom_logic($event, $arguments = null) |
5369 | 5369 | { |
5370 | - if(!isset($this->processed) || $this->processed == false){ |
|
5370 | + if (!isset($this->processed) || $this->processed == false) { |
|
5371 | 5371 | //add some logic to ensure we do not get into an infinite loop |
5372 | - if(!empty($this->logicHookDepth[$event])) { |
|
5373 | - if($this->logicHookDepth[$event] > $this->max_logic_depth) |
|
5372 | + if (!empty($this->logicHookDepth[$event])) { |
|
5373 | + if ($this->logicHookDepth[$event] > $this->max_logic_depth) |
|
5374 | 5374 | return; |
5375 | - }else |
|
5375 | + } else |
|
5376 | 5376 | $this->logicHookDepth[$event] = 0; |
5377 | 5377 | |
5378 | 5378 | //we have to put the increment operator here |
@@ -5417,7 +5417,7 @@ discard block |
||
5417 | 5417 | $GLOBALS['log']->fatal("SUGARBEAN: cannot find Real Key for custom field of type dropdown - cannot return Value."); |
5418 | 5418 | return false; |
5419 | 5419 | } |
5420 | - if(isset($realKey)) |
|
5420 | + if (isset($realKey)) |
|
5421 | 5421 | { |
5422 | 5422 | return $this->custom_fields->avail_fields[$name][$realKey]; |
5423 | 5423 | } |
@@ -5436,17 +5436,17 @@ discard block |
||
5436 | 5436 | /** |
5437 | 5437 | function ACLAccess($view,$is_owner='not_set') |
5438 | 5438 | */ |
5439 | - function ACLAccess($view,$is_owner='not_set',$in_group='not_set') |
|
5439 | + function ACLAccess($view, $is_owner = 'not_set', $in_group = 'not_set') |
|
5440 | 5440 | { |
5441 | 5441 | global $current_user; |
5442 | - if($current_user->isAdmin()) { |
|
5442 | + if ($current_user->isAdmin()) { |
|
5443 | 5443 | return true; |
5444 | 5444 | } |
5445 | 5445 | $not_set = false; |
5446 | 5446 | /** |
5447 | 5447 | if($is_owner == 'not_set') |
5448 | 5448 | */ |
5449 | - if($is_owner === 'not_set') //eggsurplus: should be === |
|
5449 | + if ($is_owner === 'not_set') //eggsurplus: should be === |
|
5450 | 5450 | { |
5451 | 5451 | $not_set = true; |
5452 | 5452 | $is_owner = $this->isOwner($current_user->id); |
@@ -5457,7 +5457,7 @@ discard block |
||
5457 | 5457 | $view = strtolower($view); |
5458 | 5458 | $action = ''; |
5459 | 5459 | // DJM - OBS Customizations - END CHANGE |
5460 | - if($in_group === 'not_set') |
|
5460 | + if ($in_group === 'not_set') |
|
5461 | 5461 | { |
5462 | 5462 | require_once("modules/SecurityGroups/SecurityGroup.php"); |
5463 | 5463 | // DJM - OBS Customizations - May 2009 |
@@ -5483,7 +5483,7 @@ discard block |
||
5483 | 5483 | $action = "view"; |
5484 | 5484 | break; |
5485 | 5485 | case 'delete': |
5486 | - $action = "delete" ; |
|
5486 | + $action = "delete"; |
|
5487 | 5487 | break; |
5488 | 5488 | case 'export': |
5489 | 5489 | $action = "export"; |
@@ -5495,11 +5495,11 @@ discard block |
||
5495 | 5495 | $action = ""; |
5496 | 5496 | break; |
5497 | 5497 | } |
5498 | - $in_group = SecurityGroup::groupHasAccess($this->module_dir,$this->id, $action); |
|
5498 | + $in_group = SecurityGroup::groupHasAccess($this->module_dir, $this->id, $action); |
|
5499 | 5499 | // DJM - OBS Customizations - END CHANGE |
5500 | 5500 | } |
5501 | 5501 | //if we don't implent acls return true |
5502 | - if(!$this->bean_implements('ACL')) |
|
5502 | + if (!$this->bean_implements('ACL')) |
|
5503 | 5503 | return true; |
5504 | 5504 | $view = strtolower($view); |
5505 | 5505 | switch ($view) |
@@ -5510,15 +5510,15 @@ discard block |
||
5510 | 5510 | /** |
5511 | 5511 | return ACLController::checkAccess($this->module_dir,'list', true); |
5512 | 5512 | */ |
5513 | - return ACLController::checkAccess($this->module_dir,'list', true, $this->acltype, $in_group); |
|
5513 | + return ACLController::checkAccess($this->module_dir, 'list', true, $this->acltype, $in_group); |
|
5514 | 5514 | case 'edit': |
5515 | 5515 | case 'save': |
5516 | - if( !$is_owner && $not_set && !empty($this->id)){ |
|
5516 | + if (!$is_owner && $not_set && !empty($this->id)) { |
|
5517 | 5517 | $class = get_class($this); |
5518 | 5518 | $temp = new $class(); |
5519 | - if(!empty($this->fetched_row) && !empty($this->fetched_row['id']) && !empty($this->fetched_row['assigned_user_id']) && !empty($this->fetched_row['created_by'])){ |
|
5519 | + if (!empty($this->fetched_row) && !empty($this->fetched_row['id']) && !empty($this->fetched_row['assigned_user_id']) && !empty($this->fetched_row['created_by'])) { |
|
5520 | 5520 | $temp->populateFromRow($this->fetched_row); |
5521 | - }else{ |
|
5521 | + } else { |
|
5522 | 5522 | $temp->retrieve($this->id); |
5523 | 5523 | } |
5524 | 5524 | $is_owner = $temp->isOwner($current_user->id); |
@@ -5528,29 +5528,29 @@ discard block |
||
5528 | 5528 | /** |
5529 | 5529 | return ACLController::checkAccess($this->module_dir,'edit', $is_owner, $this->acltype); |
5530 | 5530 | */ |
5531 | - return ACLController::checkAccess($this->module_dir,'edit', $is_owner, $this->acltype, $in_group); |
|
5531 | + return ACLController::checkAccess($this->module_dir, 'edit', $is_owner, $this->acltype, $in_group); |
|
5532 | 5532 | case 'view': |
5533 | 5533 | case 'detail': |
5534 | 5534 | case 'detailview': |
5535 | 5535 | /** |
5536 | 5536 | return ACLController::checkAccess($this->module_dir,'view', $is_owner, $this->acltype); |
5537 | 5537 | */ |
5538 | - return ACLController::checkAccess($this->module_dir,'view', $is_owner, $this->acltype, $in_group); |
|
5538 | + return ACLController::checkAccess($this->module_dir, 'view', $is_owner, $this->acltype, $in_group); |
|
5539 | 5539 | case 'delete': |
5540 | 5540 | /** |
5541 | 5541 | return ACLController::checkAccess($this->module_dir,'delete', $is_owner, $this->acltype); |
5542 | 5542 | */ |
5543 | - return ACLController::checkAccess($this->module_dir,'delete', $is_owner, $this->acltype, $in_group); |
|
5543 | + return ACLController::checkAccess($this->module_dir, 'delete', $is_owner, $this->acltype, $in_group); |
|
5544 | 5544 | case 'export': |
5545 | 5545 | /** |
5546 | 5546 | return ACLController::checkAccess($this->module_dir,'export', $is_owner, $this->acltype); |
5547 | 5547 | */ |
5548 | - return ACLController::checkAccess($this->module_dir,'export', $is_owner, $this->acltype, $in_group); |
|
5548 | + return ACLController::checkAccess($this->module_dir, 'export', $is_owner, $this->acltype, $in_group); |
|
5549 | 5549 | case 'import': |
5550 | 5550 | /** |
5551 | 5551 | return ACLController::checkAccess($this->module_dir,'import', true, $this->acltype); |
5552 | 5552 | */ |
5553 | - return ACLController::checkAccess($this->module_dir,'import', true, $this->acltype, $in_group); |
|
5553 | + return ACLController::checkAccess($this->module_dir, 'import', true, $this->acltype, $in_group); |
|
5554 | 5554 | } |
5555 | 5555 | //if it is not one of the above views then it should be implemented on the page level |
5556 | 5556 | return true; |
@@ -5566,12 +5566,12 @@ discard block |
||
5566 | 5566 | { |
5567 | 5567 | if (isset($this->field_defs['assigned_user_id'])) |
5568 | 5568 | { |
5569 | - return $returnFieldName? 'assigned_user_id': $this->assigned_user_id; |
|
5569 | + return $returnFieldName ? 'assigned_user_id' : $this->assigned_user_id; |
|
5570 | 5570 | } |
5571 | 5571 | |
5572 | 5572 | if (isset($this->field_defs['created_by'])) |
5573 | 5573 | { |
5574 | - return $returnFieldName? 'created_by': $this->created_by; |
|
5574 | + return $returnFieldName ? 'created_by' : $this->created_by; |
|
5575 | 5575 | } |
5576 | 5576 | |
5577 | 5577 | return ''; |
@@ -5586,7 +5586,7 @@ discard block |
||
5586 | 5586 | function isOwner($user_id) |
5587 | 5587 | { |
5588 | 5588 | //if we don't have an id we must be the owner as we are creating it |
5589 | - if(!isset($this->id)) |
|
5589 | + if (!isset($this->id)) |
|
5590 | 5590 | { |
5591 | 5591 | return true; |
5592 | 5592 | } |
@@ -5597,13 +5597,13 @@ discard block |
||
5597 | 5597 | } |
5598 | 5598 | return false; |
5599 | 5599 | } elseif (isset($this->assigned_user_id)) { |
5600 | - if($this->assigned_user_id == $user_id) return true; |
|
5600 | + if ($this->assigned_user_id == $user_id) return true; |
|
5601 | 5601 | return false; |
5602 | 5602 | } |
5603 | 5603 | else |
5604 | 5604 | { |
5605 | 5605 | //other wise if there is a created_by that is the owner |
5606 | - if(isset($this->created_by) && $this->created_by == $user_id) |
|
5606 | + if (isset($this->created_by) && $this->created_by == $user_id) |
|
5607 | 5607 | { |
5608 | 5608 | return true; |
5609 | 5609 | } |
@@ -5618,11 +5618,11 @@ discard block |
||
5618 | 5618 | */ |
5619 | 5619 | function getOwnerWhere($user_id) |
5620 | 5620 | { |
5621 | - if(isset($this->field_defs['assigned_user_id'])) |
|
5621 | + if (isset($this->field_defs['assigned_user_id'])) |
|
5622 | 5622 | { |
5623 | 5623 | return " $this->table_name.assigned_user_id ='$user_id' "; |
5624 | 5624 | } |
5625 | - if(isset($this->field_defs['created_by'])) |
|
5625 | + if (isset($this->field_defs['created_by'])) |
|
5626 | 5626 | { |
5627 | 5627 | return " $this->table_name.created_by ='$user_id' "; |
5628 | 5628 | } |
@@ -5639,7 +5639,7 @@ discard block |
||
5639 | 5639 | function listviewACLHelper() |
5640 | 5640 | { |
5641 | 5641 | $array_assign = array(); |
5642 | - if($this->ACLAccess('DetailView')) |
|
5642 | + if ($this->ACLAccess('DetailView')) |
|
5643 | 5643 | { |
5644 | 5644 | $array_assign['MAIN'] = 'a'; |
5645 | 5645 | } |
@@ -5655,27 +5655,27 @@ discard block |
||
5655 | 5655 | * |
5656 | 5656 | * @return array of fields with id, name, access and category |
5657 | 5657 | */ |
5658 | - function toArray($dbOnly = false, $stringOnly = false, $upperKeys=false) |
|
5658 | + function toArray($dbOnly = false, $stringOnly = false, $upperKeys = false) |
|
5659 | 5659 | { |
5660 | 5660 | static $cache = array(); |
5661 | 5661 | $arr = array(); |
5662 | 5662 | |
5663 | - foreach($this->field_defs as $field=>$data) |
|
5663 | + foreach ($this->field_defs as $field=>$data) |
|
5664 | 5664 | { |
5665 | - if( !$dbOnly || !isset($data['source']) || $data['source'] == 'db') |
|
5666 | - if(!$stringOnly || is_string($this->$field)) |
|
5667 | - if($upperKeys) |
|
5665 | + if (!$dbOnly || !isset($data['source']) || $data['source'] == 'db') |
|
5666 | + if (!$stringOnly || is_string($this->$field)) |
|
5667 | + if ($upperKeys) |
|
5668 | 5668 | { |
5669 | - if(!isset($cache[$field])){ |
|
5669 | + if (!isset($cache[$field])) { |
|
5670 | 5670 | $cache[$field] = strtoupper($field); |
5671 | 5671 | } |
5672 | 5672 | $arr[$cache[$field]] = $this->$field; |
5673 | 5673 | } |
5674 | 5674 | else |
5675 | 5675 | { |
5676 | - if(isset($this->$field)){ |
|
5676 | + if (isset($this->$field)) { |
|
5677 | 5677 | $arr[$field] = $this->$field; |
5678 | - }else{ |
|
5678 | + } else { |
|
5679 | 5679 | $arr[$field] = ''; |
5680 | 5680 | } |
5681 | 5681 | } |
@@ -5690,7 +5690,7 @@ discard block |
||
5690 | 5690 | */ |
5691 | 5691 | function fromArray($arr) |
5692 | 5692 | { |
5693 | - foreach($arr as $name=>$value) |
|
5693 | + foreach ($arr as $name=>$value) |
|
5694 | 5694 | { |
5695 | 5695 | $this->$name = $value; |
5696 | 5696 | } |
@@ -5704,7 +5704,7 @@ discard block |
||
5704 | 5704 | */ |
5705 | 5705 | public function convertRow($row) |
5706 | 5706 | { |
5707 | - foreach($this->field_defs as $name => $fieldDef) |
|
5707 | + foreach ($this->field_defs as $name => $fieldDef) |
|
5708 | 5708 | { |
5709 | 5709 | // skip empty fields and non-db fields |
5710 | 5710 | if (isset($name) && !empty($row[$name])) { |
@@ -5750,7 +5750,7 @@ discard block |
||
5750 | 5750 | |
5751 | 5751 | $this->fill_in_additional_list_fields(); |
5752 | 5752 | |
5753 | - if($this->hasCustomFields())$this->custom_fields->fill_relationships(); |
|
5753 | + if ($this->hasCustomFields())$this->custom_fields->fill_relationships(); |
|
5754 | 5754 | $this->call_custom_logic("process_record"); |
5755 | 5755 | } |
5756 | 5756 | |
@@ -5769,7 +5769,7 @@ discard block |
||
5769 | 5769 | * |
5770 | 5770 | * Internal function do not override. |
5771 | 5771 | */ |
5772 | - function create_qualified_order_by( $order_by, $qualify) |
|
5772 | + function create_qualified_order_by($order_by, $qualify) |
|
5773 | 5773 | { // if the column is empty, but the sort order is defined, the value will throw an error, so do not proceed if no order by is given |
5774 | 5774 | if (empty($order_by)) |
5775 | 5775 | { |
@@ -5778,10 +5778,10 @@ discard block |
||
5778 | 5778 | $order_by_clause = " ORDER BY "; |
5779 | 5779 | $tmp = explode(",", $order_by); |
5780 | 5780 | $comma = ' '; |
5781 | - foreach ( $tmp as $stmp) |
|
5781 | + foreach ($tmp as $stmp) |
|
5782 | 5782 | { |
5783 | - $stmp = (substr_count($stmp, ".") > 0?trim($stmp):"$qualify." . trim($stmp)); |
|
5784 | - $order_by_clause .= $comma . $stmp; |
|
5783 | + $stmp = (substr_count($stmp, ".") > 0 ? trim($stmp) : "$qualify.".trim($stmp)); |
|
5784 | + $order_by_clause .= $comma.$stmp; |
|
5785 | 5785 | $comma = ", "; |
5786 | 5786 | } |
5787 | 5787 | return $order_by_clause; |
@@ -5801,16 +5801,16 @@ discard block |
||
5801 | 5801 | $street_field_2 = $street_field.'_2'; |
5802 | 5802 | $street_field_3 = $street_field.'_3'; |
5803 | 5803 | $street_field_4 = $street_field.'_4'; |
5804 | - if ( isset($this->$street_field_2)) { |
|
5805 | - $this->$street_field .= "\n". $this->$street_field_2; |
|
5804 | + if (isset($this->$street_field_2)) { |
|
5805 | + $this->$street_field .= "\n".$this->$street_field_2; |
|
5806 | 5806 | unset($this->$street_field_2); |
5807 | 5807 | } |
5808 | - if ( isset($this->$street_field_3)) { |
|
5809 | - $this->$street_field .= "\n". $this->$street_field_3; |
|
5808 | + if (isset($this->$street_field_3)) { |
|
5809 | + $this->$street_field .= "\n".$this->$street_field_3; |
|
5810 | 5810 | unset($this->$street_field_3); |
5811 | 5811 | } |
5812 | - if ( isset($this->$street_field_4)) { |
|
5813 | - $this->$street_field .= "\n". $this->$street_field_4; |
|
5812 | + if (isset($this->$street_field_4)) { |
|
5813 | + $this->$street_field .= "\n".$this->$street_field_4; |
|
5814 | 5814 | unset($this->$street_field_4); |
5815 | 5815 | } |
5816 | 5816 | $this->$street_field = trim($this->$street_field, "\n"); |
@@ -5819,7 +5819,7 @@ discard block |
||
5819 | 5819 | |
5820 | 5820 | protected function getEncryptKey() |
5821 | 5821 | { |
5822 | - if(empty(self::$field_key)) { |
|
5822 | + if (empty(self::$field_key)) { |
|
5823 | 5823 | self::$field_key = blowfishGetKey('encrypt_field'); |
5824 | 5824 | } |
5825 | 5825 | return self::$field_key; |
@@ -5843,7 +5843,7 @@ discard block |
||
5843 | 5843 | */ |
5844 | 5844 | function decrypt_after_retrieve($value) |
5845 | 5845 | { |
5846 | - if(empty($value)) return $value; // no need to decrypt empty |
|
5846 | + if (empty($value)) return $value; // no need to decrypt empty |
|
5847 | 5847 | require_once("include/utils/encryption_utils.php"); |
5848 | 5848 | return blowfishDecode($this->getEncryptKey(), $value); |
5849 | 5849 | } |
@@ -5852,19 +5852,19 @@ discard block |
||
5852 | 5852 | * Moved from save() method, functionality is the same, but this is intended to handle |
5853 | 5853 | * Optimistic locking functionality. |
5854 | 5854 | */ |
5855 | - private function _checkOptimisticLocking($action, $isUpdate){ |
|
5856 | - if($this->optimistic_lock && !isset($_SESSION['o_lock_fs'])){ |
|
5857 | - if(isset($_SESSION['o_lock_id']) && $_SESSION['o_lock_id'] == $this->id && $_SESSION['o_lock_on'] == $this->object_name) |
|
5855 | + private function _checkOptimisticLocking($action, $isUpdate) { |
|
5856 | + if ($this->optimistic_lock && !isset($_SESSION['o_lock_fs'])) { |
|
5857 | + if (isset($_SESSION['o_lock_id']) && $_SESSION['o_lock_id'] == $this->id && $_SESSION['o_lock_on'] == $this->object_name) |
|
5858 | 5858 | { |
5859 | - if($action == 'Save' && $isUpdate && isset($this->modified_user_id) && $this->has_been_modified_since($_SESSION['o_lock_dm'], $this->modified_user_id)) |
|
5859 | + if ($action == 'Save' && $isUpdate && isset($this->modified_user_id) && $this->has_been_modified_since($_SESSION['o_lock_dm'], $this->modified_user_id)) |
|
5860 | 5860 | { |
5861 | 5861 | $_SESSION['o_lock_class'] = get_class($this); |
5862 | 5862 | $_SESSION['o_lock_module'] = $this->module_dir; |
5863 | 5863 | $_SESSION['o_lock_object'] = $this->toArray(); |
5864 | 5864 | $saveform = "<form name='save' id='save' method='POST'>"; |
5865 | - foreach($_POST as $key=>$arg) |
|
5865 | + foreach ($_POST as $key=>$arg) |
|
5866 | 5866 | { |
5867 | - $saveform .= "<input type='hidden' name='". addslashes($key) ."' value='". addslashes($arg) ."'>"; |
|
5867 | + $saveform .= "<input type='hidden' name='".addslashes($key)."' value='".addslashes($arg)."'>"; |
|
5868 | 5868 | } |
5869 | 5869 | $saveform .= "</form><script>document.getElementById('save').submit();</script>"; |
5870 | 5870 | $_SESSION['o_lock_save'] = $saveform; |
@@ -5881,20 +5881,20 @@ discard block |
||
5881 | 5881 | } |
5882 | 5882 | else |
5883 | 5883 | { |
5884 | - if(isset($_SESSION['o_lock_object'])) { unset ($_SESSION['o_lock_object']); } |
|
5885 | - if(isset($_SESSION['o_lock_id'])) { unset ($_SESSION['o_lock_id']); } |
|
5886 | - if(isset($_SESSION['o_lock_dm'])) { unset ($_SESSION['o_lock_dm']); } |
|
5887 | - if(isset($_SESSION['o_lock_fs'])) { unset ($_SESSION['o_lock_fs']); } |
|
5888 | - if(isset($_SESSION['o_lock_save'])) { unset ($_SESSION['o_lock_save']); } |
|
5884 | + if (isset($_SESSION['o_lock_object'])) { unset ($_SESSION['o_lock_object']); } |
|
5885 | + if (isset($_SESSION['o_lock_id'])) { unset ($_SESSION['o_lock_id']); } |
|
5886 | + if (isset($_SESSION['o_lock_dm'])) { unset ($_SESSION['o_lock_dm']); } |
|
5887 | + if (isset($_SESSION['o_lock_fs'])) { unset ($_SESSION['o_lock_fs']); } |
|
5888 | + if (isset($_SESSION['o_lock_save'])) { unset ($_SESSION['o_lock_save']); } |
|
5889 | 5889 | } |
5890 | 5890 | } |
5891 | 5891 | |
5892 | 5892 | /** |
5893 | 5893 | * Send assignment notifications and invites for meetings and calls |
5894 | 5894 | */ |
5895 | - private function _sendNotifications($check_notify){ |
|
5896 | - if($check_notify || (isset($this->notify_inworkflow) && $this->notify_inworkflow == true) // cn: bug 5795 - no invites sent to Contacts, and also bug 25995, in workflow, it will set the notify_on_save=true. |
|
5897 | - && !$this->isOwner($this->created_by) ) // cn: bug 42727 no need to send email to owner (within workflow) |
|
5895 | + private function _sendNotifications($check_notify) { |
|
5896 | + if ($check_notify || (isset($this->notify_inworkflow) && $this->notify_inworkflow == true) // cn: bug 5795 - no invites sent to Contacts, and also bug 25995, in workflow, it will set the notify_on_save=true. |
|
5897 | + && !$this->isOwner($this->created_by)) // cn: bug 42727 no need to send email to owner (within workflow) |
|
5898 | 5898 | { |
5899 | 5899 | $admin = new Administration(); |
5900 | 5900 | $admin->retrieveSettings(); |
@@ -5905,7 +5905,7 @@ discard block |
||
5905 | 5905 | $GLOBALS['log']->info("Notifications: user assignment has changed, checking if user receives notifications"); |
5906 | 5906 | $sendNotifications = true; |
5907 | 5907 | } |
5908 | - elseif(isset($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == 1) |
|
5908 | + elseif (isset($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == 1) |
|
5909 | 5909 | { |
5910 | 5910 | // cn: bug 5795 Send Invites failing for Contacts |
5911 | 5911 | $sendNotifications = true; |
@@ -5916,7 +5916,7 @@ discard block |
||
5916 | 5916 | } |
5917 | 5917 | |
5918 | 5918 | |
5919 | - if($sendNotifications == true) |
|
5919 | + if ($sendNotifications == true) |
|
5920 | 5920 | { |
5921 | 5921 | $notify_list = $this->get_notification_recipients(); |
5922 | 5922 | foreach ($notify_list as $notify_user) |
@@ -5977,10 +5977,10 @@ discard block |
||
5977 | 5977 | |
5978 | 5978 | $cache_key = "load_cached_array.$module_dir.$module.$key"; |
5979 | 5979 | $result = sugar_cache_retrieve($cache_key); |
5980 | - if(!empty($result)) |
|
5980 | + if (!empty($result)) |
|
5981 | 5981 | { |
5982 | 5982 | // Use SugarCache::EXTERNAL_CACHE_NULL_VALUE to store null values in the cache. |
5983 | - if($result == SugarCache::EXTERNAL_CACHE_NULL_VALUE) |
|
5983 | + if ($result == SugarCache::EXTERNAL_CACHE_NULL_VALUE) |
|
5984 | 5984 | { |
5985 | 5985 | return null; |
5986 | 5986 | } |
@@ -5988,16 +5988,16 @@ discard block |
||
5988 | 5988 | return $result; |
5989 | 5989 | } |
5990 | 5990 | |
5991 | - if(file_exists('modules/'.$module_dir.'/'.$fileName)) |
|
5991 | + if (file_exists('modules/'.$module_dir.'/'.$fileName)) |
|
5992 | 5992 | { |
5993 | 5993 | // If the data was not loaded, try loading again.... |
5994 | - if(!isset($moduleDefs[$module])) |
|
5994 | + if (!isset($moduleDefs[$module])) |
|
5995 | 5995 | { |
5996 | 5996 | include('modules/'.$module_dir.'/'.$fileName); |
5997 | 5997 | $moduleDefs[$module] = $fields_array; |
5998 | 5998 | } |
5999 | 5999 | // Now that we have tried loading, make sure it was loaded |
6000 | - if(empty($moduleDefs[$module]) || empty($moduleDefs[$module][$module][$key])) |
|
6000 | + if (empty($moduleDefs[$module]) || empty($moduleDefs[$module][$module][$key])) |
|
6001 | 6001 | { |
6002 | 6002 | // It was not loaded.... Fail. Cache null to prevent future repeats of this calculation |
6003 | 6003 | sugar_cache_put($cache_key, SugarCache::EXTERNAL_CACHE_NULL_VALUE); |
@@ -6022,7 +6022,7 @@ discard block |
||
6022 | 6022 | */ |
6023 | 6023 | public function getACLCategory() |
6024 | 6024 | { |
6025 | - return !empty($this->acl_category)?$this->acl_category:$this->module_dir; |
|
6025 | + return !empty($this->acl_category) ? $this->acl_category : $this->module_dir; |
|
6026 | 6026 | } |
6027 | 6027 | |
6028 | 6028 | /** |
@@ -6071,7 +6071,7 @@ discard block |
||
6071 | 6071 | 'select' => '', |
6072 | 6072 | 'join' => '' |
6073 | 6073 | ); |
6074 | - if(isset($this->custom_fields)) |
|
6074 | + if (isset($this->custom_fields)) |
|
6075 | 6075 | { |
6076 | 6076 | $result = $this->custom_fields->getJOIN($expandedList, $includeRelates, $where); |
6077 | 6077 | } |
@@ -6093,7 +6093,7 @@ discard block |
||
6093 | 6093 | // walk through all currency-related fields |
6094 | 6094 | foreach ($this->field_defs as $this_field) { |
6095 | 6095 | if (isset($this_field['type']) && $this_field['type'] == 'relate' |
6096 | - && isset($this_field['module']) && $this_field['module'] == 'Currencies' |
|
6096 | + && isset($this_field['module']) && $this_field['module'] == 'Currencies' |
|
6097 | 6097 | && isset($this_field['id_name']) && $this_field['id_name'] == 'currency_id') { |
6098 | 6098 | // populate related properties manually |
6099 | 6099 | $this_property = $this_field['name']; |