@@ -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. |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | { |
45 | 45 | public $loggedIn = false; //if a user has attempted to login |
46 | 46 | public $authenticated = false; |
47 | - public $loginSuccess = false;// if a user has successfully logged in |
|
47 | + public $loginSuccess = false; // if a user has successfully logged in |
|
48 | 48 | |
49 | 49 | protected static $authcontrollerinstance = null; |
50 | 50 | |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | // check in custom dir first, in case someone want's to override an auth controller |
84 | - if (file_exists('custom/modules/Users/authentication/'.$type.'/' . $type . '.php')) { |
|
85 | - require_once('custom/modules/Users/authentication/'.$type.'/' . $type . '.php'); |
|
86 | - } elseif (file_exists('modules/Users/authentication/'.$type.'/' . $type . '.php')) { |
|
87 | - require_once('modules/Users/authentication/'.$type.'/' . $type . '.php'); |
|
84 | + if (file_exists('custom/modules/Users/authentication/'.$type.'/'.$type.'.php')) { |
|
85 | + require_once('custom/modules/Users/authentication/'.$type.'/'.$type.'.php'); |
|
86 | + } elseif (file_exists('modules/Users/authentication/'.$type.'/'.$type.'.php')) { |
|
87 | + require_once('modules/Users/authentication/'.$type.'/'.$type.'.php'); |
|
88 | 88 | } else { |
89 | 89 | require_once('modules/Users/authentication/SugarAuthenticate/SugarAuthenticate.php'); |
90 | 90 | $type = 'SugarAuthenticate'; |
@@ -124,21 +124,21 @@ discard block |
||
124 | 124 | public function login($username, $password, $PARAMS = array()) |
125 | 125 | { |
126 | 126 | //kbrill bug #13225 |
127 | - $_SESSION['loginAttempts'] = (isset($_SESSION['loginAttempts']))? $_SESSION['loginAttempts'] + 1: 1; |
|
127 | + $_SESSION['loginAttempts'] = (isset($_SESSION['loginAttempts'])) ? $_SESSION['loginAttempts'] + 1 : 1; |
|
128 | 128 | unset($GLOBALS['login_error']); |
129 | 129 | |
130 | - if($this->loggedIn)return $this->loginSuccess; |
|
130 | + if ($this->loggedIn)return $this->loginSuccess; |
|
131 | 131 | LogicHook::initialize()->call_custom_logic('Users', 'before_login'); |
132 | 132 | |
133 | 133 | $this->loginSuccess = $this->authController->loginAuthenticate($username, $password, false, $PARAMS); |
134 | 134 | $this->loggedIn = true; |
135 | 135 | |
136 | - if($this->loginSuccess){ |
|
136 | + if ($this->loginSuccess) { |
|
137 | 137 | //Ensure the user is authorized |
138 | 138 | checkAuthUserStatus(); |
139 | 139 | |
140 | 140 | //loginLicense(); |
141 | - if(!empty($GLOBALS['login_error'])){ |
|
141 | + if (!empty($GLOBALS['login_error'])) { |
|
142 | 142 | unset($_SESSION['authenticated_user_id']); |
143 | 143 | $GLOBALS['log']->fatal('FAILED LOGIN: potential hack attempt:'.$GLOBALS['login_error']); |
144 | 144 | $this->loginSuccess = false; |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | //call business logic hook |
149 | - if(isset($GLOBALS['current_user'])) |
|
149 | + if (isset($GLOBALS['current_user'])) |
|
150 | 150 | $GLOBALS['current_user']->call_custom_logic('after_login'); |
151 | 151 | |
152 | 152 | // Check for running Admin Wizard |
153 | 153 | $config = new Administration(); |
154 | 154 | $config->retrieveSettings(); |
155 | - if ( is_admin($GLOBALS['current_user']) && empty($config->settings['system_adminwizard']) && $_REQUEST['action'] != 'AdminWizard' ) { |
|
155 | + if (is_admin($GLOBALS['current_user']) && empty($config->settings['system_adminwizard']) && $_REQUEST['action'] != 'AdminWizard') { |
|
156 | 156 | $GLOBALS['module'] = 'Configurator'; |
157 | 157 | $GLOBALS['action'] = 'AdminWizard'; |
158 | 158 | ob_clean(); |
@@ -165,18 +165,18 @@ discard block |
||
165 | 165 | if (is_array($PARAMS) && !empty($PARAMS) && isset($PARAMS['passwordEncrypted'])) { |
166 | 166 | $checkTimeZone = false; |
167 | 167 | } // if |
168 | - if(empty($ut) && $checkTimeZone && $_REQUEST['action'] != 'SetTimezone' && $_REQUEST['action'] != 'SaveTimezone' ) { |
|
168 | + if (empty($ut) && $checkTimeZone && $_REQUEST['action'] != 'SetTimezone' && $_REQUEST['action'] != 'SaveTimezone') { |
|
169 | 169 | $GLOBALS['module'] = 'Users'; |
170 | 170 | $GLOBALS['action'] = 'Wizard'; |
171 | 171 | ob_clean(); |
172 | 172 | header("Location: index.php?module=Users&action=Wizard"); |
173 | 173 | sugar_cleanup(true); |
174 | 174 | } |
175 | - }else{ |
|
175 | + } else { |
|
176 | 176 | //kbrill bug #13225 |
177 | 177 | LogicHook::initialize(); |
178 | 178 | $GLOBALS['logic_hook']->call_custom_logic('Users', 'login_failed'); |
179 | - $GLOBALS['log']->fatal('FAILED LOGIN:attempts[' .$_SESSION['loginAttempts'] .'] - '. $username); |
|
179 | + $GLOBALS['log']->fatal('FAILED LOGIN:attempts['.$_SESSION['loginAttempts'].'] - '.$username); |
|
180 | 180 | } |
181 | 181 | // if password has expired, set a session variable |
182 | 182 | |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function sessionAuthenticate() |
193 | 193 | { |
194 | - if(!$this->authenticated){ |
|
194 | + if (!$this->authenticated) { |
|
195 | 195 | $this->authenticated = $this->authController->sessionAuthenticate(); |
196 | 196 | } |
197 | - if($this->authenticated){ |
|
198 | - if(!isset($_SESSION['userStats']['pages'])){ |
|
197 | + if ($this->authenticated) { |
|
198 | + if (!isset($_SESSION['userStats']['pages'])) { |
|
199 | 199 | $_SESSION['userStats']['loginTime'] = time(); |
200 | 200 | $_SESSION['userStats']['pages'] = 0; |
201 | 201 | } |
@@ -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. |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | ********************************************************************************/ |
40 | 40 | |
41 | 41 | |
42 | -if( !isset( $install_script ) || !$install_script ){ |
|
42 | +if (!isset($install_script) || !$install_script) { |
|
43 | 43 | die($mod_strings['ERR_NO_DIRECT_SCRIPT']); |
44 | 44 | } |
45 | 45 | |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | |
88 | 88 | public static function getSelect($name, $options, $default) { |
89 | 89 | $out = "<select name=\"$name\">"; |
90 | - foreach($options as $key => $value) { |
|
90 | + foreach ($options as $key => $value) { |
|
91 | 91 | $selected = ''; |
92 | - if($key==$default) $selected = ' selected="selected"'; |
|
92 | + if ($key == $default) $selected = ' selected="selected"'; |
|
93 | 93 | $out .= "<option label=\"$value\" value=\"$key\"$selected>$value</option>"; |
94 | 94 | } |
95 | 95 | $out .= "</select>"; |
@@ -238,13 +238,13 @@ discard block |
||
238 | 238 | <div class=\"form_section\"> |
239 | 239 | <h3>{$mod_strings['LBL_SYSOPTS_DB']}</h3>"; |
240 | 240 | |
241 | - foreach($drivers as $type => $driver) { |
|
242 | - $oci = ($type == "oci8")?"":'none'; // hack for special oracle message |
|
243 | - $out_dbtypesel.=<<<EOQ |
|
241 | + foreach ($drivers as $type => $driver) { |
|
242 | + $oci = ($type == "oci8") ? "" : 'none'; // hack for special oracle message |
|
243 | + $out_dbtypesel .= <<<EOQ |
|
244 | 244 | <input type="radio" class="checkbox" name="setup_db_type" id="setup_db_type" value="$type" {$checked[$type]} onclick="onDBTypeClick(this);//document.getElementById('ociMsg').style.display='$oci'"/>{$mod_strings[$driver->label]}<br> |
245 | 245 | EOQ; |
246 | 246 | } |
247 | - $out_dbtypesel.=<<<EOQ |
|
247 | + $out_dbtypesel .= <<<EOQ |
|
248 | 248 | </div> |
249 | 249 | <div name="ociMsg" id="ociMsg" style="display:none"></div> |
250 | 250 | <!-- </div> --> |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $out2 = $out_dbtypesel; |
255 | 255 | |
256 | 256 | |
257 | - $out2.=<<<EOQ2 |
|
257 | + $out2 .= <<<EOQ2 |
|
258 | 258 | |
259 | 259 | <!-- <div class="floatbox"> --> |
260 | 260 | |
@@ -265,25 +265,25 @@ discard block |
||
265 | 265 | |
266 | 266 | $config_params = $db->installConfig(); |
267 | 267 | $form = ''; |
268 | - foreach($config_params as $group => $gdata) { |
|
269 | - $form.= "<div class='install_block'>"; |
|
270 | - if($mod_strings[$group . '_LABEL']) { |
|
271 | - $form .= "<label>{$mod_strings[$group . '_LABEL']}" . "<i> i <div class=\"tooltip\">{$mod_strings[$group]}</div></i></label>\n"; |
|
268 | + foreach ($config_params as $group => $gdata) { |
|
269 | + $form .= "<div class='install_block'>"; |
|
270 | + if ($mod_strings[$group.'_LABEL']) { |
|
271 | + $form .= "<label>{$mod_strings[$group.'_LABEL']}"."<i> i <div class=\"tooltip\">{$mod_strings[$group]}</div></i></label>\n"; |
|
272 | 272 | } |
273 | - foreach($gdata as $name => $value) { |
|
273 | + foreach ($gdata as $name => $value) { |
|
274 | 274 | |
275 | - if(!empty($value)) { |
|
276 | - if(!empty($value['required'])) { |
|
275 | + if (!empty($value)) { |
|
276 | + if (!empty($value['required'])) { |
|
277 | 277 | $form .= "<span class=\"required\">*</span>"; |
278 | 278 | } |
279 | 279 | else { |
280 | 280 | } |
281 | - if(!empty($_SESSION[$name])) { |
|
281 | + if (!empty($_SESSION[$name])) { |
|
282 | 282 | $sessval = $_SESSION[$name]; |
283 | 283 | } else { |
284 | 284 | $sessval = ''; |
285 | 285 | } |
286 | - if(!empty($value["type"])) { |
|
286 | + if (!empty($value["type"])) { |
|
287 | 287 | $type = $value["type"]; |
288 | 288 | } else { |
289 | 289 | $type = ''; |
@@ -293,9 +293,9 @@ discard block |
||
293 | 293 | |
294 | 294 | FORM; |
295 | 295 | //if the type is password, set a hidden field to capture the value. This is so that we can properly encode special characters, which is a limitation with password fields |
296 | - if($type=='password'){ |
|
296 | + if ($type == 'password') { |
|
297 | 297 | $form .= "</div><div class=\"install_block\"><label>{$mod_strings['LBL_DBCONF_TITLE_PSWD_INFO_LABEL']}</label><span> </span><input type='$type' name='{$name}_entry' id='{$name}_entry' value='".urldecode($sessval)."'><input type='hidden' name='$name' id='$name' value='".urldecode($sessval)."'></div><div class=\"install_block\">"; |
298 | - }else{ |
|
298 | + } else { |
|
299 | 299 | $form .= "<input type='$type' name='$name' id='$name' value='$sessval'>"; |
300 | 300 | } |
301 | 301 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | |
320 | 320 | |
321 | 321 | //if we are installing in custom mode, include the following html |
322 | - if($db->supports("create_user")) { |
|
322 | + if ($db->supports("create_user")) { |
|
323 | 323 | // create / set db user dropdown |
324 | 324 | $auto_select = ''; |
325 | 325 | $provide_select = ''; |
@@ -342,9 +342,9 @@ discard block |
||
342 | 342 | $same_select = 'selected'; |
343 | 343 | } |
344 | 344 | $dbUSRDD = "<select name='dbUSRData' id='dbUSRData' onchange='toggleDBUser();'>"; |
345 | - $dbUSRDD .= "<option value='provide' $provide_select>" . $mod_strings['LBL_DBCONFIG_PROVIDE_DD'] . "</option>"; |
|
346 | - $dbUSRDD .= "<option value='create' $create_select>" . $mod_strings['LBL_DBCONFIG_CREATE_DD'] . "</option>"; |
|
347 | - $dbUSRDD .= "<option value='same' $same_select>" . $mod_strings['LBL_DBCONFIG_SAME_DD'] . "</option>"; |
|
345 | + $dbUSRDD .= "<option value='provide' $provide_select>".$mod_strings['LBL_DBCONFIG_PROVIDE_DD']."</option>"; |
|
346 | + $dbUSRDD .= "<option value='create' $create_select>".$mod_strings['LBL_DBCONFIG_CREATE_DD']."</option>"; |
|
347 | + $dbUSRDD .= "<option value='same' $same_select>".$mod_strings['LBL_DBCONFIG_SAME_DD']."</option>"; |
|
348 | 348 | $dbUSRDD .= "</select><br> "; |
349 | 349 | |
350 | 350 | |
@@ -388,12 +388,12 @@ discard block |
||
388 | 388 | |
389 | 389 | EOQ2; |
390 | 390 | } |
391 | - $out =$out2; |
|
391 | + $out = $out2; |
|
392 | 392 | |
393 | 393 | |
394 | 394 | |
395 | 395 | // ------ siteConfig_a.php |
396 | - $out .=<<<EOQ |
|
396 | + $out .= <<<EOQ |
|
397 | 397 | </div> |
398 | 398 | </div> |
399 | 399 | <div class="floatbox" id="fb6"> |
@@ -405,8 +405,8 @@ discard block |
||
405 | 405 | <h3>{$mod_strings['LBL_SITECFG_TITLE2']}<div class="tooltip-toggle"><em> i </em><div class="tooltip">{$mod_strings['LBL_SITECFG_PASSWORD_MSG']}</div></div></h3> |
406 | 406 | EOQ; |
407 | 407 | //hide this in typical mode |
408 | - if(!empty($_SESSION['install_type']) && strtolower($_SESSION['install_type'])=='custom'){ |
|
409 | - $out .=<<<EOQ |
|
408 | + if (!empty($_SESSION['install_type']) && strtolower($_SESSION['install_type']) == 'custom') { |
|
409 | + $out .= <<<EOQ |
|
410 | 410 | <div class='install_block'> |
411 | 411 | {$mod_strings['LBL_SITECFG_URL_MSG']} |
412 | 412 | <span class="required">*</span> |
@@ -419,17 +419,17 @@ discard block |
||
419 | 419 | </div> |
420 | 420 | EOQ; |
421 | 421 | $db = getDbConnection(); |
422 | - if($db->supports("collation")) { |
|
422 | + if ($db->supports("collation")) { |
|
423 | 423 | $collationOptions = $db->getCollationList(); |
424 | 424 | } |
425 | - if(!empty($collationOptions)) { |
|
426 | - if(isset($_SESSION['setup_db_options']['collation'])) { |
|
425 | + if (!empty($collationOptions)) { |
|
426 | + if (isset($_SESSION['setup_db_options']['collation'])) { |
|
427 | 427 | $default = $_SESSION['setup_db_options']['collation']; |
428 | 428 | } else { |
429 | 429 | $default = $db->getDefaultCollation(); |
430 | 430 | } |
431 | 431 | $options = get_select_options_with_id(array_combine($collationOptions, $collationOptions), $default); |
432 | - $out .=<<<EOQ |
|
432 | + $out .= <<<EOQ |
|
433 | 433 | <div class='install_block'> |
434 | 434 | <br>{$mod_strings['LBL_SITECFG_COLLATION_MSG']} |
435 | 435 | <span class="required">*</span> |
@@ -441,15 +441,15 @@ discard block |
||
441 | 441 | } |
442 | 442 | |
443 | 443 | $help_url = get_help_button_url(); |
444 | - if(!isset($_SESSION['email1'])) { |
|
444 | + if (!isset($_SESSION['email1'])) { |
|
445 | 445 | $_SESSION['email1'] = null; |
446 | 446 | } |
447 | 447 | |
448 | - if(!isset($_SESSION['setup_site_admin_user_name'])) { |
|
448 | + if (!isset($_SESSION['setup_site_admin_user_name'])) { |
|
449 | 449 | $_SESSION['setup_site_admin_user_name'] = null; |
450 | 450 | } |
451 | 451 | |
452 | - $out .=<<<EOQ |
|
452 | + $out .= <<<EOQ |
|
453 | 453 | <div class='install_block'> |
454 | 454 | <!-- |
455 | 455 | <p class="ibmsg">{$mod_strings['LBL_SITECFG_PASSWORD_MSG']}</p> |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | EOQ; |
499 | 499 | |
500 | 500 | |
501 | - $out.=<<<EOQ |
|
501 | + $out .= <<<EOQ |
|
502 | 502 | </div><!-- dbg2 --> |
503 | 503 | EOQ; |
504 | 504 | |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | $demoDD = "<select name='demoData' id='demoData' class='select'><option value='no' >".$mod_strings['LBL_NO']."</option><option value='yes'>".$mod_strings['LBL_YES']."</option>"; |
518 | 518 | $demoDD .= "</select>"; |
519 | 519 | |
520 | - $out .=<<<EOQ3 |
|
520 | + $out .= <<<EOQ3 |
|
521 | 521 | </div> |
522 | 522 | </div> |
523 | 523 | |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | $notify_allow_default_outbound_checked = empty($_SESSION['notify_allow_default_outbound']) ? '' : ' checked="checked" '; |
560 | 560 | |
561 | 561 | // set default smtp toggle buttons selected value |
562 | - if(empty($_SESSION['smtp_tab_selected'])) $_SESSION['smtp_tab_selected'] = 'smtp_tab_other'; |
|
562 | + if (empty($_SESSION['smtp_tab_selected'])) $_SESSION['smtp_tab_selected'] = 'smtp_tab_other'; |
|
563 | 563 | |
564 | 564 | $out .= <<<EOQ |
565 | 565 | <div class="floatbox full" id="fb2"> |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | |
818 | 818 | |
819 | 819 | // db setup (dbConfig_a.php) |
820 | - $out2 =<<<EOQ2 |
|
820 | + $out2 = <<<EOQ2 |
|
821 | 821 | <input type='hidden' name='setup_db_drop_tables' id='setup_db_drop_tables' value=''> |
822 | 822 | </div> |
823 | 823 | EOQ2; |
@@ -836,7 +836,7 @@ discard block |
||
836 | 836 | $currentLogoLink = SugarThemeRegistry::current()->getImageURL('company_logo.png'); |
837 | 837 | // show logo if we have |
838 | 838 | $hiddenLogo = ''; |
839 | - if(!file_exists($currentLogoLink)) { |
|
839 | + if (!file_exists($currentLogoLink)) { |
|
840 | 840 | $hiddenLogo = 'display:none;'; |
841 | 841 | } |
842 | 842 | |
@@ -989,10 +989,10 @@ discard block |
||
989 | 989 | EOQ; |
990 | 990 | |
991 | 991 | |
992 | -$out.= "<div class=\"floatbox full\">"; |
|
993 | -$out.= " <h3 onclick=\"$(this).next().toggle();\" class=\"toggler\">» {$mod_strings['LBL_SITECFG_SECURITY_TITLE']}</h3>"; |
|
992 | +$out .= "<div class=\"floatbox full\">"; |
|
993 | +$out .= " <h3 onclick=\"$(this).next().toggle();\" class=\"toggler\">» {$mod_strings['LBL_SITECFG_SECURITY_TITLE']}</h3>"; |
|
994 | 994 | |
995 | - $out.=<<<EOQ |
|
995 | + $out .= <<<EOQ |
|
996 | 996 | |
997 | 997 | <div class="security-block" style="display:none;"> |
998 | 998 | <table cellspacing="0" cellpadding="0" border="0" align="center" class="shell"> |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | </div><!-- dbg1 --> |
1082 | 1082 | EOQ; |
1083 | 1083 | |
1084 | -$out.= "</div>"; |
|
1084 | +$out .= "</div>"; |
|
1085 | 1085 | |
1086 | 1086 | |
1087 | 1087 | |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | } |
1090 | 1090 | |
1091 | 1091 | private function getFormControlls($mod_strings, $formId) { |
1092 | - $out =<<<EOQ |
|
1092 | + $out = <<<EOQ |
|
1093 | 1093 | <div id="checkingDiv" style="display:none"> |
1094 | 1094 | <p><img alt="{$mod_strings['LBL_LICENSE_CHKDB_HEADER']}" src='install/processing.gif'> <br>{$mod_strings['LBL_LICENSE_CHKDB_HEADER']}</p> |
1095 | 1095 | </div> |
@@ -1375,7 +1375,7 @@ discard block |
||
1375 | 1375 | } |
1376 | 1376 | |
1377 | 1377 | private function getFormScripts($mod_strings, $next_step) { |
1378 | - $out =<<<EOQ |
|
1378 | + $out = <<<EOQ |
|
1379 | 1379 | /** |
1380 | 1380 | * Submit form without step. |
1381 | 1381 | */ |
@@ -1575,7 +1575,7 @@ discard block |
||
1575 | 1575 | * @return string output |
1576 | 1576 | */ |
1577 | 1577 | public function show($data = null) { |
1578 | - foreach($data as $__key => $__val) { |
|
1578 | + foreach ($data as $__key => $__val) { |
|
1579 | 1579 | $$__key = $__val; |
1580 | 1580 | } |
1581 | 1581 | $formId = 'installForm'; |
@@ -1633,7 +1633,7 @@ discard block |
||
1633 | 1633 | |
1634 | 1634 | |
1635 | 1635 | |
1636 | -if( !isset( $install_script ) || !$install_script ){ |
|
1636 | +if (!isset($install_script) || !$install_script) { |
|
1637 | 1637 | die($mod_strings['ERR_NO_DIRECT_SCRIPT']); |
1638 | 1638 | } |
1639 | 1639 | |
@@ -1641,20 +1641,20 @@ discard block |
||
1641 | 1641 | |
1642 | 1642 | //---------------- systemOption: db driver select |
1643 | 1643 | |
1644 | -if(!isset($_SESSION['setup_db_type']) || $_SESSION['setup_db_type'] ==''){ |
|
1644 | +if (!isset($_SESSION['setup_db_type']) || $_SESSION['setup_db_type'] == '') { |
|
1645 | 1645 | $_SESSION['setup_db_type'] = 'mysql'; |
1646 | 1646 | } |
1647 | 1647 | $setup_db_type = $_SESSION['setup_db_type']; |
1648 | 1648 | |
1649 | 1649 | $errs = ''; |
1650 | -if(isset($validation_errors)) { |
|
1651 | - if(count($validation_errors) > 0) { |
|
1650 | +if (isset($validation_errors)) { |
|
1651 | + if (count($validation_errors) > 0) { |
|
1652 | 1652 | $errs = '<div id="errorMsgs">'; |
1653 | 1653 | $errs .= "<p>{$mod_strings['LBL_SYSOPTS_ERRS_TITLE']}</p>"; |
1654 | 1654 | $errs .= '<ul>'; |
1655 | 1655 | |
1656 | - foreach($validation_errors as $error) { |
|
1657 | - $errs .= '<li>' . $error . '</li>'; |
|
1656 | + foreach ($validation_errors as $error) { |
|
1657 | + $errs .= '<li>'.$error.'</li>'; |
|
1658 | 1658 | } |
1659 | 1659 | |
1660 | 1660 | $errs .= '</ul>'; |
@@ -1663,7 +1663,7 @@ discard block |
||
1663 | 1663 | } |
1664 | 1664 | |
1665 | 1665 | $drivers = DBManagerFactory::getDbDrivers(); |
1666 | -foreach(array_keys($drivers) as $dname) { |
|
1666 | +foreach (array_keys($drivers) as $dname) { |
|
1667 | 1667 | $checked[$dname] = ''; |
1668 | 1668 | } |
1669 | 1669 | $checked[$setup_db_type] = 'checked="checked"'; |
@@ -1672,8 +1672,8 @@ discard block |
||
1672 | 1672 | |
1673 | 1673 | //----------------- dbConfig_a: db name user pass... |
1674 | 1674 | |
1675 | -if(empty($_SESSION['setup_db_host_name'])){ |
|
1676 | - $_SESSION['setup_db_host_name'] = (isset($sugar_config['db_host_name'])) ? $sugar_config['db_host_name'] : $_SERVER['SERVER_NAME']; |
|
1675 | +if (empty($_SESSION['setup_db_host_name'])) { |
|
1676 | + $_SESSION['setup_db_host_name'] = (isset($sugar_config['db_host_name'])) ? $sugar_config['db_host_name'] : $_SERVER['SERVER_NAME']; |
|
1677 | 1677 | } |
1678 | 1678 | |
1679 | 1679 | |
@@ -1682,16 +1682,16 @@ discard block |
||
1682 | 1682 | $createDb = (!empty($_SESSION['setup_db_create_database'])) ? 'checked="checked"' : ''; |
1683 | 1683 | $dropCreate = (!empty($_SESSION['setup_db_drop_tables'])) ? 'checked="checked"' : ''; |
1684 | 1684 | $instanceName = ''; |
1685 | -if (isset($_SESSION['setup_db_host_instance']) && !empty($_SESSION['setup_db_host_instance'])){ |
|
1685 | +if (isset($_SESSION['setup_db_host_instance']) && !empty($_SESSION['setup_db_host_instance'])) { |
|
1686 | 1686 | $instanceName = $_SESSION['setup_db_host_instance']; |
1687 | 1687 | } |
1688 | 1688 | |
1689 | -$setupDbPortNum =''; |
|
1690 | -if (isset($_SESSION['setup_db_port_num']) && !empty($_SESSION['setup_db_port_num'])){ |
|
1689 | +$setupDbPortNum = ''; |
|
1690 | +if (isset($_SESSION['setup_db_port_num']) && !empty($_SESSION['setup_db_port_num'])) { |
|
1691 | 1691 | $setupDbPortNum = $_SESSION['setup_db_port_num']; |
1692 | 1692 | } |
1693 | 1693 | |
1694 | -if(!isset($_SESSION['setup_db_manager'])) { |
|
1694 | +if (!isset($_SESSION['setup_db_manager'])) { |
|
1695 | 1695 | $_SESSION['setup_db_manager'] = null; |
1696 | 1696 | } |
1697 | 1697 | |
@@ -1704,54 +1704,54 @@ discard block |
||
1704 | 1704 | //----------------- siteConfig_a.php Site Config & admin user |
1705 | 1705 | |
1706 | 1706 | |
1707 | -if( is_file("config.php") ){ |
|
1708 | - if(!empty($sugar_config['default_theme'])) |
|
1707 | +if (is_file("config.php")) { |
|
1708 | + if (!empty($sugar_config['default_theme'])) |
|
1709 | 1709 | $_SESSION['site_default_theme'] = $sugar_config['default_theme']; |
1710 | 1710 | |
1711 | - if(!empty($sugar_config['disable_persistent_connections'])) |
|
1711 | + if (!empty($sugar_config['disable_persistent_connections'])) |
|
1712 | 1712 | $_SESSION['disable_persistent_connections'] = |
1713 | 1713 | $sugar_config['disable_persistent_connections']; |
1714 | - if(!empty($sugar_config['default_language'])) |
|
1714 | + if (!empty($sugar_config['default_language'])) |
|
1715 | 1715 | $_SESSION['default_language'] = $sugar_config['default_language']; |
1716 | - if(!empty($sugar_config['translation_string_prefix'])) |
|
1716 | + if (!empty($sugar_config['translation_string_prefix'])) |
|
1717 | 1717 | $_SESSION['translation_string_prefix'] = $sugar_config['translation_string_prefix']; |
1718 | - if(!empty($sugar_config['default_charset'])) |
|
1718 | + if (!empty($sugar_config['default_charset'])) |
|
1719 | 1719 | $_SESSION['default_charset'] = $sugar_config['default_charset']; |
1720 | 1720 | |
1721 | - if(!empty($sugar_config['default_currency_name'])) |
|
1721 | + if (!empty($sugar_config['default_currency_name'])) |
|
1722 | 1722 | $_SESSION['default_currency_name'] = $sugar_config['default_currency_name']; |
1723 | - if(!empty($sugar_config['default_currency_symbol'])) |
|
1723 | + if (!empty($sugar_config['default_currency_symbol'])) |
|
1724 | 1724 | $_SESSION['default_currency_symbol'] = $sugar_config['default_currency_symbol']; |
1725 | - if(!empty($sugar_config['default_currency_iso4217'])) |
|
1725 | + if (!empty($sugar_config['default_currency_iso4217'])) |
|
1726 | 1726 | $_SESSION['default_currency_iso4217'] = $sugar_config['default_currency_iso4217']; |
1727 | 1727 | |
1728 | - if(!empty($sugar_config['rss_cache_time'])) |
|
1728 | + if (!empty($sugar_config['rss_cache_time'])) |
|
1729 | 1729 | $_SESSION['rss_cache_time'] = $sugar_config['rss_cache_time']; |
1730 | - if(!empty($sugar_config['languages'])) |
|
1730 | + if (!empty($sugar_config['languages'])) |
|
1731 | 1731 | { |
1732 | 1732 | // We need to encode the languages in a way that can be retrieved later. |
1733 | 1733 | $language_keys = Array(); |
1734 | 1734 | $language_values = Array(); |
1735 | 1735 | |
1736 | - foreach($sugar_config['languages'] as $key=>$value) |
|
1736 | + foreach ($sugar_config['languages'] as $key=>$value) |
|
1737 | 1737 | { |
1738 | 1738 | $language_keys[] = $key; |
1739 | 1739 | $language_values[] = $value; |
1740 | 1740 | } |
1741 | 1741 | |
1742 | - $_SESSION['language_keys'] = urlencode(implode(",",$language_keys)); |
|
1743 | - $_SESSION['language_values'] = urlencode(implode(",",$language_values)); |
|
1742 | + $_SESSION['language_keys'] = urlencode(implode(",", $language_keys)); |
|
1743 | + $_SESSION['language_values'] = urlencode(implode(",", $language_values)); |
|
1744 | 1744 | } |
1745 | 1745 | } |
1746 | 1746 | |
1747 | 1747 | //// errors |
1748 | 1748 | $errors = ''; |
1749 | -if( isset($validation_errors) && is_array($validation_errors)){ |
|
1750 | - if( count($validation_errors) > 0 ){ |
|
1749 | +if (isset($validation_errors) && is_array($validation_errors)) { |
|
1750 | + if (count($validation_errors) > 0) { |
|
1751 | 1751 | $errors = '<div id="errorMsgs">'; |
1752 | 1752 | $errors .= '<p>'.$mod_strings['LBL_SITECFG_FIX_ERRORS'].'</p><ul>'; |
1753 | - foreach( $validation_errors as $error ){ |
|
1754 | - $errors .= '<li>' . $error . '</li>'; |
|
1753 | + foreach ($validation_errors as $error) { |
|
1754 | + $errors .= '<li>'.$error.'</li>'; |
|
1755 | 1755 | } |
1756 | 1756 | $errors .= '</ul></div>'; |
1757 | 1757 | } |
@@ -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. |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | |
41 | 41 | function installStatus($msg, $cmd = null, $overwrite = false, $before = '[ok]<br>') { |
42 | 42 | $fname = 'install/status.json'; |
43 | - if(!$overwrite && file_exists($fname)) { |
|
43 | + if (!$overwrite && file_exists($fname)) { |
|
44 | 44 | $stat = json_decode(file_get_contents($fname)); |
45 | 45 | //$msg = json_encode($stat); |
46 | - $msg = $stat->message . $before . $msg; |
|
46 | + $msg = $stat->message.$before.$msg; |
|
47 | 47 | } |
48 | 48 | file_put_contents($fname, json_encode(array( |
49 | 49 | 'message' => $msg, |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | // This file will load the configuration settings from session data, |
56 | 56 | // write to the config file, and execute any necessary database steps. |
57 | 57 | $GLOBALS['installing'] = true; |
58 | -if( !isset( $install_script ) || !$install_script ){ |
|
58 | +if (!isset($install_script) || !$install_script) { |
|
59 | 59 | die($mod_strings['ERR_NO_DIRECT_SCRIPT']); |
60 | 60 | } |
61 | -ini_set("output_buffering","0"); |
|
61 | +ini_set("output_buffering", "0"); |
|
62 | 62 | set_time_limit(3600); |
63 | 63 | // flush after each output so the user can see the progress in real-time |
64 | 64 | ob_implicit_flush(); |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | $parsed_url = parse_url($setup_site_url); |
99 | 99 | $setup_site_host_name = $parsed_url['host']; |
100 | 100 | $setup_site_log_dir = isset($_SESSION['setup_site_custom_log_dir']) ? $_SESSION['setup_site_log_dir'] : '.'; |
101 | -$setup_site_log_file = 'suitecrm.log'; // may be an option later |
|
101 | +$setup_site_log_file = 'suitecrm.log'; // may be an option later |
|
102 | 102 | $setup_site_session_path = isset($_SESSION['setup_site_custom_session_path']) ? $_SESSION['setup_site_session_path'] : ''; |
103 | -$setup_site_log_level ='fatal'; |
|
103 | +$setup_site_log_level = 'fatal'; |
|
104 | 104 | |
105 | 105 | /*sugar_cache_clear('TeamSetsCache'); |
106 | 106 | if ( file_exists($cache_dir .'modules/Teams/TeamSetCache.php') ) { |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | unlink($cache_dir.'modules/Teams/TeamSetMD5Cache.php'); |
113 | 113 | }*/ |
114 | 114 | $langHeader = get_language_header(); |
115 | -$out =<<<EOQ |
|
115 | +$out = <<<EOQ |
|
116 | 116 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
117 | 117 | <!DOCTYPE HTML> |
118 | 118 | <html {$langHeader}> |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | //handleLog4Php(); |
154 | 154 | |
155 | 155 | $server_software = $_SERVER["SERVER_SOFTWARE"]; |
156 | -if(strpos($server_software,'Microsoft-IIS') !== false) |
|
156 | +if (strpos($server_software, 'Microsoft-IIS') !== false) |
|
157 | 157 | { |
158 | 158 | installLog("calling handleWebConfig()"); |
159 | 159 | handleWebConfig(); |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | echo "<br>"; |
170 | 170 | |
171 | 171 | // create the SugarCRM database |
172 | -if($setup_db_create_database) { |
|
172 | +if ($setup_db_create_database) { |
|
173 | 173 | installLog("calling handleDbCreateDatabase()"); |
174 | 174 | installerHook('pre_handleDbCreateDatabase'); |
175 | 175 | handleDbCreateDatabase(); |
@@ -193,19 +193,19 @@ discard block |
||
193 | 193 | $ModuleInstaller->rebuild_tabledictionary();*/ |
194 | 194 | |
195 | 195 | // create the SugarCRM database user |
196 | -if($setup_db_create_sugarsales_user){ |
|
196 | +if ($setup_db_create_sugarsales_user) { |
|
197 | 197 | installerHook('pre_handleDbCreateSugarUser'); |
198 | 198 | handleDbCreateSugarUser(); |
199 | 199 | installerHook('post_handleDbCreateSugarUser'); |
200 | 200 | } |
201 | 201 | |
202 | -foreach( $beanFiles as $bean => $file ){ |
|
203 | - require_once( $file ); |
|
202 | +foreach ($beanFiles as $bean => $file) { |
|
203 | + require_once($file); |
|
204 | 204 | } |
205 | 205 | echo "<br>"; |
206 | 206 | // load up the config_override.php file. |
207 | 207 | // This is used to provide default user settings |
208 | -if( is_file("config_override.php") ){ |
|
208 | +if (is_file("config_override.php")) { |
|
209 | 209 | require_once("config_override.php"); |
210 | 210 | } |
211 | 211 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $new_report = 1; |
220 | 220 | |
221 | 221 | // add non-module Beans to this array to keep the installer from erroring. |
222 | -$nonStandardModules = array ( |
|
222 | +$nonStandardModules = array( |
|
223 | 223 | //'Tracker', |
224 | 224 | ); |
225 | 225 | |
@@ -234,29 +234,29 @@ discard block |
||
234 | 234 | installerHook('pre_createAllModuleTables'); |
235 | 235 | |
236 | 236 | |
237 | -foreach( $beanFiles as $bean => $file ) { |
|
238 | - $doNotInit = array('Scheduler', 'SchedulersJob', 'ProjectTask','jjwg_Maps','jjwg_Address_Cache','jjwg_Areas','jjwg_Markers'); |
|
237 | +foreach ($beanFiles as $bean => $file) { |
|
238 | + $doNotInit = array('Scheduler', 'SchedulersJob', 'ProjectTask', 'jjwg_Maps', 'jjwg_Address_Cache', 'jjwg_Areas', 'jjwg_Markers'); |
|
239 | 239 | |
240 | - if(in_array($bean, $doNotInit)) { |
|
240 | + if (in_array($bean, $doNotInit)) { |
|
241 | 241 | $focus = new $bean(false); |
242 | 242 | } else { |
243 | 243 | $focus = new $bean(); |
244 | 244 | } |
245 | 245 | |
246 | - if ( $bean == 'Configurator' ) |
|
246 | + if ($bean == 'Configurator') |
|
247 | 247 | continue; |
248 | 248 | |
249 | 249 | $table_name = $focus->table_name; |
250 | 250 | //installStatus(sprintf($mod_strings['STAT_CREATE_DB_TABLE'], $focus->table_name )); |
251 | 251 | installLog("processing table ".$focus->table_name); |
252 | 252 | // check to see if we have already setup this table |
253 | - if(!in_array($table_name, $processed_tables)) { |
|
254 | - if(!file_exists("modules/".$focus->module_dir."/vardefs.php")){ |
|
253 | + if (!in_array($table_name, $processed_tables)) { |
|
254 | + if (!file_exists("modules/".$focus->module_dir."/vardefs.php")) { |
|
255 | 255 | continue; |
256 | 256 | } |
257 | - if(!in_array($bean, $nonStandardModules)) { |
|
257 | + if (!in_array($bean, $nonStandardModules)) { |
|
258 | 258 | require_once("modules/".$focus->module_dir."/vardefs.php"); // load up $dictionary |
259 | - if($dictionary[$focus->object_name]['table'] == 'does_not_exist') { |
|
259 | + if ($dictionary[$focus->object_name]['table'] == 'does_not_exist') { |
|
260 | 260 | continue; // support new vardef definitions |
261 | 261 | } |
262 | 262 | } else { |
@@ -268,17 +268,17 @@ discard block |
||
268 | 268 | |
269 | 269 | $focus->db->database = $db->database; // set db connection so we do not need to reconnect |
270 | 270 | |
271 | - if($setup_db_drop_tables) { |
|
271 | + if ($setup_db_drop_tables) { |
|
272 | 272 | drop_table_install($focus); |
273 | 273 | installLog("dropping table ".$focus->table_name); |
274 | 274 | } |
275 | 275 | |
276 | - if(create_table_if_not_exist($focus)) { |
|
276 | + if (create_table_if_not_exist($focus)) { |
|
277 | 277 | installLog("creating table ".$focus->table_name); |
278 | - if( $bean == "User" ){ |
|
278 | + if ($bean == "User") { |
|
279 | 279 | $new_tables = 1; |
280 | 280 | } |
281 | - if($bean == "Administration") |
|
281 | + if ($bean == "Administration") |
|
282 | 282 | $new_config = 1; |
283 | 283 | |
284 | 284 | |
@@ -303,20 +303,20 @@ discard block |
||
303 | 303 | //// START RELATIONSHIP CREATION |
304 | 304 | |
305 | 305 | ksort($rel_dictionary); |
306 | - foreach( $rel_dictionary as $rel_name => $rel_data ){ |
|
306 | + foreach ($rel_dictionary as $rel_name => $rel_data) { |
|
307 | 307 | $table = $rel_data['table']; |
308 | 308 | |
309 | - if( $setup_db_drop_tables ){ |
|
310 | - if( $db->tableExists($table) ){ |
|
309 | + if ($setup_db_drop_tables) { |
|
310 | + if ($db->tableExists($table)) { |
|
311 | 311 | $db->dropTableName($table); |
312 | 312 | } |
313 | 313 | } |
314 | 314 | |
315 | - if( !$db->tableExists($table) ){ |
|
315 | + if (!$db->tableExists($table)) { |
|
316 | 316 | $db->createTableParams($table, $rel_data['fields'], $rel_data['indices']); |
317 | 317 | } |
318 | 318 | |
319 | - SugarBean::createRelationshipMeta($rel_name,$db,$table,$rel_dictionary,''); |
|
319 | + SugarBean::createRelationshipMeta($rel_name, $db, $table, $rel_dictionary, ''); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | /////////////////////////////////////////////////////////////////////////////// |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | |
377 | 377 | /////////////////////////////////////////////////////////////////////////// |
378 | 378 | //// FINALIZE LANG PACK INSTALL |
379 | - if(isset($_SESSION['INSTALLED_LANG_PACKS']) && is_array($_SESSION['INSTALLED_LANG_PACKS']) && !empty($_SESSION['INSTALLED_LANG_PACKS'])) { |
|
379 | + if (isset($_SESSION['INSTALLED_LANG_PACKS']) && is_array($_SESSION['INSTALLED_LANG_PACKS']) && !empty($_SESSION['INSTALLED_LANG_PACKS'])) { |
|
380 | 380 | updateUpgradeHistory(); |
381 | 381 | } |
382 | 382 | |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | |
394 | 394 | $memoryUsed = ''; |
395 | 395 | if (function_exists('memory_get_usage')) { |
396 | - $memoryUsed = $mod_strings['LBL_PERFORM_OUTRO_5'] . memory_get_usage() . $mod_strings['LBL_PERFORM_OUTRO_6']; |
|
396 | + $memoryUsed = $mod_strings['LBL_PERFORM_OUTRO_5'].memory_get_usage().$mod_strings['LBL_PERFORM_OUTRO_6']; |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | |
@@ -421,14 +421,14 @@ discard block |
||
421 | 421 | FP; |
422 | 422 | } |
423 | 423 | |
424 | - if( isset($_SESSION['setup_site_sugarbeet_automatic_checks']) && $_SESSION['setup_site_sugarbeet_automatic_checks'] == true){ |
|
424 | + if (isset($_SESSION['setup_site_sugarbeet_automatic_checks']) && $_SESSION['setup_site_sugarbeet_automatic_checks'] == true) { |
|
425 | 425 | set_CheckUpdates_config_setting('automatic'); |
426 | - }else{ |
|
426 | + } else { |
|
427 | 427 | set_CheckUpdates_config_setting('manual'); |
428 | 428 | } |
429 | - if(!empty($_SESSION['setup_system_name'])){ |
|
430 | - $admin=new Administration(); |
|
431 | - $admin->saveSetting('system','name',$_SESSION['setup_system_name']); |
|
429 | + if (!empty($_SESSION['setup_system_name'])) { |
|
430 | + $admin = new Administration(); |
|
431 | + $admin->saveSetting('system', 'name', $_SESSION['setup_system_name']); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | // Bug 28601 - Set the default list of tabs to show |
@@ -490,16 +490,16 @@ discard block |
||
490 | 490 | |
491 | 491 | // populating the db with seed data |
492 | 492 | installLog("populating the db with seed data"); |
493 | -if( $_SESSION['demoData'] != 'no' ){ |
|
493 | +if ($_SESSION['demoData'] != 'no') { |
|
494 | 494 | installerHook('pre_installDemoData'); |
495 | - set_time_limit( 301 ); |
|
495 | + set_time_limit(301); |
|
496 | 496 | |
497 | 497 | echo "<br>"; |
498 | 498 | echo "<b>{$mod_strings['LBL_PERFORM_DEMO_DATA']}</b>"; |
499 | 499 | echo "<br><br>"; |
500 | 500 | |
501 | - print( $render_table_close ); |
|
502 | - print( $render_table_open ); |
|
501 | + print($render_table_close); |
|
502 | + print($render_table_open); |
|
503 | 503 | |
504 | 504 | global $current_user; |
505 | 505 | $current_user = new User(); |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | //$focus->retrieveSettings(); |
540 | 540 | // switch off the adminwizard (mark that we have got past this point) |
541 | 541 | installLog('AdminWizard OFF'); |
542 | -$focus->saveSetting('system','adminwizard',1); |
|
542 | +$focus->saveSetting('system', 'adminwizard', 1); |
|
543 | 543 | |
544 | 544 | installLog('saveConfig'); |
545 | 545 | $focus->saveConfig(); |
@@ -554,10 +554,10 @@ discard block |
||
554 | 554 | |
555 | 555 | installLog('handleOverride'); |
556 | 556 | // add local settings to config overrides |
557 | -if(!empty($_SESSION['default_date_format'])) $sugar_config['default_date_format'] = $_SESSION['default_date_format']; |
|
558 | -if(!empty($_SESSION['default_time_format'])) $sugar_config['default_time_format'] = $_SESSION['default_time_format']; |
|
559 | -if(!empty($_SESSION['default_language'])) $sugar_config['default_language'] = $_SESSION['default_language']; |
|
560 | -if(!empty($_SESSION['default_locale_name_format'])) $sugar_config['default_locale_name_format'] = $_SESSION['default_locale_name_format']; |
|
557 | +if (!empty($_SESSION['default_date_format'])) $sugar_config['default_date_format'] = $_SESSION['default_date_format']; |
|
558 | +if (!empty($_SESSION['default_time_format'])) $sugar_config['default_time_format'] = $_SESSION['default_time_format']; |
|
559 | +if (!empty($_SESSION['default_language'])) $sugar_config['default_language'] = $_SESSION['default_language']; |
|
560 | +if (!empty($_SESSION['default_locale_name_format'])) $sugar_config['default_locale_name_format'] = $_SESSION['default_locale_name_format']; |
|
561 | 561 | //$configurator->handleOverride(); |
562 | 562 | |
563 | 563 | |
@@ -576,9 +576,9 @@ discard block |
||
576 | 576 | $currency = new Currency; |
577 | 577 | installLog('retrieve'); |
578 | 578 | $currency->retrieve($currency->retrieve_id_by_name($_REQUEST['default_currency_name'])); |
579 | -if ( !empty($currency->id) |
|
579 | +if (!empty($currency->id) |
|
580 | 580 | && $currency->symbol == $_REQUEST['default_currency_symbol'] |
581 | - && $currency->iso4217 == $_REQUEST['default_currency_iso4217'] ) { |
|
581 | + && $currency->iso4217 == $_REQUEST['default_currency_iso4217']) { |
|
582 | 582 | $currency->deleted = 1; |
583 | 583 | installLog('DBG: save currency'); |
584 | 584 | $currency->save(); |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | $sugar_config = get_sugar_config_defaults(); |
602 | 602 | |
603 | 603 | // set local settings - if neccessary you can set here more fields as named in User module / EditView form... |
604 | -if(isset($_REQUEST['timezone']) && $_REQUEST['timezone']) { |
|
604 | +if (isset($_REQUEST['timezone']) && $_REQUEST['timezone']) { |
|
605 | 605 | $current_user->setPreference('timezone', $_REQUEST['timezone']); |
606 | 606 | } |
607 | 607 | |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | //$_POST[''] = $_REQUEST['export_delimiter']; |
621 | 621 | |
622 | 622 | $_POST['record'] = $current_user->id; |
623 | -$_POST['is_admin'] = ( $current_user->is_admin ? 'on' : '' ); |
|
623 | +$_POST['is_admin'] = ($current_user->is_admin ? 'on' : ''); |
|
624 | 624 | $_POST['use_real_names'] = true; |
625 | 625 | $_POST['reminder_checked'] = '1'; |
626 | 626 | $_POST['reminder_time'] = 1800; |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | $_POST['mailmerge_on'] = 'on'; |
629 | 629 | $_POST['receive_notifications'] = $current_user->receive_notifications; |
630 | 630 | installLog('DBG: SugarThemeRegistry::getDefault'); |
631 | -$_POST['user_theme'] = (string) SugarThemeRegistry::getDefault(); |
|
631 | +$_POST['user_theme'] = (string)SugarThemeRegistry::getDefault(); |
|
632 | 632 | |
633 | 633 | // save and redirect to new view |
634 | 634 | $_REQUEST['return_module'] = 'Home'; |
@@ -638,15 +638,15 @@ discard block |
||
638 | 638 | |
639 | 639 | // restore superglobals and vars |
640 | 640 | $GLOBALS = $varStack['GLOBALS']; |
641 | -foreach($varStack['defined_vars'] as $__key => $__value) $$__key = $__value; |
|
641 | +foreach ($varStack['defined_vars'] as $__key => $__value) $$__key = $__value; |
|
642 | 642 | |
643 | 643 | |
644 | 644 | |
645 | 645 | $endTime = microtime(true); |
646 | 646 | $deltaTime = $endTime - $startTime; |
647 | 647 | |
648 | -if( count( $bottle ) > 0 ){ |
|
649 | - foreach( $bottle as $bottle_message ){ |
|
648 | +if (count($bottle) > 0) { |
|
649 | + foreach ($bottle as $bottle_message) { |
|
650 | 650 | $bottleMsg .= "{$bottle_message}\n"; |
651 | 651 | } |
652 | 652 | } else { |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | } |
655 | 655 | installerHook('post_installModules'); |
656 | 656 | |
657 | -$out =<<<EOQ |
|
657 | +$out = <<<EOQ |
|
658 | 658 | <br><p><b>{$mod_strings['LBL_PERFORM_OUTRO_1']} {$setup_sugar_version} {$mod_strings['LBL_PERFORM_OUTRO_2']}</b></p> |
659 | 659 | |
660 | 660 | {$mod_strings['LBL_PERFORM_OUTRO_3']} {$deltaTime} {$mod_strings['LBL_PERFORM_OUTRO_4']}<br /> |
@@ -676,6 +676,6 @@ discard block |
||
676 | 676 | echo $out; |
677 | 677 | |
678 | 678 | $loginURL = str_replace('install.php', 'index.php', "//$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"); |
679 | -installStatus(sprintf($mod_strings['STAT_INSTALL_FINISH_LOGIN'], $loginURL ) , array('function' => 'redirect', 'arguments' => $loginURL) ); |
|
679 | +installStatus(sprintf($mod_strings['STAT_INSTALL_FINISH_LOGIN'], $loginURL), array('function' => 'redirect', 'arguments' => $loginURL)); |
|
680 | 680 | |
681 | 681 | ?> |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | 'd.m.Y' => '23.12.2010', |
121 | 121 | 'm.d.Y' => '12.23.2010', |
122 | 122 | ) : $dateFormats, |
123 | - 'dbconfig' => $dbconfig, // this must be set!! |
|
124 | - 'dbconfigoption' => $dbconfigoption, // this must be set!! |
|
123 | + 'dbconfig' => $dbconfig, // this must be set!! |
|
124 | + 'dbconfigoption' => $dbconfigoption, // this must be set!! |
|
125 | 125 | 'default_action' => empty($default_action) ? 'index' : $default_action, |
126 | 126 | 'default_charset' => empty($default_charset) ? 'UTF-8' : $default_charset, |
127 | 127 | 'default_currency_name' => empty($default_currency_name) ? 'US Dollar' : $default_currency_name, |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | 'display_inbound_email_buttons' => empty($display_inbound_email_buttons) ? false : $display_inbound_email_buttons, |
150 | 150 | 'history_max_viewed' => empty($history_max_viewed) ? 50 : $history_max_viewed, |
151 | 151 | 'host_name' => empty($host_name) ? 'localhost' : $host_name, |
152 | - 'import_dir' => $import_dir, // this must be set!! |
|
152 | + 'import_dir' => $import_dir, // this must be set!! |
|
153 | 153 | 'import_max_records_per_file' => 100, |
154 | 154 | 'import_max_records_total_limit' => '', |
155 | 155 | 'languages' => empty($languages) ? array('en_us' => 'English (US)') : $languages, |
@@ -169,21 +169,21 @@ discard block |
||
169 | 169 | ), |
170 | 170 | 'require_accounts' => empty($requireAccounts) ? true : $requireAccounts, |
171 | 171 | 'rss_cache_time' => empty($RSS_CACHE_TIME) ? '10800' : $RSS_CACHE_TIME, |
172 | - 'session_dir' => $session_dir, // this must be set!! |
|
173 | - 'site_url' => empty($site_URL) ? $site_url : $site_URL, // this must be set!! |
|
172 | + 'session_dir' => $session_dir, // this must be set!! |
|
173 | + 'site_url' => empty($site_URL) ? $site_url : $site_URL, // this must be set!! |
|
174 | 174 | 'showDetailData' => true, // if true, read-only ACL fields will still appear on EditViews as non-editable |
175 | 175 | 'showThemePicker' => true, |
176 | 176 | 'sugar_version' => empty($sugar_version) ? 'unknown' : $sugar_version, |
177 | 177 | 'time_formats' => empty($timeFormats) ? array( |
178 | 178 | 'H:i' => '23:00', 'h:ia' => '11:00 pm', 'h:iA' => '11:00PM', |
179 | - 'H.i' => '23.00', 'h.ia' => '11.00 pm', 'h.iA' => '11.00PM', ) : $timeFormats, |
|
180 | - 'tmp_dir' => $tmp_dir, // this must be set!! |
|
179 | + 'H.i' => '23.00', 'h.ia' => '11.00 pm', 'h.iA' => '11.00PM',) : $timeFormats, |
|
180 | + 'tmp_dir' => $tmp_dir, // this must be set!! |
|
181 | 181 | 'translation_string_prefix' => empty($translation_string_prefix) ? false : $translation_string_prefix, |
182 | 182 | 'unique_key' => empty($unique_key) ? md5(create_guid()) : $unique_key, |
183 | 183 | 'upload_badext' => empty($upload_badext) ? array( |
184 | 184 | 'php', 'php3', 'php4', 'php5', 'pl', 'cgi', 'py', |
185 | - 'asp', 'cfm', 'js', 'vbs', 'html', 'htm', ) : $upload_badext, |
|
186 | - 'upload_dir' => $upload_dir, // this must be set!! |
|
185 | + 'asp', 'cfm', 'js', 'vbs', 'html', 'htm',) : $upload_badext, |
|
186 | + 'upload_dir' => $upload_dir, // this must be set!! |
|
187 | 187 | 'upload_maxsize' => empty($upload_maxsize) ? 30000000 : $upload_maxsize, |
188 | 188 | 'import_max_execution_time' => empty($import_max_execution_time) ? 3600 : $import_max_execution_time, |
189 | 189 | 'lock_homepage' => false, |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | 'date_formats' => array( |
250 | 250 | 'Y-m-d' => '2010-12-23', 'm-d-Y' => '12-23-2010', 'd-m-Y' => '23-12-2010', |
251 | 251 | 'Y/m/d' => '2010/12/23', 'm/d/Y' => '12/23/2010', 'd/m/Y' => '23/12/2010', |
252 | - 'Y.m.d' => '2010.12.23', 'd.m.Y' => '23.12.2010', 'm.d.Y' => '12.23.2010', ), |
|
252 | + 'Y.m.d' => '2010.12.23', 'd.m.Y' => '23.12.2010', 'm.d.Y' => '12.23.2010',), |
|
253 | 253 | 'name_formats' => array( |
254 | 254 | 's f l' => 's f l', 'f l' => 'f l', 's l' => 's l', 'l, s f' => 'l, s f', |
255 | 255 | 'l, f' => 'l, f', 's l, f' => 's l, f', 'l s f' => 'l s f', 'l f s' => 'l f s', |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | 'persistent' => true, |
259 | 259 | 'autofree' => false, |
260 | 260 | 'debug' => 0, |
261 | - 'ssl' => false, ), |
|
261 | + 'ssl' => false,), |
|
262 | 262 | 'default_action' => 'index', |
263 | 263 | 'default_charset' => return_session_value_or_default('default_charset', |
264 | 264 | 'UTF-8'), |
@@ -321,12 +321,12 @@ discard block |
||
321 | 321 | 'sugarbeet' => true, |
322 | 322 | 'time_formats' => array( |
323 | 323 | 'H:i' => '23:00', 'h:ia' => '11:00pm', 'h:iA' => '11:00PM', 'h:i a' => '11:00 pm', 'h:i A' => '11:00 PM', |
324 | - 'H.i' => '23.00', 'h.ia' => '11.00pm', 'h.iA' => '11.00PM', 'h.i a' => '11.00 pm', 'h.i A' => '11.00 PM', ), |
|
324 | + 'H.i' => '23.00', 'h.ia' => '11.00pm', 'h.iA' => '11.00PM', 'h.i a' => '11.00 pm', 'h.i A' => '11.00 PM',), |
|
325 | 325 | 'tracker_max_display_length' => 15, |
326 | 326 | 'translation_string_prefix' => return_session_value_or_default('translation_string_prefix', false), |
327 | 327 | 'upload_badext' => array( |
328 | 328 | 'php', 'php3', 'php4', 'php5', 'pl', 'cgi', 'py', |
329 | - 'asp', 'cfm', 'js', 'vbs', 'html', 'htm', 'phtml', ), |
|
329 | + 'asp', 'cfm', 'js', 'vbs', 'html', 'htm', 'phtml',), |
|
330 | 330 | 'upload_maxsize' => 30000000, |
331 | 331 | 'import_max_execution_time' => 3600, |
332 | 332 | // 'use_php_code_json' => returnPhpJsonStatus(), |
@@ -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. |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | /** |
100 | 100 | * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead |
101 | 101 | */ |
102 | - public function ProspectList(){ |
|
102 | + public function ProspectList() { |
|
103 | 103 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
104 | - if(isset($GLOBALS['log'])) { |
|
104 | + if (isset($GLOBALS['log'])) { |
|
105 | 105 | $GLOBALS['log']->deprecated($deprecatedMessage); |
106 | 106 | } |
107 | 107 | else { |
@@ -135,18 +135,18 @@ discard block |
||
135 | 135 | $query .= $custom_join['join']; |
136 | 136 | |
137 | 137 | $where_auto = '1=1'; |
138 | - if($show_deleted == 0){ |
|
138 | + if ($show_deleted == 0) { |
|
139 | 139 | $where_auto = "$this->table_name.deleted=0"; |
140 | - }else if($show_deleted == 1){ |
|
140 | + } else if ($show_deleted == 1) { |
|
141 | 141 | $where_auto = "$this->table_name.deleted=1"; |
142 | 142 | } |
143 | 143 | |
144 | - if($where != "") |
|
144 | + if ($where != "") |
|
145 | 145 | $query .= "where $where AND ".$where_auto; |
146 | 146 | else |
147 | 147 | $query .= "where ".$where_auto; |
148 | 148 | |
149 | - if($order_by != "") |
|
149 | + if ($order_by != "") |
|
150 | 150 | $query .= " ORDER BY $order_by"; |
151 | 151 | else |
152 | 152 | $query .= " ORDER BY prospect_lists.name"; |
@@ -162,17 +162,17 @@ discard block |
||
162 | 162 | prospect_lists.*, |
163 | 163 | users.user_name as assigned_user_name "; |
164 | 164 | $query .= "FROM prospect_lists "; |
165 | - $query .= "LEFT JOIN users |
|
165 | + $query .= "LEFT JOIN users |
|
166 | 166 | ON prospect_lists.assigned_user_id=users.id "; |
167 | 167 | |
168 | 168 | $where_auto = " prospect_lists.deleted=0"; |
169 | 169 | |
170 | - if($where != "") |
|
170 | + if ($where != "") |
|
171 | 171 | $query .= " WHERE $where AND ".$where_auto; |
172 | 172 | else |
173 | 173 | $query .= " WHERE ".$where_auto; |
174 | 174 | |
175 | - if($order_by != "") |
|
175 | + if ($order_by != "") |
|
176 | 176 | $query .= " ORDER BY $order_by"; |
177 | 177 | else |
178 | 178 | $query .= " ORDER BY prospect_lists.name"; |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | |
182 | 182 | function create_export_members_query($record_id) |
183 | 183 | { |
184 | - $members = array( 'Accounts' => array('has_custom_fields' => false, 'fields' => array()), |
|
184 | + $members = array('Accounts' => array('has_custom_fields' => false, 'fields' => array()), |
|
185 | 185 | 'Contacts' => array('has_custom_fields' => false, 'fields' => array()), |
186 | 186 | 'Users' => array('has_custom_fields' => false, 'fields' => array()), |
187 | 187 | 'Prospects' => array('has_custom_fields' => false, 'fields' => array()), |
@@ -190,31 +190,31 @@ discard block |
||
190 | 190 | |
191 | 191 | // query all custom fields in the fields_meta_data table for the modules which are being exported |
192 | 192 | $db = DBManagerFactory::getInstance(); |
193 | - $result = $db->query("select name, custom_module from fields_meta_data where custom_module in ('" . |
|
194 | - implode("', '", array_keys($members)) . "')", |
|
193 | + $result = $db->query("select name, custom_module from fields_meta_data where custom_module in ('". |
|
194 | + implode("', '", array_keys($members))."')", |
|
195 | 195 | true, |
196 | 196 | "ProspectList::create_export_members_query() : error querying custom fields"); |
197 | 197 | |
198 | 198 | // cycle through the custom fields and put them in the members array according to |
199 | 199 | // what module the field belongs |
200 | 200 | // take into account that the same custom field may exist in more modules |
201 | - while($val = $db->fetchByAssoc($result, false)) |
|
201 | + while ($val = $db->fetchByAssoc($result, false)) |
|
202 | 202 | { |
203 | 203 | $fieldname = $val['name']; |
204 | 204 | |
205 | - foreach($members as $membername => &$memberarr) |
|
205 | + foreach ($members as $membername => &$memberarr) |
|
206 | 206 | { |
207 | 207 | // if the field belongs to this module, then query it in the cstm table |
208 | 208 | if ($membername == $val['custom_module']) |
209 | 209 | { |
210 | 210 | $memberarr['has_custom_fields'] = true; |
211 | 211 | $memberarr['fields'][$fieldname] = |
212 | - strtolower($membername) . '_cstm.'.$fieldname . ' AS ' . $fieldname; |
|
212 | + strtolower($membername).'_cstm.'.$fieldname.' AS '.$fieldname; |
|
213 | 213 | } |
214 | 214 | // else, only if for this module no entry exists for this field, query an empty string |
215 | 215 | else if (!isset($memberarr['fields'][$val['name']])) |
216 | 216 | { |
217 | - $memberarr['fields'][$fieldname] = "'' AS " . $fieldname; |
|
217 | + $memberarr['fields'][$fieldname] = "'' AS ".$fieldname; |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | l.account_name AS account_name, |
225 | 225 | ea.email_address AS primary_email_address, ea.invalid_email AS invalid_email, ea.opt_out AS opt_out, ea.deleted AS ea_deleted, ear.deleted AS ear_deleted, ear.primary_address AS primary_address, |
226 | 226 | l.do_not_call AS do_not_call, l.phone_fax AS phone_fax, l.phone_other AS phone_other, l.phone_home AS phone_home, l.phone_mobile AS phone_mobile, l.phone_work AS phone_work |
227 | - ".(count($members['Leads']['fields']) ? ', ' : '') . implode(', ', $members['Leads']['fields'])." |
|
227 | + ".(count($members['Leads']['fields']) ? ', ' : '').implode(', ', $members['Leads']['fields'])." |
|
228 | 228 | FROM prospect_lists_prospects plp |
229 | 229 | INNER JOIN leads l ON plp.related_id=l.id |
230 | 230 | ".($members['Leads']['has_custom_fields'] ? 'LEFT join leads_cstm ON l.id = leads_cstm.id_c' : '')." |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | '' AS account_name, |
240 | 240 | ea.email_address AS email_address, ea.invalid_email AS invalid_email, ea.opt_out AS opt_out, ea.deleted AS ea_deleted, ear.deleted AS ear_deleted, ear.primary_address AS primary_address, |
241 | 241 | 0 AS do_not_call, u.phone_fax AS phone_fax, u.phone_other AS phone_other, u.phone_home AS phone_home, u.phone_mobile AS phone_mobile, u.phone_work AS phone_work |
242 | - ".(count($members['Users']['fields']) ? ', ' : '') . implode(', ', $members['Users']['fields'])." |
|
242 | + ".(count($members['Users']['fields']) ? ', ' : '').implode(', ', $members['Users']['fields'])." |
|
243 | 243 | FROM prospect_lists_prospects plp |
244 | 244 | INNER JOIN users u ON plp.related_id=u.id |
245 | 245 | ".($members['Users']['has_custom_fields'] ? 'LEFT join users_cstm ON u.id = users_cstm.id_c' : '')." |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | a.name AS account_name, |
255 | 255 | ea.email_address AS email_address, ea.invalid_email AS invalid_email, ea.opt_out AS opt_out, ea.deleted AS ea_deleted, ear.deleted AS ear_deleted, ear.primary_address AS primary_address, |
256 | 256 | c.do_not_call AS do_not_call, c.phone_fax AS phone_fax, c.phone_other AS phone_other, c.phone_home AS phone_home, c.phone_mobile AS phone_mobile, c.phone_work AS phone_work |
257 | - ".(count($members['Contacts']['fields']) ? ', ' : '') . implode(', ', $members['Contacts']['fields'])." |
|
257 | + ".(count($members['Contacts']['fields']) ? ', ' : '').implode(', ', $members['Contacts']['fields'])." |
|
258 | 258 | FROM prospect_lists_prospects plp |
259 | 259 | INNER JOIN contacts c ON plp.related_id=c.id LEFT JOIN accounts_contacts ac ON ac.contact_id=c.id |
260 | 260 | LEFT JOIN accounts a ON ac.account_id=a.id AND ac.deleted=0 |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | p.account_name AS account_name, |
271 | 271 | ea.email_address AS email_address, ea.invalid_email AS invalid_email, ea.opt_out AS opt_out, ea.deleted AS ea_deleted, ear.deleted AS ear_deleted, ear.primary_address AS primary_address, |
272 | 272 | p.do_not_call AS do_not_call, p.phone_fax AS phone_fax, p.phone_other AS phone_other, p.phone_home AS phone_home, p.phone_mobile AS phone_mobile, p.phone_work AS phone_work |
273 | - ".(count($members['Prospects']['fields']) ? ', ' : '') . implode(', ', $members['Prospects']['fields'])." |
|
273 | + ".(count($members['Prospects']['fields']) ? ', ' : '').implode(', ', $members['Prospects']['fields'])." |
|
274 | 274 | FROM prospect_lists_prospects plp |
275 | 275 | INNER JOIN prospects p ON plp.related_id=p.id |
276 | 276 | ".($members['Prospects']['has_custom_fields'] ? 'LEFT join prospects_cstm ON p.id = prospects_cstm.id_c' : '')." |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | '' AS account_name, |
286 | 286 | ea.email_address AS email_address, ea.invalid_email AS invalid_email, ea.opt_out AS opt_out, ea.deleted AS ea_deleted, ear.deleted AS ear_deleted, ear.primary_address AS primary_address, |
287 | 287 | 0 AS do_not_call, a.phone_fax as phone_fax, a.phone_alternate AS phone_other, '' AS phone_home, '' AS phone_mobile, a.phone_office AS phone_office |
288 | - ".(count($members['Accounts']['fields']) ? ', ' : '') . implode(', ', $members['Accounts']['fields'])." |
|
288 | + ".(count($members['Accounts']['fields']) ? ', ' : '').implode(', ', $members['Accounts']['fields'])." |
|
289 | 289 | FROM prospect_lists_prospects plp |
290 | 290 | INNER JOIN accounts a ON plp.related_id=a.id |
291 | 291 | ".($members['Accounts']['has_custom_fields'] ? 'LEFT join accounts_cstm ON a.id = accounts_cstm.id_c' : '')." |
@@ -302,11 +302,11 @@ discard block |
||
302 | 302 | function save_relationship_changes($is_update, $exclude = array()) |
303 | 303 | { |
304 | 304 | parent::save_relationship_changes($is_update, $exclude); |
305 | - if($this->lead_id != "") |
|
305 | + if ($this->lead_id != "") |
|
306 | 306 | $this->set_prospect_relationship($this->id, $this->lead_id, "lead"); |
307 | - if($this->contact_id != "") |
|
307 | + if ($this->contact_id != "") |
|
308 | 308 | $this->set_prospect_relationship($this->id, $this->contact_id, "contact"); |
309 | - if($this->prospect_id != "") |
|
309 | + if ($this->prospect_id != "") |
|
310 | 310 | $this->set_prospect_relationship($this->id, $this->contact_id, "prospect"); |
311 | 311 | } |
312 | 312 | |
@@ -314,9 +314,9 @@ discard block |
||
314 | 314 | { |
315 | 315 | $link_field = sprintf("%s_id", $link_name); |
316 | 316 | |
317 | - foreach($link_ids as $link_id) |
|
317 | + foreach ($link_ids as $link_id) |
|
318 | 318 | { |
319 | - $this->set_relationship('prospect_lists_prospects', array( $link_field=>$link_id, 'prospect_list_id'=>$prospect_list_id )); |
|
319 | + $this->set_relationship('prospect_lists_prospects', array($link_field=>$link_id, 'prospect_list_id'=>$prospect_list_id)); |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | { |
325 | 325 | $link_field = sprintf("%s_id", $link_name); |
326 | 326 | |
327 | - $this->set_relationship('prospect_lists_prospects', array( $link_field=>$link_id, 'prospect_list_id'=>$prospect_list_id )); |
|
327 | + $this->set_relationship('prospect_lists_prospects', array($link_field=>$link_id, 'prospect_list_id'=>$prospect_list_id)); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | } |
355 | 355 | |
356 | 356 | |
357 | - function update_currency_id($fromid, $toid){ |
|
357 | + function update_currency_id($fromid, $toid) { |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | |
@@ -365,14 +365,14 @@ discard block |
||
365 | 365 | |
366 | 366 | $row = $this->db->fetchByAssoc($result); |
367 | 367 | |
368 | - if($row) |
|
368 | + if ($row) |
|
369 | 369 | return $row['num']; |
370 | 370 | else |
371 | 371 | return 0; |
372 | 372 | } |
373 | 373 | |
374 | 374 | |
375 | - function get_list_view_data(){ |
|
375 | + function get_list_view_data() { |
|
376 | 376 | $temp_array = $this->get_list_view_array(); |
377 | 377 | $temp_array["ENTRY_COUNT"] = $this->get_entry_count(); |
378 | 378 | return $temp_array; |
@@ -381,16 +381,16 @@ discard block |
||
381 | 381 | builds a generic search based on the query string using or |
382 | 382 | do not include any $this-> because this is called on without having the class instantiated |
383 | 383 | */ |
384 | - function build_generic_where_clause ($the_query_string) |
|
384 | + function build_generic_where_clause($the_query_string) |
|
385 | 385 | { |
386 | 386 | $where_clauses = Array(); |
387 | 387 | $the_query_string = $GLOBALS['db']->quote($the_query_string); |
388 | 388 | array_push($where_clauses, "prospect_lists.name like '$the_query_string%'"); |
389 | 389 | |
390 | 390 | $the_where = ""; |
391 | - foreach($where_clauses as $clause) |
|
391 | + foreach ($where_clauses as $clause) |
|
392 | 392 | { |
393 | - if($the_where != "") $the_where .= " or "; |
|
393 | + if ($the_where != "") $the_where .= " or "; |
|
394 | 394 | $the_where .= $clause; |
395 | 395 | } |
396 | 396 | |
@@ -404,14 +404,14 @@ discard block |
||
404 | 404 | |
405 | 405 | } |
406 | 406 | |
407 | - function mark_deleted($id){ |
|
407 | + function mark_deleted($id) { |
|
408 | 408 | $query = "UPDATE prospect_lists_prospects SET deleted = 1 WHERE prospect_list_id = '{$id}' "; |
409 | 409 | $this->db->query($query); |
410 | 410 | return parent::mark_deleted($id); |
411 | 411 | } |
412 | 412 | |
413 | - function bean_implements($interface){ |
|
414 | - switch($interface){ |
|
413 | + function bean_implements($interface) { |
|
414 | + switch ($interface) { |
|
415 | 415 | case 'ACL':return true; |
416 | 416 | } |
417 | 417 | return false; |
@@ -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. |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | ini_set('mssql.datetimeconvert', '0'); |
176 | 176 | |
177 | 177 | //set the text size and textlimit to max number so that blob columns are not truncated |
178 | - ini_set('mssql.textlimit','2147483647'); |
|
179 | - ini_set('mssql.textsize','2147483647'); |
|
180 | - ini_set('mssql.charset','UTF-8'); |
|
178 | + ini_set('mssql.textlimit', '2147483647'); |
|
179 | + ini_set('mssql.textsize', '2147483647'); |
|
180 | + ini_set('mssql.charset', 'UTF-8'); |
|
181 | 181 | |
182 | - if(!empty($configOptions['db_host_instance'])) { |
|
182 | + if (!empty($configOptions['db_host_instance'])) { |
|
183 | 183 | $configOptions['db_host_instance'] = trim($configOptions['db_host_instance']); |
184 | 184 | } |
185 | 185 | //set the connections parameters |
@@ -191,37 +191,37 @@ discard block |
||
191 | 191 | |
192 | 192 | //create persistent connection |
193 | 193 | if ($this->getOption('persistent')) { |
194 | - $this->database =@mssql_pconnect( |
|
195 | - $connect_param , |
|
194 | + $this->database = @mssql_pconnect( |
|
195 | + $connect_param, |
|
196 | 196 | $configOptions['db_user_name'], |
197 | 197 | $configOptions['db_password'] |
198 | 198 | ); |
199 | 199 | } |
200 | 200 | //if no persistent connection created, then create regular connection |
201 | - if(!$this->database){ |
|
201 | + if (!$this->database) { |
|
202 | 202 | $this->database = mssql_connect( |
203 | - $connect_param , |
|
203 | + $connect_param, |
|
204 | 204 | $configOptions['db_user_name'], |
205 | 205 | $configOptions['db_password'] |
206 | 206 | ); |
207 | - if(!$this->database){ |
|
207 | + if (!$this->database) { |
|
208 | 208 | $GLOBALS['log']->fatal("Could not connect to server ".$configOptions['db_host_name']. |
209 | 209 | " as ".$configOptions['db_user_name']."."); |
210 | - if($dieOnError) { |
|
210 | + if ($dieOnError) { |
|
211 | 211 | sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
212 | 212 | } else { |
213 | 213 | return false; |
214 | 214 | } |
215 | 215 | } |
216 | - if($this->database && $this->getOption('persistent')){ |
|
216 | + if ($this->database && $this->getOption('persistent')) { |
|
217 | 217 | $_SESSION['administrator_error'] = "<B>Severe Performance Degradation: Persistent Database Connections " |
218 | 218 | . "not working. Please set \$sugar_config['dbconfigoption']['persistent'] to false in your " |
219 | 219 | . "config.php file</B>"; |
220 | 220 | } |
221 | 221 | } |
222 | 222 | //make sure connection exists |
223 | - if(!$this->database) { |
|
224 | - if($dieOnError) { |
|
223 | + if (!$this->database) { |
|
224 | + if ($dieOnError) { |
|
225 | 225 | sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
226 | 226 | } else { |
227 | 227 | return false; |
@@ -235,19 +235,19 @@ discard block |
||
235 | 235 | //mssql db maximum number of 5 times at the interval of .2 second. If can not connect |
236 | 236 | //it will throw an Unable to select database message. |
237 | 237 | |
238 | - if(!empty($configOptions['db_name']) && !@mssql_select_db($configOptions['db_name'], $this->database)){ |
|
238 | + if (!empty($configOptions['db_name']) && !@mssql_select_db($configOptions['db_name'], $this->database)) { |
|
239 | 239 | $connected = false; |
240 | - for($i=0;$i<5;$i++){ |
|
240 | + for ($i = 0; $i < 5; $i++) { |
|
241 | 241 | usleep(200000); |
242 | - if(@mssql_select_db($configOptions['db_name'], $this->database)){ |
|
242 | + if (@mssql_select_db($configOptions['db_name'], $this->database)) { |
|
243 | 243 | $connected = true; |
244 | 244 | break; |
245 | 245 | } |
246 | 246 | } |
247 | - if(!$connected){ |
|
248 | - $GLOBALS['log']->fatal( "Unable to select database {$configOptions['db_name']}"); |
|
249 | - if($dieOnError) { |
|
250 | - if(isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
247 | + if (!$connected) { |
|
248 | + $GLOBALS['log']->fatal("Unable to select database {$configOptions['db_name']}"); |
|
249 | + if ($dieOnError) { |
|
250 | + if (isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
251 | 251 | sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
252 | 252 | } else { |
253 | 253 | sugar_die("Could not connect to the database. Please refer to suitecrm.log for details."); |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
261 | - if(!$this->checkError('Could Not Connect', $dieOnError)) |
|
261 | + if (!$this->checkError('Could Not Connect', $dieOnError)) |
|
262 | 262 | $GLOBALS['log']->info("connected to db"); |
263 | 263 | |
264 | 264 | $this->connectOptions = $configOptions; |
@@ -280,16 +280,16 @@ discard block |
||
280 | 280 | */ |
281 | 281 | public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false) |
282 | 282 | { |
283 | - if(is_array($sql)) { |
|
283 | + if (is_array($sql)) { |
|
284 | 284 | return $this->queryArray($sql, $dieOnError, $msg, $suppress); |
285 | 285 | } |
286 | 286 | // Flag if there are odd number of single quotes |
287 | 287 | if ((substr_count($sql, "'") & 1)) |
288 | - $GLOBALS['log']->error("SQL statement[" . $sql . "] has odd number of single quotes."); |
|
288 | + $GLOBALS['log']->error("SQL statement[".$sql."] has odd number of single quotes."); |
|
289 | 289 | |
290 | 290 | $sql = $this->_appendN($sql); |
291 | 291 | |
292 | - $GLOBALS['log']->debug('Query:' . $sql); |
|
292 | + $GLOBALS['log']->debug('Query:'.$sql); |
|
293 | 293 | $this->checkConnection(); |
294 | 294 | $this->countQuery($sql); |
295 | 295 | $this->query_time = microtime(true); |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | // Bug 34892 - Clear out previous error message by checking the @@ERROR global variable |
298 | 298 | @mssql_query("SELECT @@ERROR", $this->database); |
299 | 299 | |
300 | - $result = $suppress?@mssql_query($sql, $this->database):mssql_query($sql, $this->database); |
|
300 | + $result = $suppress ? @mssql_query($sql, $this->database) : mssql_query($sql, $this->database); |
|
301 | 301 | |
302 | 302 | if (!$result) { |
303 | 303 | // awu Bug 10657: ignoring mssql error message 'Changed database context to' - an intermittent |
@@ -309,13 +309,13 @@ discard block |
||
309 | 309 | $sqlpos3 = strpos($sqlmsg, 'Checking identity information:'); |
310 | 310 | |
311 | 311 | if ($sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false) // if sqlmsg has 'Changed database context to', just log it |
312 | - $GLOBALS['log']->debug($sqlmsg . ": " . $sql ); |
|
312 | + $GLOBALS['log']->debug($sqlmsg.": ".$sql); |
|
313 | 313 | else { |
314 | - $GLOBALS['log']->fatal($sqlmsg . ": " . $sql ); |
|
315 | - if($dieOnError) |
|
316 | - sugar_die('SQL Error : ' . $sqlmsg); |
|
314 | + $GLOBALS['log']->fatal($sqlmsg.": ".$sql); |
|
315 | + if ($dieOnError) |
|
316 | + sugar_die('SQL Error : '.$sqlmsg); |
|
317 | 317 | else |
318 | - echo 'SQL Error : ' . $sqlmsg; |
|
318 | + echo 'SQL Error : '.$sqlmsg; |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $GLOBALS['log']->debug('Query Execution Time:'.$this->query_time); |
324 | 324 | |
325 | 325 | |
326 | - $this->checkError($msg.' Query Failed: ' . $sql, $dieOnError); |
|
326 | + $this->checkError($msg.' Query Failed: '.$sql, $dieOnError); |
|
327 | 327 | |
328 | 328 | return $result; |
329 | 329 | } |
@@ -341,14 +341,14 @@ discard block |
||
341 | 341 | { |
342 | 342 | //set the start to 0, no negs |
343 | 343 | if ($start < 0) |
344 | - $start=0; |
|
344 | + $start = 0; |
|
345 | 345 | |
346 | - $GLOBALS['log']->debug(print_r(func_get_args(),true)); |
|
346 | + $GLOBALS['log']->debug(print_r(func_get_args(), true)); |
|
347 | 347 | |
348 | 348 | $this->lastsql = $sql; |
349 | 349 | |
350 | 350 | //change the casing to lower for easier string comparison, and trim whitespaces |
351 | - $sql = strtolower(trim($sql)) ; |
|
351 | + $sql = strtolower(trim($sql)); |
|
352 | 352 | |
353 | 353 | //set default sql |
354 | 354 | $limitUnionSQL = $sql; |
@@ -364,16 +364,16 @@ discard block |
||
364 | 364 | $arr_count = 0; |
365 | 365 | |
366 | 366 | //process if there are elements |
367 | - if ($unionOrderByCount){ |
|
367 | + if ($unionOrderByCount) { |
|
368 | 368 | //we really want the last order by, so reconstruct string |
369 | 369 | //adding a 1 to count, as we dont wish to process the last element |
370 | 370 | $unionsql = ''; |
371 | - while ($unionOrderByCount>$arr_count+1) { |
|
371 | + while ($unionOrderByCount > $arr_count + 1) { |
|
372 | 372 | $unionsql .= $orderByArray[$arr_count]; |
373 | - $arr_count = $arr_count+1; |
|
373 | + $arr_count = $arr_count + 1; |
|
374 | 374 | //add an "order by" string back if we are coming into loop again |
375 | 375 | //remember they were taken out when array was created |
376 | - if ($unionOrderByCount>$arr_count+1) { |
|
376 | + if ($unionOrderByCount > $arr_count + 1) { |
|
377 | 377 | $unionsql .= "order by"; |
378 | 378 | } |
379 | 379 | } |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | //so we do not want to strip the alias like in other queries. Just add the "order by" string and |
404 | 404 | //pass column name as is |
405 | 405 | if ($unionOrderBy != '') { |
406 | - $unionOrderBy = ' order by ' . $unionOrderBy; |
|
406 | + $unionOrderBy = ' order by '.$unionOrderBy; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | //Bug 56560, use top query in conjunction with rownumber() function |
@@ -412,13 +412,13 @@ discard block |
||
412 | 412 | //If not for paging, no need to use rownumber() function |
413 | 413 | if ($count == 1 && $start == 0) |
414 | 414 | { |
415 | - $limitUnionSQL = "SELECT TOP $count * FROM (" .$unionsql .") as top_count ".$unionOrderBy; |
|
415 | + $limitUnionSQL = "SELECT TOP $count * FROM (".$unionsql.") as top_count ".$unionOrderBy; |
|
416 | 416 | } |
417 | 417 | else |
418 | 418 | { |
419 | 419 | $limitUnionSQL = "SELECT TOP $count * FROM( select ROW_NUMBER() OVER ( order by " |
420 | 420 | .$rowNumOrderBy.") AS row_number, * FROM (" |
421 | - .$unionsql .") As numbered) " |
|
421 | + .$unionsql.") As numbered) " |
|
422 | 422 | . "As top_count_limit WHERE row_number > $start " |
423 | 423 | .$unionOrderBy; |
424 | 424 | } |
@@ -437,64 +437,64 @@ discard block |
||
437 | 437 | $newSQL = $sql; |
438 | 438 | $distinctSQLARRAY = array(); |
439 | 439 | if (strpos($sql, "UNION") && !preg_match("/(')(UNION).?(')/i", $sql)) |
440 | - $newSQL = $this->handleUnionLimitQuery($sql,$start,$count); |
|
440 | + $newSQL = $this->handleUnionLimitQuery($sql, $start, $count); |
|
441 | 441 | else { |
442 | 442 | if ($start < 0) |
443 | 443 | $start = 0; |
444 | - $GLOBALS['log']->debug(print_r(func_get_args(),true)); |
|
444 | + $GLOBALS['log']->debug(print_r(func_get_args(), true)); |
|
445 | 445 | $this->lastsql = $sql; |
446 | 446 | $matches = array(); |
447 | - preg_match('/^(.*SELECT\b)(.*?\bFROM\b.*\bWHERE\b)(.*)$/isU',$sql, $matches); |
|
447 | + preg_match('/^(.*SELECT\b)(.*?\bFROM\b.*\bWHERE\b)(.*)$/isU', $sql, $matches); |
|
448 | 448 | if (!empty($matches[3])) { |
449 | 449 | if ($start == 0) { |
450 | 450 | $match_two = strtolower($matches[2]); |
451 | - if (!strpos($match_two, "distinct")> 0 && strpos($match_two, "distinct") !==0) { |
|
451 | + if (!strpos($match_two, "distinct") > 0 && strpos($match_two, "distinct") !== 0) { |
|
452 | 452 | $orderByMatch = array(); |
453 | - preg_match('/^(.*)(\bORDER BY\b)(.*)$/is',$matches[3], $orderByMatch); |
|
453 | + preg_match('/^(.*)(\bORDER BY\b)(.*)$/is', $matches[3], $orderByMatch); |
|
454 | 454 | if (!empty($orderByMatch[3])) { |
455 | 455 | $selectPart = array(); |
456 | 456 | preg_match('/^(.*)(\bFROM\b.*)$/isU', $matches[2], $selectPart); |
457 | 457 | $newSQL = "SELECT TOP $count * FROM |
458 | 458 | ( |
459 | - " . $matches[1] . $selectPart[1] . ", ROW_NUMBER() |
|
460 | - OVER (ORDER BY " . $this->returnOrderBy($sql, $orderByMatch[3]) . ") AS row_number |
|
461 | - " . $selectPart[2] . $orderByMatch[1]. " |
|
459 | + ".$matches[1].$selectPart[1].", ROW_NUMBER() |
|
460 | + OVER (ORDER BY " . $this->returnOrderBy($sql, $orderByMatch[3]).") AS row_number |
|
461 | + " . $selectPart[2].$orderByMatch[1]." |
|
462 | 462 | ) AS a |
463 | 463 | WHERE row_number > $start"; |
464 | 464 | } |
465 | 465 | else { |
466 | - $newSQL = $matches[1] . " TOP $count " . $matches[2] . $matches[3]; |
|
466 | + $newSQL = $matches[1]." TOP $count ".$matches[2].$matches[3]; |
|
467 | 467 | } |
468 | 468 | } |
469 | 469 | else { |
470 | 470 | $distinct_o = strpos($match_two, "distinct"); |
471 | 471 | $up_to_distinct_str = substr($match_two, 0, $distinct_o); |
472 | 472 | //check to see if the distinct is within a function, if so, then proceed as normal |
473 | - if (strpos($up_to_distinct_str,"(")) { |
|
473 | + if (strpos($up_to_distinct_str, "(")) { |
|
474 | 474 | //proceed as normal |
475 | - $newSQL = $matches[1] . " TOP $count " . $matches[2] . $matches[3]; |
|
475 | + $newSQL = $matches[1]." TOP $count ".$matches[2].$matches[3]; |
|
476 | 476 | } |
477 | 477 | else { |
478 | 478 | //if distinct is not within a function, then parse |
479 | 479 | //string contains distinct clause, "TOP needs to come after Distinct" |
480 | 480 | //get position of distinct |
481 | 481 | $match_zero = strtolower($matches[0]); |
482 | - $distinct_pos = strpos($match_zero , "distinct"); |
|
482 | + $distinct_pos = strpos($match_zero, "distinct"); |
|
483 | 483 | //get position of where |
484 | 484 | $where_pos = strpos($match_zero, "where"); |
485 | 485 | //parse through string |
486 | - $beg = substr($matches[0], 0, $distinct_pos+9 ); |
|
487 | - $mid = substr($matches[0], strlen($beg), ($where_pos+5) - (strlen($beg))); |
|
488 | - $end = substr($matches[0], strlen($beg) + strlen($mid) ); |
|
486 | + $beg = substr($matches[0], 0, $distinct_pos + 9); |
|
487 | + $mid = substr($matches[0], strlen($beg), ($where_pos + 5) - (strlen($beg))); |
|
488 | + $end = substr($matches[0], strlen($beg) + strlen($mid)); |
|
489 | 489 | //repopulate matches array |
490 | 490 | $matches[1] = $beg; $matches[2] = $mid; $matches[3] = $end; |
491 | 491 | |
492 | - $newSQL = $matches[1] . " TOP $count " . $matches[2] . $matches[3]; |
|
492 | + $newSQL = $matches[1]." TOP $count ".$matches[2].$matches[3]; |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 | } else { |
496 | 496 | $orderByMatch = array(); |
497 | - preg_match('/^(.*)(\bORDER BY\b)(.*)$/is',$matches[3], $orderByMatch); |
|
497 | + preg_match('/^(.*)(\bORDER BY\b)(.*)$/is', $matches[3], $orderByMatch); |
|
498 | 498 | |
499 | 499 | //if there is a distinct clause, parse sql string as we will have to insert the rownumber |
500 | 500 | //for paging, AFTER the distinct clause |
@@ -512,8 +512,8 @@ discard block |
||
512 | 512 | |
513 | 513 | //take out the select and distinct from string so we can reuse in group by |
514 | 514 | $dist_str = 'distinct'; |
515 | - preg_match('/\b' . $dist_str . '\b/simU', $matches_sql, $matchesPartSQL, PREG_OFFSET_CAPTURE); |
|
516 | - $matches_sql = trim(substr($matches_sql,$matchesPartSQL[0][1] + strlen($dist_str))); |
|
515 | + preg_match('/\b'.$dist_str.'\b/simU', $matches_sql, $matchesPartSQL, PREG_OFFSET_CAPTURE); |
|
516 | + $matches_sql = trim(substr($matches_sql, $matchesPartSQL[0][1] + strlen($dist_str))); |
|
517 | 517 | //get the position of where and from for further processing |
518 | 518 | preg_match('/\bfrom\b/simU', $matches_sql, $matchesPartSQL, PREG_OFFSET_CAPTURE); |
519 | 519 | $from_pos = $matchesPartSQL[0][1]; |
@@ -521,17 +521,17 @@ discard block |
||
521 | 521 | $where_pos = $matchesPartSQL[0][1]; |
522 | 522 | //split the sql into a string before and after the from clause |
523 | 523 | //we will use the columns being selected to construct the group by clause |
524 | - if ($from_pos>0 ) { |
|
524 | + if ($from_pos > 0) { |
|
525 | 525 | $distinctSQLARRAY[0] = substr($matches_sql, 0, $from_pos); |
526 | 526 | $distinctSQLARRAY[1] = substr($matches_sql, $from_pos); |
527 | 527 | //get position of order by (if it exists) so we can strip it from the string |
528 | 528 | $ob_pos = strpos($distinctSQLARRAY[1], "order by"); |
529 | 529 | if ($ob_pos) { |
530 | - $distinctSQLARRAY[1] = substr($distinctSQLARRAY[1],0,$ob_pos); |
|
530 | + $distinctSQLARRAY[1] = substr($distinctSQLARRAY[1], 0, $ob_pos); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | // strip off last closing parentheses from the where clause |
534 | - $distinctSQLARRAY[1] = preg_replace('/\)\s$/',' ',$distinctSQLARRAY[1]); |
|
534 | + $distinctSQLARRAY[1] = preg_replace('/\)\s$/', ' ', $distinctSQLARRAY[1]); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | $grpByStr = array(); |
@@ -550,30 +550,30 @@ discard block |
||
550 | 550 | $newSQL = "SELECT TOP $count * FROM |
551 | 551 | ( |
552 | 552 | SELECT ROW_NUMBER() |
553 | - OVER (ORDER BY " . preg_replace('/^' . $dist_str . '\s+/', '', $this->returnOrderBy($sql, $orderByMatch[3])) . ") AS row_number, |
|
554 | - count(*) counter, " . $distinctSQLARRAY[0] . " |
|
555 | - " . $distinctSQLARRAY[1] . " |
|
556 | - group by " . $grpByStr . " |
|
553 | + OVER (ORDER BY ".preg_replace('/^'.$dist_str.'\s+/', '', $this->returnOrderBy($sql, $orderByMatch[3])).") AS row_number, |
|
554 | + count(*) counter, " . $distinctSQLARRAY[0]." |
|
555 | + " . $distinctSQLARRAY[1]." |
|
556 | + group by " . $grpByStr." |
|
557 | 557 | ) AS a |
558 | 558 | WHERE row_number > $start"; |
559 | 559 | } |
560 | 560 | else { |
561 | 561 | $newSQL = "SELECT TOP $count * FROM |
562 | 562 | ( |
563 | - " . $matches[1] . " ROW_NUMBER() |
|
564 | - OVER (ORDER BY " . $this->returnOrderBy($sql, $orderByMatch[3]) . ") AS row_number, |
|
565 | - " . $matches[2] . $orderByMatch[1]. " |
|
563 | + ".$matches[1]." ROW_NUMBER() |
|
564 | + OVER (ORDER BY " . $this->returnOrderBy($sql, $orderByMatch[3]).") AS row_number, |
|
565 | + " . $matches[2].$orderByMatch[1]." |
|
566 | 566 | ) AS a |
567 | 567 | WHERE row_number > $start"; |
568 | 568 | } |
569 | - }else{ |
|
569 | + } else { |
|
570 | 570 | //if there is a distinct clause, form query with rownumber after distinct |
571 | 571 | if ($hasDistinct) { |
572 | 572 | $newSQL = "SELECT TOP $count * FROM |
573 | 573 | ( |
574 | - SELECT ROW_NUMBER() OVER (ORDER BY ".$grpByStr.") AS row_number, count(*) counter, " . $distinctSQLARRAY[0] . " |
|
575 | - " . $distinctSQLARRAY[1] . " |
|
576 | - group by " . $grpByStr . " |
|
574 | + SELECT ROW_NUMBER() OVER (ORDER BY ".$grpByStr.") AS row_number, count(*) counter, ".$distinctSQLARRAY[0]." |
|
575 | + " . $distinctSQLARRAY[1]." |
|
576 | + group by " . $grpByStr." |
|
577 | 577 | ) |
578 | 578 | AS a |
579 | 579 | WHERE row_number > $start"; |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | else { |
582 | 582 | $newSQL = "SELECT TOP $count * FROM |
583 | 583 | ( |
584 | - " . $matches[1] . " ROW_NUMBER() OVER (ORDER BY " . $sqlArray['FROM'][0]['alias'] . ".id) AS row_number, " . $matches[2] . $matches[3]. " |
|
584 | + ".$matches[1]." ROW_NUMBER() OVER (ORDER BY ".$sqlArray['FROM'][0]['alias'].".id) AS row_number, ".$matches[2].$matches[3]." |
|
585 | 585 | ) |
586 | 586 | AS a |
587 | 587 | WHERE row_number > $start"; |
@@ -591,9 +591,9 @@ discard block |
||
591 | 591 | } |
592 | 592 | } |
593 | 593 | |
594 | - $GLOBALS['log']->debug('Limit Query: ' . $newSQL); |
|
595 | - if($execute) { |
|
596 | - $result = $this->query($newSQL, $dieOnError, $msg); |
|
594 | + $GLOBALS['log']->debug('Limit Query: '.$newSQL); |
|
595 | + if ($execute) { |
|
596 | + $result = $this->query($newSQL, $dieOnError, $msg); |
|
597 | 597 | $this->dump_slow_queries($newSQL); |
598 | 598 | return $result; |
599 | 599 | } else { |
@@ -615,15 +615,15 @@ discard block |
||
615 | 615 | private function removePatternFromSQL($p_sql, $strip_beg, $strip_end, $patt = 'patt') |
616 | 616 | { |
617 | 617 | //strip all single quotes out |
618 | - $count = substr_count ( $p_sql, $strip_beg); |
|
618 | + $count = substr_count($p_sql, $strip_beg); |
|
619 | 619 | $increment = 1; |
620 | 620 | if ($strip_beg != $strip_end) |
621 | 621 | $increment = 2; |
622 | 622 | |
623 | - $i=0; |
|
623 | + $i = 0; |
|
624 | 624 | $offset = 0; |
625 | 625 | $strip_array = array(); |
626 | - while ($i<$count && $offset<strlen($p_sql)) { |
|
626 | + while ($i < $count && $offset < strlen($p_sql)) { |
|
627 | 627 | if ($offset > strlen($p_sql)) |
628 | 628 | { |
629 | 629 | break; |
@@ -634,23 +634,23 @@ discard block |
||
634 | 634 | { |
635 | 635 | break; |
636 | 636 | } |
637 | - $sec_sin = strpos($p_sql, $strip_end, $beg_sin+1); |
|
638 | - $strip_array[$patt.$i] = substr($p_sql, $beg_sin, $sec_sin - $beg_sin +1); |
|
637 | + $sec_sin = strpos($p_sql, $strip_end, $beg_sin + 1); |
|
638 | + $strip_array[$patt.$i] = substr($p_sql, $beg_sin, $sec_sin - $beg_sin + 1); |
|
639 | 639 | if ($increment > 1) { |
640 | 640 | //we are in here because beginning and end patterns are not identical, so search for nesting |
641 | - $exists = strpos($strip_array[$patt.$i], $strip_beg ); |
|
642 | - if ($exists>=0) { |
|
643 | - $nested_pos = (strrpos($strip_array[$patt.$i], $strip_beg )); |
|
644 | - $strip_array[$patt.$i] = substr($p_sql,$nested_pos+$beg_sin,$sec_sin - ($nested_pos+$beg_sin)+1); |
|
645 | - $p_sql = substr($p_sql, 0, $nested_pos+$beg_sin) . " ##". $patt.$i."## " . substr($p_sql, $sec_sin+1); |
|
641 | + $exists = strpos($strip_array[$patt.$i], $strip_beg); |
|
642 | + if ($exists >= 0) { |
|
643 | + $nested_pos = (strrpos($strip_array[$patt.$i], $strip_beg)); |
|
644 | + $strip_array[$patt.$i] = substr($p_sql, $nested_pos + $beg_sin, $sec_sin - ($nested_pos + $beg_sin) + 1); |
|
645 | + $p_sql = substr($p_sql, 0, $nested_pos + $beg_sin)." ##".$patt.$i."## ".substr($p_sql, $sec_sin + 1); |
|
646 | 646 | $i = $i + 1; |
647 | 647 | continue; |
648 | 648 | } |
649 | 649 | } |
650 | - $p_len = strlen("##". $patt.$i."##"); |
|
651 | - $p_sql = substr($p_sql, 0, $beg_sin) . " ##". $patt.$i."## " . substr($p_sql, $sec_sin+1); |
|
650 | + $p_len = strlen("##".$patt.$i."##"); |
|
651 | + $p_sql = substr($p_sql, 0, $beg_sin)." ##".$patt.$i."## ".substr($p_sql, $sec_sin + 1); |
|
652 | 652 | //move the marker up |
653 | - $offset = ($sec_sin-($sec_sin-$beg_sin))+$p_len+1; // Adjusting the starting point of the marker |
|
653 | + $offset = ($sec_sin - ($sec_sin - $beg_sin)) + $p_len + 1; // Adjusting the starting point of the marker |
|
654 | 654 | |
655 | 655 | $i = $i + 1; |
656 | 656 | } |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | $pattern_array = array_reverse($pattern_array); |
673 | 673 | |
674 | 674 | foreach ($pattern_array as $key => $replace) { |
675 | - $token = str_replace( " ##".$key."## ", $replace,$token); |
|
675 | + $token = str_replace(" ##".$key."## ", $replace, $token); |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | return $token; |
@@ -688,11 +688,11 @@ discard block |
||
688 | 688 | private function getAliasFromSQL($sql, $alias) |
689 | 689 | { |
690 | 690 | $matches = array(); |
691 | - preg_match('/^(.*SELECT)(.*?FROM.*WHERE)(.*)$/isU',$sql, $matches); |
|
691 | + preg_match('/^(.*SELECT)(.*?FROM.*WHERE)(.*)$/isU', $sql, $matches); |
|
692 | 692 | //parse all single and double quotes out of array |
693 | - $sin_array = $this->removePatternFromSQL($matches[2], "'", "'","sin_"); |
|
693 | + $sin_array = $this->removePatternFromSQL($matches[2], "'", "'", "sin_"); |
|
694 | 694 | $new_sql = array_pop($sin_array); |
695 | - $dub_array = $this->removePatternFromSQL($new_sql, "\"", "\"","dub_"); |
|
695 | + $dub_array = $this->removePatternFromSQL($new_sql, "\"", "\"", "dub_"); |
|
696 | 696 | $new_sql = array_pop($dub_array); |
697 | 697 | |
698 | 698 | //search for parenthesis |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | |
702 | 702 | //all functions should be removed now, so split the array on commas |
703 | 703 | $mstr_sql_array = explode(",", $new_sql); |
704 | - foreach($mstr_sql_array as $token ) { |
|
704 | + foreach ($mstr_sql_array as $token) { |
|
705 | 705 | if (strpos($token, $alias)) { |
706 | 706 | //found token, add back comments |
707 | 707 | $token = $this->addPatternToSQL($token, $paren_array); |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | $found = $found_in_sql; |
740 | 740 | |
741 | 741 | //if still no match found, then we need to parse through the string |
742 | - if (!$found_in_sql){ |
|
742 | + if (!$found_in_sql) { |
|
743 | 743 | //get count of how many times the match exists in string |
744 | 744 | $found_count = substr_count($sql, $orderMatch); |
745 | 745 | $i = 0; |
@@ -748,21 +748,21 @@ discard block |
||
748 | 748 | //loop through string as many times as there is a match |
749 | 749 | while ($found_count > $i) { |
750 | 750 | //get the first match |
751 | - $found_in_sql = strpos($sql, $orderMatch,$first_); |
|
751 | + $found_in_sql = strpos($sql, $orderMatch, $first_); |
|
752 | 752 | //make sure there was a match |
753 | - if($found_in_sql){ |
|
753 | + if ($found_in_sql) { |
|
754 | 754 | //grab the next 2 individual characters |
755 | - $str_plusone = substr($sql,$found_in_sql + $len,1); |
|
756 | - $str_plustwo = substr($sql,$found_in_sql + $len+1,1); |
|
755 | + $str_plusone = substr($sql, $found_in_sql + $len, 1); |
|
756 | + $str_plustwo = substr($sql, $found_in_sql + $len + 1, 1); |
|
757 | 757 | //if one of those characters is a comma, then we have our alias |
758 | - if ($str_plusone === "," || $str_plustwo === ","){ |
|
758 | + if ($str_plusone === "," || $str_plustwo === ",") { |
|
759 | 759 | //keep track of this position |
760 | 760 | $found = $found_in_sql; |
761 | 761 | } |
762 | 762 | } |
763 | 763 | //set the offset and increase the iteration counter |
764 | - $first_ = $found_in_sql+$len; |
|
765 | - $i = $i+1; |
|
764 | + $first_ = $found_in_sql + $len; |
|
765 | + $i = $i + 1; |
|
766 | 766 | } |
767 | 767 | } |
768 | 768 | //return $found, defaults have been set, so if no match was found it will be a negative number |
@@ -794,8 +794,8 @@ discard block |
||
794 | 794 | $firstSpace = strpos($orig_order_match, " "); |
795 | 795 | |
796 | 796 | //split order by into column name and ascending/descending |
797 | - $orderMatch = " " . strtolower(substr($orig_order_match, 0, $firstSpace)); |
|
798 | - $asc_desc = trim(substr($orig_order_match,$firstSpace)); |
|
797 | + $orderMatch = " ".strtolower(substr($orig_order_match, 0, $firstSpace)); |
|
798 | + $asc_desc = trim(substr($orig_order_match, $firstSpace)); |
|
799 | 799 | |
800 | 800 | //look for column name as an alias in sql string |
801 | 801 | $found_in_sql = $this->findColumnByAlias($sql, $orderMatch); |
@@ -806,18 +806,18 @@ discard block |
||
806 | 806 | $colMatchPos = strpos($sql, $orderMatch); |
807 | 807 | if ($colMatchPos !== false) { |
808 | 808 | //grab sub string up to column name |
809 | - $containsColStr = substr($sql,0, $colMatchPos); |
|
809 | + $containsColStr = substr($sql, 0, $colMatchPos); |
|
810 | 810 | //get position of first space, so we can grab table name |
811 | 811 | $lastSpacePos = strrpos($containsColStr, " "); |
812 | 812 | //use positions of column name, space before name, and length of column to find the correct column name |
813 | - $col_name = substr($sql, $lastSpacePos, $colMatchPos-$lastSpacePos+strlen($orderMatch)); |
|
813 | + $col_name = substr($sql, $lastSpacePos, $colMatchPos - $lastSpacePos + strlen($orderMatch)); |
|
814 | 814 | //bug 25485. When sorting by a custom field in Account List and then pressing NEXT >, system gives an error |
815 | 815 | $containsCommaPos = strpos($col_name, ","); |
816 | - if($containsCommaPos !== false) { |
|
817 | - $col_name = substr($col_name, $containsCommaPos+1); |
|
816 | + if ($containsCommaPos !== false) { |
|
817 | + $col_name = substr($col_name, $containsCommaPos + 1); |
|
818 | 818 | } |
819 | 819 | //add the "asc/desc" order back |
820 | - $col_name = $col_name. " ". $asc_desc; |
|
820 | + $col_name = $col_name." ".$asc_desc; |
|
821 | 821 | |
822 | 822 | //return column name |
823 | 823 | return $col_name; |
@@ -831,22 +831,22 @@ discard block |
||
831 | 831 | //grab string up to the aliased column |
832 | 832 | $GLOBALS['log']->debug("order by found, process sql string"); |
833 | 833 | |
834 | - $psql = (trim($this->getAliasFromSQL($sql, $orderMatch ))); |
|
834 | + $psql = (trim($this->getAliasFromSQL($sql, $orderMatch))); |
|
835 | 835 | if (empty($psql)) |
836 | 836 | $psql = trim(substr($sql, 0, $found_in_sql)); |
837 | 837 | |
838 | 838 | //grab the last comma before the alias |
839 | - preg_match('/\s+' . trim($orderMatch). '/', $psql, $match, PREG_OFFSET_CAPTURE); |
|
839 | + preg_match('/\s+'.trim($orderMatch).'/', $psql, $match, PREG_OFFSET_CAPTURE); |
|
840 | 840 | $comma_pos = $match[0][1]; |
841 | 841 | //substring between the comma and the alias to find the joined_table alias and column name |
842 | - $col_name = substr($psql,0, $comma_pos); |
|
842 | + $col_name = substr($psql, 0, $comma_pos); |
|
843 | 843 | |
844 | 844 | //make sure the string does not have an end parenthesis |
845 | 845 | //and is not part of a function (i.e. "ISNULL(leads.last_name,'') as name" ) |
846 | 846 | //this is especially true for unified search from home screen |
847 | 847 | |
848 | 848 | $alias_beg_pos = 0; |
849 | - if(strpos($psql, " as ")) |
|
849 | + if (strpos($psql, " as ")) |
|
850 | 850 | $alias_beg_pos = strpos($psql, " as "); |
851 | 851 | |
852 | 852 | // Bug # 44923 - This breaks the query and does not properly filter isnull |
@@ -855,13 +855,13 @@ discard block |
||
855 | 855 | $alias_beg_pos = strpos($psql, " "); */ |
856 | 856 | |
857 | 857 | if ($alias_beg_pos > 0) { |
858 | - $col_name = substr($psql,0, $alias_beg_pos ); |
|
858 | + $col_name = substr($psql, 0, $alias_beg_pos); |
|
859 | 859 | } |
860 | 860 | //add the "asc/desc" order back |
861 | - $col_name = $col_name. " ". $asc_desc; |
|
861 | + $col_name = $col_name." ".$asc_desc; |
|
862 | 862 | |
863 | 863 | //pass in new order by |
864 | - $GLOBALS['log']->debug("order by being returned is " . $col_name); |
|
864 | + $GLOBALS['log']->debug("order by being returned is ".$col_name); |
|
865 | 865 | return $col_name; |
866 | 866 | } |
867 | 867 | } |
@@ -877,12 +877,12 @@ discard block |
||
877 | 877 | { |
878 | 878 | |
879 | 879 | global $beanList, $beanFiles; |
880 | - $GLOBALS['log']->debug("Module being processed is " . $module_str); |
|
880 | + $GLOBALS['log']->debug("Module being processed is ".$module_str); |
|
881 | 881 | //get the right module files |
882 | 882 | //the module string exists in bean list, then process bean for correct table name |
883 | 883 | //note that we exempt the reports module from this, as queries from reporting module should be parsed for |
884 | 884 | //correct table name. |
885 | - if (($module_str != 'Reports' && $module_str != 'SavedReport') && isset($beanList[$module_str]) && isset($beanFiles[$beanList[$module_str]])){ |
|
885 | + if (($module_str != 'Reports' && $module_str != 'SavedReport') && isset($beanList[$module_str]) && isset($beanFiles[$beanList[$module_str]])) { |
|
886 | 886 | //if the class is not already loaded, then load files |
887 | 887 | if (!class_exists($beanList[$module_str])) |
888 | 888 | require_once($beanFiles[$beanList[$module_str]]); |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | //make sure table name is not just a blank space, or empty |
895 | 895 | $tbl_name = trim($tbl_name); |
896 | 896 | |
897 | - if(empty($tbl_name)){ |
|
897 | + if (empty($tbl_name)) { |
|
898 | 898 | $GLOBALS['log']->debug("Could not find table name for module $module_str. "); |
899 | 899 | $tbl_name = $module_str; |
900 | 900 | } |
@@ -911,20 +911,20 @@ discard block |
||
911 | 911 | $sql = str_replace(array("\n", "\r"), " ", $sql); |
912 | 912 | |
913 | 913 | //look for the location of the "from" in sql string |
914 | - $fromLoc = strpos($sql," from " ); |
|
915 | - if ($fromLoc>0){ |
|
914 | + $fromLoc = strpos($sql, " from "); |
|
915 | + if ($fromLoc > 0) { |
|
916 | 916 | //found from, substring from the " FROM " string in sql to end |
917 | - $tableEnd = substr($sql, $fromLoc+6); |
|
917 | + $tableEnd = substr($sql, $fromLoc + 6); |
|
918 | 918 | //We know that tablename will be next parameter after from, so |
919 | 919 | //grab the next space after table name. |
920 | 920 | // MFH BUG #14009: Also check to see if there are any carriage returns before the next space so that we don't grab any arbitrary joins or other tables. |
921 | - $carriage_ret = strpos($tableEnd,"\n"); |
|
922 | - $next_space = strpos($tableEnd," " ); |
|
921 | + $carriage_ret = strpos($tableEnd, "\n"); |
|
922 | + $next_space = strpos($tableEnd, " "); |
|
923 | 923 | if ($carriage_ret < $next_space) |
924 | 924 | $next_space = $carriage_ret; |
925 | 925 | if ($next_space > 0) { |
926 | - $tbl_name= substr($tableEnd,0, $next_space); |
|
927 | - if(empty($tbl_name)){ |
|
926 | + $tbl_name = substr($tableEnd, 0, $next_space); |
|
927 | + if (empty($tbl_name)) { |
|
928 | 928 | $GLOBALS['log']->debug("Could not find table name sql either, return $module_str. "); |
929 | 929 | $tbl_name = $module_str; |
930 | 930 | } |
@@ -932,11 +932,11 @@ discard block |
||
932 | 932 | |
933 | 933 | //grab the table, to see if it is aliased |
934 | 934 | $aliasTableEnd = trim(substr($tableEnd, $next_space)); |
935 | - $alias_space = strpos ($aliasTableEnd, " " ); |
|
936 | - if ($alias_space > 0){ |
|
937 | - $alias_tbl_name= substr($aliasTableEnd,0, $alias_space); |
|
935 | + $alias_space = strpos($aliasTableEnd, " "); |
|
936 | + if ($alias_space > 0) { |
|
937 | + $alias_tbl_name = substr($aliasTableEnd, 0, $alias_space); |
|
938 | 938 | strtolower($alias_tbl_name); |
939 | - if(empty($alias_tbl_name) |
|
939 | + if (empty($alias_tbl_name) |
|
940 | 940 | || $alias_tbl_name == "where" |
941 | 941 | || $alias_tbl_name == "inner" |
942 | 942 | || $alias_tbl_name == "left" |
@@ -948,9 +948,9 @@ discard block |
||
948 | 948 | elseif ($alias_tbl_name == "as") { |
949 | 949 | //the next word is the table name |
950 | 950 | $aliasTableEnd = trim(substr($aliasTableEnd, $alias_space)); |
951 | - $alias_space = strpos ($aliasTableEnd, " " ); |
|
951 | + $alias_space = strpos($aliasTableEnd, " "); |
|
952 | 952 | if ($alias_space > 0) { |
953 | - $alias_tbl_name= trim(substr($aliasTableEnd,0, $alias_space)); |
|
953 | + $alias_tbl_name = trim(substr($aliasTableEnd, 0, $alias_space)); |
|
954 | 954 | if (!empty($alias_tbl_name)) |
955 | 955 | $tbl_name = $alias_tbl_name; |
956 | 956 | } |
@@ -975,7 +975,7 @@ discard block |
||
975 | 975 | { |
976 | 976 | $field_array = array(); |
977 | 977 | |
978 | - if(! isset($result) || empty($result)) |
|
978 | + if (!isset($result) || empty($result)) |
|
979 | 979 | return 0; |
980 | 980 | |
981 | 981 | $i = 0; |
@@ -983,7 +983,7 @@ discard block |
||
983 | 983 | $meta = mssql_fetch_field($result, $i); |
984 | 984 | if (!$meta) |
985 | 985 | return 0; |
986 | - if($make_lower_case==true) |
|
986 | + if ($make_lower_case == true) |
|
987 | 987 | $meta->name = strtolower($meta->name); |
988 | 988 | |
989 | 989 | $field_array[] = $meta->name; |
@@ -1012,11 +1012,11 @@ discard block |
||
1012 | 1012 | $row = mssql_fetch_assoc($result); |
1013 | 1013 | //MSSQL returns a space " " when a varchar column is empty ("") and not null. |
1014 | 1014 | //We need to iterate through the returned row array and strip empty spaces |
1015 | - if(!empty($row)){ |
|
1016 | - foreach($row as $key => $column) { |
|
1015 | + if (!empty($row)) { |
|
1016 | + foreach ($row as $key => $column) { |
|
1017 | 1017 | //notice we only strip if one space is returned. we do not want to strip |
1018 | 1018 | //strings with intentional spaces (" foo ") |
1019 | - if (!empty($column) && $column ==" ") { |
|
1019 | + if (!empty($column) && $column == " ") { |
|
1020 | 1020 | $row[$key] = ''; |
1021 | 1021 | } |
1022 | 1022 | } |
@@ -1029,10 +1029,10 @@ discard block |
||
1029 | 1029 | */ |
1030 | 1030 | public function quote($string) |
1031 | 1031 | { |
1032 | - if(is_array($string)) { |
|
1032 | + if (is_array($string)) { |
|
1033 | 1033 | return $this->arrayQuote($string); |
1034 | 1034 | } |
1035 | - return str_replace("'","''", $this->quoteInternal($string)); |
|
1035 | + return str_replace("'", "''", $this->quoteInternal($string)); |
|
1036 | 1036 | } |
1037 | 1037 | |
1038 | 1038 | /** |
@@ -1070,7 +1070,7 @@ discard block |
||
1070 | 1070 | if (!empty($r)) { |
1071 | 1071 | while ($a = $this->fetchByAssoc($r)) { |
1072 | 1072 | $row = array_values($a); |
1073 | - $tables[]=$row[0]; |
|
1073 | + $tables[] = $row[0]; |
|
1074 | 1074 | } |
1075 | 1075 | return $tables; |
1076 | 1076 | } |
@@ -1085,7 +1085,7 @@ discard block |
||
1085 | 1085 | { |
1086 | 1086 | $GLOBALS['log']->debug('MSSQL fetching table list'); |
1087 | 1087 | |
1088 | - if($this->getDatabase()) { |
|
1088 | + if ($this->getDatabase()) { |
|
1089 | 1089 | $tables = array(); |
1090 | 1090 | $r = $this->query('SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES'); |
1091 | 1091 | if (is_resource($r)) { |
@@ -1109,7 +1109,7 @@ discard block |
||
1109 | 1109 | { |
1110 | 1110 | $GLOBALS['log']->debug('MSSQL about to wakeup FTS'); |
1111 | 1111 | |
1112 | - if($this->getDatabase()) { |
|
1112 | + if ($this->getDatabase()) { |
|
1113 | 1113 | //create wakeup catalog |
1114 | 1114 | $FTSqry[] = "if not exists( select * from sys.fulltext_catalogs where name ='wakeup_catalog' ) |
1115 | 1115 | CREATE FULLTEXT CATALOG wakeup_catalog |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | $FTSqry[] = 'ALTER FULLTEXT INDEX ON fts_wakeup START FULL POPULATION'; |
1150 | 1150 | $FTSqry[] = 'ALTER FULLTEXT INDEX ON fts_wakeup SET CHANGE_TRACKING AUTO'; |
1151 | 1151 | |
1152 | - foreach($FTSqry as $q){ |
|
1152 | + foreach ($FTSqry as $q) { |
|
1153 | 1153 | sleep(3); |
1154 | 1154 | $this->query($q); |
1155 | 1155 | } |
@@ -1172,12 +1172,12 @@ discard block |
||
1172 | 1172 | { |
1173 | 1173 | // convert the parameters array into a comma delimited string |
1174 | 1174 | if (!empty($additional_parameters)) { |
1175 | - $additional_parameters_string = ','.implode(',',$additional_parameters); |
|
1175 | + $additional_parameters_string = ','.implode(',', $additional_parameters); |
|
1176 | 1176 | } else { |
1177 | 1177 | $additional_parameters_string = ''; |
1178 | 1178 | } |
1179 | 1179 | $all_parameters = $additional_parameters; |
1180 | - if(is_array($string)) { |
|
1180 | + if (is_array($string)) { |
|
1181 | 1181 | $all_parameters = array_merge($string, $all_parameters); |
1182 | 1182 | } elseif (!is_null($string)) { |
1183 | 1183 | array_unshift($all_parameters, $string); |
@@ -1189,22 +1189,22 @@ discard block |
||
1189 | 1189 | case 'left': |
1190 | 1190 | return "LEFT($string$additional_parameters_string)"; |
1191 | 1191 | case 'date_format': |
1192 | - if(!empty($additional_parameters[0]) && $additional_parameters[0][0] == "'") { |
|
1192 | + if (!empty($additional_parameters[0]) && $additional_parameters[0][0] == "'") { |
|
1193 | 1193 | $additional_parameters[0] = trim($additional_parameters[0], "'"); |
1194 | 1194 | } |
1195 | - if(!empty($additional_parameters) && isset($this->date_formats[$additional_parameters[0]])) { |
|
1195 | + if (!empty($additional_parameters) && isset($this->date_formats[$additional_parameters[0]])) { |
|
1196 | 1196 | $len = $this->date_formats[$additional_parameters[0]]; |
1197 | - return "LEFT(CONVERT(varchar($len),". $string . ",120),$len)"; |
|
1197 | + return "LEFT(CONVERT(varchar($len),".$string.",120),$len)"; |
|
1198 | 1198 | } else { |
1199 | - return "LEFT(CONVERT(varchar(10),". $string . ",120),10)"; |
|
1199 | + return "LEFT(CONVERT(varchar(10),".$string.",120),10)"; |
|
1200 | 1200 | } |
1201 | 1201 | case 'ifnull': |
1202 | - if(empty($additional_parameters_string)) { |
|
1202 | + if (empty($additional_parameters_string)) { |
|
1203 | 1203 | $additional_parameters_string = ",''"; |
1204 | 1204 | } |
1205 | 1205 | return "ISNULL($string$additional_parameters_string)"; |
1206 | 1206 | case 'concat': |
1207 | - return implode("+",$all_parameters); |
|
1207 | + return implode("+", $all_parameters); |
|
1208 | 1208 | case 'text2char': |
1209 | 1209 | return "CAST($string AS varchar(8000))"; |
1210 | 1210 | case 'quarter': |
@@ -1220,7 +1220,7 @@ discard block |
||
1220 | 1220 | case 'add_tz_offset' : |
1221 | 1221 | $getUserUTCOffset = $GLOBALS['timedate']->getUserUTCOffset(); |
1222 | 1222 | $operation = $getUserUTCOffset < 0 ? '-' : '+'; |
1223 | - return 'DATEADD(minute, ' . $operation . abs($getUserUTCOffset) . ', ' . $string. ')'; |
|
1223 | + return 'DATEADD(minute, '.$operation.abs($getUserUTCOffset).', '.$string.')'; |
|
1224 | 1224 | case 'avg': |
1225 | 1225 | return "avg($string)"; |
1226 | 1226 | } |
@@ -1233,9 +1233,9 @@ discard block |
||
1233 | 1233 | */ |
1234 | 1234 | public function fromConvert($string, $type) |
1235 | 1235 | { |
1236 | - switch($type) { |
|
1236 | + switch ($type) { |
|
1237 | 1237 | case 'datetimecombo': |
1238 | - case 'datetime': return substr($string, 0,19); |
|
1238 | + case 'datetime': return substr($string, 0, 19); |
|
1239 | 1239 | case 'date': return substr($string, 0, 10); |
1240 | 1240 | case 'time': return substr($string, 11); |
1241 | 1241 | } |
@@ -1264,8 +1264,8 @@ discard block |
||
1264 | 1264 | public function isTextType($type) |
1265 | 1265 | { |
1266 | 1266 | $type = strtolower($type); |
1267 | - if(!isset($this->type_map[$type])) return false; |
|
1268 | - return in_array($this->type_map[$type], array('ntext','text','image', 'nvarchar(max)')); |
|
1267 | + if (!isset($this->type_map[$type])) return false; |
|
1268 | + return in_array($this->type_map[$type], array('ntext', 'text', 'image', 'nvarchar(max)')); |
|
1269 | 1269 | } |
1270 | 1270 | |
1271 | 1271 | /** |
@@ -1275,13 +1275,13 @@ discard block |
||
1275 | 1275 | public function emptyValue($type) |
1276 | 1276 | { |
1277 | 1277 | $ctype = $this->getColumnType($type); |
1278 | - if($ctype == "datetime") { |
|
1278 | + if ($ctype == "datetime") { |
|
1279 | 1279 | return $this->convert($this->quoted("1970-01-01 00:00:00"), "datetime"); |
1280 | 1280 | } |
1281 | - if($ctype == "date") { |
|
1281 | + if ($ctype == "date") { |
|
1282 | 1282 | return $this->convert($this->quoted("1970-01-01"), "datetime"); |
1283 | 1283 | } |
1284 | - if($ctype == "time") { |
|
1284 | + if ($ctype == "time") { |
|
1285 | 1285 | return $this->convert($this->quoted("00:00:00"), "time"); |
1286 | 1286 | } |
1287 | 1287 | return parent::emptyValue($type); |
@@ -1304,21 +1304,21 @@ discard block |
||
1304 | 1304 | */ |
1305 | 1305 | protected function alterSQLRep($action, array $def, $ignoreRequired, $tablename) |
1306 | 1306 | { |
1307 | - switch($action){ |
|
1307 | + switch ($action) { |
|
1308 | 1308 | case 'add': |
1309 | - $f_def=$this->oneColumnSQLRep($def, $ignoreRequired,$tablename,false); |
|
1310 | - return "ADD " . $f_def; |
|
1309 | + $f_def = $this->oneColumnSQLRep($def, $ignoreRequired, $tablename, false); |
|
1310 | + return "ADD ".$f_def; |
|
1311 | 1311 | break; |
1312 | 1312 | case 'drop': |
1313 | - return "DROP COLUMN " . $def['name']; |
|
1313 | + return "DROP COLUMN ".$def['name']; |
|
1314 | 1314 | break; |
1315 | 1315 | case 'modify': |
1316 | 1316 | //You cannot specify a default value for a column for MSSQL |
1317 | - $f_def = $this->oneColumnSQLRep($def, $ignoreRequired,$tablename, true); |
|
1317 | + $f_def = $this->oneColumnSQLRep($def, $ignoreRequired, $tablename, true); |
|
1318 | 1318 | $f_stmt = "ALTER COLUMN ".$f_def['name'].' '.$f_def['colType'].' '. |
1319 | 1319 | $f_def['required'].' '.$f_def['auto_increment']."\n"; |
1320 | - if (!empty( $f_def['default'])) |
|
1321 | - $f_stmt .= " ALTER TABLE " . $tablename . " ADD ". $f_def['default'] . " FOR " . $def['name']; |
|
1320 | + if (!empty($f_def['default'])) |
|
1321 | + $f_stmt .= " ALTER TABLE ".$tablename." ADD ".$f_def['default']." FOR ".$def['name']; |
|
1322 | 1322 | return $f_stmt; |
1323 | 1323 | break; |
1324 | 1324 | default: |
@@ -1334,7 +1334,7 @@ discard block |
||
1334 | 1334 | */ |
1335 | 1335 | protected function changeColumnSQL($tablename, $fieldDefs, $action, $ignoreRequired = false) |
1336 | 1336 | { |
1337 | - $sql=$sql2=''; |
|
1337 | + $sql = $sql2 = ''; |
|
1338 | 1338 | $constraints = $this->get_field_default_constraint_name($tablename); |
1339 | 1339 | $columns = array(); |
1340 | 1340 | if ($this->isFieldArray($fieldDefs)) { |
@@ -1343,41 +1343,41 @@ discard block |
||
1343 | 1343 | //if the column is being modified drop the default value |
1344 | 1344 | //constraint if it exists. alterSQLRep will add the constraint back |
1345 | 1345 | if (!empty($constraints[$def['name']])) { |
1346 | - $sql.=" ALTER TABLE " . $tablename . " DROP CONSTRAINT " . $constraints[$def['name']]; |
|
1346 | + $sql .= " ALTER TABLE ".$tablename." DROP CONSTRAINT ".$constraints[$def['name']]; |
|
1347 | 1347 | } |
1348 | 1348 | //check to see if we need to drop related indexes before the alter |
1349 | 1349 | $indices = $this->get_indices($tablename); |
1350 | - foreach ( $indices as $index ) { |
|
1351 | - if ( in_array($def['name'],$index['fields']) ) { |
|
1352 | - $sql .= ' ' . $this->add_drop_constraint($tablename,$index,true).' '; |
|
1353 | - $sql2 .= ' ' . $this->add_drop_constraint($tablename,$index,false).' '; |
|
1350 | + foreach ($indices as $index) { |
|
1351 | + if (in_array($def['name'], $index['fields'])) { |
|
1352 | + $sql .= ' '.$this->add_drop_constraint($tablename, $index, true).' '; |
|
1353 | + $sql2 .= ' '.$this->add_drop_constraint($tablename, $index, false).' '; |
|
1354 | 1354 | } |
1355 | 1355 | } |
1356 | 1356 | |
1357 | - $columns[] = $this->alterSQLRep($action, $def, $ignoreRequired,$tablename); |
|
1357 | + $columns[] = $this->alterSQLRep($action, $def, $ignoreRequired, $tablename); |
|
1358 | 1358 | } |
1359 | 1359 | } |
1360 | 1360 | else { |
1361 | 1361 | //if the column is being modified drop the default value |
1362 | 1362 | //constraint if it exists. alterSQLRep will add the constraint back |
1363 | 1363 | if (!empty($constraints[$fieldDefs['name']])) { |
1364 | - $sql.=" ALTER TABLE " . $tablename . " DROP CONSTRAINT " . $constraints[$fieldDefs['name']]; |
|
1364 | + $sql .= " ALTER TABLE ".$tablename." DROP CONSTRAINT ".$constraints[$fieldDefs['name']]; |
|
1365 | 1365 | } |
1366 | 1366 | //check to see if we need to drop related indexes before the alter |
1367 | 1367 | $indices = $this->get_indices($tablename); |
1368 | - foreach ( $indices as $index ) { |
|
1369 | - if ( in_array($fieldDefs['name'],$index['fields']) ) { |
|
1370 | - $sql .= ' ' . $this->add_drop_constraint($tablename,$index,true).' '; |
|
1371 | - $sql2 .= ' ' . $this->add_drop_constraint($tablename,$index,false).' '; |
|
1368 | + foreach ($indices as $index) { |
|
1369 | + if (in_array($fieldDefs['name'], $index['fields'])) { |
|
1370 | + $sql .= ' '.$this->add_drop_constraint($tablename, $index, true).' '; |
|
1371 | + $sql2 .= ' '.$this->add_drop_constraint($tablename, $index, false).' '; |
|
1372 | 1372 | } |
1373 | 1373 | } |
1374 | 1374 | |
1375 | 1375 | |
1376 | - $columns[] = $this->alterSQLRep($action, $fieldDefs, $ignoreRequired,$tablename); |
|
1376 | + $columns[] = $this->alterSQLRep($action, $fieldDefs, $ignoreRequired, $tablename); |
|
1377 | 1377 | } |
1378 | 1378 | |
1379 | 1379 | $columns = implode(", ", $columns); |
1380 | - $sql .= " ALTER TABLE $tablename $columns " . $sql2; |
|
1380 | + $sql .= " ALTER TABLE $tablename $columns ".$sql2; |
|
1381 | 1381 | |
1382 | 1382 | return $sql; |
1383 | 1383 | } |
@@ -1392,7 +1392,7 @@ discard block |
||
1392 | 1392 | */ |
1393 | 1393 | public function setAutoIncrementStart($table, $field_name, $start_value) |
1394 | 1394 | { |
1395 | - if($start_value > 1) |
|
1395 | + if ($start_value > 1) |
|
1396 | 1396 | $start_value -= 1; |
1397 | 1397 | $this->query("DBCC CHECKIDENT ('$table', RESEED, $start_value) WITH NO_INFOMSGS"); |
1398 | 1398 | return true; |
@@ -1427,11 +1427,11 @@ discard block |
||
1427 | 1427 | $result = $this->query($query); |
1428 | 1428 | |
1429 | 1429 | $indices = array(); |
1430 | - while (($row=$this->fetchByAssoc($result)) != null) { |
|
1430 | + while (($row = $this->fetchByAssoc($result)) != null) { |
|
1431 | 1431 | $index_type = 'index'; |
1432 | 1432 | if ($row['is_primary_key'] == '1') |
1433 | 1433 | $index_type = 'primary'; |
1434 | - elseif ($row['is_unique'] == 1 ) |
|
1434 | + elseif ($row['is_unique'] == 1) |
|
1435 | 1435 | $index_type = 'unique'; |
1436 | 1436 | $name = strtolower($row['index_name']); |
1437 | 1437 | $indices[$name]['name'] = $name; |
@@ -1450,36 +1450,36 @@ discard block |
||
1450 | 1450 | $result = $this->query("sp_columns $tablename"); |
1451 | 1451 | |
1452 | 1452 | $columns = array(); |
1453 | - while (($row=$this->fetchByAssoc($result)) !=null) { |
|
1453 | + while (($row = $this->fetchByAssoc($result)) != null) { |
|
1454 | 1454 | $column_name = strtolower($row['COLUMN_NAME']); |
1455 | - $columns[$column_name]['name']=$column_name; |
|
1456 | - $columns[$column_name]['type']=strtolower($row['TYPE_NAME']); |
|
1457 | - if ( $row['TYPE_NAME'] == 'decimal' ) { |
|
1458 | - $columns[$column_name]['len']=strtolower($row['PRECISION']); |
|
1459 | - $columns[$column_name]['len'].=','.strtolower($row['SCALE']); |
|
1455 | + $columns[$column_name]['name'] = $column_name; |
|
1456 | + $columns[$column_name]['type'] = strtolower($row['TYPE_NAME']); |
|
1457 | + if ($row['TYPE_NAME'] == 'decimal') { |
|
1458 | + $columns[$column_name]['len'] = strtolower($row['PRECISION']); |
|
1459 | + $columns[$column_name]['len'] .= ','.strtolower($row['SCALE']); |
|
1460 | 1460 | } |
1461 | - elseif ( in_array($row['TYPE_NAME'],array('nchar','nvarchar')) ) |
|
1462 | - $columns[$column_name]['len']=strtolower($row['PRECISION']); |
|
1463 | - elseif ( !in_array($row['TYPE_NAME'],array('datetime','text')) ) |
|
1464 | - $columns[$column_name]['len']=strtolower($row['LENGTH']); |
|
1465 | - if ( stristr($row['TYPE_NAME'],'identity') ) { |
|
1461 | + elseif (in_array($row['TYPE_NAME'], array('nchar', 'nvarchar'))) |
|
1462 | + $columns[$column_name]['len'] = strtolower($row['PRECISION']); |
|
1463 | + elseif (!in_array($row['TYPE_NAME'], array('datetime', 'text'))) |
|
1464 | + $columns[$column_name]['len'] = strtolower($row['LENGTH']); |
|
1465 | + if (stristr($row['TYPE_NAME'], 'identity')) { |
|
1466 | 1466 | $columns[$column_name]['auto_increment'] = '1'; |
1467 | - $columns[$column_name]['type']=str_replace(' identity','',strtolower($row['TYPE_NAME'])); |
|
1467 | + $columns[$column_name]['type'] = str_replace(' identity', '', strtolower($row['TYPE_NAME'])); |
|
1468 | 1468 | } |
1469 | 1469 | |
1470 | - if (!empty($row['IS_NULLABLE']) && $row['IS_NULLABLE'] == 'NO' && (empty($row['KEY']) || !stristr($row['KEY'],'PRI'))) |
|
1470 | + if (!empty($row['IS_NULLABLE']) && $row['IS_NULLABLE'] == 'NO' && (empty($row['KEY']) || !stristr($row['KEY'], 'PRI'))) |
|
1471 | 1471 | $columns[strtolower($row['COLUMN_NAME'])]['required'] = 'true'; |
1472 | 1472 | |
1473 | 1473 | $column_def = 1; |
1474 | - if ( strtolower($tablename) == 'relationships' ) { |
|
1474 | + if (strtolower($tablename) == 'relationships') { |
|
1475 | 1475 | $column_def = $this->getOne("select cdefault from syscolumns where id = object_id('relationships') and name = '$column_name'"); |
1476 | 1476 | } |
1477 | - if ( $column_def != 0 && ($row['COLUMN_DEF'] != null)) { // NOTE Not using !empty as an empty string may be a viable default value. |
|
1477 | + if ($column_def != 0 && ($row['COLUMN_DEF'] != null)) { // NOTE Not using !empty as an empty string may be a viable default value. |
|
1478 | 1478 | $matches = array(); |
1479 | - $row['COLUMN_DEF'] = html_entity_decode($row['COLUMN_DEF'],ENT_QUOTES); |
|
1480 | - if ( preg_match('/\([\(|\'](.*)[\)|\']\)/i',$row['COLUMN_DEF'],$matches) ) |
|
1479 | + $row['COLUMN_DEF'] = html_entity_decode($row['COLUMN_DEF'], ENT_QUOTES); |
|
1480 | + if (preg_match('/\([\(|\'](.*)[\)|\']\)/i', $row['COLUMN_DEF'], $matches)) |
|
1481 | 1481 | $columns[$column_name]['default'] = $matches[1]; |
1482 | - elseif ( preg_match('/\(N\'(.*)\'\)/i',$row['COLUMN_DEF'],$matches) ) |
|
1482 | + elseif (preg_match('/\(N\'(.*)\'\)/i', $row['COLUMN_DEF'], $matches)) |
|
1483 | 1483 | $columns[$column_name]['default'] = $matches[1]; |
1484 | 1484 | else |
1485 | 1485 | $columns[$column_name]['default'] = $row['COLUMN_DEF']; |
@@ -1494,7 +1494,7 @@ discard block |
||
1494 | 1494 | */ |
1495 | 1495 | protected function ftsCatalogName() |
1496 | 1496 | { |
1497 | - if(isset($this->connectOptions['db_name'])) { |
|
1497 | + if (isset($this->connectOptions['db_name'])) { |
|
1498 | 1498 | return $this->connectOptions['db_name']."_fts_catalog"; |
1499 | 1499 | } |
1500 | 1500 | return 'sugar_fts_catalog'; |
@@ -1506,11 +1506,11 @@ discard block |
||
1506 | 1506 | public function add_drop_constraint($table, $definition, $drop = false) |
1507 | 1507 | { |
1508 | 1508 | $type = $definition['type']; |
1509 | - $fields = is_array($definition['fields'])?implode(',',$definition['fields']):$definition['fields']; |
|
1509 | + $fields = is_array($definition['fields']) ? implode(',', $definition['fields']) : $definition['fields']; |
|
1510 | 1510 | $name = $definition['name']; |
1511 | 1511 | $sql = ''; |
1512 | 1512 | |
1513 | - switch ($type){ |
|
1513 | + switch ($type) { |
|
1514 | 1514 | // generic indices |
1515 | 1515 | case 'index': |
1516 | 1516 | case 'alternate_key': |
@@ -1548,13 +1548,13 @@ discard block |
||
1548 | 1548 | if ($this->full_text_indexing_enabled() && $drop) { |
1549 | 1549 | $sql = "DROP FULLTEXT INDEX ON {$table}"; |
1550 | 1550 | } elseif ($this->full_text_indexing_enabled()) { |
1551 | - $catalog_name=$this->ftsCatalogName(); |
|
1552 | - if ( isset($definition['catalog_name']) && $definition['catalog_name'] != 'default') |
|
1551 | + $catalog_name = $this->ftsCatalogName(); |
|
1552 | + if (isset($definition['catalog_name']) && $definition['catalog_name'] != 'default') |
|
1553 | 1553 | $catalog_name = $definition['catalog_name']; |
1554 | 1554 | |
1555 | 1555 | $language = "Language 1033"; |
1556 | 1556 | if (isset($definition['language']) && !empty($definition['language'])) |
1557 | - $language = "Language " . $definition['language']; |
|
1557 | + $language = "Language ".$definition['language']; |
|
1558 | 1558 | |
1559 | 1559 | $key_index = $definition['key_index']; |
1560 | 1560 | |
@@ -1562,7 +1562,7 @@ discard block |
||
1562 | 1562 | if (isset($definition['change_tracking']) && !empty($definition['change_tracking'])) |
1563 | 1563 | $change_tracking = $definition['change_tracking']; |
1564 | 1564 | |
1565 | - $sql = " CREATE FULLTEXT INDEX ON $table ($fields $language) KEY INDEX $key_index ON $catalog_name WITH CHANGE_TRACKING $change_tracking" ; |
|
1565 | + $sql = " CREATE FULLTEXT INDEX ON $table ($fields $language) KEY INDEX $key_index ON $catalog_name WITH CHANGE_TRACKING $change_tracking"; |
|
1566 | 1566 | } |
1567 | 1567 | break; |
1568 | 1568 | } |
@@ -1586,11 +1586,11 @@ discard block |
||
1586 | 1586 | protected function full_text_indexing_enabled($dbname = null) |
1587 | 1587 | { |
1588 | 1588 | // check to see if we already have install setting in session |
1589 | - if(!isset($_SESSION['IsFulltextInstalled'])) |
|
1589 | + if (!isset($_SESSION['IsFulltextInstalled'])) |
|
1590 | 1590 | $_SESSION['IsFulltextInstalled'] = $this->full_text_indexing_installed(); |
1591 | 1591 | |
1592 | 1592 | // check to see if FTS Indexing service is installed |
1593 | - if(empty($_SESSION['IsFulltextInstalled'])) |
|
1593 | + if (empty($_SESSION['IsFulltextInstalled'])) |
|
1594 | 1594 | return false; |
1595 | 1595 | |
1596 | 1596 | // grab the dbname if it was not passed through |
@@ -1640,7 +1640,7 @@ discard block |
||
1640 | 1640 | { |
1641 | 1641 | static $results = array(); |
1642 | 1642 | |
1643 | - if ( empty($column) && isset($results[$table]) ) |
|
1643 | + if (empty($column) && isset($results[$table])) |
|
1644 | 1644 | return $results[$table]; |
1645 | 1645 | |
1646 | 1646 | $query = <<<EOQ |
@@ -1654,17 +1654,17 @@ discard block |
||
1654 | 1654 | on s.schema_id = o.schema_id |
1655 | 1655 | where o.name = '$table' |
1656 | 1656 | EOQ; |
1657 | - if ( !empty($column) ) |
|
1657 | + if (!empty($column)) |
|
1658 | 1658 | $query .= " and c.name = '$column'"; |
1659 | 1659 | $res = $this->query($query); |
1660 | - if ( !empty($column) ) { |
|
1660 | + if (!empty($column)) { |
|
1661 | 1661 | $row = $this->fetchByAssoc($res); |
1662 | 1662 | if (!empty($row)) |
1663 | 1663 | return $row['ctrt']; |
1664 | 1664 | } |
1665 | 1665 | else { |
1666 | 1666 | $returnResult = array(); |
1667 | - while ( $row = $this->fetchByAssoc($res) ) |
|
1667 | + while ($row = $this->fetchByAssoc($res)) |
|
1668 | 1668 | $returnResult[$row['dtrt']] = $row['ctrt']; |
1669 | 1669 | $results[$table] = $returnResult; |
1670 | 1670 | return $returnResult; |
@@ -1678,14 +1678,14 @@ discard block |
||
1678 | 1678 | */ |
1679 | 1679 | public function massageFieldDef(&$fieldDef, $tablename) |
1680 | 1680 | { |
1681 | - parent::massageFieldDef($fieldDef,$tablename); |
|
1681 | + parent::massageFieldDef($fieldDef, $tablename); |
|
1682 | 1682 | |
1683 | 1683 | if ($fieldDef['type'] == 'int') |
1684 | 1684 | $fieldDef['len'] = '4'; |
1685 | 1685 | |
1686 | - if(empty($fieldDef['len'])) |
|
1686 | + if (empty($fieldDef['len'])) |
|
1687 | 1687 | { |
1688 | - switch($fieldDef['type']) { |
|
1688 | + switch ($fieldDef['type']) { |
|
1689 | 1689 | case 'bit' : |
1690 | 1690 | case 'bool' : $fieldDef['len'] = '1'; break; |
1691 | 1691 | case 'smallint' : $fieldDef['len'] = '2'; break; |
@@ -1695,22 +1695,22 @@ discard block |
||
1695 | 1695 | $fieldDef['len'] = $this->isTextType($fieldDef['dbType']) ? 'max' : '255'; |
1696 | 1696 | break; |
1697 | 1697 | case 'image' : $fieldDef['len'] = '2147483647'; break; |
1698 | - case 'ntext' : $fieldDef['len'] = '2147483646'; break; // Note: this is from legacy code, don't know if this is correct |
|
1698 | + case 'ntext' : $fieldDef['len'] = '2147483646'; break; // Note: this is from legacy code, don't know if this is correct |
|
1699 | 1699 | } |
1700 | 1700 | } |
1701 | - if($fieldDef['type'] == 'decimal' |
|
1701 | + if ($fieldDef['type'] == 'decimal' |
|
1702 | 1702 | && empty($fieldDef['precision']) |
1703 | 1703 | && !strpos($fieldDef['len'], ',')) |
1704 | 1704 | { |
1705 | 1705 | $fieldDef['len'] .= ',0'; // Adding 0 precision if it is not specified |
1706 | 1706 | } |
1707 | 1707 | |
1708 | - if(empty($fieldDef['default']) |
|
1709 | - && in_array($fieldDef['type'],array('bit','bool'))) |
|
1708 | + if (empty($fieldDef['default']) |
|
1709 | + && in_array($fieldDef['type'], array('bit', 'bool'))) |
|
1710 | 1710 | { |
1711 | 1711 | $fieldDef['default'] = '0'; |
1712 | 1712 | } |
1713 | - if (isset($fieldDef['required']) && $fieldDef['required'] && !isset($fieldDef['default']) ) |
|
1713 | + if (isset($fieldDef['required']) && $fieldDef['required'] && !isset($fieldDef['default'])) |
|
1714 | 1714 | $fieldDef['default'] = ''; |
1715 | 1715 | // if ($fieldDef['type'] == 'bit' && empty($fieldDef['len']) ) |
1716 | 1716 | // $fieldDef['len'] = '1'; |
@@ -1741,13 +1741,13 @@ discard block |
||
1741 | 1741 | protected function oneColumnSQLRep($fieldDef, $ignoreRequired = false, $table = '', $return_as_array = false) |
1742 | 1742 | { |
1743 | 1743 | //Bug 25814 |
1744 | - if(isset($fieldDef['name'])){ |
|
1744 | + if (isset($fieldDef['name'])) { |
|
1745 | 1745 | $colType = $this->getFieldType($fieldDef); |
1746 | - if(stristr($this->getFieldType($fieldDef), 'decimal') && isset($fieldDef['len'])){ |
|
1747 | - $fieldDef['len'] = min($fieldDef['len'],38); |
|
1746 | + if (stristr($this->getFieldType($fieldDef), 'decimal') && isset($fieldDef['len'])) { |
|
1747 | + $fieldDef['len'] = min($fieldDef['len'], 38); |
|
1748 | 1748 | } |
1749 | 1749 | //bug: 39690 float(8) is interpreted as real and this generates a diff when doing repair |
1750 | - if(stristr($colType, 'float') && isset($fieldDef['len']) && $fieldDef['len'] == 8){ |
|
1750 | + if (stristr($colType, 'float') && isset($fieldDef['len']) && $fieldDef['len'] == 8) { |
|
1751 | 1751 | unset($fieldDef['len']); |
1752 | 1752 | } |
1753 | 1753 | } |
@@ -1756,10 +1756,10 @@ discard block |
||
1756 | 1756 | $ref = parent::oneColumnSQLRep($fieldDef, $ignoreRequired, $table, true); |
1757 | 1757 | |
1758 | 1758 | // Bug 24307 - Don't add precision for float fields. |
1759 | - if ( stristr($ref['colType'],'float') ) |
|
1760 | - $ref['colType'] = preg_replace('/(,\d+)/','',$ref['colType']); |
|
1759 | + if (stristr($ref['colType'], 'float')) |
|
1760 | + $ref['colType'] = preg_replace('/(,\d+)/', '', $ref['colType']); |
|
1761 | 1761 | |
1762 | - if ( $return_as_array ) |
|
1762 | + if ($return_as_array) |
|
1763 | 1763 | return $ref; |
1764 | 1764 | else |
1765 | 1765 | return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}"; |
@@ -1774,10 +1774,10 @@ discard block |
||
1774 | 1774 | public function save_audit_records(SugarBean $bean, $changes) |
1775 | 1775 | { |
1776 | 1776 | //Bug 25078 fixed by Martin Hu: sqlserver haven't 'date' type, trim extra "00:00:00" |
1777 | - if($changes['data_type'] == 'date'){ |
|
1778 | - $changes['before'] = str_replace(' 00:00:00','',$changes['before']); |
|
1777 | + if ($changes['data_type'] == 'date') { |
|
1778 | + $changes['before'] = str_replace(' 00:00:00', '', $changes['before']); |
|
1779 | 1779 | } |
1780 | - parent::save_audit_records($bean,$changes); |
|
1780 | + parent::save_audit_records($bean, $changes); |
|
1781 | 1781 | } |
1782 | 1782 | |
1783 | 1783 | /** |
@@ -1788,7 +1788,7 @@ discard block |
||
1788 | 1788 | public function disconnect() |
1789 | 1789 | { |
1790 | 1790 | $GLOBALS['log']->debug('Calling Mssql::disconnect()'); |
1791 | - if(!empty($this->database)){ |
|
1791 | + if (!empty($this->database)) { |
|
1792 | 1792 | $this->freeResult(); |
1793 | 1793 | mssql_close($this->database); |
1794 | 1794 | $this->database = null; |
@@ -1800,7 +1800,7 @@ discard block |
||
1800 | 1800 | */ |
1801 | 1801 | protected function freeDbResult($dbResult) |
1802 | 1802 | { |
1803 | - if(!empty($dbResult)) |
|
1803 | + if (!empty($dbResult)) |
|
1804 | 1804 | mssql_free_result($dbResult); |
1805 | 1805 | } |
1806 | 1806 | |
@@ -1811,11 +1811,11 @@ discard block |
||
1811 | 1811 | public function lastDbError() |
1812 | 1812 | { |
1813 | 1813 | $sqlmsg = mssql_get_last_message(); |
1814 | - if(empty($sqlmsg)) return false; |
|
1814 | + if (empty($sqlmsg)) return false; |
|
1815 | 1815 | global $app_strings; |
1816 | 1816 | if (empty($app_strings) |
1817 | 1817 | or !isset($app_strings['ERR_MSSQL_DB_CONTEXT']) |
1818 | - or !isset($app_strings['ERR_MSSQL_WARNING']) ) { |
|
1818 | + or !isset($app_strings['ERR_MSSQL_WARNING'])) { |
|
1819 | 1819 | //ignore the message from sql-server if $app_strings array is empty. This will happen |
1820 | 1820 | //only if connection if made before language is set. |
1821 | 1821 | return false; |
@@ -1824,7 +1824,7 @@ discard block |
||
1824 | 1824 | $sqlpos = strpos($sqlmsg, 'Changed database context to'); |
1825 | 1825 | $sqlpos2 = strpos($sqlmsg, 'Warning:'); |
1826 | 1826 | $sqlpos3 = strpos($sqlmsg, 'Checking identity information:'); |
1827 | - if ( $sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false ) { |
|
1827 | + if ($sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false) { |
|
1828 | 1828 | return false; |
1829 | 1829 | } else { |
1830 | 1830 | global $app_strings; |
@@ -1832,18 +1832,18 @@ discard block |
||
1832 | 1832 | if (empty($app_strings) or !isset($app_strings['ERR_MSSQL_DB_CONTEXT'])) { |
1833 | 1833 | //ignore the message from sql-server if $app_strings array is empty. This will happen |
1834 | 1834 | //only if connection if made before languge is set. |
1835 | - $GLOBALS['log']->debug("Ignoring this database message: " . $sqlmsg); |
|
1835 | + $GLOBALS['log']->debug("Ignoring this database message: ".$sqlmsg); |
|
1836 | 1836 | return false; |
1837 | 1837 | } |
1838 | 1838 | else { |
1839 | 1839 | $sqlpos = strpos($sqlmsg, $app_strings['ERR_MSSQL_DB_CONTEXT']); |
1840 | - if ( $sqlpos !== false ) |
|
1840 | + if ($sqlpos !== false) |
|
1841 | 1841 | return false; |
1842 | 1842 | } |
1843 | 1843 | } |
1844 | 1844 | |
1845 | - if ( strlen($sqlmsg) > 2 ) { |
|
1846 | - return "SQL Server error: " . $sqlmsg; |
|
1845 | + if (strlen($sqlmsg) > 2) { |
|
1846 | + return "SQL Server error: ".$sqlmsg; |
|
1847 | 1847 | } |
1848 | 1848 | |
1849 | 1849 | return false; |
@@ -1864,7 +1864,7 @@ discard block |
||
1864 | 1864 | */ |
1865 | 1865 | public function validateQuery($query) |
1866 | 1866 | { |
1867 | - if(!$this->isSelect($query)) { |
|
1867 | + if (!$this->isSelect($query)) { |
|
1868 | 1868 | return false; |
1869 | 1869 | } |
1870 | 1870 | $this->query("SET SHOWPLAN_TEXT ON"); |
@@ -1888,7 +1888,7 @@ discard block |
||
1888 | 1888 | |
1889 | 1889 | // Flag if there are odd number of single quotes, just continue without trying to append N |
1890 | 1890 | if ((substr_count($sql, "'") & 1)) { |
1891 | - $GLOBALS['log']->error("SQL statement[" . $sql . "] has odd number of single quotes."); |
|
1891 | + $GLOBALS['log']->error("SQL statement[".$sql."] has odd number of single quotes."); |
|
1892 | 1892 | return $sql; |
1893 | 1893 | } |
1894 | 1894 | |
@@ -1918,7 +1918,7 @@ discard block |
||
1918 | 1918 | // We are assuming that all nvarchar columns are no more than 200 characters in length |
1919 | 1919 | // One problem we face is the image column type in reports which cannot accept nvarchar data |
1920 | 1920 | if (!empty($value) && !is_numeric(trim(str_replace(array("'", ","), "", $value))) && !preg_match('/^\'[\,]\'$/', $value)) { |
1921 | - $replace[$value] = 'N' . trim($value, "N"); |
|
1921 | + $replace[$value] = 'N'.trim($value, "N"); |
|
1922 | 1922 | } |
1923 | 1923 | } |
1924 | 1924 | } |
@@ -1929,7 +1929,7 @@ discard block |
||
1929 | 1929 | if (!empty($pairs)) |
1930 | 1930 | $sql = str_replace(array_keys($pairs), $pairs, $sql); |
1931 | 1931 | |
1932 | - if(strpos($sql, "<@#@#@PAIR@#@#@>")) |
|
1932 | + if (strpos($sql, "<@#@#@PAIR@#@#@>")) |
|
1933 | 1933 | $sql = str_replace(array('<@#@#@PAIR@#@#@>'), array("''"), $sql); |
1934 | 1934 | |
1935 | 1935 | return $sql; |
@@ -1956,22 +1956,22 @@ discard block |
||
1956 | 1956 | public function getFulltextQuery($field, $terms, $must_terms = array(), $exclude_terms = array()) |
1957 | 1957 | { |
1958 | 1958 | $condition = $or_condition = array(); |
1959 | - foreach($must_terms as $term) { |
|
1959 | + foreach ($must_terms as $term) { |
|
1960 | 1960 | $condition[] = $this->quoteTerm($term); |
1961 | 1961 | } |
1962 | 1962 | |
1963 | - foreach($terms as $term) { |
|
1963 | + foreach ($terms as $term) { |
|
1964 | 1964 | $or_condition[] = $this->quoteTerm($term); |
1965 | 1965 | } |
1966 | 1966 | |
1967 | - if(!empty($or_condition)) { |
|
1967 | + if (!empty($or_condition)) { |
|
1968 | 1968 | $condition[] = "(".join(" | ", $or_condition).")"; |
1969 | 1969 | } |
1970 | 1970 | |
1971 | - foreach($exclude_terms as $term) { |
|
1971 | + foreach ($exclude_terms as $term) { |
|
1972 | 1972 | $condition[] = " NOT ".$this->quoteTerm($term); |
1973 | 1973 | } |
1974 | - $condition = $this->quoted(join(" AND ",$condition)); |
|
1974 | + $condition = $this->quoted(join(" AND ", $condition)); |
|
1975 | 1975 | return "CONTAINS($field, $condition)"; |
1976 | 1976 | } |
1977 | 1977 | |
@@ -2060,7 +2060,7 @@ discard block |
||
2060 | 2060 | public function isDatabaseNameValid($name) |
2061 | 2061 | { |
2062 | 2062 | // No funny chars, does not begin with number |
2063 | - return preg_match('/^[0-9#@]+|[\"\'\*\/\\?\:\\<\>\-\ \&\!\(\)\[\]\{\}\;\,\.\`\~\|\\\\]+/', $name)==0; |
|
2063 | + return preg_match('/^[0-9#@]+|[\"\'\*\/\\?\:\\<\>\-\ \&\!\(\)\[\]\{\}\;\,\.\`\~\|\\\\]+/', $name) == 0; |
|
2064 | 2064 | } |
2065 | 2065 | |
2066 | 2066 | public function installConfig() |
@@ -7,9 +7,9 @@ discard block |
||
7 | 7 | |
8 | 8 | //execute the contructor and check for the Object type and attributes |
9 | 9 | $employee = new Employee(); |
10 | - $this->assertInstanceOf('Employee',$employee); |
|
11 | - $this->assertInstanceOf('Person',$employee); |
|
12 | - $this->assertInstanceOf('SugarBean',$employee); |
|
10 | + $this->assertInstanceOf('Employee', $employee); |
|
11 | + $this->assertInstanceOf('Person', $employee); |
|
12 | + $this->assertInstanceOf('SugarBean', $employee); |
|
13 | 13 | |
14 | 14 | $this->assertAttributeEquals('Employees', 'module_dir', $employee); |
15 | 15 | $this->assertAttributeEquals('Employee', 'object_name', $employee); |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | $employee = new Employee(); |
27 | 27 | |
28 | 28 | //test without setting name |
29 | - $this->assertEquals(' ',$employee->get_summary_text()); |
|
29 | + $this->assertEquals(' ', $employee->get_summary_text()); |
|
30 | 30 | |
31 | 31 | //test with name set |
32 | 32 | $employee->retrieve(1); |
33 | - $this->assertEquals('Administrator',$employee->get_summary_text()); |
|
33 | + $this->assertEquals('Administrator', $employee->get_summary_text()); |
|
34 | 34 | |
35 | 35 | } |
36 | 36 | |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | public function testverify_data() |
81 | 81 | { |
82 | 82 | $employee = new Employee(); |
83 | - $this->assertEquals(true ,$employee->verify_data() ); |
|
83 | + $this->assertEquals(true, $employee->verify_data()); |
|
84 | 84 | |
85 | 85 | } |
86 | 86 | |
87 | - public function testget_list_view_data(){ |
|
87 | + public function testget_list_view_data() { |
|
88 | 88 | |
89 | 89 | $employee = new Employee(); |
90 | 90 | |
91 | - $expected = array ( |
|
91 | + $expected = array( |
|
92 | 92 | 'SUGAR_LOGIN' => '1', |
93 | 93 | 'FULL_NAME' => ' ', |
94 | 94 | 'NAME' => ' ', |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | |
111 | 111 | } |
112 | 112 | |
113 | - public function testlist_view_parse_additional_sections(){ |
|
113 | + public function testlist_view_parse_additional_sections() { |
|
114 | 114 | |
115 | 115 | $employee = new Employee(); |
116 | 116 | |
@@ -132,14 +132,14 @@ discard block |
||
132 | 132 | |
133 | 133 | //test with empty string params |
134 | 134 | $expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users WHERE users.deleted = 0 ORDER BY users.user_name"; |
135 | - $actual = $employee->create_export_query('',''); |
|
136 | - $this->assertSame($expected,$actual); |
|
135 | + $actual = $employee->create_export_query('', ''); |
|
136 | + $this->assertSame($expected, $actual); |
|
137 | 137 | |
138 | 138 | |
139 | 139 | //test with valid string params |
140 | 140 | $expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users WHERE users.user_name=\"\" AND users.deleted = 0 ORDER BY users.id"; |
141 | - $actual = $employee->create_export_query('users.id','users.user_name=""'); |
|
142 | - $this->assertSame($expected,$actual); |
|
141 | + $actual = $employee->create_export_query('users.id', 'users.user_name=""'); |
|
142 | + $this->assertSame($expected, $actual); |
|
143 | 143 | |
144 | 144 | } |
145 | 145 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | { |
171 | 171 | $employee = new Employee(); |
172 | 172 | $result = $employee->hasCustomFields(); |
173 | - $this->assertEquals(false,$result); |
|
173 | + $this->assertEquals(false, $result); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | } |
@@ -311,17 +311,17 @@ discard block |
||
311 | 311 | $this->optimistic_lock = true; |
312 | 312 | } |
313 | 313 | } |
314 | - $loaded_defs[$this->object_name]['column_fields'] =& $this->column_fields; |
|
315 | - $loaded_defs[$this->object_name]['list_fields'] =& $this->list_fields; |
|
316 | - $loaded_defs[$this->object_name]['required_fields'] =& $this->required_fields; |
|
317 | - $loaded_defs[$this->object_name]['field_name_map'] =& $this->field_name_map; |
|
318 | - $loaded_defs[$this->object_name]['field_defs'] =& $this->field_defs; |
|
314 | + $loaded_defs[$this->object_name]['column_fields'] = & $this->column_fields; |
|
315 | + $loaded_defs[$this->object_name]['list_fields'] = & $this->list_fields; |
|
316 | + $loaded_defs[$this->object_name]['required_fields'] = & $this->required_fields; |
|
317 | + $loaded_defs[$this->object_name]['field_name_map'] = & $this->field_name_map; |
|
318 | + $loaded_defs[$this->object_name]['field_defs'] = & $this->field_defs; |
|
319 | 319 | } else { |
320 | - $this->column_fields =& $loaded_defs[$this->object_name]['column_fields']; |
|
321 | - $this->list_fields =& $loaded_defs[$this->object_name]['list_fields']; |
|
322 | - $this->required_fields =& $loaded_defs[$this->object_name]['required_fields']; |
|
323 | - $this->field_name_map =& $loaded_defs[$this->object_name]['field_name_map']; |
|
324 | - $this->field_defs =& $loaded_defs[$this->object_name]['field_defs']; |
|
320 | + $this->column_fields = & $loaded_defs[$this->object_name]['column_fields']; |
|
321 | + $this->list_fields = & $loaded_defs[$this->object_name]['list_fields']; |
|
322 | + $this->required_fields = & $loaded_defs[$this->object_name]['required_fields']; |
|
323 | + $this->field_name_map = & $loaded_defs[$this->object_name]['field_name_map']; |
|
324 | + $this->field_defs = & $loaded_defs[$this->object_name]['field_defs']; |
|
325 | 325 | $this->added_custom_field_defs = true; |
326 | 326 | |
327 | 327 | if (!isset($this->custom_fields) && |
@@ -343,9 +343,9 @@ discard block |
||
343 | 343 | /** |
344 | 344 | * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead |
345 | 345 | */ |
346 | - public function SugarBean(){ |
|
346 | + public function SugarBean() { |
|
347 | 347 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
348 | - if(isset($GLOBALS['log'])) { |
|
348 | + if (isset($GLOBALS['log'])) { |
|
349 | 349 | $GLOBALS['log']->deprecated($deprecatedMessage); |
350 | 350 | } |
351 | 351 | else { |
@@ -457,14 +457,14 @@ discard block |
||
457 | 457 | { |
458 | 458 | //load the module dictionary if not supplied. |
459 | 459 | if ((!isset($dictionary) or empty($dictionary)) && !empty($module_dir)) { |
460 | - $filename = 'modules/' . $module_dir . '/vardefs.php'; |
|
460 | + $filename = 'modules/'.$module_dir.'/vardefs.php'; |
|
461 | 461 | if (file_exists($filename)) { |
462 | 462 | include($filename); |
463 | 463 | } |
464 | 464 | } |
465 | 465 | if (!is_array($dictionary) or !array_key_exists($key, $dictionary)) { |
466 | - $GLOBALS['log']->fatal("removeRelationshipMeta: Metadata for table " . $tablename . " does not exist"); |
|
467 | - display_notice("meta data absent for table " . $tablename . " keyed to $key "); |
|
466 | + $GLOBALS['log']->fatal("removeRelationshipMeta: Metadata for table ".$tablename." does not exist"); |
|
467 | + display_notice("meta data absent for table ".$tablename." keyed to $key "); |
|
468 | 468 | } else { |
469 | 469 | if (isset($dictionary[$key]['relationships'])) { |
470 | 470 | $RelationshipDefs = $dictionary[$key]['relationships']; |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | //load the module dictionary if not supplied. |
496 | 496 | if (empty($dictionary) && !empty($module_dir)) { |
497 | 497 | if ($is_custom) { |
498 | - $filename = 'custom/modules/' . $module_dir . '/Ext/Vardefs/vardefs.ext.php'; |
|
498 | + $filename = 'custom/modules/'.$module_dir.'/Ext/Vardefs/vardefs.ext.php'; |
|
499 | 499 | } else { |
500 | 500 | if ($key == 'User') { |
501 | 501 | // a very special case for the Employees module |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | // Users/vardefs.php |
504 | 504 | $filename = 'modules/Users/vardefs.php'; |
505 | 505 | } else { |
506 | - $filename = 'modules/' . $module_dir . '/vardefs.php'; |
|
506 | + $filename = 'modules/'.$module_dir.'/vardefs.php'; |
|
507 | 507 | } |
508 | 508 | } |
509 | 509 | |
@@ -514,14 +514,14 @@ discard block |
||
514 | 514 | $dictionary = $GLOBALS['dictionary']; |
515 | 515 | } |
516 | 516 | } else { |
517 | - $GLOBALS['log']->debug("createRelationshipMeta: no metadata file found" . $filename); |
|
517 | + $GLOBALS['log']->debug("createRelationshipMeta: no metadata file found".$filename); |
|
518 | 518 | return; |
519 | 519 | } |
520 | 520 | } |
521 | 521 | |
522 | 522 | if (!is_array($dictionary) or !array_key_exists($key, $dictionary)) { |
523 | - $GLOBALS['log']->fatal("createRelationshipMeta: Metadata for table " . $tablename . " does not exist"); |
|
524 | - display_notice("meta data absent for table " . $tablename . " keyed to $key "); |
|
523 | + $GLOBALS['log']->fatal("createRelationshipMeta: Metadata for table ".$tablename." does not exist"); |
|
524 | + display_notice("meta data absent for table ".$tablename." keyed to $key "); |
|
525 | 525 | } else { |
526 | 526 | if (isset($dictionary[$key]['relationships'])) { |
527 | 527 | $RelationshipDefs = $dictionary[$key]['relationships']; |
@@ -530,18 +530,18 @@ discard block |
||
530 | 530 | $beanList_ucase = array_change_key_case($beanList, CASE_UPPER); |
531 | 531 | foreach ($RelationshipDefs as $rel_name => $rel_def) { |
532 | 532 | if (isset($rel_def['lhs_module']) and !isset($beanList_ucase[strtoupper($rel_def['lhs_module'])])) { |
533 | - $GLOBALS['log']->debug('skipping orphaned relationship record ' . $rel_name . ' lhs module is missing ' . $rel_def['lhs_module']); |
|
533 | + $GLOBALS['log']->debug('skipping orphaned relationship record '.$rel_name.' lhs module is missing '.$rel_def['lhs_module']); |
|
534 | 534 | continue; |
535 | 535 | } |
536 | 536 | if (isset($rel_def['rhs_module']) and !isset($beanList_ucase[strtoupper($rel_def['rhs_module'])])) { |
537 | - $GLOBALS['log']->debug('skipping orphaned relationship record ' . $rel_name . ' rhs module is missing ' . $rel_def['rhs_module']); |
|
537 | + $GLOBALS['log']->debug('skipping orphaned relationship record '.$rel_name.' rhs module is missing '.$rel_def['rhs_module']); |
|
538 | 538 | continue; |
539 | 539 | } |
540 | 540 | |
541 | 541 | |
542 | 542 | //check whether relationship exists or not first. |
543 | 543 | if (Relationship::exists($rel_name, $db)) { |
544 | - $GLOBALS['log']->debug('Skipping, relationship already exists ' . $rel_name); |
|
544 | + $GLOBALS['log']->debug('Skipping, relationship already exists '.$rel_name); |
|
545 | 545 | } else { |
546 | 546 | $seed = BeanFactory::getBean("Relationships"); |
547 | 547 | $keys = array_keys($seed->field_defs); |
@@ -559,10 +559,10 @@ discard block |
||
559 | 559 | |
560 | 560 | |
561 | 561 | $column_list = implode(",", array_keys($toInsert)); |
562 | - $value_list = "'" . implode("','", array_values($toInsert)) . "'"; |
|
562 | + $value_list = "'".implode("','", array_values($toInsert))."'"; |
|
563 | 563 | |
564 | 564 | //create the record. todo add error check. |
565 | - $insert_string = "INSERT into relationships (" . $column_list . ") values (" . $value_list . ")"; |
|
565 | + $insert_string = "INSERT into relationships (".$column_list.") values (".$value_list.")"; |
|
566 | 566 | $db->query($insert_string, true); |
567 | 567 | } |
568 | 568 | } |
@@ -638,11 +638,11 @@ discard block |
||
638 | 638 | $tmp_final_query = $parentbean->$shortcut_function_name(); |
639 | 639 | } |
640 | 640 | if (!$first) { |
641 | - $final_query_rows .= ' UNION ALL ( ' . $parentbean->create_list_count_query($tmp_final_query, $parameters) . ' )'; |
|
642 | - $final_query .= ' UNION ALL ( ' . $tmp_final_query . ' )'; |
|
641 | + $final_query_rows .= ' UNION ALL ( '.$parentbean->create_list_count_query($tmp_final_query, $parameters).' )'; |
|
642 | + $final_query .= ' UNION ALL ( '.$tmp_final_query.' )'; |
|
643 | 643 | } else { |
644 | - $final_query_rows = '(' . $parentbean->create_list_count_query($tmp_final_query, $parameters) . ')'; |
|
645 | - $final_query = '(' . $tmp_final_query . ')'; |
|
644 | + $final_query_rows = '('.$parentbean->create_list_count_query($tmp_final_query, $parameters).')'; |
|
645 | + $final_query = '('.$tmp_final_query.')'; |
|
646 | 646 | $first = false; |
647 | 647 | } |
648 | 648 | } |
@@ -673,32 +673,32 @@ discard block |
||
673 | 673 | } |
674 | 674 | $subquery['select'] = substr($subquery['select'], 0, strlen($subquery['select']) - 1); |
675 | 675 | //Put the query into the final_query |
676 | - $query = $subquery['select'] . " " . $subquery['from'] . " " . $subquery['where']; |
|
676 | + $query = $subquery['select']." ".$subquery['from']." ".$subquery['where']; |
|
677 | 677 | if (!$first) { |
678 | - $query = ' UNION ALL ( ' . $query . ' )'; |
|
678 | + $query = ' UNION ALL ( '.$query.' )'; |
|
679 | 679 | $final_query_rows .= " UNION ALL "; |
680 | 680 | } else { |
681 | - $query = '(' . $query . ')'; |
|
681 | + $query = '('.$query.')'; |
|
682 | 682 | $first = false; |
683 | 683 | } |
684 | 684 | $query_array = $subquery['query_array']; |
685 | 685 | $select_position = strpos($query_array['select'], "SELECT"); |
686 | 686 | $distinct_position = strpos($query_array['select'], "DISTINCT"); |
687 | 687 | if (!empty($subquery['params']['distinct']) && !empty($subpanel_def->table_name)) { |
688 | - $query_rows = "( SELECT count(DISTINCT " . $subpanel_def->table_name . ".id)" . $subquery['from_min'] . $query_array['join'] . $subquery['where'] . ' )'; |
|
688 | + $query_rows = "( SELECT count(DISTINCT ".$subpanel_def->table_name.".id)".$subquery['from_min'].$query_array['join'].$subquery['where'].' )'; |
|
689 | 689 | } elseif ($select_position !== false && $distinct_position != false) { |
690 | - $query_rows = "( " . substr_replace($query_array['select'], "SELECT count(", $select_position, 6) . ")" . $subquery['from_min'] . $query_array['join'] . $subquery['where'] . ' )'; |
|
690 | + $query_rows = "( ".substr_replace($query_array['select'], "SELECT count(", $select_position, 6).")".$subquery['from_min'].$query_array['join'].$subquery['where'].' )'; |
|
691 | 691 | } else { |
692 | 692 | //resort to default behavior. |
693 | - $query_rows = "( SELECT count(*)" . $subquery['from_min'] . $query_array['join'] . $subquery['where'] . ' )'; |
|
693 | + $query_rows = "( SELECT count(*)".$subquery['from_min'].$query_array['join'].$subquery['where'].' )'; |
|
694 | 694 | } |
695 | 695 | if (!empty($subquery['secondary_select'])) { |
696 | - $subquerystring = $subquery['secondary_select'] . $subquery['secondary_from'] . $query_array['join'] . $subquery['where']; |
|
696 | + $subquerystring = $subquery['secondary_select'].$subquery['secondary_from'].$query_array['join'].$subquery['where']; |
|
697 | 697 | if (!empty($subquery['secondary_where'])) { |
698 | 698 | if (empty($subquery['where'])) { |
699 | - $subquerystring .= " WHERE " . $subquery['secondary_where']; |
|
699 | + $subquerystring .= " WHERE ".$subquery['secondary_where']; |
|
700 | 700 | } else { |
701 | - $subquerystring .= " AND " . $subquery['secondary_where']; |
|
701 | + $subquerystring .= " AND ".$subquery['secondary_where']; |
|
702 | 702 | } |
703 | 703 | } |
704 | 704 | $secondary_queries[] = $subquerystring; |
@@ -721,12 +721,12 @@ discard block |
||
721 | 721 | } |
722 | 722 | |
723 | 723 | if (!empty($sort_order)) { |
724 | - $order_by .= ' ' . $sort_order; |
|
724 | + $order_by .= ' '.$sort_order; |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | $order_by = $parentbean->process_order_by($order_by, $submodule, $suppress_table_name); |
728 | 728 | if (!empty($order_by)) { |
729 | - $final_query .= ' ORDER BY ' . $order_by; |
|
729 | + $final_query .= ' ORDER BY '.$order_by; |
|
730 | 730 | } |
731 | 731 | } |
732 | 732 | |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | if (empty($where_definition)) { |
795 | 795 | $where_definition = $table_where; |
796 | 796 | } else { |
797 | - $where_definition .= ' AND ' . $table_where; |
|
797 | + $where_definition .= ' AND '.$table_where; |
|
798 | 798 | } |
799 | 799 | } |
800 | 800 | |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | |
816 | 816 | |
817 | 817 | 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')) { |
818 | - $order_by = $submodule->table_name . '.' . $order_by; |
|
818 | + $order_by = $submodule->table_name.'.'.$order_by; |
|
819 | 819 | } |
820 | 820 | $table_name = $this_subpanel->table_name; |
821 | 821 | $panel_name = $this_subpanel->name; |
@@ -831,8 +831,8 @@ discard block |
||
831 | 831 | |
832 | 832 | $subquery = $submodule->create_new_list_query('', $subwhere, $list_fields, $params, 0, '', true, $parentbean, $singleSelect); |
833 | 833 | |
834 | - $subquery['select'] = $subquery['select'] . " , '$panel_name' panel_name "; |
|
835 | - $subquery['from'] = $subquery['from'] . $query_array['join']; |
|
834 | + $subquery['select'] = $subquery['select']." , '$panel_name' panel_name "; |
|
835 | + $subquery['from'] = $subquery['from'].$query_array['join']; |
|
836 | 836 | $subquery['query_array'] = $query_array; |
837 | 837 | $subquery['params'] = $params; |
838 | 838 | |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | $use_count_query = false; |
871 | 871 | $processing_collection = $subpanel_def->isCollection(); |
872 | 872 | |
873 | - $GLOBALS['log']->debug("process_union_list_query: " . $query); |
|
873 | + $GLOBALS['log']->debug("process_union_list_query: ".$query); |
|
874 | 874 | if ($max_per_page == -1) { |
875 | 875 | $max_per_page = $sugar_config['list_max_entries_per_subpanel']; |
876 | 876 | } |
@@ -947,9 +947,9 @@ discard block |
||
947 | 947 | if (isset($row[$field])) { |
948 | 948 | $current_bean->$field = $this->convertField($row[$field], $value); |
949 | 949 | unset($row[$field]); |
950 | - } elseif (isset($row[$this->table_name . '.' . $field])) { |
|
951 | - $current_bean->$field = $this->convertField($row[$this->table_name . '.' . $field], $value); |
|
952 | - unset($row[$this->table_name . '.' . $field]); |
|
950 | + } elseif (isset($row[$this->table_name.'.'.$field])) { |
|
951 | + $current_bean->$field = $this->convertField($row[$this->table_name.'.'.$field], $value); |
|
952 | + unset($row[$this->table_name.'.'.$field]); |
|
953 | 953 | } else { |
954 | 954 | $current_bean->$field = ""; |
955 | 955 | unset($row[$field]); |
@@ -1116,7 +1116,7 @@ discard block |
||
1116 | 1116 | $class = $beanList[$child_info['parent_type']]; |
1117 | 1117 | // Added to avoid error below; just silently fail and write message to log |
1118 | 1118 | if (empty($beanFiles[$class])) { |
1119 | - $GLOBALS['log']->error($this->object_name . '::retrieve_parent_fields() - cannot load class "' . $class . '", skip loading.'); |
|
1119 | + $GLOBALS['log']->error($this->object_name.'::retrieve_parent_fields() - cannot load class "'.$class.'", skip loading.'); |
|
1120 | 1120 | continue; |
1121 | 1121 | } |
1122 | 1122 | require_once($beanFiles[$class]); |
@@ -1127,7 +1127,7 @@ discard block |
||
1127 | 1127 | $queries[$child_info['parent_type']] = "SELECT id "; |
1128 | 1128 | $field_def = $templates[$child_info['parent_type']]->field_defs['name']; |
1129 | 1129 | if (isset($field_def['db_concat_fields'])) { |
1130 | - $queries[$child_info['parent_type']] .= ' , ' . $this->db->concat($templates[$child_info['parent_type']]->table_name, $field_def['db_concat_fields']) . ' parent_name'; |
|
1130 | + $queries[$child_info['parent_type']] .= ' , '.$this->db->concat($templates[$child_info['parent_type']]->table_name, $field_def['db_concat_fields']).' parent_name'; |
|
1131 | 1131 | } else { |
1132 | 1132 | $queries[$child_info['parent_type']] .= ' , name parent_name'; |
1133 | 1133 | } |
@@ -1137,7 +1137,7 @@ discard block |
||
1137 | 1137 | } elseif (isset($templates[$child_info['parent_type']]->field_defs['created_by'])) { |
1138 | 1138 | $queries[$child_info['parent_type']] .= ", created_by parent_name_owner, '{$child_info['parent_type']}' parent_name_mod"; |
1139 | 1139 | } |
1140 | - $queries[$child_info['parent_type']] .= " FROM " . $templates[$child_info['parent_type']]->table_name . " WHERE id IN ('{$child_info['parent_id']}'"; |
|
1140 | + $queries[$child_info['parent_type']] .= " FROM ".$templates[$child_info['parent_type']]->table_name." WHERE id IN ('{$child_info['parent_id']}'"; |
|
1141 | 1141 | } else { |
1142 | 1142 | if (empty($parent_child_map[$child_info['parent_id']])) { |
1143 | 1143 | $queries[$child_info['parent_type']] .= " ,'{$child_info['parent_id']}'"; |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | } |
1150 | 1150 | $results = array(); |
1151 | 1151 | foreach ($queries as $query) { |
1152 | - $result = $this->db->query($query . ')'); |
|
1152 | + $result = $this->db->query($query.')'); |
|
1153 | 1153 | while ($row = $this->db->fetchByAssoc($result)) { |
1154 | 1154 | $results[$row['id']] = $row; |
1155 | 1155 | } |
@@ -1234,7 +1234,7 @@ discard block |
||
1234 | 1234 | */ |
1235 | 1235 | public function get_custom_table_name() |
1236 | 1236 | { |
1237 | - return $this->getTableName() . '_cstm'; |
|
1237 | + return $this->getTableName().'_cstm'; |
|
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | /** |
@@ -1474,7 +1474,7 @@ discard block |
||
1474 | 1474 | */ |
1475 | 1475 | public function load_relationship($rel_name) |
1476 | 1476 | { |
1477 | - $GLOBALS['log']->debug("SugarBean[{$this->object_name}].load_relationships, Loading relationship (" . $rel_name . ")."); |
|
1477 | + $GLOBALS['log']->debug("SugarBean[{$this->object_name}].load_relationships, Loading relationship (".$rel_name.")."); |
|
1478 | 1478 | |
1479 | 1479 | if (empty($rel_name)) { |
1480 | 1480 | $GLOBALS['log']->error("SugarBean.load_relationships, Null relationship name passed."); |
@@ -1509,7 +1509,7 @@ discard block |
||
1509 | 1509 | return true; |
1510 | 1510 | } |
1511 | 1511 | } |
1512 | - $GLOBALS['log']->debug("SugarBean.load_relationships, Error Loading relationship (" . $rel_name . ")"); |
|
1512 | + $GLOBALS['log']->debug("SugarBean.load_relationships, Error Loading relationship (".$rel_name.")"); |
|
1513 | 1513 | return false; |
1514 | 1514 | } |
1515 | 1515 | |
@@ -1616,7 +1616,7 @@ discard block |
||
1616 | 1616 | $idField = $value_array['id_name']; |
1617 | 1617 | if (isset($fieldDefs[$idField]) && isset($fieldDefs[$idField]['type']) && $fieldDefs[$idField]['type'] == 'link') { |
1618 | 1618 | $tmpFieldDefs = $fieldDefs[$idField]; |
1619 | - $tmpFieldDefs['vname'] = translate($value_array['vname'], $this->module_dir) . " " . $GLOBALS['app_strings']['LBL_ID']; |
|
1619 | + $tmpFieldDefs['vname'] = translate($value_array['vname'], $this->module_dir)." ".$GLOBALS['app_strings']['LBL_ID']; |
|
1620 | 1620 | $importableFields[$idField] = $tmpFieldDefs; |
1621 | 1621 | } |
1622 | 1622 | } |
@@ -1640,8 +1640,8 @@ discard block |
||
1640 | 1640 | |
1641 | 1641 | $key = $this->getObjectName(); |
1642 | 1642 | if (!array_key_exists($key, $dictionary)) { |
1643 | - $GLOBALS['log']->fatal("create_tables: Metadata for table " . $this->table_name . " does not exist"); |
|
1644 | - display_notice("meta data absent for table " . $this->table_name . " keyed to $key "); |
|
1643 | + $GLOBALS['log']->fatal("create_tables: Metadata for table ".$this->table_name." does not exist"); |
|
1644 | + display_notice("meta data absent for table ".$this->table_name." keyed to $key "); |
|
1645 | 1645 | } else { |
1646 | 1646 | if (!$this->db->tableExists($this->table_name)) { |
1647 | 1647 | $this->db->createTable($this); |
@@ -1702,7 +1702,7 @@ discard block |
||
1702 | 1702 | */ |
1703 | 1703 | public function get_audit_table_name() |
1704 | 1704 | { |
1705 | - return $this->getTableName() . '_audit'; |
|
1705 | + return $this->getTableName().'_audit'; |
|
1706 | 1706 | } |
1707 | 1707 | |
1708 | 1708 | /** |
@@ -1720,7 +1720,7 @@ discard block |
||
1720 | 1720 | require('metadata/audit_templateMetaData.php'); |
1721 | 1721 | |
1722 | 1722 | // Bug: 52583 Need ability to customize template for audit tables |
1723 | - $custom = 'custom/metadata/audit_templateMetaData_' . $this->getTableName() . '.php'; |
|
1723 | + $custom = 'custom/metadata/audit_templateMetaData_'.$this->getTableName().'.php'; |
|
1724 | 1724 | if (file_exists($custom)) { |
1725 | 1725 | require($custom); |
1726 | 1726 | } |
@@ -1730,7 +1730,7 @@ discard block |
||
1730 | 1730 | |
1731 | 1731 | // Renaming template indexes to fit the particular audit table (removed the brittle hard coding) |
1732 | 1732 | foreach ($indices as $nr => $properties) { |
1733 | - $indices[$nr]['name'] = 'idx_' . strtolower($this->getTableName()) . '_' . $properties['name']; |
|
1733 | + $indices[$nr]['name'] = 'idx_'.strtolower($this->getTableName()).'_'.$properties['name']; |
|
1734 | 1734 | } |
1735 | 1735 | |
1736 | 1736 | $engine = null; |
@@ -1754,8 +1754,8 @@ discard block |
||
1754 | 1754 | global $dictionary; |
1755 | 1755 | $key = $this->getObjectName(); |
1756 | 1756 | if (!array_key_exists($key, $dictionary)) { |
1757 | - $GLOBALS['log']->fatal("drop_tables: Metadata for table " . $this->table_name . " does not exist"); |
|
1758 | - echo "meta data absent for table " . $this->table_name . "<br>\n"; |
|
1757 | + $GLOBALS['log']->fatal("drop_tables: Metadata for table ".$this->table_name." does not exist"); |
|
1758 | + echo "meta data absent for table ".$this->table_name."<br>\n"; |
|
1759 | 1759 | } else { |
1760 | 1760 | if (empty($this->table_name)) { |
1761 | 1761 | return; |
@@ -1763,8 +1763,8 @@ discard block |
||
1763 | 1763 | if ($this->db->tableExists($this->table_name)) { |
1764 | 1764 | $this->db->dropTable($this); |
1765 | 1765 | } |
1766 | - if ($this->db->tableExists($this->table_name . '_cstm')) { |
|
1767 | - $this->db->dropTableName($this->table_name . '_cstm'); |
|
1766 | + if ($this->db->tableExists($this->table_name.'_cstm')) { |
|
1767 | + $this->db->dropTableName($this->table_name.'_cstm'); |
|
1768 | 1768 | DynamicField::deleteCache(); |
1769 | 1769 | } |
1770 | 1770 | if ($this->db->tableExists($this->get_audit_table_name())) { |
@@ -2059,7 +2059,7 @@ discard block |
||
2059 | 2059 | break; |
2060 | 2060 | } |
2061 | 2061 | if ($reformatted) { |
2062 | - $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'); |
|
2062 | + $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'); |
|
2063 | 2063 | } |
2064 | 2064 | } |
2065 | 2065 | } |
@@ -2101,7 +2101,7 @@ discard block |
||
2101 | 2101 | $_SESSION['o_lock_object'] = $this->toArray(); |
2102 | 2102 | $saveform = "<form name='save' id='save' method='POST'>"; |
2103 | 2103 | foreach ($_POST as $key => $arg) { |
2104 | - $saveform .= "<input type='hidden' name='" . addslashes($key) . "' value='" . addslashes($arg) . "'>"; |
|
2104 | + $saveform .= "<input type='hidden' name='".addslashes($key)."' value='".addslashes($arg)."'>"; |
|
2105 | 2105 | } |
2106 | 2106 | $saveform .= "</form><script>document.getElementById('save').submit();</script>"; |
2107 | 2107 | $_SESSION['o_lock_save'] = $saveform; |
@@ -2281,7 +2281,7 @@ discard block |
||
2281 | 2281 | if ($rel_name == $new_rel_link && $this->$id != $new_rel_id) { |
2282 | 2282 | $new_rel_id = ''; |
2283 | 2283 | } |
2284 | - $GLOBALS['log']->debug('save_relationship_changes(): From relationship_field array - adding a relationship record: ' . $rel_name . ' = ' . $this->$id); |
|
2284 | + $GLOBALS['log']->debug('save_relationship_changes(): From relationship_field array - adding a relationship record: '.$rel_name.' = '.$this->$id); |
|
2285 | 2285 | //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 |
2286 | 2286 | $this->load_relationship($rel_name); |
2287 | 2287 | $rel_add = $this->$rel_name->add($this->$id); |
@@ -2292,7 +2292,7 @@ discard block |
||
2292 | 2292 | } else { |
2293 | 2293 | //if before value is not empty then attempt to delete relationship |
2294 | 2294 | if (!empty($this->rel_fields_before_value[$id])) { |
2295 | - $GLOBALS['log']->debug('save_relationship_changes(): From relationship_field array - attempting to remove the relationship record, using relationship attribute' . $rel_name); |
|
2295 | + $GLOBALS['log']->debug('save_relationship_changes(): From relationship_field array - attempting to remove the relationship record, using relationship attribute'.$rel_name); |
|
2296 | 2296 | $this->load_relationship($rel_name); |
2297 | 2297 | $this->$rel_name->delete($this->id, $this->rel_fields_before_value[$id]); |
2298 | 2298 | } |
@@ -2342,7 +2342,7 @@ discard block |
||
2342 | 2342 | } else { |
2343 | 2343 | $modified_relationships['remove']['failure'][] = $linkField; |
2344 | 2344 | } |
2345 | - $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - attempting to remove the relationship record returned " . var_export($success, true)); |
|
2345 | + $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - attempting to remove the relationship record returned ".var_export($success, true)); |
|
2346 | 2346 | } |
2347 | 2347 | |
2348 | 2348 | if (!empty($this->$idName) && is_string($this->$idName)) { |
@@ -2357,7 +2357,7 @@ discard block |
||
2357 | 2357 | $modified_relationships['add']['failure'][] = $linkField; |
2358 | 2358 | } |
2359 | 2359 | |
2360 | - $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - add a relationship record returned " . var_export($success, true)); |
|
2360 | + $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - add a relationship record returned ".var_export($success, true)); |
|
2361 | 2361 | } |
2362 | 2362 | } else { |
2363 | 2363 | $GLOBALS['log']->fatal("Failed to load relationship {$linkField} while saving {$this->module_dir}"); |
@@ -2741,10 +2741,10 @@ discard block |
||
2741 | 2741 | $template_name = "Default"; |
2742 | 2742 | } |
2743 | 2743 | if (!empty($_SESSION["special_notification"]) && $_SESSION["special_notification"]) { |
2744 | - $template_name = $beanList[$this->module_dir] . 'Special'; |
|
2744 | + $template_name = $beanList[$this->module_dir].'Special'; |
|
2745 | 2745 | } |
2746 | 2746 | if ($this->special_notification) { |
2747 | - $template_name = $beanList[$this->module_dir] . 'Special'; |
|
2747 | + $template_name = $beanList[$this->module_dir].'Special'; |
|
2748 | 2748 | } |
2749 | 2749 | $xtpl->assign("ASSIGNED_USER", $this->new_assigned_user_name); |
2750 | 2750 | $xtpl->assign("ASSIGNER", $current_user->name); |
@@ -2755,17 +2755,17 @@ discard block |
||
2755 | 2755 | $parsedSiteUrl['port'] = 80; |
2756 | 2756 | } |
2757 | 2757 | |
2758 | - $port = ($parsedSiteUrl['port'] != 80) ? ":" . $parsedSiteUrl['port'] : ''; |
|
2758 | + $port = ($parsedSiteUrl['port'] != 80) ? ":".$parsedSiteUrl['port'] : ''; |
|
2759 | 2759 | $path = !empty($parsedSiteUrl['path']) ? $parsedSiteUrl['path'] : ""; |
2760 | 2760 | $cleanUrl = "{$parsedSiteUrl['scheme']}://{$host}{$port}{$path}"; |
2761 | 2761 | |
2762 | - $xtpl->assign("URL", $cleanUrl . "/index.php?module={$this->module_dir}&action=DetailView&record={$this->id}"); |
|
2762 | + $xtpl->assign("URL", $cleanUrl."/index.php?module={$this->module_dir}&action=DetailView&record={$this->id}"); |
|
2763 | 2763 | $xtpl->assign("SUGAR", "Sugar v{$sugar_version}"); |
2764 | 2764 | $xtpl->parse($template_name); |
2765 | - $xtpl->parse($template_name . "_Subject"); |
|
2765 | + $xtpl->parse($template_name."_Subject"); |
|
2766 | 2766 | |
2767 | 2767 | $notify_mail->Body = from_html(trim($xtpl->text($template_name))); |
2768 | - $notify_mail->Subject = from_html($xtpl->text($template_name . "_Subject")); |
|
2768 | + $notify_mail->Subject = from_html($xtpl->text($template_name."_Subject")); |
|
2769 | 2769 | |
2770 | 2770 | // cn: bug 8568 encode notify email in User's outbound email encoding |
2771 | 2771 | $notify_mail->prepForOutbound(); |
@@ -2857,7 +2857,7 @@ discard block |
||
2857 | 2857 | if (empty($where)) { |
2858 | 2858 | $where = $owner_where; |
2859 | 2859 | } else { |
2860 | - $where .= ' AND ' . $owner_where; |
|
2860 | + $where .= ' AND '.$owner_where; |
|
2861 | 2861 | } |
2862 | 2862 | } |
2863 | 2863 | } |
@@ -2911,7 +2911,7 @@ discard block |
||
2911 | 2911 | if (empty($where)) { |
2912 | 2912 | $where = $owner_where; |
2913 | 2913 | } else { |
2914 | - $where .= ' AND ' . $owner_where; |
|
2914 | + $where .= ' AND '.$owner_where; |
|
2915 | 2915 | } |
2916 | 2916 | } |
2917 | 2917 | /* BEGIN - SECURITY GROUPS */ |
@@ -2925,9 +2925,9 @@ discard block |
||
2925 | 2925 | $group_where = SecurityGroup::getGroupUsersWhere($current_user->id); |
2926 | 2926 | //$group_where = "user_name = 'admin'"; |
2927 | 2927 | if (empty($where)) { |
2928 | - $where = " (" . $group_where . ") "; |
|
2928 | + $where = " (".$group_where.") "; |
|
2929 | 2929 | } else { |
2930 | - $where .= " AND (" . $group_where . ") "; |
|
2930 | + $where .= " AND (".$group_where.") "; |
|
2931 | 2931 | } |
2932 | 2932 | } elseif ($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list')) { |
2933 | 2933 | require_once('modules/SecurityGroups/SecurityGroup.php'); |
@@ -2936,12 +2936,12 @@ discard block |
||
2936 | 2936 | $group_where = SecurityGroup::getGroupWhere($this->table_name, $this->module_dir, $current_user->id); |
2937 | 2937 | if (!empty($owner_where)) { |
2938 | 2938 | if (empty($where)) { |
2939 | - $where = " (" . $owner_where . " or " . $group_where . ") "; |
|
2939 | + $where = " (".$owner_where." or ".$group_where.") "; |
|
2940 | 2940 | } else { |
2941 | - $where .= " AND (" . $owner_where . " or " . $group_where . ") "; |
|
2941 | + $where .= " AND (".$owner_where." or ".$group_where.") "; |
|
2942 | 2942 | } |
2943 | 2943 | } else { |
2944 | - $where .= ' AND ' . $group_where; |
|
2944 | + $where .= ' AND '.$group_where; |
|
2945 | 2945 | } |
2946 | 2946 | } |
2947 | 2947 | /* END - SECURITY GROUPS */ |
@@ -2960,7 +2960,7 @@ discard block |
||
2960 | 2960 | $ret_array['order_by'] = ''; |
2961 | 2961 | //secondary selects are selects that need to be run after the primary query to retrieve additional info on main |
2962 | 2962 | if ($singleSelect) { |
2963 | - $ret_array['secondary_select'] =& $ret_array['select']; |
|
2963 | + $ret_array['secondary_select'] = & $ret_array['select']; |
|
2964 | 2964 | $ret_array['secondary_from'] = &$ret_array['from']; |
2965 | 2965 | } else { |
2966 | 2966 | $ret_array['secondary_select'] = ''; |
@@ -3034,7 +3034,7 @@ discard block |
||
3034 | 3034 | //alias is used to alias field names |
3035 | 3035 | $alias = ''; |
3036 | 3036 | if (isset($value['alias'])) { |
3037 | - $alias = ' as ' . $value['alias'] . ' '; |
|
3037 | + $alias = ' as '.$value['alias'].' '; |
|
3038 | 3038 | } |
3039 | 3039 | |
3040 | 3040 | if (empty($this->field_defs[$field]) || !empty($value['force_blank'])) { |
@@ -3073,29 +3073,29 @@ discard block |
||
3073 | 3073 | $selectedFields["$this->table_name.$field"] = true; |
3074 | 3074 | } elseif ((!isset($data['source']) || $data['source'] == 'custom_fields') && (!empty($alias) || !empty($filter))) { |
3075 | 3075 | //add this column only if it has NOT already been added to select statement string |
3076 | - $colPos = strpos($ret_array['select'], "$this->table_name" . "_cstm" . ".$field"); |
|
3076 | + $colPos = strpos($ret_array['select'], "$this->table_name"."_cstm".".$field"); |
|
3077 | 3077 | if (!$colPos || $colPos < 0) { |
3078 | - $ret_array['select'] .= ", $this->table_name" . "_cstm" . ".$field $alias"; |
|
3078 | + $ret_array['select'] .= ", $this->table_name"."_cstm".".$field $alias"; |
|
3079 | 3079 | } |
3080 | 3080 | |
3081 | 3081 | $selectedFields["$this->table_name.$field"] = true; |
3082 | 3082 | } |
3083 | 3083 | |
3084 | 3084 | if ($data['type'] != 'relate' && isset($data['db_concat_fields'])) { |
3085 | - $ret_array['select'] .= ", " . $this->db->concat($this->table_name, $data['db_concat_fields']) . " as $field"; |
|
3085 | + $ret_array['select'] .= ", ".$this->db->concat($this->table_name, $data['db_concat_fields'])." as $field"; |
|
3086 | 3086 | $selectedFields[$this->db->concat($this->table_name, $data['db_concat_fields'])] = true; |
3087 | 3087 | } |
3088 | 3088 | //Custom relate field or relate fields built in module builder which have no link field associated. |
3089 | 3089 | if ($data['type'] == 'relate' && (isset($data['custom_module']) || isset($data['ext2']))) { |
3090 | - $joinTableAlias = 'jt' . $jtcount; |
|
3090 | + $joinTableAlias = 'jt'.$jtcount; |
|
3091 | 3091 | $relateJoinInfo = $this->custom_fields->getRelateJoin($data, $joinTableAlias, false); |
3092 | 3092 | $ret_array['select'] .= $relateJoinInfo['select']; |
3093 | 3093 | $ret_array['from'] .= $relateJoinInfo['from']; |
3094 | 3094 | //Replace any references to the relationship in the where clause with the new alias |
3095 | 3095 | //If the link isn't set, assume that search used the local table for the field |
3096 | 3096 | $searchTable = isset($data['link']) ? $relateJoinInfo['rel_table'] : $this->table_name; |
3097 | - $field_name = $relateJoinInfo['rel_table'] . '.' . !empty($data['name']) ? $data['name'] : 'name'; |
|
3098 | - $where = preg_replace('/(^|[\s(])' . $field_name . '/', '${1}' . $relateJoinInfo['name_field'], $where); |
|
3097 | + $field_name = $relateJoinInfo['rel_table'].'.'.!empty($data['name']) ? $data['name'] : 'name'; |
|
3098 | + $where = preg_replace('/(^|[\s(])'.$field_name.'/', '${1}'.$relateJoinInfo['name_field'], $where); |
|
3099 | 3099 | $jtcount++; |
3100 | 3100 | } |
3101 | 3101 | //Parent Field |
@@ -3103,7 +3103,7 @@ discard block |
||
3103 | 3103 | //See if we need to join anything by inspecting the where clause |
3104 | 3104 | $match = preg_match('/(^|[\s(])parent_([a-zA-Z]+_?[a-zA-Z]+)_([a-zA-Z]+_?[a-zA-Z]+)\.name/', $where, $matches); |
3105 | 3105 | if ($match) { |
3106 | - $joinTableAlias = 'jt' . $jtcount; |
|
3106 | + $joinTableAlias = 'jt'.$jtcount; |
|
3107 | 3107 | $joinModule = $matches[2]; |
3108 | 3108 | $joinTable = $matches[3]; |
3109 | 3109 | $localTable = $this->table_name; |
@@ -3124,7 +3124,7 @@ discard block |
||
3124 | 3124 | $ret_array['from'] .= " LEFT JOIN $joinTable $joinTableAlias |
3125 | 3125 | ON $localTable.{$data['id_name']} = $joinTableAlias.id"; |
3126 | 3126 | //Replace any references to the relationship in the where clause with the new alias |
3127 | - $where = preg_replace('/(^|[\s(])parent_' . $joinModule . '_' . $joinTable . '\.name/', '${1}' . $nameField, $where); |
|
3127 | + $where = preg_replace('/(^|[\s(])parent_'.$joinModule.'_'.$joinTable.'\.name/', '${1}'.$nameField, $where); |
|
3128 | 3128 | $jtcount++; |
3129 | 3129 | } |
3130 | 3130 | } |
@@ -3133,7 +3133,7 @@ discard block |
||
3133 | 3133 | { |
3134 | 3134 | $linkField = $data['link']; |
3135 | 3135 | $this->load_relationship($linkField); |
3136 | - if(!empty($this->$linkField)) |
|
3136 | + if (!empty($this->$linkField)) |
|
3137 | 3137 | { |
3138 | 3138 | $params = array(); |
3139 | 3139 | if (empty($join_type)) { |
@@ -3144,12 +3144,12 @@ discard block |
||
3144 | 3144 | if (isset($data['join_name'])) { |
3145 | 3145 | $params['join_table_alias'] = $data['join_name']; |
3146 | 3146 | } else { |
3147 | - $params['join_table_alias'] = 'jt' . $jtcount; |
|
3147 | + $params['join_table_alias'] = 'jt'.$jtcount; |
|
3148 | 3148 | } |
3149 | 3149 | if (isset($data['join_link_name'])) { |
3150 | 3150 | $params['join_table_link_alias'] = $data['join_link_name']; |
3151 | 3151 | } else { |
3152 | - $params['join_table_link_alias'] = 'jtl' . $jtcount; |
|
3152 | + $params['join_table_link_alias'] = 'jtl'.$jtcount; |
|
3153 | 3153 | } |
3154 | 3154 | $join_primary = !isset($data['join_primary']) || $data['join_primary']; |
3155 | 3155 | |
@@ -3182,20 +3182,20 @@ discard block |
||
3182 | 3182 | require_once($beanFiles[$beanList[$rel_module]]); |
3183 | 3183 | $rel_mod = new $beanList[$rel_module](); |
3184 | 3184 | if (isset($rel_mod->field_defs['assigned_user_id'])) { |
3185 | - $ret_array['secondary_select'] .= " , " . $params['join_table_alias'] . ".assigned_user_id {$field}_owner, '$rel_module' {$field}_mod"; |
|
3185 | + $ret_array['secondary_select'] .= " , ".$params['join_table_alias'].".assigned_user_id {$field}_owner, '$rel_module' {$field}_mod"; |
|
3186 | 3186 | } else { |
3187 | 3187 | if (isset($rel_mod->field_defs['created_by'])) { |
3188 | - $ret_array['secondary_select'] .= " , " . $params['join_table_alias'] . ".created_by {$field}_owner , '$rel_module' {$field}_mod"; |
|
3188 | + $ret_array['secondary_select'] .= " , ".$params['join_table_alias'].".created_by {$field}_owner , '$rel_module' {$field}_mod"; |
|
3189 | 3189 | } |
3190 | 3190 | } |
3191 | 3191 | } |
3192 | 3192 | } |
3193 | 3193 | |
3194 | 3194 | if (isset($data['db_concat_fields'])) { |
3195 | - $ret_array['secondary_select'] .= ' , ' . $this->db->concat($params['join_table_alias'], $data['db_concat_fields']) . ' ' . $field; |
|
3195 | + $ret_array['secondary_select'] .= ' , '.$this->db->concat($params['join_table_alias'], $data['db_concat_fields']).' '.$field; |
|
3196 | 3196 | } else { |
3197 | 3197 | if (!isset($data['relationship_fields'])) { |
3198 | - $ret_array['secondary_select'] .= ' , ' . $params['join_table_alias'] . '.' . $data['rname'] . ' ' . $field; |
|
3198 | + $ret_array['secondary_select'] .= ' , '.$params['join_table_alias'].'.'.$data['rname'].' '.$field; |
|
3199 | 3199 | } |
3200 | 3200 | } |
3201 | 3201 | if (!$singleSelect) { |
@@ -3211,54 +3211,54 @@ discard block |
||
3211 | 3211 | //27416, the $ret_array['secondary_select'] should always generate, regardless the dbtype |
3212 | 3212 | // add rel_key only if it was not already added |
3213 | 3213 | if (!$singleSelect) { |
3214 | - $ret_array['select'] .= ", ' ' " . $join['rel_key'] . ' '; |
|
3214 | + $ret_array['select'] .= ", ' ' ".$join['rel_key'].' '; |
|
3215 | 3215 | } |
3216 | - $ret_array['secondary_select'] .= ', ' . $params['join_table_link_alias'] . '.' . $join['rel_key'] . ' ' . $join['rel_key']; |
|
3216 | + $ret_array['secondary_select'] .= ', '.$params['join_table_link_alias'].'.'.$join['rel_key'].' '.$join['rel_key']; |
|
3217 | 3217 | } |
3218 | 3218 | if (isset($data['relationship_fields'])) { |
3219 | 3219 | foreach ($data['relationship_fields'] as $r_name => $alias_name) { |
3220 | 3220 | if (!empty($secondarySelectedFields[$alias_name])) { |
3221 | 3221 | continue; |
3222 | 3222 | } |
3223 | - $ret_array['secondary_select'] .= ', ' . $params['join_table_link_alias'] . '.' . $r_name . ' ' . $alias_name; |
|
3223 | + $ret_array['secondary_select'] .= ', '.$params['join_table_link_alias'].'.'.$r_name.' '.$alias_name; |
|
3224 | 3224 | $secondarySelectedFields[$alias_name] = true; |
3225 | 3225 | } |
3226 | 3226 | } |
3227 | 3227 | if (!$table_joined) { |
3228 | - $ret_array['secondary_from'] .= ' ' . $join['join'] . ' AND ' . $params['join_table_alias'] . '.deleted=0'; |
|
3228 | + $ret_array['secondary_from'] .= ' '.$join['join'].' AND '.$params['join_table_alias'].'.deleted=0'; |
|
3229 | 3229 | if (isset($data['link_type']) && $data['link_type'] == 'relationship_info' && ($parentbean instanceof SugarBean)) { |
3230 | - $ret_array['secondary_where'] = $params['join_table_link_alias'] . '.' . $join['rel_key'] . "='" . $parentbean->id . "'"; |
|
3230 | + $ret_array['secondary_where'] = $params['join_table_link_alias'].'.'.$join['rel_key']."='".$parentbean->id."'"; |
|
3231 | 3231 | } |
3232 | 3232 | } |
3233 | 3233 | } else { |
3234 | 3234 | if (isset($data['db_concat_fields'])) { |
3235 | - $ret_array['select'] .= ' , ' . $this->db->concat($params['join_table_alias'], $data['db_concat_fields']) . ' ' . $field; |
|
3235 | + $ret_array['select'] .= ' , '.$this->db->concat($params['join_table_alias'], $data['db_concat_fields']).' '.$field; |
|
3236 | 3236 | } else { |
3237 | - $ret_array['select'] .= ' , ' . $params['join_table_alias'] . '.' . $data['rname'] . ' ' . $field; |
|
3237 | + $ret_array['select'] .= ' , '.$params['join_table_alias'].'.'.$data['rname'].' '.$field; |
|
3238 | 3238 | } |
3239 | 3239 | if (isset($data['additionalFields'])) { |
3240 | 3240 | foreach ($data['additionalFields'] as $k => $v) { |
3241 | 3241 | if (!empty($data['id_name']) && $data['id_name'] == $v && !empty($fields[$data['id_name']])) { |
3242 | 3242 | continue; |
3243 | 3243 | } |
3244 | - $ret_array['select'] .= ' , ' . $params['join_table_alias'] . '.' . $k . ' ' . $v; |
|
3244 | + $ret_array['select'] .= ' , '.$params['join_table_alias'].'.'.$k.' '.$v; |
|
3245 | 3245 | } |
3246 | 3246 | } |
3247 | 3247 | if (!$table_joined) { |
3248 | - $ret_array['from'] .= ' ' . $join['join'] . ' AND ' . $params['join_table_alias'] . '.deleted=0'; |
|
3248 | + $ret_array['from'] .= ' '.$join['join'].' AND '.$params['join_table_alias'].'.deleted=0'; |
|
3249 | 3249 | if (!empty($beanList[$rel_module]) && !empty($beanFiles[$beanList[$rel_module]])) { |
3250 | 3250 | require_once($beanFiles[$beanList[$rel_module]]); |
3251 | 3251 | $rel_mod = new $beanList[$rel_module](); |
3252 | 3252 | if (isset($value['target_record_key']) && !empty($filter)) { |
3253 | - $selectedFields[$this->table_name . '.' . $value['target_record_key']] = true; |
|
3253 | + $selectedFields[$this->table_name.'.'.$value['target_record_key']] = true; |
|
3254 | 3254 | $ret_array['select'] .= " , $this->table_name.{$value['target_record_key']} "; |
3255 | 3255 | } |
3256 | 3256 | if (isset($rel_mod->field_defs['assigned_user_id'])) { |
3257 | - $ret_array['select'] .= ' , ' . $params['join_table_alias'] . '.assigned_user_id ' . $field . '_owner'; |
|
3257 | + $ret_array['select'] .= ' , '.$params['join_table_alias'].'.assigned_user_id '.$field.'_owner'; |
|
3258 | 3258 | } else { |
3259 | - $ret_array['select'] .= ' , ' . $params['join_table_alias'] . '.created_by ' . $field . '_owner'; |
|
3259 | + $ret_array['select'] .= ' , '.$params['join_table_alias'].'.created_by '.$field.'_owner'; |
|
3260 | 3260 | } |
3261 | - $ret_array['select'] .= " , '" . $rel_module . "' " . $field . '_mod'; |
|
3261 | + $ret_array['select'] .= " , '".$rel_module."' ".$field.'_mod'; |
|
3262 | 3262 | } |
3263 | 3263 | } |
3264 | 3264 | } |
@@ -3268,37 +3268,37 @@ discard block |
||
3268 | 3268 | if (isset($data['db_concat_fields'])) { |
3269 | 3269 | $buildWhere = false; |
3270 | 3270 | if (in_array('first_name', $data['db_concat_fields']) && in_array('last_name', $data['db_concat_fields'])) { |
3271 | - $exp = '/\(\s*?' . $data['name'] . '.*?\%\'\s*?\)/'; |
|
3271 | + $exp = '/\(\s*?'.$data['name'].'.*?\%\'\s*?\)/'; |
|
3272 | 3272 | if (preg_match($exp, $where, $matches)) { |
3273 | 3273 | $search_expression = $matches[0]; |
3274 | 3274 | //Create three search conditions - first + last, first, last |
3275 | - $first_name_search = str_replace($data['name'], $params['join_table_alias'] . '.first_name', $search_expression); |
|
3276 | - $last_name_search = str_replace($data['name'], $params['join_table_alias'] . '.last_name', $search_expression); |
|
3275 | + $first_name_search = str_replace($data['name'], $params['join_table_alias'].'.first_name', $search_expression); |
|
3276 | + $last_name_search = str_replace($data['name'], $params['join_table_alias'].'.last_name', $search_expression); |
|
3277 | 3277 | $full_name_search = str_replace($data['name'], $this->db->concat($params['join_table_alias'], $data['db_concat_fields']), $search_expression); |
3278 | 3278 | $buildWhere = true; |
3279 | - $where = str_replace($search_expression, '(' . $full_name_search . ' OR ' . $first_name_search . ' OR ' . $last_name_search . ')', $where); |
|
3279 | + $where = str_replace($search_expression, '('.$full_name_search.' OR '.$first_name_search.' OR '.$last_name_search.')', $where); |
|
3280 | 3280 | } |
3281 | 3281 | } |
3282 | 3282 | |
3283 | 3283 | if (!$buildWhere) { |
3284 | 3284 | $db_field = $this->db->concat($params['join_table_alias'], $data['db_concat_fields']); |
3285 | - $where = preg_replace('/' . $data['name'] . '/', $db_field, $where); |
|
3285 | + $where = preg_replace('/'.$data['name'].'/', $db_field, $where); |
|
3286 | 3286 | |
3287 | 3287 | // For relationship fields replace their alias by the corresponding link table and r_name |
3288 | 3288 | if (isset($data['relationship_fields'])) { |
3289 | 3289 | foreach ($data['relationship_fields'] as $r_name => $alias_name) { |
3290 | 3290 | $db_field = $this->db->concat($params['join_table_link_alias'], $r_name); |
3291 | - $where = preg_replace('/' . $alias_name . '/', $db_field, $where); |
|
3291 | + $where = preg_replace('/'.$alias_name.'/', $db_field, $where); |
|
3292 | 3292 | } |
3293 | 3293 | } |
3294 | 3294 | } |
3295 | 3295 | } else { |
3296 | - $where = preg_replace('/(^|[\s(])' . $data['name'] . '/', '${1}' . $params['join_table_alias'] . '.' . $data['rname'], $where); |
|
3296 | + $where = preg_replace('/(^|[\s(])'.$data['name'].'/', '${1}'.$params['join_table_alias'].'.'.$data['rname'], $where); |
|
3297 | 3297 | |
3298 | 3298 | // For relationship fields replace their alias by the corresponding link table and r_name |
3299 | 3299 | if (isset($data['relationship_fields'])) { |
3300 | 3300 | foreach ($data['relationship_fields'] as $r_name => $alias_name) { |
3301 | - $where = preg_replace('/(^|[\s(])' . $alias_name . '/', '${1}' . $params['join_table_link_alias'] . '.' . $r_name, $where); |
|
3301 | + $where = preg_replace('/(^|[\s(])'.$alias_name.'/', '${1}'.$params['join_table_link_alias'].'.'.$r_name, $where); |
|
3302 | 3302 | } |
3303 | 3303 | } |
3304 | 3304 | } |
@@ -3312,12 +3312,12 @@ discard block |
||
3312 | 3312 | } |
3313 | 3313 | } |
3314 | 3314 | if (!empty($filter)) { |
3315 | - if (isset($this->field_defs['assigned_user_id']) && empty($selectedFields[$this->table_name . '.assigned_user_id'])) { |
|
3315 | + if (isset($this->field_defs['assigned_user_id']) && empty($selectedFields[$this->table_name.'.assigned_user_id'])) { |
|
3316 | 3316 | $ret_array['select'] .= ", $this->table_name.assigned_user_id "; |
3317 | - } elseif (isset($this->field_defs['created_by']) && empty($selectedFields[$this->table_name . '.created_by'])) { |
|
3317 | + } elseif (isset($this->field_defs['created_by']) && empty($selectedFields[$this->table_name.'.created_by'])) { |
|
3318 | 3318 | $ret_array['select'] .= ", $this->table_name.created_by "; |
3319 | 3319 | } |
3320 | - if (isset($this->field_defs['system_id']) && empty($selectedFields[$this->table_name . '.system_id'])) { |
|
3320 | + if (isset($this->field_defs['system_id']) && empty($selectedFields[$this->table_name.'.system_id'])) { |
|
3321 | 3321 | $ret_array['select'] .= ", $this->table_name.system_id "; |
3322 | 3322 | } |
3323 | 3323 | } |
@@ -3344,7 +3344,7 @@ discard block |
||
3344 | 3344 | //make call to process the order by clause |
3345 | 3345 | $order_by = $this->process_order_by($order_by); |
3346 | 3346 | if (!empty($order_by)) { |
3347 | - $ret_array['order_by'] = " ORDER BY " . $order_by; |
|
3347 | + $ret_array['order_by'] = " ORDER BY ".$order_by; |
|
3348 | 3348 | } |
3349 | 3349 | if ($singleSelect) { |
3350 | 3350 | unset($ret_array['secondary_where']); |
@@ -3356,7 +3356,7 @@ discard block |
||
3356 | 3356 | return $ret_array; |
3357 | 3357 | } |
3358 | 3358 | |
3359 | - return $ret_array['select'] . $ret_array['from'] . $ret_array['where'] . $ret_array['order_by']; |
|
3359 | + return $ret_array['select'].$ret_array['from'].$ret_array['where'].$ret_array['order_by']; |
|
3360 | 3360 | } |
3361 | 3361 | |
3362 | 3362 | public function get_relationship_field($field) |
@@ -3431,9 +3431,9 @@ discard block |
||
3431 | 3431 | |
3432 | 3432 | if (empty($field_defs['table']) && !$suppress_table_name) { |
3433 | 3433 | if ($source == 'db') { |
3434 | - $list_column[0] = $bean_queried->table_name . '.' . $list_column[0]; |
|
3434 | + $list_column[0] = $bean_queried->table_name.'.'.$list_column[0]; |
|
3435 | 3435 | } elseif ($source == 'custom_fields') { |
3436 | - $list_column[0] = $bean_queried->table_name . '_cstm.' . $list_column[0]; |
|
3436 | + $list_column[0] = $bean_queried->table_name.'_cstm.'.$list_column[0]; |
|
3437 | 3437 | } |
3438 | 3438 | } |
3439 | 3439 | |
@@ -3489,7 +3489,7 @@ discard block |
||
3489 | 3489 | * if the row_offset is set to 'end' go to the end of the list |
3490 | 3490 | */ |
3491 | 3491 | $toEnd = strval($row_offset) == 'end'; |
3492 | - $GLOBALS['log']->debug("process_list_query: " . $query); |
|
3492 | + $GLOBALS['log']->debug("process_list_query: ".$query); |
|
3493 | 3493 | if ($max_per_page == -1) { |
3494 | 3494 | $max_per_page = $sugar_config['list_max_entries_per_page']; |
3495 | 3495 | } |
@@ -3548,14 +3548,14 @@ discard block |
||
3548 | 3548 | foreach ($this->field_defs as $field => $value) { |
3549 | 3549 | if (isset($row[$field])) { |
3550 | 3550 | $temp->$field = $row[$field]; |
3551 | - $owner_field = $field . '_owner'; |
|
3551 | + $owner_field = $field.'_owner'; |
|
3552 | 3552 | if (isset($row[$owner_field])) { |
3553 | 3553 | $temp->$owner_field = $row[$owner_field]; |
3554 | 3554 | } |
3555 | 3555 | |
3556 | - $GLOBALS['log']->debug("$temp->object_name({$row['id']}): " . $field . " = " . $temp->$field); |
|
3557 | - } elseif (isset($row[$this->table_name . '.' . $field])) { |
|
3558 | - $temp->$field = $row[$this->table_name . '.' . $field]; |
|
3556 | + $GLOBALS['log']->debug("$temp->object_name({$row['id']}): ".$field." = ".$temp->$field); |
|
3557 | + } elseif (isset($row[$this->table_name.'.'.$field])) { |
|
3558 | + $temp->$field = $row[$this->table_name.'.'.$field]; |
|
3559 | 3559 | } else { |
3560 | 3560 | $temp->$field = ""; |
3561 | 3561 | } |
@@ -3608,22 +3608,22 @@ discard block |
||
3608 | 3608 | public function create_list_count_query($query) |
3609 | 3609 | { |
3610 | 3610 | // remove the 'order by' clause which is expected to be at the end of the query |
3611 | - $pattern = '/\sORDER BY.*/is'; // ignores the case |
|
3611 | + $pattern = '/\sORDER BY.*/is'; // ignores the case |
|
3612 | 3612 | $replacement = ''; |
3613 | 3613 | $query = preg_replace($pattern, $replacement, $query); |
3614 | 3614 | //handle distinct clause |
3615 | 3615 | $star = '*'; |
3616 | 3616 | if (substr_count(strtolower($query), 'distinct')) { |
3617 | 3617 | if (!empty($this->seed) && !empty($this->seed->table_name)) { |
3618 | - $star = 'DISTINCT ' . $this->seed->table_name . '.id'; |
|
3618 | + $star = 'DISTINCT '.$this->seed->table_name.'.id'; |
|
3619 | 3619 | } else { |
3620 | - $star = 'DISTINCT ' . $this->table_name . '.id'; |
|
3620 | + $star = 'DISTINCT '.$this->table_name.'.id'; |
|
3621 | 3621 | } |
3622 | 3622 | } |
3623 | 3623 | |
3624 | 3624 | // change the select expression to 'count(*)' |
3625 | - $pattern = '/SELECT(.*?)(\s){1}FROM(\s){1}/is'; // ignores the case |
|
3626 | - $replacement = 'SELECT count(' . $star . ') c FROM '; |
|
3625 | + $pattern = '/SELECT(.*?)(\s){1}FROM(\s){1}/is'; // ignores the case |
|
3626 | + $replacement = 'SELECT count('.$star.') c FROM '; |
|
3627 | 3627 | |
3628 | 3628 | //if the passed query has union clause then replace all instances of the pattern. |
3629 | 3629 | //this is very rare. I have seen this happening only from projects module. |
@@ -3639,13 +3639,13 @@ discard block |
||
3639 | 3639 | if (!empty($matches)) { |
3640 | 3640 | if (stristr($matches[0], "distinct")) { |
3641 | 3641 | if (!empty($this->seed) && !empty($this->seed->table_name)) { |
3642 | - $star = 'DISTINCT ' . $this->seed->table_name . '.id'; |
|
3642 | + $star = 'DISTINCT '.$this->seed->table_name.'.id'; |
|
3643 | 3643 | } else { |
3644 | - $star = 'DISTINCT ' . $this->table_name . '.id'; |
|
3644 | + $star = 'DISTINCT '.$this->table_name.'.id'; |
|
3645 | 3645 | } |
3646 | 3646 | } |
3647 | 3647 | } // if |
3648 | - $replacement = 'SELECT count(' . $star . ') c FROM '; |
|
3648 | + $replacement = 'SELECT count('.$star.') c FROM '; |
|
3649 | 3649 | $union_qs[$key] = preg_replace($pattern, $replacement, $union_query, 1); |
3650 | 3650 | } |
3651 | 3651 | $modified_select_query = implode(" UNION ALL ", $union_qs); |
@@ -3711,7 +3711,7 @@ discard block |
||
3711 | 3711 | if (empty($where)) { |
3712 | 3712 | $where = $owner_where; |
3713 | 3713 | } else { |
3714 | - $where .= ' AND ' . $owner_where; |
|
3714 | + $where .= ' AND '.$owner_where; |
|
3715 | 3715 | } |
3716 | 3716 | } |
3717 | 3717 | |
@@ -3723,12 +3723,12 @@ discard block |
||
3723 | 3723 | $group_where = SecurityGroup::getGroupWhere($this->table_name, $this->module_dir, $current_user->id); |
3724 | 3724 | if (!empty($owner_where)) { |
3725 | 3725 | if (empty($where)) { |
3726 | - $where = " (" . $owner_where . " or " . $group_where . ") "; |
|
3726 | + $where = " (".$owner_where." or ".$group_where.") "; |
|
3727 | 3727 | } else { |
3728 | - $where .= " AND (" . $owner_where . " or " . $group_where . ") "; |
|
3728 | + $where .= " AND (".$owner_where." or ".$group_where.") "; |
|
3729 | 3729 | } |
3730 | 3730 | } else { |
3731 | - $where .= ' AND ' . $group_where; |
|
3731 | + $where .= ' AND '.$group_where; |
|
3732 | 3732 | } |
3733 | 3733 | } |
3734 | 3734 | /* END - SECURITY GROUPS */ |
@@ -3757,7 +3757,7 @@ discard block |
||
3757 | 3757 | public function process_detail_query($query, $row_offset, $limit = -1, $max_per_page = -1, $where = '', $offset = 0) |
3758 | 3758 | { |
3759 | 3759 | global $sugar_config; |
3760 | - $GLOBALS['log']->debug("process_detail_query: " . $query); |
|
3760 | + $GLOBALS['log']->debug("process_detail_query: ".$query); |
|
3761 | 3761 | if ($max_per_page == -1) { |
3762 | 3762 | $max_per_page = $sugar_config['list_max_entries_per_page']; |
3763 | 3763 | } |
@@ -3823,14 +3823,14 @@ discard block |
||
3823 | 3823 | } |
3824 | 3824 | $custom_join = $this->getCustomJoin(); |
3825 | 3825 | |
3826 | - $query = "SELECT $this->table_name.*" . $custom_join['select'] . " FROM $this->table_name "; |
|
3826 | + $query = "SELECT $this->table_name.*".$custom_join['select']." FROM $this->table_name "; |
|
3827 | 3827 | |
3828 | 3828 | $query .= $custom_join['join']; |
3829 | - $query .= " WHERE $this->table_name.id = " . $this->db->quoted($id); |
|
3829 | + $query .= " WHERE $this->table_name.id = ".$this->db->quoted($id); |
|
3830 | 3830 | if ($deleted) { |
3831 | 3831 | $query .= " AND $this->table_name.deleted=0"; |
3832 | 3832 | } |
3833 | - $GLOBALS['log']->debug("Retrieve $this->object_name : " . $query); |
|
3833 | + $GLOBALS['log']->debug("Retrieve $this->object_name : ".$query); |
|
3834 | 3834 | $result = $this->db->limitQuery($query, 0, 1, true, "Retrieving record by id $this->table_name:$id found "); |
3835 | 3835 | if (empty($result)) { |
3836 | 3836 | return null; |
@@ -3981,7 +3981,7 @@ discard block |
||
3981 | 3981 | } |
3982 | 3982 | if (isset($row[$field])) { |
3983 | 3983 | $this->$field = $row[$field]; |
3984 | - $owner = $field . '_owner'; |
|
3984 | + $owner = $field.'_owner'; |
|
3985 | 3985 | if (!empty($row[$owner])) { |
3986 | 3986 | $this->$owner = $row[$owner]; |
3987 | 3987 | } |
@@ -4178,12 +4178,12 @@ discard block |
||
4178 | 4178 | $query = 'SELECT id'; |
4179 | 4179 | foreach ($fields as $field => $alias) { |
4180 | 4180 | if (!empty($GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields'])) { |
4181 | - $query .= ' ,' . $this->db->concat($table, $GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields']) . ' as ' . $alias; |
|
4181 | + $query .= ' ,'.$this->db->concat($table, $GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields']).' as '.$alias; |
|
4182 | 4182 | } elseif (!empty($GLOBALS['dictionary'][$object]['fields'][$field]) && |
4183 | 4183 | (empty($GLOBALS['dictionary'][$object]['fields'][$field]['source']) || |
4184 | 4184 | $GLOBALS['dictionary'][$object]['fields'][$field]['source'] != "non-db") |
4185 | 4185 | ) { |
4186 | - $query .= ' ,' . $table . '.' . $field . ' as ' . $alias; |
|
4186 | + $query .= ' ,'.$table.'.'.$field.' as '.$alias; |
|
4187 | 4187 | } |
4188 | 4188 | if (!$return_array) { |
4189 | 4189 | $this->$alias = ''; |
@@ -4195,12 +4195,12 @@ discard block |
||
4195 | 4195 | |
4196 | 4196 | |
4197 | 4197 | if (isset($GLOBALS['dictionary'][$object]['fields']['assigned_user_id'])) { |
4198 | - $query .= " , " . $table . ".assigned_user_id owner"; |
|
4198 | + $query .= " , ".$table.".assigned_user_id owner"; |
|
4199 | 4199 | } elseif (isset($GLOBALS['dictionary'][$object]['fields']['created_by'])) { |
4200 | - $query .= " , " . $table . ".created_by owner"; |
|
4200 | + $query .= " , ".$table.".created_by owner"; |
|
4201 | 4201 | } |
4202 | - $query .= ' FROM ' . $table . ' WHERE deleted=0 AND id='; |
|
4203 | - $result = $GLOBALS['db']->query($query . "'$id'"); |
|
4202 | + $query .= ' FROM '.$table.' WHERE deleted=0 AND id='; |
|
4203 | + $result = $GLOBALS['db']->query($query."'$id'"); |
|
4204 | 4204 | $row = $GLOBALS['db']->fetchByAssoc($result); |
4205 | 4205 | if ($return_array) { |
4206 | 4206 | return $row; |
@@ -4208,9 +4208,9 @@ discard block |
||
4208 | 4208 | $owner = (empty($row['owner'])) ? '' : $row['owner']; |
4209 | 4209 | foreach ($fields as $alias) { |
4210 | 4210 | $this->$alias = (!empty($row[$alias])) ? $row[$alias] : ''; |
4211 | - $alias = $alias . '_owner'; |
|
4211 | + $alias = $alias.'_owner'; |
|
4212 | 4212 | $this->$alias = $owner; |
4213 | - $a_mod = $alias . '_mod'; |
|
4213 | + $a_mod = $alias.'_mod'; |
|
4214 | 4214 | $this->$a_mod = $module; |
4215 | 4215 | } |
4216 | 4216 | } |
@@ -4370,15 +4370,15 @@ discard block |
||
4370 | 4370 | $entire_where = $query_array['where']; |
4371 | 4371 | if (!empty($where)) { |
4372 | 4372 | if (empty($entire_where)) { |
4373 | - $entire_where = ' WHERE ' . $where; |
|
4373 | + $entire_where = ' WHERE '.$where; |
|
4374 | 4374 | } else { |
4375 | - $entire_where .= ' AND ' . $where; |
|
4375 | + $entire_where .= ' AND '.$where; |
|
4376 | 4376 | } |
4377 | 4377 | } |
4378 | 4378 | |
4379 | - $query = 'SELECT ' . $child_seed->table_name . '.* ' . $query_array['from'] . ' ' . $entire_where; |
|
4379 | + $query = 'SELECT '.$child_seed->table_name.'.* '.$query_array['from'].' '.$entire_where; |
|
4380 | 4380 | if (!empty($order_by)) { |
4381 | - $query .= " ORDER BY " . $order_by; |
|
4381 | + $query .= " ORDER BY ".$order_by; |
|
4382 | 4382 | } |
4383 | 4383 | |
4384 | 4384 | return $child_seed->process_list_query($query, $row_offset, $limit, $max, $where); |
@@ -4414,9 +4414,9 @@ discard block |
||
4414 | 4414 | */ |
4415 | 4415 | public function process_full_list_query($query, $check_date = false) |
4416 | 4416 | { |
4417 | - $GLOBALS['log']->debug("process_full_list_query: query is " . $query); |
|
4417 | + $GLOBALS['log']->debug("process_full_list_query: query is ".$query); |
|
4418 | 4418 | $result = $this->db->query($query, false); |
4419 | - $GLOBALS['log']->debug("process_full_list_query: result is " . print_r($result, true)); |
|
4419 | + $GLOBALS['log']->debug("process_full_list_query: result is ".print_r($result, true)); |
|
4420 | 4420 | $class = get_class($this); |
4421 | 4421 | $isFirstTime = true; |
4422 | 4422 | $bean = new $class(); |
@@ -4432,7 +4432,7 @@ discard block |
||
4432 | 4432 | foreach ($bean->field_defs as $field => $value) { |
4433 | 4433 | if (isset($row[$field])) { |
4434 | 4434 | $bean->$field = $row[$field]; |
4435 | - $GLOBALS['log']->debug("process_full_list: $bean->object_name({$row['id']}): " . $field . " = " . $bean->$field); |
|
4435 | + $GLOBALS['log']->debug("process_full_list: $bean->object_name({$row['id']}): ".$field." = ".$bean->$field); |
|
4436 | 4436 | } else { |
4437 | 4437 | $bean->$field = ''; |
4438 | 4438 | } |
@@ -4524,7 +4524,7 @@ discard block |
||
4524 | 4524 | $this->call_custom_logic("before_restore", $custom_logic_arguments); |
4525 | 4525 | |
4526 | 4526 | $date_modified = $GLOBALS['timedate']->nowDb(); |
4527 | - $query = "UPDATE $this->table_name set deleted=0 , date_modified = '$date_modified' where id='" . $this->db->quote($id) . "'"; |
|
4527 | + $query = "UPDATE $this->table_name set deleted=0 , date_modified = '$date_modified' where id='".$this->db->quote($id)."'"; |
|
4528 | 4528 | $this->db->query($query, true, "Error marking record undeleted: "); |
4529 | 4529 | |
4530 | 4530 | $this->restoreFiles(); |
@@ -4554,9 +4554,9 @@ discard block |
||
4554 | 4554 | $directory = $this->deleteFileDirectory(); |
4555 | 4555 | |
4556 | 4556 | foreach ($files as $file) { |
4557 | - if (sugar_is_file('upload://deleted/' . $directory . '/' . $file)) { |
|
4558 | - if (!sugar_rename('upload://deleted/' . $directory . '/' . $file, 'upload://' . $file)) { |
|
4559 | - $GLOBALS['log']->error('Could not move file ' . $directory . '/' . $file . ' from deleted directory'); |
|
4557 | + if (sugar_is_file('upload://deleted/'.$directory.'/'.$file)) { |
|
4558 | + if (!sugar_rename('upload://deleted/'.$directory.'/'.$file, 'upload://'.$file)) { |
|
4559 | + $GLOBALS['log']->error('Could not move file '.$directory.'/'.$file.' from deleted directory'); |
|
4560 | 4560 | } |
4561 | 4561 | } |
4562 | 4562 | } |
@@ -4565,7 +4565,7 @@ discard block |
||
4565 | 4565 | * @var DBManager $db |
4566 | 4566 | */ |
4567 | 4567 | global $db; |
4568 | - $db->query('DELETE FROM cron_remove_documents WHERE bean_id=' . $db->quoted($this->id)); |
|
4568 | + $db->query('DELETE FROM cron_remove_documents WHERE bean_id='.$db->quoted($this->id)); |
|
4569 | 4569 | |
4570 | 4570 | return true; |
4571 | 4571 | } |
@@ -4713,19 +4713,19 @@ discard block |
||
4713 | 4713 | |
4714 | 4714 | $directory = $this->deleteFileDirectory(); |
4715 | 4715 | |
4716 | - $isCreated = sugar_is_dir('upload://deleted/' . $directory); |
|
4716 | + $isCreated = sugar_is_dir('upload://deleted/'.$directory); |
|
4717 | 4717 | if (!$isCreated) { |
4718 | - sugar_mkdir('upload://deleted/' . $directory, 0777, true); |
|
4719 | - $isCreated = sugar_is_dir('upload://deleted/' . $directory); |
|
4718 | + sugar_mkdir('upload://deleted/'.$directory, 0777, true); |
|
4719 | + $isCreated = sugar_is_dir('upload://deleted/'.$directory); |
|
4720 | 4720 | } |
4721 | 4721 | if (!$isCreated) { |
4722 | 4722 | return false; |
4723 | 4723 | } |
4724 | 4724 | |
4725 | 4725 | foreach ($files as $file) { |
4726 | - if (file_exists('upload://' . $file)) { |
|
4727 | - if (!sugar_rename('upload://' . $file, 'upload://deleted/' . $directory . '/' . $file)) { |
|
4728 | - $GLOBALS['log']->error('Could not move file ' . $file . ' to deleted directory'); |
|
4726 | + if (file_exists('upload://'.$file)) { |
|
4727 | + if (!sugar_rename('upload://'.$file, 'upload://deleted/'.$directory.'/'.$file)) { |
|
4728 | + $GLOBALS['log']->error('Could not move file '.$file.' to deleted directory'); |
|
4729 | 4729 | } |
4730 | 4730 | } |
4731 | 4731 | } |
@@ -4745,7 +4745,7 @@ discard block |
||
4745 | 4745 | } |
4746 | 4746 | if (empty($record['id'])) { |
4747 | 4747 | $record['id'] = $db->quoted(create_guid()); |
4748 | - $db->query('INSERT INTO cron_remove_documents (' . implode(', ', array_keys($record)) . ') VALUES(' . implode(', ', $record) . ')'); |
|
4748 | + $db->query('INSERT INTO cron_remove_documents ('.implode(', ', array_keys($record)).') VALUES('.implode(', ', $record).')'); |
|
4749 | 4749 | } else { |
4750 | 4750 | $db->query("UPDATE cron_remove_documents SET date_modified={$record['date_modified']} WHERE id={$record['id']}"); |
4751 | 4751 | } |
@@ -4766,7 +4766,7 @@ discard block |
||
4766 | 4766 | */ |
4767 | 4767 | public function build_related_list($query, &$template, $row_offset = 0, $limit = -1) |
4768 | 4768 | { |
4769 | - $GLOBALS['log']->debug("Finding linked records $this->object_name: " . $query); |
|
4769 | + $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
|
4770 | 4770 | $db = DBManagerFactory::getInstance('listviews'); |
4771 | 4771 | |
4772 | 4772 | if (!empty($row_offset) && $row_offset != 0 && !empty($limit) && $limit != -1) { |
@@ -4813,7 +4813,7 @@ discard block |
||
4813 | 4813 | { |
4814 | 4814 | $db = DBManagerFactory::getInstance('listviews'); |
4815 | 4815 | // No need to do an additional query |
4816 | - $GLOBALS['log']->debug("Finding linked records $this->object_name: " . $query); |
|
4816 | + $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
|
4817 | 4817 | if (empty($in) && !empty($query)) { |
4818 | 4818 | $idList = $this->build_related_in($query); |
4819 | 4819 | $in = $idList['in']; |
@@ -4879,9 +4879,9 @@ discard block |
||
4879 | 4879 | while ($row = $this->db->fetchByAssoc($result)) { |
4880 | 4880 | $idList[] = $row['id']; |
4881 | 4881 | if (empty($ids)) { |
4882 | - $ids = "('" . $row['id'] . "'"; |
|
4882 | + $ids = "('".$row['id']."'"; |
|
4883 | 4883 | } else { |
4884 | - $ids .= ",'" . $row['id'] . "'"; |
|
4884 | + $ids .= ",'".$row['id']."'"; |
|
4885 | 4885 | } |
4886 | 4886 | } |
4887 | 4887 | if (empty($ids)) { |
@@ -4905,7 +4905,7 @@ discard block |
||
4905 | 4905 | */ |
4906 | 4906 | public function build_related_list2($query, &$template, &$field_list) |
4907 | 4907 | { |
4908 | - $GLOBALS['log']->debug("Finding linked values $this->object_name: " . $query); |
|
4908 | + $GLOBALS['log']->debug("Finding linked values $this->object_name: ".$query); |
|
4909 | 4909 | |
4910 | 4910 | $result = $this->db->query($query, true); |
4911 | 4911 | |
@@ -5019,9 +5019,9 @@ discard block |
||
5019 | 5019 | { |
5020 | 5020 | $where_clause = $this->get_where($fields_array, $deleted); |
5021 | 5021 | $custom_join = $this->getCustomJoin(); |
5022 | - $query = "SELECT $this->table_name.*" . $custom_join['select'] . " FROM $this->table_name " . $custom_join['join']; |
|
5022 | + $query = "SELECT $this->table_name.*".$custom_join['select']." FROM $this->table_name ".$custom_join['join']; |
|
5023 | 5023 | $query .= " $where_clause"; |
5024 | - $GLOBALS['log']->debug("Retrieve $this->object_name: " . $query); |
|
5024 | + $GLOBALS['log']->debug("Retrieve $this->object_name: ".$query); |
|
5025 | 5025 | //requireSingleResult has been deprecated. |
5026 | 5026 | //$result = $this->db->requireSingleResult($query, true, "Retrieving record $where_clause:"); |
5027 | 5027 | $result = $this->db->limitQuery($query, 0, 1, true, "Retrieving record $where_clause:"); |
@@ -5060,7 +5060,7 @@ discard block |
||
5060 | 5060 | } |
5061 | 5061 | $name = $this->db->getValidDBName($name); |
5062 | 5062 | |
5063 | - $where_clause .= "$name = " . $this->db->quoted($value); |
|
5063 | + $where_clause .= "$name = ".$this->db->quoted($value); |
|
5064 | 5064 | } |
5065 | 5065 | if (!empty($where_clause)) { |
5066 | 5066 | if ($deleted) { |
@@ -5158,7 +5158,7 @@ discard block |
||
5158 | 5158 | $where = ''; |
5159 | 5159 | |
5160 | 5160 | // make sure there is a date modified |
5161 | - $date_modified = $this->db->convert("'" . $GLOBALS['timedate']->nowDb() . "'", 'datetime'); |
|
5161 | + $date_modified = $this->db->convert("'".$GLOBALS['timedate']->nowDb()."'", 'datetime'); |
|
5162 | 5162 | |
5163 | 5163 | $row = null; |
5164 | 5164 | if ($check_duplicates) { |
@@ -5168,7 +5168,7 @@ discard block |
||
5168 | 5168 | $where .= " AND $name = '$value' "; |
5169 | 5169 | } |
5170 | 5170 | $query .= $where; |
5171 | - $result = $this->db->query($query, false, "Looking For Duplicate Relationship:" . $query); |
|
5171 | + $result = $this->db->query($query, false, "Looking For Duplicate Relationship:".$query); |
|
5172 | 5172 | $row = $this->db->fetchByAssoc($result); |
5173 | 5173 | } |
5174 | 5174 | |
@@ -5177,16 +5177,16 @@ discard block |
||
5177 | 5177 | if (isset($data_values)) { |
5178 | 5178 | $relate_values = array_merge($relate_values, $data_values); |
5179 | 5179 | } |
5180 | - $query = "INSERT INTO $table (id, " . implode(',', array_keys($relate_values)) . ", date_modified) VALUES ('" . create_guid() . "', " . "'" . implode("', '", $relate_values) . "', " . $date_modified . ")"; |
|
5180 | + $query = "INSERT INTO $table (id, ".implode(',', array_keys($relate_values)).", date_modified) VALUES ('".create_guid()."', "."'".implode("', '", $relate_values)."', ".$date_modified.")"; |
|
5181 | 5181 | |
5182 | - $this->db->query($query, false, "Creating Relationship:" . $query); |
|
5182 | + $this->db->query($query, false, "Creating Relationship:".$query); |
|
5183 | 5183 | } elseif ($do_update) { |
5184 | 5184 | $conds = array(); |
5185 | 5185 | foreach ($data_values as $key => $value) { |
5186 | - array_push($conds, $key . "='" . $this->db->quote($value) . "'"); |
|
5186 | + array_push($conds, $key."='".$this->db->quote($value)."'"); |
|
5187 | 5187 | } |
5188 | - $query = "UPDATE $table SET " . implode(',', $conds) . ",date_modified=" . $date_modified . " " . $where; |
|
5189 | - $this->db->query($query, false, "Updating Relationship:" . $query); |
|
5188 | + $query = "UPDATE $table SET ".implode(',', $conds).",date_modified=".$date_modified." ".$where; |
|
5189 | + $this->db->query($query, false, "Updating Relationship:".$query); |
|
5190 | 5190 | } |
5191 | 5191 | } |
5192 | 5192 | |
@@ -5197,7 +5197,7 @@ discard block |
||
5197 | 5197 | $query .= " AND $name = '$value' "; |
5198 | 5198 | } |
5199 | 5199 | $query .= " ORDER BY $select_id "; |
5200 | - $result = $this->db->query($query, false, "Retrieving Relationship:" . $query); |
|
5200 | + $result = $this->db->query($query, false, "Retrieving Relationship:".$query); |
|
5201 | 5201 | $ids = array(); |
5202 | 5202 | while ($row = $this->db->fetchByAssoc($result)) { |
5203 | 5203 | $ids[] = $row; |
@@ -5208,13 +5208,13 @@ discard block |
||
5208 | 5208 | public function loadLayoutDefs() |
5209 | 5209 | { |
5210 | 5210 | global $layout_defs; |
5211 | - if (empty($this->layout_def) && file_exists('modules/' . $this->module_dir . '/layout_defs.php')) { |
|
5212 | - include_once('modules/' . $this->module_dir . '/layout_defs.php'); |
|
5213 | - if (file_exists('custom/modules/' . $this->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php')) { |
|
5214 | - include_once('custom/modules/' . $this->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php'); |
|
5211 | + if (empty($this->layout_def) && file_exists('modules/'.$this->module_dir.'/layout_defs.php')) { |
|
5212 | + include_once('modules/'.$this->module_dir.'/layout_defs.php'); |
|
5213 | + if (file_exists('custom/modules/'.$this->module_dir.'/Ext/Layoutdefs/layoutdefs.ext.php')) { |
|
5214 | + include_once('custom/modules/'.$this->module_dir.'/Ext/Layoutdefs/layoutdefs.ext.php'); |
|
5215 | 5215 | } |
5216 | 5216 | if (empty($layout_defs[get_class($this)])) { |
5217 | - echo "\$layout_defs[" . get_class($this) . "]; does not exist"; |
|
5217 | + echo "\$layout_defs[".get_class($this)."]; does not exist"; |
|
5218 | 5218 | } |
5219 | 5219 | |
5220 | 5220 | $this->layout_def = $layout_defs[get_class($this)]; |
@@ -5440,8 +5440,8 @@ discard block |
||
5440 | 5440 | $tmp = explode(",", $order_by); |
5441 | 5441 | $comma = ' '; |
5442 | 5442 | foreach ($tmp as $stmp) { |
5443 | - $stmp = (substr_count($stmp, ".") > 0 ? trim($stmp) : "$qualify." . trim($stmp)); |
|
5444 | - $order_by_clause .= $comma . $stmp; |
|
5443 | + $stmp = (substr_count($stmp, ".") > 0 ? trim($stmp) : "$qualify.".trim($stmp)); |
|
5444 | + $order_by_clause .= $comma.$stmp; |
|
5445 | 5445 | $comma = ", "; |
5446 | 5446 | } |
5447 | 5447 | return $order_by_clause; |
@@ -5457,19 +5457,19 @@ discard block |
||
5457 | 5457 | $street_field |
5458 | 5458 | ) { |
5459 | 5459 | if (isset($this->$street_field)) { |
5460 | - $street_field_2 = $street_field . '_2'; |
|
5461 | - $street_field_3 = $street_field . '_3'; |
|
5462 | - $street_field_4 = $street_field . '_4'; |
|
5460 | + $street_field_2 = $street_field.'_2'; |
|
5461 | + $street_field_3 = $street_field.'_3'; |
|
5462 | + $street_field_4 = $street_field.'_4'; |
|
5463 | 5463 | if (isset($this->$street_field_2)) { |
5464 | - $this->$street_field .= "\n" . $this->$street_field_2; |
|
5464 | + $this->$street_field .= "\n".$this->$street_field_2; |
|
5465 | 5465 | unset($this->$street_field_2); |
5466 | 5466 | } |
5467 | 5467 | if (isset($this->$street_field_3)) { |
5468 | - $this->$street_field .= "\n" . $this->$street_field_3; |
|
5468 | + $this->$street_field .= "\n".$this->$street_field_3; |
|
5469 | 5469 | unset($this->$street_field_3); |
5470 | 5470 | } |
5471 | 5471 | if (isset($this->$street_field_4)) { |
5472 | - $this->$street_field .= "\n" . $this->$street_field_4; |
|
5472 | + $this->$street_field .= "\n".$this->$street_field_4; |
|
5473 | 5473 | unset($this->$street_field_4); |
5474 | 5474 | } |
5475 | 5475 | $this->$street_field = trim($this->$street_field, "\n"); |
@@ -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. |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | global $current_user; |
41 | 41 | $module_name = "Tasks"; |
42 | 42 | $searchFields['Tasks'] = |
43 | - array ( |
|
44 | - 'name' => array( 'query_type'=>'default'), |
|
43 | + array( |
|
44 | + 'name' => array('query_type'=>'default'), |
|
45 | 45 | 'contact_name' => array('query_type' => 'default', 'db_field' => array('contacts.first_name', 'contacts.last_name'), 'force_unifiedsearch' => true), |
46 | - 'current_user_only'=> array('query_type'=>'default','db_field'=>array('assigned_user_id'),'my_items'=>true, 'vname' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'), |
|
46 | + 'current_user_only'=> array('query_type'=>'default', 'db_field'=>array('assigned_user_id'), 'my_items'=>true, 'vname' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'), |
|
47 | 47 | 'assigned_user_id'=> array('query_type'=>'default'), |
48 | 48 | 'status'=> array('query_type'=>'default', 'options' => 'task_status_dom', 'template_var' => 'STATUS_FILTER'), |
49 | 49 | |
@@ -60,22 +60,22 @@ discard block |
||
60 | 60 | 'subquery' => "SELECT favorites.parent_id FROM favorites |
61 | 61 | WHERE favorites.deleted = 0 |
62 | 62 | and favorites.parent_type = '".$module_name."' |
63 | - and favorites.assigned_user_id = '" .$current_user->id . "') OR NOT ({0}", |
|
63 | + and favorites.assigned_user_id = '" .$current_user->id."') OR NOT ({0}", |
|
64 | 64 | 'db_field'=>array('id')), |
65 | 65 | //Range Search Support |
66 | - 'range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
67 | - 'start_range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
68 | - 'end_range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
69 | - 'range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
70 | - 'start_range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
71 | - 'end_range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
66 | + 'range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
67 | + 'start_range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
68 | + 'end_range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
69 | + 'range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
70 | + 'start_range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
71 | + 'end_range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
72 | 72 | |
73 | - 'range_date_start' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
74 | - 'start_range_date_start' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
75 | - 'end_range_date_start' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
76 | - 'range_date_due' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
77 | - 'start_range_date_due' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
78 | - 'end_range_date_due' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
73 | + 'range_date_start' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
74 | + 'start_range_date_start' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
75 | + 'end_range_date_start' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
76 | + 'range_date_due' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
77 | + 'start_range_date_due' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
78 | + 'end_range_date_due' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
79 | 79 | //Range Search Support |
80 | 80 | ); |
81 | 81 | ?> |