@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | 'd.m.Y' => '23.12.2010', |
116 | 116 | 'm.d.Y' => '12.23.2010', |
117 | 117 | ) : $dateFormats, |
118 | - 'dbconfig' => $dbconfig, // this must be set!! |
|
119 | - 'dbconfigoption' => $dbconfigoption, // this must be set!! |
|
118 | + 'dbconfig' => $dbconfig, // this must be set!! |
|
119 | + 'dbconfigoption' => $dbconfigoption, // this must be set!! |
|
120 | 120 | 'default_action' => empty($default_action) ? 'index' : $default_action, |
121 | 121 | 'default_charset' => empty($default_charset) ? 'UTF-8' : $default_charset, |
122 | 122 | 'default_currency_name' => empty($default_currency_name) ? 'US Dollar' : $default_currency_name, |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | 'display_inbound_email_buttons' => empty($display_inbound_email_buttons) ? false : $display_inbound_email_buttons, |
145 | 145 | 'history_max_viewed' => empty($history_max_viewed) ? 50 : $history_max_viewed, |
146 | 146 | 'host_name' => empty($host_name) ? 'localhost' : $host_name, |
147 | - 'import_dir' => $import_dir, // this must be set!! |
|
147 | + 'import_dir' => $import_dir, // this must be set!! |
|
148 | 148 | 'import_max_records_per_file' => 100, |
149 | 149 | 'import_max_records_total_limit' => '', |
150 | 150 | 'languages' => empty($languages) ? array('en_us' => 'English (US)') : $languages, |
@@ -164,21 +164,21 @@ discard block |
||
164 | 164 | ), |
165 | 165 | 'require_accounts' => empty($requireAccounts) ? true : $requireAccounts, |
166 | 166 | 'rss_cache_time' => empty($RSS_CACHE_TIME) ? '10800' : $RSS_CACHE_TIME, |
167 | - 'session_dir' => $session_dir, // this must be set!! |
|
168 | - 'site_url' => empty($site_URL) ? $site_url : $site_URL, // this must be set!! |
|
167 | + 'session_dir' => $session_dir, // this must be set!! |
|
168 | + 'site_url' => empty($site_URL) ? $site_url : $site_URL, // this must be set!! |
|
169 | 169 | 'showDetailData' => true, // if true, read-only ACL fields will still appear on EditViews as non-editable |
170 | 170 | 'showThemePicker' => true, |
171 | 171 | 'sugar_version' => empty($sugar_version) ? 'unknown' : $sugar_version, |
172 | 172 | 'time_formats' => empty($timeFormats) ? array( |
173 | 173 | 'H:i' => '23:00', 'h:ia' => '11:00 pm', 'h:iA' => '11:00PM', |
174 | - 'H.i' => '23.00', 'h.ia' => '11.00 pm', 'h.iA' => '11.00PM', ) : $timeFormats, |
|
175 | - 'tmp_dir' => $tmp_dir, // this must be set!! |
|
174 | + 'H.i' => '23.00', 'h.ia' => '11.00 pm', 'h.iA' => '11.00PM',) : $timeFormats, |
|
175 | + 'tmp_dir' => $tmp_dir, // this must be set!! |
|
176 | 176 | 'translation_string_prefix' => empty($translation_string_prefix) ? false : $translation_string_prefix, |
177 | 177 | 'unique_key' => empty($unique_key) ? md5(create_guid()) : $unique_key, |
178 | 178 | 'upload_badext' => empty($upload_badext) ? array( |
179 | 179 | 'php', 'php3', 'php4', 'php5', 'pl', 'cgi', 'py', |
180 | - 'asp', 'cfm', 'js', 'vbs', 'html', 'htm', ) : $upload_badext, |
|
181 | - 'upload_dir' => $upload_dir, // this must be set!! |
|
180 | + 'asp', 'cfm', 'js', 'vbs', 'html', 'htm',) : $upload_badext, |
|
181 | + 'upload_dir' => $upload_dir, // this must be set!! |
|
182 | 182 | 'upload_maxsize' => empty($upload_maxsize) ? 30000000 : $upload_maxsize, |
183 | 183 | 'import_max_execution_time' => empty($import_max_execution_time) ? 3600 : $import_max_execution_time, |
184 | 184 | 'lock_homepage' => false, |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | 'date_formats' => array( |
245 | 245 | 'Y-m-d' => '2010-12-23', 'm-d-Y' => '12-23-2010', 'd-m-Y' => '23-12-2010', |
246 | 246 | 'Y/m/d' => '2010/12/23', 'm/d/Y' => '12/23/2010', 'd/m/Y' => '23/12/2010', |
247 | - 'Y.m.d' => '2010.12.23', 'd.m.Y' => '23.12.2010', 'm.d.Y' => '12.23.2010', ), |
|
247 | + 'Y.m.d' => '2010.12.23', 'd.m.Y' => '23.12.2010', 'm.d.Y' => '12.23.2010',), |
|
248 | 248 | 'name_formats' => array( |
249 | 249 | 's f l' => 's f l', 'f l' => 'f l', 's l' => 's l', 'l, s f' => 'l, s f', |
250 | 250 | 'l, f' => 'l, f', 's l, f' => 's l, f', 'l s f' => 'l s f', 'l f s' => 'l f s', |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | 'persistent' => true, |
254 | 254 | 'autofree' => false, |
255 | 255 | 'debug' => 0, |
256 | - 'ssl' => false, ), |
|
256 | + 'ssl' => false,), |
|
257 | 257 | 'default_action' => 'index', |
258 | 258 | 'default_charset' => return_session_value_or_default('default_charset', |
259 | 259 | 'UTF-8'), |
@@ -316,12 +316,12 @@ discard block |
||
316 | 316 | 'sugarbeet' => true, |
317 | 317 | 'time_formats' => array( |
318 | 318 | 'H:i' => '23:00', 'h:ia' => '11:00pm', 'h:iA' => '11:00PM', 'h:i a' => '11:00 pm', 'h:i A' => '11:00 PM', |
319 | - 'H.i' => '23.00', 'h.ia' => '11.00pm', 'h.iA' => '11.00PM', 'h.i a' => '11.00 pm', 'h.i A' => '11.00 PM', ), |
|
319 | + 'H.i' => '23.00', 'h.ia' => '11.00pm', 'h.iA' => '11.00PM', 'h.i a' => '11.00 pm', 'h.i A' => '11.00 PM',), |
|
320 | 320 | 'tracker_max_display_length' => 15, |
321 | 321 | 'translation_string_prefix' => return_session_value_or_default('translation_string_prefix', false), |
322 | 322 | 'upload_badext' => array( |
323 | 323 | 'php', 'php3', 'php4', 'php5', 'pl', 'cgi', 'py', |
324 | - 'asp', 'cfm', 'js', 'vbs', 'html', 'htm', 'phtml', ), |
|
324 | + 'asp', 'cfm', 'js', 'vbs', 'html', 'htm', 'phtml',), |
|
325 | 325 | 'upload_maxsize' => 30000000, |
326 | 326 | 'import_max_execution_time' => 3600, |
327 | 327 | // 'use_php_code_json' => returnPhpJsonStatus(), |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | { |
439 | 439 | global $sugar_config; |
440 | 440 | |
441 | - if (is_windows() || !isset($sugar_config)|| !isset($addUser) || ($addUser == '')) { |
|
441 | + if (is_windows() || !isset($sugar_config) || !isset($addUser) || ($addUser == '')) { |
|
442 | 442 | return; |
443 | 443 | } |
444 | 444 | if (!array_key_exists('cron', $sugar_config)) { |
@@ -1687,11 +1687,11 @@ discard block |
||
1687 | 1687 | |
1688 | 1688 | $response = '<OPTION value="'.$value.'"'; |
1689 | 1689 | |
1690 | - if($isSelected === true) { |
|
1691 | - $response .= ' ' . 'selected'; |
|
1690 | + if ($isSelected === true) { |
|
1691 | + $response .= ' '.'selected'; |
|
1692 | 1692 | } |
1693 | 1693 | |
1694 | - $response .= '>' . $app_strings[$app_strings_label] . '</OPTION>'; |
|
1694 | + $response .= '>'.$app_strings[$app_strings_label].'</OPTION>'; |
|
1695 | 1695 | |
1696 | 1696 | return $response; |
1697 | 1697 | } |
@@ -1702,8 +1702,8 @@ discard block |
||
1702 | 1702 | |
1703 | 1703 | $response = '<OPTION value="'.$value.'"'; |
1704 | 1704 | |
1705 | - if($isSelected === true) { |
|
1706 | - $response .= ' ' . 'selected'; |
|
1705 | + if ($isSelected === true) { |
|
1706 | + $response .= ' '.'selected'; |
|
1707 | 1707 | } |
1708 | 1708 | |
1709 | 1709 | $response .= '>'; |
@@ -1726,15 +1726,15 @@ discard block |
||
1726 | 1726 | { |
1727 | 1727 | $isSelected = false; |
1728 | 1728 | |
1729 | - if(empty($option_key)) { |
|
1729 | + if (empty($option_key)) { |
|
1730 | 1730 | continue; |
1731 | 1731 | } |
1732 | 1732 | |
1733 | - if(empty($option_value)) { |
|
1733 | + if (empty($option_value)) { |
|
1734 | 1734 | continue; |
1735 | 1735 | } |
1736 | 1736 | |
1737 | - if($option_key === $selected_key) |
|
1737 | + if ($option_key === $selected_key) |
|
1738 | 1738 | { |
1739 | 1739 | $isSelected = true; |
1740 | 1740 | } |
@@ -2455,9 +2455,9 @@ discard block |
||
2455 | 2455 | { |
2456 | 2456 | $current_theme = SugarThemeRegistry::current(); |
2457 | 2457 | $theme_directory = $current_theme->dirName; |
2458 | - if(strpos($relative_path, "themes".DIRECTORY_SEPARATOR.$theme_directory) === false) { |
|
2458 | + if (strpos($relative_path, "themes".DIRECTORY_SEPARATOR.$theme_directory) === false) { |
|
2459 | 2459 | $test_path = SUGAR_PATH.DIRECTORY_SEPARATOR."themes".DIRECTORY_SEPARATOR.$theme_directory.DIRECTORY_SEPARATOR.$relative_path; |
2460 | - if(file_exists($test_path)) { |
|
2460 | + if (file_exists($test_path)) { |
|
2461 | 2461 | $resource_name = "themes".DIRECTORY_SEPARATOR.$theme_directory.DIRECTORY_SEPARATOR.$relative_path; |
2462 | 2462 | } |
2463 | 2463 | } |
@@ -3116,14 +3116,14 @@ discard block |
||
3116 | 3116 | * 0 if version is between minimun and recomended PHP versions, |
3117 | 3117 | * -1 otherwise (less than minimum or buggy version) |
3118 | 3118 | */ |
3119 | -function check_php_version($sys_php_version = ''){ |
|
3120 | -if ($sys_php_version === ''){ |
|
3121 | - $sys_php_version = constant('PHP_VERSION') ; |
|
3119 | +function check_php_version($sys_php_version = '') { |
|
3120 | +if ($sys_php_version === '') { |
|
3121 | + $sys_php_version = constant('PHP_VERSION'); |
|
3122 | 3122 | } |
3123 | 3123 | |
3124 | 3124 | // versions below MIN_PHP_VERSION are not accepted, so return early. |
3125 | - if ( version_compare($sys_php_version, constant('SUITECRM_PHP_MIN_VERSION'), '<') === true) { |
|
3126 | - return - 1; |
|
3125 | + if (version_compare($sys_php_version, constant('SUITECRM_PHP_MIN_VERSION'), '<') === true) { |
|
3126 | + return -1; |
|
3127 | 3127 | |
3128 | 3128 | } |
3129 | 3129 | |
@@ -3131,7 +3131,7 @@ discard block |
||
3131 | 3131 | // and check immediately for one of this versions |
3132 | 3132 | $bug_php_versions = array(); |
3133 | 3133 | foreach ($bug_php_versions as $v) { |
3134 | - if ( version_compare($sys_php_version, $v, '=') === true) { |
|
3134 | + if (version_compare($sys_php_version, $v, '=') === true) { |
|
3135 | 3135 | return -1; |
3136 | 3136 | |
3137 | 3137 | } |
@@ -4407,7 +4407,7 @@ discard block |
||
4407 | 4407 | |
4408 | 4408 | function _getIcon($iconFileName) |
4409 | 4409 | { |
4410 | - if(file_exists(SugarThemeRegistry::current()->getImagePath().DIRECTORY_SEPARATOR.'icon_'.$iconFileName.'.svg')) { |
|
4410 | + if (file_exists(SugarThemeRegistry::current()->getImagePath().DIRECTORY_SEPARATOR.'icon_'.$iconFileName.'.svg')) { |
|
4411 | 4411 | $iconName = "icon_{$iconFileName}.svg"; |
4412 | 4412 | $iconFound = SugarThemeRegistry::current()->getImageURL($iconName, false); |
4413 | 4413 | } |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | |
48 | 48 | global $current_language, $app_strings, $app_list_strings, $current_user, $beanFiles, $beanList; |
49 | 49 | |
50 | - $bean = BeanFactory::getBean($module,$id); |
|
50 | + $bean = BeanFactory::getBean($module, $id); |
|
51 | 51 | |
52 | - if(!checkAccess($bean)){ |
|
52 | + if (!checkAccess($bean)) { |
|
53 | 53 | return false; |
54 | 54 | } |
55 | 55 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $mod_strings = return_module_language($current_language, $module); |
60 | 60 | |
61 | 61 | // set the filename for this control |
62 | - $file = create_cache_directory('include/InlineEditing/') . $module . $view . $alt_type . $fieldname . '.tpl'; |
|
62 | + $file = create_cache_directory('include/InlineEditing/').$module.$view.$alt_type.$fieldname.'.tpl'; |
|
63 | 63 | |
64 | 64 | if (!is_file($file) |
65 | 65 | || inDeveloperMode() |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | if ($vardef['type'] == 'link') { |
105 | 105 | $vardef['type'] = 'relate'; |
106 | 106 | $vardef['rname'] = 'name'; |
107 | - $vardef['id_name'] = $vardef['name'] . '_id'; |
|
107 | + $vardef['id_name'] = $vardef['name'].'_id'; |
|
108 | 108 | if ((!isset($vardef['module']) || $vardef['module'] == '') && $focus->load_relationship($vardef['name'])) { |
109 | 109 | $vardef['module'] = $focus->{$vardef['name']}->getRelatedModuleName(); |
110 | 110 | } |
@@ -140,15 +140,15 @@ discard block |
||
140 | 140 | // Remove all the copyright comments |
141 | 141 | $contents = preg_replace('/\{\*[^\}]*?\*\}/', '', $contents); |
142 | 142 | // remove extra wrong javascript which breaks auto complete on flexi relationship parent fields |
143 | - $contents = preg_replace("/<script language=\"javascript\">if\(typeof sqs_objects == \'undefined\'\){var sqs_objects = new Array;}sqs_objects\[\'EditView_parent_name\'\].*?<\/script>/","",$contents); |
|
143 | + $contents = preg_replace("/<script language=\"javascript\">if\(typeof sqs_objects == \'undefined\'\){var sqs_objects = new Array;}sqs_objects\[\'EditView_parent_name\'\].*?<\/script>/", "", $contents); |
|
144 | 144 | |
145 | 145 | |
146 | 146 | if ($view == 'EditView' && ($vardef['type'] == 'relate' || $vardef['type'] == 'parent')) { |
147 | 147 | |
148 | - $contents = str_replace('"' . $vardef['id_name'] . '"', '{/literal}"{$fields.' . $vardef['name'] . '.id_name}"{literal}', $contents); |
|
149 | - $contents = str_replace('"' . $vardef['name'] . '"', '{/literal}"{$fields.' . $vardef['name'] . '.name}"{literal}', $contents); |
|
148 | + $contents = str_replace('"'.$vardef['id_name'].'"', '{/literal}"{$fields.'.$vardef['name'].'.id_name}"{literal}', $contents); |
|
149 | + $contents = str_replace('"'.$vardef['name'].'"', '{/literal}"{$fields.'.$vardef['name'].'.name}"{literal}', $contents); |
|
150 | 150 | // regex below fixes button javascript for flexi relationship |
151 | - if($vardef['type'] == 'parent') { |
|
151 | + if ($vardef['type'] == 'parent') { |
|
152 | 152 | $contents = str_replace("onclick='open_popup(document.{\$form_name}.parent_type.value, 600, 400, \"\", true, false, {literal}{\"call_back_function\":\"set_return\",\"form_name\":\"EditView\",\"field_to_name_array\":{\"id\":{/literal}\"{\$fields.parent_name.id_name}", "onclick='open_popup(document.{\$form_name}.parent_type.value, 600, 400, \"\", true, false, {literal}{\"call_back_function\":\"set_return\",\"form_name\":\"EditView\",\"field_to_name_array\":{\"id\":{/literal}\"parent_id", $contents); |
153 | 153 | } |
154 | 154 | } |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | } |
183 | 183 | $t23 = strpos($time_format, '23') !== false ? '%H' : '%I'; |
184 | 184 | if (!isset($match[2]) || $match[2] == '') { |
185 | - $ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . "%M"); |
|
185 | + $ss->assign('CALENDAR_FORMAT', $date_format.' '.$t23.$time_separator."%M"); |
|
186 | 186 | } else { |
187 | 187 | $pm = $match[2] == "pm" ? "%P" : "%p"; |
188 | - $ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . "%M" . $pm); |
|
188 | + $ss->assign('CALENDAR_FORMAT', $date_format.' '.$t23.$time_separator."%M".$pm); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | $ss->assign('CALENDAR_FDOW', $current_user->get_first_day_of_week()); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | } |
225 | 225 | |
226 | 226 | if ($fieldlist[$fieldname]['type'] == 'link') { |
227 | - $fieldlist[$fieldname]['id_name'] = $fieldlist[$fieldname]['name'] . '_id'; |
|
227 | + $fieldlist[$fieldname]['id_name'] = $fieldlist[$fieldname]['name'].'_id'; |
|
228 | 228 | |
229 | 229 | if ((!isset($fieldlist[$fieldname]['module']) || $fieldlist[$fieldname]['module'] == '') && $focus->load_relationship($fieldlist[$fieldname]['name'])) { |
230 | 230 | $relateField = $fieldlist[$fieldname]['name']; |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
235 | - if($fieldlist[$fieldname]['type'] == 'parent'){ |
|
235 | + if ($fieldlist[$fieldname]['type'] == 'parent') { |
|
236 | 236 | $fieldlist['parent_id']['name'] = 'parent_id'; |
237 | 237 | } |
238 | 238 | |
@@ -243,15 +243,15 @@ discard block |
||
243 | 243 | } |
244 | 244 | |
245 | 245 | if (isset($fieldlist[$fieldname]['id_name']) && $fieldlist[$fieldname]['id_name'] != '' && $fieldlist[$fieldname]['id_name'] != $fieldlist[$fieldname]['name']) { |
246 | - if($value){ |
|
246 | + if ($value) { |
|
247 | 247 | $relateIdField = $fieldlist[$fieldname]['id_name']; |
248 | - $rel_value = $bean->$relateIdField; |
|
248 | + $rel_value = $bean->$relateIdField; |
|
249 | 249 | |
250 | 250 | } |
251 | 251 | $fieldlist[$fieldlist[$fieldname]['id_name']]['value'] = $rel_value; |
252 | 252 | $fieldlist[$fieldname]['value'] = $value; |
253 | 253 | $fieldlist[$fieldname]['id_name'] = $aow_field; |
254 | - $fieldlist[$fieldname]['name'] = $aow_field . '_display'; |
|
254 | + $fieldlist[$fieldname]['name'] = $aow_field.'_display'; |
|
255 | 255 | } else if (isset($fieldlist[$fieldname]['type']) && ($fieldlist[$fieldname]['type'] == 'datetimecombo' || $fieldlist[$fieldname]['type'] == 'datetime')) { |
256 | 256 | $value = $focus->convertField($value, $fieldlist[$fieldname]); |
257 | 257 | if (!$value) { |
@@ -323,29 +323,29 @@ discard block |
||
323 | 323 | |
324 | 324 | if ($bean->field_defs[$field]['type'] == "multienum") { |
325 | 325 | $bean->$field = encodeMultienumValue($value); |
326 | - }else if ($bean->field_defs[$field]['type'] == "relate" || $bean->field_defs[$field]['type'] == 'parent'){ |
|
326 | + } else if ($bean->field_defs[$field]['type'] == "relate" || $bean->field_defs[$field]['type'] == 'parent') { |
|
327 | 327 | $save_field = $bean->field_defs[$field]['id_name']; |
328 | 328 | $bean->$save_field = $value; |
329 | 329 | if ($bean->field_defs[$field]['type'] == 'parent') { |
330 | 330 | $bean->parent_type = $_REQUEST['parent_type']; |
331 | 331 | $bean->fill_in_additional_parent_fields(); // get up to date parent info as need it to display name |
332 | 332 | } |
333 | - }else if ($bean->field_defs[$field]['type'] == "currency"){ |
|
333 | + } else if ($bean->field_defs[$field]['type'] == "currency") { |
|
334 | 334 | if (stripos($field, 'usdollar')) { |
335 | 335 | $newfield = str_replace("_usdollar", "", $field); |
336 | 336 | $bean->$newfield = $value; |
337 | 337 | } |
338 | - else{ |
|
338 | + else { |
|
339 | 339 | $bean->$field = $value; |
340 | 340 | } |
341 | 341 | |
342 | - }else{ |
|
342 | + } else { |
|
343 | 343 | $bean->$field = $value; |
344 | 344 | } |
345 | 345 | |
346 | 346 | $check_notify = FALSE; |
347 | 347 | |
348 | - if (isset( $bean->fetched_row['assigned_user_id']) && $field == "assigned_user_name") { |
|
348 | + if (isset($bean->fetched_row['assigned_user_id']) && $field == "assigned_user_name") { |
|
349 | 349 | $old_assigned_user_id = $bean->fetched_row['assigned_user_id']; |
350 | 350 | if (!empty($value) && ($old_assigned_user_id != $value) && ($value != $current_user->id)) { |
351 | 351 | $check_notify = TRUE; |
@@ -355,12 +355,12 @@ discard block |
||
355 | 355 | $adminOnlyModules = array('Users', 'Employees'); |
356 | 356 | |
357 | 357 | $enabled = true; |
358 | - if(in_array($module, $adminOnlyModules) && !is_admin($current_user)) { |
|
358 | + if (in_array($module, $adminOnlyModules) && !is_admin($current_user)) { |
|
359 | 359 | $enabled = false; |
360 | 360 | } |
361 | 361 | |
362 | - if(($bean->ACLAccess("edit") || is_admin($current_user)) && $enabled) { |
|
363 | - if(!$bean->save($check_notify)) { |
|
362 | + if (($bean->ACLAccess("edit") || is_admin($current_user)) && $enabled) { |
|
363 | + if (!$bean->save($check_notify)) { |
|
364 | 364 | $GLOBALS['log']->fatal("Saving probably failed or bean->save() method did not return with a positive result."); |
365 | 365 | } |
366 | 366 | } else { |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | |
386 | 386 | $fieldlist[$field] = $bean->getFieldDefinition($field); |
387 | 387 | |
388 | - if(is_array($listViewDefs)){ |
|
388 | + if (is_array($listViewDefs)) { |
|
389 | 389 | $fieldlist[$field] = array_merge($fieldlist[$field], $listViewDefs); |
390 | 390 | } |
391 | 391 | |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | $vardef['module'] = $bean->module_dir; |
424 | 424 | |
425 | 425 | $SugarWidgetSubPanelDetailViewLink = new SugarWidgetSubPanelDetailViewLink($vardef); |
426 | - $value = "<b>" . $SugarWidgetSubPanelDetailViewLink->displayList($vardef) . "</b>"; |
|
426 | + $value = "<b>".$SugarWidgetSubPanelDetailViewLink->displayList($vardef)."</b>"; |
|
427 | 427 | |
428 | 428 | } |
429 | 429 | |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | } |
437 | 437 | $datetime_format = $timedate->get_date_time_format(); |
438 | 438 | // create utc date (as it's utc in db) |
439 | - $datetime = DateTime::createFromFormat("Y-m-d H:i:s", $value,new DateTimeZone('UTC')); |
|
439 | + $datetime = DateTime::createFromFormat("Y-m-d H:i:s", $value, new DateTimeZone('UTC')); |
|
440 | 440 | // convert it to timezone the user uses |
441 | 441 | $datetime = $timedate->tzUser($datetime); |
442 | 442 | |
@@ -475,24 +475,24 @@ discard block |
||
475 | 475 | } |
476 | 476 | |
477 | 477 | //if field is of type relate. |
478 | - if ($vardef['type'] == "relate" || $vardef['type'] == "parent") { |
|
478 | + if ($vardef['type'] == "relate" || $vardef['type'] == "parent") { |
|
479 | 479 | |
480 | - if($vardef['source'] == "non-db"){ |
|
480 | + if ($vardef['source'] == "non-db") { |
|
481 | 481 | |
482 | - if($vardef['module'] == "Employees"){ |
|
482 | + if ($vardef['module'] == "Employees") { |
|
483 | 483 | $vardef['ext2'] = "Users"; |
484 | 484 | $vardef['rname'] = "full_name"; |
485 | 485 | } |
486 | 486 | |
487 | 487 | } |
488 | - if($vardef['type'] == "parent") { |
|
488 | + if ($vardef['type'] == "parent") { |
|
489 | 489 | $vardef['module'] = $bean->parent_type; |
490 | 490 | $name = $bean->parent_name; |
491 | 491 | } |
492 | 492 | $idName = $vardef['id_name']; |
493 | 493 | $record = $bean->$idName; |
494 | 494 | |
495 | - if($vardef['name'] != "assigned_user_name") { |
|
495 | + if ($vardef['name'] != "assigned_user_name") { |
|
496 | 496 | $value = "<a class=\"listViewTdLinkS1\" href=\"index.php?action=DetailView&module=".$vardef['module']."&record=$record\">"; |
497 | 497 | } else { |
498 | 498 | $value = ""; |
@@ -500,32 +500,32 @@ discard block |
||
500 | 500 | |
501 | 501 | |
502 | 502 | //To fix github bug 880 (the rname was null and was causing a 500 error in the getFieldValueFromModule call to $fieldname |
503 | - $fieldName = 'name';//$vardef['name']; |
|
504 | - if(!is_null($vardef['rname'])) |
|
503 | + $fieldName = 'name'; //$vardef['name']; |
|
504 | + if (!is_null($vardef['rname'])) |
|
505 | 505 | $fieldName = $vardef['rname']; |
506 | 506 | |
507 | - if($vardef['ext2']){ |
|
507 | + if ($vardef['ext2']) { |
|
508 | 508 | |
509 | - $value .= getFieldValueFromModule($fieldName,$vardef['ext2'],$record); |
|
509 | + $value .= getFieldValueFromModule($fieldName, $vardef['ext2'], $record); |
|
510 | 510 | |
511 | - } else if(!empty($vardef['rname']) || $vardef['name'] == "related_doc_name") { |
|
512 | - $value .= getFieldValueFromModule($fieldName,$vardef['module'],$record); |
|
511 | + } else if (!empty($vardef['rname']) || $vardef['name'] == "related_doc_name") { |
|
512 | + $value .= getFieldValueFromModule($fieldName, $vardef['module'], $record); |
|
513 | 513 | |
514 | 514 | } else { |
515 | 515 | $value .= $name; |
516 | 516 | } |
517 | 517 | |
518 | - if($vardef['name'] != "assigned_user_name") { |
|
518 | + if ($vardef['name'] != "assigned_user_name") { |
|
519 | 519 | $value .= "</a>"; |
520 | 520 | } |
521 | 521 | } |
522 | - if($vardef['type'] == "url") |
|
522 | + if ($vardef['type'] == "url") |
|
523 | 523 | { |
524 | 524 | $value = '<a href='.$value.' target="_blank">'.$value.'</a>'; |
525 | 525 | } |
526 | 526 | |
527 | - if($vardef['type'] == "currency"){ |
|
528 | - if($_REQUEST['view'] != "DetailView"){ |
|
527 | + if ($vardef['type'] == "currency") { |
|
528 | + if ($_REQUEST['view'] != "DetailView") { |
|
529 | 529 | $value = currency_format_number($value); |
530 | 530 | } |
531 | 531 | else |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | function getFieldValueFromModule($fieldname, $module, $id) |
539 | 539 | { |
540 | 540 | //Github bug 880, if the fieldname is null, do no call from bean |
541 | - if(is_null($fieldname)) |
|
541 | + if (is_null($fieldname)) |
|
542 | 542 | return ''; |
543 | 543 | |
544 | 544 | $bean = BeanFactory::getBean($module, $id); |
@@ -559,11 +559,11 @@ discard block |
||
559 | 559 | return $value; |
560 | 560 | } |
561 | 561 | |
562 | -function checkAccess($bean){ |
|
562 | +function checkAccess($bean) { |
|
563 | 563 | |
564 | - if($bean->ACLAccess('EditView')) { |
|
564 | + if ($bean->ACLAccess('EditView')) { |
|
565 | 565 | return true; |
566 | - }else { |
|
566 | + } else { |
|
567 | 567 | return false; |
568 | 568 | } |
569 | 569 | } |
@@ -174,25 +174,25 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false) |
176 | 176 | { |
177 | - if(is_array($sql)) { |
|
177 | + if (is_array($sql)) { |
|
178 | 178 | return $this->queryArray($sql, $dieOnError, $msg, $suppress); |
179 | 179 | } |
180 | 180 | |
181 | 181 | parent::countQuery($sql); |
182 | - $GLOBALS['log']->info('Query:' . $sql); |
|
182 | + $GLOBALS['log']->info('Query:'.$sql); |
|
183 | 183 | $this->checkConnection(); |
184 | 184 | $this->query_time = microtime(true); |
185 | 185 | $this->lastsql = $sql; |
186 | - $result = $suppress?@mysql_query($sql, $this->database):mysql_query($sql, $this->database); |
|
186 | + $result = $suppress ? @mysql_query($sql, $this->database) : mysql_query($sql, $this->database); |
|
187 | 187 | |
188 | 188 | $this->query_time = microtime(true) - $this->query_time; |
189 | 189 | $GLOBALS['log']->info('Query Execution Time:'.$this->query_time); |
190 | 190 | |
191 | 191 | |
192 | - if($keepResult) |
|
192 | + if ($keepResult) |
|
193 | 193 | $this->lastResult = $result; |
194 | 194 | |
195 | - $this->checkError($msg.' Query Failed:' . $sql . '::', $dieOnError); |
|
195 | + $this->checkError($msg.' Query Failed:'.$sql.'::', $dieOnError); |
|
196 | 196 | return $result; |
197 | 197 | } |
198 | 198 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | public function disconnect() |
229 | 229 | { |
230 | 230 | $GLOBALS['log']->debug('Calling MySQL::disconnect()'); |
231 | - if(!empty($this->database)){ |
|
231 | + if (!empty($this->database)) { |
|
232 | 232 | $this->freeResult(); |
233 | 233 | mysql_close($this->database); |
234 | 234 | $this->database = null; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | protected function freeDbResult($dbResult) |
242 | 242 | { |
243 | - if(!empty($dbResult)) |
|
243 | + if (!empty($dbResult)) |
|
244 | 244 | mysql_free_result($dbResult); |
245 | 245 | } |
246 | 246 | |
@@ -266,15 +266,15 @@ discard block |
||
266 | 266 | $count = (int)$count; |
267 | 267 | if ($start < 0) |
268 | 268 | $start = 0; |
269 | - $GLOBALS['log']->debug('Limit Query:' . $sql. ' Start: ' .$start . ' count: ' . $count); |
|
269 | + $GLOBALS['log']->debug('Limit Query:'.$sql.' Start: '.$start.' count: '.$count); |
|
270 | 270 | |
271 | 271 | $sql = "$sql LIMIT $start,$count"; |
272 | 272 | $this->lastsql = $sql; |
273 | 273 | |
274 | - if(!empty($GLOBALS['sugar_config']['check_query'])){ |
|
274 | + if (!empty($GLOBALS['sugar_config']['check_query'])) { |
|
275 | 275 | $this->checkQuery($sql); |
276 | 276 | } |
277 | - if(!$execute) { |
|
277 | + if (!$execute) { |
|
278 | 278 | return $sql; |
279 | 279 | } |
280 | 280 | |
@@ -287,14 +287,14 @@ discard block |
||
287 | 287 | */ |
288 | 288 | protected function checkQuery($sql, $object_name = false) |
289 | 289 | { |
290 | - $result = $this->query('EXPLAIN ' . $sql); |
|
290 | + $result = $this->query('EXPLAIN '.$sql); |
|
291 | 291 | $badQuery = array(); |
292 | 292 | while ($row = $this->fetchByAssoc($result)) { |
293 | 293 | if (empty($row['table'])) |
294 | 294 | continue; |
295 | 295 | $badQuery[$row['table']] = ''; |
296 | 296 | if (strtoupper($row['type']) == 'ALL') |
297 | - $badQuery[$row['table']] .= ' Full Table Scan;'; |
|
297 | + $badQuery[$row['table']] .= ' Full Table Scan;'; |
|
298 | 298 | if (empty($row['key'])) |
299 | 299 | $badQuery[$row['table']] .= ' No Index Key Used;'; |
300 | 300 | if (!empty($row['Extra']) && substr_count($row['Extra'], 'Using filesort') > 0) |
@@ -303,18 +303,18 @@ discard block |
||
303 | 303 | $badQuery[$row['table']] .= ' Using Temporary Table;'; |
304 | 304 | } |
305 | 305 | |
306 | - if ( empty($badQuery) ) |
|
306 | + if (empty($badQuery)) |
|
307 | 307 | return true; |
308 | 308 | |
309 | - foreach($badQuery as $table=>$data ){ |
|
310 | - if(!empty($data)){ |
|
311 | - $warning = ' Table:' . $table . ' Data:' . $data; |
|
312 | - if(!empty($GLOBALS['sugar_config']['check_query_log'])){ |
|
309 | + foreach ($badQuery as $table=>$data) { |
|
310 | + if (!empty($data)) { |
|
311 | + $warning = ' Table:'.$table.' Data:'.$data; |
|
312 | + if (!empty($GLOBALS['sugar_config']['check_query_log'])) { |
|
313 | 313 | $GLOBALS['log']->fatal($sql); |
314 | - $GLOBALS['log']->fatal('CHECK QUERY:' .$warning); |
|
314 | + $GLOBALS['log']->fatal('CHECK QUERY:'.$warning); |
|
315 | 315 | } |
316 | - else{ |
|
317 | - $GLOBALS['log']->warn('CHECK QUERY:' .$warning); |
|
316 | + else { |
|
317 | + $GLOBALS['log']->warn('CHECK QUERY:'.$warning); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | } |
@@ -331,19 +331,19 @@ discard block |
||
331 | 331 | $result = $this->query("DESCRIBE $tablename"); |
332 | 332 | |
333 | 333 | $columns = array(); |
334 | - while (($row=$this->fetchByAssoc($result)) !=null) { |
|
334 | + while (($row = $this->fetchByAssoc($result)) != null) { |
|
335 | 335 | $name = strtolower($row['Field']); |
336 | - $columns[$name]['name']=$name; |
|
336 | + $columns[$name]['name'] = $name; |
|
337 | 337 | $matches = array(); |
338 | 338 | preg_match_all('/(\w+)(?:\(([0-9]+,?[0-9]*)\)|)( unsigned)?/i', $row['Type'], $matches); |
339 | - $columns[$name]['type']=strtolower($matches[1][0]); |
|
340 | - if ( isset($matches[2][0]) && in_array(strtolower($matches[1][0]),array('varchar','char','varchar2','int','decimal','float')) ) |
|
341 | - $columns[$name]['len']=strtolower($matches[2][0]); |
|
342 | - if ( stristr($row['Extra'],'auto_increment') ) |
|
339 | + $columns[$name]['type'] = strtolower($matches[1][0]); |
|
340 | + if (isset($matches[2][0]) && in_array(strtolower($matches[1][0]), array('varchar', 'char', 'varchar2', 'int', 'decimal', 'float'))) |
|
341 | + $columns[$name]['len'] = strtolower($matches[2][0]); |
|
342 | + if (stristr($row['Extra'], 'auto_increment')) |
|
343 | 343 | $columns[$name]['auto_increment'] = '1'; |
344 | - if ($row['Null'] == 'NO' && !stristr($row['Key'],'PRI')) |
|
344 | + if ($row['Null'] == 'NO' && !stristr($row['Key'], 'PRI')) |
|
345 | 345 | $columns[$name]['required'] = 'true'; |
346 | - if (!empty($row['Default']) ) |
|
346 | + if (!empty($row['Default'])) |
|
347 | 347 | $columns[$name]['default'] = $row['Default']; |
348 | 348 | } |
349 | 349 | return $columns; |
@@ -352,20 +352,20 @@ discard block |
||
352 | 352 | /** |
353 | 353 | * @see DBManager::getFieldsArray() |
354 | 354 | */ |
355 | - public function getFieldsArray($result, $make_lower_case=false) |
|
355 | + public function getFieldsArray($result, $make_lower_case = false) |
|
356 | 356 | { |
357 | 357 | $field_array = array(); |
358 | 358 | |
359 | - if(empty($result)) |
|
359 | + if (empty($result)) |
|
360 | 360 | return 0; |
361 | 361 | |
362 | 362 | $fields = mysql_num_fields($result); |
363 | - for ($i=0; $i < $fields; $i++) { |
|
363 | + for ($i = 0; $i < $fields; $i++) { |
|
364 | 364 | $meta = mysql_fetch_field($result, $i); |
365 | 365 | if (!$meta) |
366 | 366 | return array(); |
367 | 367 | |
368 | - if($make_lower_case == true) |
|
368 | + if ($make_lower_case == true) |
|
369 | 369 | $meta->name = strtolower($meta->name); |
370 | 370 | |
371 | 371 | $field_array[] = $meta->name; |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | if (!empty($r)) { |
398 | 398 | while ($a = $this->fetchByAssoc($r)) { |
399 | 399 | $row = array_values($a); |
400 | - $tables[]=$row[0]; |
|
400 | + $tables[] = $row[0]; |
|
401 | 401 | } |
402 | 402 | return $tables; |
403 | 403 | } |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | |
424 | 424 | if ($this->getDatabase()) { |
425 | 425 | $result = $this->query("SHOW TABLES LIKE ".$this->quoted($tableName)); |
426 | - if(empty($result)) return false; |
|
426 | + if (empty($result)) return false; |
|
427 | 427 | $row = $this->fetchByAssoc($result); |
428 | 428 | return !empty($row); |
429 | 429 | } |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | if (!empty($r)) { |
445 | 445 | while ($a = $this->fetchByAssoc($r)) { |
446 | 446 | $row = array_values($a); |
447 | - $tables[]=$row[0]; |
|
447 | + $tables[] = $row[0]; |
|
448 | 448 | } |
449 | 449 | return $tables; |
450 | 450 | } |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | */ |
458 | 458 | public function quote($string) |
459 | 459 | { |
460 | - if(is_array($string)) { |
|
460 | + if (is_array($string)) { |
|
461 | 461 | return $this->arrayQuote($string); |
462 | 462 | } |
463 | 463 | return mysqli_real_escape_string($this->quoteInternal($string), $this->getDatabase()); |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | { |
479 | 479 | global $sugar_config; |
480 | 480 | |
481 | - if(is_null($configOptions)) |
|
481 | + if (is_null($configOptions)) |
|
482 | 482 | $configOptions = $sugar_config['dbconfig']; |
483 | 483 | |
484 | 484 | if ($this->getOption('persistent')) { |
@@ -495,10 +495,10 @@ discard block |
||
495 | 495 | $configOptions['db_user_name'], |
496 | 496 | $configOptions['db_password'] |
497 | 497 | ); |
498 | - if(empty($this->database)) { |
|
498 | + if (empty($this->database)) { |
|
499 | 499 | $GLOBALS['log']->fatal("Could not connect to server ".$configOptions['db_host_name']." as ".$configOptions['db_user_name'].":".mysql_error()); |
500 | - if($dieOnError) { |
|
501 | - if(isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
500 | + if ($dieOnError) { |
|
501 | + if (isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
502 | 502 | sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
503 | 503 | } else { |
504 | 504 | sugar_die("Could not connect to the database. Please refer to suitecrm.log for details."); |
@@ -508,15 +508,15 @@ discard block |
||
508 | 508 | } |
509 | 509 | } |
510 | 510 | // Do not pass connection information because we have not connected yet |
511 | - if($this->database && $this->getOption('persistent')){ |
|
511 | + if ($this->database && $this->getOption('persistent')) { |
|
512 | 512 | $_SESSION['administrator_error'] = "<b>Severe Performance Degradation: Persistent Database Connections " |
513 | 513 | . "not working. Please set \$sugar_config['dbconfigoption']['persistent'] to false " |
514 | 514 | . "in your config.php file</b>"; |
515 | 515 | } |
516 | 516 | } |
517 | - if(!empty($configOptions['db_name']) && !@mysql_select_db($configOptions['db_name'])) { |
|
518 | - $GLOBALS['log']->fatal( "Unable to select database {$configOptions['db_name']}: " . mysql_error($this->database)); |
|
519 | - if($dieOnError) { |
|
517 | + if (!empty($configOptions['db_name']) && !@mysql_select_db($configOptions['db_name'])) { |
|
518 | + $GLOBALS['log']->fatal("Unable to select database {$configOptions['db_name']}: ".mysql_error($this->database)); |
|
519 | + if ($dieOnError) { |
|
520 | 520 | sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
521 | 521 | } else { |
522 | 522 | return false; |
@@ -527,12 +527,12 @@ discard block |
||
527 | 527 | mysql_query("SET CHARACTER SET utf8", $this->database); |
528 | 528 | $names = "SET NAMES 'utf8'"; |
529 | 529 | $collation = $this->getOption('collation'); |
530 | - if(!empty($collation)) { |
|
530 | + if (!empty($collation)) { |
|
531 | 531 | $names .= " COLLATE '$collation'"; |
532 | 532 | } |
533 | 533 | mysql_query($names, $this->database); |
534 | 534 | |
535 | - if(!$this->checkError('Could Not Connect:', $dieOnError)) |
|
535 | + if (!$this->checkError('Could Not Connect:', $dieOnError)) |
|
536 | 536 | $GLOBALS['log']->info("connected to db"); |
537 | 537 | $this->connectOptions = $configOptions; |
538 | 538 | |
@@ -548,16 +548,16 @@ discard block |
||
548 | 548 | */ |
549 | 549 | public function repairTableParams($tablename, $fielddefs, $indices, $execute = true, $engine = null) |
550 | 550 | { |
551 | - $sql = parent::repairTableParams($tablename,$fielddefs,$indices,false,$engine); |
|
551 | + $sql = parent::repairTableParams($tablename, $fielddefs, $indices, false, $engine); |
|
552 | 552 | |
553 | - if ( $sql == '' ) |
|
553 | + if ($sql == '') |
|
554 | 554 | return ''; |
555 | 555 | |
556 | - if ( stristr($sql,'create table') ) |
|
556 | + if (stristr($sql, 'create table')) |
|
557 | 557 | { |
558 | 558 | if ($execute) { |
559 | - $msg = "Error creating table: ".$tablename. ":"; |
|
560 | - $this->query($sql,true,$msg); |
|
559 | + $msg = "Error creating table: ".$tablename.":"; |
|
560 | + $this->query($sql, true, $msg); |
|
561 | 561 | } |
562 | 562 | return $sql; |
563 | 563 | } |
@@ -566,23 +566,23 @@ discard block |
||
566 | 566 | $match = array(); |
567 | 567 | preg_match_all('!/\*.*?\*/!is', $sql, $match); |
568 | 568 | $commentBlocks = $match[0]; |
569 | - $sql = preg_replace('!/\*.*?\*/!is','', $sql); |
|
569 | + $sql = preg_replace('!/\*.*?\*/!is', '', $sql); |
|
570 | 570 | |
571 | 571 | // now, we should only have alter table statements |
572 | 572 | // let's replace the 'alter table name' part with a comma |
573 | - $sql = preg_replace("!alter table $tablename!is",', ', $sql); |
|
573 | + $sql = preg_replace("!alter table $tablename!is", ', ', $sql); |
|
574 | 574 | |
575 | 575 | // re-add it at the beginning |
576 | - $sql = substr_replace($sql,'',strpos($sql,','),1); |
|
577 | - $sql = str_replace(";","",$sql); |
|
578 | - $sql = str_replace("\n","",$sql); |
|
576 | + $sql = substr_replace($sql, '', strpos($sql, ','), 1); |
|
577 | + $sql = str_replace(";", "", $sql); |
|
578 | + $sql = str_replace("\n", "", $sql); |
|
579 | 579 | $sql = "ALTER TABLE $tablename $sql"; |
580 | 580 | |
581 | - if ( $execute ) |
|
582 | - $this->query($sql,'Error with MySQL repair table'); |
|
581 | + if ($execute) |
|
582 | + $this->query($sql, 'Error with MySQL repair table'); |
|
583 | 583 | |
584 | 584 | // and re-add the comments at the beginning |
585 | - $sql = implode("\n",$commentBlocks) . "\n". $sql . "\n"; |
|
585 | + $sql = implode("\n", $commentBlocks)."\n".$sql."\n"; |
|
586 | 586 | |
587 | 587 | return $sql; |
588 | 588 | } |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | public function convert($string, $type, array $additional_parameters = array()) |
594 | 594 | { |
595 | 595 | $all_parameters = $additional_parameters; |
596 | - if(is_array($string)) { |
|
596 | + if (is_array($string)) { |
|
597 | 597 | $all_parameters = array_merge($string, $all_parameters); |
598 | 598 | } elseif (!is_null($string)) { |
599 | 599 | array_unshift($all_parameters, $string); |
@@ -606,17 +606,17 @@ discard block |
||
606 | 606 | case 'left': |
607 | 607 | return "LEFT($all_strings)"; |
608 | 608 | case 'date_format': |
609 | - if(empty($additional_parameters)) { |
|
609 | + if (empty($additional_parameters)) { |
|
610 | 610 | return "DATE_FORMAT($string,'%Y-%m-%d')"; |
611 | 611 | } else { |
612 | 612 | $format = $additional_parameters[0]; |
613 | - if($format[0] != "'") { |
|
613 | + if ($format[0] != "'") { |
|
614 | 614 | $format = $this->quoted($format); |
615 | 615 | } |
616 | 616 | return "DATE_FORMAT($string,$format)"; |
617 | 617 | } |
618 | 618 | case 'ifnull': |
619 | - if(empty($additional_parameters) && !strstr($all_strings, ",")) { |
|
619 | + if (empty($additional_parameters) && !strstr($all_strings, ",")) { |
|
620 | 620 | $all_strings .= ",''"; |
621 | 621 | } |
622 | 622 | return "IFNULL($all_strings)"; |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | case 'add_tz_offset' : |
636 | 636 | $getUserUTCOffset = $GLOBALS['timedate']->getUserUTCOffset(); |
637 | 637 | $operation = $getUserUTCOffset < 0 ? '-' : '+'; |
638 | - return $string . ' ' . $operation . ' INTERVAL ' . abs($getUserUTCOffset) . ' MINUTE'; |
|
638 | + return $string.' '.$operation.' INTERVAL '.abs($getUserUTCOffset).' MINUTE'; |
|
639 | 639 | case 'avg': |
640 | 640 | return "avg($string)"; |
641 | 641 | } |
@@ -676,15 +676,15 @@ discard block |
||
676 | 676 | */ |
677 | 677 | protected function isEngineEnabled($engine) |
678 | 678 | { |
679 | - if(!is_string($engine)) return false; |
|
679 | + if (!is_string($engine)) return false; |
|
680 | 680 | |
681 | 681 | $engine = strtoupper($engine); |
682 | 682 | |
683 | 683 | $r = $this->query("SHOW ENGINES"); |
684 | 684 | |
685 | - while ( $row = $this->fetchByAssoc($r) ) |
|
686 | - if ( strtoupper($row['Engine']) == $engine ) |
|
687 | - return ($row['Support']=='YES' || $row['Support']=='DEFAULT'); |
|
685 | + while ($row = $this->fetchByAssoc($r)) |
|
686 | + if (strtoupper($row['Engine']) == $engine) |
|
687 | + return ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT'); |
|
688 | 688 | |
689 | 689 | return false; |
690 | 690 | } |
@@ -712,9 +712,9 @@ discard block |
||
712 | 712 | */ |
713 | 713 | public function createTableSQLParams($tablename, $fieldDefs, $indices, $engine = null) |
714 | 714 | { |
715 | - if ( empty($engine) && isset($fieldDefs['engine'])) |
|
715 | + if (empty($engine) && isset($fieldDefs['engine'])) |
|
716 | 716 | $engine = $fieldDefs['engine']; |
717 | - if ( !$this->isEngineEnabled($engine) ) |
|
717 | + if (!$this->isEngineEnabled($engine)) |
|
718 | 718 | $engine = ''; |
719 | 719 | |
720 | 720 | $columns = $this->columnSQLRep($fieldDefs, false, $tablename); |
@@ -727,13 +727,13 @@ discard block |
||
727 | 727 | |
728 | 728 | // cn: bug 9873 - module tables do not get created in utf8 with assoc collation |
729 | 729 | $collation = $this->getOption('collation'); |
730 | - if(empty($collation)) { |
|
730 | + if (empty($collation)) { |
|
731 | 731 | $collation = 'utf8_general_ci'; |
732 | 732 | } |
733 | 733 | $sql = "CREATE TABLE $tablename ($columns $keys) CHARACTER SET utf8 COLLATE $collation"; |
734 | 734 | |
735 | 735 | if (!empty($engine)) |
736 | - $sql.= " ENGINE=$engine"; |
|
736 | + $sql .= " ENGINE=$engine"; |
|
737 | 737 | |
738 | 738 | return $sql; |
739 | 739 | } |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | public function isTextType($type) |
746 | 746 | { |
747 | 747 | $type = $this->getColumnType(strtolower($type)); |
748 | - return in_array($type, array('blob','text','longblob', 'longtext')); |
|
748 | + return in_array($type, array('blob', 'text', 'longblob', 'longtext')); |
|
749 | 749 | } |
750 | 750 | |
751 | 751 | /** |
@@ -756,16 +756,16 @@ discard block |
||
756 | 756 | // always return as array for post-processing |
757 | 757 | $ref = parent::oneColumnSQLRep($fieldDef, $ignoreRequired, $table, true); |
758 | 758 | |
759 | - if ( $ref['colType'] == 'int' && !empty($fieldDef['len']) ) { |
|
759 | + if ($ref['colType'] == 'int' && !empty($fieldDef['len'])) { |
|
760 | 760 | $ref['colType'] .= "(".$fieldDef['len'].")"; |
761 | 761 | } |
762 | 762 | |
763 | 763 | // bug 22338 - don't set a default value on text or blob fields |
764 | - if ( isset($ref['default']) && |
|
764 | + if (isset($ref['default']) && |
|
765 | 765 | in_array($ref['colBaseType'], array('text', 'blob', 'longtext', 'longblob'))) |
766 | 766 | $ref['default'] = ''; |
767 | 767 | |
768 | - if ( $return_as_array ) |
|
768 | + if ($return_as_array) |
|
769 | 769 | return $ref; |
770 | 770 | else |
771 | 771 | return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}"; |
@@ -777,8 +777,8 @@ discard block |
||
777 | 777 | protected function changeColumnSQL($tablename, $fieldDefs, $action, $ignoreRequired = false) |
778 | 778 | { |
779 | 779 | $columns = array(); |
780 | - if ($this->isFieldArray($fieldDefs)){ |
|
781 | - foreach ($fieldDefs as $def){ |
|
780 | + if ($this->isFieldArray($fieldDefs)) { |
|
781 | + foreach ($fieldDefs as $def) { |
|
782 | 782 | if ($action == 'drop') |
783 | 783 | $columns[] = $def['name']; |
784 | 784 | else |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | |
816 | 816 | $columns = array(); |
817 | 817 | foreach ($indices as $index) { |
818 | - if(!empty($index['db']) && $index['db'] != $this->dbType) |
|
818 | + if (!empty($index['db']) && $index['db'] != $this->dbType) |
|
819 | 819 | continue; |
820 | 820 | if (isset($index['source']) && $index['source'] != 'db') |
821 | 821 | continue; |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | * that this can easily be fixed by referring to db dictionary |
846 | 846 | * to find the correct primary field name |
847 | 847 | */ |
848 | - if ( $alter_table ) |
|
848 | + if ($alter_table) |
|
849 | 849 | $columns[] = " INDEX $name ($fields)"; |
850 | 850 | else |
851 | 851 | $columns[] = " KEY $name ($fields)"; |
@@ -854,13 +854,13 @@ discard block |
||
854 | 854 | if ($this->full_text_indexing_installed()) |
855 | 855 | $columns[] = " FULLTEXT ($fields)"; |
856 | 856 | else |
857 | - $GLOBALS['log']->debug('MYISAM engine is not available/enabled, full-text indexes will be skipped. Skipping:',$name); |
|
857 | + $GLOBALS['log']->debug('MYISAM engine is not available/enabled, full-text indexes will be skipped. Skipping:', $name); |
|
858 | 858 | break; |
859 | 859 | } |
860 | 860 | } |
861 | 861 | $columns = implode(", $alter_action ", $columns); |
862 | - if(!empty($alter_action)){ |
|
863 | - $columns = $alter_action . ' '. $columns; |
|
862 | + if (!empty($alter_action)) { |
|
863 | + $columns = $alter_action.' '.$columns; |
|
864 | 864 | } |
865 | 865 | return $columns; |
866 | 866 | } |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | public function setAutoIncrementStart($table, $field_name, $start_value) |
883 | 883 | { |
884 | 884 | $start_value = (int)$start_value; |
885 | - return $this->query( "ALTER TABLE $table AUTO_INCREMENT = $start_value;"); |
|
885 | + return $this->query("ALTER TABLE $table AUTO_INCREMENT = $start_value;"); |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | /** |
@@ -911,18 +911,18 @@ discard block |
||
911 | 911 | $result = $this->query("SHOW INDEX FROM $tablename"); |
912 | 912 | |
913 | 913 | $indices = array(); |
914 | - while (($row=$this->fetchByAssoc($result)) !=null) { |
|
915 | - $index_type='index'; |
|
916 | - if ($row['Key_name'] =='PRIMARY') { |
|
917 | - $index_type='primary'; |
|
914 | + while (($row = $this->fetchByAssoc($result)) != null) { |
|
915 | + $index_type = 'index'; |
|
916 | + if ($row['Key_name'] == 'PRIMARY') { |
|
917 | + $index_type = 'primary'; |
|
918 | 918 | } |
919 | - elseif ( $row['Non_unique'] == '0' ) { |
|
920 | - $index_type='unique'; |
|
919 | + elseif ($row['Non_unique'] == '0') { |
|
920 | + $index_type = 'unique'; |
|
921 | 921 | } |
922 | 922 | $name = strtolower($row['Key_name']); |
923 | - $indices[$name]['name']=$name; |
|
924 | - $indices[$name]['type']=$index_type; |
|
925 | - $indices[$name]['fields'][]=strtolower($row['Column_name']); |
|
923 | + $indices[$name]['name'] = $name; |
|
924 | + $indices[$name]['type'] = $index_type; |
|
925 | + $indices[$name]['fields'][] = strtolower($row['Column_name']); |
|
926 | 926 | } |
927 | 927 | return $indices; |
928 | 928 | } |
@@ -933,11 +933,11 @@ discard block |
||
933 | 933 | public function add_drop_constraint($table, $definition, $drop = false) |
934 | 934 | { |
935 | 935 | $type = $definition['type']; |
936 | - $fields = implode(',',$definition['fields']); |
|
936 | + $fields = implode(',', $definition['fields']); |
|
937 | 937 | $name = $definition['name']; |
938 | 938 | $sql = ''; |
939 | 939 | |
940 | - switch ($type){ |
|
940 | + switch ($type) { |
|
941 | 941 | // generic indices |
942 | 942 | case 'index': |
943 | 943 | case 'alternate_key': |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | */ |
982 | 982 | public function fetchOne($sql, $dieOnError = false, $msg = '', $suppress = false) |
983 | 983 | { |
984 | - if(stripos($sql, ' LIMIT ') === false) { |
|
984 | + if (stripos($sql, ' LIMIT ') === false) { |
|
985 | 985 | // little optimization to just fetch one row |
986 | 986 | $sql .= " LIMIT 0,1"; |
987 | 987 | } |
@@ -1001,13 +1001,13 @@ discard block |
||
1001 | 1001 | */ |
1002 | 1002 | public function massageFieldDef(&$fieldDef, $tablename) |
1003 | 1003 | { |
1004 | - parent::massageFieldDef($fieldDef,$tablename); |
|
1004 | + parent::massageFieldDef($fieldDef, $tablename); |
|
1005 | 1005 | |
1006 | - if ( isset($fieldDef['default']) && |
|
1006 | + if (isset($fieldDef['default']) && |
|
1007 | 1007 | ($fieldDef['dbType'] == 'text' |
1008 | 1008 | || $fieldDef['dbType'] == 'blob' |
1009 | 1009 | || $fieldDef['dbType'] == 'longtext' |
1010 | - || $fieldDef['dbType'] == 'longblob' )) |
|
1010 | + || $fieldDef['dbType'] == 'longblob')) |
|
1011 | 1011 | unset($fieldDef['default']); |
1012 | 1012 | if ($fieldDef['dbType'] == 'uint') |
1013 | 1013 | $fieldDef['len'] = '10'; |
@@ -1015,22 +1015,22 @@ discard block |
||
1015 | 1015 | $fieldDef['len'] = '20'; |
1016 | 1016 | if ($fieldDef['dbType'] == 'bool') |
1017 | 1017 | $fieldDef['type'] = 'tinyint'; |
1018 | - if ($fieldDef['dbType'] == 'bool' && empty($fieldDef['default']) ) |
|
1018 | + if ($fieldDef['dbType'] == 'bool' && empty($fieldDef['default'])) |
|
1019 | 1019 | $fieldDef['default'] = '0'; |
1020 | - if (($fieldDef['dbType'] == 'varchar' || $fieldDef['dbType'] == 'enum') && empty($fieldDef['len']) ) |
|
1020 | + if (($fieldDef['dbType'] == 'varchar' || $fieldDef['dbType'] == 'enum') && empty($fieldDef['len'])) |
|
1021 | 1021 | $fieldDef['len'] = '255'; |
1022 | 1022 | if ($fieldDef['dbType'] == 'uint') |
1023 | 1023 | $fieldDef['len'] = '10'; |
1024 | - if ($fieldDef['dbType'] == 'int' && empty($fieldDef['len']) ) |
|
1024 | + if ($fieldDef['dbType'] == 'int' && empty($fieldDef['len'])) |
|
1025 | 1025 | $fieldDef['len'] = '11'; |
1026 | 1026 | |
1027 | - if($fieldDef['dbType'] == 'decimal') { |
|
1028 | - if(isset($fieldDef['len'])) { |
|
1029 | - if(strstr($fieldDef['len'], ",") === false) { |
|
1027 | + if ($fieldDef['dbType'] == 'decimal') { |
|
1028 | + if (isset($fieldDef['len'])) { |
|
1029 | + if (strstr($fieldDef['len'], ",") === false) { |
|
1030 | 1030 | $fieldDef['len'] .= ",0"; |
1031 | 1031 | } |
1032 | 1032 | } else { |
1033 | - $fieldDef['len'] = '10,0'; |
|
1033 | + $fieldDef['len'] = '10,0'; |
|
1034 | 1034 | } |
1035 | 1035 | } |
1036 | 1036 | } |
@@ -1050,8 +1050,8 @@ discard block |
||
1050 | 1050 | { |
1051 | 1051 | $sql = array(); |
1052 | 1052 | foreach ($indexes as $index) { |
1053 | - $name =$index['name']; |
|
1054 | - if($execute) { |
|
1053 | + $name = $index['name']; |
|
1054 | + if ($execute) { |
|
1055 | 1055 | unset(self::$index_descriptions[$tablename][$name]); |
1056 | 1056 | } |
1057 | 1057 | if ($index['type'] == 'primary') { |
@@ -1061,8 +1061,8 @@ discard block |
||
1061 | 1061 | } |
1062 | 1062 | } |
1063 | 1063 | if (!empty($sql)) { |
1064 | - $sql = "ALTER TABLE $tablename " . join(",", $sql) . ";"; |
|
1065 | - if($execute) |
|
1064 | + $sql = "ALTER TABLE $tablename ".join(",", $sql).";"; |
|
1065 | + if ($execute) |
|
1066 | 1066 | $this->query($sql); |
1067 | 1067 | } else { |
1068 | 1068 | $sql = ''; |
@@ -1088,7 +1088,7 @@ discard block |
||
1088 | 1088 | $q = "SHOW COLLATION LIKE 'utf8%'"; |
1089 | 1089 | $r = $this->query($q); |
1090 | 1090 | $res = array(); |
1091 | - while($a = $this->fetchByAssoc($r)) { |
|
1091 | + while ($a = $this->fetchByAssoc($r)) { |
|
1092 | 1092 | $res[] = $a['Collation']; |
1093 | 1093 | } |
1094 | 1094 | return $res; |
@@ -1108,13 +1108,13 @@ discard block |
||
1108 | 1108 | public function emptyValue($type) |
1109 | 1109 | { |
1110 | 1110 | $ctype = $this->getColumnType($type); |
1111 | - if($ctype == "datetime") { |
|
1111 | + if ($ctype == "datetime") { |
|
1112 | 1112 | return 'NULL'; |
1113 | 1113 | } |
1114 | - if($ctype == "date") { |
|
1114 | + if ($ctype == "date") { |
|
1115 | 1115 | return 'NULL'; |
1116 | 1116 | } |
1117 | - if($ctype == "time") { |
|
1117 | + if ($ctype == "time") { |
|
1118 | 1118 | return 'NULL'; |
1119 | 1119 | } |
1120 | 1120 | return parent::emptyValue($type); |
@@ -1126,13 +1126,13 @@ discard block |
||
1126 | 1126 | */ |
1127 | 1127 | public function lastDbError() |
1128 | 1128 | { |
1129 | - if($this->database) { |
|
1130 | - if(mysql_errno($this->database)) { |
|
1129 | + if ($this->database) { |
|
1130 | + if (mysql_errno($this->database)) { |
|
1131 | 1131 | return "MySQL error ".mysql_errno($this->database).": ".mysql_error($this->database); |
1132 | 1132 | } |
1133 | 1133 | } else { |
1134 | - $err = mysql_error(); |
|
1135 | - if($err) { |
|
1134 | + $err = mysql_error(); |
|
1135 | + if ($err) { |
|
1136 | 1136 | return $err; |
1137 | 1137 | } |
1138 | 1138 | } |
@@ -1145,7 +1145,7 @@ discard block |
||
1145 | 1145 | */ |
1146 | 1146 | protected function quoteTerm($term) |
1147 | 1147 | { |
1148 | - if(strpos($term, ' ') !== false) { |
|
1148 | + if (strpos($term, ' ') !== false) { |
|
1149 | 1149 | return '"'.$term.'"'; |
1150 | 1150 | } |
1151 | 1151 | return $term; |
@@ -1161,16 +1161,16 @@ discard block |
||
1161 | 1161 | public function getFulltextQuery($field, $terms, $must_terms = array(), $exclude_terms = array()) |
1162 | 1162 | { |
1163 | 1163 | $condition = array(); |
1164 | - foreach($terms as $term) { |
|
1164 | + foreach ($terms as $term) { |
|
1165 | 1165 | $condition[] = $this->quoteTerm($term); |
1166 | 1166 | } |
1167 | - foreach($must_terms as $term) { |
|
1167 | + foreach ($must_terms as $term) { |
|
1168 | 1168 | $condition[] = "+".$this->quoteTerm($term); |
1169 | 1169 | } |
1170 | - foreach($exclude_terms as $term) { |
|
1170 | + foreach ($exclude_terms as $term) { |
|
1171 | 1171 | $condition[] = "-".$this->quoteTerm($term); |
1172 | 1172 | } |
1173 | - $condition = $this->quoted(join(" ",$condition)); |
|
1173 | + $condition = $this->quoted(join(" ", $condition)); |
|
1174 | 1174 | return "MATCH($field) AGAINST($condition IN BOOLEAN MODE)"; |
1175 | 1175 | } |
1176 | 1176 | |
@@ -1182,7 +1182,7 @@ discard block |
||
1182 | 1182 | { |
1183 | 1183 | $charsets = array(); |
1184 | 1184 | $res = $this->query("show variables like 'character\\_set\\_%'"); |
1185 | - while($row = $this->fetchByAssoc($res)) { |
|
1185 | + while ($row = $this->fetchByAssoc($res)) { |
|
1186 | 1186 | $charsets[$row['Variable_name']] = $row['Value']; |
1187 | 1187 | } |
1188 | 1188 | return $charsets; |
@@ -1192,7 +1192,7 @@ discard block |
||
1192 | 1192 | { |
1193 | 1193 | $charsets = $this->getCharsetInfo(); |
1194 | 1194 | $charset_str = array(); |
1195 | - foreach($charsets as $name => $value) { |
|
1195 | + foreach ($charsets as $name => $value) { |
|
1196 | 1196 | $charset_str[] = "$name = $value"; |
1197 | 1197 | } |
1198 | 1198 | return array( |
@@ -1214,18 +1214,18 @@ discard block |
||
1214 | 1214 | { |
1215 | 1215 | $this->log->debug("creating temp table for [$table]..."); |
1216 | 1216 | $result = $this->query("SHOW CREATE TABLE {$table}"); |
1217 | - if(empty($result)) { |
|
1217 | + if (empty($result)) { |
|
1218 | 1218 | return false; |
1219 | 1219 | } |
1220 | 1220 | $row = $this->fetchByAssoc($result); |
1221 | - if(empty($row) || empty($row['Create Table'])) { |
|
1221 | + if (empty($row) || empty($row['Create Table'])) { |
|
1222 | 1222 | return false; |
1223 | 1223 | } |
1224 | 1224 | $create = $row['Create Table']; |
1225 | 1225 | // rewrite DDL with _temp name |
1226 | 1226 | $tempTableQuery = str_replace("CREATE TABLE `{$table}`", "CREATE TABLE `{$table}__uw_temp`", $create); |
1227 | 1227 | $r2 = $this->query($tempTableQuery); |
1228 | - if(empty($r2)) { |
|
1228 | + if (empty($r2)) { |
|
1229 | 1229 | return false; |
1230 | 1230 | } |
1231 | 1231 | |
@@ -1247,11 +1247,11 @@ discard block |
||
1247 | 1247 | $this->log->debug("verifying ALTER TABLE"); |
1248 | 1248 | // Skipping ALTER TABLE [table] DROP PRIMARY KEY because primary keys are not being copied |
1249 | 1249 | // over to the temp tables |
1250 | - if(strpos(strtoupper($query), 'DROP PRIMARY KEY') !== false) { |
|
1250 | + if (strpos(strtoupper($query), 'DROP PRIMARY KEY') !== false) { |
|
1251 | 1251 | $this->log->debug("Skipping DROP PRIMARY KEY"); |
1252 | 1252 | return ''; |
1253 | 1253 | } |
1254 | - if(!$this->makeTempTableCopy($table)) { |
|
1254 | + if (!$this->makeTempTableCopy($table)) { |
|
1255 | 1255 | return 'Could not create temp table copy'; |
1256 | 1256 | } |
1257 | 1257 | |
@@ -1259,7 +1259,7 @@ discard block |
||
1259 | 1259 | $this->log->debug('testing query: ['.$query.']'); |
1260 | 1260 | $tempTableTestQuery = str_replace("ALTER TABLE `{$table}`", "ALTER TABLE `{$table}__uw_temp`", $query); |
1261 | 1261 | if (strpos($tempTableTestQuery, 'idx') === false) { |
1262 | - if(strpos($tempTableTestQuery, '__uw_temp') === false) { |
|
1262 | + if (strpos($tempTableTestQuery, '__uw_temp') === false) { |
|
1263 | 1263 | return 'Could not use a temp table to test query!'; |
1264 | 1264 | } |
1265 | 1265 | |
@@ -1272,7 +1272,7 @@ discard block |
||
1272 | 1272 | $this->query($tempTableTestQuery_idx, false, "Preflight Failed for: {$query}"); |
1273 | 1273 | } |
1274 | 1274 | $mysqlError = $this->getL(); |
1275 | - if(!empty($mysqlError)) { |
|
1275 | + if (!empty($mysqlError)) { |
|
1276 | 1276 | return $mysqlError; |
1277 | 1277 | } |
1278 | 1278 | $this->dropTableName("{$table}__uw_temp"); |
@@ -1284,13 +1284,13 @@ discard block |
||
1284 | 1284 | { |
1285 | 1285 | $this->log->debug("verifying $querytype statement"); |
1286 | 1286 | |
1287 | - if(!$this->makeTempTableCopy($table)) { |
|
1287 | + if (!$this->makeTempTableCopy($table)) { |
|
1288 | 1288 | return 'Could not create temp table copy'; |
1289 | 1289 | } |
1290 | 1290 | // test the query on the test table |
1291 | 1291 | $this->log->debug('testing query: ['.$query.']'); |
1292 | 1292 | $tempTableTestQuery = str_replace("$querytype `{$table}`", "$querytype `{$table}__uw_temp`", $query); |
1293 | - if(strpos($tempTableTestQuery, '__uw_temp') === false) { |
|
1293 | + if (strpos($tempTableTestQuery, '__uw_temp') === false) { |
|
1294 | 1294 | return 'Could not use a temp table to test query!'; |
1295 | 1295 | } |
1296 | 1296 | |
@@ -1370,11 +1370,11 @@ discard block |
||
1370 | 1370 | public function userExists($username) |
1371 | 1371 | { |
1372 | 1372 | $db = $this->getOne("SELECT DATABASE()"); |
1373 | - if(!$this->selectDb("mysql")) { |
|
1373 | + if (!$this->selectDb("mysql")) { |
|
1374 | 1374 | return false; |
1375 | 1375 | } |
1376 | 1376 | $user = $this->getOne("select count(*) from user where user = ".$this->quoted($username)); |
1377 | - if(!$this->selectDb($db)) { |
|
1377 | + if (!$this->selectDb($db)) { |
|
1378 | 1378 | $this->checkError("Cannot select database $db", true); |
1379 | 1379 | } |
1380 | 1380 | return !empty($user); |
@@ -1396,7 +1396,7 @@ discard block |
||
1396 | 1396 | IDENTIFIED BY '{$qpassword}';", true); |
1397 | 1397 | |
1398 | 1398 | $this->query("SET PASSWORD FOR \"{$user}\"@\"{$host_name}\" = password('{$qpassword}');", true); |
1399 | - if($host_name != 'localhost') { |
|
1399 | + if ($host_name != 'localhost') { |
|
1400 | 1400 | $this->createDbUser($database_name, "localhost", $user, $password); |
1401 | 1401 | } |
1402 | 1402 | } |
@@ -1442,10 +1442,10 @@ discard block |
||
1442 | 1442 | public function canInstall() |
1443 | 1443 | { |
1444 | 1444 | $db_version = $this->version(); |
1445 | - if(empty($db_version)) { |
|
1445 | + if (empty($db_version)) { |
|
1446 | 1446 | return array('ERR_DB_VERSION_FAILURE'); |
1447 | 1447 | } |
1448 | - if(version_compare($db_version, '4.1.2') < 0) { |
|
1448 | + if (version_compare($db_version, '4.1.2') < 0) { |
|
1449 | 1449 | return array('ERR_DB_MYSQL_VERSION', $db_version); |
1450 | 1450 | } |
1451 | 1451 | return true; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * process the action. If this is set we will default to the noaccess view. |
180 | 180 | *@var bool |
181 | 181 | */ |
182 | - public $hasAccess ; |
|
182 | + public $hasAccess; |
|
183 | 183 | |
184 | 184 | /** |
185 | 185 | * Map case sensitive filenames to action. This is used for linux/unix systems |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | */ |
198 | 198 | public function __construct() |
199 | 199 | { |
200 | - $this->hasAccess = true;} |
|
200 | + $this->hasAccess = true; } |
|
201 | 201 | |
202 | 202 | /** |
203 | 203 | * @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 |
@@ -328,24 +328,24 @@ discard block |
||
328 | 328 | */ |
329 | 329 | private function loadMapping($var, $merge = false) |
330 | 330 | { |
331 | - $$var = sugar_cache_retrieve("CONTROLLER_" . $var . "_" . $this->module); |
|
331 | + $$var = sugar_cache_retrieve("CONTROLLER_".$var."_".$this->module); |
|
332 | 332 | if (!$$var) { |
333 | 333 | if ($merge && !empty($this->$var)) { |
334 | 334 | $$var = $this->$var; |
335 | 335 | } else { |
336 | 336 | $$var = array(); |
337 | 337 | } |
338 | - if (file_exists('include/MVC/Controller/' . $var . '.php')) { |
|
339 | - require('include/MVC/Controller/' . $var . '.php'); |
|
338 | + if (file_exists('include/MVC/Controller/'.$var.'.php')) { |
|
339 | + require('include/MVC/Controller/'.$var.'.php'); |
|
340 | 340 | } |
341 | - if (file_exists('modules/' . $this->module . '/' . $var . '.php')) { |
|
342 | - require('modules/' . $this->module . '/' . $var . '.php'); |
|
341 | + if (file_exists('modules/'.$this->module.'/'.$var.'.php')) { |
|
342 | + require('modules/'.$this->module.'/'.$var.'.php'); |
|
343 | 343 | } |
344 | - if (file_exists('custom/modules/' . $this->module . '/' . $var . '.php')) { |
|
345 | - require('custom/modules/' . $this->module . '/' . $var . '.php'); |
|
344 | + if (file_exists('custom/modules/'.$this->module.'/'.$var.'.php')) { |
|
345 | + require('custom/modules/'.$this->module.'/'.$var.'.php'); |
|
346 | 346 | } |
347 | - if (file_exists('custom/include/MVC/Controller/' . $var . '.php')) { |
|
348 | - require('custom/include/MVC/Controller/' . $var . '.php'); |
|
347 | + if (file_exists('custom/include/MVC/Controller/'.$var.'.php')) { |
|
348 | + require('custom/include/MVC/Controller/'.$var.'.php'); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | // entry_point_registry -> EntryPointRegistry |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | require("custom/modules/{$this->module}/Ext/$varname/$var.ext.php"); |
359 | 359 | } |
360 | 360 | |
361 | - sugar_cache_put("CONTROLLER_" . $var . "_" . $this->module, $$var); |
|
361 | + sugar_cache_put("CONTROLLER_".$var."_".$this->module, $$var); |
|
362 | 362 | } |
363 | 363 | $this->$var = $$var; |
364 | 364 | } |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | } elseif (!empty($this->redirect_url)) { |
377 | 377 | $this->redirect(); |
378 | 378 | } |
379 | - } catch (Exception $e) { |
|
379 | + }catch (Exception $e) { |
|
380 | 380 | $this->handleException($e); |
381 | 381 | } |
382 | 382 | |
@@ -385,8 +385,8 @@ discard block |
||
385 | 385 | |
386 | 386 | protected function showException(Exception $e) |
387 | 387 | { |
388 | - $GLOBALS['log']->fatal('Exception in Controller: ' . $e->getMessage()); |
|
389 | - $GLOBALS['log']->fatal("backtrace:\n" . $e->getTraceAsString()); |
|
388 | + $GLOBALS['log']->fatal('Exception in Controller: '.$e->getMessage()); |
|
389 | + $GLOBALS['log']->fatal("backtrace:\n".$e->getTraceAsString()); |
|
390 | 390 | if ($prev = $e->getPrevious()) { |
391 | 391 | $GLOBALS['log']->fatal("Previous:\n"); |
392 | 392 | $this->showException($prev); |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | */ |
400 | 400 | protected function handleException(Exception $e) |
401 | 401 | { |
402 | - $GLOBALS['log']->fatal("Exception handling in " . __FILE__ . ':' . __LINE__); |
|
402 | + $GLOBALS['log']->fatal("Exception handling in ".__FILE__.':'.__LINE__); |
|
403 | 403 | $this->showException($e); |
404 | 404 | $logicHook = new LogicHook(); |
405 | 405 | |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | |
520 | 520 | $function = $this->getActionMethodName(); |
521 | 521 | if ($this->hasFunction($function)) { |
522 | - $GLOBALS['log']->debug('Performing action: ' . $function . ' MODULE: ' . $this->module); |
|
522 | + $GLOBALS['log']->debug('Performing action: '.$function.' MODULE: '.$this->module); |
|
523 | 523 | $this->$function(); |
524 | 524 | |
525 | 525 | return true; |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | */ |
582 | 582 | protected function getPreActionMethodName() |
583 | 583 | { |
584 | - return 'pre_' . $this->action; |
|
584 | + return 'pre_'.$this->action; |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | /** |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | */ |
591 | 591 | protected function getActionMethodName() |
592 | 592 | { |
593 | - return 'action_' . strtolower($this->do_action); |
|
593 | + return 'action_'.strtolower($this->do_action); |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | /** |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | */ |
600 | 600 | protected function getPostActionMethodName() |
601 | 601 | { |
602 | - return 'post_' . strtolower($this->action); |
|
602 | + return 'post_'.strtolower($this->action); |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | /** |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | } |
656 | 656 | $this->bean->$field = $_POST[$field]; |
657 | 657 | } else { |
658 | - if (!empty($properties['isMultiSelect']) && !isset($_POST[$field]) && isset($_POST[$field . '_multiselect'])) { |
|
658 | + if (!empty($properties['isMultiSelect']) && !isset($_POST[$field]) && isset($_POST[$field.'_multiselect'])) { |
|
659 | 659 | $this->bean->$field = ''; |
660 | 660 | } |
661 | 661 | } |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | $action = (!empty($this->return_action) ? $this->return_action : 'DetailView'); |
700 | 700 | $id = (!empty($this->return_id) ? $this->return_id : $this->bean->id); |
701 | 701 | |
702 | - $url = "index.php?module=" . $module . "&action=" . $action . "&record=" . $id; |
|
702 | + $url = "index.php?module=".$module."&action=".$action."&record=".$id; |
|
703 | 703 | $this->set_redirect($url); |
704 | 704 | } |
705 | 705 | |
@@ -732,22 +732,19 @@ discard block |
||
732 | 732 | { |
733 | 733 | if (empty($_REQUEST['return_url'])) { |
734 | 734 | $return_module = isset($_REQUEST['return_module']) ? |
735 | - $_REQUEST['return_module'] : |
|
736 | - $GLOBALS['sugar_config']['default_module']; |
|
735 | + $_REQUEST['return_module'] : $GLOBALS['sugar_config']['default_module']; |
|
737 | 736 | $return_action = isset($_REQUEST['return_action']) ? |
738 | - $_REQUEST['return_action'] : |
|
739 | - $GLOBALS['sugar_config']['default_action']; |
|
737 | + $_REQUEST['return_action'] : $GLOBALS['sugar_config']['default_action']; |
|
740 | 738 | $return_id = isset($_REQUEST['return_id']) ? |
741 | - $_REQUEST['return_id'] : |
|
742 | - ''; |
|
743 | - $url = "index.php?module=" . $return_module . "&action=" . $return_action . "&record=" . $return_id; |
|
739 | + $_REQUEST['return_id'] : ''; |
|
740 | + $url = "index.php?module=".$return_module."&action=".$return_action."&record=".$return_id; |
|
744 | 741 | } else { |
745 | 742 | $url = $_REQUEST['return_url']; |
746 | 743 | } |
747 | 744 | |
748 | 745 | //eggsurplus Bug 23816: maintain VCR after an edit/save. If it is a duplicate then don't worry about it. The offset is now worthless. |
749 | 746 | if (isset($_REQUEST['offset']) && empty($_REQUEST['duplicateSave'])) { |
750 | - $url .= "&offset=" . $_REQUEST['offset']; |
|
747 | + $url .= "&offset=".$_REQUEST['offset']; |
|
751 | 748 | } |
752 | 749 | |
753 | 750 | $this->set_redirect($url); |
@@ -766,7 +763,7 @@ discard block |
||
766 | 763 | sugar_cleanup(true); |
767 | 764 | } |
768 | 765 | |
769 | - set_time_limit(0);//I'm wondering if we will set it never goes timeout here. |
|
766 | + set_time_limit(0); //I'm wondering if we will set it never goes timeout here. |
|
770 | 767 | // until we have more efficient way of handling MU, we have to disable the limit |
771 | 768 | $GLOBALS['db']->setQueryLimit(0); |
772 | 769 | require_once("include/MassUpdate.php"); |
@@ -778,7 +775,7 @@ discard block |
||
778 | 775 | $mass->generateSearchWhere($_REQUEST['module'], $_REQUEST['current_query_by_page']); |
779 | 776 | } |
780 | 777 | $mass->handleMassUpdate(); |
781 | - $storeQuery = new StoreQuery();//restore the current search. to solve bug 24722 for multi tabs massupdate. |
|
778 | + $storeQuery = new StoreQuery(); //restore the current search. to solve bug 24722 for multi tabs massupdate. |
|
782 | 779 | $temp_req = array( |
783 | 780 | 'current_query_by_page' => $_REQUEST['current_query_by_page'], |
784 | 781 | 'return_module' => $_REQUEST['return_module'], |
@@ -794,12 +791,12 @@ discard block |
||
794 | 791 | } |
795 | 792 | $_REQUEST = array(); |
796 | 793 | $_REQUEST = json_decode(html_entity_decode($temp_req['current_query_by_page']), true); |
797 | - unset($_REQUEST[$seed->module_dir . '2_' . strtoupper($seed->object_name) . '_offset']);//after massupdate, the page should redirect to no offset page |
|
794 | + unset($_REQUEST[$seed->module_dir.'2_'.strtoupper($seed->object_name).'_offset']); //after massupdate, the page should redirect to no offset page |
|
798 | 795 | $storeQuery->saveFromRequest($_REQUEST['module']); |
799 | 796 | $_REQUEST = array( |
800 | 797 | 'return_module' => $temp_req['return_module'], |
801 | 798 | 'return_action' => $temp_req['return_action'] |
802 | - );//for post_massupdate, to go back to original page. |
|
799 | + ); //for post_massupdate, to go back to original page. |
|
803 | 800 | } else { |
804 | 801 | sugar_die("You must massupdate at least one record"); |
805 | 802 | } |
@@ -811,15 +808,13 @@ discard block |
||
811 | 808 | protected function post_massupdate() |
812 | 809 | { |
813 | 810 | $return_module = isset($_REQUEST['return_module']) ? |
814 | - $_REQUEST['return_module'] : |
|
815 | - $GLOBALS['sugar_config']['default_module']; |
|
811 | + $_REQUEST['return_module'] : $GLOBALS['sugar_config']['default_module']; |
|
816 | 812 | $return_action = isset($_REQUEST['return_action']) ? |
817 | - $_REQUEST['return_action'] : |
|
818 | - $GLOBALS['sugar_config']['default_action']; |
|
819 | - $url = "index.php?module=" . $return_module . "&action=" . $return_action; |
|
813 | + $_REQUEST['return_action'] : $GLOBALS['sugar_config']['default_action']; |
|
814 | + $url = "index.php?module=".$return_module."&action=".$return_action; |
|
820 | 815 | if ($return_module == 'Emails') {//specificly for My Achieves |
821 | 816 | if (!empty($this->req_for_email['type']) && !empty($this->req_for_email['ie_assigned_user_id'])) { |
822 | - $url = $url . "&type=" . $this->req_for_email['type'] . "&assigned_user_id=" . $this->req_for_email['ie_assigned_user_id']; |
|
817 | + $url = $url."&type=".$this->req_for_email['type']."&assigned_user_id=".$this->req_for_email['ie_assigned_user_id']; |
|
823 | 818 | } |
824 | 819 | } |
825 | 820 | $this->set_redirect($url); |
@@ -893,8 +888,8 @@ discard block |
||
893 | 888 | } else { // display options |
894 | 889 | $json = getJSONobj(); |
895 | 890 | |
896 | - return 'result = ' . $json->encode((array( |
|
897 | - 'header' => $dashlet->title . ' : ' . $mod_strings['LBL_OPTIONS'], |
|
891 | + return 'result = '.$json->encode((array( |
|
892 | + 'header' => $dashlet->title.' : '.$mod_strings['LBL_OPTIONS'], |
|
898 | 893 | 'body' => $dashlet->displayOptions() |
899 | 894 | ))); |
900 | 895 | |
@@ -1054,15 +1049,15 @@ discard block |
||
1054 | 1049 | $action = 'list'; |
1055 | 1050 | } |
1056 | 1051 | |
1057 | - if ((file_exists('modules/' . $this->module . '/' . $file . '.php') |
|
1058 | - && !file_exists('modules/' . $this->module . '/views/view.' . $action . '.php')) |
|
1059 | - || (file_exists('custom/modules/' . $this->module . '/' . $file . '.php') |
|
1060 | - && !file_exists('custom/modules/' . $this->module . '/views/view.' . $action . '.php')) |
|
1052 | + if ((file_exists('modules/'.$this->module.'/'.$file.'.php') |
|
1053 | + && !file_exists('modules/'.$this->module.'/views/view.'.$action.'.php')) |
|
1054 | + || (file_exists('custom/modules/'.$this->module.'/'.$file.'.php') |
|
1055 | + && !file_exists('custom/modules/'.$this->module.'/views/view.'.$action.'.php')) |
|
1061 | 1056 | ) { |
1062 | 1057 | // A 'classic' module, using the old pre-MVC display files |
1063 | 1058 | // We should now discard the bean we just obtained for tracking as the pre-MVC module will instantiate its own |
1064 | 1059 | unset($GLOBALS['FOCUS']); |
1065 | - $GLOBALS['log']->debug('Module:' . $this->module . ' using file: ' . $file); |
|
1060 | + $GLOBALS['log']->debug('Module:'.$this->module.' using file: '.$file); |
|
1066 | 1061 | $this->action_default(); |
1067 | 1062 | $this->_processed = true; |
1068 | 1063 | } |
@@ -1077,11 +1072,11 @@ discard block |
||
1077 | 1072 | { |
1078 | 1073 | if (!empty($this->action_file_map[strtolower($this->do_action)])) { |
1079 | 1074 | $this->view = ''; |
1080 | - $GLOBALS['log']->debug('Using Action File Map:' . $this->action_file_map[strtolower($this->do_action)]); |
|
1075 | + $GLOBALS['log']->debug('Using Action File Map:'.$this->action_file_map[strtolower($this->do_action)]); |
|
1081 | 1076 | require_once($this->action_file_map[strtolower($this->do_action)]); |
1082 | 1077 | $this->_processed = true; |
1083 | 1078 | } elseif (!empty($this->action_view_map[strtolower($this->do_action)])) { |
1084 | - $GLOBALS['log']->debug('Using Action View Map:' . $this->action_view_map[strtolower($this->do_action)]); |
|
1079 | + $GLOBALS['log']->debug('Using Action View Map:'.$this->action_view_map[strtolower($this->do_action)]); |
|
1085 | 1080 | $this->view = $this->action_view_map[strtolower($this->do_action)]; |
1086 | 1081 | $this->_processed = true; |
1087 | 1082 | } else { |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | |
63 | 63 | require_once('include/formbase.php'); |
64 | 64 | |
65 | - global $beanFiles,$beanList; |
|
65 | + global $beanFiles, $beanList; |
|
66 | 66 | $bean_name = $beanList[$_REQUEST['module']]; |
67 | 67 | require_once($beanFiles[$bean_name]); |
68 | 68 | $focus = new $bean_name(); |
69 | - if ( empty($_REQUEST['linked_id']) || empty($_REQUEST['linked_field']) || empty($_REQUEST['record'])){ |
|
69 | + if (empty($_REQUEST['linked_id']) || empty($_REQUEST['linked_field']) || empty($_REQUEST['record'])) { |
|
70 | 70 | |
71 | 71 | die("need linked_field, linked_id and record fields"); |
72 | 72 | } |
@@ -78,26 +78,26 @@ discard block |
||
78 | 78 | ACLController::displayNoAccess(); |
79 | 79 | sugar_cleanup(true); |
80 | 80 | } |
81 | -}if($linked_field === 'aclroles') { |
|
82 | - if (!ACLController::checkAccess($bean_name , 'edit', true)) { |
|
81 | +}if ($linked_field === 'aclroles') { |
|
82 | + if (!ACLController::checkAccess($bean_name, 'edit', true)) { |
|
83 | 83 | ACLController::displayNoAccess(); |
84 | 84 | sugar_cleanup(true); |
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | -if ($bean_name === 'Team'){ |
|
88 | +if ($bean_name === 'Team') { |
|
89 | 89 | $focus->retrieve($record); |
90 | 90 | $focus->remove_user_from_team($linked_id); |
91 | 91 | } |
92 | - else{ |
|
92 | + else { |
|
93 | 93 | |
94 | 94 | // cut it off: |
95 | 95 | $focus->load_relationship($linked_field); |
96 | - if($focus->$linked_field->_relationship->relationship_name === 'quotes_contacts_shipto'){ |
|
97 | - unset($focus->$linked_field->_relationship->relationship_role_column);} |
|
98 | - $focus->$linked_field->delete($record,$linked_id); |
|
96 | + if ($focus->$linked_field->_relationship->relationship_name === 'quotes_contacts_shipto') { |
|
97 | + unset($focus->$linked_field->_relationship->relationship_role_column); } |
|
98 | + $focus->$linked_field->delete($record, $linked_id); |
|
99 | 99 | } |
100 | - if ($bean_name === 'Campaign' and $linked_field==='prospectlists' ) { |
|
100 | + if ($bean_name === 'Campaign' and $linked_field === 'prospectlists') { |
|
101 | 101 | |
102 | 102 | $query = "SELECT email_marketing_prospect_lists.id from email_marketing_prospect_lists "; |
103 | 103 | $query .= " left join email_marketing on email_marketing.id=email_marketing_prospect_lists.email_marketing_id"; |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | $result = $focus->db->query($query); |
108 | 108 | while (($row = $focus->db->fetchByAssoc($result)) != null) { |
109 | - $del_query = " update email_marketing_prospect_lists set email_marketing_prospect_lists.deleted=1, email_marketing_prospect_lists.date_modified=" . $focus->db->convert("'" . TimeDate::getInstance()->nowDb() . "'", |
|
109 | + $del_query = " update email_marketing_prospect_lists set email_marketing_prospect_lists.deleted=1, email_marketing_prospect_lists.date_modified=".$focus->db->convert("'".TimeDate::getInstance()->nowDb()."'", |
|
110 | 110 | 'datetime'); |
111 | 111 | $del_query .= " WHERE email_marketing_prospect_lists.id='{$row['id']}'"; |
112 | 112 | $focus->db->query($del_query); |
@@ -55,33 +55,33 @@ discard block |
||
55 | 55 | global $app_strings; |
56 | 56 | global $subpanel_item_count; |
57 | 57 | |
58 | - $unique_id = $layout_def['subpanel_id'] . "_remove_" . $subpanel_item_count; //bug 51512 |
|
58 | + $unique_id = $layout_def['subpanel_id']."_remove_".$subpanel_item_count; //bug 51512 |
|
59 | 59 | |
60 | 60 | $parent_record_id = $_REQUEST['record']; |
61 | 61 | $parent_module = $_REQUEST['module']; |
62 | 62 | |
63 | 63 | $action = 'DeleteRelationship'; |
64 | 64 | $record = $layout_def['fields']['ID']; |
65 | - $current_module=$layout_def['module']; |
|
65 | + $current_module = $layout_def['module']; |
|
66 | 66 | //in document revisions subpanel ,users are now allowed to |
67 | 67 | //delete the latest revsion of a document. this will be tested here |
68 | 68 | //and if the condition is met delete button will be removed. |
69 | - $hideremove=false; |
|
70 | - if ($current_module==='DocumentRevisions') { |
|
71 | - if ($layout_def['fields']['ID']===$layout_def['fields']['LATEST_REVISION_ID']) { |
|
72 | - $hideremove=true; |
|
69 | + $hideremove = false; |
|
70 | + if ($current_module === 'DocumentRevisions') { |
|
71 | + if ($layout_def['fields']['ID'] === $layout_def['fields']['LATEST_REVISION_ID']) { |
|
72 | + $hideremove = true; |
|
73 | 73 | } |
74 | 74 | }elseif ($_REQUEST['module'] === 'Teams' && $current_module === 'Users') { |
75 | 75 | // Implicit Team-memberships are not "removeable" |
76 | 76 | |
77 | - if($layout_def['fields']['UPLINE'] !== translate('LBL_TEAM_UPLINE_EXPLICIT', 'Users')) { |
|
77 | + if ($layout_def['fields']['UPLINE'] !== translate('LBL_TEAM_UPLINE_EXPLICIT', 'Users')) { |
|
78 | 78 | $hideremove = true; |
79 | 79 | } |
80 | 80 | |
81 | 81 | //We also cannot remove the user whose private team is set to the parent_record_id value |
82 | 82 | $user = new User(); |
83 | 83 | $user->retrieve($layout_def['fields']['ID']); |
84 | - if($parent_record_id === $user->getPrivateTeamID()){ |
|
84 | + if ($parent_record_id === $user->getPrivateTeamID()) { |
|
85 | 85 | |
86 | 86 | $hideremove = true; |
87 | 87 | }} elseif ($current_module === 'ACLRoles' && (!ACLController::checkAccess($current_module, 'edit', true))) { |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | $subpanel = $layout_def['subpanel_id']; |
96 | 96 | $return_id = $_REQUEST['record']; |
97 | 97 | if (isset($layout_def['linked_field_set']) && !empty($layout_def['linked_field_set'])) { |
98 | - $linked_field= $layout_def['linked_field_set'] ; |
|
98 | + $linked_field = $layout_def['linked_field_set']; |
|
99 | 99 | } else { |
100 | 100 | $linked_field = $layout_def['linked_field']; |
101 | 101 | } |
102 | 102 | $refresh_page = 0; |
103 | - if(!empty($layout_def['refresh_page'])){ |
|
103 | + if (!empty($layout_def['refresh_page'])) { |
|
104 | 104 | $refresh_page = 1; |
105 | 105 | } |
106 | 106 | $return_url = "index.php?module=$return_module&action=$return_action&subpanel=$subpanel&record=$return_id&sugar_body_only=1&inline=1"; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public static function clearCache($module, $view = '') |
116 | 116 | { |
117 | - $cacheDir = create_cache_directory('modules/' . $module . '/'); |
|
117 | + $cacheDir = create_cache_directory('modules/'.$module.'/'); |
|
118 | 118 | $d = dir($cacheDir); |
119 | 119 | while ($e = $d->read()) { |
120 | 120 | if (!empty($view) && $e !== $view) { |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | $end = strlen($e) - 4; |
125 | - if (is_file($cacheDir . $e) && $end > 1 && substr($e, $end) === '.tpl') { |
|
126 | - unlink($cacheDir . $e); |
|
125 | + if (is_file($cacheDir.$e) && $end > 1 && substr($e, $end) === '.tpl') { |
|
126 | + unlink($cacheDir.$e); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
@@ -134,10 +134,10 @@ discard block |
||
134 | 134 | * The tpl files for each theme should be cleared for consistency. |
135 | 135 | */ |
136 | 136 | $cacheDir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\'); |
137 | - $themesDir = array_filter(glob($cacheDir . '/themes/*'), 'is_dir'); |
|
137 | + $themesDir = array_filter(glob($cacheDir.'/themes/*'), 'is_dir'); |
|
138 | 138 | |
139 | 139 | foreach ($themesDir as $theme) { |
140 | - $tplDir = $theme . '/modules/' . $module . '/'; |
|
140 | + $tplDir = $theme.'/modules/'.$module.'/'; |
|
141 | 141 | if (!file_exists($tplDir)) { |
142 | 142 | continue; |
143 | 143 | } |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | $end = strlen($e) - 4; |
151 | - if ($end > 1 && is_file($tplDir . $e) && substr($e, $end) === '.tpl') { |
|
152 | - unlink($tplDir . $e); |
|
151 | + if ($end > 1 && is_file($tplDir.$e) && substr($e, $end) === '.tpl') { |
|
152 | + unlink($tplDir.$e); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | } |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | global $theme; |
172 | 172 | |
173 | 173 | $this->loadSmarty(); |
174 | - $cacheDir = create_cache_directory($this->themeDir . $theme . '/' . $this->templateDir . $module . '/'); |
|
175 | - $file = $cacheDir . $view . '.tpl'; |
|
174 | + $cacheDir = create_cache_directory($this->themeDir.$theme.'/'.$this->templateDir.$module.'/'); |
|
175 | + $file = $cacheDir.$view.'.tpl'; |
|
176 | 176 | $this->ss->left_delimiter = '{{'; |
177 | 177 | $this->ss->right_delimiter = '}}'; |
178 | 178 | $this->ss->assign('module', $module); |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | |
258 | 258 | $validatedFields = array(); |
259 | 259 | $javascript->addToValidateBinaryDependency('assigned_user_name', 'alpha', |
260 | - $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD') . ': ' . $javascript->buildStringToTranslateInSmarty('LBL_ASSIGNED_TO'), |
|
260 | + $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty('LBL_ASSIGNED_TO'), |
|
261 | 261 | 'false', '', 'assigned_user_id'); |
262 | 262 | $validatedFields[] = 'assigned_user_name'; |
263 | 263 | //Add remaining validation dependency for related fields |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | $vname = "undefined"; |
285 | 285 | } |
286 | 286 | $javascript->addToValidateBinaryDependency($name, 'alpha', |
287 | - $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD') . ': ' . $javascript->buildStringToTranslateInSmarty($vname), |
|
287 | + $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty($vname), |
|
288 | 288 | (!empty($def['required']) ? 'true' : 'false'), '', $def['id_name']); |
289 | 289 | $validatedFields[] = $name; |
290 | 290 | } |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | } |
341 | 341 | $view = $checkFormName ? $formName : $view; |
342 | 342 | |
343 | - return file_exists($this->cacheDir . $this->themeDir . $theme . '/' . $this->templateDir . $module . '/' . $view . '.tpl'); |
|
343 | + return file_exists($this->cacheDir.$this->themeDir.$theme.'/'.$this->templateDir.$module.'/'.$view.'.tpl'); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
@@ -360,14 +360,14 @@ discard block |
||
360 | 360 | if (!$this->checkTemplate($module, $view)) { |
361 | 361 | $this->buildTemplate($module, $view, $tpl, $ajaxSave, $metaDataDefs); |
362 | 362 | } |
363 | - $file = $this->cacheDir . $this->themeDir . $theme . '/' . $this->templateDir . $module . '/' . $view . '.tpl'; |
|
363 | + $file = $this->cacheDir.$this->themeDir.$theme.'/'.$this->templateDir.$module.'/'.$view.'.tpl'; |
|
364 | 364 | if (file_exists($file)) { |
365 | 365 | return $this->ss->fetch($file); |
366 | 366 | } else { |
367 | 367 | global $app_strings; |
368 | - $GLOBALS['log']->fatal($app_strings['ERR_NO_SUCH_FILE'] . ": $file"); |
|
368 | + $GLOBALS['log']->fatal($app_strings['ERR_NO_SUCH_FILE'].": $file"); |
|
369 | 369 | |
370 | - return $app_strings['ERR_NO_SUCH_FILE'] . ": $file"; |
|
370 | + return $app_strings['ERR_NO_SUCH_FILE'].": $file"; |
|
371 | 371 | } |
372 | 372 | } |
373 | 373 | |
@@ -381,15 +381,15 @@ discard block |
||
381 | 381 | public function deleteTemplate($module, $view) |
382 | 382 | { |
383 | 383 | global $theme; |
384 | - if (is_file($this->cacheDir . $this->themeDir . $theme . '/' . $this->templateDir . $module . '/' . $view . '.tpl')) { |
|
384 | + if (is_file($this->cacheDir.$this->themeDir.$theme.'/'.$this->templateDir.$module.'/'.$view.'.tpl')) { |
|
385 | 385 | // Bug #54634 : RTC 18144 : Cannot add more than 1 user to role but popup is multi-selectable |
386 | 386 | if (!isset($this->ss)) { |
387 | 387 | $this->loadSmarty(); |
388 | 388 | } |
389 | - $cache_file_name = $this->ss->_get_compile_path($this->cacheDir . $this->themeDir . $theme . '/' . $this->templateDir . $module . '/' . $view . '.tpl'); |
|
389 | + $cache_file_name = $this->ss->_get_compile_path($this->cacheDir.$this->themeDir.$theme.'/'.$this->templateDir.$module.'/'.$view.'.tpl'); |
|
390 | 390 | SugarCache::cleanFile($cache_file_name); |
391 | 391 | |
392 | - return unlink($this->cacheDir . $this->themeDir . $theme . '/' . $this->templateDir . $module . '/' . $view . '.tpl'); |
|
392 | + return unlink($this->cacheDir.$this->themeDir.$theme.'/'.$this->templateDir.$module.'/'.$view.'.tpl'); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | return false; |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | //Loop through the Meta-Data fields to see which ones need quick search support |
431 | 431 | foreach ($defs as $f) { |
432 | 432 | $field = $f; |
433 | - $name = $qsd->form_name . '_' . $field['name']; |
|
433 | + $name = $qsd->form_name.'_'.$field['name']; |
|
434 | 434 | |
435 | 435 | if (($field['type'] === 'relate' && |
436 | 436 | isset($field['module']) && |
@@ -441,20 +441,20 @@ discard block |
||
441 | 441 | if (preg_match('/^(Campaigns|Teams|Users|Contacts|Accounts)$/si', $field['module'], $matches)) { |
442 | 442 | |
443 | 443 | if ($matches[0] === 'Campaigns') { |
444 | - $sqs_objects[$name . '_' . $parsedView] = $qsd->loadQSObject('Campaigns', 'Campaign', |
|
444 | + $sqs_objects[$name.'_'.$parsedView] = $qsd->loadQSObject('Campaigns', 'Campaign', |
|
445 | 445 | $field['name'], $field['id_name'], $field['id_name']); |
446 | 446 | } else { |
447 | 447 | if ($matches[0] === 'Users') { |
448 | 448 | |
449 | 449 | if (!empty($f['name']) && !empty($f['id_name'])) { |
450 | - $sqs_objects[$name . '_' . $parsedView] = $qsd->getQSUser($f['name'], |
|
450 | + $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser($f['name'], |
|
451 | 451 | $f['id_name']); |
452 | 452 | } else { |
453 | - $sqs_objects[$name . '_' . $parsedView] = $qsd->getQSUser(); |
|
453 | + $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser(); |
|
454 | 454 | } |
455 | 455 | } else { |
456 | 456 | if ($matches[0] === 'Campaigns') { |
457 | - $sqs_objects[$name . '_' . $parsedView] = $qsd->loadQSObject('Campaigns', |
|
457 | + $sqs_objects[$name.'_'.$parsedView] = $qsd->loadQSObject('Campaigns', |
|
458 | 458 | 'Campaign', $field['name'], $field['id_name'], $field['id_name']); |
459 | 459 | } else { |
460 | 460 | if ($matches[0] === 'Accounts') { |
@@ -469,11 +469,11 @@ discard block |
||
469 | 469 | $billingKey = isset($f['displayParams']['billingKey']) ? $f['displayParams']['billingKey'] : null; |
470 | 470 | $shippingKey = isset($f['displayParams']['shippingKey']) ? $f['displayParams']['shippingKey'] : null; |
471 | 471 | $additionalFields = isset($f['displayParams']['additionalFields']) ? $f['displayParams']['additionalFields'] : null; |
472 | - $sqs_objects[$name . '_' . $parsedView] = $qsd->getQSAccount($nameKey, $idKey, |
|
472 | + $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSAccount($nameKey, $idKey, |
|
473 | 473 | $billingKey, $shippingKey, $additionalFields); |
474 | 474 | } else { |
475 | 475 | if ($matches[0] === 'Contacts') { |
476 | - $sqs_objects[$name . '_' . $parsedView] = $qsd->getQSContact($field['name'], |
|
476 | + $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSContact($field['name'], |
|
477 | 477 | $field['id_name']); |
478 | 478 | } |
479 | 479 | } |
@@ -481,28 +481,28 @@ discard block |
||
481 | 481 | } |
482 | 482 | } |
483 | 483 | } else { |
484 | - $sqs_objects[$name . '_' . $parsedView] = $qsd->getQSParent($field['module']); |
|
484 | + $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSParent($field['module']); |
|
485 | 485 | if (!isset($field['field_list']) && !isset($field['populate_list'])) { |
486 | - $sqs_objects[$name . '_' . $parsedView]['populate_list'] = array( |
|
486 | + $sqs_objects[$name.'_'.$parsedView]['populate_list'] = array( |
|
487 | 487 | $field['name'], |
488 | 488 | $field['id_name'] |
489 | 489 | ); |
490 | - $sqs_objects[$name . '_' . $parsedView]['field_list'] = array('name', 'id'); |
|
490 | + $sqs_objects[$name.'_'.$parsedView]['field_list'] = array('name', 'id'); |
|
491 | 491 | } else { |
492 | - $sqs_objects[$name . '_' . $parsedView]['populate_list'] = $field['field_list']; |
|
493 | - $sqs_objects[$name . '_' . $parsedView]['field_list'] = $field['populate_list']; |
|
492 | + $sqs_objects[$name.'_'.$parsedView]['populate_list'] = $field['field_list']; |
|
493 | + $sqs_objects[$name.'_'.$parsedView]['field_list'] = $field['populate_list']; |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | } else { |
497 | 497 | if ($field['type'] == 'parent') { |
498 | - $sqs_objects[$name . '_' . $parsedView] = $qsd->getQSParent(); |
|
498 | + $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSParent(); |
|
499 | 499 | } |
500 | 500 | } //if-else |
501 | 501 | } //foreach |
502 | 502 | |
503 | 503 | foreach ($sqs_objects as $name => $field) { |
504 | 504 | foreach ($field['populate_list'] as $key => $fieldname) { |
505 | - $sqs_objects[$name]['populate_list'][$key] = $sqs_objects[$name]['populate_list'][$key] . '_' . $parsedView; |
|
505 | + $sqs_objects[$name]['populate_list'][$key] = $sqs_objects[$name]['populate_list'][$key].'_'.$parsedView; |
|
506 | 506 | } |
507 | 507 | } |
508 | 508 | } else { |
@@ -514,25 +514,25 @@ discard block |
||
514 | 514 | |
515 | 515 | $field = $defs[$f['name']]; |
516 | 516 | if ($view === 'ConvertLead') { |
517 | - $field['name'] = $module . $field['name']; |
|
517 | + $field['name'] = $module.$field['name']; |
|
518 | 518 | if (isset($field['module']) && |
519 | 519 | isset($field['id_name']) && |
520 | 520 | substr($field['id_name'], -4) === '_ida' |
521 | 521 | ) { |
522 | 522 | $lc_module = strtolower($field['module']); |
523 | - $ida_suffix = '_' . $lc_module . $lc_module . '_ida'; |
|
524 | - if (preg_match('/' . $ida_suffix . '$/', $field['id_name']) > 0) { |
|
525 | - $field['id_name'] = $module . $field['id_name']; |
|
523 | + $ida_suffix = '_'.$lc_module.$lc_module.'_ida'; |
|
524 | + if (preg_match('/'.$ida_suffix.'$/', $field['id_name']) > 0) { |
|
525 | + $field['id_name'] = $module.$field['id_name']; |
|
526 | 526 | } else { |
527 | - $field['id_name'] = $field['name'] . '_' . $field['id_name']; |
|
527 | + $field['id_name'] = $field['name'].'_'.$field['id_name']; |
|
528 | 528 | } |
529 | 529 | } else { |
530 | 530 | if (!empty($field['id_name'])) { |
531 | - $field['id_name'] = $module . $field['id_name']; |
|
531 | + $field['id_name'] = $module.$field['id_name']; |
|
532 | 532 | } |
533 | 533 | } |
534 | 534 | } |
535 | - $name = $qsd->form_name . '_' . $field['name']; |
|
535 | + $name = $qsd->form_name.'_'.$field['name']; |
|
536 | 536 | |
537 | 537 | |
538 | 538 | if ($field['type'] === 'relate' && isset($field['module']) && (preg_match('/_name$|_c$/si', |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | for ($j = 0; $j < $totalFields; $j++) { |
633 | 633 | //search for the same couple (field_list_item,populate_field_item) |
634 | 634 | $field_list_item = $field['field_list'][$j]; |
635 | - $field_list_item_alternate = $qsd->form_name . '_' . $field['field_list'][$j]; |
|
635 | + $field_list_item_alternate = $qsd->form_name.'_'.$field['field_list'][$j]; |
|
636 | 636 | $populate_list_item = $field['populate_list'][$j]; |
637 | 637 | $found = false; |
638 | 638 | $totalSqsObjects = count($sqs_objects[$name]['field_list']); |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | $quicksearch_js .= "sqs_objects['$sqsfield']={$json->encode($sqsfieldArray)};"; |
668 | 668 | } |
669 | 669 | |
670 | - return $quicksearch_js . '</script>'; |
|
670 | + return $quicksearch_js.'</script>'; |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | return ''; |
@@ -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,9 +39,9 @@ discard block |
||
39 | 39 | ********************************************************************************/ |
40 | 40 | |
41 | 41 | |
42 | -require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationship.php' ; |
|
43 | -require_once 'modules/ModuleBuilder/parsers/relationships/OneToManyRelationship.php' ; |
|
44 | -require_once 'modules/ModuleBuilder/parsers/constants.php' ; |
|
42 | +require_once 'modules/ModuleBuilder/parsers/relationships/AbstractRelationship.php'; |
|
43 | +require_once 'modules/ModuleBuilder/parsers/relationships/OneToManyRelationship.php'; |
|
44 | +require_once 'modules/ModuleBuilder/parsers/constants.php'; |
|
45 | 45 | |
46 | 46 | /* |
47 | 47 | * Class to manage the metadata for a many-To-one Relationship |
@@ -57,21 +57,21 @@ discard block |
||
57 | 57 | * @param array $definition Parameters passed in as array defined in parent::$definitionKeys |
58 | 58 | * The lhs_module value is for the One side; the rhs_module value is for the Many |
59 | 59 | */ |
60 | - function __construct ($definition) |
|
60 | + function __construct($definition) |
|
61 | 61 | { |
62 | 62 | |
63 | - parent::__construct ( $definition ) ; |
|
63 | + parent::__construct($definition); |
|
64 | 64 | $onetomanyDef = array_merge($definition, array( |
65 | - 'rhs_label' => isset($definition['lhs_label']) ? $definition['lhs_label'] : null, |
|
66 | - 'lhs_label' => isset($definition['rhs_label']) ? $definition['rhs_label'] : null, |
|
65 | + 'rhs_label' => isset($definition['lhs_label']) ? $definition['lhs_label'] : null, |
|
66 | + 'lhs_label' => isset($definition['rhs_label']) ? $definition['rhs_label'] : null, |
|
67 | 67 | 'lhs_subpanel' => isset($definition['rhs_subpanel']) ? $definition['rhs_subpanel'] : null, |
68 | 68 | 'rhs_subpanel' => isset($definition['lhs_subpanel']) ? $definition['lhs_subpanel'] : null, |
69 | - 'lhs_module' => isset($definition['rhs_module']) ? $definition['rhs_module'] : null, |
|
70 | - 'lhs_table' => isset($definition['rhs_table']) ? $definition['rhs_table'] : null, |
|
71 | - 'lhs_key' => isset($definition['rhs_key']) ? $definition['rhs_key'] : null, |
|
72 | - 'rhs_module' => isset($definition['lhs_module']) ? $definition['lhs_module'] : null, |
|
73 | - 'rhs_table' => isset($definition['lhs_table']) ? $definition['lhs_table'] : null, |
|
74 | - 'rhs_key' => isset($definition['lhs_key']) ? $definition['lhs_key'] : null, |
|
69 | + 'lhs_module' => isset($definition['rhs_module']) ? $definition['rhs_module'] : null, |
|
70 | + 'lhs_table' => isset($definition['rhs_table']) ? $definition['rhs_table'] : null, |
|
71 | + 'lhs_key' => isset($definition['rhs_key']) ? $definition['rhs_key'] : null, |
|
72 | + 'rhs_module' => isset($definition['lhs_module']) ? $definition['lhs_module'] : null, |
|
73 | + 'rhs_table' => isset($definition['lhs_table']) ? $definition['lhs_table'] : null, |
|
74 | + 'rhs_key' => isset($definition['lhs_key']) ? $definition['lhs_key'] : null, |
|
75 | 75 | 'join_key_lhs' => isset($definition['join_key_rhs']) ? $definition['join_key_rhs'] : null, |
76 | 76 | 'join_key_rhs' => isset($definition['join_key_lhs']) ? $definition['join_key_lhs'] : null, |
77 | 77 | 'relationship_type' => MB_ONETOMANY, |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * The format is that of TO_MODULE => relationship, FROM_MODULE, FROM_MODULES_SUBPANEL, mimicking the format in the layoutdefs.php |
94 | 94 | * @return array An array of subpanel definitions, keyed by the module |
95 | 95 | */ |
96 | - function buildSubpanelDefinitions () |
|
96 | + function buildSubpanelDefinitions() |
|
97 | 97 | { |
98 | 98 | return $this->one_to_many->buildSubpanelDefinitions(); |
99 | 99 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | /* |
103 | 103 | * @return array An array of field definitions, ready for the vardefs, keyed by module |
104 | 104 | */ |
105 | - function buildVardefs ( ) |
|
105 | + function buildVardefs( ) |
|
106 | 106 | { |
107 | 107 | return $this->one_to_many->buildVardefs(); |
108 | 108 | } |
@@ -111,41 +111,41 @@ discard block |
||
111 | 111 | * Define what fields to add to which modules layouts |
112 | 112 | * @return array An array of module => fieldname |
113 | 113 | */ |
114 | - function buildFieldsToLayouts () |
|
114 | + function buildFieldsToLayouts() |
|
115 | 115 | { |
116 | 116 | if ($this->relationship_only) |
117 | - return array () ; |
|
117 | + return array(); |
|
118 | 118 | |
119 | - return array( $this->lhs_module => $this->getValidDBName($this->relationship_name . "_name") ) ; // this must match the name of the relate field from buildVardefs |
|
119 | + return array($this->lhs_module => $this->getValidDBName($this->relationship_name."_name")); // this must match the name of the relate field from buildVardefs |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /* |
123 | 123 | * @return array An array of relationship metadata definitions |
124 | 124 | */ |
125 | - function buildRelationshipMetaData () |
|
125 | + function buildRelationshipMetaData() |
|
126 | 126 | { |
127 | 127 | return $this->one_to_many->buildRelationshipMetaData(); |
128 | 128 | } |
129 | 129 | |
130 | - public function setName ($relationshipName) |
|
130 | + public function setName($relationshipName) |
|
131 | 131 | { |
132 | 132 | parent::setName($relationshipName); |
133 | 133 | $this->one_to_many->setname($relationshipName); |
134 | 134 | } |
135 | 135 | |
136 | - public function setReadonly ($set = true) |
|
136 | + public function setReadonly($set = true) |
|
137 | 137 | { |
138 | 138 | parent::setReadonly($set); |
139 | 139 | $this->one_to_many->setReadonly(); |
140 | 140 | } |
141 | 141 | |
142 | - public function delete () |
|
142 | + public function delete() |
|
143 | 143 | { |
144 | 144 | parent::delete(); |
145 | 145 | $this->one_to_many->delete(); |
146 | 146 | } |
147 | 147 | |
148 | - public function setRelationship_only () |
|
148 | + public function setRelationship_only() |
|
149 | 149 | { |
150 | 150 | parent::setRelationship_only(); |
151 | 151 | $this->one_to_many->setRelationship_only(); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | die('Not A Valid Entry Point'); |
43 | 43 | } |
44 | 44 | |
45 | -function getModuleFields($module, $view='EditView', $value = '', $valid = array()) |
|
45 | +function getModuleFields($module, $view = 'EditView', $value = '', $valid = array()) |
|
46 | 46 | { |
47 | 47 | global $app_strings, $beanList, $current_user; |
48 | 48 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $blockedModuleFields[$mod->module_dir] |
80 | 80 | ) && !$current_user->isAdmin() |
81 | 81 | ) { |
82 | - $GLOBALS['log']->debug('hiding ' . $arr['name'] . ' field from ' . $current_user->name); |
|
82 | + $GLOBALS['log']->debug('hiding '.$arr['name'].' field from '.$current_user->name); |
|
83 | 83 | continue; |
84 | 84 | } |
85 | 85 | } |
@@ -107,44 +107,44 @@ discard block |
||
107 | 107 | } |
108 | 108 | } |
109 | 109 | asort($fields); |
110 | - if($view == 'JSON'){ |
|
110 | + if ($view == 'JSON') { |
|
111 | 111 | return json_encode($fields); |
112 | 112 | } |
113 | - if($view == 'EditView'){ |
|
113 | + if ($view == 'EditView') { |
|
114 | 114 | return get_select_options_with_id($fields, $value); |
115 | 115 | } else { |
116 | 116 | return $fields[$value]; |
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | -function getRelModuleFields($module, $rel_field, $view='EditView',$value = ''){ |
|
120 | +function getRelModuleFields($module, $rel_field, $view = 'EditView', $value = '') { |
|
121 | 121 | global $beanList; |
122 | 122 | |
123 | - if($module == $rel_field){ |
|
123 | + if ($module == $rel_field) { |
|
124 | 124 | return getModuleFields($module, $view, $value); |
125 | 125 | } |
126 | 126 | |
127 | 127 | $mod = new $beanList[$module](); |
128 | 128 | $data = $mod->field_defs[$rel_field]; |
129 | 129 | |
130 | - if(isset($data['module']) && $data['module'] != ''){ |
|
130 | + if (isset($data['module']) && $data['module'] != '') { |
|
131 | 131 | return getModuleFields($data['module'], $view, $value); |
132 | 132 | } |
133 | 133 | |
134 | 134 | } |
135 | 135 | |
136 | -function getRelatedModule($module, $rel_field){ |
|
136 | +function getRelatedModule($module, $rel_field) { |
|
137 | 137 | global $beanList; |
138 | 138 | |
139 | - if($module == $rel_field){ |
|
139 | + if ($module == $rel_field) { |
|
140 | 140 | return $module; |
141 | 141 | } |
142 | 142 | |
143 | 143 | $mod = new $beanList[$module](); |
144 | 144 | |
145 | - if(isset($arr['module']) && $arr['module'] != '') { |
|
145 | + if (isset($arr['module']) && $arr['module'] != '') { |
|
146 | 146 | return $arr['module']; |
147 | - } else if($mod->load_relationship($rel_field)){ |
|
147 | + } else if ($mod->load_relationship($rel_field)) { |
|
148 | 148 | return $mod->$rel_field->getRelatedModuleName(); |
149 | 149 | } |
150 | 150 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | |
153 | 153 | } |
154 | 154 | |
155 | -function getModuleTreeData($module){ |
|
155 | +function getModuleTreeData($module) { |
|
156 | 156 | global $beanList, $app_list_strings; |
157 | 157 | |
158 | 158 | $sort_fields = array(); |
@@ -165,33 +165,33 @@ discard block |
||
165 | 165 | ); |
166 | 166 | |
167 | 167 | if ($module != '') { |
168 | - if(isset($beanList[$module]) && $beanList[$module]){ |
|
168 | + if (isset($beanList[$module]) && $beanList[$module]) { |
|
169 | 169 | $mod = new $beanList[$module](); |
170 | 170 | |
171 | - foreach($mod->get_linked_fields() as $name => $arr){ |
|
172 | - if(isset($arr['module']) && $arr['module'] != '') { |
|
171 | + foreach ($mod->get_linked_fields() as $name => $arr) { |
|
172 | + if (isset($arr['module']) && $arr['module'] != '') { |
|
173 | 173 | $rel_module = $arr['module']; |
174 | - } else if($mod->load_relationship($name)){ |
|
174 | + } else if ($mod->load_relationship($name)) { |
|
175 | 175 | $rel_module = $mod->$name->getRelatedModuleName(); |
176 | 176 | } |
177 | 177 | |
178 | 178 | $rel_module_label = isset($app_list_strings['moduleList'][$rel_module]) ? $app_list_strings['moduleList'][$rel_module] : $rel_module; |
179 | - if(isset($arr['vname']) && $arr['vname'] != '') { |
|
180 | - $label = $rel_module_label . ' : ' . translate($arr['vname'], $mod->module_dir); |
|
181 | - $module_label = trim(translate($arr['vname'],$mod->module_dir),':'); |
|
182 | - }else { |
|
183 | - $label = $rel_module_label . ' : '. $name; |
|
179 | + if (isset($arr['vname']) && $arr['vname'] != '') { |
|
180 | + $label = $rel_module_label.' : '.translate($arr['vname'], $mod->module_dir); |
|
181 | + $module_label = trim(translate($arr['vname'], $mod->module_dir), ':'); |
|
182 | + } else { |
|
183 | + $label = $rel_module_label.' : '.$name; |
|
184 | 184 | $module_label = $name; |
185 | 185 | } |
186 | - $sort_fields[$name] = array('label'=>$label,'type'=>'relationship','module' => $rel_module,'module_label'=>$module_label); |
|
187 | - if($arr['type'] == 'relate' && isset($arr['id_name']) && $arr['id_name'] != ''){ |
|
188 | - if(isset($fields[$arr['id_name']])){ |
|
189 | - unset( $fields[$arr['id_name']]); |
|
186 | + $sort_fields[$name] = array('label'=>$label, 'type'=>'relationship', 'module' => $rel_module, 'module_label'=>$module_label); |
|
187 | + if ($arr['type'] == 'relate' && isset($arr['id_name']) && $arr['id_name'] != '') { |
|
188 | + if (isset($fields[$arr['id_name']])) { |
|
189 | + unset($fields[$arr['id_name']]); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | } //End loop. |
193 | - uasort($sort_fields,function($a,$b){ |
|
194 | - return strcmp($a['label'],$b['label']); |
|
193 | + uasort($sort_fields, function($a, $b) { |
|
194 | + return strcmp($a['label'], $b['label']); |
|
195 | 195 | }); |
196 | 196 | |
197 | 197 | $fields = array_merge((array)$fields, (array)$sort_fields); |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | return json_encode($fields); |
202 | 202 | } |
203 | 203 | |
204 | -function getModuleRelationships($module, $view='EditView',$value = '') |
|
204 | +function getModuleRelationships($module, $view = 'EditView', $value = '') |
|
205 | 205 | { |
206 | 206 | global $beanList, $app_list_strings; |
207 | 207 | |
@@ -210,27 +210,27 @@ discard block |
||
210 | 210 | $invalid_modules = array(); |
211 | 211 | |
212 | 212 | if ($module != '') { |
213 | - if(isset($beanList[$module]) && $beanList[$module]){ |
|
213 | + if (isset($beanList[$module]) && $beanList[$module]) { |
|
214 | 214 | $mod = new $beanList[$module](); |
215 | 215 | |
216 | 216 | /*if($mod->is_AuditEnabled()){ |
217 | 217 | $fields['Audit'] = translate('LBL_AUDIT_TABLE','AOR_Fields'); |
218 | 218 | }*/ |
219 | - foreach($mod->get_linked_fields() as $name => $arr){ |
|
220 | - if(isset($arr['module']) && $arr['module'] != '') { |
|
219 | + foreach ($mod->get_linked_fields() as $name => $arr) { |
|
220 | + if (isset($arr['module']) && $arr['module'] != '') { |
|
221 | 221 | $rel_module = $arr['module']; |
222 | - } else if($mod->load_relationship($name)){ |
|
222 | + } else if ($mod->load_relationship($name)) { |
|
223 | 223 | $rel_module = $mod->$name->getRelatedModuleName(); |
224 | 224 | } |
225 | - if(!in_array($rel_module,$invalid_modules)){ |
|
225 | + if (!in_array($rel_module, $invalid_modules)) { |
|
226 | 226 | $relModuleName = isset($app_list_strings['moduleList'][$rel_module]) ? $app_list_strings['moduleList'][$rel_module] : $rel_module; |
227 | - if(isset($arr['vname']) && $arr['vname'] != ''){ |
|
228 | - $sort_fields[$name] = $relModuleName.' : '.translate($arr['vname'],$mod->module_dir); |
|
227 | + if (isset($arr['vname']) && $arr['vname'] != '') { |
|
228 | + $sort_fields[$name] = $relModuleName.' : '.translate($arr['vname'], $mod->module_dir); |
|
229 | 229 | } else { |
230 | - $sort_fields[$name] = $relModuleName.' : '. $name; |
|
230 | + $sort_fields[$name] = $relModuleName.' : '.$name; |
|
231 | 231 | } |
232 | - if($arr['type'] == 'relate' && isset($arr['id_name']) && $arr['id_name'] != ''){ |
|
233 | - if(isset($fields[$arr['id_name']])) unset( $fields[$arr['id_name']]); |
|
232 | + if ($arr['type'] == 'relate' && isset($arr['id_name']) && $arr['id_name'] != '') { |
|
233 | + if (isset($fields[$arr['id_name']])) unset($fields[$arr['id_name']]); |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | } //End loop. |
@@ -238,26 +238,26 @@ discard block |
||
238 | 238 | $fields = array_merge((array)$fields, (array)$sort_fields); |
239 | 239 | } |
240 | 240 | } |
241 | - if($view == 'EditView'){ |
|
241 | + if ($view == 'EditView') { |
|
242 | 242 | return get_select_options_with_id($fields, $value); |
243 | 243 | } else { |
244 | 244 | return $fields[$value]; |
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
248 | -function getValidFieldsTypes($module, $field){ |
|
248 | +function getValidFieldsTypes($module, $field) { |
|
249 | 249 | global $beanFiles, $beanList; |
250 | 250 | |
251 | 251 | require_once($beanFiles[$beanList[$module]]); |
252 | 252 | $focus = new $beanList[$module]; |
253 | 253 | $vardef = $focus->getFieldDefinition($field); |
254 | 254 | |
255 | - switch($vardef['type']) { |
|
255 | + switch ($vardef['type']) { |
|
256 | 256 | case 'double': |
257 | 257 | case 'decimal': |
258 | 258 | case 'float': |
259 | 259 | case 'currency': |
260 | - $valid_type = array('double','decimal','float','currency'); |
|
260 | + $valid_type = array('double', 'decimal', 'float', 'currency'); |
|
261 | 261 | break; |
262 | 262 | case 'uint': |
263 | 263 | case 'ulong': |
@@ -265,12 +265,12 @@ discard block |
||
265 | 265 | case 'short': |
266 | 266 | case 'tinyint': |
267 | 267 | case 'int': |
268 | - $valid_type = array('uint','ulong','long','short','tinyint','int'); |
|
268 | + $valid_type = array('uint', 'ulong', 'long', 'short', 'tinyint', 'int'); |
|
269 | 269 | break; |
270 | 270 | case 'date': |
271 | 271 | case 'datetime': |
272 | 272 | case 'datetimecombo': |
273 | - $valid_type = array('date','datetime', 'datetimecombo'); |
|
273 | + $valid_type = array('date', 'datetime', 'datetimecombo'); |
|
274 | 274 | break; |
275 | 275 | case 'id': |
276 | 276 | case 'relate': |
@@ -287,29 +287,29 @@ discard block |
||
287 | 287 | } |
288 | 288 | |
289 | 289 | |
290 | -function getModuleField($module, $fieldname, $aow_field, $view='EditView',$value = '', $alt_type = '', $currency_id = '', $params= array()){ |
|
290 | +function getModuleField($module, $fieldname, $aow_field, $view = 'EditView', $value = '', $alt_type = '', $currency_id = '', $params = array()) { |
|
291 | 291 | global $current_language, $app_strings, $app_list_strings, $current_user, $beanFiles, $beanList; |
292 | 292 | |
293 | 293 | // use the mod_strings for this module |
294 | - $mod_strings = return_module_language($current_language,$module); |
|
294 | + $mod_strings = return_module_language($current_language, $module); |
|
295 | 295 | |
296 | 296 | // set the filename for this control |
297 | - $file = create_cache_directory('modules/AOW_WorkFlow/') . $module . $view . $alt_type . $fieldname . '.tpl'; |
|
297 | + $file = create_cache_directory('modules/AOW_WorkFlow/').$module.$view.$alt_type.$fieldname.'.tpl'; |
|
298 | 298 | |
299 | 299 | $displayParams = array(); |
300 | 300 | |
301 | - if ( !is_file($file) |
|
301 | + if (!is_file($file) |
|
302 | 302 | || inDeveloperMode() |
303 | - || !empty($_SESSION['developerMode']) ) { |
|
303 | + || !empty($_SESSION['developerMode'])) { |
|
304 | 304 | |
305 | - if ( !isset($vardef) ) { |
|
305 | + if (!isset($vardef)) { |
|
306 | 306 | require_once($beanFiles[$beanList[$module]]); |
307 | 307 | $focus = new $beanList[$module]; |
308 | 308 | $vardef = $focus->getFieldDefinition($fieldname); |
309 | 309 | } |
310 | 310 | |
311 | 311 | // Bug: check for AOR value SecurityGroups value missing |
312 | - if(stristr($fieldname, 'securitygroups') != false && empty($vardef)) { |
|
312 | + if (stristr($fieldname, 'securitygroups') != false && empty($vardef)) { |
|
313 | 313 | require_once($beanFiles[$beanList['SecurityGroups']]); |
314 | 314 | $module = 'SecurityGroups'; |
315 | 315 | $focus = new $beanList[$module]; |
@@ -320,36 +320,36 @@ discard block |
||
320 | 320 | //$displayParams['formName'] = 'EditView'; |
321 | 321 | |
322 | 322 | // if this is the id relation field, then don't have a pop-up selector. |
323 | - if( $vardef['type'] == 'relate' && $vardef['id_name'] == $vardef['name']) { |
|
323 | + if ($vardef['type'] == 'relate' && $vardef['id_name'] == $vardef['name']) { |
|
324 | 324 | $vardef['type'] = 'varchar'; |
325 | 325 | } |
326 | 326 | |
327 | - if(isset($vardef['precision'])) unset($vardef['precision']); |
|
327 | + if (isset($vardef['precision'])) unset($vardef['precision']); |
|
328 | 328 | |
329 | 329 | //$vardef['precision'] = $locale->getPrecedentPreference('default_currency_significant_digits', $current_user); |
330 | 330 | |
331 | 331 | //TODO Fix datetimecomebo |
332 | 332 | //temp work around |
333 | - if( $vardef['type'] == 'datetimecombo') { |
|
333 | + if ($vardef['type'] == 'datetimecombo') { |
|
334 | 334 | $vardef['type'] = 'datetime'; |
335 | 335 | } |
336 | 336 | |
337 | 337 | // trim down textbox display |
338 | - if( $vardef['type'] == 'text' ) { |
|
338 | + if ($vardef['type'] == 'text') { |
|
339 | 339 | $vardef['rows'] = 2; |
340 | 340 | $vardef['cols'] = 32; |
341 | 341 | } |
342 | 342 | |
343 | 343 | // create the dropdowns for the parent type fields |
344 | - if ( $vardef['type'] == 'parent_type' ) { |
|
344 | + if ($vardef['type'] == 'parent_type') { |
|
345 | 345 | $vardef['type'] = 'enum'; |
346 | 346 | } |
347 | 347 | |
348 | - if($vardef['type'] == 'link'){ |
|
348 | + if ($vardef['type'] == 'link') { |
|
349 | 349 | $vardef['type'] = 'relate'; |
350 | 350 | $vardef['rname'] = 'name'; |
351 | 351 | $vardef['id_name'] = $vardef['name'].'_id'; |
352 | - if((!isset($vardef['module']) || $vardef['module'] == '') && $focus->load_relationship($vardef['name'])) { |
|
352 | + if ((!isset($vardef['module']) || $vardef['module'] == '') && $focus->load_relationship($vardef['name'])) { |
|
353 | 353 | $relName = $vardef['name']; |
354 | 354 | $vardef['module'] = $focus->$relName->getRelatedModuleName(); |
355 | 355 | } |
@@ -357,24 +357,24 @@ discard block |
||
357 | 357 | } |
358 | 358 | |
359 | 359 | //check for $alt_type |
360 | - if ( $alt_type != '' ) { |
|
360 | + if ($alt_type != '') { |
|
361 | 361 | $vardef['type'] = $alt_type; |
362 | 362 | } |
363 | 363 | |
364 | 364 | // remove the special text entry field function 'getEmailAddressWidget' |
365 | - if ( isset($vardef['function']) |
|
366 | - && ( $vardef['function'] == 'getEmailAddressWidget' |
|
367 | - || $vardef['function']['name'] == 'getEmailAddressWidget' ) ) |
|
365 | + if (isset($vardef['function']) |
|
366 | + && ($vardef['function'] == 'getEmailAddressWidget' |
|
367 | + || $vardef['function']['name'] == 'getEmailAddressWidget')) |
|
368 | 368 | unset($vardef['function']); |
369 | 369 | |
370 | - if(isset($vardef['name']) && ($vardef['name'] == 'date_entered' || $vardef['name'] == 'date_modified')){ |
|
370 | + if (isset($vardef['name']) && ($vardef['name'] == 'date_entered' || $vardef['name'] == 'date_modified')) { |
|
371 | 371 | $vardef['name'] = 'aow_temp_date'; |
372 | 372 | } |
373 | 373 | |
374 | 374 | // load SugarFieldHandler to render the field tpl file |
375 | 375 | static $sfh; |
376 | 376 | |
377 | - if(!isset($sfh)) { |
|
377 | + if (!isset($sfh)) { |
|
378 | 378 | require_once('include/SugarFields/SugarFieldHandler.php'); |
379 | 379 | $sfh = new SugarFieldHandler(); |
380 | 380 | } |
@@ -384,17 +384,17 @@ discard block |
||
384 | 384 | // Remove all the copyright comments |
385 | 385 | $contents = preg_replace('/\{\*[^\}]*?\*\}/', '', $contents); |
386 | 386 | |
387 | - if( $view == 'EditView' && ($vardef['type'] == 'relate' || $vardef['type'] == 'parent')){ |
|
388 | - $contents = str_replace('"'.$vardef['id_name'].'"','{/literal}"{$fields.'.$vardef['name'].'.id_name}"{literal}', $contents); |
|
389 | - $contents = str_replace('"'.$vardef['name'].'"','{/literal}"{$fields.'.$vardef['name'].'.name}"{literal}', $contents); |
|
387 | + if ($view == 'EditView' && ($vardef['type'] == 'relate' || $vardef['type'] == 'parent')) { |
|
388 | + $contents = str_replace('"'.$vardef['id_name'].'"', '{/literal}"{$fields.'.$vardef['name'].'.id_name}"{literal}', $contents); |
|
389 | + $contents = str_replace('"'.$vardef['name'].'"', '{/literal}"{$fields.'.$vardef['name'].'.name}"{literal}', $contents); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | // hack to disable one of the js calls in this control |
393 | - if ( isset($vardef['function']) && ( $vardef['function'] == 'getCurrencyDropDown' || $vardef['function']['name'] == 'getCurrencyDropDown' ) ) |
|
393 | + if (isset($vardef['function']) && ($vardef['function'] == 'getCurrencyDropDown' || $vardef['function']['name'] == 'getCurrencyDropDown')) |
|
394 | 394 | $contents .= "{literal}<script>function CurrencyConvertAll() { return; }</script>{/literal}"; |
395 | 395 | |
396 | 396 | // Save it to the cache file |
397 | - if($fh = @sugar_fopen($file, 'w')) { |
|
397 | + if ($fh = @sugar_fopen($file, 'w')) { |
|
398 | 398 | fputs($fh, $contents); |
399 | 399 | fclose($fh); |
400 | 400 | } |
@@ -411,51 +411,51 @@ discard block |
||
411 | 411 | $ss->assign('TIME_FORMAT', $time_format); |
412 | 412 | $time_separator = ":"; |
413 | 413 | $match = array(); |
414 | - if(preg_match('/\d+([^\d])\d+([^\d]*)/s', $time_format, $match)) { |
|
414 | + if (preg_match('/\d+([^\d])\d+([^\d]*)/s', $time_format, $match)) { |
|
415 | 415 | $time_separator = $match[1]; |
416 | 416 | } |
417 | 417 | $t23 = strpos($time_format, '23') !== false ? '%H' : '%I'; |
418 | - if(!isset($match[2]) || $match[2] == '') { |
|
419 | - $ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . "%M"); |
|
418 | + if (!isset($match[2]) || $match[2] == '') { |
|
419 | + $ss->assign('CALENDAR_FORMAT', $date_format.' '.$t23.$time_separator."%M"); |
|
420 | 420 | } |
421 | 421 | else { |
422 | 422 | $pm = $match[2] == "pm" ? "%P" : "%p"; |
423 | - $ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . "%M" . $pm); |
|
423 | + $ss->assign('CALENDAR_FORMAT', $date_format.' '.$t23.$time_separator."%M".$pm); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | $ss->assign('CALENDAR_FDOW', $current_user->get_first_day_of_week()); |
427 | 427 | |
428 | 428 | // populate the fieldlist from the vardefs |
429 | 429 | $fieldlist = array(); |
430 | - if ( !isset($focus) || !($focus instanceof SugarBean) ) |
|
430 | + if (!isset($focus) || !($focus instanceof SugarBean)) |
|
431 | 431 | require_once($beanFiles[$beanList[$module]]); |
432 | 432 | $focus = new $beanList[$module]; |
433 | 433 | // create the dropdowns for the parent type fields |
434 | 434 | $vardefFields = $focus->getFieldDefinitions(); |
435 | - if (isset($vardefFields[$fieldname]['type']) && $vardefFields[$fieldname]['type'] == 'parent_type' ) { |
|
435 | + if (isset($vardefFields[$fieldname]['type']) && $vardefFields[$fieldname]['type'] == 'parent_type') { |
|
436 | 436 | $focus->field_defs[$fieldname]['options'] = $focus->field_defs[$vardefFields[$fieldname]['group']]['options']; |
437 | 437 | } |
438 | - foreach ( $vardefFields as $name => $properties ) { |
|
438 | + foreach ($vardefFields as $name => $properties) { |
|
439 | 439 | $fieldlist[$name] = $properties; |
440 | 440 | // fill in enums |
441 | - if(isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($app_list_strings[$fieldlist[$name]['options']])) |
|
441 | + if (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($app_list_strings[$fieldlist[$name]['options']])) |
|
442 | 442 | $fieldlist[$name]['options'] = $app_list_strings[$fieldlist[$name]['options']]; |
443 | 443 | // Bug 32626: fall back on checking the mod_strings if not in the app_list_strings |
444 | - elseif(isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($mod_strings[$fieldlist[$name]['options']])) |
|
444 | + elseif (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($mod_strings[$fieldlist[$name]['options']])) |
|
445 | 445 | $fieldlist[$name]['options'] = $mod_strings[$fieldlist[$name]['options']]; |
446 | 446 | // Bug 22730: make sure all enums have the ability to select blank as the default value. |
447 | - if(!isset($fieldlist[$name]['options'][''])) |
|
447 | + if (!isset($fieldlist[$name]['options'][''])) |
|
448 | 448 | $fieldlist[$name]['options'][''] = ''; |
449 | 449 | } |
450 | 450 | |
451 | 451 | // fill in function return values |
452 | - if ( !in_array($fieldname,array('email1','email2')) ) |
|
452 | + if (!in_array($fieldname, array('email1', 'email2'))) |
|
453 | 453 | { |
454 | 454 | if (!empty($fieldlist[$fieldname]['function']['returns']) && $fieldlist[$fieldname]['function']['returns'] == 'html') |
455 | 455 | { |
456 | 456 | $function = $fieldlist[$fieldname]['function']['name']; |
457 | 457 | // include various functions required in the various vardefs |
458 | - if ( isset($fieldlist[$fieldname]['function']['include']) && is_file($fieldlist[$fieldname]['function']['include'])) |
|
458 | + if (isset($fieldlist[$fieldname]['function']['include']) && is_file($fieldlist[$fieldname]['function']['include'])) |
|
459 | 459 | require_once($fieldlist[$fieldname]['function']['include']); |
460 | 460 | $_REQUEST[$fieldname] = $value; |
461 | 461 | $value = $function($focus, $fieldname, $value, $view); |
@@ -464,40 +464,40 @@ discard block |
||
464 | 464 | } |
465 | 465 | } |
466 | 466 | |
467 | - if(isset($fieldlist[$fieldname]['type']) && $fieldlist[$fieldname]['type'] == 'link'){ |
|
467 | + if (isset($fieldlist[$fieldname]['type']) && $fieldlist[$fieldname]['type'] == 'link') { |
|
468 | 468 | $fieldlist[$fieldname]['id_name'] = $fieldlist[$fieldname]['name'].'_id'; |
469 | 469 | |
470 | - if((!isset($fieldlist[$fieldname]['module']) || $fieldlist[$fieldname]['module'] == '') && $focus->load_relationship($fieldlist[$fieldname]['name'])) { |
|
470 | + if ((!isset($fieldlist[$fieldname]['module']) || $fieldlist[$fieldname]['module'] == '') && $focus->load_relationship($fieldlist[$fieldname]['name'])) { |
|
471 | 471 | $relName = $fieldlist[$fieldname]['name']; |
472 | 472 | $fieldlist[$fieldname]['module'] = $focus->$relName->getRelatedModuleName(); |
473 | 473 | } |
474 | 474 | } |
475 | 475 | |
476 | - if(isset($fieldlist[$fieldname]['name']) && ($fieldlist[$fieldname]['name'] == 'date_entered' || $fieldlist[$fieldname]['name'] == 'date_modified')){ |
|
476 | + if (isset($fieldlist[$fieldname]['name']) && ($fieldlist[$fieldname]['name'] == 'date_entered' || $fieldlist[$fieldname]['name'] == 'date_modified')) { |
|
477 | 477 | $fieldlist[$fieldname]['name'] = 'aow_temp_date'; |
478 | 478 | $fieldlist['aow_temp_date'] = $fieldlist[$fieldname]; |
479 | 479 | $fieldname = 'aow_temp_date'; |
480 | 480 | } |
481 | 481 | |
482 | 482 | $quicksearch_js = ''; |
483 | - if(isset( $fieldlist[$fieldname]['id_name'] ) && $fieldlist[$fieldname]['id_name'] != '' && $fieldlist[$fieldname]['id_name'] != $fieldlist[$fieldname]['name']){ |
|
483 | + if (isset($fieldlist[$fieldname]['id_name']) && $fieldlist[$fieldname]['id_name'] != '' && $fieldlist[$fieldname]['id_name'] != $fieldlist[$fieldname]['name']) { |
|
484 | 484 | $rel_value = $value; |
485 | 485 | |
486 | 486 | require_once("include/TemplateHandler/TemplateHandler.php"); |
487 | 487 | $template_handler = new TemplateHandler(); |
488 | - $quicksearch_js = $template_handler->createQuickSearchCode($fieldlist,$fieldlist,$view); |
|
488 | + $quicksearch_js = $template_handler->createQuickSearchCode($fieldlist, $fieldlist, $view); |
|
489 | 489 | $quicksearch_js = str_replace($fieldname, $aow_field.'_display', $quicksearch_js); |
490 | 490 | $quicksearch_js = str_replace($fieldlist[$fieldname]['id_name'], $aow_field, $quicksearch_js); |
491 | 491 | |
492 | 492 | echo $quicksearch_js; |
493 | 493 | |
494 | - if(isset($fieldlist[$fieldname]['module']) && $fieldlist[$fieldname]['module'] == 'Users'){ |
|
494 | + if (isset($fieldlist[$fieldname]['module']) && $fieldlist[$fieldname]['module'] == 'Users') { |
|
495 | 495 | $rel_value = get_assigned_user_name($value); |
496 | - } else if(isset($fieldlist[$fieldname]['module'])){ |
|
496 | + } else if (isset($fieldlist[$fieldname]['module'])) { |
|
497 | 497 | require_once($beanFiles[$beanList[$fieldlist[$fieldname]['module']]]); |
498 | 498 | $rel_focus = new $beanList[$fieldlist[$fieldname]['module']]; |
499 | 499 | $rel_focus->retrieve($value); |
500 | - if(isset($fieldlist[$fieldname]['rname']) && $fieldlist[$fieldname]['rname'] != ''){ |
|
500 | + if (isset($fieldlist[$fieldname]['rname']) && $fieldlist[$fieldname]['rname'] != '') { |
|
501 | 501 | $relDisplayField = $fieldlist[$fieldname]['rname']; |
502 | 502 | } else { |
503 | 503 | $relDisplayField = 'name'; |
@@ -510,17 +510,17 @@ discard block |
||
510 | 510 | $fieldlist[$fieldname]['id_name'] = $aow_field; |
511 | 511 | $fieldlist[$fieldlist[$fieldname]['id_name']]['name'] = $aow_field; |
512 | 512 | $fieldlist[$fieldname]['name'] = $aow_field.'_display'; |
513 | - } else if(isset( $fieldlist[$fieldname]['type'] ) && $view == 'DetailView' && ($fieldlist[$fieldname]['type'] == 'datetimecombo' || $fieldlist[$fieldname]['type'] == 'datetime' || $fieldlist[$fieldname]['type'] == 'date')){ |
|
513 | + } else if (isset($fieldlist[$fieldname]['type']) && $view == 'DetailView' && ($fieldlist[$fieldname]['type'] == 'datetimecombo' || $fieldlist[$fieldname]['type'] == 'datetime' || $fieldlist[$fieldname]['type'] == 'date')) { |
|
514 | 514 | $value = $focus->convertField($value, $fieldlist[$fieldname]); |
515 | - if(!empty($params['date_format']) && isset($params['date_format'])){ |
|
515 | + if (!empty($params['date_format']) && isset($params['date_format'])) { |
|
516 | 516 | $convert_format = "Y-m-d H:i:s"; |
517 | - if($fieldlist[$fieldname]['type'] == 'date') $convert_format = "Y-m-d"; |
|
517 | + if ($fieldlist[$fieldname]['type'] == 'date') $convert_format = "Y-m-d"; |
|
518 | 518 | $fieldlist[$fieldname]['value'] = $timedate->to_display($value, $convert_format, $params['date_format']); |
519 | - }else{ |
|
519 | + } else { |
|
520 | 520 | $fieldlist[$fieldname]['value'] = $timedate->to_display_date_time($value, true, true); |
521 | 521 | } |
522 | 522 | $fieldlist[$fieldname]['name'] = $aow_field; |
523 | - } else if(isset( $fieldlist[$fieldname]['type'] ) && ($fieldlist[$fieldname]['type'] == 'datetimecombo' || $fieldlist[$fieldname]['type'] == 'datetime' || $fieldlist[$fieldname]['type'] == 'date')){ |
|
523 | + } else if (isset($fieldlist[$fieldname]['type']) && ($fieldlist[$fieldname]['type'] == 'datetimecombo' || $fieldlist[$fieldname]['type'] == 'datetime' || $fieldlist[$fieldname]['type'] == 'date')) { |
|
524 | 524 | $value = $focus->convertField($value, $fieldlist[$fieldname]); |
525 | 525 | $fieldlist[$fieldname]['value'] = $timedate->to_display_date($value); |
526 | 526 | //$fieldlist[$fieldname]['value'] = $timedate->to_display_date_time($value, true, true); |
@@ -532,17 +532,17 @@ discard block |
||
532 | 532 | |
533 | 533 | } |
534 | 534 | |
535 | - if(isset($fieldlist[$fieldname]['type']) && $fieldlist[$fieldname]['type'] == 'currency' && $view != 'EditView'){ |
|
535 | + if (isset($fieldlist[$fieldname]['type']) && $fieldlist[$fieldname]['type'] == 'currency' && $view != 'EditView') { |
|
536 | 536 | static $sfh; |
537 | 537 | |
538 | - if(!isset($sfh)) { |
|
538 | + if (!isset($sfh)) { |
|
539 | 539 | require_once('include/SugarFields/SugarFieldHandler.php'); |
540 | 540 | $sfh = new SugarFieldHandler(); |
541 | 541 | } |
542 | 542 | |
543 | - if($currency_id != '' && !stripos($fieldname, '_USD')){ |
|
543 | + if ($currency_id != '' && !stripos($fieldname, '_USD')) { |
|
544 | 544 | $userCurrencyId = $current_user->getPreference('currency'); |
545 | - if($currency_id != $userCurrencyId){ |
|
545 | + if ($currency_id != $userCurrencyId) { |
|
546 | 546 | $currency = new Currency(); |
547 | 547 | $currency->retrieve($currency_id); |
548 | 548 | $value = $currency->convertToDollar($value); |
@@ -557,9 +557,9 @@ discard block |
||
557 | 557 | } |
558 | 558 | |
559 | 559 | $ss->assign("QS_JS", $quicksearch_js); |
560 | - $ss->assign("fields",$fieldlist); |
|
561 | - $ss->assign("form_name",$view); |
|
562 | - $ss->assign("bean",$focus); |
|
560 | + $ss->assign("fields", $fieldlist); |
|
561 | + $ss->assign("form_name", $view); |
|
562 | + $ss->assign("bean", $focus); |
|
563 | 563 | |
564 | 564 | // add in any additional strings |
565 | 565 | $ss->assign("MOD", $mod_strings); |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | |
573 | 573 | |
574 | 574 | |
575 | -function getDateField($module, $aow_field, $view, $value, $field_option = true){ |
|
575 | +function getDateField($module, $aow_field, $view, $value, $field_option = true) { |
|
576 | 576 | global $app_list_strings; |
577 | 577 | |
578 | 578 | // set $view = 'EditView' as default |
@@ -582,21 +582,21 @@ discard block |
||
582 | 582 | |
583 | 583 | $value = json_decode(html_entity_decode_utf8($value), true); |
584 | 584 | |
585 | - if(!file_exists('modules/AOBH_BusinessHours/AOBH_BusinessHours.php')) unset($app_list_strings['aow_date_type_list']['business_hours']); |
|
585 | + if (!file_exists('modules/AOBH_BusinessHours/AOBH_BusinessHours.php')) unset($app_list_strings['aow_date_type_list']['business_hours']); |
|
586 | 586 | |
587 | 587 | $field = ''; |
588 | 588 | |
589 | - if($view == 'EditView'){ |
|
590 | - $field .= "<select type='text' name='$aow_field".'[0]'."' id='$aow_field".'[0]'."' title='' tabindex='116'>". getDateFields($module, $view, $value[0], $field_option) ."</select> "; |
|
591 | - $field .= "<select type='text' name='$aow_field".'[1]'."' id='$aow_field".'[1]'."' onchange='date_field_change(\"$aow_field\")' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aow_date_operator'], $value[1]) ."</select> "; |
|
589 | + if ($view == 'EditView') { |
|
590 | + $field .= "<select type='text' name='$aow_field".'[0]'."' id='$aow_field".'[0]'."' title='' tabindex='116'>".getDateFields($module, $view, $value[0], $field_option)."</select> "; |
|
591 | + $field .= "<select type='text' name='$aow_field".'[1]'."' id='$aow_field".'[1]'."' onchange='date_field_change(\"$aow_field\")' title='' tabindex='116'>".get_select_options_with_id($app_list_strings['aow_date_operator'], $value[1])."</select> "; |
|
592 | 592 | $display = 'none'; |
593 | - if($value[1] == 'plus' || $value[1] == 'minus') $display = ''; |
|
593 | + if ($value[1] == 'plus' || $value[1] == 'minus') $display = ''; |
|
594 | 594 | $field .= "<input type='text' style='display:$display' name='$aow_field".'[2]'."' id='$aow_field".'[2]'."' title='' value='$value[2]' tabindex='116'> "; |
595 | - $field .= "<select type='text' style='display:$display' name='$aow_field".'[3]'."' id='$aow_field".'[3]'."' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aow_date_type_list'], $value[3]) ."</select>"; |
|
595 | + $field .= "<select type='text' style='display:$display' name='$aow_field".'[3]'."' id='$aow_field".'[3]'."' title='' tabindex='116'>".get_select_options_with_id($app_list_strings['aow_date_type_list'], $value[3])."</select>"; |
|
596 | 596 | } |
597 | 597 | else { |
598 | 598 | $field = getDateFields($module, $view, $value[0], $field_option).' '.$app_list_strings['aow_date_operator'][$value[1]]; |
599 | - if($value[1] == 'plus' || $value[1] == 'minus'){ |
|
599 | + if ($value[1] == 'plus' || $value[1] == 'minus') { |
|
600 | 600 | $field .= ' '.$value[2].' '.$app_list_strings['aow_date_type_list'][$value[3]]; |
601 | 601 | } |
602 | 602 | } |
@@ -604,21 +604,21 @@ discard block |
||
604 | 604 | |
605 | 605 | } |
606 | 606 | |
607 | -function getDateFields($module, $view='EditView',$value = '', $field_option = true) |
|
607 | +function getDateFields($module, $view = 'EditView', $value = '', $field_option = true) |
|
608 | 608 | { |
609 | 609 | global $beanList, $app_list_strings; |
610 | 610 | |
611 | 611 | $fields = $app_list_strings['aow_date_options']; |
612 | 612 | |
613 | - if(!$field_option) unset($fields['field']); |
|
613 | + if (!$field_option) unset($fields['field']); |
|
614 | 614 | |
615 | 615 | if ($module != '') { |
616 | - if(isset($beanList[$module]) && $beanList[$module]){ |
|
616 | + if (isset($beanList[$module]) && $beanList[$module]) { |
|
617 | 617 | $mod = new $beanList[$module](); |
618 | - foreach($mod->field_defs as $name => $arr){ |
|
619 | - if($arr['type'] == 'date' || $arr['type'] == 'datetime' || $arr['type'] == 'datetimecombo'){ |
|
620 | - if(isset($arr['vname']) && $arr['vname'] != ''){ |
|
621 | - $fields[$name] = translate($arr['vname'],$mod->module_dir); |
|
618 | + foreach ($mod->field_defs as $name => $arr) { |
|
619 | + if ($arr['type'] == 'date' || $arr['type'] == 'datetime' || $arr['type'] == 'datetimecombo') { |
|
620 | + if (isset($arr['vname']) && $arr['vname'] != '') { |
|
621 | + $fields[$name] = translate($arr['vname'], $mod->module_dir); |
|
622 | 622 | } else { |
623 | 623 | $fields[$name] = $name; |
624 | 624 | } |
@@ -627,42 +627,42 @@ discard block |
||
627 | 627 | |
628 | 628 | } |
629 | 629 | } |
630 | - if($view == 'EditView'){ |
|
630 | + if ($view == 'EditView') { |
|
631 | 631 | return get_select_options_with_id($fields, $value); |
632 | 632 | } else { |
633 | 633 | return $fields[$value]; |
634 | 634 | } |
635 | 635 | } |
636 | 636 | |
637 | -function getAssignField($aow_field, $view, $value){ |
|
637 | +function getAssignField($aow_field, $view, $value) { |
|
638 | 638 | global $app_list_strings; |
639 | 639 | |
640 | 640 | $value = json_decode(html_entity_decode_utf8($value), true); |
641 | 641 | |
642 | - $roles = get_bean_select_array(true, 'ACLRole','name', '','name',true); |
|
642 | + $roles = get_bean_select_array(true, 'ACLRole', 'name', '', 'name', true); |
|
643 | 643 | |
644 | - if(!file_exists('modules/SecurityGroups/SecurityGroup.php')){ |
|
644 | + if (!file_exists('modules/SecurityGroups/SecurityGroup.php')) { |
|
645 | 645 | unset($app_list_strings['aow_assign_options']['security_group']); |
646 | 646 | } |
647 | - else{ |
|
648 | - $securityGroups = get_bean_select_array(true, 'SecurityGroup','name', '','name',true); |
|
647 | + else { |
|
648 | + $securityGroups = get_bean_select_array(true, 'SecurityGroup', 'name', '', 'name', true); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | $field = ''; |
652 | 652 | |
653 | - if($view == 'EditView'){ |
|
654 | - $field .= "<select type='text' name='$aow_field".'[0]'."' id='$aow_field".'[0]'."' onchange='assign_field_change(\"$aow_field\")' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aow_assign_options'], $value[0]) ."</select> "; |
|
655 | - if(!file_exists('modules/SecurityGroups/SecurityGroup.php')){ |
|
653 | + if ($view == 'EditView') { |
|
654 | + $field .= "<select type='text' name='$aow_field".'[0]'."' id='$aow_field".'[0]'."' onchange='assign_field_change(\"$aow_field\")' title='' tabindex='116'>".get_select_options_with_id($app_list_strings['aow_assign_options'], $value[0])."</select> "; |
|
655 | + if (!file_exists('modules/SecurityGroups/SecurityGroup.php')) { |
|
656 | 656 | $field .= "<input type='hidden' name='$aow_field".'[1]'."' id='$aow_field".'[1]'."' value='' />"; |
657 | 657 | } |
658 | 658 | else { |
659 | 659 | $display = 'none'; |
660 | - if($value[0] == 'security_group') $display = ''; |
|
661 | - $field .= "<select type='text' style='display:$display' name='$aow_field".'[1]'."' id='$aow_field".'[1]'."' title='' tabindex='116'>". get_select_options_with_id($securityGroups, $value[1]) ."</select> "; |
|
660 | + if ($value[0] == 'security_group') $display = ''; |
|
661 | + $field .= "<select type='text' style='display:$display' name='$aow_field".'[1]'."' id='$aow_field".'[1]'."' title='' tabindex='116'>".get_select_options_with_id($securityGroups, $value[1])."</select> "; |
|
662 | 662 | } |
663 | 663 | $display = 'none'; |
664 | - if($value[0] == 'role' || $value[0] == 'security_group') $display = ''; |
|
665 | - $field .= "<select type='text' style='display:$display' name='$aow_field".'[2]'."' id='$aow_field".'[2]'."' title='' tabindex='116'>". get_select_options_with_id($roles, $value[2]) ."</select> "; |
|
664 | + if ($value[0] == 'role' || $value[0] == 'security_group') $display = ''; |
|
665 | + $field .= "<select type='text' style='display:$display' name='$aow_field".'[2]'."' id='$aow_field".'[2]'."' title='' tabindex='116'>".get_select_options_with_id($roles, $value[2])."</select> "; |
|
666 | 666 | } |
667 | 667 | else { |
668 | 668 | $field = $app_list_strings['aow_assign_options'][$value[1]]; |
@@ -674,10 +674,10 @@ discard block |
||
674 | 674 | function getDropdownList($list_id, $selected_value) { |
675 | 675 | global $app_list_strings; |
676 | 676 | $option = ''; |
677 | - foreach($app_list_strings[$list_id] as $key => $value) { |
|
678 | - if(base64_decode($selected_value) == $key) { |
|
677 | + foreach ($app_list_strings[$list_id] as $key => $value) { |
|
678 | + if (base64_decode($selected_value) == $key) { |
|
679 | 679 | $option .= '<option value="'.$key.'" selected>'.$value.'</option>'; |
680 | - } else if($selected_value == $key) { |
|
680 | + } else if ($selected_value == $key) { |
|
681 | 681 | $option .= '<option value="'.$key.'" selected>'.$value.'</option>'; |
682 | 682 | } |
683 | 683 | else { |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | } |
689 | 689 | function getLeastBusyUser($users, $field, SugarBean $bean) { |
690 | 690 | $counts = array(); |
691 | - foreach($users as $id) { |
|
691 | + foreach ($users as $id) { |
|
692 | 692 | $c = $bean->db->getOne("SELECT count(*) AS c FROM ".$bean->table_name." WHERE $field = '$id' AND deleted = 0"); |
693 | 693 | $counts[$id] = $c; |
694 | 694 | } |
@@ -699,21 +699,21 @@ discard block |
||
699 | 699 | |
700 | 700 | function getRoundRobinUser($users, $id) { |
701 | 701 | |
702 | - $file = create_cache_directory('modules/AOW_WorkFlow/Users/') . $id . 'lastUser.cache.php'; |
|
702 | + $file = create_cache_directory('modules/AOW_WorkFlow/Users/').$id.'lastUser.cache.php'; |
|
703 | 703 | |
704 | - if(isset($_SESSION['lastuser'][$id]) && $_SESSION['lastuser'][$id] != '') { |
|
704 | + if (isset($_SESSION['lastuser'][$id]) && $_SESSION['lastuser'][$id] != '') { |
|
705 | 705 | $users_by_key = array_flip($users); // now keys are values |
706 | 706 | $key = $users_by_key[$_SESSION['lastuser'][$id]] + 1; |
707 | - if(!empty($users[$key])) { |
|
707 | + if (!empty($users[$key])) { |
|
708 | 708 | return $users[$key]; |
709 | 709 | } |
710 | 710 | } |
711 | - else if (is_file($file)){ |
|
711 | + else if (is_file($file)) { |
|
712 | 712 | require_once($file); |
713 | - if(isset($lastUser['User']) && $lastUser['User'] != '') { |
|
713 | + if (isset($lastUser['User']) && $lastUser['User'] != '') { |
|
714 | 714 | $users_by_key = array_flip($users); // now keys are values |
715 | 715 | $key = $users_by_key[$lastUser['User']] + 1; |
716 | - if(!empty($users[$key])) { |
|
716 | + if (!empty($users[$key])) { |
|
717 | 717 | return $users[$key]; |
718 | 718 | } |
719 | 719 | } |
@@ -726,31 +726,31 @@ discard block |
||
726 | 726 | |
727 | 727 | $_SESSION['lastuser'][$id] = $user_id; |
728 | 728 | |
729 | - $file = create_cache_directory('modules/AOW_WorkFlow/Users/') . $id . 'lastUser.cache.php'; |
|
729 | + $file = create_cache_directory('modules/AOW_WorkFlow/Users/').$id.'lastUser.cache.php'; |
|
730 | 730 | |
731 | 731 | $arrayString = var_export_helper(array('User' => $user_id)); |
732 | 732 | |
733 | - $content =<<<eoq |
|
733 | + $content = <<<eoq |
|
734 | 734 | <?php |
735 | 735 | \$lastUser = {$arrayString}; |
736 | 736 | ?> |
737 | 737 | eoq; |
738 | 738 | |
739 | - if($fh = @sugar_fopen($file, 'w')) { |
|
739 | + if ($fh = @sugar_fopen($file, 'w')) { |
|
740 | 740 | fputs($fh, $content); |
741 | 741 | fclose($fh); |
742 | 742 | } |
743 | 743 | return true; |
744 | 744 | } |
745 | 745 | |
746 | -function getEmailableModules(){ |
|
746 | +function getEmailableModules() { |
|
747 | 747 | global $beanFiles, $beanList, $app_list_strings; |
748 | 748 | $emailableModules = array(); |
749 | - foreach($app_list_strings['aow_moduleList'] as $bean_name => $bean_dis) { |
|
750 | - if(isset($beanList[$bean_name]) && isset($beanFiles[$beanList[$bean_name]])){ |
|
749 | + foreach ($app_list_strings['aow_moduleList'] as $bean_name => $bean_dis) { |
|
750 | + if (isset($beanList[$bean_name]) && isset($beanFiles[$beanList[$bean_name]])) { |
|
751 | 751 | require_once($beanFiles[$beanList[$bean_name]]); |
752 | 752 | $obj = new $beanList[$bean_name]; |
753 | - if($obj instanceof Person || $obj instanceof Company){ |
|
753 | + if ($obj instanceof Person || $obj instanceof Company) { |
|
754 | 754 | $emailableModules[] = $bean_name; |
755 | 755 | } |
756 | 756 | } |
@@ -759,37 +759,37 @@ discard block |
||
759 | 759 | return $emailableModules; |
760 | 760 | } |
761 | 761 | |
762 | -function getRelatedEmailableFields($module){ |
|
762 | +function getRelatedEmailableFields($module) { |
|
763 | 763 | global $beanList, $app_list_strings; |
764 | 764 | $relEmailFields = array(); |
765 | 765 | $checked_link = array(); |
766 | 766 | $emailableModules = getEmailableModules(); |
767 | 767 | if ($module != '') { |
768 | - if(isset($beanList[$module]) && $beanList[$module]){ |
|
768 | + if (isset($beanList[$module]) && $beanList[$module]) { |
|
769 | 769 | $mod = new $beanList[$module](); |
770 | 770 | |
771 | - foreach($mod->get_related_fields() as $field){ |
|
772 | - if(isset($field['link'])) $checked_link[] = $field['link']; |
|
773 | - if(!isset($field['module']) || !in_array($field['module'],$emailableModules) || (isset($field['dbType']) && $field['dbType'] == "id")){ |
|
771 | + foreach ($mod->get_related_fields() as $field) { |
|
772 | + if (isset($field['link'])) $checked_link[] = $field['link']; |
|
773 | + if (!isset($field['module']) || !in_array($field['module'], $emailableModules) || (isset($field['dbType']) && $field['dbType'] == "id")) { |
|
774 | 774 | continue; |
775 | 775 | } |
776 | - $relEmailFields[$field['name']] = $field['module'].": ".trim(translate($field['vname'],$mod->module_name),":"); |
|
776 | + $relEmailFields[$field['name']] = $field['module'].": ".trim(translate($field['vname'], $mod->module_name), ":"); |
|
777 | 777 | } |
778 | 778 | |
779 | - foreach($mod->get_linked_fields() as $field){ |
|
780 | - if(!in_array($field['name'],$checked_link) && !in_array($field['relationship'],$checked_link)){ |
|
781 | - if(isset($field['module']) && $field['module'] != '') { |
|
779 | + foreach ($mod->get_linked_fields() as $field) { |
|
780 | + if (!in_array($field['name'], $checked_link) && !in_array($field['relationship'], $checked_link)) { |
|
781 | + if (isset($field['module']) && $field['module'] != '') { |
|
782 | 782 | $rel_module = $field['module']; |
783 | - } else if($mod->load_relationship($field['name'])){ |
|
783 | + } else if ($mod->load_relationship($field['name'])) { |
|
784 | 784 | $relField = $field['name']; |
785 | 785 | $rel_module = $mod->$relField->getRelatedModuleName(); |
786 | 786 | } |
787 | 787 | |
788 | - if(in_array($rel_module,$emailableModules)) { |
|
788 | + if (in_array($rel_module, $emailableModules)) { |
|
789 | 789 | if (isset($field['vname']) && $field['vname'] != '') { |
790 | - $relEmailFields[$field['name']] = $app_list_strings['moduleList'][$rel_module] . ' : ' . translate($field['vname'], $mod->module_dir); |
|
790 | + $relEmailFields[$field['name']] = $app_list_strings['moduleList'][$rel_module].' : '.translate($field['vname'], $mod->module_dir); |
|
791 | 791 | } else { |
792 | - $relEmailFields[$field['name']] = $app_list_strings['moduleList'][$rel_module] . ' : ' . $field['name']; |
|
792 | + $relEmailFields[$field['name']] = $app_list_strings['moduleList'][$rel_module].' : '.$field['name']; |
|
793 | 793 | } |
794 | 794 | } |
795 | 795 | } |
@@ -810,37 +810,37 @@ discard block |
||
810 | 810 | |
811 | 811 | static $boolean_false_values = array('off', 'false', '0', 'no'); |
812 | 812 | |
813 | - switch($bean->field_defs[$field]['type']) { |
|
813 | + switch ($bean->field_defs[$field]['type']) { |
|
814 | 814 | case 'datetime': |
815 | 815 | case 'datetimecombo': |
816 | - if(empty($value)) break; |
|
816 | + if (empty($value)) break; |
|
817 | 817 | if ($value == 'NULL') { |
818 | 818 | $value = ''; |
819 | 819 | break; |
820 | 820 | } |
821 | - if ( ! preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/',$value) ) { |
|
821 | + if (!preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/', $value)) { |
|
822 | 822 | // This appears to be formatted in user date/time |
823 | 823 | $value = $timedate->to_db($value); |
824 | 824 | } |
825 | 825 | break; |
826 | 826 | case 'date': |
827 | - if(empty($value)) break; |
|
827 | + if (empty($value)) break; |
|
828 | 828 | if ($value == 'NULL') { |
829 | 829 | $value = ''; |
830 | 830 | break; |
831 | 831 | } |
832 | - if ( ! preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/',$value) ) { |
|
832 | + if (!preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $value)) { |
|
833 | 833 | // This date appears to be formatted in the user's format |
834 | 834 | $value = $timedate->to_db_date($value, false); |
835 | 835 | } |
836 | 836 | break; |
837 | 837 | case 'time': |
838 | - if(empty($value)) break; |
|
838 | + if (empty($value)) break; |
|
839 | 839 | if ($value == 'NULL') { |
840 | 840 | $value = ''; |
841 | 841 | break; |
842 | 842 | } |
843 | - if ( preg_match('/(am|pm)/i',$value) ) { |
|
843 | + if (preg_match('/(am|pm)/i', $value)) { |
|
844 | 844 | // This time appears to be formatted in the user's format |
845 | 845 | $value = $timedate->fromUserTime($value)->format(TimeDate::DB_TIME_FORMAT); |
846 | 846 | } |
@@ -849,10 +849,10 @@ discard block |
||
849 | 849 | case 'decimal': |
850 | 850 | case 'currency': |
851 | 851 | case 'float': |
852 | - if ( $value === '' || $value == NULL || $value == 'NULL') { |
|
852 | + if ($value === '' || $value == NULL || $value == 'NULL') { |
|
853 | 853 | continue; |
854 | 854 | } |
855 | - if ( is_string($value) ) { |
|
855 | + if (is_string($value)) { |
|
856 | 856 | $value = (float)unformat_number($value); |
857 | 857 | } |
858 | 858 | break; |
@@ -862,19 +862,19 @@ discard block |
||
862 | 862 | case 'short': |
863 | 863 | case 'tinyint': |
864 | 864 | case 'int': |
865 | - if ( $value === '' || $value == NULL || $value == 'NULL') { |
|
865 | + if ($value === '' || $value == NULL || $value == 'NULL') { |
|
866 | 866 | continue; |
867 | 867 | } |
868 | - if ( is_string($value) ) { |
|
868 | + if (is_string($value)) { |
|
869 | 869 | $value = (int)unformat_number($value); |
870 | 870 | } |
871 | 871 | break; |
872 | 872 | case 'bool': |
873 | 873 | if (empty($value)) { |
874 | 874 | $value = false; |
875 | - } else if(true === $value || 1 == $value) { |
|
875 | + } else if (true === $value || 1 == $value) { |
|
876 | 876 | $value = true; |
877 | - } else if(in_array(strval($value), $boolean_false_values)) { |
|
877 | + } else if (in_array(strval($value), $boolean_false_values)) { |
|
878 | 878 | $value = false; |
879 | 879 | } else { |
880 | 880 | $value = true; |