@@ -42,18 +42,18 @@ discard block |
||
42 | 42 | class SugarFieldText extends SugarFieldBase { |
43 | 43 | |
44 | 44 | function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) { |
45 | - if(!isset($displayParams['nl2br'])){ |
|
45 | + if (!isset($displayParams['nl2br'])) { |
|
46 | 46 | $displayParams['nl2br'] = true; |
47 | 47 | } |
48 | - if(!isset($displayParams['htmlescape'])) { |
|
48 | + if (!isset($displayParams['htmlescape'])) { |
|
49 | 49 | $displayParams['htmlescape'] = true; |
50 | 50 | } |
51 | - if(!isset($displayParams['url2html'])) { |
|
51 | + if (!isset($displayParams['url2html'])) { |
|
52 | 52 | $displayParams['url2html'] = true; |
53 | 53 | } |
54 | 54 | return parent::getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex); |
55 | 55 | } |
56 | - function getClassicEditView($field_id='description', $value='', $prefix='', $rich_text=false, $maxlength='', $tabindex=1, $cols=80, $rows=4) { |
|
56 | + function getClassicEditView($field_id = 'description', $value = '', $prefix = '', $rich_text = false, $maxlength = '', $tabindex = 1, $cols = 80, $rows = 4) { |
|
57 | 57 | |
58 | 58 | $this->ss->assign('prefix', $prefix); |
59 | 59 | $this->ss->assign('field_id', $field_id); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | |
70 | 70 | $this->ss->assign('displayParams', $displayParams); |
71 | - if(isset($GLOBALS['current_user'])) { |
|
71 | + if (isset($GLOBALS['current_user'])) { |
|
72 | 72 | $height = $GLOBALS['current_user']->getPreference('text_editor_height'); |
73 | 73 | $width = $GLOBALS['current_user']->getPreference('text_editor_width'); |
74 | 74 | $height = isset($height) ? $height : '300px'; |
@@ -3,48 +3,48 @@ |
||
3 | 3 | |
4 | 4 | class SugarFieldCronSchedule extends SugarFieldBase { |
5 | 5 | |
6 | - private function getDays(){ |
|
6 | + private function getDays() { |
|
7 | 7 | $days = array(); |
8 | 8 | $date = new DateTime("1986-05-01"); |
9 | 9 | $period = new DateInterval('P1D'); |
10 | - for($x = 1; $x <= 31; $x++){ |
|
11 | - $days[$x] = $date->format('jS');; |
|
10 | + for ($x = 1; $x <= 31; $x++) { |
|
11 | + $days[$x] = $date->format('jS'); ; |
|
12 | 12 | $date->add($period); |
13 | 13 | } |
14 | 14 | return $days; |
15 | 15 | } |
16 | - private function getWeekDays(){ |
|
16 | + private function getWeekDays() { |
|
17 | 17 | $days = array(); |
18 | 18 | $date = new DateTime("1986-05-04"); |
19 | 19 | $period = new DateInterval('P1D'); |
20 | - for($x = 0; $x < 7; $x++){ |
|
20 | + for ($x = 0; $x < 7; $x++) { |
|
21 | 21 | $days[$x] = $date->format('D'); |
22 | 22 | $date->add($period); |
23 | 23 | } |
24 | 24 | return $days; |
25 | 25 | } |
26 | 26 | |
27 | - function getHumanReadable($schedule){ |
|
27 | + function getHumanReadable($schedule) { |
|
28 | 28 | |
29 | 29 | } |
30 | 30 | |
31 | 31 | function setup($parentFieldArray, $vardef, $displayParams, $tabindex, $twopass = true) { |
32 | - global $app_list_strings,$app_strings; |
|
32 | + global $app_list_strings, $app_strings; |
|
33 | 33 | parent::setup($parentFieldArray, $vardef, $displayParams, $tabindex, $twopass); |
34 | - $this->ss->assign('APP',$app_strings); |
|
35 | - $this->ss->assign('types',get_select_options_with_id($app_list_strings['aor_scheduled_report_schedule_types'],'')); |
|
34 | + $this->ss->assign('APP', $app_strings); |
|
35 | + $this->ss->assign('types', get_select_options_with_id($app_list_strings['aor_scheduled_report_schedule_types'], '')); |
|
36 | 36 | $weekdays = $this->getWeekDays(); |
37 | - $this->ss->assign('weekday_vals',json_encode($weekdays)); |
|
38 | - $this->ss->assign('weekdays',get_select_options($weekdays,'')); |
|
37 | + $this->ss->assign('weekday_vals', json_encode($weekdays)); |
|
38 | + $this->ss->assign('weekdays', get_select_options($weekdays, '')); |
|
39 | 39 | $days = $this->getDays(); |
40 | - $this->ss->assign('days',get_select_options($days,'')); |
|
41 | - function padNumbers($x){ |
|
42 | - return str_pad($x,2,'0',STR_PAD_LEFT); |
|
40 | + $this->ss->assign('days', get_select_options($days, '')); |
|
41 | + function padNumbers($x) { |
|
42 | + return str_pad($x, 2, '0', STR_PAD_LEFT); |
|
43 | 43 | } |
44 | - $minutes = array_map('padNumbers',range(0,59)); |
|
45 | - $hours = array_map('padNumbers',range(0,23)); |
|
46 | - $this->ss->assign('minutes',get_select_options($minutes,'')); |
|
47 | - $this->ss->assign('hours',get_select_options($hours,'')); |
|
44 | + $minutes = array_map('padNumbers', range(0, 59)); |
|
45 | + $hours = array_map('padNumbers', range(0, 23)); |
|
46 | + $this->ss->assign('minutes', get_select_options($minutes, '')); |
|
47 | + $this->ss->assign('hours', get_select_options($hours, '')); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 |
@@ -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. |
@@ -84,16 +84,16 @@ discard block |
||
84 | 84 | * @param string $module |
85 | 85 | */ |
86 | 86 | function handleLegacySave($bean, $prefix = "") { |
87 | - if(!isset($_REQUEST) || !isset($_REQUEST['useEmailWidget'])) { |
|
87 | + if (!isset($_REQUEST) || !isset($_REQUEST['useEmailWidget'])) { |
|
88 | 88 | if (empty($this->addresses) || !isset($_REQUEST['massupdate'])) { |
89 | 89 | $this->addresses = array(); |
90 | 90 | $optOut = (isset($bean->email_opt_out) && $bean->email_opt_out == "1") ? true : false; |
91 | 91 | $invalid = (isset($bean->invalid_email) && $bean->invalid_email == "1") ? true : false; |
92 | 92 | |
93 | 93 | $isPrimary = true; |
94 | - for($i = 1; $i <= 10; $i++){ |
|
94 | + for ($i = 1; $i <= 10; $i++) { |
|
95 | 95 | $email = 'email'.$i; |
96 | - if(isset($bean->$email) && !empty($bean->$email)){ |
|
96 | + if (isset($bean->$email) && !empty($bean->$email)) { |
|
97 | 97 | $opt_out_field = $email.'_opt_out'; |
98 | 98 | $invalid_field = $email.'_invalid'; |
99 | 99 | $field_optOut = (isset($bean->$opt_out_field)) ? $bean->$opt_out_field : $optOut; |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | } |
105 | 105 | } |
106 | 106 | } |
107 | - $this->populateAddresses($bean->id, $bean->module_dir, array(),''); |
|
108 | - if(isset($_REQUEST) && isset($_REQUEST['useEmailWidget'])) { |
|
107 | + $this->populateAddresses($bean->id, $bean->module_dir, array(), ''); |
|
108 | + if (isset($_REQUEST) && isset($_REQUEST['useEmailWidget'])) { |
|
109 | 109 | $this->populateLegacyFields($bean); |
110 | 110 | } |
111 | 111 | } |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | return; |
128 | 128 | } |
129 | 129 | |
130 | - function populateLegacyFields(&$bean){ |
|
130 | + function populateLegacyFields(&$bean) { |
|
131 | 131 | $primary_found = false; |
132 | 132 | $alternate_found = false; |
133 | 133 | $alternate2_found = false; |
134 | - foreach($this->addresses as $k=>$address) { |
|
134 | + foreach ($this->addresses as $k=>$address) { |
|
135 | 135 | if ($primary_found && $alternate_found) |
136 | 136 | break; |
137 | 137 | if ($address['primary_address'] == 1 && !$primary_found) { |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | } elseif (!$alternate_found) { |
141 | 141 | $alternate_index = $k; |
142 | 142 | $alternate_found = true; |
143 | - } elseif (!$alternate2_found){ |
|
143 | + } elseif (!$alternate2_found) { |
|
144 | 144 | $alternate2_index = $k; |
145 | 145 | $alternate2_found = true; |
146 | 146 | } |
@@ -177,27 +177,27 @@ discard block |
||
177 | 177 | $args = func_get_args(); |
178 | 178 | return call_user_func_array(array($this, '_save'), $args); |
179 | 179 | } |
180 | - private function _save($id, $module, $new_addrs=array(), $primary='', $replyTo='', $invalid='', $optOut='', $in_workflow=false) { |
|
181 | - if(empty($this->addresses) || $in_workflow){ |
|
182 | - $this->populateAddresses($id, $module, $new_addrs,$primary); |
|
180 | + private function _save($id, $module, $new_addrs = array(), $primary = '', $replyTo = '', $invalid = '', $optOut = '', $in_workflow = false) { |
|
181 | + if (empty($this->addresses) || $in_workflow) { |
|
182 | + $this->populateAddresses($id, $module, $new_addrs, $primary); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | //find all email addresses.. |
186 | - $current_links=array(); |
|
186 | + $current_links = array(); |
|
187 | 187 | // Need to correct this to handle the Employee/User split |
188 | 188 | $module = $this->getCorrectedModule($module); |
189 | - $q2="select * from email_addr_bean_rel eabr WHERE eabr.bean_id = '".$this->db->quote($id)."' AND eabr.bean_module = '".$this->db->quote($module)."' and eabr.deleted=0"; |
|
189 | + $q2 = "select * from email_addr_bean_rel eabr WHERE eabr.bean_id = '".$this->db->quote($id)."' AND eabr.bean_module = '".$this->db->quote($module)."' and eabr.deleted=0"; |
|
190 | 190 | $r2 = $this->db->query($q2); |
191 | - while(($row2=$this->db->fetchByAssoc($r2)) != null ) { |
|
192 | - $current_links[$row2['email_address_id']]=$row2; |
|
191 | + while (($row2 = $this->db->fetchByAssoc($r2)) != null) { |
|
192 | + $current_links[$row2['email_address_id']] = $row2; |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | $isConversion = (isset($_REQUEST) && isset($_REQUEST['action']) && $_REQUEST['action'] == 'ConvertLead') ? true : false; |
196 | 196 | |
197 | 197 | if (!empty($this->addresses)) { |
198 | 198 | // insert new relationships and create email address record, if they don't exist |
199 | - foreach($this->addresses as $address) { |
|
200 | - if(!empty($address['email_address'])) { |
|
199 | + foreach ($this->addresses as $address) { |
|
200 | + if (!empty($address['email_address'])) { |
|
201 | 201 | $guid = create_guid(); |
202 | 202 | $emailId = isset($address['email_address_id']) |
203 | 203 | && isset($current_links[$address['email_address_id']]) |
@@ -205,14 +205,14 @@ discard block |
||
205 | 205 | $emailId = $this->AddUpdateEmailAddress($address['email_address'], |
206 | 206 | $address['invalid_email'], |
207 | 207 | $address['opt_out'], |
208 | - $emailId);// this will save the email address if not found |
|
208 | + $emailId); // this will save the email address if not found |
|
209 | 209 | |
210 | 210 | //verify linkage and flags. |
211 | - $upd_eabr=""; |
|
211 | + $upd_eabr = ""; |
|
212 | 212 | if (isset($current_links[$emailId])) { |
213 | 213 | if (!$isConversion) { // do not update anything if this is for lead conversion |
214 | - if ($address['primary_address'] != $current_links[$emailId]['primary_address'] or $address['reply_to_address'] != $current_links[$emailId]['reply_to_address'] ) { |
|
215 | - $upd_eabr="UPDATE email_addr_bean_rel SET primary_address='".$this->db->quote($address['primary_address'])."', reply_to_address='".$this->db->quote($address['reply_to_address'])."' WHERE id='".$this->db->quote($current_links[$emailId]['id'])."'"; |
|
214 | + if ($address['primary_address'] != $current_links[$emailId]['primary_address'] or $address['reply_to_address'] != $current_links[$emailId]['reply_to_address']) { |
|
215 | + $upd_eabr = "UPDATE email_addr_bean_rel SET primary_address='".$this->db->quote($address['primary_address'])."', reply_to_address='".$this->db->quote($address['reply_to_address'])."' WHERE id='".$this->db->quote($current_links[$emailId]['id'])."'"; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | unset($current_links[$emailId]); |
@@ -243,13 +243,13 @@ discard block |
||
243 | 243 | // for lead conversion, do not delete email addresses |
244 | 244 | if (!empty($current_links) && !$isConversion) { |
245 | 245 | |
246 | - $delete=""; |
|
246 | + $delete = ""; |
|
247 | 247 | foreach ($current_links as $eabr) { |
248 | 248 | |
249 | - $delete.=empty($delete) ? "'".$this->db->quote($eabr['id']) . "' " : ",'" . $this->db->quote($eabr['id']) . "'"; |
|
249 | + $delete .= empty($delete) ? "'".$this->db->quote($eabr['id'])."' " : ",'".$this->db->quote($eabr['id'])."'"; |
|
250 | 250 | } |
251 | 251 | |
252 | - $eabr_unlink="update email_addr_bean_rel set deleted=1 where id in ({$delete})"; |
|
252 | + $eabr_unlink = "update email_addr_bean_rel set deleted=1 where id in ({$delete})"; |
|
253 | 253 | $this->db->query($eabr_unlink); |
254 | 254 | } |
255 | 255 | $this->stateBeforeWorkflow = null; |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | ) |
272 | 272 | { |
273 | 273 | $emailCaps = strtoupper(trim($email)); |
274 | - if(empty($emailCaps)) |
|
274 | + if (empty($emailCaps)) |
|
275 | 275 | return 0; |
276 | 276 | |
277 | 277 | $q = "SELECT * |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | $r = $this->db->query($q, true); |
310 | 310 | |
311 | 311 | $retArr = array(); |
312 | - while($a = $this->db->fetchByAssoc($r)) { |
|
312 | + while ($a = $this->db->fetchByAssoc($r)) { |
|
313 | 313 | $retArr[] = $a['bean_id']; |
314 | 314 | } |
315 | - if(count($retArr) > 0) { |
|
315 | + if (count($retArr) > 0) { |
|
316 | 316 | return $retArr; |
317 | 317 | } else { |
318 | 318 | return false; |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | |
333 | 333 | $email = trim($email); |
334 | 334 | |
335 | - if(empty($email)) { |
|
335 | + if (empty($email)) { |
|
336 | 336 | return array(); |
337 | 337 | } |
338 | 338 | |
@@ -341,12 +341,12 @@ discard block |
||
341 | 341 | WHERE ea.email_address_caps = $emailCaps and eabl.deleted=0 "; |
342 | 342 | $r = $this->db->query($q); |
343 | 343 | |
344 | - while($a = $this->db->fetchByAssoc($r)) { |
|
345 | - if(isset($beanList[$a['bean_module']]) && !empty($beanList[$a['bean_module']])) { |
|
344 | + while ($a = $this->db->fetchByAssoc($r)) { |
|
345 | + if (isset($beanList[$a['bean_module']]) && !empty($beanList[$a['bean_module']])) { |
|
346 | 346 | $className = $beanList[$a['bean_module']]; |
347 | 347 | |
348 | - if(isset($beanFiles[$className]) && !empty($beanFiles[$className])) { |
|
349 | - if(!class_exists($className)) { |
|
348 | + if (isset($beanFiles[$className]) && !empty($beanFiles[$className])) { |
|
349 | + if (!class_exists($className)) { |
|
350 | 350 | require_once($beanFiles[$className]); |
351 | 351 | } |
352 | 352 | |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | * @param string $replyTo GUID of reply-to address |
375 | 375 | * @param string $invalid GUID of invalid address |
376 | 376 | */ |
377 | - function populateAddresses($id, $module, $new_addrs=array(), $primary='', $replyTo='', $invalid='', $optOut='') { |
|
377 | + function populateAddresses($id, $module, $new_addrs = array(), $primary = '', $replyTo = '', $invalid = '', $optOut = '') { |
|
378 | 378 | $module = $this->getCorrectedModule($module); |
379 | 379 | //One last check for the ConvertLead action in which case we need to change $module to 'Leads' |
380 | 380 | $module = (isset($_REQUEST) && isset($_REQUEST['action']) && $_REQUEST['action'] == 'ConvertLead') ? 'Leads' : $module; |
@@ -385,54 +385,54 @@ discard block |
||
385 | 385 | $hasEmailValue = false; |
386 | 386 | $email_ids = array(); |
387 | 387 | |
388 | - if (isset($_REQUEST) && isset($_REQUEST[$module .'_email_widget_id'])) { |
|
388 | + if (isset($_REQUEST) && isset($_REQUEST[$module.'_email_widget_id'])) { |
|
389 | 389 | |
390 | 390 | $fromRequest = false; |
391 | 391 | // determine which array to process |
392 | - foreach($_REQUEST as $k => $v) { |
|
393 | - if(strpos($k, 'emailAddress') !== false) { |
|
392 | + foreach ($_REQUEST as $k => $v) { |
|
393 | + if (strpos($k, 'emailAddress') !== false) { |
|
394 | 394 | $fromRequest = true; |
395 | 395 | break; |
396 | 396 | } |
397 | - $widget_id = $_REQUEST[$module .'_email_widget_id']; |
|
397 | + $widget_id = $_REQUEST[$module.'_email_widget_id']; |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | //Iterate over the widgets for this module, in case there are multiple email widgets for this module |
401 | - while(isset($_REQUEST[$module . $widget_id . "emailAddress" . $widgetCount])) |
|
401 | + while (isset($_REQUEST[$module.$widget_id."emailAddress".$widgetCount])) |
|
402 | 402 | { |
403 | - if (empty($_REQUEST[$module . $widget_id . "emailAddress" . $widgetCount])) { |
|
403 | + if (empty($_REQUEST[$module.$widget_id."emailAddress".$widgetCount])) { |
|
404 | 404 | $widgetCount++; |
405 | 405 | continue; |
406 | 406 | } |
407 | 407 | |
408 | 408 | $hasEmailValue = true; |
409 | 409 | |
410 | - $eId = $module . $widget_id; |
|
411 | - if(isset($_REQUEST[$eId . 'emailAddressPrimaryFlag'])) { |
|
412 | - $primaryValue = $_REQUEST[$eId . 'emailAddressPrimaryFlag']; |
|
413 | - } else if(isset($_REQUEST[$module . 'emailAddressPrimaryFlag'])) { |
|
414 | - $primaryValue = $_REQUEST[$module . 'emailAddressPrimaryFlag']; |
|
410 | + $eId = $module.$widget_id; |
|
411 | + if (isset($_REQUEST[$eId.'emailAddressPrimaryFlag'])) { |
|
412 | + $primaryValue = $_REQUEST[$eId.'emailAddressPrimaryFlag']; |
|
413 | + } else if (isset($_REQUEST[$module.'emailAddressPrimaryFlag'])) { |
|
414 | + $primaryValue = $_REQUEST[$module.'emailAddressPrimaryFlag']; |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | $optOutValues = array(); |
418 | - if(isset($_REQUEST[$eId .'emailAddressOptOutFlag'])) { |
|
419 | - $optOutValues = $_REQUEST[$eId .'emailAddressOptOutFlag']; |
|
420 | - } else if(isset($_REQUEST[$module . 'emailAddressOptOutFlag'])) { |
|
421 | - $optOutValues = $_REQUEST[$module . 'emailAddressOptOutFlag']; |
|
418 | + if (isset($_REQUEST[$eId.'emailAddressOptOutFlag'])) { |
|
419 | + $optOutValues = $_REQUEST[$eId.'emailAddressOptOutFlag']; |
|
420 | + } else if (isset($_REQUEST[$module.'emailAddressOptOutFlag'])) { |
|
421 | + $optOutValues = $_REQUEST[$module.'emailAddressOptOutFlag']; |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | $invalidValues = array(); |
425 | - if(isset($_REQUEST[$eId .'emailAddressInvalidFlag'])) { |
|
426 | - $invalidValues = $_REQUEST[$eId .'emailAddressInvalidFlag']; |
|
427 | - } else if(isset($_REQUEST[$module . 'emailAddressInvalidFlag'])) { |
|
428 | - $invalidValues = $_REQUEST[$module . 'emailAddressInvalidFlag']; |
|
425 | + if (isset($_REQUEST[$eId.'emailAddressInvalidFlag'])) { |
|
426 | + $invalidValues = $_REQUEST[$eId.'emailAddressInvalidFlag']; |
|
427 | + } else if (isset($_REQUEST[$module.'emailAddressInvalidFlag'])) { |
|
428 | + $invalidValues = $_REQUEST[$module.'emailAddressInvalidFlag']; |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | $deleteValues = array(); |
432 | - if(isset($_REQUEST[$eId .'emailAddressDeleteFlag'])) { |
|
433 | - $deleteValues = $_REQUEST[$eId .'emailAddressDeleteFlag']; |
|
434 | - } else if(isset($_REQUEST[$module . 'emailAddressDeleteFlag'])) { |
|
435 | - $deleteValues = $_REQUEST[$module . 'emailAddressDeleteFlag']; |
|
432 | + if (isset($_REQUEST[$eId.'emailAddressDeleteFlag'])) { |
|
433 | + $deleteValues = $_REQUEST[$eId.'emailAddressDeleteFlag']; |
|
434 | + } else if (isset($_REQUEST[$module.'emailAddressDeleteFlag'])) { |
|
435 | + $deleteValues = $_REQUEST[$module.'emailAddressDeleteFlag']; |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | // prep from form save |
@@ -440,36 +440,36 @@ discard block |
||
440 | 440 | $replyToField = ''; |
441 | 441 | $invalidField = ''; |
442 | 442 | $optOutField = ''; |
443 | - if($fromRequest && empty($primary) && isset($primaryValue)) { |
|
443 | + if ($fromRequest && empty($primary) && isset($primaryValue)) { |
|
444 | 444 | $primaryField = $primaryValue; |
445 | 445 | } |
446 | 446 | |
447 | - if($fromRequest && empty($replyTo)) { |
|
448 | - if(isset($_REQUEST[$eId .'emailAddressReplyToFlag'])) { |
|
449 | - $replyToField = $_REQUEST[$eId .'emailAddressReplyToFlag']; |
|
450 | - } else if(isset($_REQUEST[$module . 'emailAddressReplyToFlag'])) { |
|
451 | - $replyToField = $_REQUEST[$module . 'emailAddressReplyToFlag']; |
|
447 | + if ($fromRequest && empty($replyTo)) { |
|
448 | + if (isset($_REQUEST[$eId.'emailAddressReplyToFlag'])) { |
|
449 | + $replyToField = $_REQUEST[$eId.'emailAddressReplyToFlag']; |
|
450 | + } else if (isset($_REQUEST[$module.'emailAddressReplyToFlag'])) { |
|
451 | + $replyToField = $_REQUEST[$module.'emailAddressReplyToFlag']; |
|
452 | 452 | } |
453 | 453 | } |
454 | - if($fromRequest && empty($new_addrs)) { |
|
455 | - foreach($_REQUEST as $k => $v) { |
|
456 | - if(preg_match('/'.$eId.'emailAddress[0-9]+$/i', $k) && !empty($v)) { |
|
454 | + if ($fromRequest && empty($new_addrs)) { |
|
455 | + foreach ($_REQUEST as $k => $v) { |
|
456 | + if (preg_match('/'.$eId.'emailAddress[0-9]+$/i', $k) && !empty($v)) { |
|
457 | 457 | $new_addrs[$k] = $v; |
458 | 458 | } |
459 | 459 | } |
460 | 460 | } |
461 | - if($fromRequest && empty($email_ids)) { |
|
462 | - foreach($_REQUEST as $k => $v) { |
|
463 | - if(preg_match('/'.$eId.'emailAddressId[0-9]+$/i', $k) && !empty($v)) { |
|
461 | + if ($fromRequest && empty($email_ids)) { |
|
462 | + foreach ($_REQUEST as $k => $v) { |
|
463 | + if (preg_match('/'.$eId.'emailAddressId[0-9]+$/i', $k) && !empty($v)) { |
|
464 | 464 | $key = str_replace('emailAddressId', 'emailAddress', $k); |
465 | 465 | $email_ids[$key] = $v; |
466 | 466 | } |
467 | 467 | } |
468 | 468 | } |
469 | 469 | |
470 | - if($fromRequest && empty($new_addrs)) { |
|
471 | - foreach($_REQUEST as $k => $v) { |
|
472 | - if(preg_match('/'.$eId.'emailAddressVerifiedValue[0-9]+$/i', $k) && !empty($v)) { |
|
470 | + if ($fromRequest && empty($new_addrs)) { |
|
471 | + foreach ($_REQUEST as $k => $v) { |
|
472 | + if (preg_match('/'.$eId.'emailAddressVerifiedValue[0-9]+$/i', $k) && !empty($v)) { |
|
473 | 473 | $validateFlag = str_replace("Value", "Flag", $k); |
474 | 474 | if (isset($_REQUEST[$validateFlag]) && $_REQUEST[$validateFlag] == "true") |
475 | 475 | $new_addrs[$k] = $v; |
@@ -478,21 +478,21 @@ discard block |
||
478 | 478 | } |
479 | 479 | |
480 | 480 | //empty the addresses array if the post happened from email address widget. |
481 | - if($post_from_email_address_widget) { |
|
482 | - $this->addresses=array(); //this gets populated during retrieve of the contact bean. |
|
481 | + if ($post_from_email_address_widget) { |
|
482 | + $this->addresses = array(); //this gets populated during retrieve of the contact bean. |
|
483 | 483 | } else { |
484 | 484 | $optOutValues = array(); |
485 | 485 | $invalidValues = array(); |
486 | - foreach($new_addrs as $k=>$email) { |
|
486 | + foreach ($new_addrs as $k=>$email) { |
|
487 | 487 | preg_match('/emailAddress([0-9])+$/', $k, $matches); |
488 | 488 | $count = $matches[1]; |
489 | - $result = $this->db->query("SELECT opt_out, invalid_email from email_addresses where email_address_caps = '" . $this->db->quote(strtoupper($email)) . "'"); |
|
490 | - if(!empty($result)) { |
|
491 | - $row=$this->db->fetchByAssoc($result); |
|
492 | - if(!empty($row['opt_out'])) { |
|
489 | + $result = $this->db->query("SELECT opt_out, invalid_email from email_addresses where email_address_caps = '".$this->db->quote(strtoupper($email))."'"); |
|
490 | + if (!empty($result)) { |
|
491 | + $row = $this->db->fetchByAssoc($result); |
|
492 | + if (!empty($row['opt_out'])) { |
|
493 | 493 | $optOutValues[$k] = "emailAddress$count"; |
494 | 494 | } |
495 | - if(!empty($row['invalid_email'])) { |
|
495 | + if (!empty($row['invalid_email'])) { |
|
496 | 496 | $invalidValues[$k] = "emailAddress$count"; |
497 | 497 | } |
498 | 498 | } |
@@ -500,11 +500,11 @@ discard block |
||
500 | 500 | } |
501 | 501 | // Re-populate the addresses class variable if we have new address(es). |
502 | 502 | if (!empty($new_addrs)) { |
503 | - foreach($new_addrs as $k => $reqVar) { |
|
503 | + foreach ($new_addrs as $k => $reqVar) { |
|
504 | 504 | //$key = preg_match("/^$eId/s", $k) ? substr($k, strlen($eId)) : $k; |
505 | 505 | $reqVar = trim($reqVar); |
506 | - if(strpos($k, 'emailAddress') !== false) { |
|
507 | - if(!empty($reqVar) && !in_array($k, $deleteValues)) { |
|
506 | + if (strpos($k, 'emailAddress') !== false) { |
|
507 | + if (!empty($reqVar) && !in_array($k, $deleteValues)) { |
|
508 | 508 | $email_id = (array_key_exists($k, $email_ids)) ? $email_ids[$k] : null; |
509 | 509 | $primary = ($k == $primaryValue) ? true : false; |
510 | 510 | $replyTo = ($k == $replyToField) ? true : false; |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | } |
522 | 522 | |
523 | 523 | //If no widgets, set addresses array to empty |
524 | - if($post_from_email_address_widget && !$hasEmailValue) { |
|
524 | + if ($post_from_email_address_widget && !$hasEmailValue) { |
|
525 | 525 | $this->addresses = array(); |
526 | 526 | } |
527 | 527 | } |
@@ -532,9 +532,9 @@ discard block |
||
532 | 532 | * @param bool $primary Default false |
533 | 533 | * @param bool $replyTo Default false |
534 | 534 | */ |
535 | - function addAddress($addr, $primary=false, $replyTo=false, $invalid=false, $optOut=false, $email_id = null) { |
|
535 | + function addAddress($addr, $primary = false, $replyTo = false, $invalid = false, $optOut = false, $email_id = null) { |
|
536 | 536 | $addr = html_entity_decode($addr, ENT_QUOTES); |
537 | - if(preg_match($this->regex, $addr)) { |
|
537 | + if (preg_match($this->regex, $addr)) { |
|
538 | 538 | $primaryFlag = ($primary) ? '1' : '0'; |
539 | 539 | $replyToFlag = ($replyTo) ? '1' : '0'; |
540 | 540 | $invalidFlag = ($invalid) ? '1' : '0'; |
@@ -570,17 +570,17 @@ discard block |
||
570 | 570 | * Updates invalid_email and opt_out flags for each address |
571 | 571 | */ |
572 | 572 | function updateFlags() { |
573 | - if(!empty($this->addresses)) { |
|
574 | - foreach($this->addresses as $addressMeta) { |
|
575 | - if(isset($addressMeta['email_address']) && !empty($addressMeta['email_address'])) { |
|
573 | + if (!empty($this->addresses)) { |
|
574 | + foreach ($this->addresses as $addressMeta) { |
|
575 | + if (isset($addressMeta['email_address']) && !empty($addressMeta['email_address'])) { |
|
576 | 576 | $address = $this->db->quote($this->_cleanAddress($addressMeta['email_address'])); |
577 | 577 | |
578 | 578 | $q = "SELECT * FROM email_addresses WHERE email_address = '{$address}'"; |
579 | 579 | $r = $this->db->query($q); |
580 | 580 | $a = $this->db->fetchByAssoc($r); |
581 | 581 | |
582 | - if(!empty($a)) { |
|
583 | - if(isset($a['invalid_email']) && isset($addressMeta['invalid_email']) && isset($addressMeta['opt_out']) && $a['invalid_email'] != $addressMeta['invalid_email'] || $a['opt_out'] != $addressMeta['opt_out']) { |
|
582 | + if (!empty($a)) { |
|
583 | + if (isset($a['invalid_email']) && isset($addressMeta['invalid_email']) && isset($addressMeta['opt_out']) && $a['invalid_email'] != $addressMeta['invalid_email'] || $a['opt_out'] != $addressMeta['opt_out']) { |
|
584 | 584 | $qUpdate = "UPDATE email_addresses SET invalid_email = ".intval($addressMeta['invalid_email']).", opt_out = ".intval($addressMeta['opt_out']).", date_modified = '".TimeDate::getInstance()->nowDb()."' WHERE id = '".$this->db->quote($a['id'])."'"; |
585 | 585 | $rUpdate = $this->db->query($qUpdate); |
586 | 586 | } |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | public function splitEmailAddress($addr) |
594 | 594 | { |
595 | 595 | $email = $this->_cleanAddress($addr); |
596 | - if(!preg_match($this->regex, $email)) { |
|
596 | + if (!preg_match($this->regex, $email)) { |
|
597 | 597 | $email = ''; // remove bad email addr |
598 | 598 | } |
599 | 599 | $name = trim(str_replace(array($email, '<', '>', '"', "'"), '', $addr)); |
@@ -609,8 +609,8 @@ discard block |
||
609 | 609 | function _cleanAddress($addr) { |
610 | 610 | $addr = trim(from_html($addr)); |
611 | 611 | |
612 | - if(strpos($addr, "<") !== false && strpos($addr, ">") !== false) { |
|
613 | - $address = trim(substr($addr, strrpos($addr, "<") +1, strrpos($addr, ">") - strrpos($addr, "<") -1)); |
|
612 | + if (strpos($addr, "<") !== false && strpos($addr, ">") !== false) { |
|
613 | + $address = trim(substr($addr, strrpos($addr, "<") + 1, strrpos($addr, ">") - strrpos($addr, "<") - 1)); |
|
614 | 614 | } else { |
615 | 615 | $address = trim($addr); |
616 | 616 | } |
@@ -631,11 +631,11 @@ discard block |
||
631 | 631 | $r = $this->db->query($q); |
632 | 632 | $a = $this->db->fetchByAssoc($r); |
633 | 633 | |
634 | - if(!empty($a) && !empty($a['id'])) { |
|
634 | + if (!empty($a) && !empty($a['id'])) { |
|
635 | 635 | return $a['id']; |
636 | 636 | } else { |
637 | 637 | $guid = ''; |
638 | - if(!empty($address)){ |
|
638 | + if (!empty($address)) { |
|
639 | 639 | $guid = create_guid(); |
640 | 640 | $now = TimeDate::getInstance()->nowDb(); |
641 | 641 | $qa = "INSERT INTO email_addresses (id, email_address, email_address_caps, date_created, date_modified, deleted) |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | * to propagate to the new SugarEmailAddress - see bug 39188 |
658 | 658 | * @return String GUID of Email Address or '' if cleaned address was empty. |
659 | 659 | */ |
660 | - public function AddUpdateEmailAddress($addr,$invalid=0,$opt_out=0,$id=null) |
|
660 | + public function AddUpdateEmailAddress($addr, $invalid = 0, $opt_out = 0, $id = null) |
|
661 | 661 | { |
662 | 662 | // sanity checks to avoid SQL injection. |
663 | 663 | $invalid = intval($invalid); |
@@ -707,12 +707,12 @@ discard block |
||
707 | 707 | if ($duplicate_email['invalid_email'] != $new_invalid || |
708 | 708 | $duplicate_email['opt_out'] != $new_opt_out || |
709 | 709 | (trim($duplicate_email['email_address']) != $address)) { |
710 | - $upd_q = 'UPDATE ' . $this->table_name . ' ' . |
|
711 | - 'SET email_address=\'' . $address . '\', ' . |
|
712 | - 'invalid_email=' . $new_invalid . ', ' . |
|
713 | - 'opt_out=' . $new_opt_out . ', ' . |
|
714 | - 'date_modified=' . $this->db->now() . ' ' . |
|
715 | - 'WHERE id=\'' . $this->db->quote($duplicate_email['id']) . '\''; |
|
710 | + $upd_q = 'UPDATE '.$this->table_name.' '. |
|
711 | + 'SET email_address=\''.$address.'\', '. |
|
712 | + 'invalid_email='.$new_invalid.', '. |
|
713 | + 'opt_out='.$new_opt_out.', '. |
|
714 | + 'date_modified='.$this->db->now().' '. |
|
715 | + 'WHERE id=\''.$this->db->quote($duplicate_email['id']).'\''; |
|
716 | 716 | $upd_r = $this->db->query($upd_q); |
717 | 717 | } |
718 | 718 | return $duplicate_email['id']; |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | else { |
721 | 721 | // no case-insensitive address match - it's new, or undeleted. |
722 | 722 | $guid = ''; |
723 | - if(!empty($address)){ |
|
723 | + if (!empty($address)) { |
|
724 | 724 | $guid = create_guid(); |
725 | 725 | $now = TimeDate::getInstance()->nowDb(); |
726 | 726 | $qa = "INSERT INTO email_addresses (id, email_address, email_address_caps, date_created, date_modified, deleted, invalid_email, opt_out) |
@@ -736,12 +736,12 @@ discard block |
||
736 | 736 | * @param object $focus Object in focus |
737 | 737 | * @return string email |
738 | 738 | */ |
739 | - function getPrimaryAddress($focus,$parent_id=null,$parent_type=null) { |
|
739 | + function getPrimaryAddress($focus, $parent_id = null, $parent_type = null) { |
|
740 | 740 | |
741 | - $parent_type=empty($parent_type) ? $focus->module_dir : $parent_type; |
|
741 | + $parent_type = empty($parent_type) ? $focus->module_dir : $parent_type; |
|
742 | 742 | // Bug63174: Email address is not shown in the list view for employees |
743 | 743 | $parent_type = $this->getCorrectedModule($parent_type); |
744 | - $parent_id=empty($parent_id) ? $focus->id : $parent_id; |
|
744 | + $parent_id = empty($parent_id) ? $focus->id : $parent_id; |
|
745 | 745 | |
746 | 746 | $q = "SELECT ea.email_address FROM email_addresses ea |
747 | 747 | LEFT JOIN email_addr_bean_rel ear ON ea.id = ear.email_address_id |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | $r = $this->db->limitQuery($q, 0, 1); |
754 | 754 | $a = $this->db->fetchByAssoc($r); |
755 | 755 | |
756 | - if(isset($a['email_address'])) { |
|
756 | + if (isset($a['email_address'])) { |
|
757 | 757 | return $a['email_address']; |
758 | 758 | } |
759 | 759 | return ''; |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | $r = $this->db->query($q); |
795 | 795 | $a = $this->db->fetchByAssoc($r); |
796 | 796 | |
797 | - if(isset($a['email_address'])) { |
|
797 | + if (isset($a['email_address'])) { |
|
798 | 798 | return $a['email_address']; |
799 | 799 | } |
800 | 800 | return ''; |
@@ -819,7 +819,7 @@ discard block |
||
819 | 819 | ORDER BY ear.reply_to_address, ear.primary_address DESC"; |
820 | 820 | $r = $this->db->query($q); |
821 | 821 | |
822 | - while($a = $this->db->fetchByAssoc($r, FALSE)) { |
|
822 | + while ($a = $this->db->fetchByAssoc($r, FALSE)) { |
|
823 | 823 | $return[] = $a; |
824 | 824 | } |
825 | 825 | |
@@ -833,9 +833,9 @@ discard block |
||
833 | 833 | * @param bool asMetadata Default false |
834 | 834 | * @return string HTML/JS for widget |
835 | 835 | */ |
836 | - function getEmailAddressWidgetEditView($id, $module, $asMetadata=false, $tpl='',$tabindex='0') |
|
836 | + function getEmailAddressWidgetEditView($id, $module, $asMetadata = false, $tpl = '', $tabindex = '0') |
|
837 | 837 | { |
838 | - if ( !($this->smarty instanceOf Sugar_Smarty ) ) |
|
838 | + if (!($this->smarty instanceOf Sugar_Smarty)) |
|
839 | 839 | $this->smarty = new Sugar_Smarty(); |
840 | 840 | |
841 | 841 | global $app_strings, $dictionary, $beanList; |
@@ -846,33 +846,33 @@ discard block |
||
846 | 846 | $passedModule = $module; |
847 | 847 | $module = $this->getCorrectedModule($module); |
848 | 848 | $saveModule = $module; |
849 | - if(isset($_POST['is_converted']) && $_POST['is_converted']==true){ |
|
850 | - $id=$_POST['return_id']; |
|
851 | - $module=$_POST['return_module']; |
|
849 | + if (isset($_POST['is_converted']) && $_POST['is_converted'] == true) { |
|
850 | + $id = $_POST['return_id']; |
|
851 | + $module = $_POST['return_module']; |
|
852 | 852 | } |
853 | 853 | $prefillDataArr = array(); |
854 | - if(!empty($id)) { |
|
854 | + if (!empty($id)) { |
|
855 | 855 | $prefillDataArr = $this->getAddressesByGUID($id, $module); |
856 | 856 | //When coming from convert leads, sometimes module is Contacts while the id is for a lead. |
857 | 857 | if (empty($prefillDataArr) && $module == "Contacts") |
858 | 858 | $prefillDataArr = $this->getAddressesByGUID($id, "Leads"); |
859 | - } else if(isset($_REQUEST['full_form']) && !empty($_REQUEST['emailAddressWidget'])){ |
|
860 | - $widget_id = isset($_REQUEST[$module . '_email_widget_id']) ? $_REQUEST[$module . '_email_widget_id'] : '0'; |
|
859 | + } else if (isset($_REQUEST['full_form']) && !empty($_REQUEST['emailAddressWidget'])) { |
|
860 | + $widget_id = isset($_REQUEST[$module.'_email_widget_id']) ? $_REQUEST[$module.'_email_widget_id'] : '0'; |
|
861 | 861 | $count = 0; |
862 | - $key = $module . $widget_id . 'emailAddress'.$count; |
|
863 | - while(isset($_REQUEST[$key])) { |
|
862 | + $key = $module.$widget_id.'emailAddress'.$count; |
|
863 | + while (isset($_REQUEST[$key])) { |
|
864 | 864 | $email = $_REQUEST[$key]; |
865 | - $prefillDataArr[] = array('email_address'=>$email, |
|
865 | + $prefillDataArr[] = array('email_address'=>$email, |
|
866 | 866 | 'primary_address'=>isset($_REQUEST['emailAddressPrimaryFlag']) && $_REQUEST['emailAddressPrimaryFlag'] == $key, |
867 | 867 | 'invalid_email'=>isset($_REQUEST['emailAddressInvalidFlag']) && in_array($key, $_REQUEST['emailAddressInvalidFlag']), |
868 | 868 | 'opt_out'=>isset($_REQUEST['emailAddressOptOutFlag']) && in_array($key, $_REQUEST['emailAddressOptOutFlag']), |
869 | 869 | 'reply_to_address'=>false |
870 | 870 | ); |
871 | - $key = $module . $widget_id . 'emailAddress' . ++$count; |
|
871 | + $key = $module.$widget_id.'emailAddress'.++$count; |
|
872 | 872 | } //while |
873 | 873 | } |
874 | 874 | |
875 | - if(!empty($prefillDataArr)) { |
|
875 | + if (!empty($prefillDataArr)) { |
|
876 | 876 | $json = new JSON(JSON_LOOSE_TYPE); |
877 | 877 | $prefillData = $json->encode($prefillDataArr); |
878 | 878 | $prefill = !empty($prefillDataArr) ? 'true' : 'false'; |
@@ -895,16 +895,16 @@ discard block |
||
895 | 895 | $form = $this->view; |
896 | 896 | |
897 | 897 | //determine if this should be a quickcreate form, or a quick create form under subpanels |
898 | - if ($this->view == "QuickCreate"){ |
|
899 | - $form = 'form_DC'.$this->view .'_'.$module; |
|
900 | - if(isset($_REQUEST['action']) && $_REQUEST['action']=='SubpanelCreates' || $_REQUEST['action']=='SubpanelEdits'){ |
|
901 | - $form = 'form_Subpanel'.$this->view .'_'.$module; |
|
898 | + if ($this->view == "QuickCreate") { |
|
899 | + $form = 'form_DC'.$this->view.'_'.$module; |
|
900 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'SubpanelCreates' || $_REQUEST['action'] == 'SubpanelEdits') { |
|
901 | + $form = 'form_Subpanel'.$this->view.'_'.$module; |
|
902 | 902 | } |
903 | 903 | } |
904 | 904 | |
905 | 905 | $this->smarty->assign('emailView', $form); |
906 | 906 | |
907 | - if($module == 'Users') { |
|
907 | + if ($module == 'Users') { |
|
908 | 908 | $this->smarty->assign('useReplyTo', true); |
909 | 909 | } else { |
910 | 910 | $this->smarty->assign('useOptOut', true); |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | $newEmail = $this->smarty->fetch($template); |
916 | 916 | |
917 | 917 | |
918 | - if($asMetadata) { |
|
918 | + if ($asMetadata) { |
|
919 | 919 | // used by Email 2.0 |
920 | 920 | $ret = array(); |
921 | 921 | $ret['prefillData'] = $prefillDataArr; |
@@ -933,18 +933,18 @@ discard block |
||
933 | 933 | * @param object $focus Bean in focus |
934 | 934 | * @return string HTML/JS for widget |
935 | 935 | */ |
936 | - function getEmailAddressWidgetDetailView($focus, $tpl='') |
|
936 | + function getEmailAddressWidgetDetailView($focus, $tpl = '') |
|
937 | 937 | { |
938 | - if ( !($this->smarty instanceOf Sugar_Smarty ) ) |
|
938 | + if (!($this->smarty instanceOf Sugar_Smarty)) |
|
939 | 939 | $this->smarty = new Sugar_Smarty(); |
940 | 940 | |
941 | 941 | global $app_strings; |
942 | 942 | global $current_user; |
943 | 943 | $assign = array(); |
944 | - if(empty($focus->id))return ''; |
|
944 | + if (empty($focus->id))return ''; |
|
945 | 945 | $prefillData = $this->getAddressesByGUID($focus->id, $focus->module_dir); |
946 | 946 | |
947 | - foreach($prefillData as $addressItem) { |
|
947 | + foreach ($prefillData as $addressItem) { |
|
948 | 948 | $key = ($addressItem['primary_address'] == 1) ? 'primary' : ""; |
949 | 949 | $key = ($addressItem['reply_to_address'] == 1) ? 'reply_to' : $key; |
950 | 950 | $key = ($addressItem['opt_out'] == 1) ? 'opt_out' : $key; |
@@ -970,7 +970,7 @@ discard block |
||
970 | 970 | */ |
971 | 971 | function getEmailAddressWidgetDuplicatesView($focus) |
972 | 972 | { |
973 | - if ( !($this->smarty instanceOf Sugar_Smarty ) ) |
|
973 | + if (!($this->smarty instanceOf Sugar_Smarty)) |
|
974 | 974 | $this->smarty = new Sugar_Smarty(); |
975 | 975 | |
976 | 976 | $count = 0; |
@@ -980,49 +980,49 @@ discard block |
||
980 | 980 | $invalid = array(); |
981 | 981 | $mod = isset($focus) ? $focus->module_dir : ""; |
982 | 982 | |
983 | - $widget_id = $_POST[$mod .'_email_widget_id']; |
|
984 | - $this->smarty->assign('email_widget_id',$widget_id); |
|
985 | - $this->smarty->assign('emailAddressWidget',$_POST['emailAddressWidget']); |
|
983 | + $widget_id = $_POST[$mod.'_email_widget_id']; |
|
984 | + $this->smarty->assign('email_widget_id', $widget_id); |
|
985 | + $this->smarty->assign('emailAddressWidget', $_POST['emailAddressWidget']); |
|
986 | 986 | |
987 | - if(isset($_POST[$mod . $widget_id . 'emailAddressPrimaryFlag'])) { |
|
988 | - $primary = $_POST[$mod . $widget_id . 'emailAddressPrimaryFlag']; |
|
987 | + if (isset($_POST[$mod.$widget_id.'emailAddressPrimaryFlag'])) { |
|
988 | + $primary = $_POST[$mod.$widget_id.'emailAddressPrimaryFlag']; |
|
989 | 989 | } |
990 | 990 | |
991 | - while(isset($_POST[$mod . $widget_id . "emailAddress" . $count])) { |
|
992 | - $emails[] = $_POST[$mod . $widget_id . 'emailAddress' . $count]; |
|
991 | + while (isset($_POST[$mod.$widget_id."emailAddress".$count])) { |
|
992 | + $emails[] = $_POST[$mod.$widget_id.'emailAddress'.$count]; |
|
993 | 993 | $count++; |
994 | 994 | } |
995 | 995 | |
996 | - if($count == 0) { |
|
996 | + if ($count == 0) { |
|
997 | 997 | return ""; |
998 | 998 | } |
999 | 999 | |
1000 | - if(isset($_POST[$mod . $widget_id . 'emailAddressOptOutFlag'])) { |
|
1001 | - foreach($_POST[$mod . $widget_id . 'emailAddressOptOutFlag'] as $v) { |
|
1000 | + if (isset($_POST[$mod.$widget_id.'emailAddressOptOutFlag'])) { |
|
1001 | + foreach ($_POST[$mod.$widget_id.'emailAddressOptOutFlag'] as $v) { |
|
1002 | 1002 | $optOut[] = $v; |
1003 | 1003 | } |
1004 | 1004 | } |
1005 | 1005 | |
1006 | - if(isset($_POST[$mod . $widget_id . 'emailAddressInvalidFlag'])) { |
|
1007 | - foreach($_POST[$mod . $widget_id . 'emailAddressInvalidFlag'] as $v) { |
|
1006 | + if (isset($_POST[$mod.$widget_id.'emailAddressInvalidFlag'])) { |
|
1007 | + foreach ($_POST[$mod.$widget_id.'emailAddressInvalidFlag'] as $v) { |
|
1008 | 1008 | $invalid[] = $v; |
1009 | 1009 | } |
1010 | 1010 | } |
1011 | 1011 | |
1012 | - if(isset($_POST[$mod . $widget_id . 'emailAddressReplyToFlag'])) { |
|
1013 | - foreach($_POST[$mod . $widget_id . 'emailAddressReplyToFlag'] as $v) { |
|
1012 | + if (isset($_POST[$mod.$widget_id.'emailAddressReplyToFlag'])) { |
|
1013 | + foreach ($_POST[$mod.$widget_id.'emailAddressReplyToFlag'] as $v) { |
|
1014 | 1014 | $replyTo[] = $v; |
1015 | 1015 | } |
1016 | 1016 | } |
1017 | 1017 | |
1018 | - if(isset($_POST[$mod . $widget_id . 'emailAddressDeleteFlag'])) { |
|
1019 | - foreach($_POST[$mod . $widget_id . 'emailAddressDeleteFlag'] as $v) { |
|
1018 | + if (isset($_POST[$mod.$widget_id.'emailAddressDeleteFlag'])) { |
|
1019 | + foreach ($_POST[$mod.$widget_id.'emailAddressDeleteFlag'] as $v) { |
|
1020 | 1020 | $delete[] = $v; |
1021 | 1021 | } |
1022 | 1022 | } |
1023 | 1023 | |
1024 | - while(isset($_POST[$mod . $widget_id . "emailAddressVerifiedValue" . $count])) { |
|
1025 | - $verified[] = $_POST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count]; |
|
1024 | + while (isset($_POST[$mod.$widget_id."emailAddressVerifiedValue".$count])) { |
|
1025 | + $verified[] = $_POST[$mod.$widget_id.'emailAddressVerifiedValue'.$count]; |
|
1026 | 1026 | $count++; |
1027 | 1027 | } |
1028 | 1028 | |
@@ -1047,33 +1047,33 @@ discard block |
||
1047 | 1047 | $count = 0; |
1048 | 1048 | $mod = isset($focus) ? $focus->module_dir : ""; |
1049 | 1049 | |
1050 | - $widget_id = $_POST[$mod .'_email_widget_id']; |
|
1051 | - $get .= '&' . $mod . '_email_widget_id='. $widget_id; |
|
1050 | + $widget_id = $_POST[$mod.'_email_widget_id']; |
|
1051 | + $get .= '&'.$mod.'_email_widget_id='.$widget_id; |
|
1052 | 1052 | $get .= '&emailAddressWidget='.$_POST['emailAddressWidget']; |
1053 | 1053 | |
1054 | - while(isset($_REQUEST[$mod . $widget_id . 'emailAddress' . $count])) { |
|
1055 | - $get .= "&" . $mod . $widget_id . "emailAddress" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddress' . $count]); |
|
1054 | + while (isset($_REQUEST[$mod.$widget_id.'emailAddress'.$count])) { |
|
1055 | + $get .= "&".$mod.$widget_id."emailAddress".$count."=".urlencode($_REQUEST[$mod.$widget_id.'emailAddress'.$count]); |
|
1056 | 1056 | $count++; |
1057 | 1057 | } //while |
1058 | 1058 | |
1059 | - while(isset($_REQUEST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count])) { |
|
1060 | - $get .= "&" . $mod . $widget_id . "emailAddressVerifiedValue" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count]); |
|
1059 | + while (isset($_REQUEST[$mod.$widget_id.'emailAddressVerifiedValue'.$count])) { |
|
1060 | + $get .= "&".$mod.$widget_id."emailAddressVerifiedValue".$count."=".urlencode($_REQUEST[$mod.$widget_id.'emailAddressVerifiedValue'.$count]); |
|
1061 | 1061 | $count++; |
1062 | 1062 | } //while |
1063 | 1063 | |
1064 | 1064 | $options = array('emailAddressPrimaryFlag', 'emailAddressOptOutFlag', 'emailAddressInvalidFlag', 'emailAddressDeleteFlag', 'emailAddressReplyToFlag'); |
1065 | 1065 | |
1066 | - foreach($options as $option) { |
|
1066 | + foreach ($options as $option) { |
|
1067 | 1067 | $count = 0; |
1068 | 1068 | $optionIdentifier = $mod.$widget_id.$option; |
1069 | - if(isset($_REQUEST[$optionIdentifier])) { |
|
1070 | - if(is_array($_REQUEST[$optionIdentifier])) { |
|
1071 | - foreach($_REQUEST[$optionIdentifier] as $optOut) { |
|
1072 | - $get .= "&" . $optionIdentifier . "[" . $count . "]=" . $optOut; |
|
1069 | + if (isset($_REQUEST[$optionIdentifier])) { |
|
1070 | + if (is_array($_REQUEST[$optionIdentifier])) { |
|
1071 | + foreach ($_REQUEST[$optionIdentifier] as $optOut) { |
|
1072 | + $get .= "&".$optionIdentifier."[".$count."]=".$optOut; |
|
1073 | 1073 | $count++; |
1074 | 1074 | } //foreach |
1075 | 1075 | } else { |
1076 | - $get .= "&" . $optionIdentifier . "=" . $_REQUEST[$optionIdentifier]; |
|
1076 | + $get .= "&".$optionIdentifier."=".$_REQUEST[$optionIdentifier]; |
|
1077 | 1077 | } |
1078 | 1078 | } //if |
1079 | 1079 | } //foreach |
@@ -1091,7 +1091,7 @@ discard block |
||
1091 | 1091 | * @return string The value for the bean_module column in the email_addr_bean_rel table |
1092 | 1092 | */ |
1093 | 1093 | function getCorrectedModule(&$module) { |
1094 | - return ($module == "Employees")? "Users" : $module; |
|
1094 | + return ($module == "Employees") ? "Users" : $module; |
|
1095 | 1095 | } |
1096 | 1096 | |
1097 | 1097 | public function stash($parentBeanId, $moduleName) |
@@ -1101,7 +1101,7 @@ discard block |
||
1101 | 1101 | $ids = array(); |
1102 | 1102 | while ($row = $this->db->fetchByAssoc($result, false)) |
1103 | 1103 | { |
1104 | - $ids[] =$this->db->quote($row['email_address_id']); // avoid 2nd order SQL Injection |
|
1104 | + $ids[] = $this->db->quote($row['email_address_id']); // avoid 2nd order SQL Injection |
|
1105 | 1105 | } |
1106 | 1106 | if (!empty($ids)) |
1107 | 1107 | { |
@@ -1125,15 +1125,15 @@ discard block |
||
1125 | 1125 | * @param string $view DetailView or EditView |
1126 | 1126 | * @return string |
1127 | 1127 | */ |
1128 | -function getEmailAddressWidget($focus, $field, $value, $view, $tabindex='0') { |
|
1128 | +function getEmailAddressWidget($focus, $field, $value, $view, $tabindex = '0') { |
|
1129 | 1129 | $sea = new SugarEmailAddress(); |
1130 | 1130 | $sea->setView($view); |
1131 | 1131 | |
1132 | - if($view == 'EditView' || $view == 'QuickCreate' || $view == 'ConvertLead') { |
|
1132 | + if ($view == 'EditView' || $view == 'QuickCreate' || $view == 'ConvertLead') { |
|
1133 | 1133 | $module = $focus->module_dir; |
1134 | 1134 | if ($view == 'ConvertLead' && $module == "Contacts") $module = "Leads"; |
1135 | 1135 | |
1136 | - return $sea->getEmailAddressWidgetEditView($focus->id, $module, false,'',$tabindex); |
|
1136 | + return $sea->getEmailAddressWidgetEditView($focus->id, $module, false, '', $tabindex); |
|
1137 | 1137 | } |
1138 | 1138 | |
1139 | 1139 | return $sea->getEmailAddressWidgetDetailView($focus); |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | * @param string $consumer_secret |
56 | 56 | * @param array $params OAuth options |
57 | 57 | */ |
58 | - public function __construct($consumer_key , $consumer_secret, $params = null) |
|
58 | + public function __construct($consumer_key, $consumer_secret, $params = null) |
|
59 | 59 | { |
60 | 60 | $this->_oauth_config = array( |
61 | 61 | 'consumerKey' => $consumer_key, |
62 | 62 | 'consumerSecret' => $consumer_secret, |
63 | 63 | ); |
64 | - if(!empty($params)) { |
|
64 | + if (!empty($params)) { |
|
65 | 65 | $this->_oauth_config = array_merge($this->_oauth_config, $params); |
66 | 66 | } |
67 | 67 | parent::__construct($this->_oauth_config); |
@@ -120,20 +120,20 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function getRequestTokenByUrl($url, $callback = null, $params = array()) |
122 | 122 | { |
123 | - if(!empty($callback)) { |
|
123 | + if (!empty($callback)) { |
|
124 | 124 | $this->setCallbackUrl($callback); |
125 | 125 | } |
126 | 126 | list($clean_url, $query) = explode('?', $url); |
127 | - if($query) { |
|
127 | + if ($query) { |
|
128 | 128 | $url = $clean_url; |
129 | 129 | parse_str($query, $query_params); |
130 | 130 | $params = array_merge($params, $query_params); |
131 | 131 | } |
132 | 132 | $this->setRequestTokenUrl($url); |
133 | - try{ |
|
133 | + try { |
|
134 | 134 | $this->_last = $token = parent::getRequestToken($params); |
135 | 135 | return array('oauth_token' => $token->getToken(), 'oauth_token_secret' => $token->getTokenSecret()); |
136 | - }catch(Zend_Oauth_Exception $e){ |
|
136 | + }catch (Zend_Oauth_Exception $e) { |
|
137 | 137 | return array('oauth_token' => '', 'oauth_token_secret' => ''); |
138 | 138 | } |
139 | 139 | } |
@@ -166,12 +166,12 @@ discard block |
||
166 | 166 | public function fetch($url, $params = null, $method = 'GET', $headers = null) |
167 | 167 | { |
168 | 168 | $acc = $this->makeAccessToken(); |
169 | - if ( strpos($url,'?') ) { |
|
169 | + if (strpos($url, '?')) { |
|
170 | 170 | list($clean_url, $query) = explode('?', $url); |
171 | - if($query) { |
|
171 | + if ($query) { |
|
172 | 172 | $url = $clean_url; |
173 | 173 | parse_str($query, $query_params); |
174 | - $params = array_merge($params?$params:array(), $query_params); |
|
174 | + $params = array_merge($params ? $params : array(), $query_params); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | $client = $acc->getHttpClient($this->_oauth_config, $url); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $proxy_config = SugarModule::get('Administration')->loadBean(); |
181 | 181 | $proxy_config->retrieveSettings('proxy'); |
182 | 182 | |
183 | - if( !empty($proxy_config) && |
|
183 | + if (!empty($proxy_config) && |
|
184 | 184 | !empty($proxy_config->settings['proxy_on']) && |
185 | 185 | $proxy_config->settings['proxy_on'] == 1) { |
186 | 186 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $proxy_settings['proxy_host'] = $proxy_config->settings['proxy_host']; |
189 | 189 | $proxy_settings['proxy_port'] = $proxy_config->settings['proxy_port']; |
190 | 190 | |
191 | - if(!empty($proxy_config->settings['proxy_auth'])){ |
|
191 | + if (!empty($proxy_config->settings['proxy_auth'])) { |
|
192 | 192 | $proxy_settings['proxy_user'] = $proxy_config->settings['proxy_username']; |
193 | 193 | $proxy_settings['proxy_pass'] = $proxy_config->settings['proxy_password']; |
194 | 194 | } |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | } |
200 | 200 | |
201 | 201 | $client->setMethod($method); |
202 | - if(!empty($headers)) { |
|
202 | + if (!empty($headers)) { |
|
203 | 203 | $client->setHeaders($headers); |
204 | 204 | } |
205 | - if(!empty($params)) { |
|
206 | - if($method == 'GET') { |
|
205 | + if (!empty($params)) { |
|
206 | + if ($method == 'GET') { |
|
207 | 207 | $client->setParameterGet($params); |
208 | 208 | } else { |
209 | 209 | $client->setParameterPost($params); |
@@ -18,7 +18,7 @@ |
||
18 | 18 | $PHPMAILER_LANG['invalid_address'] = 'الإرسال غير ممكن لأن عنوان البريد الإلكتروني غير صالح.'; |
19 | 19 | $PHPMAILER_LANG['mailer_not_supported'] = ' برنامج الإرسال غير مدعوم.'; |
20 | 20 | $PHPMAILER_LANG['provide_address'] = 'يجب توفير عنوان البريد الإلكتروني لمستلم واحد على الأقل.'; |
21 | -$PHPMAILER_LANG['recipients_failed'] = 'خطأ SMTP: الأخطاء التالية ' . |
|
21 | +$PHPMAILER_LANG['recipients_failed'] = 'خطأ SMTP: الأخطاء التالية '. |
|
22 | 22 | 'فشل في الارسال لكل من : '; |
23 | 23 | $PHPMAILER_LANG['signing'] = 'خطأ في التوقيع: '; |
24 | 24 | $PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() غير ممكن.'; |
@@ -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. |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | */ |
55 | 55 | function checkRequired($prefix, $required) |
56 | 56 | { |
57 | - foreach($required as $key) |
|
57 | + foreach ($required as $key) |
|
58 | 58 | { |
59 | - if(!isset($_POST[$prefix.$key]) || number_empty($_POST[$prefix.$key])) |
|
59 | + if (!isset($_POST[$prefix.$key]) || number_empty($_POST[$prefix.$key])) |
|
60 | 60 | { |
61 | 61 | return false; |
62 | 62 | } |
@@ -77,15 +77,15 @@ discard block |
||
77 | 77 | { |
78 | 78 | global $current_user; |
79 | 79 | |
80 | - if(!empty($_REQUEST[$prefix.'record']) && !$skipRetrieve) |
|
80 | + if (!empty($_REQUEST[$prefix.'record']) && !$skipRetrieve) |
|
81 | 81 | $focus->retrieve($_REQUEST[$prefix.'record']); |
82 | 82 | |
83 | - if(!empty($_POST['assigned_user_id']) && |
|
83 | + if (!empty($_POST['assigned_user_id']) && |
|
84 | 84 | ($focus->assigned_user_id != $_POST['assigned_user_id']) && |
85 | 85 | ($_POST['assigned_user_id'] != $current_user->id)) { |
86 | 86 | $GLOBALS['check_notify'] = true; |
87 | 87 | } |
88 | - if(isset($_POST['dup_checked']) && $_POST['dup_checked'] && isset($_POST['id']) && $_POST['id'] != '' ){ |
|
88 | + if (isset($_POST['dup_checked']) && $_POST['dup_checked'] && isset($_POST['id']) && $_POST['id'] != '') { |
|
89 | 89 | $focus->new_with_id = true; |
90 | 90 | } |
91 | 91 | require_once('include/SugarFields/SugarFieldHandler.php'); |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | $relatedFields[$def['id_name']] = $field; |
107 | 107 | } |
108 | 108 | |
109 | - foreach($focus->field_defs as $field=>$def) { |
|
110 | - if ( $field == 'id' && !empty($focus->id) ) { |
|
109 | + foreach ($focus->field_defs as $field=>$def) { |
|
110 | + if ($field == 'id' && !empty($focus->id)) { |
|
111 | 111 | // Don't try and overwrite the ID |
112 | 112 | continue; |
113 | 113 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | $type = !empty($def['custom_type']) ? $def['custom_type'] : $def['type']; |
117 | 117 | $sf = $sfh->getSugarField($type); |
118 | - if($sf != null){ |
|
118 | + if ($sf != null) { |
|
119 | 119 | $sf->save($focus, $_POST, $field, $def, $prefix); |
120 | 120 | } else { |
121 | 121 | $GLOBALS['log']->fatal("Field '$field' does not have a SugarField handler"); |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | */ |
155 | 155 | } |
156 | 156 | |
157 | - foreach($focus->additional_column_fields as $field) { |
|
158 | - if(isset($_POST[$prefix.$field])) { |
|
157 | + foreach ($focus->additional_column_fields as $field) { |
|
158 | + if (isset($_POST[$prefix.$field])) { |
|
159 | 159 | $value = $_POST[$prefix.$field]; |
160 | 160 | $focus->$field = $value; |
161 | 161 | } |
@@ -180,18 +180,18 @@ discard block |
||
180 | 180 | } |
181 | 181 | |
182 | 182 | |
183 | -function getPostToForm($ignore='', $isRegularExpression=false) |
|
183 | +function getPostToForm($ignore = '', $isRegularExpression = false) |
|
184 | 184 | { |
185 | 185 | $fields = ''; |
186 | - if(!empty($ignore) && $isRegularExpression) { |
|
187 | - foreach ($_POST as $key=>$value){ |
|
188 | - if(!preg_match($ignore, $key)) { |
|
186 | + if (!empty($ignore) && $isRegularExpression) { |
|
187 | + foreach ($_POST as $key=>$value) { |
|
188 | + if (!preg_match($ignore, $key)) { |
|
189 | 189 | $fields .= add_hidden_elements($key, $value); |
190 | 190 | } |
191 | 191 | } |
192 | 192 | } else { |
193 | - foreach ($_POST as $key=>$value){ |
|
194 | - if($key != $ignore) { |
|
193 | + foreach ($_POST as $key=>$value) { |
|
194 | + if ($key != $ignore) { |
|
195 | 195 | $fields .= add_hidden_elements($key, $value); |
196 | 196 | } |
197 | 197 | } |
@@ -199,21 +199,21 @@ discard block |
||
199 | 199 | return $fields; |
200 | 200 | } |
201 | 201 | |
202 | -function getGetToForm($ignore='', $usePostAsAuthority = false) |
|
202 | +function getGetToForm($ignore = '', $usePostAsAuthority = false) |
|
203 | 203 | { |
204 | 204 | $fields = ''; |
205 | 205 | foreach ($_GET as $key=>$value) |
206 | 206 | { |
207 | - if($key != $ignore){ |
|
208 | - if(!$usePostAsAuthority || !isset($_POST[$key])){ |
|
209 | - $fields.= "<input type='hidden' name='$key' value='$value'>"; |
|
207 | + if ($key != $ignore) { |
|
208 | + if (!$usePostAsAuthority || !isset($_POST[$key])) { |
|
209 | + $fields .= "<input type='hidden' name='$key' value='$value'>"; |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | } |
213 | 213 | return $fields; |
214 | 214 | |
215 | 215 | } |
216 | -function getAnyToForm($ignore='', $usePostAsAuthority = false) |
|
216 | +function getAnyToForm($ignore = '', $usePostAsAuthority = false) |
|
217 | 217 | { |
218 | 218 | $fields = getPostToForm($ignore); |
219 | 219 | $fields .= getGetToForm($ignore, $usePostAsAuthority); |
@@ -221,11 +221,11 @@ discard block |
||
221 | 221 | |
222 | 222 | } |
223 | 223 | |
224 | -function handleRedirect($return_id='', $return_module='', $additionalFlags = false) |
|
224 | +function handleRedirect($return_id = '', $return_module = '', $additionalFlags = false) |
|
225 | 225 | { |
226 | - if(isset($_REQUEST['return_url']) && $_REQUEST['return_url'] != "") |
|
226 | + if (isset($_REQUEST['return_url']) && $_REQUEST['return_url'] != "") |
|
227 | 227 | { |
228 | - header("Location: ". $_REQUEST['return_url']); |
|
228 | + header("Location: ".$_REQUEST['return_url']); |
|
229 | 229 | exit; |
230 | 230 | } |
231 | 231 | |
@@ -235,9 +235,9 @@ discard block |
||
235 | 235 | } |
236 | 236 | |
237 | 237 | //eggsurplus: abstract to simplify unit testing |
238 | -function buildRedirectURL($return_id='', $return_module='') |
|
238 | +function buildRedirectURL($return_id = '', $return_module = '') |
|
239 | 239 | { |
240 | - if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") |
|
240 | + if (isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") |
|
241 | 241 | { |
242 | 242 | $return_module = $_REQUEST['return_module']; |
243 | 243 | } |
@@ -245,24 +245,24 @@ discard block |
||
245 | 245 | { |
246 | 246 | $return_module = $return_module; |
247 | 247 | } |
248 | - if(isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") |
|
248 | + if (isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") |
|
249 | 249 | { |
250 | 250 | |
251 | 251 | //if we are doing a "Close and Create New" |
252 | - if(isCloseAndCreateNewPressed()) |
|
252 | + if (isCloseAndCreateNewPressed()) |
|
253 | 253 | { |
254 | 254 | $return_action = "EditView"; |
255 | 255 | $isDuplicate = "true"; |
256 | 256 | $status = ""; |
257 | 257 | |
258 | 258 | // Meeting Integration |
259 | - if(isset($_REQUEST['meetingIntegrationFlag']) && $_REQUEST['meetingIntegrationFlag'] == 1) { |
|
259 | + if (isset($_REQUEST['meetingIntegrationFlag']) && $_REQUEST['meetingIntegrationFlag'] == 1) { |
|
260 | 260 | $additionalFlags = array('meetingIntegrationShowForm' => '1'); |
261 | 261 | } |
262 | 262 | // END Meeting Integration |
263 | 263 | } |
264 | 264 | // if we create a new record "Save", we want to redirect to the DetailView |
265 | - else if(isset($_REQUEST['action']) && $_REQUEST['action'] == "Save" |
|
265 | + else if (isset($_REQUEST['action']) && $_REQUEST['action'] == "Save" |
|
266 | 266 | && $_REQUEST['return_module'] != 'Activities' |
267 | 267 | && $_REQUEST['return_module'] != 'Home' |
268 | 268 | && $_REQUEST['return_module'] != 'Forecasts' |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | ) |
272 | 272 | { |
273 | 273 | $return_action = 'DetailView'; |
274 | - } elseif($_REQUEST['return_module'] == 'Activities' || $_REQUEST['return_module'] == 'Calendar') { |
|
274 | + } elseif ($_REQUEST['return_module'] == 'Activities' || $_REQUEST['return_module'] == 'Calendar') { |
|
275 | 275 | $return_module = $_REQUEST['module']; |
276 | 276 | $return_action = $_REQUEST['return_action']; |
277 | 277 | // wp: return action needs to be set for one-click close in task list |
@@ -287,25 +287,25 @@ discard block |
||
287 | 287 | $return_action = "DetailView"; |
288 | 288 | } |
289 | 289 | |
290 | - if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") |
|
290 | + if (isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") |
|
291 | 291 | { |
292 | 292 | $return_id = $_REQUEST['return_id']; |
293 | 293 | } |
294 | 294 | |
295 | 295 | $add = ""; |
296 | - if(isset($additionalFlags) && !empty($additionalFlags)) { |
|
297 | - foreach($additionalFlags as $k => $v) { |
|
296 | + if (isset($additionalFlags) && !empty($additionalFlags)) { |
|
297 | + foreach ($additionalFlags as $k => $v) { |
|
298 | 298 | $add .= "&{$k}={$v}"; |
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
302 | 302 | if (!isset($isDuplicate) || !$isDuplicate) |
303 | 303 | { |
304 | - $url="index.php?action=$return_action&module=$return_module&record=$return_id&return_module=$return_module&return_action=$return_action{$add}"; |
|
305 | - if(isset($_REQUEST['offset']) && empty($_REQUEST['duplicateSave'])) { |
|
304 | + $url = "index.php?action=$return_action&module=$return_module&record=$return_id&return_module=$return_module&return_action=$return_action{$add}"; |
|
305 | + if (isset($_REQUEST['offset']) && empty($_REQUEST['duplicateSave'])) { |
|
306 | 306 | $url .= "&offset=".$_REQUEST['offset']; |
307 | 307 | } |
308 | - if(!empty($_REQUEST['ajax_load'])) |
|
308 | + if (!empty($_REQUEST['ajax_load'])) |
|
309 | 309 | { |
310 | 310 | $ajax_ret = array( |
311 | 311 | 'content' => "<script>SUGAR.ajaxUI.loadContent('$url');</script>\n", |
@@ -321,8 +321,8 @@ discard block |
||
321 | 321 | } |
322 | 322 | } else { |
323 | 323 | $standard = "action=$return_action&module=$return_module&record=$return_id&isDuplicate=true&return_module=$return_module&return_action=$return_action&status=$status"; |
324 | - $url="index.php?{$standard}{$add}"; |
|
325 | - if(!empty($_REQUEST['ajax_load'])) |
|
324 | + $url = "index.php?{$standard}{$add}"; |
|
325 | + if (!empty($_REQUEST['ajax_load'])) |
|
326 | 326 | { |
327 | 327 | $ajax_ret = array( |
328 | 328 | 'content' => "<script>SUGAR.ajaxUI.loadContent('$url');</script>\n", |
@@ -339,20 +339,20 @@ discard block |
||
339 | 339 | } |
340 | 340 | } |
341 | 341 | |
342 | -function getLikeForEachWord($fieldname, $value, $minsize=4) |
|
342 | +function getLikeForEachWord($fieldname, $value, $minsize = 4) |
|
343 | 343 | { |
344 | 344 | $value = trim($value); |
345 | - $values = explode(' ',$value); |
|
345 | + $values = explode(' ', $value); |
|
346 | 346 | $ret = ''; |
347 | - foreach($values as $val) |
|
347 | + foreach ($values as $val) |
|
348 | 348 | { |
349 | - if(strlen($val) >= $minsize) |
|
349 | + if (strlen($val) >= $minsize) |
|
350 | 350 | { |
351 | - if(!empty($ret)) |
|
351 | + if (!empty($ret)) |
|
352 | 352 | { |
353 | 353 | $ret .= ' or'; |
354 | 354 | } |
355 | - $ret .= ' '. $fieldname . ' LIKE %'.$val.'%'; |
|
355 | + $ret .= ' '.$fieldname.' LIKE %'.$val.'%'; |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | } |
@@ -373,36 +373,36 @@ discard block |
||
373 | 373 | * @see include/generic/Save2.php |
374 | 374 | */ |
375 | 375 | |
376 | -function add_prospects_to_prospect_list($parent_id,$child_id) |
|
376 | +function add_prospects_to_prospect_list($parent_id, $child_id) |
|
377 | 377 | { |
378 | - $focus=BeanFactory::getBean('Prospects'); |
|
379 | - if(is_array($child_id)){ |
|
378 | + $focus = BeanFactory::getBean('Prospects'); |
|
379 | + if (is_array($child_id)) { |
|
380 | 380 | $uids = $child_id; |
381 | 381 | } |
382 | - else{ |
|
382 | + else { |
|
383 | 383 | $uids = array($child_id); |
384 | 384 | } |
385 | 385 | |
386 | 386 | $relationship = ''; |
387 | - foreach($focus->get_linked_fields() as $field => $def) { |
|
387 | + foreach ($focus->get_linked_fields() as $field => $def) { |
|
388 | 388 | if ($focus->load_relationship($field)) { |
389 | - if ( $focus->$field->getRelatedModuleName() == 'ProspectLists' ) { |
|
389 | + if ($focus->$field->getRelatedModuleName() == 'ProspectLists') { |
|
390 | 390 | $relationship = $field; |
391 | 391 | break; |
392 | 392 | } |
393 | 393 | } |
394 | 394 | } |
395 | 395 | |
396 | - if ( $relationship != '' ) { |
|
397 | - foreach ( $uids as $id) { |
|
396 | + if ($relationship != '') { |
|
397 | + foreach ($uids as $id) { |
|
398 | 398 | $focus->retrieve($id); |
399 | 399 | $focus->load_relationship($relationship); |
400 | - $focus->prospect_lists->add( $parent_id ); |
|
400 | + $focus->prospect_lists->add($parent_id); |
|
401 | 401 | } |
402 | 402 | } |
403 | 403 | } |
404 | 404 | |
405 | -function add_to_prospect_list($query_panel,$parent_module,$parent_type,$parent_id,$child_id,$link_attribute,$link_type,$parent) |
|
405 | +function add_to_prospect_list($query_panel, $parent_module, $parent_type, $parent_id, $child_id, $link_attribute, $link_type, $parent) |
|
406 | 406 | { |
407 | 407 | $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:'.$query_panel); |
408 | 408 | $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:'.$parent_module); |
@@ -419,21 +419,21 @@ discard block |
||
419 | 419 | } |
420 | 420 | $focus = new $parent_type(); |
421 | 421 | $focus->retrieve($parent_id); |
422 | - if(empty($focus->id)) { |
|
422 | + if (empty($focus->id)) { |
|
423 | 423 | return false; |
424 | 424 | } |
425 | - if(empty($parent)) { |
|
425 | + if (empty($parent)) { |
|
426 | 426 | return false; |
427 | 427 | } |
428 | 428 | |
429 | 429 | //if link_type is default then load relationship once and add all the child ids. |
430 | - $relationship_attribute=$link_attribute; |
|
430 | + $relationship_attribute = $link_attribute; |
|
431 | 431 | |
432 | 432 | //find all prospects based on the query |
433 | 433 | |
434 | 434 | $subpanel = new SubPanelTiles($parent, $parent->module_dir); |
435 | - $thisPanel=$subpanel->subpanel_definitions->load_subpanel($query_panel); |
|
436 | - if(empty($thisPanel)) { |
|
435 | + $thisPanel = $subpanel->subpanel_definitions->load_subpanel($query_panel); |
|
436 | + if (empty($thisPanel)) { |
|
437 | 437 | return false; |
438 | 438 | } |
439 | 439 | |
@@ -443,12 +443,12 @@ discard block |
||
443 | 443 | $thisPanel->_instance_properties['function_parameters']['EMAIL_MARKETING_ID_VALUE'] = $_REQUEST['marketing_id']; |
444 | 444 | } |
445 | 445 | |
446 | - $result = SugarBean::get_union_related_list($parent, '', '', '', 0, -99,-99,'', $thisPanel); |
|
446 | + $result = SugarBean::get_union_related_list($parent, '', '', '', 0, -99, -99, '', $thisPanel); |
|
447 | 447 | |
448 | - if(!empty($result['list'])) { |
|
449 | - foreach($result['list'] as $object) { |
|
448 | + if (!empty($result['list'])) { |
|
449 | + foreach ($result['list'] as $object) { |
|
450 | 450 | if ($link_type != 'default') { |
451 | - $relationship_attribute=strtolower($object->$link_attribute); |
|
451 | + $relationship_attribute = strtolower($object->$link_attribute); |
|
452 | 452 | } |
453 | 453 | $GLOBALS['log']->debug('add_prospects_to_prospect_list:relationship_attribute:'.$relationship_attribute); |
454 | 454 | // load relationship for the first time or on change of relationship atribute. |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | } |
463 | 463 | |
464 | 464 | //Link rows returned by a report to parent record. |
465 | -function save_from_report($report_id,$parent_id, $module_name, $relationship_attr_name) { |
|
465 | +function save_from_report($report_id, $parent_id, $module_name, $relationship_attr_name) { |
|
466 | 466 | global $beanFiles; |
467 | 467 | global $beanList; |
468 | 468 | |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | $GLOBALS['log']->debug("Save2:Module Name=".$module_name); |
473 | 473 | $GLOBALS['log']->debug("Save2:Relationship Attribute Name=".$relationship_attr_name); |
474 | 474 | |
475 | - $GLOBALS['log']->debug("Save2:Bean Name=" . $module_name); |
|
475 | + $GLOBALS['log']->debug("Save2:Bean Name=".$module_name); |
|
476 | 476 | $focus = BeanFactory::newBean($module_name); |
477 | 477 | |
478 | 478 | $focus->retrieve($parent_id); |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | //fetch report definition. |
482 | 482 | global $current_language, $report_modules, $modules_report; |
483 | 483 | |
484 | - $mod_strings = return_module_language($current_language,"Reports"); |
|
484 | + $mod_strings = return_module_language($current_language, "Reports"); |
|
485 | 485 | |
486 | 486 | |
487 | 487 | $saved = new SavedReport(); |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | $result = $report->db->query($sql); |
499 | 499 | |
500 | 500 | $reportBean = BeanFactory::newBean($saved->module); |
501 | - while($row = $report->db->fetchByAssoc($result)) |
|
501 | + while ($row = $report->db->fetchByAssoc($result)) |
|
502 | 502 | { |
503 | 503 | $reportBean->id = $row['primaryid']; |
504 | 504 | $focus->$relationship_attr_name->add($reportBean); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | // assumes the following variables must be set: |
106 | 106 | // $dbconfig, $dbconfigoption, $cache_dir, $session_dir, $site_URL, $upload_dir |
107 | 107 | |
108 | - $sugar_config = array ( |
|
108 | + $sugar_config = array( |
|
109 | 109 | 'admin_export_only' => empty($admin_export_only) ? false : $admin_export_only, |
110 | 110 | 'export_delimiter' => empty($export_delimiter) ? ',' : $export_delimiter, |
111 | 111 | 'cache_dir' => empty($cache_dir) ? 'cache/' : $cache_dir, |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | 'd.m.Y' => '23.12.2010', |
124 | 124 | 'm.d.Y' => '12.23.2010' |
125 | 125 | ) : $dateFormats, |
126 | - 'dbconfig' => $dbconfig, // this must be set!! |
|
127 | - 'dbconfigoption' => $dbconfigoption, // this must be set!! |
|
126 | + 'dbconfig' => $dbconfig, // this must be set!! |
|
127 | + 'dbconfigoption' => $dbconfigoption, // this must be set!! |
|
128 | 128 | 'default_action' => empty($default_action) ? 'index' : $default_action, |
129 | 129 | 'default_charset' => empty($default_charset) ? 'UTF-8' : $default_charset, |
130 | 130 | 'default_currency_name' => empty($default_currency_name) ? 'US Dollar' : $default_currency_name, |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | 'default_language' => empty($default_language) ? 'en_us' : $default_language, |
137 | 137 | 'default_module' => empty($default_module) ? 'Home' : $default_module, |
138 | 138 | 'default_password' => empty($default_password) ? '' : $default_password, |
139 | - 'default_permissions' => array ( |
|
139 | + 'default_permissions' => array( |
|
140 | 140 | 'dir_mode' => 02770, |
141 | 141 | 'file_mode' => 0755, |
142 | 142 | 'chown' => '', |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | 'display_inbound_email_buttons' => empty($display_inbound_email_buttons) ? false : $display_inbound_email_buttons, |
153 | 153 | 'history_max_viewed' => empty($history_max_viewed) ? 50 : $history_max_viewed, |
154 | 154 | 'host_name' => empty($host_name) ? 'localhost' : $host_name, |
155 | - 'import_dir' => $import_dir, // this must be set!! |
|
155 | + 'import_dir' => $import_dir, // this must be set!! |
|
156 | 156 | 'import_max_records_per_file' => 100, |
157 | 157 | 'import_max_records_total_limit' => '', |
158 | 158 | 'languages' => empty($languages) ? array('en_us' => 'English (US)') : $languages, |
@@ -165,34 +165,34 @@ discard block |
||
165 | 165 | 'l, f' => 'l, f', 's l, f' => 's l, f', 'l s f' => 'l s f', 'l f s' => 'l f s' |
166 | 166 | ) : $nameFormats, |
167 | 167 | 'portal_view' => 'single_user', |
168 | - 'resource_management' => array ( |
|
168 | + 'resource_management' => array( |
|
169 | 169 | 'special_query_limit' => 50000, |
170 | 170 | 'special_query_modules' => array('Reports', 'Export', 'Import', 'Administration', 'Sync'), |
171 | 171 | 'default_limit' => 1000, |
172 | 172 | ), |
173 | 173 | 'require_accounts' => empty($requireAccounts) ? true : $requireAccounts, |
174 | 174 | 'rss_cache_time' => empty($RSS_CACHE_TIME) ? '10800' : $RSS_CACHE_TIME, |
175 | - 'session_dir' => $session_dir, // this must be set!! |
|
176 | - 'site_url' => empty($site_URL) ? $site_url : $site_URL, // this must be set!! |
|
175 | + 'session_dir' => $session_dir, // this must be set!! |
|
176 | + 'site_url' => empty($site_URL) ? $site_url : $site_URL, // this must be set!! |
|
177 | 177 | 'showDetailData' => true, // if true, read-only ACL fields will still appear on EditViews as non-editable |
178 | 178 | 'showThemePicker' => true, |
179 | 179 | 'sugar_version' => empty($sugar_version) ? 'unknown' : $sugar_version, |
180 | - 'time_formats' => empty($timeFormats) ? array ( |
|
180 | + 'time_formats' => empty($timeFormats) ? array( |
|
181 | 181 | 'H:i'=>'23:00', 'h:ia'=>'11:00 pm', 'h:iA'=>'11:00PM', |
182 | 182 | 'H.i'=>'23.00', 'h.ia'=>'11.00 pm', 'h.iA'=>'11.00PM' ) : $timeFormats, |
183 | - 'tmp_dir' => $tmp_dir, // this must be set!! |
|
183 | + 'tmp_dir' => $tmp_dir, // this must be set!! |
|
184 | 184 | 'translation_string_prefix' => empty($translation_string_prefix) ? false : $translation_string_prefix, |
185 | 185 | 'unique_key' => empty($unique_key) ? md5(create_guid()) : $unique_key, |
186 | - 'upload_badext' => empty($upload_badext) ? array ( |
|
186 | + 'upload_badext' => empty($upload_badext) ? array( |
|
187 | 187 | 'php', 'php3', 'php4', 'php5', 'pl', 'cgi', 'py', |
188 | 188 | 'asp', 'cfm', 'js', 'vbs', 'html', 'htm' ) : $upload_badext, |
189 | - 'upload_dir' => $upload_dir, // this must be set!! |
|
189 | + 'upload_dir' => $upload_dir, // this must be set!! |
|
190 | 190 | 'upload_maxsize' => empty($upload_maxsize) ? 30000000 : $upload_maxsize, |
191 | 191 | 'import_max_execution_time' => empty($import_max_execution_time) ? 3600 : $import_max_execution_time, |
192 | 192 | 'lock_homepage' => false, |
193 | 193 | 'lock_subpanels' => false, |
194 | 194 | 'max_dashlets_homepage' => 15, |
195 | - 'dashlet_display_row_options' => array('1','3','5','10'), |
|
195 | + 'dashlet_display_row_options' => array('1', '3', '5', '10'), |
|
196 | 196 | 'default_max_tabs' => empty($max_tabs) ? '7' : $max_tabs, |
197 | 197 | 'default_subpanel_tabs' => empty($subpanel_tabs) ? true : $subpanel_tabs, |
198 | 198 | 'default_subpanel_links' => empty($subpanel_links) ? false : $subpanel_links, |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | 'default_navigation_paradigm' => empty($navigation_paradigm) ? 'gm' : $navigation_paradigm, |
202 | 202 | 'default_call_status' => 'Planned', |
203 | 203 | 'js_lang_version' => 1, |
204 | - 'passwordsetting' => empty($passwordsetting) ? array ( |
|
204 | + 'passwordsetting' => empty($passwordsetting) ? array( |
|
205 | 205 | 'SystemGeneratedPasswordON' => '', |
206 | 206 | 'generatepasswordtmpl' => '', |
207 | 207 | 'lostpasswordtmpl' => '', |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * sugar_config_union |
241 | 241 | */ |
242 | 242 | |
243 | - $sugar_config_defaults = array ( |
|
243 | + $sugar_config_defaults = array( |
|
244 | 244 | 'admin_export_only' => false, |
245 | 245 | 'export_delimiter' => ',', |
246 | 246 | 'export_excel_compatible' => false, |
@@ -248,15 +248,15 @@ discard block |
||
248 | 248 | 'calculate_response_time' => true, |
249 | 249 | 'create_default_user' => false, |
250 | 250 | 'chartEngine' => 'Jit', |
251 | - 'date_formats' => array ( |
|
251 | + 'date_formats' => array( |
|
252 | 252 | 'Y-m-d' => '2010-12-23', 'm-d-Y' => '12-23-2010', 'd-m-Y' => '23-12-2010', |
253 | 253 | 'Y/m/d' => '2010/12/23', 'm/d/Y' => '12/23/2010', 'd/m/Y' => '23/12/2010', |
254 | 254 | 'Y.m.d' => '2010.12.23', 'd.m.Y' => '23.12.2010', 'm.d.Y' => '12.23.2010',), |
255 | - 'name_formats' => array ( |
|
255 | + 'name_formats' => array( |
|
256 | 256 | 's f l' => 's f l', 'f l' => 'f l', 's l' => 's l', 'l, s f' => 'l, s f', |
257 | 257 | 'l, f' => 'l, f', 's l, f' => 's l, f', 'l s f' => 'l s f', 'l f s' => 'l f s' |
258 | 258 | ), |
259 | - 'dbconfigoption' => array ( |
|
259 | + 'dbconfigoption' => array( |
|
260 | 260 | 'persistent' => true, |
261 | 261 | 'autofree' => false, |
262 | 262 | 'debug' => 0, |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | 'en_us'), |
278 | 278 | 'default_module' => 'Home', |
279 | 279 | 'default_password' => '', |
280 | - 'default_permissions' => array ( |
|
280 | + 'default_permissions' => array( |
|
281 | 281 | 'dir_mode' => 02770, |
282 | 282 | 'file_mode' => 0755, |
283 | 283 | 'user' => '', |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | 'lock_default_user_name' => false, |
310 | 310 | 'log_memory_usage' => false, |
311 | 311 | 'portal_view' => 'single_user', |
312 | - 'resource_management' => array ( |
|
312 | + 'resource_management' => array( |
|
313 | 313 | 'special_query_limit' => 50000, |
314 | 314 | 'special_query_modules' => array('Reports', 'Export', 'Import', 'Administration', 'Sync'), |
315 | 315 | 'default_limit' => 1000, |
@@ -322,13 +322,13 @@ discard block |
||
322 | 322 | 'showThemePicker' => true, |
323 | 323 | 'slow_query_time_msec' => '100', |
324 | 324 | 'sugarbeet' => true, |
325 | - 'time_formats' => array ( |
|
325 | + 'time_formats' => array( |
|
326 | 326 | 'H:i'=>'23:00', 'h:ia'=>'11:00pm', 'h:iA'=>'11:00PM', 'h:i a'=>'11:00 pm', 'h:i A'=>'11:00 PM', |
327 | 327 | 'H.i'=>'23.00', 'h.ia'=>'11.00pm', 'h.iA'=>'11.00PM', 'h.i a'=>'11.00 pm', 'h.i A'=>'11.00 PM' ), |
328 | 328 | 'tracker_max_display_length' => 15, |
329 | 329 | 'translation_string_prefix' => |
330 | 330 | return_session_value_or_default('translation_string_prefix', false), |
331 | - 'upload_badext' => array ( |
|
331 | + 'upload_badext' => array( |
|
332 | 332 | 'php', 'php3', 'php4', 'php5', 'pl', 'cgi', 'py', |
333 | 333 | 'asp', 'cfm', 'js', 'vbs', 'html', 'htm', 'phtml' ), |
334 | 334 | 'upload_maxsize' => 30000000, |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | 'lock_subpanels' => false, |
345 | 345 | 'max_dashlets_homepage' => '15', |
346 | 346 | 'default_max_tabs' => '7', |
347 | - 'dashlet_display_row_options' => array('1','3','5','10'), |
|
347 | + 'dashlet_display_row_options' => array('1', '3', '5', '10'), |
|
348 | 348 | 'default_subpanel_tabs' => true, |
349 | 349 | 'default_subpanel_links' => false, |
350 | 350 | 'default_swap_last_viewed' => false, |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | 'enable_repeat' => true, |
369 | 369 | 'max_repeat_count' => 1000, |
370 | 370 | ), |
371 | - 'passwordsetting' => empty($passwordsetting) ? array ( |
|
371 | + 'passwordsetting' => empty($passwordsetting) ? array( |
|
372 | 372 | 'SystemGeneratedPasswordON' => '', |
373 | 373 | 'generatepasswordtmpl' => '', |
374 | 374 | 'lostpasswordtmpl' => '', |
@@ -397,31 +397,31 @@ discard block |
||
397 | 397 | ), |
398 | 398 | ); |
399 | 399 | |
400 | - if(!is_object($locale)) { |
|
400 | + if (!is_object($locale)) { |
|
401 | 401 | $locale = new Localization(); |
402 | 402 | } |
403 | 403 | |
404 | 404 | $sugar_config_defaults['default_currencies'] = $locale->getDefaultCurrencies(); |
405 | 405 | |
406 | 406 | $sugar_config_defaults = sugarArrayMerge($locale->getLocaleConfigDefaults(), $sugar_config_defaults); |
407 | - return( $sugar_config_defaults ); |
|
407 | + return($sugar_config_defaults); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | /** |
411 | 411 | * @deprecated use SugarView::getMenu() instead |
412 | 412 | */ |
413 | -function load_menu($path){ |
|
413 | +function load_menu($path) { |
|
414 | 414 | global $module_menu; |
415 | 415 | |
416 | - if(file_exists($path . 'Menu.php')) |
|
416 | + if (file_exists($path.'Menu.php')) |
|
417 | 417 | { |
418 | - require($path . 'Menu.php'); |
|
418 | + require($path.'Menu.php'); |
|
419 | 419 | } |
420 | - if(file_exists('custom/' . $path . 'Ext/Menus/menu.ext.php')) |
|
420 | + if (file_exists('custom/'.$path.'Ext/Menus/menu.ext.php')) |
|
421 | 421 | { |
422 | - require('custom/' . $path . 'Ext/Menus/menu.ext.php'); |
|
422 | + require('custom/'.$path.'Ext/Menus/menu.ext.php'); |
|
423 | 423 | } |
424 | - if(file_exists('custom/application/Ext/Menus/menu.ext.php')) |
|
424 | + if (file_exists('custom/application/Ext/Menus/menu.ext.php')) |
|
425 | 425 | { |
426 | 426 | require('custom/application/Ext/Menus/menu.ext.php'); |
427 | 427 | } |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | * |
435 | 435 | * @return string relative file path to email notifications template file |
436 | 436 | */ |
437 | -function get_notify_template_file($language){ |
|
437 | +function get_notify_template_file($language) { |
|
438 | 438 | /* |
439 | 439 | * Order of operation: |
440 | 440 | * 1) custom version of specified language |
@@ -446,43 +446,43 @@ discard block |
||
446 | 446 | // set $file to the base code template so it's set if none of the conditions pass |
447 | 447 | $file = "include/language/en_us.notify_template.html"; |
448 | 448 | |
449 | - if(file_exists("custom/include/language/{$language}.notify_template.html")){ |
|
449 | + if (file_exists("custom/include/language/{$language}.notify_template.html")) { |
|
450 | 450 | $file = "custom/include/language/{$language}.notify_template.html"; |
451 | 451 | } |
452 | - else if(file_exists("include/language/{$language}.notify_template.html")){ |
|
452 | + else if (file_exists("include/language/{$language}.notify_template.html")) { |
|
453 | 453 | $file = "include/language/{$language}.notify_template.html"; |
454 | 454 | } |
455 | - else if(file_exists("custom/include/language/en_us.notify_template.html")){ |
|
455 | + else if (file_exists("custom/include/language/en_us.notify_template.html")) { |
|
456 | 456 | $file = "custom/include/language/en_us.notify_template.html"; |
457 | 457 | } |
458 | 458 | |
459 | 459 | return $file; |
460 | 460 | } |
461 | 461 | |
462 | -function sugar_config_union( $default, $override ){ |
|
462 | +function sugar_config_union($default, $override) { |
|
463 | 463 | // a little different then array_merge and array_merge_recursive. we want |
464 | 464 | // the second array to override the first array if the same value exists, |
465 | 465 | // otherwise merge the unique keys. it handles arrays of arrays recursively |
466 | 466 | // might be suitable for a generic array_union |
467 | - if( !is_array( $override ) ){ |
|
467 | + if (!is_array($override)) { |
|
468 | 468 | $override = array(); |
469 | 469 | } |
470 | - foreach( $default as $key => $value ){ |
|
471 | - if( !array_key_exists($key, $override) ){ |
|
470 | + foreach ($default as $key => $value) { |
|
471 | + if (!array_key_exists($key, $override)) { |
|
472 | 472 | $override[$key] = $value; |
473 | 473 | } |
474 | - else if( is_array( $key ) ){ |
|
475 | - $override[$key] = sugar_config_union( $value, $override[$key] ); |
|
474 | + else if (is_array($key)) { |
|
475 | + $override[$key] = sugar_config_union($value, $override[$key]); |
|
476 | 476 | } |
477 | 477 | } |
478 | - return( $override ); |
|
478 | + return($override); |
|
479 | 479 | } |
480 | 480 | |
481 | -function make_not_writable( $file ){ |
|
481 | +function make_not_writable($file) { |
|
482 | 482 | // Returns true if the given file/dir has been made not writable |
483 | 483 | $ret_val = false; |
484 | - if( is_file($file) || is_dir($file) ){ |
|
485 | - if( !is_writable($file) ){ |
|
484 | + if (is_file($file) || is_dir($file)) { |
|
485 | + if (!is_writable($file)) { |
|
486 | 486 | $ret_val = true; |
487 | 487 | } |
488 | 488 | else { |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | $new_fileperms = $original_fileperms & ~0x0092; |
493 | 493 | @sugar_chmod($file, $new_fileperms); |
494 | 494 | |
495 | - if( !is_writable($file) ){ |
|
495 | + if (!is_writable($file)) { |
|
496 | 496 | $ret_val = true; |
497 | 497 | } |
498 | 498 | } |
@@ -515,12 +515,12 @@ discard block |
||
515 | 515 | $last_name = ""; |
516 | 516 | $full_name = ""; |
517 | 517 | |
518 | - if(isset($row[$first_column])) |
|
518 | + if (isset($row[$first_column])) |
|
519 | 519 | { |
520 | 520 | $first_name = stripslashes($row[$first_column]); |
521 | 521 | } |
522 | 522 | |
523 | - if(isset($row[$last_column])) |
|
523 | + if (isset($row[$last_column])) |
|
524 | 524 | { |
525 | 525 | $last_name = stripslashes($row[$last_column]); |
526 | 526 | } |
@@ -528,13 +528,13 @@ discard block |
||
528 | 528 | $full_name = $first_name; |
529 | 529 | |
530 | 530 | // If we have a first name and we have a last name |
531 | - if($full_name != "" && $last_name != "") |
|
531 | + if ($full_name != "" && $last_name != "") |
|
532 | 532 | { |
533 | 533 | // append a space, then the last name |
534 | 534 | $full_name .= " ".$last_name; |
535 | 535 | } |
536 | 536 | // If we have no first name, but we have a last name |
537 | - else if($last_name != "") |
|
537 | + else if ($last_name != "") |
|
538 | 538 | { |
539 | 539 | // append the last name without the space. |
540 | 540 | $full_name .= $last_name; |
@@ -548,8 +548,8 @@ discard block |
||
548 | 548 | { |
549 | 549 | global $sugar_config; |
550 | 550 | $lang = $sugar_config['languages']; |
551 | - if(!empty($sugar_config['disabled_languages'])){ |
|
552 | - foreach(explode(',', $sugar_config['disabled_languages']) as $disable) { |
|
551 | + if (!empty($sugar_config['disabled_languages'])) { |
|
552 | + foreach (explode(',', $sugar_config['disabled_languages']) as $disable) { |
|
553 | 553 | unset($lang[$disable]); |
554 | 554 | } |
555 | 555 | } |
@@ -572,11 +572,11 @@ discard block |
||
572 | 572 | function get_assigned_user_name($assigned_user_id, $is_group = '') { |
573 | 573 | static $saved_user_list = null; |
574 | 574 | |
575 | - if(empty($saved_user_list)) { |
|
575 | + if (empty($saved_user_list)) { |
|
576 | 576 | $saved_user_list = get_user_array(false, '', '', false, null, $is_group); |
577 | 577 | } |
578 | 578 | |
579 | - if(isset($saved_user_list[$assigned_user_id])) { |
|
579 | + if (isset($saved_user_list[$assigned_user_id])) { |
|
580 | 580 | return $saved_user_list[$assigned_user_id]; |
581 | 581 | } |
582 | 582 | |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | function get_user_name($id) { |
592 | 592 | global $db; |
593 | 593 | |
594 | - if(empty($db)) |
|
594 | + if (empty($db)) |
|
595 | 595 | $db = DBManagerFactory::getInstance(); |
596 | 596 | |
597 | 597 | $q = "SELECT user_name FROM users WHERE id='{$id}'"; |
@@ -619,19 +619,19 @@ discard block |
||
619 | 619 | * @param bool $from_cache Boolean value indicating whether or not to use the get_register_value function for caching, true by default |
620 | 620 | * @return array Array of users matching the filter criteria that may be from cache (if similar search was previously run) |
621 | 621 | */ |
622 | -function get_user_array($add_blank=true, $status="Active", $user_id='', $use_real_name=false, $user_name_filter='', $portal_filter=' AND portal_only=0 ', $from_cache = true) { |
|
622 | +function get_user_array($add_blank = true, $status = "Active", $user_id = '', $use_real_name = false, $user_name_filter = '', $portal_filter = ' AND portal_only=0 ', $from_cache = true) { |
|
623 | 623 | global $locale, $sugar_config, $current_user; |
624 | 624 | |
625 | - if(empty($locale)) { |
|
625 | + if (empty($locale)) { |
|
626 | 626 | $locale = new Localization(); |
627 | 627 | } |
628 | 628 | |
629 | - if($from_cache) { |
|
630 | - $key_name = $add_blank. $status . $user_id . $use_real_name . $user_name_filter . $portal_filter; |
|
629 | + if ($from_cache) { |
|
630 | + $key_name = $add_blank.$status.$user_id.$use_real_name.$user_name_filter.$portal_filter; |
|
631 | 631 | $user_array = get_register_value('user_array', $key_name); |
632 | 632 | } |
633 | 633 | |
634 | - if(empty($user_array)) { |
|
634 | + if (empty($user_array)) { |
|
635 | 635 | $db = DBManagerFactory::getInstance(); |
636 | 636 | $temp_result = Array(); |
637 | 637 | // Including deleted users for now. |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | } |
644 | 644 | /* BEGIN - SECURITY GROUPS */ |
645 | 645 | global $current_user, $sugar_config; |
646 | - if(!is_admin($current_user) |
|
646 | + if (!is_admin($current_user) |
|
647 | 647 | && isset($sugar_config['securitysuite_filter_user_list']) |
648 | 648 | && $sugar_config['securitysuite_filter_user_list'] == true |
649 | 649 | && (empty($_REQUEST['module']) || $_REQUEST['module'] != 'Home') |
@@ -664,21 +664,21 @@ discard block |
||
664 | 664 | } |
665 | 665 | |
666 | 666 | //get the user preference for name formatting, to be used in order by |
667 | - $order_by_string =' user_name ASC '; |
|
668 | - if(!empty($current_user) && !empty($current_user->id)) |
|
667 | + $order_by_string = ' user_name ASC '; |
|
668 | + if (!empty($current_user) && !empty($current_user->id)) |
|
669 | 669 | { |
670 | 670 | $formatString = $current_user->getPreference('default_locale_name_format'); |
671 | 671 | |
672 | 672 | //create the order by string based on position of first and last name in format string |
673 | - $order_by_string =' user_name ASC '; |
|
674 | - $firstNamePos = strpos( $formatString, 'f'); |
|
675 | - $lastNamePos = strpos( $formatString, 'l'); |
|
676 | - if($firstNamePos !== false || $lastNamePos !== false){ |
|
673 | + $order_by_string = ' user_name ASC '; |
|
674 | + $firstNamePos = strpos($formatString, 'f'); |
|
675 | + $lastNamePos = strpos($formatString, 'l'); |
|
676 | + if ($firstNamePos !== false || $lastNamePos !== false) { |
|
677 | 677 | //its possible for first name to be skipped, check for this |
678 | - if($firstNamePos===false){ |
|
679 | - $order_by_string = 'last_name ASC'; |
|
680 | - }else{ |
|
681 | - $order_by_string = ($lastNamePos < $firstNamePos) ? "last_name, first_name ASC" : "first_name, last_name ASC"; |
|
678 | + if ($firstNamePos === false) { |
|
679 | + $order_by_string = 'last_name ASC'; |
|
680 | + } else { |
|
681 | + $order_by_string = ($lastNamePos < $firstNamePos) ? "last_name, first_name ASC" : "first_name, last_name ASC"; |
|
682 | 682 | } |
683 | 683 | } |
684 | 684 | } |
@@ -687,16 +687,16 @@ discard block |
||
687 | 687 | $GLOBALS['log']->debug("get_user_array query: $query"); |
688 | 688 | $result = $db->query($query, true, "Error filling in user array: "); |
689 | 689 | |
690 | - if ($add_blank==true) { |
|
690 | + if ($add_blank == true) { |
|
691 | 691 | // Add in a blank row |
692 | 692 | $temp_result[''] = ''; |
693 | 693 | } |
694 | 694 | |
695 | 695 | // Get the id and the name. |
696 | - while($row = $db->fetchByAssoc($result)) { |
|
697 | - if($use_real_name == true || showFullName()) { |
|
698 | - if(isset($row['last_name'])) { // cn: we will ALWAYS have both first_name and last_name (empty value if blank in db) |
|
699 | - $temp_result[$row['id']] = $locale->getLocaleFormattedName($row['first_name'],$row['last_name']); |
|
696 | + while ($row = $db->fetchByAssoc($result)) { |
|
697 | + if ($use_real_name == true || showFullName()) { |
|
698 | + if (isset($row['last_name'])) { // cn: we will ALWAYS have both first_name and last_name (empty value if blank in db) |
|
699 | + $temp_result[$row['id']] = $locale->getLocaleFormattedName($row['first_name'], $row['last_name']); |
|
700 | 700 | } else { |
701 | 701 | $temp_result[$row['id']] = $row['user_name']; |
702 | 702 | } |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | } |
707 | 707 | |
708 | 708 | $user_array = $temp_result; |
709 | - if($from_cache) |
|
709 | + if ($from_cache) |
|
710 | 710 | { |
711 | 711 | set_register_value('user_array', $key_name, $temp_result); |
712 | 712 | } |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | $inClauses[] = "(first_name LIKE '{$arg}%' OR last_name LIKE '{$arg}%')"; |
747 | 747 | } |
748 | 748 | |
749 | - $inClause = '(' . implode('OR ', $inClauses) . ')'; |
|
749 | + $inClause = '('.implode('OR ', $inClauses).')'; |
|
750 | 750 | |
751 | 751 | } else { |
752 | 752 | $args = $db->quote($args); |
@@ -754,14 +754,14 @@ discard block |
||
754 | 754 | } |
755 | 755 | // ~jmorais@dri |
756 | 756 | |
757 | - $query = "SELECT id, first_name, last_name, user_name FROM users WHERE status='Active' AND deleted=0 AND "; |
|
758 | - if ( $hide_portal_users ) { |
|
757 | + $query = "SELECT id, first_name, last_name, user_name FROM users WHERE status='Active' AND deleted=0 AND "; |
|
758 | + if ($hide_portal_users) { |
|
759 | 759 | $query .= " portal_only=0 AND "; |
760 | 760 | } |
761 | 761 | $query .= $inClause; |
762 | 762 | /* BEGIN - SECURITY GROUPS */ |
763 | 763 | global $current_user, $sugar_config; |
764 | - if(!is_admin($current_user) |
|
764 | + if (!is_admin($current_user) |
|
765 | 765 | && isset($sugar_config['securitysuite_filter_user_list']) |
766 | 766 | && $sugar_config['securitysuite_filter_user_list'] == true |
767 | 767 | ) { |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | |
776 | 776 | $r = $db->query($query); |
777 | 777 | $ret = array(); |
778 | - while($a = $db->fetchByAssoc($r)) { |
|
778 | + while ($a = $db->fetchByAssoc($r)) { |
|
779 | 779 | $ret[$a['id']] = $locale->getLocaleFormattedName($a['first_name'], $a['last_name']); |
780 | 780 | } |
781 | 781 | |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | $sysPref = !empty($sugar_config['use_real_names']); |
796 | 796 | $userPref = (is_object($current_user)) ? $current_user->getPreference('use_real_names') : null; |
797 | 797 | |
798 | - if($userPref != null) { |
|
798 | + if ($userPref != null) { |
|
799 | 799 | $showFullName = ($userPref == 'on'); |
800 | 800 | } else { |
801 | 801 | $showFullName = $sysPref; |
@@ -853,7 +853,7 @@ discard block |
||
853 | 853 | |
854 | 854 | // Check for cached value |
855 | 855 | $cache_entry = sugar_cache_retrieve($cache_key); |
856 | - if(!empty($cache_entry)) |
|
856 | + if (!empty($cache_entry)) |
|
857 | 857 | { |
858 | 858 | return $cache_entry; |
859 | 859 | } |
@@ -872,17 +872,17 @@ discard block |
||
872 | 872 | |
873 | 873 | $app_list_strings_array = array(); |
874 | 874 | |
875 | - foreach ( $langs as $lang ) { |
|
875 | + foreach ($langs as $lang) { |
|
876 | 876 | $app_list_strings = array(); |
877 | - if(file_exists("include/language/$lang.lang.php")) { |
|
877 | + if (file_exists("include/language/$lang.lang.php")) { |
|
878 | 878 | include("include/language/$lang.lang.php"); |
879 | 879 | $GLOBALS['log']->info("Found language file: $lang.lang.php"); |
880 | 880 | } |
881 | - if(file_exists("include/language/$lang.lang.override.php")) { |
|
881 | + if (file_exists("include/language/$lang.lang.override.php")) { |
|
882 | 882 | include("include/language/$lang.lang.override.php"); |
883 | 883 | $GLOBALS['log']->info("Found override language file: $lang.lang.override.php"); |
884 | 884 | } |
885 | - if(file_exists("include/language/$lang.lang.php.override")) { |
|
885 | + if (file_exists("include/language/$lang.lang.php.override")) { |
|
886 | 886 | include("include/language/$lang.lang.php.override"); |
887 | 887 | $GLOBALS['log']->info("Found override language file: $lang.lang.php.override"); |
888 | 888 | } |
@@ -891,22 +891,22 @@ discard block |
||
891 | 891 | } |
892 | 892 | |
893 | 893 | $app_list_strings = array(); |
894 | - foreach ( $app_list_strings_array as $app_list_strings_item ) { |
|
894 | + foreach ($app_list_strings_array as $app_list_strings_item) { |
|
895 | 895 | $app_list_strings = sugarLangArrayMerge($app_list_strings, $app_list_strings_item); |
896 | 896 | } |
897 | 897 | |
898 | - foreach ( $langs as $lang ) { |
|
899 | - if(file_exists("custom/application/Ext/Language/$lang.lang.ext.php")) { |
|
900 | - $app_list_strings = _mergeCustomAppListStrings("custom/application/Ext/Language/$lang.lang.ext.php" , $app_list_strings); |
|
898 | + foreach ($langs as $lang) { |
|
899 | + if (file_exists("custom/application/Ext/Language/$lang.lang.ext.php")) { |
|
900 | + $app_list_strings = _mergeCustomAppListStrings("custom/application/Ext/Language/$lang.lang.ext.php", $app_list_strings); |
|
901 | 901 | $GLOBALS['log']->info("Found extended language file: $lang.lang.ext.php"); |
902 | 902 | } |
903 | - if(file_exists("custom/include/language/$lang.lang.php")) { |
|
903 | + if (file_exists("custom/include/language/$lang.lang.php")) { |
|
904 | 904 | include("custom/include/language/$lang.lang.php"); |
905 | 905 | $GLOBALS['log']->info("Found custom language file: $lang.lang.php"); |
906 | 906 | } |
907 | 907 | } |
908 | 908 | |
909 | - if(!isset($app_list_strings)) { |
|
909 | + if (!isset($app_list_strings)) { |
|
910 | 910 | $GLOBALS['log']->fatal("Unable to load the application language file for the selected language ($language) or the default language ($default_language) or the en_us language"); |
911 | 911 | return null; |
912 | 912 | } |
@@ -927,14 +927,14 @@ discard block |
||
927 | 927 | * @return array |
928 | 928 | */ |
929 | 929 | //jchi 25347 |
930 | -function _mergeCustomAppListStrings($file , $app_list_strings){ |
|
930 | +function _mergeCustomAppListStrings($file, $app_list_strings) { |
|
931 | 931 | $app_list_strings_original = $app_list_strings; |
932 | 932 | unset($app_list_strings); |
933 | 933 | // FG - bug 45525 - $exemptDropdown array is defined (once) here, not inside the foreach |
934 | 934 | // This way, language file can add items to save specific standard codelist from being overwritten |
935 | 935 | $exemptDropdowns = array(); |
936 | 936 | include($file); |
937 | - if(!isset($app_list_strings) || !is_array($app_list_strings)){ |
|
937 | + if (!isset($app_list_strings) || !is_array($app_list_strings)) { |
|
938 | 938 | return $app_list_strings_original; |
939 | 939 | } |
940 | 940 | //Bug 25347: We should not merge custom dropdown fields unless they relate to parent fields or the module list. |
@@ -944,14 +944,14 @@ discard block |
||
944 | 944 | $exemptDropdowns[] = "moduleListSingular"; |
945 | 945 | $exemptDropdowns = array_merge($exemptDropdowns, getTypeDisplayList()); |
946 | 946 | |
947 | - foreach($app_list_strings as $key=>$value) |
|
947 | + foreach ($app_list_strings as $key=>$value) |
|
948 | 948 | { |
949 | 949 | if (!in_array($key, $exemptDropdowns) && array_key_exists($key, $app_list_strings_original)) |
950 | 950 | { |
951 | 951 | unset($app_list_strings_original["$key"]); |
952 | 952 | } |
953 | 953 | } |
954 | - $app_list_strings = sugarArrayMergeRecursive($app_list_strings_original , $app_list_strings); |
|
954 | + $app_list_strings = sugarArrayMergeRecursive($app_list_strings_original, $app_list_strings); |
|
955 | 955 | return $app_list_strings; |
956 | 956 | } |
957 | 957 | |
@@ -969,7 +969,7 @@ discard block |
||
969 | 969 | |
970 | 970 | // Check for cached value |
971 | 971 | $cache_entry = sugar_cache_retrieve($cache_key); |
972 | - if(!empty($cache_entry)) |
|
972 | + if (!empty($cache_entry)) |
|
973 | 973 | { |
974 | 974 | return $cache_entry; |
975 | 975 | } |
@@ -989,25 +989,25 @@ discard block |
||
989 | 989 | |
990 | 990 | $app_strings_array = array(); |
991 | 991 | |
992 | - foreach ( $langs as $lang ) { |
|
992 | + foreach ($langs as $lang) { |
|
993 | 993 | $app_strings = array(); |
994 | - if(file_exists("include/language/$lang.lang.php")) { |
|
994 | + if (file_exists("include/language/$lang.lang.php")) { |
|
995 | 995 | include("include/language/$lang.lang.php"); |
996 | 996 | $GLOBALS['log']->info("Found language file: $lang.lang.php"); |
997 | 997 | } |
998 | - if(file_exists("include/language/$lang.lang.override.php")) { |
|
998 | + if (file_exists("include/language/$lang.lang.override.php")) { |
|
999 | 999 | include("include/language/$lang.lang.override.php"); |
1000 | 1000 | $GLOBALS['log']->info("Found override language file: $lang.lang.override.php"); |
1001 | 1001 | } |
1002 | - if(file_exists("include/language/$lang.lang.php.override")) { |
|
1002 | + if (file_exists("include/language/$lang.lang.php.override")) { |
|
1003 | 1003 | include("include/language/$lang.lang.php.override"); |
1004 | 1004 | $GLOBALS['log']->info("Found override language file: $lang.lang.php.override"); |
1005 | 1005 | } |
1006 | - if(file_exists("custom/application/Ext/Language/$lang.lang.ext.php")) { |
|
1006 | + if (file_exists("custom/application/Ext/Language/$lang.lang.ext.php")) { |
|
1007 | 1007 | include("custom/application/Ext/Language/$lang.lang.ext.php"); |
1008 | 1008 | $GLOBALS['log']->info("Found extended language file: $lang.lang.ext.php"); |
1009 | 1009 | } |
1010 | - if(file_exists("custom/include/language/$lang.lang.php")) { |
|
1010 | + if (file_exists("custom/include/language/$lang.lang.php")) { |
|
1011 | 1011 | include("custom/include/language/$lang.lang.php"); |
1012 | 1012 | $GLOBALS['log']->info("Found custom language file: $lang.lang.php"); |
1013 | 1013 | } |
@@ -1015,23 +1015,23 @@ discard block |
||
1015 | 1015 | } |
1016 | 1016 | |
1017 | 1017 | $app_strings = array(); |
1018 | - foreach ( $app_strings_array as $app_strings_item ) { |
|
1018 | + foreach ($app_strings_array as $app_strings_item) { |
|
1019 | 1019 | $app_strings = sugarLangArrayMerge($app_strings, $app_strings_item); |
1020 | 1020 | } |
1021 | 1021 | |
1022 | - if(!isset($app_strings)) { |
|
1022 | + if (!isset($app_strings)) { |
|
1023 | 1023 | $GLOBALS['log']->fatal("Unable to load the application language strings"); |
1024 | 1024 | return null; |
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | // If we are in debug mode for translating, turn on the prefix now! |
1028 | - if(!empty($sugar_config['translation_string_prefix'])) |
|
1028 | + if (!empty($sugar_config['translation_string_prefix'])) |
|
1029 | 1029 | { |
1030 | - foreach($app_strings as $entry_key=>$entry_value) { |
|
1030 | + foreach ($app_strings as $entry_key=>$entry_value) { |
|
1031 | 1031 | $app_strings[$entry_key] = $language.' '.$entry_value; |
1032 | 1032 | } |
1033 | 1033 | } |
1034 | - if(isset($_SESSION['show_deleted'])) { |
|
1034 | + if (isset($_SESSION['show_deleted'])) { |
|
1035 | 1035 | $app_strings['LBL_DELETE_BUTTON'] = $app_strings['LBL_UNDELETE_BUTTON']; |
1036 | 1036 | $app_strings['LBL_DELETE_BUTTON_LABEL'] = $app_strings['LBL_UNDELETE_BUTTON_LABEL']; |
1037 | 1037 | $app_strings['LBL_DELETE_BUTTON_TITLE'] = $app_strings['LBL_UNDELETE_BUTTON_TITLE']; |
@@ -1056,7 +1056,7 @@ discard block |
||
1056 | 1056 | * @param bool $refresh optional, true if you want to rebuild the language strings |
1057 | 1057 | * @return array lang strings |
1058 | 1058 | */ |
1059 | -function return_module_language($language, $module, $refresh=false) |
|
1059 | +function return_module_language($language, $module, $refresh = false) |
|
1060 | 1060 | { |
1061 | 1061 | global $mod_strings; |
1062 | 1062 | global $sugar_config; |
@@ -1064,17 +1064,17 @@ discard block |
||
1064 | 1064 | |
1065 | 1065 | // Jenny - Bug 8119: Need to check if $module is not empty |
1066 | 1066 | if (empty($module)) { |
1067 | - $stack = debug_backtrace(); |
|
1068 | - $GLOBALS['log']->warn("Variable module is not in return_module_language ". var_export($stack, true)); |
|
1067 | + $stack = debug_backtrace(); |
|
1068 | + $GLOBALS['log']->warn("Variable module is not in return_module_language ".var_export($stack, true)); |
|
1069 | 1069 | return array(); |
1070 | 1070 | } |
1071 | 1071 | |
1072 | - if( !$refresh ) |
|
1072 | + if (!$refresh) |
|
1073 | 1073 | { |
1074 | 1074 | $cache_key = LanguageManager::getLanguageCacheKey($module, $language); |
1075 | 1075 | // Check for cached value |
1076 | 1076 | $cache_entry = sugar_cache_retrieve($cache_key); |
1077 | - if(!empty($cache_entry) && is_array($cache_entry)) |
|
1077 | + if (!empty($cache_entry) && is_array($cache_entry)) |
|
1078 | 1078 | { |
1079 | 1079 | return $cache_entry; |
1080 | 1080 | } |
@@ -1085,43 +1085,43 @@ discard block |
||
1085 | 1085 | $language_used = $language; |
1086 | 1086 | $default_language = $sugar_config['default_language']; |
1087 | 1087 | |
1088 | - if(empty($language)) { |
|
1088 | + if (empty($language)) { |
|
1089 | 1089 | $language = $default_language; |
1090 | 1090 | } |
1091 | 1091 | |
1092 | 1092 | // Bug 21559 - So we can get all the strings defined in the template, refresh |
1093 | 1093 | // the vardefs file if the cached language file doesn't exist. |
1094 | - if(!file_exists(sugar_cached('modules/'). $module . '/language/'.$language.'.lang.php') |
|
1095 | - && !empty($GLOBALS['beanList'][$module])){ |
|
1094 | + if (!file_exists(sugar_cached('modules/').$module.'/language/'.$language.'.lang.php') |
|
1095 | + && !empty($GLOBALS['beanList'][$module])) { |
|
1096 | 1096 | $object = BeanFactory::getObjectName($module); |
1097 | - VardefManager::refreshVardefs($module,$object); |
|
1097 | + VardefManager::refreshVardefs($module, $object); |
|
1098 | 1098 | } |
1099 | 1099 | |
1100 | - $loaded_mod_strings = LanguageManager::loadModuleLanguage($module, $language,$refresh); |
|
1100 | + $loaded_mod_strings = LanguageManager::loadModuleLanguage($module, $language, $refresh); |
|
1101 | 1101 | |
1102 | 1102 | // cn: bug 6048 - merge en_us with requested language |
1103 | - if($language != $sugar_config['default_language']) |
|
1103 | + if ($language != $sugar_config['default_language']) |
|
1104 | 1104 | $loaded_mod_strings = sugarLangArrayMerge( |
1105 | - LanguageManager::loadModuleLanguage($module, $sugar_config['default_language'],$refresh), |
|
1105 | + LanguageManager::loadModuleLanguage($module, $sugar_config['default_language'], $refresh), |
|
1106 | 1106 | $loaded_mod_strings |
1107 | 1107 | ); |
1108 | 1108 | |
1109 | 1109 | // Load in en_us strings by default |
1110 | - if($language != 'en_us' && $sugar_config['default_language'] != 'en_us') |
|
1110 | + if ($language != 'en_us' && $sugar_config['default_language'] != 'en_us') |
|
1111 | 1111 | $loaded_mod_strings = sugarLangArrayMerge( |
1112 | 1112 | LanguageManager::loadModuleLanguage($module, 'en_us', $refresh), |
1113 | 1113 | $loaded_mod_strings |
1114 | 1114 | ); |
1115 | 1115 | |
1116 | 1116 | // If we are in debug mode for translating, turn on the prefix now! |
1117 | - if($sugar_config['translation_string_prefix']) { |
|
1118 | - foreach($loaded_mod_strings as $entry_key=>$entry_value) { |
|
1117 | + if ($sugar_config['translation_string_prefix']) { |
|
1118 | + foreach ($loaded_mod_strings as $entry_key=>$entry_value) { |
|
1119 | 1119 | $loaded_mod_strings[$entry_key] = $language_used.' '.$entry_value; |
1120 | 1120 | } |
1121 | 1121 | } |
1122 | 1122 | |
1123 | 1123 | $return_value = $loaded_mod_strings; |
1124 | - if(!isset($mod_strings)){ |
|
1124 | + if (!isset($mod_strings)) { |
|
1125 | 1125 | $mod_strings = $return_value; |
1126 | 1126 | } |
1127 | 1127 | else |
@@ -1138,7 +1138,7 @@ discard block |
||
1138 | 1138 | * All Rights Reserved. |
1139 | 1139 | * Contributor(s): ______________________________________.. |
1140 | 1140 | * If you are using the current language, do not call this function unless you are loading it for the first time */ |
1141 | -function return_mod_list_strings_language($language,$module) { |
|
1141 | +function return_mod_list_strings_language($language, $module) { |
|
1142 | 1142 | global $mod_list_strings; |
1143 | 1143 | global $sugar_config; |
1144 | 1144 | global $currentModule; |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | |
1148 | 1148 | // Check for cached value |
1149 | 1149 | $cache_entry = sugar_cache_retrieve($cache_key); |
1150 | - if(!empty($cache_entry)) |
|
1150 | + if (!empty($cache_entry)) |
|
1151 | 1151 | { |
1152 | 1152 | return $cache_entry; |
1153 | 1153 | } |
@@ -1156,7 +1156,7 @@ discard block |
||
1156 | 1156 | $temp_mod_list_strings = $mod_list_strings; |
1157 | 1157 | $default_language = $sugar_config['default_language']; |
1158 | 1158 | |
1159 | - if($currentModule == $module && isset($mod_list_strings) && $mod_list_strings != null) { |
|
1159 | + if ($currentModule == $module && isset($mod_list_strings) && $mod_list_strings != null) { |
|
1160 | 1160 | return $mod_list_strings; |
1161 | 1161 | } |
1162 | 1162 | |
@@ -1164,19 +1164,19 @@ discard block |
||
1164 | 1164 | // cn: bug 6048 - merge en_us with requested language |
1165 | 1165 | include("modules/$module/language/en_us.lang.php"); |
1166 | 1166 | $en_mod_list_strings = array(); |
1167 | - if($language_used != $default_language) |
|
1167 | + if ($language_used != $default_language) |
|
1168 | 1168 | $en_mod_list_strings = $mod_list_strings; |
1169 | 1169 | |
1170 | - if(file_exists("modules/$module/language/$language.lang.php")) { |
|
1170 | + if (file_exists("modules/$module/language/$language.lang.php")) { |
|
1171 | 1171 | include("modules/$module/language/$language.lang.php"); |
1172 | 1172 | } |
1173 | 1173 | |
1174 | - if(file_exists("modules/$module/language/$language.lang.override.php")){ |
|
1174 | + if (file_exists("modules/$module/language/$language.lang.override.php")) { |
|
1175 | 1175 | include("modules/$module/language/$language.lang.override.php"); |
1176 | 1176 | } |
1177 | 1177 | |
1178 | - if(file_exists("modules/$module/language/$language.lang.php.override")){ |
|
1179 | - echo 'Please Change:<br>' . "modules/$module/language/$language.lang.php.override" . '<br>to<br>' . 'Please Change:<br>' . "modules/$module/language/$language.lang.override.php"; |
|
1178 | + if (file_exists("modules/$module/language/$language.lang.php.override")) { |
|
1179 | + echo 'Please Change:<br>'."modules/$module/language/$language.lang.php.override".'<br>to<br>'.'Please Change:<br>'."modules/$module/language/$language.lang.override.php"; |
|
1180 | 1180 | include("modules/$module/language/$language.lang.php.override"); |
1181 | 1181 | } |
1182 | 1182 | |
@@ -1184,7 +1184,7 @@ discard block |
||
1184 | 1184 | $mod_list_strings = sugarLangArrayMerge($en_mod_list_strings, $mod_list_strings); |
1185 | 1185 | |
1186 | 1186 | // if we still don't have a language pack, then log an error |
1187 | - if(!isset($mod_list_strings)) { |
|
1187 | + if (!isset($mod_list_strings)) { |
|
1188 | 1188 | $GLOBALS['log']->fatal("Unable to load the application list language file for the selected language($language) or the default language($default_language) for module({$module})"); |
1189 | 1189 | return null; |
1190 | 1190 | } |
@@ -1210,30 +1210,30 @@ discard block |
||
1210 | 1210 | $default_language = $sugar_config['default_language']; |
1211 | 1211 | |
1212 | 1212 | include(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.php"); |
1213 | - if(file_exists(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.override.php")){ |
|
1213 | + if (file_exists(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.override.php")) { |
|
1214 | 1214 | include(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.override.php"); |
1215 | 1215 | } |
1216 | - if(file_exists(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.php.override")){ |
|
1217 | - echo 'Please Change:<br>' . SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.php.override" . '<br>to<br>' . 'Please Change:<br>' . SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.override.php"; |
|
1216 | + if (file_exists(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.php.override")) { |
|
1217 | + echo 'Please Change:<br>'.SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.php.override".'<br>to<br>'.'Please Change:<br>'.SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.override.php"; |
|
1218 | 1218 | include(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.php.override"); |
1219 | 1219 | } |
1220 | - if(!isset($theme_strings)) |
|
1220 | + if (!isset($theme_strings)) |
|
1221 | 1221 | { |
1222 | 1222 | $GLOBALS['log']->warn("Unable to find the theme file for language: ".$language." and theme: ".$theme); |
1223 | 1223 | require(SugarThemeRegistry::get($theme)->getFilePath()."/language/$default_language.lang.php"); |
1224 | 1224 | $language_used = $default_language; |
1225 | 1225 | } |
1226 | 1226 | |
1227 | - if(!isset($theme_strings)) |
|
1227 | + if (!isset($theme_strings)) |
|
1228 | 1228 | { |
1229 | 1229 | $GLOBALS['log']->fatal("Unable to load the theme($theme) language file for the selected language($language) or the default language($default_language)"); |
1230 | 1230 | return null; |
1231 | 1231 | } |
1232 | 1232 | |
1233 | 1233 | // If we are in debug mode for translating, turn on the prefix now! |
1234 | - if($sugar_config['translation_string_prefix']) |
|
1234 | + if ($sugar_config['translation_string_prefix']) |
|
1235 | 1235 | { |
1236 | - foreach($theme_strings as $entry_key=>$entry_value) |
|
1236 | + foreach ($theme_strings as $entry_key=>$entry_value) |
|
1237 | 1237 | { |
1238 | 1238 | $theme_strings[$entry_key] = $language_used.' '.$entry_value; |
1239 | 1239 | } |
@@ -1251,7 +1251,7 @@ discard block |
||
1251 | 1251 | */ |
1252 | 1252 | function return_session_value_or_default($varname, $default) |
1253 | 1253 | { |
1254 | - if(isset($_SESSION[$varname]) && $_SESSION[$varname] != "") |
|
1254 | + if (isset($_SESSION[$varname]) && $_SESSION[$varname] != "") |
|
1255 | 1255 | { |
1256 | 1256 | return $_SESSION[$varname]; |
1257 | 1257 | } |
@@ -1271,12 +1271,12 @@ discard block |
||
1271 | 1271 | */ |
1272 | 1272 | function append_where_clause(&$where_clauses, $variable_name, $SQL_name = null) |
1273 | 1273 | { |
1274 | - if($SQL_name == null) |
|
1274 | + if ($SQL_name == null) |
|
1275 | 1275 | { |
1276 | 1276 | $SQL_name = $variable_name; |
1277 | 1277 | } |
1278 | 1278 | |
1279 | - if(isset($_REQUEST[$variable_name]) && $_REQUEST[$variable_name] != "") |
|
1279 | + if (isset($_REQUEST[$variable_name]) && $_REQUEST[$variable_name] != "") |
|
1280 | 1280 | { |
1281 | 1281 | array_push($where_clauses, "$SQL_name like '".$GLOBALS['db']->quote($_REQUEST[$variable_name])."%'"); |
1282 | 1282 | } |
@@ -1293,9 +1293,9 @@ discard block |
||
1293 | 1293 | function generate_where_statement($where_clauses) |
1294 | 1294 | { |
1295 | 1295 | $where = ""; |
1296 | - foreach($where_clauses as $clause) |
|
1296 | + foreach ($where_clauses as $clause) |
|
1297 | 1297 | { |
1298 | - if($where != "") |
|
1298 | + if ($where != "") |
|
1299 | 1299 | $where .= " and "; |
1300 | 1300 | $where .= $clause; |
1301 | 1301 | } |
@@ -1310,15 +1310,15 @@ discard block |
||
1310 | 1310 | * @return bool False on failure |
1311 | 1311 | */ |
1312 | 1312 | function is_guid($guid) { |
1313 | - if(strlen($guid) != 36) { |
|
1313 | + if (strlen($guid) != 36) { |
|
1314 | 1314 | return false; |
1315 | 1315 | } |
1316 | 1316 | |
1317 | - if(preg_match("/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/i", $guid)) { |
|
1317 | + if (preg_match("/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/i", $guid)) { |
|
1318 | 1318 | return true; |
1319 | 1319 | } |
1320 | 1320 | |
1321 | - return true;; |
|
1321 | + return true; ; |
|
1322 | 1322 | } |
1323 | 1323 | |
1324 | 1324 | |
@@ -1335,7 +1335,7 @@ discard block |
||
1335 | 1335 | $microTime = microtime(); |
1336 | 1336 | list($a_dec, $a_sec) = explode(" ", $microTime); |
1337 | 1337 | |
1338 | - $dec_hex = dechex($a_dec* 1000000); |
|
1338 | + $dec_hex = dechex($a_dec * 1000000); |
|
1339 | 1339 | $sec_hex = dechex($a_sec); |
1340 | 1340 | |
1341 | 1341 | ensure_length($dec_hex, 5); |
@@ -1361,9 +1361,9 @@ discard block |
||
1361 | 1361 | function create_guid_section($characters) |
1362 | 1362 | { |
1363 | 1363 | $return = ""; |
1364 | - for($i=0; $i<$characters; $i++) |
|
1364 | + for ($i = 0; $i < $characters; $i++) |
|
1365 | 1365 | { |
1366 | - $return .= dechex(mt_rand(0,15)); |
|
1366 | + $return .= dechex(mt_rand(0, 15)); |
|
1367 | 1367 | } |
1368 | 1368 | return $return; |
1369 | 1369 | } |
@@ -1371,11 +1371,11 @@ discard block |
||
1371 | 1371 | function ensure_length(&$string, $length) |
1372 | 1372 | { |
1373 | 1373 | $strlen = strlen($string); |
1374 | - if($strlen < $length) |
|
1374 | + if ($strlen < $length) |
|
1375 | 1375 | { |
1376 | - $string = str_pad($string,$length,"0"); |
|
1376 | + $string = str_pad($string, $length, "0"); |
|
1377 | 1377 | } |
1378 | - else if($strlen > $length) |
|
1378 | + else if ($strlen > $length) |
|
1379 | 1379 | { |
1380 | 1380 | $string = substr($string, 0, $length); |
1381 | 1381 | } |
@@ -1391,7 +1391,7 @@ discard block |
||
1391 | 1391 | function displayStudioForCurrentUser() |
1392 | 1392 | { |
1393 | 1393 | global $current_user; |
1394 | - if ( $current_user->isAdmin() ) { |
|
1394 | + if ($current_user->isAdmin()) { |
|
1395 | 1395 | return true; |
1396 | 1396 | } |
1397 | 1397 | |
@@ -1411,7 +1411,7 @@ discard block |
||
1411 | 1411 | function get_admin_modules_for_user($user) { |
1412 | 1412 | $GLOBALS['log']->deprecated("get_admin_modules_for_user() is deprecated as of 6.2.2 and may disappear in the future, use Users->getDeveloperModules() instead"); |
1413 | 1413 | |
1414 | - if(!isset($user)){ |
|
1414 | + if (!isset($user)) { |
|
1415 | 1415 | $modules = array(); |
1416 | 1416 | return $modules; |
1417 | 1417 | } |
@@ -1420,14 +1420,14 @@ discard block |
||
1420 | 1420 | |
1421 | 1421 | } |
1422 | 1422 | |
1423 | - function get_workflow_admin_modules_for_user($user){ |
|
1423 | + function get_workflow_admin_modules_for_user($user) { |
|
1424 | 1424 | if (isset($_SESSION['get_workflow_admin_modules_for_user'])) { |
1425 | 1425 | return $_SESSION['get_workflow_admin_modules_for_user']; |
1426 | 1426 | } |
1427 | 1427 | |
1428 | 1428 | global $moduleList; |
1429 | 1429 | $workflow_mod_list = array(); |
1430 | - foreach($moduleList as $module){ |
|
1430 | + foreach ($moduleList as $module) { |
|
1431 | 1431 | $workflow_mod_list[$module] = $module; |
1432 | 1432 | } |
1433 | 1433 | |
@@ -1442,18 +1442,18 @@ discard block |
||
1442 | 1442 | // End of list |
1443 | 1443 | |
1444 | 1444 | $workflow_admin_modules = array(); |
1445 | - if(empty($user)) { |
|
1445 | + if (empty($user)) { |
|
1446 | 1446 | return $workflow_admin_modules; |
1447 | 1447 | } |
1448 | 1448 | $actions = ACLAction::getUserActions($user->id); |
1449 | 1449 | //check for ForecastSchedule because it doesn't exist in $workflow_mod_list |
1450 | - if (isset($actions['ForecastSchedule']['module']['admin']['aclaccess']) && ($actions['ForecastSchedule']['module']['admin']['aclaccess']==ACL_ALLOW_DEV || |
|
1451 | - $actions['ForecastSchedule']['module']['admin']['aclaccess']==ACL_ALLOW_ADMIN_DEV)) { |
|
1450 | + if (isset($actions['ForecastSchedule']['module']['admin']['aclaccess']) && ($actions['ForecastSchedule']['module']['admin']['aclaccess'] == ACL_ALLOW_DEV || |
|
1451 | + $actions['ForecastSchedule']['module']['admin']['aclaccess'] == ACL_ALLOW_ADMIN_DEV)) { |
|
1452 | 1452 | $workflow_admin_modules['Forecasts'] = 'Forecasts'; |
1453 | 1453 | } |
1454 | 1454 | foreach ($workflow_mod_list as $key=>$val) { |
1455 | - if(!in_array($val, $workflow_admin_modules) && ($val!='iFrames' && $val!='Feeds' && $val!='Home' && $val!='Dashboard' |
|
1456 | - && $val!='Calendar' && $val!='Activities' && $val!='Reports') && |
|
1455 | + if (!in_array($val, $workflow_admin_modules) && ($val != 'iFrames' && $val != 'Feeds' && $val != 'Home' && $val != 'Dashboard' |
|
1456 | + && $val != 'Calendar' && $val != 'Activities' && $val != 'Reports') && |
|
1457 | 1457 | ($user->isDeveloperForModule($key))) { |
1458 | 1458 | $workflow_admin_modules[$key] = $val; |
1459 | 1459 | } |
@@ -1464,10 +1464,10 @@ discard block |
||
1464 | 1464 | |
1465 | 1465 | // Check if user is admin for at least one module. |
1466 | 1466 | function is_admin_for_any_module($user) { |
1467 | - if (!isset($user)){ |
|
1467 | + if (!isset($user)) { |
|
1468 | 1468 | return false; |
1469 | 1469 | } |
1470 | - if($user->isAdmin()) { |
|
1470 | + if ($user->isAdmin()) { |
|
1471 | 1471 | return true; |
1472 | 1472 | } |
1473 | 1473 | return false; |
@@ -1475,7 +1475,7 @@ discard block |
||
1475 | 1475 | |
1476 | 1476 | |
1477 | 1477 | // Check if user is admin for a specific module. |
1478 | -function is_admin_for_module($user,$module) { |
|
1478 | +function is_admin_for_module($user, $module) { |
|
1479 | 1479 | if (!isset($user)) { |
1480 | 1480 | return false; |
1481 | 1481 | } |
@@ -1493,7 +1493,7 @@ discard block |
||
1493 | 1493 | * Contributor(s): ______________________________________.. |
1494 | 1494 | */ |
1495 | 1495 | function is_admin($user) { |
1496 | - if(empty($user)) { |
|
1496 | + if (empty($user)) { |
|
1497 | 1497 | return false; |
1498 | 1498 | } |
1499 | 1499 | |
@@ -1536,7 +1536,7 @@ discard block |
||
1536 | 1536 | * All Rights Reserved. |
1537 | 1537 | * Contributor(s): ______________________________________.. |
1538 | 1538 | */ |
1539 | -function get_select_options ($option_list, $selected) { |
|
1539 | +function get_select_options($option_list, $selected) { |
|
1540 | 1540 | return get_select_options_with_id($option_list, $selected); |
1541 | 1541 | } |
1542 | 1542 | |
@@ -1549,7 +1549,7 @@ discard block |
||
1549 | 1549 | * All Rights Reserved. |
1550 | 1550 | * Contributor(s): ______________________________________.. |
1551 | 1551 | */ |
1552 | -function get_select_options_with_id ($option_list, $selected_key) { |
|
1552 | +function get_select_options_with_id($option_list, $selected_key) { |
|
1553 | 1553 | return get_select_options_with_id_separate_key($option_list, $option_list, $selected_key); |
1554 | 1554 | } |
1555 | 1555 | |
@@ -1564,14 +1564,14 @@ discard block |
||
1564 | 1564 | * All Rights Reserved. |
1565 | 1565 | * Contributor(s): ______________________________________.. |
1566 | 1566 | */ |
1567 | -function get_select_options_with_id_separate_key ($label_list, $key_list, $selected_key, $massupdate=false) { |
|
1567 | +function get_select_options_with_id_separate_key($label_list, $key_list, $selected_key, $massupdate = false) { |
|
1568 | 1568 | global $app_strings; |
1569 | 1569 | $select_options = ""; |
1570 | 1570 | |
1571 | 1571 | //for setting null selection values to human readable --None-- |
1572 | 1572 | $pattern = "/'0?'></"; |
1573 | 1573 | $replacement = "''>".$app_strings['LBL_NONE']."<"; |
1574 | - if($massupdate){ |
|
1574 | + if ($massupdate) { |
|
1575 | 1575 | $replacement .= "/OPTION>\n<OPTION value='__SugarMassUpdateClearField__'><"; // Giving the user the option to unset a drop down list. I.e. none means that it won't get updated |
1576 | 1576 | } |
1577 | 1577 | |
@@ -1588,7 +1588,7 @@ discard block |
||
1588 | 1588 | $option_key == '' |
1589 | 1589 | && (($selected_key == '' && !$massupdate) || $selected_key == '__SugarMassUpdateClearField__') |
1590 | 1590 | ) |
1591 | - || (is_array($selected_key) && in_array($option_key, $selected_key)) |
|
1591 | + || (is_array($selected_key) && in_array($option_key, $selected_key)) |
|
1592 | 1592 | ) { |
1593 | 1593 | $selected_string = 'selected '; |
1594 | 1594 | } |
@@ -1622,7 +1622,7 @@ discard block |
||
1622 | 1622 | * All Rights Reserved. |
1623 | 1623 | * Contributor(s): ______________________________________.. |
1624 | 1624 | */ |
1625 | -function get_clear_form_js () { |
|
1625 | +function get_clear_form_js() { |
|
1626 | 1626 | $the_script = <<<EOQ |
1627 | 1627 | <script type="text/javascript" language="JavaScript"> |
1628 | 1628 | function clear_form(form) { |
@@ -1646,7 +1646,7 @@ discard block |
||
1646 | 1646 | * All Rights Reserved. |
1647 | 1647 | * Contributor(s): ______________________________________.. |
1648 | 1648 | */ |
1649 | -function get_set_focus_js () { |
|
1649 | +function get_set_focus_js() { |
|
1650 | 1650 | //TODO Clint 5/20 - Make this function more generic so that it can take in the target form and field names as variables |
1651 | 1651 | $the_script = <<<EOQ |
1652 | 1652 | <script type="text/javascript" language="JavaScript"> |
@@ -1719,7 +1719,7 @@ discard block |
||
1719 | 1719 | */ |
1720 | 1720 | function parse_calendardate($local_format) { |
1721 | 1721 | preg_match('/\(?([^-]{1})[^-]*-([^-]{1})[^-]*-([^-]{1})[^-]*\)/', $local_format, $matches); |
1722 | - $calendar_format = "%" . $matches[1] . "-%" . $matches[2] . "-%" . $matches[3]; |
|
1722 | + $calendar_format = "%".$matches[1]."-%".$matches[2]."-%".$matches[3]; |
|
1723 | 1723 | return str_replace(array("y", "ᅣ1�7", "a", "j"), array("Y", "Y", "Y", "d"), $calendar_format); |
1724 | 1724 | } |
1725 | 1725 | |
@@ -1727,20 +1727,20 @@ discard block |
||
1727 | 1727 | |
1728 | 1728 | |
1729 | 1729 | |
1730 | -function translate($string, $mod='', $selectedValue=''){ |
|
1730 | +function translate($string, $mod = '', $selectedValue = '') { |
|
1731 | 1731 | //$test_start = microtime(); |
1732 | 1732 | //static $mod_strings_results = array(); |
1733 | - if(!empty($mod)){ |
|
1733 | + if (!empty($mod)) { |
|
1734 | 1734 | global $current_language; |
1735 | 1735 | //Bug 31275 |
1736 | - if(isset($_REQUEST['login_language'])){ |
|
1737 | - $current_language = ($_REQUEST['login_language'] == $current_language)? $current_language : $_REQUEST['login_language']; |
|
1736 | + if (isset($_REQUEST['login_language'])) { |
|
1737 | + $current_language = ($_REQUEST['login_language'] == $current_language) ? $current_language : $_REQUEST['login_language']; |
|
1738 | 1738 | } |
1739 | 1739 | $mod_strings = return_module_language($current_language, $mod); |
1740 | 1740 | if ($mod == "") |
1741 | - echo "Language is <pre>" . $mod_strings . "</pre>"; |
|
1741 | + echo "Language is <pre>".$mod_strings."</pre>"; |
|
1742 | 1742 | |
1743 | - }else{ |
|
1743 | + } else { |
|
1744 | 1744 | global $mod_strings; |
1745 | 1745 | } |
1746 | 1746 | |
@@ -1774,13 +1774,13 @@ discard block |
||
1774 | 1774 | |
1775 | 1775 | |
1776 | 1776 | |
1777 | - if(empty($returnValue)){ |
|
1777 | + if (empty($returnValue)) { |
|
1778 | 1778 | return $string; |
1779 | 1779 | } |
1780 | 1780 | |
1781 | 1781 | // Bug 48996 - Custom enums with '0' value were not returning because of empty check |
1782 | 1782 | // Added a numeric 0 checker to the conditional to allow 0 value indexed to pass |
1783 | - if(is_array($returnValue) && (!empty($selectedValue) || (is_numeric($selectedValue) && $selectedValue == 0)) && isset($returnValue[$selectedValue]) ){ |
|
1783 | + if (is_array($returnValue) && (!empty($selectedValue) || (is_numeric($selectedValue) && $selectedValue == 0)) && isset($returnValue[$selectedValue])) { |
|
1784 | 1784 | return $returnValue[$selectedValue]; |
1785 | 1785 | } |
1786 | 1786 | |
@@ -1792,25 +1792,25 @@ discard block |
||
1792 | 1792 | static $num_grp_sep; |
1793 | 1793 | global $current_user, $sugar_config; |
1794 | 1794 | |
1795 | - if($dec_sep == null) { |
|
1795 | + if ($dec_sep == null) { |
|
1796 | 1796 | $user_dec_sep = $current_user->getPreference('dec_sep'); |
1797 | 1797 | $dec_sep = (empty($user_dec_sep) ? $sugar_config['default_decimal_seperator'] : $user_dec_sep); |
1798 | 1798 | } |
1799 | - if($num_grp_sep == null) { |
|
1799 | + if ($num_grp_sep == null) { |
|
1800 | 1800 | $user_num_grp_sep = $current_user->getPreference('num_grp_sep'); |
1801 | 1801 | $num_grp_sep = (empty($user_num_grp_sep) ? $sugar_config['default_number_grouping_seperator'] : $user_num_grp_sep); |
1802 | 1802 | } |
1803 | 1803 | |
1804 | - $num = preg_replace("'" . preg_quote($num_grp_sep) . "'", '', $num); |
|
1805 | - $num = preg_replace("'" . preg_quote($dec_sep) . "'", '.', $num); |
|
1804 | + $num = preg_replace("'".preg_quote($num_grp_sep)."'", '', $num); |
|
1805 | + $num = preg_replace("'".preg_quote($dec_sep)."'", '.', $num); |
|
1806 | 1806 | return $num; |
1807 | 1807 | |
1808 | 1808 | } |
1809 | 1809 | |
1810 | 1810 | function add_http($url) { |
1811 | - if(!preg_match("@://@i", $url)) { |
|
1811 | + if (!preg_match("@://@i", $url)) { |
|
1812 | 1812 | $scheme = "http"; |
1813 | - if(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') { |
|
1813 | + if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') { |
|
1814 | 1814 | $scheme = 'https'; |
1815 | 1815 | } |
1816 | 1816 | |
@@ -1864,10 +1864,10 @@ discard block |
||
1864 | 1864 | * @param bool cleanImg Flag to allow <img> tags to survive - only used by InboundEmail for inline images. |
1865 | 1865 | * @return array Array of matches, empty on clean string |
1866 | 1866 | */ |
1867 | -function clean_xss($str, $cleanImg=true) { |
|
1867 | +function clean_xss($str, $cleanImg = true) { |
|
1868 | 1868 | global $sugar_config; |
1869 | 1869 | |
1870 | - if(empty($sugar_config['email_xss'])) |
|
1870 | + if (empty($sugar_config['email_xss'])) |
|
1871 | 1871 | $sugar_config['email_xss'] = getDefaultXssTags(); |
1872 | 1872 | |
1873 | 1873 | $xsstags = unserialize(base64_decode($sugar_config['email_xss'])); |
@@ -1877,32 +1877,32 @@ discard block |
||
1877 | 1877 | $jsEvents .= "onmouseup|onmouseover|onmousedown|onmouseenter|onmouseleave|onmousemove|onload|onchange|"; |
1878 | 1878 | $jsEvents .= "onreset|onselect|onsubmit|onkeydown|onkeypress|onkeyup|onabort|onerror|ondragdrop"; |
1879 | 1879 | |
1880 | - $attribute_regex = "#\b({$jsEvents})\s*=\s*(?|(?!['\"])\S+|['\"].+?['\"])#sim"; |
|
1881 | - $javascript_regex = '@<[^/>][^>]+(expression\(|j\W*a\W*v\W*a|v\W*b\W*s\W*c\W*r|&#|/\*|\*/)[^>]*>@sim'; |
|
1882 | - $imgsrc_regex = '#<[^>]+src[^=]*=([^>]*?http(s)?://[^>]*)>#sim'; |
|
1883 | - $css_url = '#url\(.*\.\w+\)#'; |
|
1880 | + $attribute_regex = "#\b({$jsEvents})\s*=\s*(?|(?!['\"])\S+|['\"].+?['\"])#sim"; |
|
1881 | + $javascript_regex = '@<[^/>][^>]+(expression\(|j\W*a\W*v\W*a|v\W*b\W*s\W*c\W*r|&#|/\*|\*/)[^>]*>@sim'; |
|
1882 | + $imgsrc_regex = '#<[^>]+src[^=]*=([^>]*?http(s)?://[^>]*)>#sim'; |
|
1883 | + $css_url = '#url\(.*\.\w+\)#'; |
|
1884 | 1884 | |
1885 | 1885 | $tagsrex = '#<\/?(\w+)((?:\s+(?:\w|\w[\w-]*\w)(?:\s*=\s*(?:\".*?\"|\'.*?\'|[^\'\">\s]+))?)+\s*|\s*)\/?>#im'; |
1886 | 1886 | |
1887 | 1887 | $tagmatches = array(); |
1888 | 1888 | $matches = array(); |
1889 | 1889 | preg_match_all($tagsrex, $str, $tagmatches, PREG_PATTERN_ORDER); |
1890 | - foreach($tagmatches[1] as $no => $tag) { |
|
1891 | - if(in_array($tag, $xsstags)) { |
|
1890 | + foreach ($tagmatches[1] as $no => $tag) { |
|
1891 | + if (in_array($tag, $xsstags)) { |
|
1892 | 1892 | // dangerous tag - take out whole |
1893 | 1893 | $matches[] = $tagmatches[0][$no]; |
1894 | 1894 | continue; |
1895 | 1895 | } |
1896 | 1896 | $attrmatch = array(); |
1897 | 1897 | preg_match_all($attribute_regex, $tagmatches[2][$no], $attrmatch, PREG_PATTERN_ORDER); |
1898 | - if(!empty($attrmatch[0])) { |
|
1898 | + if (!empty($attrmatch[0])) { |
|
1899 | 1899 | $matches = array_merge($matches, $attrmatch[0]); |
1900 | 1900 | } |
1901 | 1901 | } |
1902 | 1902 | |
1903 | 1903 | $matches = array_merge($matches, xss_check_pattern($javascript_regex, $str)); |
1904 | 1904 | |
1905 | - if($cleanImg) { |
|
1905 | + if ($cleanImg) { |
|
1906 | 1906 | $matches = array_merge($matches, |
1907 | 1907 | xss_check_pattern($imgsrc_regex, $str) |
1908 | 1908 | ); |
@@ -1911,18 +1911,18 @@ discard block |
||
1911 | 1911 | // cn: bug 13498 - custom white-list of allowed domains that vet remote images |
1912 | 1912 | preg_match_all($css_url, $str, $cssUrlMatches, PREG_PATTERN_ORDER); |
1913 | 1913 | |
1914 | - if(isset($sugar_config['security_trusted_domains']) && !empty($sugar_config['security_trusted_domains']) && is_array($sugar_config['security_trusted_domains'])) { |
|
1915 | - if(is_array($cssUrlMatches) && count($cssUrlMatches) > 0) { |
|
1914 | + if (isset($sugar_config['security_trusted_domains']) && !empty($sugar_config['security_trusted_domains']) && is_array($sugar_config['security_trusted_domains'])) { |
|
1915 | + if (is_array($cssUrlMatches) && count($cssUrlMatches) > 0) { |
|
1916 | 1916 | // normalize whitelist |
1917 | - foreach($sugar_config['security_trusted_domains'] as $k => $v) { |
|
1917 | + foreach ($sugar_config['security_trusted_domains'] as $k => $v) { |
|
1918 | 1918 | $sugar_config['security_trusted_domains'][$k] = strtolower($v); |
1919 | 1919 | } |
1920 | 1920 | |
1921 | - foreach($cssUrlMatches[0] as $match) { |
|
1921 | + foreach ($cssUrlMatches[0] as $match) { |
|
1922 | 1922 | $domain = strtolower(substr(strstr($match, "://"), 3)); |
1923 | 1923 | $baseUrl = substr($domain, 0, strpos($domain, "/")); |
1924 | 1924 | |
1925 | - if(!in_array($baseUrl, $sugar_config['security_trusted_domains'])) { |
|
1925 | + if (!in_array($baseUrl, $sugar_config['security_trusted_domains'])) { |
|
1926 | 1926 | $matches[] = $match; |
1927 | 1927 | } |
1928 | 1928 | } |
@@ -1983,7 +1983,7 @@ discard block |
||
1983 | 1983 | if (isset($GLOBALS['log']) && is_object($GLOBALS['log'])) { |
1984 | 1984 | $GLOBALS['log']->fatal("SECURITY[$filter]: bad data passed in; string: {$str}"); |
1985 | 1985 | } |
1986 | - if ( $dieOnBadData ) { |
|
1986 | + if ($dieOnBadData) { |
|
1987 | 1987 | die("Bad data passed in; <a href=\"{$sugar_config['site_url']}\">Return to Home</a>"); |
1988 | 1988 | } |
1989 | 1989 | return false; |
@@ -1994,7 +1994,7 @@ discard block |
||
1994 | 1994 | } |
1995 | 1995 | |
1996 | 1996 | function clean_special_arguments() { |
1997 | - if(isset($_SERVER['PHP_SELF'])) { |
|
1997 | + if (isset($_SERVER['PHP_SELF'])) { |
|
1998 | 1998 | if (!empty($_SERVER['PHP_SELF'])) clean_string($_SERVER['PHP_SELF'], 'SAFED_GET'); |
1999 | 1999 | } |
2000 | 2000 | if (!empty($_REQUEST) && !empty($_REQUEST['login_theme'])) clean_string($_REQUEST['login_theme'], "STANDARD"); |
@@ -2024,12 +2024,12 @@ discard block |
||
2024 | 2024 | * cleans the given key in superglobals $_GET, $_POST, $_REQUEST |
2025 | 2025 | */ |
2026 | 2026 | function clean_superglobals($key, $filter = 'STANDARD') { |
2027 | - if(isset($_GET[$key])) clean_string($_GET[$key], $filter); |
|
2028 | - if(isset($_POST[$key])) clean_string($_POST[$key], $filter); |
|
2029 | - if(isset($_REQUEST[$key])) clean_string($_REQUEST[$key], $filter); |
|
2027 | + if (isset($_GET[$key])) clean_string($_GET[$key], $filter); |
|
2028 | + if (isset($_POST[$key])) clean_string($_POST[$key], $filter); |
|
2029 | + if (isset($_REQUEST[$key])) clean_string($_REQUEST[$key], $filter); |
|
2030 | 2030 | } |
2031 | 2031 | |
2032 | -function set_superglobals($key, $val){ |
|
2032 | +function set_superglobals($key, $val) { |
|
2033 | 2033 | $_GET[$key] = $val; |
2034 | 2034 | $_POST[$key] = $val; |
2035 | 2035 | $_REQUEST[$key] = $val; |
@@ -2040,7 +2040,7 @@ discard block |
||
2040 | 2040 | global $sugar_config; |
2041 | 2041 | global $RAW_REQUEST; |
2042 | 2042 | |
2043 | - if(get_magic_quotes_gpc()) { |
|
2043 | + if (get_magic_quotes_gpc()) { |
|
2044 | 2044 | // magic quotes screw up data, we'd have to clean up |
2045 | 2045 | $RAW_REQUEST = array_map("cleanup_slashes", $_REQUEST); |
2046 | 2046 | } else { |
@@ -2059,17 +2059,17 @@ discard block |
||
2059 | 2059 | } |
2060 | 2060 | |
2061 | 2061 | // PHP cannot stomp out superglobals reliably |
2062 | - foreach($post as $k => $v) { $_POST[$k] = $v; } |
|
2063 | - foreach($get as $k => $v) { $_GET[$k] = $v; } |
|
2064 | - foreach($req as $k => $v) { |
|
2062 | + foreach ($post as $k => $v) { $_POST[$k] = $v; } |
|
2063 | + foreach ($get as $k => $v) { $_GET[$k] = $v; } |
|
2064 | + foreach ($req as $k => $v) { |
|
2065 | 2065 | $_REQUEST[$k] = $v; |
2066 | 2066 | |
2067 | 2067 | //ensure the keys are safe as well. If mbstring encoding translation is on, the post keys don't |
2068 | 2068 | //get translated, so scrub the data but don't die |
2069 | - if(ini_get('mbstring.encoding_translation')==='1'){ |
|
2070 | - securexsskey($k,false); |
|
2071 | - }else{ |
|
2072 | - securexsskey($k,true); |
|
2069 | + if (ini_get('mbstring.encoding_translation') === '1') { |
|
2070 | + securexsskey($k, false); |
|
2071 | + } else { |
|
2072 | + securexsskey($k, true); |
|
2073 | 2073 | } |
2074 | 2074 | |
2075 | 2075 | } |
@@ -2088,8 +2088,8 @@ discard block |
||
2088 | 2088 | if (isset($_REQUEST['offset'])) clean_string($_REQUEST['offset']); |
2089 | 2089 | if (isset($_REQUEST['stamp'])) clean_string($_REQUEST['stamp']); |
2090 | 2090 | |
2091 | - if(isset($_REQUEST['lvso'])){ |
|
2092 | - set_superglobals('lvso', (strtolower($_REQUEST['lvso']) === 'desc')?'desc':'asc'); |
|
2091 | + if (isset($_REQUEST['lvso'])) { |
|
2092 | + set_superglobals('lvso', (strtolower($_REQUEST['lvso']) === 'desc') ? 'desc' : 'asc'); |
|
2093 | 2093 | } |
2094 | 2094 | // Clean "offset" and "order_by" parameters in URL |
2095 | 2095 | foreach ($_REQUEST as $key => $val) { |
@@ -2118,27 +2118,27 @@ discard block |
||
2118 | 2118 | } |
2119 | 2119 | |
2120 | 2120 | function securexss($value) { |
2121 | - if(is_array($value)){ |
|
2121 | + if (is_array($value)) { |
|
2122 | 2122 | $new = array(); |
2123 | - foreach($value as $key=>$val){ |
|
2123 | + foreach ($value as $key=>$val) { |
|
2124 | 2124 | $new[$key] = securexss($val); |
2125 | 2125 | } |
2126 | 2126 | return $new; |
2127 | 2127 | } |
2128 | - static $xss_cleanup= array(""" => "&", '"' =>'"', "'" => ''' , '<' =>'<' , '>'=>'>'); |
|
2128 | + static $xss_cleanup = array(""" => "&", '"' =>'"', "'" => ''', '<' =>'<', '>'=>'>'); |
|
2129 | 2129 | $value = preg_replace(array('/javascript:/i', '/\0/'), array('java script:', ''), $value); |
2130 | 2130 | $value = preg_replace('/javascript:/i', 'java script:', $value); |
2131 | 2131 | return str_replace(array_keys($xss_cleanup), array_values($xss_cleanup), $value); |
2132 | 2132 | } |
2133 | 2133 | |
2134 | -function securexsskey($value, $die=true){ |
|
2134 | +function securexsskey($value, $die = true) { |
|
2135 | 2135 | global $sugar_config; |
2136 | 2136 | $matches = array(); |
2137 | 2137 | preg_match('/[\'"<>]/', $value, $matches); |
2138 | - if(!empty($matches)){ |
|
2139 | - if($die){ |
|
2138 | + if (!empty($matches)) { |
|
2139 | + if ($die) { |
|
2140 | 2140 | die("Bad data passed in; <a href=\"{$sugar_config['site_url']}\">Return to Home</a>"); |
2141 | - }else{ |
|
2141 | + } else { |
|
2142 | 2142 | unset($_REQUEST[$value]); |
2143 | 2143 | unset($_POST[$value]); |
2144 | 2144 | unset($_GET[$value]); |
@@ -2146,15 +2146,15 @@ discard block |
||
2146 | 2146 | } |
2147 | 2147 | } |
2148 | 2148 | |
2149 | -function preprocess_param($value){ |
|
2150 | - if(is_string($value)){ |
|
2151 | - if(get_magic_quotes_gpc() == 1){ |
|
2149 | +function preprocess_param($value) { |
|
2150 | + if (is_string($value)) { |
|
2151 | + if (get_magic_quotes_gpc() == 1) { |
|
2152 | 2152 | $value = stripslashes($value); |
2153 | 2153 | } |
2154 | 2154 | |
2155 | 2155 | $value = securexss($value); |
2156 | 2156 | } |
2157 | - else if (is_array($value)){ |
|
2157 | + else if (is_array($value)) { |
|
2158 | 2158 | foreach ($value as $key => $element) { |
2159 | 2159 | $value[$key] = preprocess_param($element); |
2160 | 2160 | } |
@@ -2165,40 +2165,40 @@ discard block |
||
2165 | 2165 | |
2166 | 2166 | function cleanup_slashes($value) |
2167 | 2167 | { |
2168 | - if(is_string($value)) return stripslashes($value); |
|
2168 | + if (is_string($value)) return stripslashes($value); |
|
2169 | 2169 | return $value; |
2170 | 2170 | } |
2171 | 2171 | |
2172 | 2172 | |
2173 | -function set_register_value($category, $name, $value){ |
|
2173 | +function set_register_value($category, $name, $value) { |
|
2174 | 2174 | return sugar_cache_put("{$category}:{$name}", $value); |
2175 | 2175 | } |
2176 | 2176 | |
2177 | -function get_register_value($category,$name){ |
|
2177 | +function get_register_value($category, $name) { |
|
2178 | 2178 | return sugar_cache_retrieve("{$category}:{$name}"); |
2179 | 2179 | } |
2180 | 2180 | |
2181 | -function clear_register_value($category,$name){ |
|
2181 | +function clear_register_value($category, $name) { |
|
2182 | 2182 | return sugar_cache_clear("{$category}:{$name}"); |
2183 | 2183 | } |
2184 | 2184 | // this function cleans id's when being imported |
2185 | 2185 | function convert_id($string) |
2186 | 2186 | { |
2187 | - return preg_replace_callback( '|[^A-Za-z0-9\-]|', |
|
2187 | + return preg_replace_callback('|[^A-Za-z0-9\-]|', |
|
2188 | 2188 | create_function( |
2189 | 2189 | // single quotes are essential here, |
2190 | 2190 | // or alternative escape all $ as \$ |
2191 | 2191 | '$matches', |
2192 | 2192 | 'return ord($matches[0]);' |
2193 | - ) ,$string); |
|
2193 | + ), $string); |
|
2194 | 2194 | } |
2195 | 2195 | |
2196 | 2196 | /** |
2197 | 2197 | * @deprecated use SugarTheme::getImage() |
2198 | 2198 | */ |
2199 | -function get_image($image,$other_attributes,$width="",$height="",$ext='.gif',$alt="") |
|
2199 | +function get_image($image, $other_attributes, $width = "", $height = "", $ext = '.gif', $alt = "") |
|
2200 | 2200 | { |
2201 | - return SugarThemeRegistry::current()->getImage(basename($image), $other_attributes, empty($width) ? null : $width, empty($height) ? null : $height, $ext, $alt ); |
|
2201 | + return SugarThemeRegistry::current()->getImage(basename($image), $other_attributes, empty($width) ? null : $width, empty($height) ? null : $height, $ext, $alt); |
|
2202 | 2202 | } |
2203 | 2203 | /** |
2204 | 2204 | * @deprecated use SugarTheme::getImageURL() |
@@ -2208,54 +2208,54 @@ discard block |
||
2208 | 2208 | return SugarThemeRegistry::current()->getImageURL($image_name); |
2209 | 2209 | } |
2210 | 2210 | |
2211 | -function getWebPath($relative_path){ |
|
2211 | +function getWebPath($relative_path) { |
|
2212 | 2212 | //if it has a :// then it isn't a relative path |
2213 | - if(substr_count($relative_path, '://') > 0) return $relative_path; |
|
2214 | - if(defined('TEMPLATE_URL'))$relative_path = SugarTemplateUtilities::getWebPath($relative_path); |
|
2213 | + if (substr_count($relative_path, '://') > 0) return $relative_path; |
|
2214 | + if (defined('TEMPLATE_URL'))$relative_path = SugarTemplateUtilities::getWebPath($relative_path); |
|
2215 | 2215 | return $relative_path; |
2216 | 2216 | } |
2217 | 2217 | |
2218 | -function getVersionedPath($path, $additional_attrs='') |
|
2218 | +function getVersionedPath($path, $additional_attrs = '') |
|
2219 | 2219 | { |
2220 | - if(empty($GLOBALS['sugar_config']['js_custom_version'])) $GLOBALS['sugar_config']['js_custom_version'] = 1; |
|
2221 | - $js_version_key = isset($GLOBALS['js_version_key'])?$GLOBALS['js_version_key']:''; |
|
2222 | - if(inDeveloperMode()) { |
|
2220 | + if (empty($GLOBALS['sugar_config']['js_custom_version'])) $GLOBALS['sugar_config']['js_custom_version'] = 1; |
|
2221 | + $js_version_key = isset($GLOBALS['js_version_key']) ? $GLOBALS['js_version_key'] : ''; |
|
2222 | + if (inDeveloperMode()) { |
|
2223 | 2223 | static $rand; |
2224 | - if(empty($rand)) $rand = mt_rand(); |
|
2224 | + if (empty($rand)) $rand = mt_rand(); |
|
2225 | 2225 | $dev = $rand; |
2226 | 2226 | } else { |
2227 | 2227 | $dev = ''; |
2228 | 2228 | } |
2229 | - if(is_array($additional_attrs)) { |
|
2230 | - $additional_attrs = join("|",$additional_attrs); |
|
2229 | + if (is_array($additional_attrs)) { |
|
2230 | + $additional_attrs = join("|", $additional_attrs); |
|
2231 | 2231 | } |
2232 | 2232 | // cutting 2 last chars here because since md5 is 32 chars, it's always == |
2233 | 2233 | $str = substr(base64_encode(md5("$js_version_key|{$GLOBALS['sugar_config']['js_custom_version']}|$dev|$additional_attrs", true)), 0, -2); |
2234 | 2234 | // remove / - it confuses some parsers |
2235 | 2235 | $str = strtr($str, '/+', '-_'); |
2236 | - if(empty($path)) return $str; |
|
2236 | + if (empty($path)) return $str; |
|
2237 | 2237 | |
2238 | - return $path . "?v=$str"; |
|
2238 | + return $path."?v=$str"; |
|
2239 | 2239 | } |
2240 | 2240 | |
2241 | -function getVersionedScript($path, $additional_attrs='') |
|
2241 | +function getVersionedScript($path, $additional_attrs = '') |
|
2242 | 2242 | { |
2243 | 2243 | return '<script type="text/javascript" src="'.getVersionedPath($path, $additional_attrs).'"></script>'; |
2244 | 2244 | } |
2245 | 2245 | |
2246 | -function getJSPath($relative_path, $additional_attrs='') |
|
2246 | +function getJSPath($relative_path, $additional_attrs = '') |
|
2247 | 2247 | { |
2248 | - if(defined('TEMPLATE_URL'))$relative_path = SugarTemplateUtilities::getWebPath($relative_path); |
|
2249 | - return getVersionedPath($relative_path).(!empty($additional_attrs)?"&$additional_attrs":""); |
|
2248 | + if (defined('TEMPLATE_URL'))$relative_path = SugarTemplateUtilities::getWebPath($relative_path); |
|
2249 | + return getVersionedPath($relative_path).(!empty($additional_attrs) ? "&$additional_attrs" : ""); |
|
2250 | 2250 | } |
2251 | 2251 | |
2252 | -function getSWFPath($relative_path, $additional_params=''){ |
|
2252 | +function getSWFPath($relative_path, $additional_params = '') { |
|
2253 | 2253 | $path = $relative_path; |
2254 | - if (!empty($additional_params)){ |
|
2255 | - $path .= '?' . $additional_params; |
|
2254 | + if (!empty($additional_params)) { |
|
2255 | + $path .= '?'.$additional_params; |
|
2256 | 2256 | } |
2257 | - if (defined('TEMPLATE_URL')){ |
|
2258 | - $path = TEMPLATE_URL . '/' . $path; |
|
2257 | + if (defined('TEMPLATE_URL')) { |
|
2258 | + $path = TEMPLATE_URL.'/'.$path; |
|
2259 | 2259 | } |
2260 | 2260 | return $path; |
2261 | 2261 | } |
@@ -2266,25 +2266,25 @@ discard block |
||
2266 | 2266 | |
2267 | 2267 | function getSQLDate($date_str) |
2268 | 2268 | { |
2269 | - if (preg_match('/^(\d{1,2})-(\d{1,2})-(\d{4})$/',$date_str,$match)) |
|
2269 | + if (preg_match('/^(\d{1,2})-(\d{1,2})-(\d{4})$/', $date_str, $match)) |
|
2270 | 2270 | { |
2271 | - if ( strlen($match[2]) == 1) |
|
2271 | + if (strlen($match[2]) == 1) |
|
2272 | 2272 | { |
2273 | 2273 | $match[2] = "0".$match[2]; |
2274 | 2274 | } |
2275 | - if ( strlen($match[1]) == 1) |
|
2275 | + if (strlen($match[1]) == 1) |
|
2276 | 2276 | { |
2277 | 2277 | $match[1] = "0".$match[1]; |
2278 | 2278 | } |
2279 | 2279 | return "{$match[3]}-{$match[1]}-{$match[2]}"; |
2280 | 2280 | } |
2281 | - else if (preg_match('/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/',$date_str,$match)) |
|
2281 | + else if (preg_match('/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/', $date_str, $match)) |
|
2282 | 2282 | { |
2283 | - if ( strlen($match[2]) == 1) |
|
2283 | + if (strlen($match[2]) == 1) |
|
2284 | 2284 | { |
2285 | 2285 | $match[2] = "0".$match[2]; |
2286 | 2286 | } |
2287 | - if ( strlen($match[1]) == 1) |
|
2287 | + if (strlen($match[1]) == 1) |
|
2288 | 2288 | { |
2289 | 2289 | $match[1] = "0".$match[1]; |
2290 | 2290 | } |
@@ -2296,15 +2296,15 @@ discard block |
||
2296 | 2296 | } |
2297 | 2297 | } |
2298 | 2298 | |
2299 | -function clone_history(&$db, $from_id,$to_id, $to_type) |
|
2299 | +function clone_history(&$db, $from_id, $to_id, $to_type) |
|
2300 | 2300 | { |
2301 | 2301 | global $timedate; |
2302 | - $old_note_id=null; |
|
2303 | - $old_filename=null; |
|
2302 | + $old_note_id = null; |
|
2303 | + $old_filename = null; |
|
2304 | 2304 | require_once('include/upload_file.php'); |
2305 | 2305 | $tables = array('calls'=>'Call', 'meetings'=>'Meeting', 'notes'=>'Note', 'tasks'=>'Task'); |
2306 | 2306 | |
2307 | - $location=array('Email'=>"modules/Emails/Email.php", |
|
2307 | + $location = array('Email'=>"modules/Emails/Email.php", |
|
2308 | 2308 | 'Call'=>"modules/Calls/Call.php", |
2309 | 2309 | 'Meeting'=>"modules/Meetings/Meeting.php", |
2310 | 2310 | 'Note'=>"modules/Notes/Note.php", |
@@ -2312,7 +2312,7 @@ discard block |
||
2312 | 2312 | ); |
2313 | 2313 | |
2314 | 2314 | |
2315 | - foreach($tables as $table=>$bean_class) |
|
2315 | + foreach ($tables as $table=>$bean_class) |
|
2316 | 2316 | { |
2317 | 2317 | |
2318 | 2318 | if (!class_exists($bean_class)) |
@@ -2320,48 +2320,48 @@ discard block |
||
2320 | 2320 | require_once($location[$bean_class]); |
2321 | 2321 | } |
2322 | 2322 | |
2323 | - $bProcessingNotes=false; |
|
2324 | - if ($table=='notes') |
|
2323 | + $bProcessingNotes = false; |
|
2324 | + if ($table == 'notes') |
|
2325 | 2325 | { |
2326 | - $bProcessingNotes=true; |
|
2326 | + $bProcessingNotes = true; |
|
2327 | 2327 | } |
2328 | 2328 | $query = "SELECT id FROM $table WHERE parent_id='$from_id'"; |
2329 | 2329 | $results = $db->query($query); |
2330 | - while($row = $db->fetchByAssoc($results)) |
|
2330 | + while ($row = $db->fetchByAssoc($results)) |
|
2331 | 2331 | { |
2332 | 2332 | //retrieve existing record. |
2333 | - $bean= new $bean_class(); |
|
2333 | + $bean = new $bean_class(); |
|
2334 | 2334 | $bean->retrieve($row['id']); |
2335 | 2335 | //process for new instance. |
2336 | 2336 | if ($bProcessingNotes) |
2337 | 2337 | { |
2338 | - $old_note_id=$row['id']; |
|
2339 | - $old_filename=$bean->filename; |
|
2338 | + $old_note_id = $row['id']; |
|
2339 | + $old_filename = $bean->filename; |
|
2340 | 2340 | } |
2341 | - $bean->id=null; |
|
2342 | - $bean->parent_id=$to_id; |
|
2343 | - $bean->parent_type=$to_type; |
|
2344 | - if ($to_type=='Contacts' and in_array('contact_id',$bean->column_fields)) |
|
2341 | + $bean->id = null; |
|
2342 | + $bean->parent_id = $to_id; |
|
2343 | + $bean->parent_type = $to_type; |
|
2344 | + if ($to_type == 'Contacts' and in_array('contact_id', $bean->column_fields)) |
|
2345 | 2345 | { |
2346 | - $bean->contact_id=$to_id; |
|
2346 | + $bean->contact_id = $to_id; |
|
2347 | 2347 | } |
2348 | 2348 | $bean->update_date_modified = false; |
2349 | 2349 | $bean->update_modified_by = false; |
2350 | - if(isset($bean->date_modified)) |
|
2350 | + if (isset($bean->date_modified)) |
|
2351 | 2351 | $bean->date_modified = $timedate->to_db($bean->date_modified); |
2352 | - if(isset($bean->date_entered)) |
|
2352 | + if (isset($bean->date_entered)) |
|
2353 | 2353 | $bean->date_entered = $timedate->to_db($bean->date_entered); |
2354 | 2354 | //save |
2355 | - $new_id=$bean->save(); |
|
2355 | + $new_id = $bean->save(); |
|
2356 | 2356 | |
2357 | 2357 | //duplicate the file now. for notes. |
2358 | 2358 | if ($bProcessingNotes && !empty($old_filename)) |
2359 | 2359 | { |
2360 | - UploadFile::duplicate_file($old_note_id,$new_id,$old_filename); |
|
2360 | + UploadFile::duplicate_file($old_note_id, $new_id, $old_filename); |
|
2361 | 2361 | } |
2362 | 2362 | //reset the values needed for attachment duplication. |
2363 | - $old_note_id=null; |
|
2364 | - $old_filename=null; |
|
2363 | + $old_note_id = null; |
|
2364 | + $old_filename = null; |
|
2365 | 2365 | } |
2366 | 2366 | } |
2367 | 2367 | } |
@@ -2369,11 +2369,11 @@ discard block |
||
2369 | 2369 | function values_to_keys($array) |
2370 | 2370 | { |
2371 | 2371 | $new_array = array(); |
2372 | - if(!is_array($array)) |
|
2372 | + if (!is_array($array)) |
|
2373 | 2373 | { |
2374 | 2374 | return $new_array; |
2375 | 2375 | } |
2376 | - foreach($array as $arr){ |
|
2376 | + foreach ($array as $arr) { |
|
2377 | 2377 | $new_array[$arr] = $arr; |
2378 | 2378 | } |
2379 | 2379 | return $new_array; |
@@ -2381,7 +2381,7 @@ discard block |
||
2381 | 2381 | |
2382 | 2382 | function clone_relationship(&$db, $tables = array(), $from_column, $from_id, $to_id) |
2383 | 2383 | { |
2384 | - foreach($tables as $table) |
|
2384 | + foreach ($tables as $table) |
|
2385 | 2385 | { |
2386 | 2386 | |
2387 | 2387 | if ($table == 'emails_beans') { |
@@ -2390,27 +2390,27 @@ discard block |
||
2390 | 2390 | $query = "SELECT * FROM $table WHERE $from_column='$from_id'"; |
2391 | 2391 | } |
2392 | 2392 | $results = $db->query($query); |
2393 | - while($row = $db->fetchByAssoc($results)) |
|
2393 | + while ($row = $db->fetchByAssoc($results)) |
|
2394 | 2394 | { |
2395 | 2395 | $query = "INSERT INTO $table "; |
2396 | 2396 | $names = ''; |
2397 | 2397 | $values = ''; |
2398 | 2398 | $row[$from_column] = $to_id; |
2399 | 2399 | $row['id'] = create_guid(); |
2400 | - if ($table=='emails_beans') { |
|
2401 | - $row['bean_module'] =='Contacts'; |
|
2400 | + if ($table == 'emails_beans') { |
|
2401 | + $row['bean_module'] == 'Contacts'; |
|
2402 | 2402 | } |
2403 | 2403 | |
2404 | - foreach($row as $name=>$value) |
|
2404 | + foreach ($row as $name=>$value) |
|
2405 | 2405 | { |
2406 | 2406 | |
2407 | - if(empty($names)) |
|
2407 | + if (empty($names)) |
|
2408 | 2408 | { |
2409 | 2409 | $names .= $name; |
2410 | 2410 | $values .= "'$value'"; |
2411 | 2411 | } else |
2412 | 2412 | { |
2413 | - $names .= ', '. $name; |
|
2413 | + $names .= ', '.$name; |
|
2414 | 2414 | $values .= ", '$value'"; |
2415 | 2415 | } |
2416 | 2416 | } |
@@ -2423,9 +2423,9 @@ discard block |
||
2423 | 2423 | function get_unlinked_email_query($type, $bean) { |
2424 | 2424 | global $current_user; |
2425 | 2425 | |
2426 | - $return_array['select']='SELECT emails.id '; |
|
2427 | - $return_array['from']='FROM emails '; |
|
2428 | - $return_array['where']=""; |
|
2426 | + $return_array['select'] = 'SELECT emails.id '; |
|
2427 | + $return_array['from'] = 'FROM emails '; |
|
2428 | + $return_array['where'] = ""; |
|
2429 | 2429 | $return_array['join'] = " JOIN (select DISTINCT email_id from emails_email_addr_rel eear |
2430 | 2430 | |
2431 | 2431 | join email_addr_bean_rel eabr on eabr.bean_id ='$bean->id' and eabr.bean_module = '$bean->module_dir' and |
@@ -2439,17 +2439,17 @@ discard block |
||
2439 | 2439 | return $return_array; |
2440 | 2440 | } |
2441 | 2441 | |
2442 | - return $return_array['select'] . $return_array['from'] . $return_array['where'] . $return_array['join'] ; |
|
2442 | + return $return_array['select'].$return_array['from'].$return_array['where'].$return_array['join']; |
|
2443 | 2443 | } // fn |
2444 | 2444 | |
2445 | 2445 | function get_emails_by_assign_or_link($params) |
2446 | 2446 | { |
2447 | 2447 | $relation = $params['link']; |
2448 | 2448 | $bean = $GLOBALS['app']->controller->bean; |
2449 | - if(empty($bean->$relation)) { |
|
2449 | + if (empty($bean->$relation)) { |
|
2450 | 2450 | $bean->load_relationship($relation); |
2451 | 2451 | } |
2452 | - if(empty($bean->$relation)) { |
|
2452 | + if (empty($bean->$relation)) { |
|
2453 | 2453 | $GLOBALS['log']->error("Bad relation '$relation' for bean '{$bean->object_name}' id '{$bean->id}'"); |
2454 | 2454 | return array(); |
2455 | 2455 | } |
@@ -2459,7 +2459,7 @@ discard block |
||
2459 | 2459 | 'join_table_link_alias' => 'linkt', |
2460 | 2460 | )); |
2461 | 2461 | $rel_join = str_replace("{$bean->table_name}.id", "'{$bean->id}'", $rel_join); |
2462 | - $return_array['select']='SELECT DISTINCT emails.id '; |
|
2462 | + $return_array['select'] = 'SELECT DISTINCT emails.id '; |
|
2463 | 2463 | $return_array['from'] = "FROM emails "; |
2464 | 2464 | |
2465 | 2465 | $return_array['join'] = array(); |
@@ -2531,15 +2531,15 @@ discard block |
||
2531 | 2531 | "; |
2532 | 2532 | } |
2533 | 2533 | |
2534 | - $return_array['join'] = " INNER JOIN (" . implode(" UNION ", $return_array['join']). ") email_ids ON emails.id=email_ids.email_id "; |
|
2534 | + $return_array['join'] = " INNER JOIN (".implode(" UNION ", $return_array['join']).") email_ids ON emails.id=email_ids.email_id "; |
|
2535 | 2535 | |
2536 | - $return_array['where']=" WHERE emails.deleted=0 "; |
|
2536 | + $return_array['where'] = " WHERE emails.deleted=0 "; |
|
2537 | 2537 | |
2538 | 2538 | //$return_array['join'] = ''; |
2539 | 2539 | $return_array['join_tables'][0] = ''; |
2540 | 2540 | |
2541 | - if($bean->object_name == "Case" && !empty($bean->case_number)) { |
|
2542 | - $where = str_replace("%1", $bean->case_number, $bean->getEmailSubjectMacro()); |
|
2541 | + if ($bean->object_name == "Case" && !empty($bean->case_number)) { |
|
2542 | + $where = str_replace("%1", $bean->case_number, $bean->getEmailSubjectMacro()); |
|
2543 | 2543 | $return_array["where"] .= "\n AND (email_ids.source = 'direct' OR emails.name LIKE '%$where%')"; |
2544 | 2544 | } |
2545 | 2545 | |
@@ -2556,16 +2556,16 @@ discard block |
||
2556 | 2556 | return empty($value) && $value != '0'; |
2557 | 2557 | } |
2558 | 2558 | |
2559 | -function get_bean_select_array($add_blank=true, $bean_name, $display_columns, $where='', $order_by='', $blank_is_none=false) |
|
2559 | +function get_bean_select_array($add_blank = true, $bean_name, $display_columns, $where = '', $order_by = '', $blank_is_none = false) |
|
2560 | 2560 | { |
2561 | 2561 | global $beanFiles; |
2562 | 2562 | require_once($beanFiles[$bean_name]); |
2563 | 2563 | $focus = new $bean_name(); |
2564 | 2564 | $user_array = array(); |
2565 | 2565 | |
2566 | - $key = ($bean_name == 'EmailTemplate') ? $bean_name : $bean_name . $display_columns. $where . $order_by; |
|
2567 | - $user_array = get_register_value('select_array', $key ); |
|
2568 | - if(!$user_array) |
|
2566 | + $key = ($bean_name == 'EmailTemplate') ? $bean_name : $bean_name.$display_columns.$where.$order_by; |
|
2567 | + $user_array = get_register_value('select_array', $key); |
|
2568 | + if (!$user_array) |
|
2569 | 2569 | { |
2570 | 2570 | |
2571 | 2571 | $db = DBManagerFactory::getInstance(); |
@@ -2573,16 +2573,16 @@ discard block |
||
2573 | 2573 | $temp_result = Array(); |
2574 | 2574 | $query = "SELECT {$focus->table_name}.id, {$display_columns} as display from {$focus->table_name} "; |
2575 | 2575 | $query .= "where "; |
2576 | - if ( $where != '') |
|
2576 | + if ($where != '') |
|
2577 | 2577 | { |
2578 | 2578 | $query .= $where." AND "; |
2579 | 2579 | } |
2580 | 2580 | |
2581 | - $query .= " {$focus->table_name}.deleted=0"; |
|
2581 | + $query .= " {$focus->table_name}.deleted=0"; |
|
2582 | 2582 | |
2583 | 2583 | /* BEGIN - SECURITY GROUPS */ |
2584 | 2584 | global $current_user, $sugar_config; |
2585 | - if($focus->module_dir == 'Users' && !is_admin($current_user) |
|
2585 | + if ($focus->module_dir == 'Users' && !is_admin($current_user) |
|
2586 | 2586 | && isset($sugar_config['securitysuite_filter_user_list']) |
2587 | 2587 | && $sugar_config['securitysuite_filter_user_list'] == true |
2588 | 2588 | ) { |
@@ -2590,20 +2590,20 @@ discard block |
||
2590 | 2590 | $group_where = SecurityGroup::getGroupUsersWhere($current_user->id); |
2591 | 2591 | $query .= " AND (".$group_where.") "; |
2592 | 2592 | } else |
2593 | - if($focus->bean_implements('ACL') && ACLController::requireSecurityGroup($focus->module_dir, 'list') ) |
|
2593 | + if ($focus->bean_implements('ACL') && ACLController::requireSecurityGroup($focus->module_dir, 'list')) |
|
2594 | 2594 | { |
2595 | 2595 | require_once('modules/SecurityGroups/SecurityGroup.php'); |
2596 | 2596 | $owner_where = $focus->getOwnerWhere($current_user->id); |
2597 | - $group_where = SecurityGroup::getGroupWhere($focus->table_name,$focus->module_dir,$current_user->id); |
|
2598 | - if(!empty($owner_where)){ |
|
2599 | - $query .= " AND (". $owner_where." or ".$group_where.") "; |
|
2597 | + $group_where = SecurityGroup::getGroupWhere($focus->table_name, $focus->module_dir, $current_user->id); |
|
2598 | + if (!empty($owner_where)) { |
|
2599 | + $query .= " AND (".$owner_where." or ".$group_where.") "; |
|
2600 | 2600 | } else { |
2601 | - $query .= ' AND '. $group_where; |
|
2601 | + $query .= ' AND '.$group_where; |
|
2602 | 2602 | } |
2603 | 2603 | } |
2604 | 2604 | /* END - SECURITY GROUPS */ |
2605 | 2605 | |
2606 | - if ( $order_by != '') |
|
2606 | + if ($order_by != '') |
|
2607 | 2607 | { |
2608 | 2608 | $query .= " order by {$focus->table_name}.{$order_by}"; |
2609 | 2609 | } |
@@ -2611,9 +2611,9 @@ discard block |
||
2611 | 2611 | $GLOBALS['log']->debug("get_user_array query: $query"); |
2612 | 2612 | $result = $db->query($query, true, "Error filling in user array: "); |
2613 | 2613 | |
2614 | - if ($add_blank==true){ |
|
2614 | + if ($add_blank == true) { |
|
2615 | 2615 | // Add in a blank row |
2616 | - if($blank_is_none == true) { // set 'blank row' to "--None--" |
|
2616 | + if ($blank_is_none == true) { // set 'blank row' to "--None--" |
|
2617 | 2617 | global $app_strings; |
2618 | 2618 | $temp_result[''] = $app_strings['LBL_NONE']; |
2619 | 2619 | } else { |
@@ -2622,13 +2622,13 @@ discard block |
||
2622 | 2622 | } |
2623 | 2623 | |
2624 | 2624 | // Get the id and the name. |
2625 | - while($row = $db->fetchByAssoc($result)) |
|
2625 | + while ($row = $db->fetchByAssoc($result)) |
|
2626 | 2626 | { |
2627 | 2627 | $temp_result[$row['id']] = $row['display']; |
2628 | 2628 | } |
2629 | 2629 | |
2630 | 2630 | $user_array = $temp_result; |
2631 | - set_register_value('select_array', $key ,$temp_result); |
|
2631 | + set_register_value('select_array', $key, $temp_result); |
|
2632 | 2632 | } |
2633 | 2633 | |
2634 | 2634 | return $user_array; |
@@ -2646,21 +2646,21 @@ discard block |
||
2646 | 2646 | global $modListHeader; |
2647 | 2647 | $returnArray = array(); |
2648 | 2648 | |
2649 | - foreach($listArray as $optionName => $optionVal) |
|
2649 | + foreach ($listArray as $optionName => $optionVal) |
|
2650 | 2650 | { |
2651 | - if(array_key_exists($optionName, $modListHeader)) |
|
2651 | + if (array_key_exists($optionName, $modListHeader)) |
|
2652 | 2652 | { |
2653 | 2653 | $returnArray[$optionName] = $optionVal; |
2654 | 2654 | } |
2655 | 2655 | |
2656 | 2656 | // special case for projects |
2657 | - if(array_key_exists('Project', $modListHeader)) |
|
2657 | + if (array_key_exists('Project', $modListHeader)) |
|
2658 | 2658 | { |
2659 | 2659 | $returnArray['ProjectTask'] = $listArray['ProjectTask']; |
2660 | 2660 | } |
2661 | 2661 | } |
2662 | - $acldenied = ACLController::disabledModuleList($listArray,false); |
|
2663 | - foreach($acldenied as $denied){ |
|
2662 | + $acldenied = ACLController::disabledModuleList($listArray, false); |
|
2663 | + foreach ($acldenied as $denied) { |
|
2664 | 2664 | unset($returnArray[$denied]); |
2665 | 2665 | } |
2666 | 2666 | asort($returnArray); |
@@ -2668,21 +2668,21 @@ discard block |
||
2668 | 2668 | return $returnArray; |
2669 | 2669 | } |
2670 | 2670 | |
2671 | -function display_notice($msg = false){ |
|
2671 | +function display_notice($msg = false) { |
|
2672 | 2672 | global $error_notice; |
2673 | 2673 | //no error notice - lets just display the error to the user |
2674 | - if(!isset($error_notice)){ |
|
2675 | - echo '<br>'.$msg . '<br>'; |
|
2676 | - }else{ |
|
2677 | - $error_notice .= $msg . '<br>'; |
|
2674 | + if (!isset($error_notice)) { |
|
2675 | + echo '<br>'.$msg.'<br>'; |
|
2676 | + } else { |
|
2677 | + $error_notice .= $msg.'<br>'; |
|
2678 | 2678 | } |
2679 | 2679 | } |
2680 | 2680 | |
2681 | 2681 | /* checks if it is a number that at least has the plus at the beginning. |
2682 | 2682 | */ |
2683 | -function skype_formatted($number){ |
|
2683 | +function skype_formatted($number) { |
|
2684 | 2684 | //kbrill - BUG #15375 |
2685 | - if(isset($_REQUEST['action']) && $_REQUEST['action']=="Popup") { |
|
2685 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == "Popup") { |
|
2686 | 2686 | return false; |
2687 | 2687 | } else { |
2688 | 2688 | return substr($number, 0, 1) == '+' || substr($number, 0, 2) == '00' || substr($number, 0, 3) == '011'; |
@@ -2691,7 +2691,7 @@ discard block |
||
2691 | 2691 | } |
2692 | 2692 | |
2693 | 2693 | function format_skype($number) { |
2694 | - return preg_replace('/[^\+0-9]/','',$number); |
|
2694 | + return preg_replace('/[^\+0-9]/', '', $number); |
|
2695 | 2695 | } |
2696 | 2696 | |
2697 | 2697 | function insert_charset_header() { |
@@ -2701,23 +2701,23 @@ discard block |
||
2701 | 2701 | function getCurrentURL() |
2702 | 2702 | { |
2703 | 2703 | $href = "http:"; |
2704 | - if(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') |
|
2704 | + if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') |
|
2705 | 2705 | { |
2706 | 2706 | $href = 'https:'; |
2707 | 2707 | } |
2708 | 2708 | |
2709 | - $href.= "//".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING']; |
|
2709 | + $href .= "//".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING']; |
|
2710 | 2710 | return $href; |
2711 | 2711 | } |
2712 | 2712 | |
2713 | 2713 | function javascript_escape($str) { |
2714 | 2714 | $new_str = ''; |
2715 | 2715 | |
2716 | - for($i = 0; $i < strlen($str); $i++) { |
|
2716 | + for ($i = 0; $i < strlen($str); $i++) { |
|
2717 | 2717 | |
2718 | - if(ord(substr($str, $i, 1))==10){ |
|
2718 | + if (ord(substr($str, $i, 1)) == 10) { |
|
2719 | 2719 | $new_str .= '\n'; |
2720 | - }elseif(ord(substr($str, $i, 1))==13){ |
|
2720 | + }elseif (ord(substr($str, $i, 1)) == 13) { |
|
2721 | 2721 | $new_str .= '\r'; |
2722 | 2722 | } |
2723 | 2723 | else { |
@@ -2730,10 +2730,10 @@ discard block |
||
2730 | 2730 | return $new_str; |
2731 | 2731 | } |
2732 | 2732 | |
2733 | -function js_escape($str, $keep=true){ |
|
2733 | +function js_escape($str, $keep = true) { |
|
2734 | 2734 | $str = html_entity_decode(str_replace("\\", "", $str), ENT_QUOTES); |
2735 | 2735 | |
2736 | - if($keep){ |
|
2736 | + if ($keep) { |
|
2737 | 2737 | $str = javascript_escape($str); |
2738 | 2738 | } |
2739 | 2739 | else { |
@@ -2750,11 +2750,11 @@ discard block |
||
2750 | 2750 | $regex = "#<[^>]+br.+?>#i"; |
2751 | 2751 | preg_match_all($regex, $str, $matches); |
2752 | 2752 | |
2753 | - foreach($matches[0] as $match) { |
|
2753 | + foreach ($matches[0] as $match) { |
|
2754 | 2754 | $str = str_replace($match, "<br>", $str); |
2755 | 2755 | } |
2756 | 2756 | |
2757 | - $brs = array('<br>','<br/>', '<br />'); |
|
2757 | + $brs = array('<br>', '<br/>', '<br />'); |
|
2758 | 2758 | $str = str_replace("\r\n", "\n", $str); // make from windows-returns, *nix-returns |
2759 | 2759 | $str = str_replace("\n\r", "\n", $str); // make from windows-returns, *nix-returns |
2760 | 2760 | $str = str_replace("\r", "\n", $str); // make from windows-returns, *nix-returns |
@@ -2781,20 +2781,20 @@ discard block |
||
2781 | 2781 | * @param $die boolean end script flow |
2782 | 2782 | * @param $displayStackTrace also show stack trace |
2783 | 2783 | */ |
2784 | -function _ppl($mixed, $die=false, $displayStackTrace=false, $loglevel="fatal") { |
|
2785 | - if(!isset($GLOBALS['log']) || empty($GLOBALS['log'])) { |
|
2784 | +function _ppl($mixed, $die = false, $displayStackTrace = false, $loglevel = "fatal") { |
|
2785 | + if (!isset($GLOBALS['log']) || empty($GLOBALS['log'])) { |
|
2786 | 2786 | |
2787 | 2787 | $GLOBALS['log'] = LoggerManager :: getLogger('SugarCRM'); |
2788 | 2788 | } |
2789 | 2789 | |
2790 | 2790 | |
2791 | - $mix = print_r($mixed, true); // send print_r() output to $mix |
|
2792 | - $stack = debug_backtrace(); |
|
2791 | + $mix = print_r($mixed, true); // send print_r() output to $mix |
|
2792 | + $stack = debug_backtrace(); |
|
2793 | 2793 | |
2794 | 2794 | $GLOBALS['log']->$loglevel('------------------------------ _ppLogger() output start -----------------------------'); |
2795 | 2795 | $GLOBALS['log']->$loglevel($mix); |
2796 | - if($displayStackTrace) { |
|
2797 | - foreach($stack as $position) { |
|
2796 | + if ($displayStackTrace) { |
|
2797 | + foreach ($stack as $position) { |
|
2798 | 2798 | $GLOBALS['log']->$loglevel($position['file']."({$position['line']})"); |
2799 | 2799 | } |
2800 | 2800 | } |
@@ -2802,7 +2802,7 @@ discard block |
||
2802 | 2802 | $GLOBALS['log']->$loglevel('------------------------------ _ppLogger() output end -----------------------------'); |
2803 | 2803 | $GLOBALS['log']->$loglevel('------------------------------ _ppLogger() file: '.$stack[0]['file'].' line#: '.$stack[0]['line'].'-----------------------------'); |
2804 | 2804 | |
2805 | - if($die) { |
|
2805 | + if ($die) { |
|
2806 | 2806 | die(); |
2807 | 2807 | } |
2808 | 2808 | } |
@@ -2812,7 +2812,7 @@ discard block |
||
2812 | 2812 | * The ppf stands for Pre[formatted] Print Focus [object] |
2813 | 2813 | * @param object bean The focus bean |
2814 | 2814 | */ |
2815 | -function _ppf($bean, $die=false) { |
|
2815 | +function _ppf($bean, $die = false) { |
|
2816 | 2816 | } |
2817 | 2817 | |
2818 | 2818 | |
@@ -2831,7 +2831,7 @@ discard block |
||
2831 | 2831 | * This function is only intended to be used for SugarCRM internal development. |
2832 | 2832 | * The pp stands for Pre Print. |
2833 | 2833 | */ |
2834 | -function _pstack_trace($mixed=NULL) |
|
2834 | +function _pstack_trace($mixed = NULL) |
|
2835 | 2835 | { |
2836 | 2836 | } |
2837 | 2837 | |
@@ -2840,7 +2840,7 @@ discard block |
||
2840 | 2840 | * This function is only intended to be used for SugarCRM internal development. |
2841 | 2841 | * The pp stands for Pre Print Trace. |
2842 | 2842 | */ |
2843 | -function _ppt($mixed, $textOnly=false) |
|
2843 | +function _ppt($mixed, $textOnly = false) |
|
2844 | 2844 | { |
2845 | 2845 | } |
2846 | 2846 | |
@@ -2877,7 +2877,7 @@ discard block |
||
2877 | 2877 | |
2878 | 2878 | // only the supported versions, |
2879 | 2879 | // should be mutually exclusive with $invalid_php_versions |
2880 | - $supported_php_versions = array ( |
|
2880 | + $supported_php_versions = array( |
|
2881 | 2881 | '5.3.0' |
2882 | 2882 | ); |
2883 | 2883 | |
@@ -2891,21 +2891,21 @@ discard block |
||
2891 | 2891 | $retval = 0; |
2892 | 2892 | |
2893 | 2893 | // versions below $min_considered_php_version are invalid |
2894 | - if(1 == version_compare($sys_php_version, $min_considered_php_version, '<')) { |
|
2894 | + if (1 == version_compare($sys_php_version, $min_considered_php_version, '<')) { |
|
2895 | 2895 | $retval = -1; |
2896 | 2896 | } |
2897 | 2897 | |
2898 | 2898 | // supported version check overrides default unsupported |
2899 | - foreach($supported_php_versions as $ver) { |
|
2900 | - if(1 == version_compare($sys_php_version, $ver, 'eq') || strpos($sys_php_version,$ver) !== false) { |
|
2899 | + foreach ($supported_php_versions as $ver) { |
|
2900 | + if (1 == version_compare($sys_php_version, $ver, 'eq') || strpos($sys_php_version, $ver) !== false) { |
|
2901 | 2901 | $retval = 1; |
2902 | 2902 | break; |
2903 | 2903 | } |
2904 | 2904 | } |
2905 | 2905 | |
2906 | 2906 | // invalid version check overrides default unsupported |
2907 | - foreach($invalid_php_versions as $ver) { |
|
2908 | - if(1 == version_compare($sys_php_version, $ver, 'eq') && strpos($sys_php_version,$ver) !== false) { |
|
2907 | + foreach ($invalid_php_versions as $ver) { |
|
2908 | + if (1 == version_compare($sys_php_version, $ver, 'eq') && strpos($sys_php_version, $ver) !== false) { |
|
2909 | 2909 | $retval = -1; |
2910 | 2910 | break; |
2911 | 2911 | } |
@@ -2913,7 +2913,7 @@ discard block |
||
2913 | 2913 | |
2914 | 2914 | //allow a redhat distro to install, regardless of version. We are assuming the redhat naming convention is followed |
2915 | 2915 | //and the php version contains 'rh' characters |
2916 | - if(strpos($sys_php_version, 'rh') !== false) { |
|
2916 | + if (strpos($sys_php_version, 'rh') !== false) { |
|
2917 | 2917 | $retval = 1; |
2918 | 2918 | } |
2919 | 2919 | |
@@ -2931,7 +2931,7 @@ discard block |
||
2931 | 2931 | |
2932 | 2932 | $server_software = $_SERVER["SERVER_SOFTWARE"]; |
2933 | 2933 | $iis_version = ''; |
2934 | - if(strpos($server_software,'Microsoft-IIS') !== false && preg_match_all("/^.*\/(\d+\.?\d*)$/", $server_software, $out)) |
|
2934 | + if (strpos($server_software, 'Microsoft-IIS') !== false && preg_match_all("/^.*\/(\d+\.?\d*)$/", $server_software, $out)) |
|
2935 | 2935 | $iis_version = $out[1][0]; |
2936 | 2936 | |
2937 | 2937 | $sys_iis_version = empty($sys_iis_version) ? $iis_version : $sys_iis_version; |
@@ -2943,7 +2943,7 @@ discard block |
||
2943 | 2943 | |
2944 | 2944 | // only the supported versions, |
2945 | 2945 | // should be mutually exclusive with $invalid_iis_versions |
2946 | - $supported_iis_versions = array ('6.0', '7.0',); |
|
2946 | + $supported_iis_versions = array('6.0', '7.0',); |
|
2947 | 2947 | $unsupported_iis_versions = array(); |
2948 | 2948 | $invalid_iis_versions = array('5.0',); |
2949 | 2949 | |
@@ -2951,29 +2951,29 @@ discard block |
||
2951 | 2951 | $retval = 0; |
2952 | 2952 | |
2953 | 2953 | // versions below $min_considered_iis_version are invalid |
2954 | - if(1 == version_compare($sys_iis_version, $min_considered_iis_version, '<')) { |
|
2954 | + if (1 == version_compare($sys_iis_version, $min_considered_iis_version, '<')) { |
|
2955 | 2955 | $retval = -1; |
2956 | 2956 | } |
2957 | 2957 | |
2958 | 2958 | // supported version check overrides default unsupported |
2959 | - foreach($supported_iis_versions as $ver) { |
|
2960 | - if(1 == version_compare($sys_iis_version, $ver, 'eq') || strpos($sys_iis_version,$ver) !== false) { |
|
2959 | + foreach ($supported_iis_versions as $ver) { |
|
2960 | + if (1 == version_compare($sys_iis_version, $ver, 'eq') || strpos($sys_iis_version, $ver) !== false) { |
|
2961 | 2961 | $retval = 1; |
2962 | 2962 | break; |
2963 | 2963 | } |
2964 | 2964 | } |
2965 | 2965 | |
2966 | 2966 | // unsupported version check overrides default unsupported |
2967 | - foreach($unsupported_iis_versions as $ver) { |
|
2968 | - if(1 == version_compare($sys_iis_version, $ver, 'eq') && strpos($sys_iis_version,$ver) !== false) { |
|
2967 | + foreach ($unsupported_iis_versions as $ver) { |
|
2968 | + if (1 == version_compare($sys_iis_version, $ver, 'eq') && strpos($sys_iis_version, $ver) !== false) { |
|
2969 | 2969 | $retval = 0; |
2970 | 2970 | break; |
2971 | 2971 | } |
2972 | 2972 | } |
2973 | 2973 | |
2974 | 2974 | // invalid version check overrides default unsupported |
2975 | - foreach($invalid_iis_versions as $ver) { |
|
2976 | - if(1 == version_compare($sys_iis_version, $ver, 'eq') && strpos($sys_iis_version,$ver) !== false) { |
|
2975 | + foreach ($invalid_iis_versions as $ver) { |
|
2976 | + if (1 == version_compare($sys_iis_version, $ver, 'eq') && strpos($sys_iis_version, $ver) !== false) { |
|
2977 | 2977 | $retval = -1; |
2978 | 2978 | break; |
2979 | 2979 | } |
@@ -2982,18 +2982,18 @@ discard block |
||
2982 | 2982 | return $retval; |
2983 | 2983 | } |
2984 | 2984 | |
2985 | -function pre_login_check(){ |
|
2985 | +function pre_login_check() { |
|
2986 | 2986 | global $action, $login_error; |
2987 | - if(!empty($action)&& $action == 'Login'){ |
|
2987 | + if (!empty($action) && $action == 'Login') { |
|
2988 | 2988 | |
2989 | - if(!empty($login_error)){ |
|
2989 | + if (!empty($login_error)) { |
|
2990 | 2990 | $login_error = htmlentities($login_error); |
2991 | - $login_error = str_replace(array("<pre>","</pre>","\r\n", "\n"), "<br>", $login_error); |
|
2991 | + $login_error = str_replace(array("<pre>", "</pre>", "\r\n", "\n"), "<br>", $login_error); |
|
2992 | 2992 | $_SESSION['login_error'] = $login_error; |
2993 | 2993 | echo '<script> |
2994 | 2994 | function set_focus() {} |
2995 | 2995 | if(document.getElementById("post_error")) { |
2996 | - document.getElementById("post_error").innerHTML="'. $login_error. '"; |
|
2996 | + document.getElementById("post_error").innerHTML="'. $login_error.'"; |
|
2997 | 2997 | document.getElementById("cant_login").value=1; |
2998 | 2998 | document.getElementById("login_button").disabled = true; |
2999 | 2999 | document.getElementById("user_name").disabled = true; |
@@ -3008,10 +3008,10 @@ discard block |
||
3008 | 3008 | |
3009 | 3009 | function sugar_cleanup($exit = false) { |
3010 | 3010 | static $called = false; |
3011 | - if($called)return; |
|
3011 | + if ($called)return; |
|
3012 | 3012 | $called = true; |
3013 | - set_include_path(realpath(dirname(__FILE__) . '/..') . PATH_SEPARATOR . get_include_path()); |
|
3014 | - chdir(realpath(dirname(__FILE__) . '/..')); |
|
3013 | + set_include_path(realpath(dirname(__FILE__).'/..').PATH_SEPARATOR.get_include_path()); |
|
3014 | + chdir(realpath(dirname(__FILE__).'/..')); |
|
3015 | 3015 | global $sugar_config; |
3016 | 3016 | require_once('include/utils/LogicHook.php'); |
3017 | 3017 | LogicHook::initialize(); |
@@ -3027,20 +3027,20 @@ discard block |
||
3027 | 3027 | } |
3028 | 3028 | Tracker::logPage(); |
3029 | 3029 | // Now write the cached tracker_queries |
3030 | - if(!empty($GLOBALS['savePreferencesToDB']) && $GLOBALS['savePreferencesToDB']) { |
|
3031 | - if ( isset($GLOBALS['current_user']) && $GLOBALS['current_user'] instanceOf User ) |
|
3030 | + if (!empty($GLOBALS['savePreferencesToDB']) && $GLOBALS['savePreferencesToDB']) { |
|
3031 | + if (isset($GLOBALS['current_user']) && $GLOBALS['current_user'] instanceOf User) |
|
3032 | 3032 | $GLOBALS['current_user']->savePreferencesToDB(); |
3033 | 3033 | } |
3034 | 3034 | |
3035 | 3035 | //check to see if this is not an `ajax call AND the user preference error flag is set |
3036 | - if( |
|
3036 | + if ( |
|
3037 | 3037 | (isset($_SESSION['USER_PREFRENCE_ERRORS']) && $_SESSION['USER_PREFRENCE_ERRORS']) |
3038 | - && ($_REQUEST['action']!='modulelistmenu' && $_REQUEST['action']!='DynamicAction') |
|
3039 | - && ($_REQUEST['action']!='favorites' && $_REQUEST['action']!='DynamicAction') |
|
3040 | - && (empty($_REQUEST['to_pdf']) || !$_REQUEST['to_pdf'] ) |
|
3041 | - && (empty($_REQUEST['sugar_body_only']) || !$_REQUEST['sugar_body_only'] ) |
|
3038 | + && ($_REQUEST['action'] != 'modulelistmenu' && $_REQUEST['action'] != 'DynamicAction') |
|
3039 | + && ($_REQUEST['action'] != 'favorites' && $_REQUEST['action'] != 'DynamicAction') |
|
3040 | + && (empty($_REQUEST['to_pdf']) || !$_REQUEST['to_pdf']) |
|
3041 | + && (empty($_REQUEST['sugar_body_only']) || !$_REQUEST['sugar_body_only']) |
|
3042 | 3042 | |
3043 | - ){ |
|
3043 | + ) { |
|
3044 | 3044 | global $app_strings; |
3045 | 3045 | //this is not an ajax call and the user preference error flag is set, so reset the flag and print js to flash message |
3046 | 3046 | $err_mess = $app_strings['ERROR_USER_PREFS']; |
@@ -3053,10 +3053,10 @@ discard block |
||
3053 | 3053 | } |
3054 | 3054 | |
3055 | 3055 | pre_login_check(); |
3056 | - if(class_exists('DBManagerFactory')) { |
|
3056 | + if (class_exists('DBManagerFactory')) { |
|
3057 | 3057 | $db = DBManagerFactory::getInstance(); |
3058 | 3058 | $db->disconnect(); |
3059 | - if($exit) { |
|
3059 | + if ($exit) { |
|
3060 | 3060 | exit; |
3061 | 3061 | } |
3062 | 3062 | } |
@@ -3070,27 +3070,27 @@ discard block |
||
3070 | 3070 | if not, it will add it. If the file isn't built yet, it will create the file |
3071 | 3071 | |
3072 | 3072 | */ |
3073 | -function check_logic_hook_file($module_name, $event, $action_array){ |
|
3073 | +function check_logic_hook_file($module_name, $event, $action_array) { |
|
3074 | 3074 | require_once('include/utils/logic_utils.php'); |
3075 | 3075 | $add_logic = false; |
3076 | 3076 | |
3077 | - if(file_exists("custom/modules/$module_name/logic_hooks.php")){ |
|
3077 | + if (file_exists("custom/modules/$module_name/logic_hooks.php")) { |
|
3078 | 3078 | |
3079 | 3079 | $hook_array = get_hook_array($module_name); |
3080 | 3080 | |
3081 | - if(check_existing_element($hook_array, $event, $action_array)==true){ |
|
3081 | + if (check_existing_element($hook_array, $event, $action_array) == true) { |
|
3082 | 3082 | //the hook at hand is present, so do nothing |
3083 | 3083 | } else { |
3084 | 3084 | $add_logic = true; |
3085 | 3085 | |
3086 | 3086 | $logic_count = 0; |
3087 | - if(!empty($hook_array[$event])) |
|
3087 | + if (!empty($hook_array[$event])) |
|
3088 | 3088 | { |
3089 | 3089 | $logic_count = count($hook_array[$event]); |
3090 | 3090 | } |
3091 | 3091 | |
3092 | - if($action_array[0]==""){ |
|
3093 | - $action_array[0] = $logic_count + 1; |
|
3092 | + if ($action_array[0] == "") { |
|
3093 | + $action_array[0] = $logic_count + 1; |
|
3094 | 3094 | } |
3095 | 3095 | $hook_array[$event][] = $action_array; |
3096 | 3096 | |
@@ -3098,14 +3098,14 @@ discard block |
||
3098 | 3098 | //end if the file exists already |
3099 | 3099 | } else { |
3100 | 3100 | $add_logic = true; |
3101 | - if($action_array[0]==""){ |
|
3101 | + if ($action_array[0] == "") { |
|
3102 | 3102 | $action_array[0] = 1; |
3103 | 3103 | } |
3104 | 3104 | $hook_array = array(); |
3105 | 3105 | $hook_array[$event][] = $action_array; |
3106 | 3106 | //end if else file exists already |
3107 | 3107 | } |
3108 | - if($add_logic == true){ |
|
3108 | + if ($add_logic == true) { |
|
3109 | 3109 | |
3110 | 3110 | //reorder array by element[0] |
3111 | 3111 | //$hook_array = reorder_array($hook_array, $event); |
@@ -3124,19 +3124,19 @@ discard block |
||
3124 | 3124 | require_once('include/utils/logic_utils.php'); |
3125 | 3125 | $add_logic = false; |
3126 | 3126 | |
3127 | - if(file_exists("custom/modules/".$module_name."/logic_hooks.php")){ |
|
3127 | + if (file_exists("custom/modules/".$module_name."/logic_hooks.php")) { |
|
3128 | 3128 | // The file exists, let's make sure the hook is there |
3129 | 3129 | $hook_array = get_hook_array($module_name); |
3130 | 3130 | |
3131 | - if(check_existing_element($hook_array, $event, $action_array)==true){ |
|
3131 | + if (check_existing_element($hook_array, $event, $action_array) == true) { |
|
3132 | 3132 | // The hook is there, time to take it out. |
3133 | 3133 | |
3134 | - foreach ( $hook_array[$event] as $i => $hook ) { |
|
3134 | + foreach ($hook_array[$event] as $i => $hook) { |
|
3135 | 3135 | // We don't do a full comparison below just in case the filename changes |
3136 | - if ( $hook[0] == $action_array[0] |
|
3136 | + if ($hook[0] == $action_array[0] |
|
3137 | 3137 | && $hook[1] == $action_array[1] |
3138 | 3138 | && $hook[3] == $action_array[3] |
3139 | - && $hook[4] == $action_array[4] ) { |
|
3139 | + && $hook[4] == $action_array[4]) { |
|
3140 | 3140 | unset($hook_array[$event][$i]); |
3141 | 3141 | } |
3142 | 3142 | } |
@@ -3148,53 +3148,53 @@ discard block |
||
3148 | 3148 | } |
3149 | 3149 | } |
3150 | 3150 | |
3151 | -function display_stack_trace($textOnly=false){ |
|
3151 | +function display_stack_trace($textOnly = false) { |
|
3152 | 3152 | |
3153 | - $stack = debug_backtrace(); |
|
3153 | + $stack = debug_backtrace(); |
|
3154 | 3154 | |
3155 | - echo "\n\n display_stack_trace caller, file: " . $stack[0]['file']. ' line#: ' .$stack[0]['line']; |
|
3155 | + echo "\n\n display_stack_trace caller, file: ".$stack[0]['file'].' line#: '.$stack[0]['line']; |
|
3156 | 3156 | |
3157 | - if(!$textOnly) |
|
3157 | + if (!$textOnly) |
|
3158 | 3158 | echo '<br>'; |
3159 | 3159 | |
3160 | 3160 | $first = true; |
3161 | 3161 | $out = ''; |
3162 | 3162 | |
3163 | - foreach($stack as $item) { |
|
3163 | + foreach ($stack as $item) { |
|
3164 | 3164 | $file = ''; |
3165 | 3165 | $class = ''; |
3166 | 3166 | $line = ''; |
3167 | - $function = ''; |
|
3167 | + $function = ''; |
|
3168 | 3168 | |
3169 | - if(isset($item['file'])) |
|
3169 | + if (isset($item['file'])) |
|
3170 | 3170 | $file = $item['file']; |
3171 | - if(isset($item['class'])) |
|
3171 | + if (isset($item['class'])) |
|
3172 | 3172 | $class = $item['class']; |
3173 | - if(isset($item['line'])) |
|
3173 | + if (isset($item['line'])) |
|
3174 | 3174 | $line = $item['line']; |
3175 | - if(isset($item['function'])) |
|
3175 | + if (isset($item['function'])) |
|
3176 | 3176 | $function = $item['function']; |
3177 | 3177 | |
3178 | - if(!$first) { |
|
3179 | - if(!$textOnly) { |
|
3178 | + if (!$first) { |
|
3179 | + if (!$textOnly) { |
|
3180 | 3180 | $out .= '<font color="black"><b>'; |
3181 | 3181 | } |
3182 | 3182 | |
3183 | 3183 | $out .= $file; |
3184 | 3184 | |
3185 | - if(!$textOnly) { |
|
3185 | + if (!$textOnly) { |
|
3186 | 3186 | $out .= '</b></font><font color="blue">'; |
3187 | 3187 | } |
3188 | 3188 | |
3189 | 3189 | $out .= "[L:{$line}]"; |
3190 | 3190 | |
3191 | - if(!$textOnly) { |
|
3191 | + if (!$textOnly) { |
|
3192 | 3192 | $out .= '</font><font color="red">'; |
3193 | 3193 | } |
3194 | 3194 | |
3195 | 3195 | $out .= "({$class}:{$function})"; |
3196 | 3196 | |
3197 | - if(!$textOnly) { |
|
3197 | + if (!$textOnly) { |
|
3198 | 3198 | $out .= '</font><br>'; |
3199 | 3199 | } else { |
3200 | 3200 | $out .= "\n"; |
@@ -3207,14 +3207,14 @@ discard block |
||
3207 | 3207 | echo $out; |
3208 | 3208 | } |
3209 | 3209 | |
3210 | -function StackTraceErrorHandler($errno, $errstr, $errfile,$errline, $errcontext) { |
|
3211 | - $error_msg = " $errstr occurred in <b>$errfile</b> on line $errline [" . date("Y-m-d H:i:s") . ']'; |
|
3210 | +function StackTraceErrorHandler($errno, $errstr, $errfile, $errline, $errcontext) { |
|
3211 | + $error_msg = " $errstr occurred in <b>$errfile</b> on line $errline [".date("Y-m-d H:i:s").']'; |
|
3212 | 3212 | $halt_script = true; |
3213 | - switch($errno){ |
|
3213 | + switch ($errno) { |
|
3214 | 3214 | case 2048: return; //depricated we have lots of these ignore them |
3215 | 3215 | case E_USER_NOTICE: |
3216 | 3216 | case E_NOTICE: |
3217 | - if ( error_reporting() & E_NOTICE ) { |
|
3217 | + if (error_reporting() & E_NOTICE) { |
|
3218 | 3218 | $halt_script = false; |
3219 | 3219 | $type = 'Notice'; |
3220 | 3220 | } |
@@ -3249,10 +3249,10 @@ discard block |
||
3249 | 3249 | $type = "Unknown Error ($errno)"; |
3250 | 3250 | break; |
3251 | 3251 | } |
3252 | - $error_msg = '<b>'.$type.'</b>:' . $error_msg; |
|
3252 | + $error_msg = '<b>'.$type.'</b>:'.$error_msg; |
|
3253 | 3253 | echo $error_msg; |
3254 | 3254 | display_stack_trace(); |
3255 | - if($halt_script){ |
|
3255 | + if ($halt_script) { |
|
3256 | 3256 | exit -1; |
3257 | 3257 | } |
3258 | 3258 | |
@@ -3261,16 +3261,16 @@ discard block |
||
3261 | 3261 | } |
3262 | 3262 | |
3263 | 3263 | |
3264 | -if(isset($sugar_config['stack_trace_errors']) && $sugar_config['stack_trace_errors']){ |
|
3264 | +if (isset($sugar_config['stack_trace_errors']) && $sugar_config['stack_trace_errors']) { |
|
3265 | 3265 | |
3266 | 3266 | set_error_handler('StackTraceErrorHandler'); |
3267 | 3267 | } |
3268 | -function get_sub_cookies($name){ |
|
3268 | +function get_sub_cookies($name) { |
|
3269 | 3269 | $cookies = array(); |
3270 | - if(isset($_COOKIE[$name])){ |
|
3270 | + if (isset($_COOKIE[$name])) { |
|
3271 | 3271 | $subs = explode('#', $_COOKIE[$name]); |
3272 | - foreach($subs as $cookie){ |
|
3273 | - if(!empty($cookie)){ |
|
3272 | + foreach ($subs as $cookie) { |
|
3273 | + if (!empty($cookie)) { |
|
3274 | 3274 | $cookie = explode('=', $cookie); |
3275 | 3275 | |
3276 | 3276 | $cookies[$cookie[0]] = $cookie[1]; |
@@ -3282,16 +3282,16 @@ discard block |
||
3282 | 3282 | } |
3283 | 3283 | |
3284 | 3284 | |
3285 | -function mark_delete_components($sub_object_array, $run_second_level=false, $sub_sub_array=""){ |
|
3285 | +function mark_delete_components($sub_object_array, $run_second_level = false, $sub_sub_array = "") { |
|
3286 | 3286 | |
3287 | - if(!empty($sub_object_array)){ |
|
3287 | + if (!empty($sub_object_array)) { |
|
3288 | 3288 | |
3289 | - foreach($sub_object_array as $sub_object){ |
|
3289 | + foreach ($sub_object_array as $sub_object) { |
|
3290 | 3290 | |
3291 | 3291 | //run_second level is set to true if you need to remove sub-sub components |
3292 | - if($run_second_level==true){ |
|
3292 | + if ($run_second_level == true) { |
|
3293 | 3293 | |
3294 | - mark_delete_components($sub_object->get_linked_beans($sub_sub_array['rel_field'],$sub_sub_array['rel_module'])); |
|
3294 | + mark_delete_components($sub_object->get_linked_beans($sub_sub_array['rel_field'], $sub_sub_array['rel_module'])); |
|
3295 | 3295 | |
3296 | 3296 | //end if run_second_level is true |
3297 | 3297 | } |
@@ -3310,9 +3310,9 @@ discard block |
||
3310 | 3310 | function return_bytes($val) |
3311 | 3311 | { |
3312 | 3312 | $val = trim($val); |
3313 | - $last = strtolower($val{strlen($val)-1}); |
|
3313 | + $last = strtolower($val{strlen($val) - 1}); |
|
3314 | 3314 | |
3315 | - switch($last) |
|
3315 | + switch ($last) |
|
3316 | 3316 | { |
3317 | 3317 | // The 'G' modifier is available since PHP 5.1.0 |
3318 | 3318 | case 'g': |
@@ -3353,27 +3353,27 @@ discard block |
||
3353 | 3353 | * @return bool true if writable |
3354 | 3354 | */ |
3355 | 3355 | function is_writable_windows($file) { |
3356 | - if($file{strlen($file)-1}=='/') { |
|
3356 | + if ($file{strlen($file) - 1} == '/') { |
|
3357 | 3357 | return is_writable_windows($file.uniqid(mt_rand()).'.tmp'); |
3358 | 3358 | } |
3359 | 3359 | |
3360 | 3360 | // the assumption here is that Windows has an inherited permissions scheme |
3361 | 3361 | // any file that is a descendant of an unwritable directory will inherit |
3362 | 3362 | // that property and will trigger a failure below. |
3363 | - if(is_dir($file)) { |
|
3363 | + if (is_dir($file)) { |
|
3364 | 3364 | return true; |
3365 | 3365 | } |
3366 | 3366 | |
3367 | 3367 | $file = str_replace("/", '\\', $file); |
3368 | 3368 | |
3369 | - if(file_exists($file)) { |
|
3369 | + if (file_exists($file)) { |
|
3370 | 3370 | if (!($f = @sugar_fopen($file, 'r+'))) |
3371 | 3371 | return false; |
3372 | 3372 | fclose($f); |
3373 | 3373 | return true; |
3374 | 3374 | } |
3375 | 3375 | |
3376 | - if(!($f = @sugar_fopen($file, 'w'))) |
|
3376 | + if (!($f = @sugar_fopen($file, 'w'))) |
|
3377 | 3377 | return false; |
3378 | 3378 | fclose($f); |
3379 | 3379 | unlink($file); |
@@ -3389,16 +3389,16 @@ discard block |
||
3389 | 3389 | return TimeDate::guessTimezone($userOffset); |
3390 | 3390 | } |
3391 | 3391 | |
3392 | -function convert_module_to_singular($module_array){ |
|
3392 | +function convert_module_to_singular($module_array) { |
|
3393 | 3393 | global $beanList; |
3394 | 3394 | |
3395 | - foreach($module_array as $key => $value){ |
|
3396 | - if(!empty($beanList[$value])) $module_array[$key] = $beanList[$value]; |
|
3395 | + foreach ($module_array as $key => $value) { |
|
3396 | + if (!empty($beanList[$value])) $module_array[$key] = $beanList[$value]; |
|
3397 | 3397 | |
3398 | - if($value=="Cases") { |
|
3398 | + if ($value == "Cases") { |
|
3399 | 3399 | $module_array[$key] = "Case"; |
3400 | 3400 | } |
3401 | - if($key=="projecttask"){ |
|
3401 | + if ($key == "projecttask") { |
|
3402 | 3402 | $module_array['ProjectTask'] = "Project Task"; |
3403 | 3403 | unset($module_array[$key]); |
3404 | 3404 | } |
@@ -3413,12 +3413,12 @@ discard block |
||
3413 | 3413 | * Given the bean_name which may be plural or singular return the singular |
3414 | 3414 | * bean_name. This is important when you need to include files. |
3415 | 3415 | */ |
3416 | -function get_singular_bean_name($bean_name){ |
|
3416 | +function get_singular_bean_name($bean_name) { |
|
3417 | 3417 | global $beanFiles, $beanList; |
3418 | - if(array_key_exists($bean_name, $beanList)){ |
|
3418 | + if (array_key_exists($bean_name, $beanList)) { |
|
3419 | 3419 | return $beanList[$bean_name]; |
3420 | 3420 | } |
3421 | - else{ |
|
3421 | + else { |
|
3422 | 3422 | return $bean_name; |
3423 | 3423 | } |
3424 | 3424 | } |
@@ -3457,13 +3457,13 @@ discard block |
||
3457 | 3457 | return $singular; |
3458 | 3458 | } |
3459 | 3459 | |
3460 | -function get_label($label_tag, $temp_module_strings){ |
|
3460 | +function get_label($label_tag, $temp_module_strings) { |
|
3461 | 3461 | global $app_strings; |
3462 | - if(!empty($temp_module_strings[$label_tag])){ |
|
3462 | + if (!empty($temp_module_strings[$label_tag])) { |
|
3463 | 3463 | |
3464 | 3464 | $label_name = $temp_module_strings[$label_tag]; |
3465 | 3465 | } else { |
3466 | - if(!empty($app_strings[$label_tag])){ |
|
3466 | + if (!empty($app_strings[$label_tag])) { |
|
3467 | 3467 | $label_name = $app_strings[$label_tag]; |
3468 | 3468 | } else { |
3469 | 3469 | $label_name = $label_tag; |
@@ -3475,16 +3475,16 @@ discard block |
||
3475 | 3475 | } |
3476 | 3476 | |
3477 | 3477 | |
3478 | -function search_filter_rel_info(& $focus, $tar_rel_module, $relationship_name){ |
|
3478 | +function search_filter_rel_info(& $focus, $tar_rel_module, $relationship_name) { |
|
3479 | 3479 | |
3480 | 3480 | $rel_list = array(); |
3481 | 3481 | |
3482 | - foreach($focus->relationship_fields as $rel_key => $rel_value){ |
|
3483 | - if($rel_value == $relationship_name){ |
|
3482 | + foreach ($focus->relationship_fields as $rel_key => $rel_value) { |
|
3483 | + if ($rel_value == $relationship_name) { |
|
3484 | 3484 | $temp_bean = get_module_info($tar_rel_module); |
3485 | 3485 | // echo $focus->$rel_key; |
3486 | 3486 | $temp_bean->retrieve($focus->$rel_key); |
3487 | - if($temp_bean->id!=""){ |
|
3487 | + if ($temp_bean->id != "") { |
|
3488 | 3488 | |
3489 | 3489 | $rel_list[] = $temp_bean; |
3490 | 3490 | return $rel_list; |
@@ -3492,9 +3492,9 @@ discard block |
||
3492 | 3492 | } |
3493 | 3493 | } |
3494 | 3494 | |
3495 | - foreach($focus->field_defs as $field_name => $field_def){ |
|
3495 | + foreach ($focus->field_defs as $field_name => $field_def) { |
|
3496 | 3496 | //Check if the relationship_name matches a "relate" field |
3497 | - if(!empty($field_def['type']) && $field_def['type'] == 'relate' |
|
3497 | + if (!empty($field_def['type']) && $field_def['type'] == 'relate' |
|
3498 | 3498 | && !empty($field_def['id_name']) && !empty($focus->field_defs[$field_def['id_name']]) |
3499 | 3499 | && !empty($focus->field_defs[$field_def['id_name']]['relationship']) |
3500 | 3500 | && $focus->field_defs[$field_def['id_name']]['relationship'] == $relationship_name) |
@@ -3502,17 +3502,17 @@ discard block |
||
3502 | 3502 | $temp_bean = get_module_info($tar_rel_module); |
3503 | 3503 | // echo $focus->$field_def['id_name']; |
3504 | 3504 | $temp_bean->retrieve($focus->$field_def['id_name']); |
3505 | - if($temp_bean->id!=""){ |
|
3505 | + if ($temp_bean->id != "") { |
|
3506 | 3506 | |
3507 | 3507 | $rel_list[] = $temp_bean; |
3508 | 3508 | return $rel_list; |
3509 | 3509 | } |
3510 | 3510 | //Check if the relationship_name matches a "link" in a relate field |
3511 | - } else if(!empty($rel_value['link']) && !empty($rel_value['id_name']) && $rel_value['link'] == $relationship_name){ |
|
3511 | + } else if (!empty($rel_value['link']) && !empty($rel_value['id_name']) && $rel_value['link'] == $relationship_name) { |
|
3512 | 3512 | $temp_bean = get_module_info($tar_rel_module); |
3513 | 3513 | // echo $focus->$rel_value['id_name']; |
3514 | 3514 | $temp_bean->retrieve($focus->$rel_value['id_name']); |
3515 | - if($temp_bean->id!=""){ |
|
3515 | + if ($temp_bean->id != "") { |
|
3516 | 3516 | |
3517 | 3517 | $rel_list[] = $temp_bean; |
3518 | 3518 | return $rel_list; |
@@ -3521,10 +3521,10 @@ discard block |
||
3521 | 3521 | } |
3522 | 3522 | |
3523 | 3523 | // special case for unlisted parent-type relationships |
3524 | - if( !empty($focus->parent_type) && $focus->parent_type == $tar_rel_module && !empty($focus->parent_id)) { |
|
3524 | + if (!empty($focus->parent_type) && $focus->parent_type == $tar_rel_module && !empty($focus->parent_id)) { |
|
3525 | 3525 | $temp_bean = get_module_info($tar_rel_module); |
3526 | 3526 | $temp_bean->retrieve($focus->parent_id); |
3527 | - if($temp_bean->id!=""){ |
|
3527 | + if ($temp_bean->id != "") { |
|
3528 | 3528 | $rel_list[] = $temp_bean; |
3529 | 3529 | return $rel_list; |
3530 | 3530 | } |
@@ -3535,24 +3535,24 @@ discard block |
||
3535 | 3535 | //end function search_filter_rel_info |
3536 | 3536 | } |
3537 | 3537 | |
3538 | -function get_module_info($module_name){ |
|
3538 | +function get_module_info($module_name) { |
|
3539 | 3539 | global $beanList; |
3540 | 3540 | global $dictionary; |
3541 | 3541 | |
3542 | 3542 | //Get dictionary and focus data for module |
3543 | 3543 | $vardef_name = $beanList[$module_name]; |
3544 | 3544 | |
3545 | - if($vardef_name=="aCase"){ |
|
3545 | + if ($vardef_name == "aCase") { |
|
3546 | 3546 | $class_name = "Case"; |
3547 | 3547 | } else { |
3548 | 3548 | $class_name = $vardef_name; |
3549 | 3549 | } |
3550 | 3550 | |
3551 | - if(!file_exists('modules/'. $module_name . '/'.$class_name.'.php')){ |
|
3551 | + if (!file_exists('modules/'.$module_name.'/'.$class_name.'.php')) { |
|
3552 | 3552 | return; |
3553 | 3553 | } |
3554 | 3554 | |
3555 | - include_once('modules/'. $module_name . '/'.$class_name.'.php'); |
|
3555 | + include_once('modules/'.$module_name.'/'.$class_name.'.php'); |
|
3556 | 3556 | |
3557 | 3557 | $module_bean = new $vardef_name(); |
3558 | 3558 | return $module_bean; |
@@ -3564,11 +3564,11 @@ discard block |
||
3564 | 3564 | * |
3565 | 3565 | * @param string $moduleName |
3566 | 3566 | */ |
3567 | -function get_valid_bean_name($module_name){ |
|
3567 | +function get_valid_bean_name($module_name) { |
|
3568 | 3568 | global $beanList; |
3569 | 3569 | |
3570 | 3570 | $vardef_name = $beanList[$module_name]; |
3571 | - if($vardef_name=="aCase"){ |
|
3571 | + if ($vardef_name == "aCase") { |
|
3572 | 3572 | $bean_name = "Case"; |
3573 | 3573 | } else { |
3574 | 3574 | $bean_name = $vardef_name; |
@@ -3578,7 +3578,7 @@ discard block |
||
3578 | 3578 | |
3579 | 3579 | |
3580 | 3580 | |
3581 | -function checkAuthUserStatus(){ |
|
3581 | +function checkAuthUserStatus() { |
|
3582 | 3582 | |
3583 | 3583 | //authUserStatus(); |
3584 | 3584 | } |
@@ -3592,7 +3592,7 @@ discard block |
||
3592 | 3592 | * @author original by "code at adspeed dot com" Fron php.net |
3593 | 3593 | * @author customized for Sugar by Chris N. |
3594 | 3594 | */ |
3595 | -function getPhpInfo($level=-1) { |
|
3595 | +function getPhpInfo($level = -1) { |
|
3596 | 3596 | /** Name (constant) Value Description |
3597 | 3597 | INFO_GENERAL 1 The configuration line, php.ini location, build date, Web Server, System and more. |
3598 | 3598 | INFO_CREDITS 2 PHP Credits. See also phpcredits(). |
@@ -3608,36 +3608,36 @@ discard block |
||
3608 | 3608 | $phpinfo = ob_get_contents(); |
3609 | 3609 | ob_end_clean(); |
3610 | 3610 | |
3611 | - $phpinfo = strip_tags($phpinfo,'<h1><h2><th><td>'); |
|
3612 | - $phpinfo = preg_replace('/<th[^>]*>([^<]+)<\/th>/',"<info>\\1</info>",$phpinfo); |
|
3613 | - $phpinfo = preg_replace('/<td[^>]*>([^<]+)<\/td>/',"<info>\\1</info>",$phpinfo); |
|
3611 | + $phpinfo = strip_tags($phpinfo, '<h1><h2><th><td>'); |
|
3612 | + $phpinfo = preg_replace('/<th[^>]*>([^<]+)<\/th>/', "<info>\\1</info>", $phpinfo); |
|
3613 | + $phpinfo = preg_replace('/<td[^>]*>([^<]+)<\/td>/', "<info>\\1</info>", $phpinfo); |
|
3614 | 3614 | $parsedInfo = preg_split('/(<h.?>[^<]+<\/h.>)/', $phpinfo, -1, PREG_SPLIT_DELIM_CAPTURE); |
3615 | - $match = ''; |
|
3615 | + $match = ''; |
|
3616 | 3616 | $version = ''; |
3617 | 3617 | $returnInfo = array(); |
3618 | 3618 | |
3619 | - if(preg_match('/<h1 class\=\"p\">PHP Version ([^<]+)<\/h1>/', $phpinfo, $version)) { |
|
3619 | + if (preg_match('/<h1 class\=\"p\">PHP Version ([^<]+)<\/h1>/', $phpinfo, $version)) { |
|
3620 | 3620 | $returnInfo['PHP Version'] = $version[1]; |
3621 | 3621 | } |
3622 | 3622 | |
3623 | 3623 | |
3624 | - for ($i=1; $i<count($parsedInfo); $i++) { |
|
3624 | + for ($i = 1; $i < count($parsedInfo); $i++) { |
|
3625 | 3625 | if (preg_match('/<h.>([^<]+)<\/h.>/', $parsedInfo[$i], $match)) { |
3626 | 3626 | $vName = trim($match[1]); |
3627 | - $parsedInfo2 = explode("\n",$parsedInfo[$i+1]); |
|
3627 | + $parsedInfo2 = explode("\n", $parsedInfo[$i + 1]); |
|
3628 | 3628 | |
3629 | 3629 | foreach ($parsedInfo2 AS $vOne) { |
3630 | - $vPat = '<info>([^<]+)<\/info>'; |
|
3630 | + $vPat = '<info>([^<]+)<\/info>'; |
|
3631 | 3631 | $vPat3 = "/$vPat\s*$vPat\s*$vPat/"; |
3632 | 3632 | $vPat2 = "/$vPat\s*$vPat/"; |
3633 | 3633 | |
3634 | - if (preg_match($vPat3,$vOne,$match)) { // 3cols |
|
3635 | - $returnInfo[$vName][trim($match[1])] = array(trim($match[2]),trim($match[3])); |
|
3636 | - } elseif (preg_match($vPat2,$vOne,$match)) { // 2cols |
|
3634 | + if (preg_match($vPat3, $vOne, $match)) { // 3cols |
|
3635 | + $returnInfo[$vName][trim($match[1])] = array(trim($match[2]), trim($match[3])); |
|
3636 | + } elseif (preg_match($vPat2, $vOne, $match)) { // 2cols |
|
3637 | 3637 | $returnInfo[$vName][trim($match[1])] = trim($match[2]); |
3638 | 3638 | } |
3639 | 3639 | } |
3640 | - } elseif(true) { |
|
3640 | + } elseif (true) { |
|
3641 | 3641 | |
3642 | 3642 | } |
3643 | 3643 | } |
@@ -3652,7 +3652,7 @@ discard block |
||
3652 | 3652 | * @param $args args to replace |
3653 | 3653 | * @return $result a formatted string |
3654 | 3654 | */ |
3655 | -function string_format($format, $args){ |
|
3655 | +function string_format($format, $args) { |
|
3656 | 3656 | $result = $format; |
3657 | 3657 | |
3658 | 3658 | /** Bug47277 fix. |
@@ -3670,7 +3670,7 @@ discard block |
||
3670 | 3670 | } |
3671 | 3671 | /* End of fix */ |
3672 | 3672 | |
3673 | - for($i = 0; $i < count($args); $i++){ |
|
3673 | + for ($i = 0; $i < count($args); $i++) { |
|
3674 | 3674 | $result = str_replace('{'.$i.'}', $args[$i], $result); |
3675 | 3675 | } |
3676 | 3676 | return $result; |
@@ -3686,19 +3686,19 @@ discard block |
||
3686 | 3686 | * @param $system_id from system |
3687 | 3687 | * @return $result a formatted string |
3688 | 3688 | */ |
3689 | -function format_number_display($num, $system_id){ |
|
3689 | +function format_number_display($num, $system_id) { |
|
3690 | 3690 | global $sugar_config; |
3691 | - if(isset($num) && !empty($num)){ |
|
3692 | - $num=unformat_number($num); |
|
3693 | - if(isset($system_id) && $system_id == 1){ |
|
3691 | + if (isset($num) && !empty($num)) { |
|
3692 | + $num = unformat_number($num); |
|
3693 | + if (isset($system_id) && $system_id == 1) { |
|
3694 | 3694 | return sprintf("%d", $num); |
3695 | 3695 | } |
3696 | - else{ |
|
3696 | + else { |
|
3697 | 3697 | return sprintf("%d-%d", $num, $system_id); |
3698 | 3698 | } |
3699 | 3699 | } |
3700 | 3700 | } |
3701 | -function checkLoginUserStatus(){ |
|
3701 | +function checkLoginUserStatus() { |
|
3702 | 3702 | } |
3703 | 3703 | |
3704 | 3704 | /** |
@@ -3712,11 +3712,11 @@ discard block |
||
3712 | 3712 | $resulturl = $url; |
3713 | 3713 | |
3714 | 3714 | // if no port, don't change the url |
3715 | - if($port != '') |
|
3715 | + if ($port != '') |
|
3716 | 3716 | { |
3717 | 3717 | $split = explode("/", $url); |
3718 | 3718 | //check if it starts with http, in case they didn't include that in url |
3719 | - if(str_begin($url, 'http')) |
|
3719 | + if (str_begin($url, 'http')) |
|
3720 | 3720 | { |
3721 | 3721 | //third index ($split[2]) will be the host |
3722 | 3722 | $split[2] .= ":".$port; |
@@ -3739,7 +3739,7 @@ discard block |
||
3739 | 3739 | */ |
3740 | 3740 | function getJSONobj() { |
3741 | 3741 | static $json = null; |
3742 | - if(!isset($json)) { |
|
3742 | + if (!isset($json)) { |
|
3743 | 3743 | require_once('include/JSON.php'); |
3744 | 3744 | $json = new JSON(JSON_LOOSE_TYPE); |
3745 | 3745 | } |
@@ -3771,7 +3771,7 @@ discard block |
||
3771 | 3771 | // http://us3.php.net/manual/en/ref.pcre.php#ini.pcre.backtrack-limit |
3772 | 3772 | // starting with 5.2.0, backtrack_limit breaks JSON decoding |
3773 | 3773 | $backtrack_limit = ini_get('pcre.backtrack_limit'); |
3774 | - if(!empty($backtrack_limit)) { |
|
3774 | + if (!empty($backtrack_limit)) { |
|
3775 | 3775 | ini_set('pcre.backtrack_limit', '-1'); |
3776 | 3776 | } |
3777 | 3777 | } |
@@ -3788,19 +3788,19 @@ discard block |
||
3788 | 3788 | */ |
3789 | 3789 | function sugarLangArrayMerge($gimp, $dom) |
3790 | 3790 | { |
3791 | - if(is_array($gimp) && is_array($dom)) |
|
3791 | + if (is_array($gimp) && is_array($dom)) |
|
3792 | 3792 | { |
3793 | - foreach($dom as $domKey => $domVal) |
|
3793 | + foreach ($dom as $domKey => $domVal) |
|
3794 | 3794 | { |
3795 | - if(isset($gimp[$domKey])) |
|
3795 | + if (isset($gimp[$domKey])) |
|
3796 | 3796 | { |
3797 | - if(is_array($domVal)) |
|
3797 | + if (is_array($domVal)) |
|
3798 | 3798 | { |
3799 | 3799 | $tempArr = array(); |
3800 | - foreach ( $domVal as $domArrKey => $domArrVal ) |
|
3800 | + foreach ($domVal as $domArrKey => $domArrVal) |
|
3801 | 3801 | $tempArr[$domArrKey] = $domArrVal; |
3802 | - foreach ( $gimp[$domKey] as $gimpArrKey => $gimpArrVal ) |
|
3803 | - if ( !isset($tempArr[$gimpArrKey]) ) |
|
3802 | + foreach ($gimp[$domKey] as $gimpArrKey => $gimpArrVal) |
|
3803 | + if (!isset($tempArr[$gimpArrKey])) |
|
3804 | 3804 | $tempArr[$gimpArrKey] = $gimpArrVal; |
3805 | 3805 | $gimp[$domKey] = $tempArr; |
3806 | 3806 | } |
@@ -3816,7 +3816,7 @@ discard block |
||
3816 | 3816 | } |
3817 | 3817 | } |
3818 | 3818 | // if the passed value for gimp isn't an array, then return the $dom |
3819 | - elseif(is_array($dom)) |
|
3819 | + elseif (is_array($dom)) |
|
3820 | 3820 | { |
3821 | 3821 | return $dom; |
3822 | 3822 | } |
@@ -3838,15 +3838,15 @@ discard block |
||
3838 | 3838 | * @return array beaten gimp |
3839 | 3839 | */ |
3840 | 3840 | function sugarArrayMerge($gimp, $dom) { |
3841 | - if(is_array($gimp) && is_array($dom)) { |
|
3842 | - foreach($dom as $domKey => $domVal) { |
|
3843 | - if(array_key_exists($domKey, $gimp)) { |
|
3844 | - if(is_array($domVal)) { |
|
3841 | + if (is_array($gimp) && is_array($dom)) { |
|
3842 | + foreach ($dom as $domKey => $domVal) { |
|
3843 | + if (array_key_exists($domKey, $gimp)) { |
|
3844 | + if (is_array($domVal)) { |
|
3845 | 3845 | $tempArr = array(); |
3846 | - foreach ( $domVal as $domArrKey => $domArrVal ) |
|
3846 | + foreach ($domVal as $domArrKey => $domArrVal) |
|
3847 | 3847 | $tempArr[$domArrKey] = $domArrVal; |
3848 | - foreach ( $gimp[$domKey] as $gimpArrKey => $gimpArrVal ) |
|
3849 | - if ( !array_key_exists($gimpArrKey, $tempArr) ) |
|
3848 | + foreach ($gimp[$domKey] as $gimpArrKey => $gimpArrVal) |
|
3849 | + if (!array_key_exists($gimpArrKey, $tempArr)) |
|
3850 | 3850 | $tempArr[$gimpArrKey] = $gimpArrVal; |
3851 | 3851 | $gimp[$domKey] = $tempArr; |
3852 | 3852 | } else { |
@@ -3858,7 +3858,7 @@ discard block |
||
3858 | 3858 | } |
3859 | 3859 | } |
3860 | 3860 | // if the passed value for gimp isn't an array, then return the $dom |
3861 | - elseif(is_array($dom)) |
|
3861 | + elseif (is_array($dom)) |
|
3862 | 3862 | return $dom; |
3863 | 3863 | |
3864 | 3864 | return $gimp; |
@@ -3872,10 +3872,10 @@ discard block |
||
3872 | 3872 | * @return array beaten gimp |
3873 | 3873 | */ |
3874 | 3874 | function sugarArrayMergeRecursive($gimp, $dom) { |
3875 | - if(is_array($gimp) && is_array($dom)) { |
|
3876 | - foreach($dom as $domKey => $domVal) { |
|
3877 | - if(array_key_exists($domKey, $gimp)) { |
|
3878 | - if(is_array($domVal) && is_array($gimp[$domKey])) { |
|
3875 | + if (is_array($gimp) && is_array($dom)) { |
|
3876 | + foreach ($dom as $domKey => $domVal) { |
|
3877 | + if (array_key_exists($domKey, $gimp)) { |
|
3878 | + if (is_array($domVal) && is_array($gimp[$domKey])) { |
|
3879 | 3879 | $gimp[$domKey] = sugarArrayMergeRecursive($gimp[$domKey], $domVal); |
3880 | 3880 | } else { |
3881 | 3881 | $gimp[$domKey] = $domVal; |
@@ -3886,7 +3886,7 @@ discard block |
||
3886 | 3886 | } |
3887 | 3887 | } |
3888 | 3888 | // if the passed value for gimp isn't an array, then return the $dom |
3889 | - elseif(is_array($dom)) |
|
3889 | + elseif (is_array($dom)) |
|
3890 | 3890 | return $dom; |
3891 | 3891 | |
3892 | 3892 | return $gimp; |
@@ -3897,7 +3897,7 @@ discard block |
||
3897 | 3897 | * @return bool True if NOT found or WRONG version |
3898 | 3898 | */ |
3899 | 3899 | function returnPhpJsonStatus() { |
3900 | - if(function_exists('json_encode')) { |
|
3900 | + if (function_exists('json_encode')) { |
|
3901 | 3901 | $phpInfo = getPhpInfo(8); |
3902 | 3902 | return version_compare($phpInfo['json']['json version'], '1.1.1', '<'); |
3903 | 3903 | } |
@@ -3924,16 +3924,16 @@ discard block |
||
3924 | 3924 | |
3925 | 3925 | global $sugar_config; |
3926 | 3926 | |
3927 | - if(!isset($max_tracker_item_length)) { |
|
3928 | - if(isset($sugar_config['tracker_max_display_length'])) { |
|
3927 | + if (!isset($max_tracker_item_length)) { |
|
3928 | + if (isset($sugar_config['tracker_max_display_length'])) { |
|
3929 | 3929 | $max_tracker_item_length = (is_int($sugar_config['tracker_max_display_length']) && $sugar_config['tracker_max_display_length'] > 0 && $sugar_config['tracker_max_display_length'] < 50) ? $sugar_config['tracker_max_display_length'] : 15; |
3930 | 3930 | } else { |
3931 | 3931 | $max_tracker_item_length = 15; |
3932 | 3932 | } |
3933 | 3933 | } |
3934 | 3934 | |
3935 | - if($strlen > $max_tracker_item_length) { |
|
3936 | - $chopped = function_exists('mb_substr') ? mb_substr($name, 0, $max_tracker_item_length-3, "UTF-8") : substr($name, 0, $max_tracker_item_length-3); |
|
3935 | + if ($strlen > $max_tracker_item_length) { |
|
3936 | + $chopped = function_exists('mb_substr') ? mb_substr($name, 0, $max_tracker_item_length - 3, "UTF-8") : substr($name, 0, $max_tracker_item_length - 3); |
|
3937 | 3937 | $chopped .= "..."; |
3938 | 3938 | } else { |
3939 | 3939 | $chopped = $name; |
@@ -3941,51 +3941,51 @@ discard block |
||
3941 | 3941 | |
3942 | 3942 | return $chopped; |
3943 | 3943 | } |
3944 | -function generate_search_where ($field_list=array(),$values=array(),&$bean,$add_custom_fields=false,$module='') { |
|
3945 | - $where_clauses= array(); |
|
3946 | - $like_char='%'; |
|
3947 | - $table_name=$bean->object_name; |
|
3944 | +function generate_search_where($field_list = array(), $values = array(), &$bean, $add_custom_fields = false, $module = '') { |
|
3945 | + $where_clauses = array(); |
|
3946 | + $like_char = '%'; |
|
3947 | + $table_name = $bean->object_name; |
|
3948 | 3948 | foreach ($field_list[$module] as $field=>$parms) { |
3949 | - if(isset($values[$field]) && $values[$field] != "") { |
|
3950 | - $operator='like'; |
|
3949 | + if (isset($values[$field]) && $values[$field] != "") { |
|
3950 | + $operator = 'like'; |
|
3951 | 3951 | if (!empty($parms['operator'])) { |
3952 | - $operator=$parms['operator']; |
|
3952 | + $operator = $parms['operator']; |
|
3953 | 3953 | } |
3954 | 3954 | if (is_array($values[$field])) { |
3955 | - $operator='in'; |
|
3956 | - $field_value=''; |
|
3955 | + $operator = 'in'; |
|
3956 | + $field_value = ''; |
|
3957 | 3957 | foreach ($values[$field] as $key => $val) { |
3958 | 3958 | if ($val != ' ' and $val != '') { |
3959 | 3959 | if (!empty($field_value)) { |
3960 | - $field_value.=','; |
|
3960 | + $field_value .= ','; |
|
3961 | 3961 | } |
3962 | 3962 | $field_value .= "'".$GLOBALS['db']->quote($val)."'"; |
3963 | 3963 | } |
3964 | 3964 | } |
3965 | 3965 | } else { |
3966 | - $field_value=$GLOBALS['db']->quote($values[$field]); |
|
3966 | + $field_value = $GLOBALS['db']->quote($values[$field]); |
|
3967 | 3967 | } |
3968 | 3968 | //set db_fields array. |
3969 | - if (!isset($parms['db_field']) ) { |
|
3969 | + if (!isset($parms['db_field'])) { |
|
3970 | 3970 | $parms['db_field'] = array($field); |
3971 | 3971 | } |
3972 | 3972 | if (isset($parms['my_items']) and $parms['my_items'] == true) { |
3973 | 3973 | global $current_user; |
3974 | 3974 | $field_value = $GLOBALS['db']->quote($current_user->id); |
3975 | - $operator='='; |
|
3975 | + $operator = '='; |
|
3976 | 3976 | } |
3977 | 3977 | |
3978 | - $where=''; |
|
3979 | - $itr=0; |
|
3978 | + $where = ''; |
|
3979 | + $itr = 0; |
|
3980 | 3980 | if ($field_value != '') { |
3981 | 3981 | |
3982 | 3982 | foreach ($parms['db_field'] as $db_field) { |
3983 | - if (strstr($db_field,'.')===false) { |
|
3984 | - $db_field=$bean->table_name.".".$db_field; |
|
3983 | + if (strstr($db_field, '.') === false) { |
|
3984 | + $db_field = $bean->table_name.".".$db_field; |
|
3985 | 3985 | } |
3986 | - if ($GLOBALS['db']->supports('case_sensitive') && isset($parms['query_type']) && $parms['query_type']=='case_insensitive') { |
|
3987 | - $db_field='upper('.$db_field.")"; |
|
3988 | - $field_value=strtoupper($field_value); |
|
3986 | + if ($GLOBALS['db']->supports('case_sensitive') && isset($parms['query_type']) && $parms['query_type'] == 'case_insensitive') { |
|
3987 | + $db_field = 'upper('.$db_field.")"; |
|
3988 | + $field_value = strtoupper($field_value); |
|
3989 | 3989 | } |
3990 | 3990 | |
3991 | 3991 | $itr++; |
@@ -3994,19 +3994,19 @@ discard block |
||
3994 | 3994 | } |
3995 | 3995 | switch (strtolower($operator)) { |
3996 | 3996 | case 'like' : |
3997 | - $where .= $db_field . " like '".$field_value.$like_char."'"; |
|
3997 | + $where .= $db_field." like '".$field_value.$like_char."'"; |
|
3998 | 3998 | break; |
3999 | 3999 | case 'in': |
4000 | - $where .= $db_field . " in (".$field_value.')'; |
|
4000 | + $where .= $db_field." in (".$field_value.')'; |
|
4001 | 4001 | break; |
4002 | 4002 | case '=': |
4003 | - $where .= $db_field . " = '".$field_value ."'"; |
|
4003 | + $where .= $db_field." = '".$field_value."'"; |
|
4004 | 4004 | break; |
4005 | 4005 | } |
4006 | 4006 | } |
4007 | 4007 | } |
4008 | 4008 | if (!empty($where)) { |
4009 | - if ($itr>1) { |
|
4009 | + if ($itr > 1) { |
|
4010 | 4010 | array_push($where_clauses, '( '.$where.' )'); |
4011 | 4011 | } else { |
4012 | 4012 | array_push($where_clauses, $where); |
@@ -4034,13 +4034,13 @@ discard block |
||
4034 | 4034 | */ |
4035 | 4035 | function rebuildConfigFile($sugar_config, $sugar_version) { |
4036 | 4036 | // add defaults to missing values of in-memory sugar_config |
4037 | - $sugar_config = sugarArrayMerge(get_sugar_config_defaults(), $sugar_config ); |
|
4037 | + $sugar_config = sugarArrayMerge(get_sugar_config_defaults(), $sugar_config); |
|
4038 | 4038 | // need to override version with default no matter what |
4039 | 4039 | $sugar_config['sugar_version'] = $sugar_version; |
4040 | 4040 | |
4041 | - ksort( $sugar_config ); |
|
4041 | + ksort($sugar_config); |
|
4042 | 4042 | |
4043 | - if( write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ){ |
|
4043 | + if (write_array_to_file("sugar_config", $sugar_config, "config.php")) { |
|
4044 | 4044 | return true; |
4045 | 4045 | } |
4046 | 4046 | else { |
@@ -4073,40 +4073,40 @@ discard block |
||
4073 | 4073 | */ |
4074 | 4074 | function getJavascriptSiteURL() { |
4075 | 4075 | global $sugar_config; |
4076 | - if(!empty($_SERVER['HTTP_REFERER'])) { |
|
4076 | + if (!empty($_SERVER['HTTP_REFERER'])) { |
|
4077 | 4077 | $url = parse_url($_SERVER['HTTP_REFERER']); |
4078 | 4078 | $replacement_url = $url['scheme']."://".$url['host']; |
4079 | - if(!empty($url['port'])) |
|
4079 | + if (!empty($url['port'])) |
|
4080 | 4080 | $replacement_url .= ':'.$url['port']; |
4081 | - $site_url = preg_replace('/^http[s]?\:\/\/[^\/]+/',$replacement_url,$sugar_config['site_url']); |
|
4081 | + $site_url = preg_replace('/^http[s]?\:\/\/[^\/]+/', $replacement_url, $sugar_config['site_url']); |
|
4082 | 4082 | } else { |
4083 | - $site_url = preg_replace('/^http(s)?\:\/\/[^\/]+/',"http$1://".$_SERVER['HTTP_HOST'],$sugar_config['site_url']); |
|
4084 | - if(!empty($_SERVER['SERVER_PORT']) &&$_SERVER['SERVER_PORT'] == '443') { |
|
4085 | - $site_url = preg_replace('/^http\:/','https:',$site_url); |
|
4083 | + $site_url = preg_replace('/^http(s)?\:\/\/[^\/]+/', "http$1://".$_SERVER['HTTP_HOST'], $sugar_config['site_url']); |
|
4084 | + if (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443') { |
|
4085 | + $site_url = preg_replace('/^http\:/', 'https:', $site_url); |
|
4086 | 4086 | } |
4087 | 4087 | } |
4088 | - $GLOBALS['log']->debug("getJavascriptSiteURL(), site_url=". $site_url); |
|
4088 | + $GLOBALS['log']->debug("getJavascriptSiteURL(), site_url=".$site_url); |
|
4089 | 4089 | return $site_url; |
4090 | 4090 | } |
4091 | 4091 | |
4092 | 4092 | // works nicely with array_map() -- can be used to wrap single quotes around each element in an array |
4093 | 4093 | function add_squotes($str) { |
4094 | - return "'" . $str . "'"; |
|
4094 | + return "'".$str."'"; |
|
4095 | 4095 | } |
4096 | 4096 | |
4097 | 4097 | |
4098 | 4098 | // recursive function to count the number of levels within an array |
4099 | -function array_depth($array, $depth_count=-1, $depth_array=array()){ |
|
4099 | +function array_depth($array, $depth_count = -1, $depth_array = array()) { |
|
4100 | 4100 | $depth_count++; |
4101 | - if (is_array($array)){ |
|
4102 | - foreach ($array as $key => $value){ |
|
4101 | + if (is_array($array)) { |
|
4102 | + foreach ($array as $key => $value) { |
|
4103 | 4103 | $depth_array[] = array_depth($value, $depth_count); |
4104 | 4104 | } |
4105 | 4105 | } |
4106 | - else{ |
|
4106 | + else { |
|
4107 | 4107 | return $depth_count; |
4108 | 4108 | } |
4109 | - foreach ($depth_array as $value){ |
|
4109 | + foreach ($depth_array as $value) { |
|
4110 | 4110 | $depth_count = $value > $depth_count ? $value : $depth_count; |
4111 | 4111 | } |
4112 | 4112 | return $depth_count; |
@@ -4125,7 +4125,7 @@ discard block |
||
4125 | 4125 | $group->last_name = $name; |
4126 | 4126 | $group->is_group = 1; |
4127 | 4127 | $group->deleted = 0; |
4128 | - $group->status = 'Active'; // cn: bug 6711 |
|
4128 | + $group->status = 'Active'; // cn: bug 6711 |
|
4129 | 4129 | $group->setPreference('timezone', TimeDate::userTimezone()); |
4130 | 4130 | $group->save(); |
4131 | 4131 | |
@@ -4143,19 +4143,19 @@ discard block |
||
4143 | 4143 | { |
4144 | 4144 | |
4145 | 4145 | $iconName = "icon_{$iconFileName}.gif"; |
4146 | - $iconFound = SugarThemeRegistry::current()->getImageURL($iconName,false); |
|
4146 | + $iconFound = SugarThemeRegistry::current()->getImageURL($iconName, false); |
|
4147 | 4147 | |
4148 | 4148 | //First try un-ucfirst-ing the icon name |
4149 | - if ( empty($iconFound) ) |
|
4150 | - $iconName = "icon_" . strtolower(substr($iconFileName,0,1)).substr($iconFileName,1) . ".gif"; |
|
4151 | - $iconFound = SugarThemeRegistry::current()->getImageURL($iconName,false); |
|
4149 | + if (empty($iconFound)) |
|
4150 | + $iconName = "icon_".strtolower(substr($iconFileName, 0, 1)).substr($iconFileName, 1).".gif"; |
|
4151 | + $iconFound = SugarThemeRegistry::current()->getImageURL($iconName, false); |
|
4152 | 4152 | |
4153 | 4153 | //Next try removing the icon prefix |
4154 | - if ( empty($iconFound) ) |
|
4154 | + if (empty($iconFound)) |
|
4155 | 4155 | $iconName = "{$iconFileName}.gif"; |
4156 | - $iconFound = SugarThemeRegistry::current()->getImageURL($iconName,false); |
|
4156 | + $iconFound = SugarThemeRegistry::current()->getImageURL($iconName, false); |
|
4157 | 4157 | |
4158 | - if ( empty($iconFound) ) |
|
4158 | + if (empty($iconFound)) |
|
4159 | 4159 | $iconName = ''; |
4160 | 4160 | |
4161 | 4161 | return $iconName; |
@@ -4171,12 +4171,12 @@ discard block |
||
4171 | 4171 | * @return string $string <img> tag with corresponding image |
4172 | 4172 | */ |
4173 | 4173 | |
4174 | -function getStudioIcon($iconFileName='', $altFileName='', $width='48', $height='48', $align='baseline', $alt='' ) |
|
4174 | +function getStudioIcon($iconFileName = '', $altFileName = '', $width = '48', $height = '48', $align = 'baseline', $alt = '') |
|
4175 | 4175 | { |
4176 | 4176 | global $app_strings, $theme; |
4177 | 4177 | |
4178 | 4178 | $iconName = _getIcon($iconFileName); |
4179 | - if(empty($iconName)){ |
|
4179 | + if (empty($iconName)) { |
|
4180 | 4180 | $iconName = _getIcon($altFileName); |
4181 | 4181 | if (empty($iconName)) |
4182 | 4182 | { |
@@ -4197,14 +4197,14 @@ discard block |
||
4197 | 4197 | * @return string $string <img> tag with corresponding image |
4198 | 4198 | */ |
4199 | 4199 | |
4200 | -function get_dashlets_dialog_icon($module='', $width='32', $height='32', $align='absmiddle',$alt=''){ |
|
4200 | +function get_dashlets_dialog_icon($module = '', $width = '32', $height = '32', $align = 'absmiddle', $alt = '') { |
|
4201 | 4201 | global $app_strings, $theme; |
4202 | - $iconName = _getIcon($module . "_32"); |
|
4202 | + $iconName = _getIcon($module."_32"); |
|
4203 | 4203 | if (empty($iconName)) |
4204 | 4204 | { |
4205 | 4205 | $iconName = _getIcon($module); |
4206 | 4206 | } |
4207 | - if(empty($iconName)){ |
|
4207 | + if (empty($iconName)) { |
|
4208 | 4208 | return $app_strings['LBL_NO_IMAGE']; |
4209 | 4209 | } |
4210 | 4210 | return SugarThemeRegistry::current()->getImage($iconName, "align=\"$align\" border=\"0\"", $width, $height); |
@@ -4232,9 +4232,9 @@ discard block |
||
4232 | 4232 | function code2utf($num) |
4233 | 4233 | { |
4234 | 4234 | if ($num < 128) return chr($num); |
4235 | - if ($num < 2048) return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
4236 | - if ($num < 65536) return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
4237 | - if ($num < 2097152) return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
4235 | + if ($num < 2048) return chr(($num >> 6) + 192).chr(($num & 63) + 128); |
|
4236 | + if ($num < 65536) return chr(($num >> 12) + 224).chr((($num >> 6) & 63) + 128).chr(($num & 63) + 128); |
|
4237 | + if ($num < 2097152) return chr(($num >> 18) + 240).chr((($num >> 12) & 63) + 128).chr((($num >> 6) & 63) + 128).chr(($num & 63) + 128); |
|
4238 | 4238 | return ''; |
4239 | 4239 | } |
4240 | 4240 | |
@@ -4287,7 +4287,7 @@ discard block |
||
4287 | 4287 | */ |
4288 | 4288 | function chartColors() |
4289 | 4289 | { |
4290 | - if (SugarThemeRegistry::current()->getCSSURL('sugarColors.xml')=='') |
|
4290 | + if (SugarThemeRegistry::current()->getCSSURL('sugarColors.xml') == '') |
|
4291 | 4291 | return SugarThemeRegistry::current()->getImageURL('sugarColors.xml'); |
4292 | 4292 | return SugarThemeRegistry::current()->getCSSURL('sugarColors.xml'); |
4293 | 4293 | } |
@@ -4316,10 +4316,10 @@ discard block |
||
4316 | 4316 | $path = trim($path); |
4317 | 4317 | |
4318 | 4318 | // try to match absolute paths like \\server\share, /directory or c:\ |
4319 | - if ( ( substr($path,0,2) == '\\\\' ) |
|
4320 | - || ( $path[0] == '/' ) |
|
4321 | - || preg_match('/^[A-z]:/i',$path) |
|
4322 | - || $currentServer ) |
|
4319 | + if ((substr($path, 0, 2) == '\\\\') |
|
4320 | + || ($path[0] == '/') |
|
4321 | + || preg_match('/^[A-z]:/i', $path) |
|
4322 | + || $currentServer) |
|
4323 | 4323 | return $path; |
4324 | 4324 | |
4325 | 4325 | return getcwd().'/'.$path; |
@@ -4348,12 +4348,12 @@ discard block |
||
4348 | 4348 | $ua = empty($_SERVER['HTTP_USER_AGENT']) ? "undefined" : strtolower($_SERVER['HTTP_USER_AGENT']); |
4349 | 4349 | |
4350 | 4350 | // first check if we have forced use of the touch enhanced interface |
4351 | - if ( isset($_COOKIE['touchscreen']) && $_COOKIE['touchscreen'] == '1' ) { |
|
4351 | + if (isset($_COOKIE['touchscreen']) && $_COOKIE['touchscreen'] == '1') { |
|
4352 | 4352 | return true; |
4353 | 4353 | } |
4354 | 4354 | |
4355 | 4355 | // next check if we should use the touch interface with our device |
4356 | - if ( strpos($ua, 'ipad') !== false ) { |
|
4356 | + if (strpos($ua, 'ipad') !== false) { |
|
4357 | 4357 | return true; |
4358 | 4358 | } |
4359 | 4359 | |
@@ -4367,30 +4367,30 @@ discard block |
||
4367 | 4367 | */ |
4368 | 4368 | function get_alt_hot_key() { |
4369 | 4369 | $ua = ''; |
4370 | - if ( isset($_SERVER['HTTP_USER_AGENT']) ) |
|
4370 | + if (isset($_SERVER['HTTP_USER_AGENT'])) |
|
4371 | 4371 | $ua = strtolower($_SERVER['HTTP_USER_AGENT']); |
4372 | 4372 | $isMac = strpos($ua, 'mac') !== false; |
4373 | 4373 | $isLinux = strpos($ua, 'linux') !== false; |
4374 | 4374 | |
4375 | - if(!$isMac && !$isLinux && strpos($ua, 'mozilla') !== false) { |
|
4376 | - if(preg_match('/firefox\/(\d)?\./', $ua, $matches)) { |
|
4375 | + if (!$isMac && !$isLinux && strpos($ua, 'mozilla') !== false) { |
|
4376 | + if (preg_match('/firefox\/(\d)?\./', $ua, $matches)) { |
|
4377 | 4377 | return $matches[1] < 2 ? 'Alt+' : 'Alt+Shift+'; |
4378 | 4378 | } |
4379 | 4379 | } |
4380 | 4380 | return $isMac ? 'Ctrl+' : 'Alt+'; |
4381 | 4381 | } |
4382 | 4382 | |
4383 | -function can_start_session(){ |
|
4384 | - if(!empty($_GET['PHPSESSID'])) { |
|
4383 | +function can_start_session() { |
|
4384 | + if (!empty($_GET['PHPSESSID'])) { |
|
4385 | 4385 | return true; |
4386 | 4386 | } |
4387 | 4387 | $session_id = session_id(); |
4388 | 4388 | return empty($session_id) ? true : false; |
4389 | 4389 | } |
4390 | 4390 | |
4391 | -function load_link_class($properties){ |
|
4391 | +function load_link_class($properties) { |
|
4392 | 4392 | $class = 'Link2'; |
4393 | - if(!empty($properties['link_class']) && !empty($properties['link_file'])){ |
|
4393 | + if (!empty($properties['link_class']) && !empty($properties['link_file'])) { |
|
4394 | 4394 | require_once($properties['link_file']); |
4395 | 4395 | $class = $properties['link_class']; |
4396 | 4396 | } |
@@ -4410,9 +4410,9 @@ discard block |
||
4410 | 4410 | */ |
4411 | 4411 | function filterInboundEmailPopSelection($protocol) |
4412 | 4412 | { |
4413 | - if ( !isset($GLOBALS['sugar_config']['allow_pop_inbound']) || ! $GLOBALS['sugar_config']['allow_pop_inbound'] ) |
|
4413 | + if (!isset($GLOBALS['sugar_config']['allow_pop_inbound']) || !$GLOBALS['sugar_config']['allow_pop_inbound']) |
|
4414 | 4414 | { |
4415 | - if( isset($protocol['pop3']) ) |
|
4415 | + if (isset($protocol['pop3'])) |
|
4416 | 4416 | unset($protocol['pop3']); |
4417 | 4417 | } |
4418 | 4418 | else |
@@ -4427,10 +4427,10 @@ discard block |
||
4427 | 4427 | * The varchar in MySQL, Orcale, and nvarchar in FreeTDS, we can store $length mutilbyte charaters in it. we need mb_substr to keep more info. |
4428 | 4428 | * @returns the substred strings. |
4429 | 4429 | */ |
4430 | -function sugar_substr($string, $length, $charset='UTF-8') |
|
4430 | +function sugar_substr($string, $length, $charset = 'UTF-8') |
|
4431 | 4431 | { |
4432 | - if(mb_strlen($string,$charset) > $length) { |
|
4433 | - $string = trim(mb_substr(trim($string),0,$length,$charset)); |
|
4432 | + if (mb_strlen($string, $charset) > $length) { |
|
4433 | + $string = trim(mb_substr(trim($string), 0, $length, $charset)); |
|
4434 | 4434 | } |
4435 | 4435 | return $string; |
4436 | 4436 | } |
@@ -4439,8 +4439,8 @@ discard block |
||
4439 | 4439 | * The function is used because on FastCGI enviroment, the ucfirst(Chinese Characters) will produce bad charcters. |
4440 | 4440 | * This will work even without setting the mbstring.*encoding |
4441 | 4441 | */ |
4442 | -function sugar_ucfirst($string, $charset='UTF-8') { |
|
4443 | - return mb_strtoupper(mb_substr($string, 0, 1, $charset), $charset) . mb_substr($string, 1, mb_strlen($string), $charset); |
|
4442 | +function sugar_ucfirst($string, $charset = 'UTF-8') { |
|
4443 | + return mb_strtoupper(mb_substr($string, 0, 1, $charset), $charset).mb_substr($string, 1, mb_strlen($string), $charset); |
|
4444 | 4444 | } |
4445 | 4445 | |
4446 | 4446 | |
@@ -4452,8 +4452,8 @@ discard block |
||
4452 | 4452 | { |
4453 | 4453 | return $string; |
4454 | 4454 | } |
4455 | - if (substr($string, 0 ,1) == "^" && substr($string, -1) == "^") { |
|
4456 | - $string = substr(substr($string, 1), 0, strlen($string) -2); |
|
4455 | + if (substr($string, 0, 1) == "^" && substr($string, -1) == "^") { |
|
4456 | + $string = substr(substr($string, 1), 0, strlen($string) - 2); |
|
4457 | 4457 | } |
4458 | 4458 | |
4459 | 4459 | return explode('^,^', $string); |
@@ -4466,7 +4466,7 @@ discard block |
||
4466 | 4466 | if (empty($arr)) |
4467 | 4467 | return ""; |
4468 | 4468 | |
4469 | - $string = "^" . implode('^,^', $arr) . "^"; |
|
4469 | + $string = "^".implode('^,^', $arr)."^"; |
|
4470 | 4470 | |
4471 | 4471 | return $string; |
4472 | 4472 | } |
@@ -4481,19 +4481,19 @@ discard block |
||
4481 | 4481 | * @return $ret_array['where']: corrected where clause |
4482 | 4482 | * @return $ret_array['join']: extra join condition |
4483 | 4483 | */ |
4484 | -function create_export_query_relate_link_patch($module, $searchFields, $where){ |
|
4485 | - if(file_exists('modules/'.$module.'/SearchForm.html')){ |
|
4484 | +function create_export_query_relate_link_patch($module, $searchFields, $where) { |
|
4485 | + if (file_exists('modules/'.$module.'/SearchForm.html')) { |
|
4486 | 4486 | $ret_array['where'] = $where; |
4487 | 4487 | return $ret_array; |
4488 | 4488 | } |
4489 | 4489 | $seed = loadBean($module); |
4490 | - foreach($seed->field_defs as $name=>$field) |
|
4490 | + foreach ($seed->field_defs as $name=>$field) |
|
4491 | 4491 | { |
4492 | 4492 | |
4493 | - if( $field['type'] == 'relate' && isset($field['link']) && !empty($searchFields[$name]['value']) ){ |
|
4493 | + if ($field['type'] == 'relate' && isset($field['link']) && !empty($searchFields[$name]['value'])) { |
|
4494 | 4494 | $seed->load_relationship($field['link']); |
4495 | 4495 | $params = array(); |
4496 | - if(empty($join_type)) |
|
4496 | + if (empty($join_type)) |
|
4497 | 4497 | { |
4498 | 4498 | $params['join_type'] = ' LEFT JOIN '; |
4499 | 4499 | } |
@@ -4501,16 +4501,16 @@ discard block |
||
4501 | 4501 | { |
4502 | 4502 | $params['join_type'] = $join_type; |
4503 | 4503 | } |
4504 | - if(isset($data['join_name'])) |
|
4504 | + if (isset($data['join_name'])) |
|
4505 | 4505 | { |
4506 | 4506 | $params['join_table_alias'] = $field['join_name']; |
4507 | 4507 | } |
4508 | 4508 | else |
4509 | 4509 | { |
4510 | - $params['join_table_alias'] = 'join_'.$field['name']; |
|
4510 | + $params['join_table_alias'] = 'join_'.$field['name']; |
|
4511 | 4511 | |
4512 | 4512 | } |
4513 | - if(isset($data['join_link_name'])) |
|
4513 | + if (isset($data['join_link_name'])) |
|
4514 | 4514 | { |
4515 | 4515 | $params['join_table_link_alias'] = $field['join_link_name']; |
4516 | 4516 | } |
@@ -4520,11 +4520,11 @@ discard block |
||
4520 | 4520 | } |
4521 | 4521 | $join = $seed->$field['link']->getJoin($params, true); |
4522 | 4522 | $join_table_alias = 'join_'.$field['name']; |
4523 | - if(isset($field['db_concat_fields'])){ |
|
4523 | + if (isset($field['db_concat_fields'])) { |
|
4524 | 4524 | $db_field = db_concat($join_table_alias, $field['db_concat_fields']); |
4525 | 4525 | $where = preg_replace('/'.$field['name'].'/', $db_field, $where); |
4526 | - }else{ |
|
4527 | - $where = preg_replace('/(^|[\s(])' . $field['name'] . '/', '${1}' . $join_table_alias . '.'.$field['rname'], $where); |
|
4526 | + } else { |
|
4527 | + $where = preg_replace('/(^|[\s(])'.$field['name'].'/', '${1}'.$join_table_alias.'.'.$field['rname'], $where); |
|
4528 | 4528 | } |
4529 | 4529 | } |
4530 | 4530 | } |
@@ -4537,11 +4537,11 @@ discard block |
||
4537 | 4537 | * @Depends on QuickRepairAndRebuild.php |
4538 | 4538 | * @Relate bug 30642 ,23177 |
4539 | 4539 | */ |
4540 | -function clearAllJsAndJsLangFilesWithoutOutput(){ |
|
4541 | - global $current_language , $mod_strings; |
|
4540 | +function clearAllJsAndJsLangFilesWithoutOutput() { |
|
4541 | + global $current_language, $mod_strings; |
|
4542 | 4542 | $MBmodStrings = $mod_strings; |
4543 | - $mod_strings = return_module_language ( $current_language, 'Administration' ) ; |
|
4544 | - include_once ('modules/Administration/QuickRepairAndRebuild.php') ; |
|
4543 | + $mod_strings = return_module_language($current_language, 'Administration'); |
|
4544 | + include_once ('modules/Administration/QuickRepairAndRebuild.php'); |
|
4545 | 4545 | $repair = new RepairAndClear(); |
4546 | 4546 | $repair->module_list = array(); |
4547 | 4547 | $repair->show_output = false; |
@@ -4553,13 +4553,13 @@ discard block |
||
4553 | 4553 | /** |
4554 | 4554 | * This function will allow you to get a variable value from query string |
4555 | 4555 | */ |
4556 | -function getVariableFromQueryString($variable, $string){ |
|
4556 | +function getVariableFromQueryString($variable, $string) { |
|
4557 | 4557 | $matches = array(); |
4558 | 4558 | $number = preg_match("/{$variable}=([a-zA-Z0-9_-]+)[&]?/", $string, $matches); |
4559 | - if($number){ |
|
4559 | + if ($number) { |
|
4560 | 4560 | return $matches[1]; |
4561 | 4561 | } |
4562 | - else{ |
|
4562 | + else { |
|
4563 | 4563 | return false; |
4564 | 4564 | } |
4565 | 4565 | } |
@@ -4573,8 +4573,8 @@ discard block |
||
4573 | 4573 | */ |
4574 | 4574 | function should_hide_iframes() { |
4575 | 4575 | //Remove the MySites module |
4576 | - if(file_exists('modules/iFrames/iFrame.php')) { |
|
4577 | - if(!class_exists("iFrame")) { |
|
4576 | + if (file_exists('modules/iFrames/iFrame.php')) { |
|
4577 | + if (!class_exists("iFrame")) { |
|
4578 | 4578 | require_once('modules/iFrames/iFrame.php'); |
4579 | 4579 | } |
4580 | 4580 | return false; |
@@ -4588,10 +4588,10 @@ discard block |
||
4588 | 4588 | * @param string $version |
4589 | 4589 | * @return string RC, BETA, GA |
4590 | 4590 | */ |
4591 | -function getVersionStatus($version){ |
|
4592 | - if(preg_match('/^[\d\.]+?([a-zA-Z]+?)[\d]*?$/si', $version, $matches)) { |
|
4591 | +function getVersionStatus($version) { |
|
4592 | + if (preg_match('/^[\d\.]+?([a-zA-Z]+?)[\d]*?$/si', $version, $matches)) { |
|
4593 | 4593 | return strtoupper($matches[1]); |
4594 | - }else{ |
|
4594 | + } else { |
|
4595 | 4595 | return 'GA'; |
4596 | 4596 | } |
4597 | 4597 | } |
@@ -4603,12 +4603,12 @@ discard block |
||
4603 | 4603 | * @param string $version |
4604 | 4604 | * @return version |
4605 | 4605 | */ |
4606 | -function getMajorMinorVersion($version){ |
|
4607 | - if(preg_match('/^([\d\.]+).*$/si', $version, $matches2)){ |
|
4606 | +function getMajorMinorVersion($version) { |
|
4607 | + if (preg_match('/^([\d\.]+).*$/si', $version, $matches2)) { |
|
4608 | 4608 | $version = $matches2[1]; |
4609 | 4609 | $arr = explode('.', $version); |
4610 | - if(count($arr) > 2){ |
|
4611 | - if($arr[2] == '0'){ |
|
4610 | + if (count($arr) > 2) { |
|
4611 | + if ($arr[2] == '0') { |
|
4612 | 4612 | $version = substr($version, 0, 3); |
4613 | 4613 | } |
4614 | 4614 | } |
@@ -4636,10 +4636,10 @@ discard block |
||
4636 | 4636 | { |
4637 | 4637 | $lines = explode("<br>", trim($string)); |
4638 | 4638 | $urls = array(); |
4639 | - foreach($lines as $line){ |
|
4639 | + foreach ($lines as $line) { |
|
4640 | 4640 | $regex = '/http?\:\/\/[^\" ]+/i'; |
4641 | 4641 | preg_match_all($regex, $line, $matches); |
4642 | - foreach($matches[0] as $match){ |
|
4642 | + foreach ($matches[0] as $match) { |
|
4643 | 4643 | $urls[] = $match; |
4644 | 4644 | } |
4645 | 4645 | } |
@@ -4654,20 +4654,20 @@ discard block |
||
4654 | 4654 | */ |
4655 | 4655 | function verify_image_file($path, $jpeg = false) |
4656 | 4656 | { |
4657 | - if(function_exists('imagepng') && function_exists('imagejpeg') && function_exists('imagecreatefromstring')) { |
|
4657 | + if (function_exists('imagepng') && function_exists('imagejpeg') && function_exists('imagecreatefromstring')) { |
|
4658 | 4658 | $img = imagecreatefromstring(file_get_contents($path)); |
4659 | - if(!$img) { |
|
4659 | + if (!$img) { |
|
4660 | 4660 | return false; |
4661 | 4661 | } |
4662 | 4662 | $img_size = getimagesize($path); |
4663 | 4663 | $filetype = $img_size['mime']; |
4664 | 4664 | //if filetype is jpeg or if we are only allowing jpegs, create jpg image |
4665 | - if($filetype == "image/jpeg" || $jpeg) { |
|
4665 | + if ($filetype == "image/jpeg" || $jpeg) { |
|
4666 | 4666 | ob_start(); |
4667 | 4667 | imagejpeg($img); |
4668 | 4668 | $image = ob_get_clean(); |
4669 | 4669 | // not writing directly because imagejpeg does not work with streams |
4670 | - if(file_put_contents($path, $image)) { |
|
4670 | + if (file_put_contents($path, $image)) { |
|
4671 | 4671 | return true; |
4672 | 4672 | } |
4673 | 4673 | } elseif ($filetype == "image/png") { |
@@ -4677,7 +4677,7 @@ discard block |
||
4677 | 4677 | ob_start(); |
4678 | 4678 | imagepng($img); |
4679 | 4679 | $image = ob_get_clean(); |
4680 | - if(file_put_contents($path, $image)) { |
|
4680 | + if (file_put_contents($path, $image)) { |
|
4681 | 4681 | return true; |
4682 | 4682 | } |
4683 | 4683 | } else { |
@@ -4686,15 +4686,15 @@ discard block |
||
4686 | 4686 | } else { |
4687 | 4687 | // check image manually |
4688 | 4688 | $fp = fopen($path, "rb"); |
4689 | - if(!$fp) return false; |
|
4689 | + if (!$fp) return false; |
|
4690 | 4690 | $data = ''; |
4691 | 4691 | // read the whole file in chunks |
4692 | - while(!feof($fp)) { |
|
4693 | - $data .= fread($fp,8192); |
|
4692 | + while (!feof($fp)) { |
|
4693 | + $data .= fread($fp, 8192); |
|
4694 | 4694 | } |
4695 | 4695 | |
4696 | 4696 | fclose($fp); |
4697 | - if(preg_match("/<(\?php|html|!doctype|script|body|head|plaintext|table|img |pre(>| )|frameset|iframe|object|link|base|style|font|applet|meta|center|form|isindex)/i", |
|
4697 | + if (preg_match("/<(\?php|html|!doctype|script|body|head|plaintext|table|img |pre(>| )|frameset|iframe|object|link|base|style|font|applet|meta|center|form|isindex)/i", |
|
4698 | 4698 | $data, $m)) { |
4699 | 4699 | $GLOBALS['log']->fatal("Found {$m[0]} in $path, not allowing upload"); |
4700 | 4700 | return false; |
@@ -4713,18 +4713,18 @@ discard block |
||
4713 | 4713 | function verify_uploaded_image($path, $jpeg_only = false) |
4714 | 4714 | { |
4715 | 4715 | $supportedExtensions = array('jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg'); |
4716 | - if(!$jpeg_only) { |
|
4716 | + if (!$jpeg_only) { |
|
4717 | 4717 | $supportedExtensions['png'] = 'image/png'; |
4718 | 4718 | } |
4719 | 4719 | |
4720 | - if(!file_exists($path) || !is_file($path)) { |
|
4720 | + if (!file_exists($path) || !is_file($path)) { |
|
4721 | 4721 | return false; |
4722 | 4722 | } |
4723 | 4723 | |
4724 | 4724 | $img_size = getimagesize($path); |
4725 | 4725 | $filetype = $img_size['mime']; |
4726 | 4726 | $ext = end(explode(".", $path)); |
4727 | - if(substr_count('..', $path) > 0 || ($ext !== $path && !isset($supportedExtensions[strtolower($ext)])) || |
|
4727 | + if (substr_count('..', $path) > 0 || ($ext !== $path && !isset($supportedExtensions[strtolower($ext)])) || |
|
4728 | 4728 | !in_array($filetype, array_values($supportedExtensions))) { |
4729 | 4729 | return false; |
4730 | 4730 | } |
@@ -4735,7 +4735,7 @@ discard block |
||
4735 | 4735 | { |
4736 | 4736 | global $sugar_web_service_order_by; |
4737 | 4737 | //If the order_by field is not valid, return 0; |
4738 | - if (empty($sugar_web_service_order_by) || !isset($a->$sugar_web_service_order_by) || !isset($b->$sugar_web_service_order_by)){ |
|
4738 | + if (empty($sugar_web_service_order_by) || !isset($a->$sugar_web_service_order_by) || !isset($b->$sugar_web_service_order_by)) { |
|
4739 | 4739 | return 0; |
4740 | 4740 | } |
4741 | 4741 | if (is_object($a->$sugar_web_service_order_by) || is_object($b->$sugar_web_service_order_by) |
@@ -4778,13 +4778,13 @@ discard block |
||
4778 | 4778 | // add wildcard at the beginning of the search string |
4779 | 4779 | if (isset($GLOBALS['sugar_config']['search_wildcard_infront']) && |
4780 | 4780 | $GLOBALS['sugar_config']['search_wildcard_infront'] == true) { |
4781 | - if (substr($str,0,1) <> $wildcard) |
|
4781 | + if (substr($str, 0, 1) <> $wildcard) |
|
4782 | 4782 | $str = $wildcard.$str; |
4783 | 4783 | } |
4784 | 4784 | |
4785 | 4785 | // add wildcard at the end of search string (default) |
4786 | 4786 | if ($appendWildcard) { |
4787 | - if(substr($str,-1) <> $wildcard) { |
|
4787 | + if (substr($str, -1) <> $wildcard) { |
|
4788 | 4788 | $str .= $wildcard; |
4789 | 4789 | } |
4790 | 4790 | } |
@@ -4793,12 +4793,12 @@ discard block |
||
4793 | 4793 | } |
4794 | 4794 | |
4795 | 4795 | //check to see if custom utils exists |
4796 | -if(file_exists('custom/include/custom_utils.php')){ |
|
4796 | +if (file_exists('custom/include/custom_utils.php')) { |
|
4797 | 4797 | include_once('custom/include/custom_utils.php'); |
4798 | 4798 | } |
4799 | 4799 | |
4800 | 4800 | //check to see if custom utils exists in Extension framework |
4801 | -if(file_exists('custom/application/Ext/Utils/custom_utils.ext.php')) { |
|
4801 | +if (file_exists('custom/application/Ext/Utils/custom_utils.ext.php')) { |
|
4802 | 4802 | include_once('custom/application/Ext/Utils/custom_utils.ext.php'); |
4803 | 4803 | } |
4804 | 4804 | /** |
@@ -4852,8 +4852,8 @@ discard block |
||
4852 | 4852 | function utf8_recursive_encode($data) |
4853 | 4853 | { |
4854 | 4854 | $result = array(); |
4855 | - foreach($data as $key=>$val) { |
|
4856 | - if(is_array($val)) { |
|
4855 | + foreach ($data as $key=>$val) { |
|
4856 | + if (is_array($val)) { |
|
4857 | 4857 | $result[$key] = utf8_recursive_encode($val); |
4858 | 4858 | } else { |
4859 | 4859 | $result[$key] = utf8_encode($val); |
@@ -4917,12 +4917,12 @@ discard block |
||
4917 | 4917 | $sendUrl = $sugar_config['custom_help_url']; |
4918 | 4918 | } else { |
4919 | 4919 | if (!empty($sugar_config['custom_help_base_url'])) { |
4920 | - $baseUrl= $sugar_config['custom_help_base_url']; |
|
4920 | + $baseUrl = $sugar_config['custom_help_base_url']; |
|
4921 | 4921 | } else { |
4922 | 4922 | $baseUrl = "http://www.sugarcrm.com/crm/product_doc.php"; |
4923 | 4923 | } |
4924 | - $sendUrl = $baseUrl . "?edition={$send_edition}&version={$send_version}&lang={$send_lang}&module={$send_module}&help_action={$send_action}&status={$dev_status}&key={$send_key}"; |
|
4925 | - if(!empty($send_anchor)) { |
|
4924 | + $sendUrl = $baseUrl."?edition={$send_edition}&version={$send_version}&lang={$send_lang}&module={$send_module}&help_action={$send_action}&status={$dev_status}&key={$send_key}"; |
|
4925 | + if (!empty($send_anchor)) { |
|
4926 | 4926 | $sendUrl .= "&anchor=".$send_anchor; |
4927 | 4927 | } |
4928 | 4928 | } |
@@ -4937,13 +4937,13 @@ discard block |
||
4937 | 4937 | * |
4938 | 4938 | * @param string $etag ETag to use for this content. |
4939 | 4939 | */ |
4940 | -function generateETagHeader($etag){ |
|
4940 | +function generateETagHeader($etag) { |
|
4941 | 4941 | header("cache-control:"); |
4942 | 4942 | header('Expires: '); |
4943 | - header("ETag: " . $etag); |
|
4943 | + header("ETag: ".$etag); |
|
4944 | 4944 | header("Pragma:"); |
4945 | - if(isset($_SERVER["HTTP_IF_NONE_MATCH"])){ |
|
4946 | - if($etag == $_SERVER["HTTP_IF_NONE_MATCH"]){ |
|
4945 | + if (isset($_SERVER["HTTP_IF_NONE_MATCH"])) { |
|
4946 | + if ($etag == $_SERVER["HTTP_IF_NONE_MATCH"]) { |
|
4947 | 4947 | ob_clean(); |
4948 | 4948 | header("Status: 304 Not Modified"); |
4949 | 4949 | header("HTTP/1.0 304 Not Modified"); |
@@ -4988,12 +4988,12 @@ discard block |
||
4988 | 4988 | */ |
4989 | 4989 | function clean_sensitive_data($defs, $data) |
4990 | 4990 | { |
4991 | - foreach($defs as $field => $def) { |
|
4992 | - if(!empty($def['sensitive'])) { |
|
4993 | - if(is_array($data)) { |
|
4991 | + foreach ($defs as $field => $def) { |
|
4992 | + if (!empty($def['sensitive'])) { |
|
4993 | + if (is_array($data)) { |
|
4994 | 4994 | $data[$field] = ''; |
4995 | 4995 | } |
4996 | - if($data instanceof SugarBean) { |
|
4996 | + if ($data instanceof SugarBean) { |
|
4997 | 4997 | $data->$field = ''; |
4998 | 4998 | } |
4999 | 4999 | } |
@@ -5027,7 +5027,7 @@ discard block |
||
5027 | 5027 | // Add the relationship name for easier recognition |
5028 | 5028 | foreach ($select_array as $key => $value) |
5029 | 5029 | { |
5030 | - $select_array[$key] .= ' (' . $key . ')'; |
|
5030 | + $select_array[$key] .= ' ('.$key.')'; |
|
5031 | 5031 | } |
5032 | 5032 | } |
5033 | 5033 | asort($select_array); |
@@ -5056,7 +5056,7 @@ discard block |
||
5056 | 5056 | */ |
5057 | 5057 | function assignConcatenatedValue(SugarBean $bean, $fieldDef, $value) |
5058 | 5058 | { |
5059 | - $valueParts = explode(' ',$value); |
|
5059 | + $valueParts = explode(' ', $value); |
|
5060 | 5060 | $valueParts = array_filter($valueParts); |
5061 | 5061 | $fieldNum = count($fieldDef['db_concat_fields']); |
5062 | 5062 | |
@@ -5076,56 +5076,56 @@ discard block |
||
5076 | 5076 | |
5077 | 5077 | if (!empty($valueParts)) |
5078 | 5078 | { |
5079 | - $bean->$fieldName .= ' ' . implode(' ', $valueParts); |
|
5079 | + $bean->$fieldName .= ' '.implode(' ', $valueParts); |
|
5080 | 5080 | } |
5081 | 5081 | } |
5082 | 5082 | } |
5083 | 5083 | |
5084 | -define("DEFAULT_UTIL_SUITE_ENCODING","UTF-8"); |
|
5084 | +define("DEFAULT_UTIL_SUITE_ENCODING", "UTF-8"); |
|
5085 | 5085 | |
5086 | 5086 | function suite_strlen($input, $encoding = DEFAULT_UTIL_SUITE_ENCODING) |
5087 | 5087 | { |
5088 | - if(function_exists('mb_strlen')) |
|
5089 | - return mb_strlen($input,$encoding); |
|
5088 | + if (function_exists('mb_strlen')) |
|
5089 | + return mb_strlen($input, $encoding); |
|
5090 | 5090 | else |
5091 | 5091 | return strlen($input); |
5092 | 5092 | } |
5093 | 5093 | |
5094 | -function suite_substr($input, $start, $length = null,$encoding = DEFAULT_UTIL_SUITE_ENCODING) |
|
5094 | +function suite_substr($input, $start, $length = null, $encoding = DEFAULT_UTIL_SUITE_ENCODING) |
|
5095 | 5095 | { |
5096 | - if(function_exists('mb_substr')) |
|
5097 | - return mb_substr($input,$start,$length,$encoding); |
|
5096 | + if (function_exists('mb_substr')) |
|
5097 | + return mb_substr($input, $start, $length, $encoding); |
|
5098 | 5098 | else |
5099 | - return substr($input,$start,$length); |
|
5099 | + return substr($input, $start, $length); |
|
5100 | 5100 | } |
5101 | 5101 | |
5102 | -function suite_strtoupper($input,$encoding = DEFAULT_UTIL_SUITE_ENCODING) |
|
5102 | +function suite_strtoupper($input, $encoding = DEFAULT_UTIL_SUITE_ENCODING) |
|
5103 | 5103 | { |
5104 | - if(function_exists('mb_strtoupper')) |
|
5105 | - return mb_strtoupper($input,$encoding); |
|
5104 | + if (function_exists('mb_strtoupper')) |
|
5105 | + return mb_strtoupper($input, $encoding); |
|
5106 | 5106 | else |
5107 | 5107 | return strtoupper($input); |
5108 | 5108 | } |
5109 | -function suite_strtolower($input,$encoding = DEFAULT_UTIL_SUITE_ENCODING) |
|
5109 | +function suite_strtolower($input, $encoding = DEFAULT_UTIL_SUITE_ENCODING) |
|
5110 | 5110 | { |
5111 | - if(function_exists('mb_strtolower')) |
|
5112 | - return mb_strtolower($input,$encoding); |
|
5111 | + if (function_exists('mb_strtolower')) |
|
5112 | + return mb_strtolower($input, $encoding); |
|
5113 | 5113 | else |
5114 | 5114 | return strtolower($input); |
5115 | 5115 | } |
5116 | 5116 | |
5117 | -function suite_strpos($haystack,$needle,$offset=0,$encoding = DEFAULT_UTIL_SUITE_ENCODING) |
|
5117 | +function suite_strpos($haystack, $needle, $offset = 0, $encoding = DEFAULT_UTIL_SUITE_ENCODING) |
|
5118 | 5118 | { |
5119 | - if(function_exists('mb_strpos')) |
|
5120 | - return mb_strpos($haystack,$needle,$offset,$encoding); |
|
5119 | + if (function_exists('mb_strpos')) |
|
5120 | + return mb_strpos($haystack, $needle, $offset, $encoding); |
|
5121 | 5121 | else |
5122 | - return strpos($haystack,$needle,$offset); |
|
5122 | + return strpos($haystack, $needle, $offset); |
|
5123 | 5123 | } |
5124 | 5124 | |
5125 | -function suite_strrpos($haystack,$needle,$offset=0,$encoding = DEFAULT_UTIL_SUITE_ENCODING) |
|
5125 | +function suite_strrpos($haystack, $needle, $offset = 0, $encoding = DEFAULT_UTIL_SUITE_ENCODING) |
|
5126 | 5126 | { |
5127 | - if(function_exists('mb_strrpos')) |
|
5128 | - return mb_strrpos($haystack,$needle,$offset,$encoding); |
|
5127 | + if (function_exists('mb_strrpos')) |
|
5128 | + return mb_strrpos($haystack, $needle, $offset, $encoding); |
|
5129 | 5129 | else |
5130 | - return strrpos($haystack,$needle,$offset); |
|
5130 | + return strrpos($haystack, $needle, $offset); |
|
5131 | 5131 | } |
5132 | 5132 | \ No newline at end of file |
@@ -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. |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | require_once('include/TemplateHandler/TemplateHandler.php'); |
44 | 44 | require_once('include/SearchForm/SearchForm2.php'); |
45 | 45 | define("NUM_COLS", 2); |
46 | -class PopupSmarty extends ListViewSmarty{ |
|
46 | +class PopupSmarty extends ListViewSmarty { |
|
47 | 47 | |
48 | 48 | var $contextMenus = false; |
49 | 49 | var $export = false; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | var $module; |
71 | 71 | var $massUpdateData = ''; |
72 | 72 | |
73 | - function PopupSmarty($seed, $module){ |
|
73 | + function PopupSmarty($seed, $module) { |
|
74 | 74 | parent::ListViewSmarty(); |
75 | 75 | $this->th = new TemplateHandler(); |
76 | 76 | $this->th->loadSmarty(); |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | */ |
92 | 92 | function processArrowVars() |
93 | 93 | { |
94 | - $pathParts = pathinfo(SugarThemeRegistry::current()->getImageURL('arrow.gif',false)); |
|
94 | + $pathParts = pathinfo(SugarThemeRegistry::current()->getImageURL('arrow.gif', false)); |
|
95 | 95 | |
96 | - list($width,$height) = getimagesize($pathParts['dirname'].'/'.$pathParts['basename']); |
|
96 | + list($width, $height) = getimagesize($pathParts['dirname'].'/'.$pathParts['basename']); |
|
97 | 97 | |
98 | 98 | $this->th->ss->assign('arrowExt', $pathParts['extension']); |
99 | 99 | $this->th->ss->assign('arrowWidth', $width); |
@@ -119,16 +119,16 @@ discard block |
||
119 | 119 | $this->data = $data; |
120 | 120 | |
121 | 121 | $totalWidth = 0; |
122 | - foreach($this->displayColumns as $name => $params) { |
|
122 | + foreach ($this->displayColumns as $name => $params) { |
|
123 | 123 | $totalWidth += $params['width']; |
124 | 124 | } |
125 | 125 | $adjustment = $totalWidth / 100; |
126 | 126 | |
127 | 127 | $contextMenuObjectsTypes = array(); |
128 | - foreach($this->displayColumns as $name => $params) { |
|
128 | + foreach ($this->displayColumns as $name => $params) { |
|
129 | 129 | $this->displayColumns[$name]['width'] = round($this->displayColumns[$name]['width'] / $adjustment, 2); |
130 | 130 | // figure out which contextMenu objectsTypes are required |
131 | - if(!empty($params['contextMenu']['objectType'])) |
|
131 | + if (!empty($params['contextMenu']['objectType'])) |
|
132 | 132 | $contextMenuObjectsTypes[$params['contextMenu']['objectType']] = true; |
133 | 133 | } |
134 | 134 | $this->th->ss->assign('displayColumns', $this->displayColumns); |
@@ -147,22 +147,22 @@ discard block |
||
147 | 147 | $this->th->ss->assign('searchForm', $this->searchForm->display(false)); |
148 | 148 | //rrs |
149 | 149 | |
150 | - if($this->export) $this->th->ss->assign('exportLink', $this->buildExportLink()); |
|
150 | + if ($this->export) $this->th->ss->assign('exportLink', $this->buildExportLink()); |
|
151 | 151 | $this->th->ss->assign('quickViewLinks', $this->quickViewLinks); |
152 | - if($this->mailMerge) $this->th->ss->assign('mergeLink', $this->buildMergeLink()); // still check for mailmerge access |
|
153 | - if($this->mergeduplicates) $this->th->ss->assign('mergedupLink', $this->buildMergeDuplicatesLink()); |
|
152 | + if ($this->mailMerge) $this->th->ss->assign('mergeLink', $this->buildMergeLink()); // still check for mailmerge access |
|
153 | + if ($this->mergeduplicates) $this->th->ss->assign('mergedupLink', $this->buildMergeDuplicatesLink()); |
|
154 | 154 | |
155 | 155 | |
156 | 156 | if (!empty($_REQUEST['mode']) && strtoupper($_REQUEST['mode']) == 'MULTISELECT') { |
157 | 157 | $this->multiSelect = true; |
158 | 158 | } |
159 | 159 | // handle save checks and stuff |
160 | - if($this->multiSelect) { |
|
160 | + if ($this->multiSelect) { |
|
161 | 161 | $this->th->ss->assign('selectedObjectsSpan', $this->buildSelectedObjectsSpan()); |
162 | 162 | $this->th->ss->assign('multiSelectData', $this->getMultiSelectData()); |
163 | 163 | $this->th->ss->assign('MODE', "<input type='hidden' name='mode' value='MultiSelect'>"); |
164 | 164 | $pageTotal = $this->data['pageData']['offsets']['next'] - $this->data['pageData']['offsets']['current']; |
165 | - if($this->data['pageData']['offsets']['next'] < 0){ // If we are on the last page, 'next' is -1, which means we have to have a custom calculation |
|
165 | + if ($this->data['pageData']['offsets']['next'] < 0) { // If we are on the last page, 'next' is -1, which means we have to have a custom calculation |
|
166 | 166 | $pageTotal = $this->data['pageData']['offsets']['total'] - $this->data['pageData']['offsets']['current']; |
167 | 167 | } |
168 | 168 | $this->th->ss->assign('selectLink', $this->buildSelectLink('select_link', $this->data['pageData']['offsets']['total'], $pageTotal)); |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | $this->th->ss->assign('contextMenus', $this->contextMenus); |
176 | 176 | |
177 | 177 | |
178 | - if($this->contextMenus && !empty($contextMenuObjectsTypes)) { |
|
178 | + if ($this->contextMenus && !empty($contextMenuObjectsTypes)) { |
|
179 | 179 | $script = ''; |
180 | 180 | $cm = new contextMenu(); |
181 | - foreach($contextMenuObjectsTypes as $type => $value) { |
|
181 | + foreach ($contextMenuObjectsTypes as $type => $value) { |
|
182 | 182 | $cm->loadFromFile($type); |
183 | 183 | $script .= $cm->getScript(); |
184 | 184 | $cm->menuItems = array(); // clear menuItems out |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | function display($end = true) { |
200 | 200 | global $app_strings; |
201 | 201 | |
202 | - if(!is_file(sugar_cached("jsLanguage/{$GLOBALS['current_language']}.js"))) { |
|
202 | + if (!is_file(sugar_cached("jsLanguage/{$GLOBALS['current_language']}.js"))) { |
|
203 | 203 | require_once('include/language/jsLanguage.php'); |
204 | 204 | jsLanguage::createAppStringsCache($GLOBALS['current_language']); |
205 | 205 | } |
206 | - $jsLang = getVersionedScript("cache/jsLanguage/{$GLOBALS['current_language']}.js", $GLOBALS['sugar_config']['js_lang_version']); |
|
206 | + $jsLang = getVersionedScript("cache/jsLanguage/{$GLOBALS['current_language']}.js", $GLOBALS['sugar_config']['js_lang_version']); |
|
207 | 207 | |
208 | 208 | $this->th->ss->assign('data', $this->data['data']); |
209 | 209 | $this->data['pageData']['offsets']['lastOffsetOnPage'] = $this->data['pageData']['offsets']['current'] + count($this->data['data']); |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | $searchNameOverride = !empty($this->seed) && $this->seed instanceof Person && (isset($this->data['data'][0]['FIRST_NAME']) && isset($this->data['data'][0]['LAST_NAME'])) ? true : false; |
224 | 224 | |
225 | 225 | global $locale; |
226 | - foreach($this->data['data'] as $val) |
|
226 | + foreach ($this->data['data'] as $val) |
|
227 | 227 | { |
228 | 228 | $associated_row_data[$val['ID']] = $val; |
229 | - if($searchNameOverride) |
|
229 | + if ($searchNameOverride) |
|
230 | 230 | { |
231 | 231 | $associated_row_data[$val['ID']]['NAME'] = $locale->getLocaleFormattedName($val['FIRST_NAME'], $val['LAST_NAME']); |
232 | 232 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | $this->th->ss->assign('lang', substr($GLOBALS['current_language'], 0, 2)); |
238 | 238 | $this->th->ss->assign('headerTpl', $this->headerTpl); |
239 | 239 | $this->th->ss->assign('footerTpl', $this->footerTpl); |
240 | - $this->th->ss->assign('ASSOCIATED_JAVASCRIPT_DATA', 'var associated_javascript_data = '.$json->encode($associated_row_data). '; var is_show_fullname = '.$is_show_fullname.';'); |
|
240 | + $this->th->ss->assign('ASSOCIATED_JAVASCRIPT_DATA', 'var associated_javascript_data = '.$json->encode($associated_row_data).'; var is_show_fullname = '.$is_show_fullname.';'); |
|
241 | 241 | $this->th->ss->assign('module', $this->seed->module_dir); |
242 | 242 | $request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data']; |
243 | 243 | |
@@ -258,8 +258,8 @@ discard block |
||
258 | 258 | $this->th->ss->assign('sugarVersion', $GLOBALS['sugar_version']); |
259 | 259 | $this->th->ss->assign('should_process', $this->should_process); |
260 | 260 | |
261 | - if($this->_create){ |
|
262 | - $this->th->ss->assign('ADDFORM', $this->getQuickCreate());//$this->_getAddForm()); |
|
261 | + if ($this->_create) { |
|
262 | + $this->th->ss->assign('ADDFORM', $this->getQuickCreate()); //$this->_getAddForm()); |
|
263 | 263 | $this->th->ss->assign('ADDFORMHEADER', $this->_getAddFormHeader()); |
264 | 264 | $this->th->ss->assign('object_name', $this->seed->object_name); |
265 | 265 | } |
@@ -278,15 +278,15 @@ discard block |
||
278 | 278 | } |
279 | 279 | function _setup($file) { |
280 | 280 | |
281 | - if(isset($this->_popupMeta)){ |
|
282 | - if(isset($this->_popupMeta['create']['formBase'])) { |
|
283 | - require_once('modules/' . $this->seed->module_dir . '/' . $this->_popupMeta['create']['formBase']); |
|
281 | + if (isset($this->_popupMeta)) { |
|
282 | + if (isset($this->_popupMeta['create']['formBase'])) { |
|
283 | + require_once('modules/'.$this->seed->module_dir.'/'.$this->_popupMeta['create']['formBase']); |
|
284 | 284 | $this->_create = true; |
285 | 285 | } |
286 | 286 | } |
287 | - if(!empty($this->_popupMeta['create'])){ |
|
287 | + if (!empty($this->_popupMeta['create'])) { |
|
288 | 288 | $formBase = new $this->_popupMeta['create']['formBaseClass'](); |
289 | - if(isset($_REQUEST['doAction']) && $_REQUEST['doAction'] == 'save') |
|
289 | + if (isset($_REQUEST['doAction']) && $_REQUEST['doAction'] == 'save') |
|
290 | 290 | { |
291 | 291 | //If it's a new record, set useRequired to false |
292 | 292 | $useRequired = empty($_REQUEST['id']) ? false : true; |
@@ -295,19 +295,19 @@ discard block |
||
295 | 295 | } |
296 | 296 | |
297 | 297 | $params = array(); |
298 | - if(!empty($this->_popupMeta['orderBy'])){ |
|
298 | + if (!empty($this->_popupMeta['orderBy'])) { |
|
299 | 299 | $params['orderBy'] = $this->_popupMeta['orderBy']; |
300 | 300 | } |
301 | 301 | |
302 | - if(file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')){ |
|
302 | + if (file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')) { |
|
303 | 303 | require('custom/modules/'.$this->module.'/metadata/metafiles.php'); |
304 | - }elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){ |
|
304 | + }elseif (file_exists('modules/'.$this->module.'/metadata/metafiles.php')) { |
|
305 | 305 | require('modules/'.$this->module.'/metadata/metafiles.php'); |
306 | 306 | } |
307 | 307 | |
308 | - if(!empty($metafiles[$this->module]['searchfields'])) { |
|
308 | + if (!empty($metafiles[$this->module]['searchfields'])) { |
|
309 | 309 | require($metafiles[$this->module]['searchfields']); |
310 | - } elseif(file_exists('modules/'.$this->module.'/metadata/SearchFields.php')) { |
|
310 | + } elseif (file_exists('modules/'.$this->module.'/metadata/SearchFields.php')) { |
|
311 | 311 | require('modules/'.$this->module.'/metadata/SearchFields.php'); |
312 | 312 | } |
313 | 313 | $this->searchdefs[$this->module]['templateMeta']['maxColumns'] = 2; |
@@ -319,23 +319,23 @@ discard block |
||
319 | 319 | |
320 | 320 | $lv = new ListViewSmarty(); |
321 | 321 | $displayColumns = array(); |
322 | - if(!empty($_REQUEST['displayColumns'])) { |
|
323 | - foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) { |
|
324 | - if(!empty($listViewDefs[$this->module][$col])) |
|
322 | + if (!empty($_REQUEST['displayColumns'])) { |
|
323 | + foreach (explode('|', $_REQUEST['displayColumns']) as $num => $col) { |
|
324 | + if (!empty($listViewDefs[$this->module][$col])) |
|
325 | 325 | $displayColumns[$col] = $this->listviewdefs[$this->module][$col]; |
326 | 326 | } |
327 | 327 | } |
328 | 328 | else { |
329 | - foreach($this->listviewdefs[$this->module] as $col => $para) { |
|
330 | - if(!empty($para['default']) && $para['default']) |
|
329 | + foreach ($this->listviewdefs[$this->module] as $col => $para) { |
|
330 | + if (!empty($para['default']) && $para['default']) |
|
331 | 331 | $displayColumns[$col] = $para; |
332 | 332 | } |
333 | 333 | } |
334 | 334 | $params['massupdate'] = true; |
335 | - if(!empty($_REQUEST['orderBy'])) { |
|
335 | + if (!empty($_REQUEST['orderBy'])) { |
|
336 | 336 | $params['orderBy'] = $_REQUEST['orderBy']; |
337 | 337 | $params['overrideOrder'] = true; |
338 | - if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder']; |
|
338 | + if (!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder']; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | $lv->displayColumns = $displayColumns; |
@@ -350,27 +350,27 @@ discard block |
||
350 | 350 | |
351 | 351 | $this->should_process = true; |
352 | 352 | |
353 | - if(isset($params['export'])) { |
|
353 | + if (isset($params['export'])) { |
|
354 | 354 | $this->export = $params['export']; |
355 | 355 | } |
356 | - if(!empty($params['multiSelectPopup'])) { |
|
356 | + if (!empty($params['multiSelectPopup'])) { |
|
357 | 357 | $this->multi_select_popup = $params['multiSelectPopup']; |
358 | 358 | } |
359 | - if(!empty($params['massupdate']) && $params['massupdate'] != false) { |
|
359 | + if (!empty($params['massupdate']) && $params['massupdate'] != false) { |
|
360 | 360 | $this->show_mass_update_form = true; |
361 | 361 | $this->mass = new MassUpdate(); |
362 | 362 | $this->mass->setSugarBean($this->seed); |
363 | - if(!empty($params['handleMassupdate']) || !isset($params['handleMassupdate'])) { |
|
363 | + if (!empty($params['handleMassupdate']) || !isset($params['handleMassupdate'])) { |
|
364 | 364 | $this->mass->handleMassUpdate(); |
365 | 365 | } |
366 | 366 | } |
367 | 367 | |
368 | 368 | // create filter fields based off of display columns |
369 | - if(empty($this->filter_fields) || $this->mergeDisplayColumns) { |
|
370 | - foreach($this->displayColumns as $columnName => $def) { |
|
369 | + if (empty($this->filter_fields) || $this->mergeDisplayColumns) { |
|
370 | + foreach ($this->displayColumns as $columnName => $def) { |
|
371 | 371 | $this->filter_fields[strtolower($columnName)] = true; |
372 | - if(!empty($def['related_fields'])) { |
|
373 | - foreach($def['related_fields'] as $field) { |
|
372 | + if (!empty($def['related_fields'])) { |
|
373 | + foreach ($def['related_fields'] as $field) { |
|
374 | 374 | //id column is added by query construction function. This addition creates duplicates |
375 | 375 | //and causes issues in oracle. #10165 |
376 | 376 | if ($field != 'id') { |
@@ -379,15 +379,15 @@ discard block |
||
379 | 379 | } |
380 | 380 | } |
381 | 381 | if (!empty($this->seed->field_defs[strtolower($columnName)]['db_concat_fields'])) { |
382 | - foreach($this->seed->field_defs[strtolower($columnName)]['db_concat_fields'] as $index=>$field){ |
|
383 | - if(!isset($this->filter_fields[strtolower($field)]) || !$this->filter_fields[strtolower($field)]) |
|
382 | + foreach ($this->seed->field_defs[strtolower($columnName)]['db_concat_fields'] as $index=>$field) { |
|
383 | + if (!isset($this->filter_fields[strtolower($field)]) || !$this->filter_fields[strtolower($field)]) |
|
384 | 384 | { |
385 | 385 | $this->filter_fields[strtolower($field)] = true; |
386 | 386 | } |
387 | 387 | } |
388 | 388 | } |
389 | 389 | } |
390 | - foreach ($this->searchColumns as $columnName => $def ) |
|
390 | + foreach ($this->searchColumns as $columnName => $def) |
|
391 | 391 | { |
392 | 392 | $this->filter_fields[strtolower($columnName)] = true; |
393 | 393 | } |
@@ -403,13 +403,13 @@ discard block |
||
403 | 403 | * By default bean's create_new_list_query function loads fields displayed on the page or used in the search |
404 | 404 | * add fields used to populate forms from _viewdefs :: field_to_name_array to retrive from db |
405 | 405 | */ |
406 | - if ( isset($_REQUEST['field_to_name']) && $_REQUEST['field_to_name'] ) |
|
406 | + if (isset($_REQUEST['field_to_name']) && $_REQUEST['field_to_name']) |
|
407 | 407 | { |
408 | 408 | $_REQUEST['field_to_name'] = is_array($_REQUEST['field_to_name']) ? $_REQUEST['field_to_name'] : array($_REQUEST['field_to_name']); |
409 | - foreach ( $_REQUEST['field_to_name'] as $add_field ) |
|
409 | + foreach ($_REQUEST['field_to_name'] as $add_field) |
|
410 | 410 | { |
411 | 411 | $add_field = strtolower($add_field); |
412 | - if ( $add_field != 'id' && !isset($this->filter_fields[$add_field]) && isset($this->seed->field_defs[$add_field]) ) |
|
412 | + if ($add_field != 'id' && !isset($this->filter_fields[$add_field]) && isset($this->seed->field_defs[$add_field])) |
|
413 | 413 | { |
414 | 414 | $this->filter_fields[$add_field] = true; |
415 | 415 | } |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | 'pageData'=>array( |
428 | 428 | 'bean'=>array('moduleDir'=>$this->seed->module_dir), |
429 | 429 | 'ordering'=>'', |
430 | - 'offsets'=>array('total'=>0,'next'=>0,'current'=>0), |
|
430 | + 'offsets'=>array('total'=>0, 'next'=>0, 'current'=>0), |
|
431 | 431 | ), |
432 | 432 | ); |
433 | 433 | } |
@@ -447,13 +447,13 @@ discard block |
||
447 | 447 | |
448 | 448 | // Bug 43452 - FG - Changed the way generated Where array is imploded into the string. |
449 | 449 | // Now it's imploding in the same way view.list.php do. |
450 | - if (count($where_clauses) > 0 ) { |
|
451 | - $where = '( ' . implode(' and ', $where_clauses) . ' )'; |
|
450 | + if (count($where_clauses) > 0) { |
|
451 | + $where = '( '.implode(' and ', $where_clauses).' )'; |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | // Need to include the default whereStatement |
455 | - if(!empty($this->_popupMeta['whereStatement'])){ |
|
456 | - if(!empty($where))$where .= ' AND '; |
|
455 | + if (!empty($this->_popupMeta['whereStatement'])) { |
|
456 | + if (!empty($where))$where .= ' AND '; |
|
457 | 457 | $where .= $this->_popupMeta['whereStatement']; |
458 | 458 | } |
459 | 459 | |
@@ -463,48 +463,48 @@ discard block |
||
463 | 463 | /* |
464 | 464 | * Generate the data for the search form on the header of the Popup. |
465 | 465 | */ |
466 | - function _build_field_defs(){ |
|
466 | + function _build_field_defs() { |
|
467 | 467 | $this->formData = array(); |
468 | 468 | $this->customFieldDefs = array(); |
469 | - foreach($this->searchdefs[$this->module]['layout']['advanced_search'] as $data){ |
|
470 | - if(is_array($data)){ |
|
469 | + foreach ($this->searchdefs[$this->module]['layout']['advanced_search'] as $data) { |
|
470 | + if (is_array($data)) { |
|
471 | 471 | |
472 | 472 | $this->formData[] = array('field' => $data); |
473 | 473 | $value = ''; |
474 | - $this->customFieldDefs[$data['name']]= $data; |
|
475 | - if(!empty($_REQUEST[$data['name']])) |
|
474 | + $this->customFieldDefs[$data['name']] = $data; |
|
475 | + if (!empty($_REQUEST[$data['name']])) |
|
476 | 476 | $value = $_REQUEST[$data['name']]; |
477 | 477 | $this->customFieldDefs[$data['name']]['value'] = $value; |
478 | - }else |
|
478 | + } else |
|
479 | 479 | $this->formData[] = array('field' => array('name'=>$data)); |
480 | 480 | } |
481 | 481 | $this->fieldDefs = array(); |
482 | - if($this->seed){ |
|
482 | + if ($this->seed) { |
|
483 | 483 | $this->seed->fill_in_additional_detail_fields(); |
484 | 484 | |
485 | - foreach($this->seed->toArray() as $name => $value) { |
|
485 | + foreach ($this->seed->toArray() as $name => $value) { |
|
486 | 486 | $this->fieldDefs[$name] = $this->seed->field_defs[$name]; |
487 | 487 | //if we have a relate type then reset to name so that we end up with a textbox |
488 | 488 | //rather than a select button |
489 | 489 | $this->fieldDefs[$name]['name'] = $this->fieldDefs[$name]['name']; |
490 | - if($this->fieldDefs[$name]['type'] == 'relate') |
|
490 | + if ($this->fieldDefs[$name]['type'] == 'relate') |
|
491 | 491 | $this->fieldDefs[$name]['type'] = 'name'; |
492 | - if(isset($this->fieldDefs[$name]['options']) && isset($GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']])) { |
|
492 | + if (isset($this->fieldDefs[$name]['options']) && isset($GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']])) { |
|
493 | 493 | $this->fieldDefs[$name]['options'] = $GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']]; // fill in enums |
494 | 494 | } |
495 | - if(!empty($_REQUEST[$name])) |
|
495 | + if (!empty($_REQUEST[$name])) |
|
496 | 496 | $value = $_REQUEST[$name]; |
497 | 497 | $this->fieldDefs[$name]['value'] = $value; |
498 | 498 | } |
499 | 499 | } |
500 | 500 | } |
501 | 501 | |
502 | - function _getAddForm(){ |
|
502 | + function _getAddForm() { |
|
503 | 503 | $addform = ''; |
504 | - if(!$this->seed->ACLAccess('save')){ |
|
504 | + if (!$this->seed->ACLAccess('save')) { |
|
505 | 505 | return; |
506 | 506 | } |
507 | - if(!empty($this->_popupMeta['create'])){ |
|
507 | + if (!empty($this->_popupMeta['create'])) { |
|
508 | 508 | $formBase = new $this->_popupMeta['create']['formBaseClass'](); |
509 | 509 | |
510 | 510 | |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | } |
527 | 527 | } |
528 | 528 | |
529 | - function _getAddFormHeader(){ |
|
529 | + function _getAddFormHeader() { |
|
530 | 530 | $lbl_save_button_title = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_TITLE']; |
531 | 531 | $lbl_save_button_key = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_KEY']; |
532 | 532 | $lbl_save_button_label = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_LABEL']; |
@@ -539,9 +539,9 @@ discard block |
||
539 | 539 | <input type="hidden" name="return_action" value="Popup"> |
540 | 540 | EOQ; |
541 | 541 | // if metadata contains custom inputs for the quickcreate |
542 | - if(!empty($this->_popupMeta['customInput']) && is_array($this->_popupMeta['customInput'])) { |
|
543 | - foreach($this->_popupMeta['customInput'] as $key => $value) |
|
544 | - $formSave .= '<input type="hidden" name="' . $key . '" value="'. $value .'">\n'; |
|
542 | + if (!empty($this->_popupMeta['customInput']) && is_array($this->_popupMeta['customInput'])) { |
|
543 | + foreach ($this->_popupMeta['customInput'] as $key => $value) |
|
544 | + $formSave .= '<input type="hidden" name="'.$key.'" value="'.$value.'">\n'; |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | return $addformheader; |
550 | 550 | } |
551 | 551 | |
552 | - function getQuickCreate(){ |
|
552 | + function getQuickCreate() { |
|
553 | 553 | require_once("include/EditView/PopupQuickCreate.php"); |
554 | 554 | $qc = new PopupQuickCreate($this->module); |
555 | 555 | return $qc->process($this->module); |
@@ -35,14 +35,14 @@ discard block |
||
35 | 35 | if (!preg_match("/^\w\w_\w\w$/", $lang)) { |
36 | 36 | echo "did not match regex<br/>"; |
37 | 37 | } else { |
38 | - echo "$lang was not in list . <pre>" . print_r($languages, true) . "</pre>"; |
|
38 | + echo "$lang was not in list . <pre>".print_r($languages, true)."</pre>"; |
|
39 | 39 | } |
40 | 40 | echo "Invalid language specified"; |
41 | 41 | |
42 | 42 | return; |
43 | 43 | } |
44 | 44 | if (empty($_REQUEST['module']) || $_REQUEST['module'] === 'app_strings') { |
45 | - $file = sugar_cached('jsLanguage/') . $lang . '.js'; |
|
45 | + $file = sugar_cached('jsLanguage/').$lang.'.js'; |
|
46 | 46 | if (!sugar_is_file($file)) { |
47 | 47 | jsLanguage::createAppStringsCache($lang); |
48 | 48 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | return; |
56 | 56 | } |
57 | - $file = sugar_cached('jsLanguage/') . $module . "/" . $lang . '.js'; |
|
57 | + $file = sugar_cached('jsLanguage/').$module."/".$lang.'.js'; |
|
58 | 58 | if (!sugar_is_file($file)) { |
59 | 59 | jsLanguage::createModuleStringsCache($module, $lang); |
60 | 60 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | header("Content-Type: application/javascript"); |
65 | 65 | header("Cache-Control: max-age=31556940, private"); |
66 | 66 | header("Pragma: "); |
67 | - header("Expires: " . gmdate('D, d M Y H:i:s \G\M\T', time() + 31556940)); |
|
67 | + header("Expires: ".gmdate('D, d M Y H:i:s \G\M\T', time() + 31556940)); |
|
68 | 68 | |
69 | 69 | readfile($file); |
70 | 70 | } |