@@ -1,140 +1,140 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // created: 2014-01-29 09:59:23 |
| 3 | -$unified_search_modules_display = array ( |
|
| 3 | +$unified_search_modules_display = array( |
|
| 4 | 4 | 'AOP_Case_Events' => |
| 5 | - array ( |
|
| 5 | + array( |
|
| 6 | 6 | 'visible' => false, |
| 7 | 7 | ), |
| 8 | 8 | 'AOP_Case_Updates' => |
| 9 | - array ( |
|
| 9 | + array( |
|
| 10 | 10 | 'visible' => false, |
| 11 | 11 | ), |
| 12 | 12 | 'AOR_Reports' => |
| 13 | - array ( |
|
| 13 | + array( |
|
| 14 | 14 | 'visible' => false, |
| 15 | 15 | ), |
| 16 | 16 | 'AOS_Contracts' => |
| 17 | - array ( |
|
| 17 | + array( |
|
| 18 | 18 | 'visible' => false, |
| 19 | 19 | ), |
| 20 | 20 | 'AOS_Invoices' => |
| 21 | - array ( |
|
| 21 | + array( |
|
| 22 | 22 | 'visible' => false, |
| 23 | 23 | ), |
| 24 | 24 | 'AOS_PDF_Templates' => |
| 25 | - array ( |
|
| 25 | + array( |
|
| 26 | 26 | 'visible' => false, |
| 27 | 27 | ), |
| 28 | 28 | 'AOS_Product_Categories' => |
| 29 | - array ( |
|
| 29 | + array( |
|
| 30 | 30 | 'visible' => false, |
| 31 | 31 | ), |
| 32 | 32 | 'AOS_Products' => |
| 33 | - array ( |
|
| 33 | + array( |
|
| 34 | 34 | 'visible' => false, |
| 35 | 35 | ), |
| 36 | 36 | 'AOS_Quotes' => |
| 37 | - array ( |
|
| 37 | + array( |
|
| 38 | 38 | 'visible' => false, |
| 39 | 39 | ), |
| 40 | 40 | 'AOW_Processed' => |
| 41 | - array ( |
|
| 41 | + array( |
|
| 42 | 42 | 'visible' => false, |
| 43 | 43 | ), |
| 44 | 44 | 'AOW_WorkFlow' => |
| 45 | - array ( |
|
| 45 | + array( |
|
| 46 | 46 | 'visible' => false, |
| 47 | 47 | ), |
| 48 | 48 | 'Accounts' => |
| 49 | - array ( |
|
| 49 | + array( |
|
| 50 | 50 | 'visible' => true, |
| 51 | 51 | ), |
| 52 | 52 | 'Bugs' => |
| 53 | - array ( |
|
| 53 | + array( |
|
| 54 | 54 | 'visible' => false, |
| 55 | 55 | ), |
| 56 | 56 | 'Calls' => |
| 57 | - array ( |
|
| 57 | + array( |
|
| 58 | 58 | 'visible' => true, |
| 59 | 59 | ), |
| 60 | 60 | 'Calls_Reschedule' => |
| 61 | - array ( |
|
| 61 | + array( |
|
| 62 | 62 | 'visible' => false, |
| 63 | 63 | ), |
| 64 | 64 | 'Campaigns' => |
| 65 | - array ( |
|
| 65 | + array( |
|
| 66 | 66 | 'visible' => false, |
| 67 | 67 | ), |
| 68 | 68 | 'Cases' => |
| 69 | - array ( |
|
| 69 | + array( |
|
| 70 | 70 | 'visible' => true, |
| 71 | 71 | ), |
| 72 | 72 | 'Contacts' => |
| 73 | - array ( |
|
| 73 | + array( |
|
| 74 | 74 | 'visible' => true, |
| 75 | 75 | ), |
| 76 | 76 | 'Documents' => |
| 77 | - array ( |
|
| 77 | + array( |
|
| 78 | 78 | 'visible' => true, |
| 79 | 79 | ), |
| 80 | 80 | 'FP_Event_Locations' => |
| 81 | - array ( |
|
| 81 | + array( |
|
| 82 | 82 | 'visible' => false, |
| 83 | 83 | ), |
| 84 | 84 | 'FP_events' => |
| 85 | - array ( |
|
| 85 | + array( |
|
| 86 | 86 | 'visible' => false, |
| 87 | 87 | ), |
| 88 | 88 | 'Leads' => |
| 89 | - array ( |
|
| 89 | + array( |
|
| 90 | 90 | 'visible' => true, |
| 91 | 91 | ), |
| 92 | 92 | 'Meetings' => |
| 93 | - array ( |
|
| 93 | + array( |
|
| 94 | 94 | 'visible' => true, |
| 95 | 95 | ), |
| 96 | 96 | 'Notes' => |
| 97 | - array ( |
|
| 97 | + array( |
|
| 98 | 98 | 'visible' => true, |
| 99 | 99 | ), |
| 100 | 100 | 'Opportunities' => |
| 101 | - array ( |
|
| 101 | + array( |
|
| 102 | 102 | 'visible' => true, |
| 103 | 103 | ), |
| 104 | 104 | 'Project' => |
| 105 | - array ( |
|
| 105 | + array( |
|
| 106 | 106 | 'visible' => false, |
| 107 | 107 | ), |
| 108 | 108 | 'ProjectTask' => |
| 109 | - array ( |
|
| 109 | + array( |
|
| 110 | 110 | 'visible' => false, |
| 111 | 111 | ), |
| 112 | 112 | 'ProspectLists' => |
| 113 | - array ( |
|
| 113 | + array( |
|
| 114 | 114 | 'visible' => false, |
| 115 | 115 | ), |
| 116 | 116 | 'Prospects' => |
| 117 | - array ( |
|
| 117 | + array( |
|
| 118 | 118 | 'visible' => false, |
| 119 | 119 | ), |
| 120 | 120 | 'Tasks' => |
| 121 | - array ( |
|
| 121 | + array( |
|
| 122 | 122 | 'visible' => false, |
| 123 | 123 | ), |
| 124 | 124 | 'jjwg_Address_Cache' => |
| 125 | - array ( |
|
| 125 | + array( |
|
| 126 | 126 | 'visible' => false, |
| 127 | 127 | ), |
| 128 | 128 | 'jjwg_Areas' => |
| 129 | - array ( |
|
| 129 | + array( |
|
| 130 | 130 | 'visible' => false, |
| 131 | 131 | ), |
| 132 | 132 | 'jjwg_Maps' => |
| 133 | - array ( |
|
| 133 | + array( |
|
| 134 | 134 | 'visible' => false, |
| 135 | 135 | ), |
| 136 | 136 | 'jjwg_Markers' => |
| 137 | - array ( |
|
| 137 | + array( |
|
| 138 | 138 | 'visible' => false, |
| 139 | 139 | ), |
| 140 | 140 | ); |
| 141 | 141 | \ No newline at end of file |
@@ -28,4 +28,4 @@ |
||
| 28 | 28 | if (!isset($hook_array['after_save']) || !is_array($hook_array['after_save'])) { |
| 29 | 29 | $hook_array['after_save'] = array(); |
| 30 | 30 | } |
| 31 | -$hook_array['after_save'][] = Array(99, 'AOW_Workflow', 'modules/AOW_WorkFlow/AOW_WorkFlow.php','AOW_WorkFlow', 'run_bean_flows'); |
|
| 32 | 31 | \ No newline at end of file |
| 32 | +$hook_array['after_save'][] = Array(99, 'AOW_Workflow', 'modules/AOW_WorkFlow/AOW_WorkFlow.php', 'AOW_WorkFlow', 'run_bean_flows'); |
|
| 33 | 33 | \ 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. |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * Parses for contents enclosed within <form>...</form> tags |
| 67 | 67 | */ |
| 68 | 68 | function getFormContents($contents, $all = true) { |
| 69 | - if($all) { |
|
| 69 | + if ($all) { |
|
| 70 | 70 | preg_match_all("'(<form[^>]*?>)(.*?)(</form[^>]*?>)'si", $contents, $matches); |
| 71 | 71 | return $matches; |
| 72 | 72 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | function getFormElements($contents) { |
| 87 | 87 | preg_match_all("'(<[ ]*?)(textarea|input|select)([^>]*?)(>)'si", $contents, $matches, PREG_PATTERN_ORDER); |
| 88 | 88 | $elems = array(); |
| 89 | - foreach($matches[3] as $match) { |
|
| 89 | + foreach ($matches[3] as $match) { |
|
| 90 | 90 | $elems[] = $match; |
| 91 | 91 | } |
| 92 | 92 | return $elems; |
@@ -118,13 +118,13 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $exp = "'".$name."[\s]*?=[\s]*?[\'\"]([^\'^\"]*?)[\'\"]'si"; |
| 120 | 120 | preg_match_all($exp, $contents, $matches, PREG_SET_ORDER); |
| 121 | - if(empty($filter)) { |
|
| 121 | + if (empty($filter)) { |
|
| 122 | 122 | return !empty($matches[0][1]) ? $matches[0][1] : ''; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $filtered = array(); |
| 126 | - foreach($matches as $tag) { |
|
| 127 | - if(preg_match($filter, $tag[1])) { |
|
| 126 | + foreach ($matches as $tag) { |
|
| 127 | + if (preg_match($filter, $tag[1])) { |
|
| 128 | 128 | $filtered[] = $tag; |
| 129 | 129 | } |
| 130 | 130 | } |
@@ -141,13 +141,13 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | function getTables($tableClass = null, $contents) { |
| 143 | 143 | preg_match_all("'(<table[^>]*?>)(.*?)(</table[^>]*?>)'si", $contents, $matches, PREG_SET_ORDER); |
| 144 | - if($tableClass == null) { |
|
| 144 | + if ($tableClass == null) { |
|
| 145 | 145 | return $matches; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | $tables = array(); |
| 149 | - foreach($matches as $key => $table) { |
|
| 150 | - if(strpos($table[1], $tableClass) > 0) { |
|
| 149 | + foreach ($matches as $key => $table) { |
|
| 150 | + if (strpos($table[1], $tableClass) > 0) { |
|
| 151 | 151 | $tables[] = $table; |
| 152 | 152 | } |
| 153 | 153 | } |
@@ -170,27 +170,27 @@ discard block |
||
| 170 | 170 | $x = strlen($contents); |
| 171 | 171 | $mark = 0; |
| 172 | 172 | $count = 0; |
| 173 | - $stag1 = "<" . trim($type, " <>") . '>'; |
|
| 174 | - $stag2 = "<" . trim($type, " <>") . ' '; |
|
| 173 | + $stag1 = "<".trim($type, " <>").'>'; |
|
| 174 | + $stag2 = "<".trim($type, " <>").' '; |
|
| 175 | 175 | $etag = "</".$type.">"; |
| 176 | 176 | $sincrement = strlen($stag1); |
| 177 | 177 | $eincrement = strlen($etag); |
| 178 | 178 | $sarr = array(); |
| 179 | 179 | $values = array(); |
| 180 | 180 | |
| 181 | - while($count < $x) { |
|
| 181 | + while ($count < $x) { |
|
| 182 | 182 | $stok = substr($contents, $count, $sincrement); |
| 183 | 183 | $etok = substr($contents, $count, $eincrement); |
| 184 | - if($stok == $stag1 || $stok == $stag2) { |
|
| 184 | + if ($stok == $stag1 || $stok == $stag2) { |
|
| 185 | 185 | //Reset mark; |
| 186 | - if(count($sarr) == 0) { |
|
| 186 | + if (count($sarr) == 0) { |
|
| 187 | 187 | $mark = $count; |
| 188 | 188 | } |
| 189 | 189 | $sarr[] = $count; |
| 190 | 190 | |
| 191 | - } else if($etok == $etag) { |
|
| 191 | + } else if ($etok == $etag) { |
|
| 192 | 192 | array_shift($sarr); |
| 193 | - if(count($sarr) == 0) { |
|
| 193 | + if (count($sarr) == 0) { |
|
| 194 | 194 | $val = substr($contents, $mark, ($count - $mark) + $eincrement); |
| 195 | 195 | $values[] = $val; |
| 196 | 196 | $mark = $count; |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | function stripFlavorTags($contents) { |
| 232 | 232 | $flavor = isset($GLOBALS['sugar_flavor']) ? $GLOBALS['sugar_flavor'] : 'PRO'; |
| 233 | 233 | $isPro = ($flavor == 'ENT' || $flavor == 'PRO') ? true : false; |
| 234 | - if($isPro) { |
|
| 234 | + if ($isPro) { |
|
| 235 | 235 | $contents = preg_replace('/<!-- BEGIN: open_source -->.*?<!-- END: open_source -->/', '', $contents); |
| 236 | 236 | } else { |
| 237 | 237 | $contents = preg_replace('/<!-- BEGIN: pro -->.*?<!-- END: pro -->/', '', $contents); |
@@ -249,9 +249,9 @@ discard block |
||
| 249 | 249 | function getMaxColumns($contents, $filter) { |
| 250 | 250 | preg_match_all("'(<tr[^>]*?>)(.*?)(</tr[^>]*?>)'si", $contents, $matches, PREG_SET_ORDER); |
| 251 | 251 | $max = 0; |
| 252 | - foreach($matches as $tableRows) { |
|
| 252 | + foreach ($matches as $tableRows) { |
|
| 253 | 253 | $count = substr_count($tableRows[2], $filter); |
| 254 | - if($count > $max) { |
|
| 254 | + if ($count > $max) { |
|
| 255 | 255 | $max = $count; |
| 256 | 256 | } |
| 257 | 257 | } |
@@ -263,9 +263,9 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | $elements = array(); |
| 265 | 265 | |
| 266 | - foreach($matches as $data) { |
|
| 266 | + foreach ($matches as $data) { |
|
| 267 | 267 | // We need 4 because the 1,2,3 indexes make up start,body,end |
| 268 | - if(count($data) == 4) { |
|
| 268 | + if (count($data) == 4) { |
|
| 269 | 269 | $element = array(); |
| 270 | 270 | $element['start'] = $data[1]; |
| 271 | 271 | $element['body'] = $data[2]; |
@@ -306,12 +306,12 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | //Check if there are Javascript blocks of code to process |
| 308 | 308 | preg_match_all("'(<script[^>]*?>)(.*?)(</script[^>]*?>)'si", $contents, $matches, PREG_PATTERN_ORDER); |
| 309 | -if(empty($matches)) { |
|
| 309 | +if (empty($matches)) { |
|
| 310 | 310 | return $javascript; |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | -foreach($matches[0] as $scriptBlock) { |
|
| 314 | - $javascript .= "\n" . $scriptBlock; |
|
| 313 | +foreach ($matches[0] as $scriptBlock) { |
|
| 314 | + $javascript .= "\n".$scriptBlock; |
|
| 315 | 315 | } //foreach |
| 316 | 316 | |
| 317 | 317 | $javascript = substr($javascript, 1); |
@@ -322,11 +322,11 @@ discard block |
||
| 322 | 322 | |
| 323 | 323 | //Find all blocks that may need to be replaced with Smarty syntax |
| 324 | 324 | preg_match_all("'([\{])([a-zA-Z0-9_]*?)([\}])'si", $javascript, $matches, PREG_PATTERN_ORDER); |
| 325 | -if(!empty($matches)) { |
|
| 325 | +if (!empty($matches)) { |
|
| 326 | 326 | $replace = array(); |
| 327 | 327 | |
| 328 | - foreach($matches[0] as $xTemplateCode) { |
|
| 329 | - if(!isset($replace[$xTemplateCode])) { |
|
| 328 | + foreach ($matches[0] as $xTemplateCode) { |
|
| 329 | + if (!isset($replace[$xTemplateCode])) { |
|
| 330 | 330 | $replace[$xTemplateCode] = str_replace("{", "{\$", $xTemplateCode); |
| 331 | 331 | } //if |
| 332 | 332 | } //foreach |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | $javascript = str_replace(array_keys($replace), array_values($replace), $javascript); |
| 335 | 335 | } //if |
| 336 | 336 | |
| 337 | -if(!$addLiterals) { |
|
| 337 | +if (!$addLiterals) { |
|
| 338 | 338 | return $javascript; |
| 339 | 339 | } |
| 340 | 340 | |
@@ -348,12 +348,12 @@ discard block |
||
| 348 | 348 | $count = 0; |
| 349 | 349 | $inSmartyVariable = false; |
| 350 | 350 | |
| 351 | - while($count < $scriptLength) { |
|
| 351 | + while ($count < $scriptLength) { |
|
| 352 | 352 | |
| 353 | - if($inSmartyVariable) { |
|
| 353 | + if ($inSmartyVariable) { |
|
| 354 | 354 | $start = $count; |
| 355 | 355 | $numOfChars = 1; |
| 356 | - while(isset($javascript[$count]) && $javascript[$count] != '}') { |
|
| 356 | + while (isset($javascript[$count]) && $javascript[$count] != '}') { |
|
| 357 | 357 | $count++; |
| 358 | 358 | $numOfChars++; |
| 359 | 359 | } |
@@ -366,12 +366,12 @@ discard block |
||
| 366 | 366 | $char = $javascript[$count]; |
| 367 | 367 | $nextChar = ($count + 1 >= $scriptLength) ? '' : $javascript[$count + 1]; |
| 368 | 368 | |
| 369 | - if($char == "{" && $nextChar == "$") { |
|
| 369 | + if ($char == "{" && $nextChar == "$") { |
|
| 370 | 370 | $inSmartyVariable = true; |
| 371 | 371 | $newJavascript .= $javascript[$count]; |
| 372 | - } else if($char == "{") { |
|
| 373 | - $newJavascript .= " {ldelim} "; |
|
| 374 | - } else if($char == "}") { |
|
| 372 | + } else if ($char == "{") { |
|
| 373 | + $newJavascript .= " {ldelim} "; |
|
| 374 | + } else if ($char == "}") { |
|
| 375 | 375 | $newJavascript .= " {rdelim} "; |
| 376 | 376 | } else { |
| 377 | 377 | $newJavascript .= $javascript[$count]; |
@@ -397,32 +397,32 @@ discard block |
||
| 397 | 397 | */ |
| 398 | 398 | function findAssignedVariableName($name, $filePath) { |
| 399 | 399 | |
| 400 | - if($this->mPHPFile == "INVALID") { |
|
| 400 | + if ($this->mPHPFile == "INVALID") { |
|
| 401 | 401 | return $name; |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - if(!isset($this->mPHPFile)) { |
|
| 405 | - if(preg_match('/(.*?)(DetailView).html$/', $filePath, $matches)) { |
|
| 404 | + if (!isset($this->mPHPFile)) { |
|
| 405 | + if (preg_match('/(.*?)(DetailView).html$/', $filePath, $matches)) { |
|
| 406 | 406 | $dir = $matches[1]; |
| 407 | - } else if(preg_match('/(.*?)(EditView).html$/', $filePath, $matches)) { |
|
| 407 | + } else if (preg_match('/(.*?)(EditView).html$/', $filePath, $matches)) { |
|
| 408 | 408 | $dir = $matches[1]; |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - if(!isset($dir) || !is_dir($dir)) { |
|
| 411 | + if (!isset($dir) || !is_dir($dir)) { |
|
| 412 | 412 | $this->mPHPFile = "INVALID"; |
| 413 | 413 | return $name; |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | $filesInDir = $this->dirList($dir); |
| 417 | 417 | $phpFile = $matches[2].'.*?[\.]php'; |
| 418 | - foreach($filesInDir as $file) { |
|
| 419 | - if(preg_match("/$phpFile/", $file)) { |
|
| 420 | - $this->mPHPFile = $matches[1] . $file; |
|
| 418 | + foreach ($filesInDir as $file) { |
|
| 419 | + if (preg_match("/$phpFile/", $file)) { |
|
| 420 | + $this->mPHPFile = $matches[1].$file; |
|
| 421 | 421 | break; |
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - if(!isset($this->mPHPFile) || !file_exists($this->mPHPFile)) { |
|
| 425 | + if (!isset($this->mPHPFile) || !file_exists($this->mPHPFile)) { |
|
| 426 | 426 | $this->mPHPFile = "INVALID"; |
| 427 | 427 | return $name; |
| 428 | 428 | } |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | |
| 431 | 431 | $phpContents = file_get_contents($this->mPHPFile); |
| 432 | 432 | $uname = strtoupper($name); |
| 433 | - if(preg_match("/xtpl->assign[\(][\"\']".$uname."[\"\'][\s]*?,[\s]*?[\$]focus->(.*?)[\)]/si", $phpContents, $matches)) { |
|
| 433 | + if (preg_match("/xtpl->assign[\(][\"\']".$uname."[\"\'][\s]*?,[\s]*?[\$]focus->(.*?)[\)]/si", $phpContents, $matches)) { |
|
| 434 | 434 | return $matches[1]; |
| 435 | 435 | } |
| 436 | 436 | return $name; |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | * @param $directory The directory to scan |
| 445 | 445 | * @return $results The files in the directory that were found |
| 446 | 446 | */ |
| 447 | -function dirList ($directory) { |
|
| 447 | +function dirList($directory) { |
|
| 448 | 448 | |
| 449 | 449 | // create an array to hold directory list |
| 450 | 450 | $results = array(); |
@@ -476,19 +476,19 @@ discard block |
||
| 476 | 476 | */ |
| 477 | 477 | function getCustomField($elementNames) { |
| 478 | 478 | |
| 479 | - if(!isset($elementNames) || (!is_string($elementNames) && !is_array($elementNames))) { |
|
| 479 | + if (!isset($elementNames) || (!is_string($elementNames) && !is_array($elementNames))) { |
|
| 480 | 480 | return null; |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | - if(is_string($elementNames)) { |
|
| 484 | - if(preg_match('/(.+_c)(_basic)?(\[\])?$/', $elementNames, $matches)) { |
|
| 483 | + if (is_string($elementNames)) { |
|
| 484 | + if (preg_match('/(.+_c)(_basic)?(\[\])?$/', $elementNames, $matches)) { |
|
| 485 | 485 | return count($matches) == 1 ? $matches[0] : $matches[1]; |
| 486 | 486 | } |
| 487 | 487 | return null; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - foreach($elementNames as $name) { |
|
| 491 | - if(preg_match('/(.+_c)(_basic)?(\[\])?$/', $name, $matches)) { |
|
| 490 | + foreach ($elementNames as $name) { |
|
| 491 | + if (preg_match('/(.+_c)(_basic)?(\[\])?$/', $name, $matches)) { |
|
| 492 | 492 | return count($matches) == 1 ? $matches[0] : $matches[1]; |
| 493 | 493 | } |
| 494 | 494 | } |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | function applyPreRules($moduleDir, $panels) { |
| 500 | - if(file_exists("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php")) { |
|
| 500 | + if (file_exists("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php")) { |
|
| 501 | 501 | require_once("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php"); |
| 502 | 502 | $class = $moduleDir."ParseRule"; |
| 503 | 503 | $parseRule = new $class(); |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | |
| 513 | 513 | function applyPostRules($moduleDir, $panels) { |
| 514 | 514 | //Run module specific rules |
| 515 | - if(file_exists("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php")) { |
|
| 515 | + if (file_exists("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php")) { |
|
| 516 | 516 | require_once("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php"); |
| 517 | 517 | $class = $moduleDir."ParseRule"; |
| 518 | 518 | $parseRule = new $class(); |
@@ -523,9 +523,9 @@ discard block |
||
| 523 | 523 | require_once("include/SugarFields/Parsers/Rules/ParseRules.php"); |
| 524 | 524 | $rules = ParseRules::getRules(); |
| 525 | 525 | |
| 526 | - foreach($rules as $rule) { |
|
| 527 | - if(!file_exists($rule['file'])) { |
|
| 528 | - $GLOBALS['log']->error("Cannot run rule for " . $rule['file']); |
|
| 526 | + foreach ($rules as $rule) { |
|
| 527 | + if (!file_exists($rule['file'])) { |
|
| 528 | + $GLOBALS['log']->error("Cannot run rule for ".$rule['file']); |
|
| 529 | 529 | continue; |
| 530 | 530 | } //if |
| 531 | 531 | require_once($rule['file']); |
@@ -537,11 +537,11 @@ discard block |
||
| 537 | 537 | return $panels; |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | -function createFileContents($moduleDir, $panels, $templateMeta=array(), $htmlFilePath) { |
|
| 540 | +function createFileContents($moduleDir, $panels, $templateMeta = array(), $htmlFilePath) { |
|
| 541 | 541 | |
| 542 | 542 | $header = "<?php\n\n"; |
| 543 | 543 | |
| 544 | -if(empty($templateMeta)) { |
|
| 544 | +if (empty($templateMeta)) { |
|
| 545 | 545 | $header .= "\$viewdefs['$moduleDir']['$this->mView'] = array( |
| 546 | 546 | 'templateMeta' => array('maxColumns' => '2', |
| 547 | 547 | 'widths' => array( |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | ),"; |
| 552 | 552 | } else { |
| 553 | 553 | $header .= "\$viewdefs['$moduleDir']['$this->mView'] = array( |
| 554 | - 'templateMeta' =>" . var_export($templateMeta, true) . ","; |
|
| 554 | + 'templateMeta' =>".var_export($templateMeta, true).","; |
|
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | //Replace all the @sq (single quote tags that may have been inserted) |
@@ -576,8 +576,8 @@ discard block |
||
| 576 | 576 | |
| 577 | 577 | $metadata = ''; |
| 578 | 578 | $body = var_export($panels, true); |
| 579 | - $metadata = $header . $body . $footer; |
|
| 580 | - $metadata = preg_replace('/(\d+)[\s]=>[\s]?/',"",$metadata); |
|
| 579 | + $metadata = $header.$body.$footer; |
|
| 580 | + $metadata = preg_replace('/(\d+)[\s]=>[\s]?/', "", $metadata); |
|
| 581 | 581 | return $metadata; |
| 582 | 582 | |
| 583 | 583 | } |
@@ -596,10 +596,10 @@ discard block |
||
| 596 | 596 | $masterpanels = $viewdefs[$moduleDir][$this->mView]['panels']; |
| 597 | 597 | $hasMultiplePanels = $this->hasMultiplePanels($masterpanels); |
| 598 | 598 | |
| 599 | - if(!$hasMultiplePanels) { |
|
| 599 | + if (!$hasMultiplePanels) { |
|
| 600 | 600 | $keys = array_keys($viewdefs[$moduleDir][$this->mView]['panels']); |
| 601 | - if(!empty($keys) && count($keys) == 1) { |
|
| 602 | - if(strtolower($keys[0]) == 'default') { |
|
| 601 | + if (!empty($keys) && count($keys) == 1) { |
|
| 602 | + if (strtolower($keys[0]) == 'default') { |
|
| 603 | 603 | $masterpanels = array('default'=>$viewdefs[$moduleDir][$this->mView]['panels'][$keys[0]]); |
| 604 | 604 | } else { |
| 605 | 605 | $firstPanel = array_values($viewdefs[$moduleDir][$this->mView]['panels']); |
@@ -609,18 +609,18 @@ discard block |
||
| 609 | 609 | $masterpanels = array('default'=>$viewdefs[$moduleDir][$this->mView]['panels']); |
| 610 | 610 | } |
| 611 | 611 | } |
| 612 | - foreach($masterpanels as $name=>$masterpanel) { |
|
| 613 | - if(isset($panels[$name])) { |
|
| 612 | + foreach ($masterpanels as $name=>$masterpanel) { |
|
| 613 | + if (isset($panels[$name])) { |
|
| 614 | 614 | // Get all the names in the panel |
| 615 | 615 | $existingElements = array(); |
| 616 | 616 | $existingLocation = array(); |
| 617 | 617 | |
| 618 | - foreach($panels[$name] as $rowKey=>$row) { |
|
| 619 | - foreach($row as $colKey=>$column) { |
|
| 620 | - if(is_array($column) && !empty($column['name'])) { |
|
| 618 | + foreach ($panels[$name] as $rowKey=>$row) { |
|
| 619 | + foreach ($row as $colKey=>$column) { |
|
| 620 | + if (is_array($column) && !empty($column['name'])) { |
|
| 621 | 621 | $existingElements[$column['name']] = $column['name']; |
| 622 | 622 | $existingLocation[$column['name']] = array("panel"=>$name, "row"=>$rowKey, "col"=>$colKey); |
| 623 | - } else if(!is_array($column) && !empty($column)) { |
|
| 623 | + } else if (!is_array($column) && !empty($column)) { |
|
| 624 | 624 | $existingElements[$column] = $column; |
| 625 | 625 | $existingLocation[$column] = array("panel"=>$name, "row"=>$rowKey, "col"=>$colKey); |
| 626 | 626 | } |
@@ -628,23 +628,23 @@ discard block |
||
| 628 | 628 | } //foreach |
| 629 | 629 | |
| 630 | 630 | // Now check against the $masterCopy |
| 631 | - foreach($masterpanel as $rowKey=>$row) { |
|
| 631 | + foreach ($masterpanel as $rowKey=>$row) { |
|
| 632 | 632 | |
| 633 | 633 | $addRow = array(); |
| 634 | 634 | |
| 635 | - foreach($row as $colKey=>$column) { |
|
| 636 | - if(is_array($column) && isset($column['name'])) { |
|
| 635 | + foreach ($row as $colKey=>$column) { |
|
| 636 | + if (is_array($column) && isset($column['name'])) { |
|
| 637 | 637 | $id = $column['name']; |
| 638 | - } else if(!is_array($column) && !empty($column)) { |
|
| 638 | + } else if (!is_array($column) && !empty($column)) { |
|
| 639 | 639 | $id = $column; |
| 640 | 640 | } else { |
| 641 | 641 | continue; |
| 642 | 642 | } |
| 643 | - if(empty($existingElements[$id])) { |
|
| 643 | + if (empty($existingElements[$id])) { |
|
| 644 | 644 | //Only add if |
| 645 | 645 | // 1) if it is a required field (as defined in metadata) |
| 646 | 646 | // 2) or if it has a customLabel and customCode (a very deep customization) |
| 647 | - if((is_array($column) && !empty($column['displayParams']['required'])) || |
|
| 647 | + if ((is_array($column) && !empty($column['displayParams']['required'])) || |
|
| 648 | 648 | (is_array($column) && !empty($column['customCode']) && !empty($column['customLabel']))) { |
| 649 | 649 | $addRow[] = $column; |
| 650 | 650 | } |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | } //foreach |
| 656 | 656 | |
| 657 | 657 | // Add it to the $panels |
| 658 | - if(!empty($addRow)) { |
|
| 658 | + if (!empty($addRow)) { |
|
| 659 | 659 | $panels[$name][] = $addRow; |
| 660 | 660 | } |
| 661 | 661 | } //foreach |
@@ -667,8 +667,8 @@ discard block |
||
| 667 | 667 | |
| 668 | 668 | // We're not done yet... go through the $panels Array now and try to remove duplicate |
| 669 | 669 | // or empty panels |
| 670 | - foreach($panels as $name=>$panel) { |
|
| 671 | - if(count($panel) == 0 || !isset($masterpanels[$name])) { |
|
| 670 | + foreach ($panels as $name=>$panel) { |
|
| 671 | + if (count($panel) == 0 || !isset($masterpanels[$name])) { |
|
| 672 | 672 | unset($panels[$name]); |
| 673 | 673 | } |
| 674 | 674 | } //foreach |
@@ -688,7 +688,7 @@ discard block |
||
| 688 | 688 | require($masterCopy); |
| 689 | 689 | $masterTemplateMeta = $viewdefs[$moduleDir][$this->mView]['templateMeta']; |
| 690 | 690 | |
| 691 | - if(isset($masterTemplateMeta['javascript'])) { |
|
| 691 | + if (isset($masterTemplateMeta['javascript'])) { |
|
| 692 | 692 | //Insert the getJSPath code back into src value |
| 693 | 693 | $masterTemplateMeta['javascript'] = preg_replace('/src\s*=\s*[\'\"].*?(modules\/|include\/)([^\.]*?\.js)([^\'\"]*?)[\'\"]/i', 'src="@sq . getJSPath(@sq${1}${2}@sq) . @sq"', $masterTemplateMeta['javascript']); |
| 694 | 694 | } |
@@ -697,7 +697,7 @@ discard block |
||
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | function hasRequiredSpanLabel($html) { |
| 700 | - if(empty($html)) { |
|
| 700 | + if (empty($html)) { |
|
| 701 | 701 | return false; |
| 702 | 702 | } |
| 703 | 703 | |
@@ -706,20 +706,20 @@ discard block |
||
| 706 | 706 | |
| 707 | 707 | function hasMultiplePanels($panels) { |
| 708 | 708 | |
| 709 | - if(!isset($panels) || empty($panels) || !is_array($panels)) { |
|
| 709 | + if (!isset($panels) || empty($panels) || !is_array($panels)) { |
|
| 710 | 710 | return false; |
| 711 | 711 | } |
| 712 | 712 | |
| 713 | - if(is_array($panels) && (count($panels) == 0 || count($panels) == 1)) { |
|
| 713 | + if (is_array($panels) && (count($panels) == 0 || count($panels) == 1)) { |
|
| 714 | 714 | return false; |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | - foreach($panels as $panel) { |
|
| 718 | - if(!empty($panel) && !is_array($panel)) { |
|
| 717 | + foreach ($panels as $panel) { |
|
| 718 | + if (!empty($panel) && !is_array($panel)) { |
|
| 719 | 719 | return false; |
| 720 | 720 | } else { |
| 721 | - foreach($panel as $row) { |
|
| 722 | - if(!empty($row) && !is_array($row)) { |
|
| 721 | + foreach ($panel as $row) { |
|
| 722 | + if (!empty($row) && !is_array($row)) { |
|
| 723 | 723 | return false; |
| 724 | 724 | } //if |
| 725 | 725 | } //foreach |
@@ -729,16 +729,16 @@ discard block |
||
| 729 | 729 | return true; |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | -function getRelateFieldName($mixed='') { |
|
| 733 | - if(!is_array($mixed)) { |
|
| 732 | +function getRelateFieldName($mixed = '') { |
|
| 733 | + if (!is_array($mixed)) { |
|
| 734 | 734 | return ''; |
| 735 | - } else if(count($mixed) == 2){ |
|
| 735 | + } else if (count($mixed) == 2) { |
|
| 736 | 736 | $id = ''; |
| 737 | 737 | $name = ''; |
| 738 | - foreach($mixed as $el) { |
|
| 739 | - if(preg_match('/_id$/', $el)) { |
|
| 738 | + foreach ($mixed as $el) { |
|
| 739 | + if (preg_match('/_id$/', $el)) { |
|
| 740 | 740 | $id = $el; |
| 741 | - } else if(preg_match('/_name$/', $el)) { |
|
| 741 | + } else if (preg_match('/_name$/', $el)) { |
|
| 742 | 742 | $name = $el; |
| 743 | 743 | } |
| 744 | 744 | } |
@@ -759,7 +759,7 @@ discard block |
||
| 759 | 759 | * |
| 760 | 760 | */ |
| 761 | 761 | function fixTablesWithMissingTr($tableContents) { |
| 762 | - if(preg_match('/(<table[^>]*?[\/]?>\s*?<td)/i', $tableContents, $matches)) { |
|
| 762 | + if (preg_match('/(<table[^>]*?[\/]?>\s*?<td)/i', $tableContents, $matches)) { |
|
| 763 | 763 | return preg_replace('/(<table[^>]*?[\/]?>\s*?<td)/i', '<table><tr><td', $tableContents); |
| 764 | 764 | } |
| 765 | 765 | return $tableContents; |
@@ -770,7 +770,7 @@ discard block |
||
| 770 | 770 | * This is a very crude function to fix instances where files have an </tr> tag immediately followed by a <td> tag |
| 771 | 771 | */ |
| 772 | 772 | function fixRowsWithMissingTr($tableContents) { |
| 773 | - if(preg_match('/(<\/tr[^>]*?[\/]?>\s*?<td)/i', $tableContents, $matches)) { |
|
| 773 | + if (preg_match('/(<\/tr[^>]*?[\/]?>\s*?<td)/i', $tableContents, $matches)) { |
|
| 774 | 774 | return preg_replace('/(<\/tr[^>]*?[\/]?>\s*?<td)/i', '</tr><tr><td', $tableContents); |
| 775 | 775 | } |
| 776 | 776 | return $tableContents; |
@@ -781,7 +781,7 @@ discard block |
||
| 781 | 781 | * This is a very crude function to fix instances where files have two consecutive <tr> tags |
| 782 | 782 | */ |
| 783 | 783 | function fixDuplicateTrTags($tableContents) { |
| 784 | - if(preg_match('/(<tr[^>]*?[\/]?>\s*?<tr)/i', $tableContents, $matches)) { |
|
| 784 | + if (preg_match('/(<tr[^>]*?[\/]?>\s*?<tr)/i', $tableContents, $matches)) { |
|
| 785 | 785 | return preg_replace('/(<tr[^>]*?[\/]?>\s*?<tr)/i', '<tr', $tableContents); |
| 786 | 786 | } |
| 787 | 787 | return $tableContents; |
@@ -792,14 +792,14 @@ discard block |
||
| 792 | 792 | * Scans array of form elements to see if just one is a vardef element and, if so, |
| 793 | 793 | * return that vardef name |
| 794 | 794 | */ |
| 795 | -function findSingleVardefElement($formElements=array(), $vardefs=array()) { |
|
| 796 | - if(empty($formElements) || !is_array($formElements)) { |
|
| 795 | +function findSingleVardefElement($formElements = array(), $vardefs = array()) { |
|
| 796 | + if (empty($formElements) || !is_array($formElements)) { |
|
| 797 | 797 | return ''; |
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | $found = array(); |
| 801 | - foreach($formElements as $el) { |
|
| 802 | - if(isset($vardefs[$el])) { |
|
| 801 | + foreach ($formElements as $el) { |
|
| 802 | + if (isset($vardefs[$el])) { |
|
| 803 | 803 | $found[] = $el; |
| 804 | 804 | } |
| 805 | 805 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | /** |
| 97 | 97 | * getFormElementsNames |
| 98 | 98 | * Parses for the name values of input, select, textarea types from string content |
| 99 | - * @param $contents The String contents to parse |
|
| 99 | + * @param string $contents The String contents to parse |
|
| 100 | 100 | * @return $matches Array of name/value pairs |
| 101 | 101 | */ |
| 102 | 102 | function getFormElementsNames($contents) { |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | /** |
| 109 | 109 | * getTagAttribute |
| 110 | 110 | * Returns the name/value of a tag attribute where name is set to $name |
| 111 | - * @param $name The name of the attribute |
|
| 111 | + * @param string $name The name of the attribute |
|
| 112 | 112 | * @param $contents The contents to parse |
| 113 | 113 | * @param $filter Option regular expression to filter value |
| 114 | 114 | * @return Array of name/value for matching attribute |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * and method call getElementsByType("<td>", $contents) returns |
| 164 | 164 | * "<td>Text <table><tr><td>a</td></tr></table></td>" |
| 165 | 165 | * |
| 166 | - * @param $type The type of element to parse out and return |
|
| 166 | + * @param string $type The type of element to parse out and return |
|
| 167 | 167 | * @return a tag element format Array |
| 168 | 168 | */ |
| 169 | 169 | function getElementsByType($type, $contents) { |
@@ -208,6 +208,7 @@ discard block |
||
| 208 | 208 | /** |
| 209 | 209 | * getElementValue |
| 210 | 210 | * |
| 211 | + * @param string $type |
|
| 211 | 212 | */ |
| 212 | 213 | function getElementValue($type, $contents, $filter = "(.*?)") { |
| 213 | 214 | $exp = "'<".$type."[^>]*?>".$filter."</".$type."[^>]*?>'si"; |
@@ -244,7 +245,7 @@ discard block |
||
| 244 | 245 | * Returns the highest number of <td>...</td> blocks within a <tr>...</tr> block. |
| 245 | 246 | * @param $contents The table contents to parse |
| 246 | 247 | * @param $filter Optional filter to parse for an attribute within the td block. |
| 247 | - * @return The maximum column count |
|
| 248 | + * @return integer maximum column count |
|
| 248 | 249 | */ |
| 249 | 250 | function getMaxColumns($contents, $filter) { |
| 250 | 251 | preg_match_all("'(<tr[^>]*?>)(.*?)(</tr[^>]*?>)'si", $contents, $matches, PREG_SET_ORDER); |
@@ -281,6 +282,9 @@ discard block |
||
| 281 | 282 | * trimHTML |
| 282 | 283 | * This function removes the \r (return), \n (newline) and \t (tab) markup from string |
| 283 | 284 | */ |
| 285 | +/** |
|
| 286 | + * @param string $contents |
|
| 287 | + */ |
|
| 284 | 288 | function trimHTML($contents) { |
| 285 | 289 | $contents = str_replace(array("\r"), array(""), $contents); |
| 286 | 290 | $contents = str_replace(array("\n"), array(""), $contents); |
@@ -342,6 +346,9 @@ discard block |
||
| 342 | 346 | |
| 343 | 347 | } |
| 344 | 348 | |
| 349 | +/** |
|
| 350 | + * @param string $javascript |
|
| 351 | + */ |
|
| 345 | 352 | static function parseDelimiters($javascript) { |
| 346 | 353 | $newJavascript = ''; |
| 347 | 354 | $scriptLength = strlen($javascript); |
@@ -441,7 +448,7 @@ discard block |
||
| 441 | 448 | * dirList |
| 442 | 449 | * Utility method to list all the files in a given directory. |
| 443 | 450 | * |
| 444 | - * @param $directory The directory to scan |
|
| 451 | + * @param string $directory The directory to scan |
|
| 445 | 452 | * @return $results The files in the directory that were found |
| 446 | 453 | */ |
| 447 | 454 | function dirList ($directory) { |
@@ -496,6 +503,9 @@ discard block |
||
| 496 | 503 | return null; |
| 497 | 504 | } |
| 498 | 505 | |
| 506 | +/** |
|
| 507 | + * @param string $moduleDir |
|
| 508 | + */ |
|
| 499 | 509 | function applyPreRules($moduleDir, $panels) { |
| 500 | 510 | if(file_exists("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php")) { |
| 501 | 511 | require_once("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php"); |
@@ -506,6 +516,9 @@ discard block |
||
| 506 | 516 | return $panels; |
| 507 | 517 | } |
| 508 | 518 | |
| 519 | +/** |
|
| 520 | + * @param string $moduleDir |
|
| 521 | + */ |
|
| 509 | 522 | function applyRules($moduleDir, $panels) { |
| 510 | 523 | return $this->applyPostRules($moduleDir, $panels); |
| 511 | 524 | } |
@@ -537,6 +550,9 @@ discard block |
||
| 537 | 550 | return $panels; |
| 538 | 551 | } |
| 539 | 552 | |
| 553 | +/** |
|
| 554 | + * @param string $moduleDir |
|
| 555 | + */ |
|
| 540 | 556 | function createFileContents($moduleDir, $panels, $templateMeta=array(), $htmlFilePath) { |
| 541 | 557 | |
| 542 | 558 | $header = "<?php\n\n"; |
@@ -587,7 +603,7 @@ discard block |
||
| 587 | 603 | * mergePanels |
| 588 | 604 | * This function merges the $panels Array against the $masterCopy's meta data definition |
| 589 | 605 | * @param $panels meta data Array to merge |
| 590 | - * @param $moduleDir Directory name of the module |
|
| 606 | + * @param string $moduleDir Directory name of the module |
|
| 591 | 607 | * @param $masterCopy file path to the meta data master copy |
| 592 | 608 | * @return Array of merged $panel definition |
| 593 | 609 | */ |
@@ -680,7 +696,7 @@ discard block |
||
| 680 | 696 | * mergeTemplateMeta |
| 681 | 697 | * This function merges the $templateMeta Array against the $masterCopy's meta data definition |
| 682 | 698 | * @param $templateMeta meta data Array to merge |
| 683 | - * @param $moduleDir Directory name of the module |
|
| 699 | + * @param string $moduleDir Directory name of the module |
|
| 684 | 700 | * @param $masterCopy file path to the meta data master copy |
| 685 | 701 | * @return Array of merged $templateMeta definition |
| 686 | 702 | */ |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | static function fixupFieldType($field) { |
| 51 | - switch($field) { |
|
| 51 | + switch ($field) { |
|
| 52 | 52 | case 'double': |
| 53 | 53 | case 'decimal': |
| 54 | 54 | $field = 'float'; |
@@ -79,26 +79,26 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @param field string field type |
| 81 | 81 | */ |
| 82 | - static function getSugarField($field, $returnNullIfBase=false) { |
|
| 82 | + static function getSugarField($field, $returnNullIfBase = false) { |
|
| 83 | 83 | static $sugarFieldObjects = array(); |
| 84 | 84 | |
| 85 | 85 | $field = self::fixupFieldType($field); |
| 86 | 86 | $field = ucfirst($field); |
| 87 | 87 | |
| 88 | - if(!isset($sugarFieldObjects[$field])) { |
|
| 88 | + if (!isset($sugarFieldObjects[$field])) { |
|
| 89 | 89 | //check custom directory |
| 90 | - if(file_exists('custom/include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php')){ |
|
| 91 | - $file = 'custom/include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php'; |
|
| 90 | + if (file_exists('custom/include/SugarFields/Fields/'.$field.'/SugarField'.$field.'.php')) { |
|
| 91 | + $file = 'custom/include/SugarFields/Fields/'.$field.'/SugarField'.$field.'.php'; |
|
| 92 | 92 | $type = $field; |
| 93 | 93 | //else check the fields directory |
| 94 | - }else if(file_exists('include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php')){ |
|
| 95 | - $file = 'include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php'; |
|
| 94 | + } else if (file_exists('include/SugarFields/Fields/'.$field.'/SugarField'.$field.'.php')) { |
|
| 95 | + $file = 'include/SugarFields/Fields/'.$field.'/SugarField'.$field.'.php'; |
|
| 96 | 96 | $type = $field; |
| 97 | - }else{ |
|
| 97 | + } else { |
|
| 98 | 98 | // No direct class, check the directories to see if they are defined |
| 99 | - if( $returnNullIfBase && |
|
| 99 | + if ($returnNullIfBase && |
|
| 100 | 100 | !is_dir('custom/include/SugarFields/Fields/'.$field) && |
| 101 | - !is_dir('include/SugarFields/Fields/'.$field) ) { |
|
| 101 | + !is_dir('include/SugarFields/Fields/'.$field)) { |
|
| 102 | 102 | return null; |
| 103 | 103 | } |
| 104 | 104 | $file = 'include/SugarFields/Fields/Base/SugarFieldBase.php'; |
@@ -106,12 +106,12 @@ discard block |
||
| 106 | 106 | } |
| 107 | 107 | require_once($file); |
| 108 | 108 | |
| 109 | - $class = 'SugarField' . $type; |
|
| 109 | + $class = 'SugarField'.$type; |
|
| 110 | 110 | //could be a custom class check it |
| 111 | - $customClass = 'Custom' . $class; |
|
| 112 | - if(class_exists($customClass)){ |
|
| 111 | + $customClass = 'Custom'.$class; |
|
| 112 | + if (class_exists($customClass)) { |
|
| 113 | 113 | $sugarFieldObjects[$field] = new $customClass($field); |
| 114 | - }else{ |
|
| 114 | + } else { |
|
| 115 | 115 | $sugarFieldObjects[$field] = new $class($field); |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -132,20 +132,20 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | static function displaySmarty($parentFieldArray, $vardef, $displayType, $displayParams = array(), $tabindex = 1) { |
| 134 | 134 | $string = ''; |
| 135 | - $displayTypeFunc = 'get' . $displayType . 'Smarty'; // getDetailViewSmarty, getEditViewSmarty, etc... |
|
| 135 | + $displayTypeFunc = 'get'.$displayType.'Smarty'; // getDetailViewSmarty, getEditViewSmarty, etc... |
|
| 136 | 136 | |
| 137 | 137 | // This will handle custom type fields. |
| 138 | 138 | // The incoming $vardef Array may have custom_type set. |
| 139 | 139 | // If so, set $vardef['type'] to the $vardef['custom_type'] value |
| 140 | - if(isset($vardef['custom_type'])) { |
|
| 140 | + if (isset($vardef['custom_type'])) { |
|
| 141 | 141 | $vardef['type'] = $vardef['custom_type']; |
| 142 | 142 | } |
| 143 | - if(empty($vardef['type'])) { |
|
| 143 | + if (empty($vardef['type'])) { |
|
| 144 | 144 | $vardef['type'] = 'varchar'; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | $field = self::getSugarField($vardef['type']); |
| 148 | - if ( !empty($vardef['function']) ) { |
|
| 148 | + if (!empty($vardef['function'])) { |
|
| 149 | 149 | $string = $field->displayFromFunc($displayType, $parentFieldArray, $vardef, $displayParams, $tabindex); |
| 150 | 150 | } else { |
| 151 | 151 | $string = $field->$displayTypeFunc($parentFieldArray, $vardef, $displayParams, $tabindex); |
@@ -47,6 +47,9 @@ |
||
| 47 | 47 | function SugarFieldHandler() { |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | + /** |
|
| 51 | + * @param string $field |
|
| 52 | + */ |
|
| 50 | 53 | static function fixupFieldType($field) { |
| 51 | 54 | switch($field) { |
| 52 | 55 | case 'double': |
@@ -43,19 +43,19 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | function getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) { |
| 45 | 45 | // Create Smarty variables for the Calendar picker widget |
| 46 | - if(!isset($displayParams['showMinutesDropdown'])) { |
|
| 46 | + if (!isset($displayParams['showMinutesDropdown'])) { |
|
| 47 | 47 | $displayParams['showMinutesDropdown'] = false; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if(!isset($displayParams['showHoursDropdown'])) { |
|
| 50 | + if (!isset($displayParams['showHoursDropdown'])) { |
|
| 51 | 51 | $displayParams['showHoursDropdown'] = false; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - if(!isset($displayParams['showNoneCheckbox'])) { |
|
| 54 | + if (!isset($displayParams['showNoneCheckbox'])) { |
|
| 55 | 55 | $displayParams['showNoneCheckbox'] = false; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if(!isset($displayParams['showFormats'])) { |
|
| 58 | + if (!isset($displayParams['showFormats'])) { |
|
| 59 | 59 | $displayParams['showFormats'] = false; |
| 60 | 60 | } |
| 61 | 61 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) { |
| 77 | 77 | |
| 78 | - if($this->isRangeSearchView($vardef)) { |
|
| 78 | + if ($this->isRangeSearchView($vardef)) { |
|
| 79 | 79 | $displayParams['showMinutesDropdown'] = false; |
| 80 | 80 | $displayParams['showHoursDropdown'] = false; |
| 81 | 81 | $displayParams['showNoneCheckbox'] = false; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $this->ss->assign('id_range_start', "start_range_{$id}"); |
| 92 | 92 | $this->ss->assign('id_range_end', "end_range_{$id}"); |
| 93 | 93 | $this->ss->assign('id_range_choice', "{$id}_range_choice"); |
| 94 | - if(file_exists('custom/include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl')) |
|
| 94 | + if (file_exists('custom/include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl')) |
|
| 95 | 95 | { |
| 96 | 96 | return $this->fetch('custom/include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl'); |
| 97 | 97 | } |
@@ -99,19 +99,19 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // Create Smarty variables for the Calendar picker widget |
| 102 | - if(!isset($displayParams['showMinutesDropdown'])) { |
|
| 102 | + if (!isset($displayParams['showMinutesDropdown'])) { |
|
| 103 | 103 | $displayParams['showMinutesDropdown'] = false; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - if(!isset($displayParams['showHoursDropdown'])) { |
|
| 106 | + if (!isset($displayParams['showHoursDropdown'])) { |
|
| 107 | 107 | $displayParams['showHoursDropdown'] = false; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if(!isset($displayParams['showNoneCheckbox'])) { |
|
| 110 | + if (!isset($displayParams['showNoneCheckbox'])) { |
|
| 111 | 111 | $displayParams['showNoneCheckbox'] = false; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if(!isset($displayParams['showFormats'])) { |
|
| 114 | + if (!isset($displayParams['showFormats'])) { |
|
| 115 | 115 | $displayParams['showFormats'] = false; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -124,9 +124,9 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
| 127 | - public function getEmailTemplateValue($inputField, $vardef, $context = null, $tabindex = 0){ |
|
| 127 | + public function getEmailTemplateValue($inputField, $vardef, $context = null, $tabindex = 0) { |
|
| 128 | 128 | // This does not return a smarty section, instead it returns a direct value |
| 129 | - if(isset($context['notify_user'])) { |
|
| 129 | + if (isset($context['notify_user'])) { |
|
| 130 | 130 | $user = $context['notify_user']; |
| 131 | 131 | } else { |
| 132 | 132 | $user = $GLOBALS['current_user']; |
@@ -136,19 +136,19 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | public function save(&$bean, $params, $field, $properties, $prefix = '') { |
| 138 | 138 | global $timedate; |
| 139 | - if ( !isset($params[$prefix.$field]) ) { |
|
| 139 | + if (!isset($params[$prefix.$field])) { |
|
| 140 | 140 | //$bean->$field = ''; |
| 141 | 141 | return; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - if(strpos($params[$prefix.$field], ' ') > 0) { |
|
| 144 | + if (strpos($params[$prefix.$field], ' ') > 0) { |
|
| 145 | 145 | if ($timedate->check_matching_format($params[$prefix.$field], TimeDate::DB_DATETIME_FORMAT)) { |
| 146 | 146 | $bean->$field = $params[$prefix.$field]; |
| 147 | 147 | } else { |
| 148 | 148 | $bean->$field = $timedate->to_db($params[$prefix.$field]); |
| 149 | 149 | } |
| 150 | 150 | } else { |
| 151 | - $GLOBALS['log']->error('Field ' . $prefix.$field . ' expecting datetime format, but got value: ' . $params[$prefix.$field]); |
|
| 151 | + $GLOBALS['log']->error('Field '.$prefix.$field.' expecting datetime format, but got value: '.$params[$prefix.$field]); |
|
| 152 | 152 | //Default to assume date format value |
| 153 | 153 | if ($timedate->check_matching_format($params[$prefix.$field], TimeDate::DB_DATE_FORMAT)) { |
| 154 | 154 | $bean->$field = $params[$prefix.$field]; |
@@ -172,39 +172,39 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | $format = $timedate->merge_date_time($settings->dateformat, $settings->timeformat); |
| 174 | 174 | |
| 175 | - if ( !$timedate->check_matching_format($value, $format) ) { |
|
| 175 | + if (!$timedate->check_matching_format($value, $format)) { |
|
| 176 | 176 | $parts = $timedate->split_date_time($value); |
| 177 | - if(empty($parts[0])) { |
|
| 177 | + if (empty($parts[0])) { |
|
| 178 | 178 | $datepart = $timedate->getNow()->format($settings->dateformat); |
| 179 | 179 | } |
| 180 | 180 | else { |
| 181 | 181 | $datepart = $parts[0]; |
| 182 | 182 | } |
| 183 | - if(empty($parts[1])) { |
|
| 183 | + if (empty($parts[1])) { |
|
| 184 | 184 | $timepart = $timedate->fromTimestamp(0)->format($settings->timeformat); |
| 185 | 185 | } else { |
| 186 | 186 | $timepart = $parts[1]; |
| 187 | 187 | // see if we can get by stripping the seconds |
| 188 | - if(strpos($settings->timeformat, 's') === false) { |
|
| 188 | + if (strpos($settings->timeformat, 's') === false) { |
|
| 189 | 189 | $sep = $timedate->timeSeparatorFormat($settings->timeformat); |
| 190 | 190 | // We are assuming here seconds are the last component, which |
| 191 | 191 | // is kind of reasonable - no sane time format puts seconds first |
| 192 | 192 | $timeparts = explode($sep, $timepart); |
| 193 | - if(!empty($timeparts[2])) { |
|
| 193 | + if (!empty($timeparts[2])) { |
|
| 194 | 194 | $timepart = join($sep, array($timeparts[0], $timeparts[1])); |
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | $value = $timedate->merge_date_time($datepart, $timepart); |
| 200 | - if ( !$timedate->check_matching_format($value, $format) ) { |
|
| 200 | + if (!$timedate->check_matching_format($value, $format)) { |
|
| 201 | 201 | return false; |
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | try { |
| 206 | 206 | $date = SugarDateTime::createFromFormat($format, $value, new DateTimeZone($settings->timezone)); |
| 207 | - } catch(Exception $e) { |
|
| 207 | + }catch (Exception $e) { |
|
| 208 | 208 | return false; |
| 209 | 209 | } |
| 210 | 210 | return $date->asDb(); |
@@ -43,10 +43,10 @@ |
||
| 43 | 43 | |
| 44 | 44 | function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) { |
| 45 | 45 | $vardef['options'] = get_user_array(false); |
| 46 | - if(!empty($vardef['function']['returns']) && $vardef['function']['returns']== 'html'){ |
|
| 46 | + if (!empty($vardef['function']['returns']) && $vardef['function']['returns'] == 'html') { |
|
| 47 | 47 | $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex); |
| 48 | 48 | return $this->fetch($this->findTemplate('EditViewFunction')); |
| 49 | - }else{ |
|
| 49 | + } else { |
|
| 50 | 50 | $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex); |
| 51 | 51 | return $this->fetch($this->findTemplate('SearchView')); |
| 52 | 52 | } |
@@ -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); |
@@ -80,8 +80,6 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * Legacy email address handling. This is to allow support for SOAP or customizations |
| 83 | - * @param string $id |
|
| 84 | - * @param string $module |
|
| 85 | 83 | */ |
| 86 | 84 | function handleLegacySave($bean, $prefix = "") { |
| 87 | 85 | if(!isset($_REQUEST) || !isset($_REQUEST['useEmailWidget'])) { |
@@ -166,12 +164,6 @@ discard block |
||
| 166 | 164 | |
| 167 | 165 | /** |
| 168 | 166 | * Saves email addresses for a parent bean |
| 169 | - * @param string $id Parent bean ID |
|
| 170 | - * @param string $module Parent bean's module |
|
| 171 | - * @param array $addresses Override of $_REQUEST vars, used to handle non-standard bean saves |
|
| 172 | - * @param string $primary GUID of primary address |
|
| 173 | - * @param string $replyTo GUID of reply-to address |
|
| 174 | - * @param string $invalid GUID of invalid address |
|
| 175 | 167 | */ |
| 176 | 168 | public function save($check_notify = FALSE) { |
| 177 | 169 | $args = func_get_args(); |
@@ -369,7 +361,6 @@ discard block |
||
| 369 | 361 | * Saves email addresses for a parent bean |
| 370 | 362 | * @param string $id Parent bean ID |
| 371 | 363 | * @param string $module Parent bean's module |
| 372 | - * @param array $addresses Override of $_REQUEST vars, used to handle non-standard bean saves |
|
| 373 | 364 | * @param string $primary GUID of primary address |
| 374 | 365 | * @param string $replyTo GUID of reply-to address |
| 375 | 366 | * @param string $invalid GUID of invalid address |
@@ -620,7 +611,7 @@ discard block |
||
| 620 | 611 | |
| 621 | 612 | /** |
| 622 | 613 | * preps a passed email address for email address storage |
| 623 | - * @param array $addr Address in focus, must be RFC compliant |
|
| 614 | + * @param string $addr Address in focus, must be RFC compliant |
|
| 624 | 615 | * @return string $id email_addresses ID |
| 625 | 616 | */ |
| 626 | 617 | function getEmailGUID($addr) { |
@@ -733,7 +724,8 @@ discard block |
||
| 733 | 724 | |
| 734 | 725 | /** |
| 735 | 726 | * Returns Primary or newest email address |
| 736 | - * @param object $focus Object in focus |
|
| 727 | + * @param boolean $focus Object in focus |
|
| 728 | + * @param string $parent_type |
|
| 737 | 729 | * @return string email |
| 738 | 730 | */ |
| 739 | 731 | function getPrimaryAddress($focus,$parent_id=null,$parent_type=null) { |
@@ -804,7 +796,7 @@ discard block |
||
| 804 | 796 | * Returns all email addresses by parent's GUID |
| 805 | 797 | * @param string $id Parent's GUID |
| 806 | 798 | * @param string $module Parent's module |
| 807 | - * @return array |
|
| 799 | + * @return string |
|
| 808 | 800 | */ |
| 809 | 801 | function getAddressesByGUID($id, $module) { |
| 810 | 802 | $return = array(); |
@@ -828,7 +820,6 @@ discard block |
||
| 828 | 820 | |
| 829 | 821 | /** |
| 830 | 822 | * Returns the HTML/JS for the EmailAddress widget |
| 831 | - * @param string $parent_id ID of parent bean, generally $focus |
|
| 832 | 823 | * @param string $module $focus' module |
| 833 | 824 | * @param bool asMetadata Default false |
| 834 | 825 | * @return string HTML/JS for widget |
@@ -965,7 +956,7 @@ discard block |
||
| 965 | 956 | |
| 966 | 957 | /** |
| 967 | 958 | * getEmailAddressWidgetDuplicatesView($focus) |
| 968 | - * @param object $focus Bean in focus |
|
| 959 | + * @param Lead $focus Bean in focus |
|
| 969 | 960 | * @return string HTML that contains hidden input values based off of HTML request |
| 970 | 961 | */ |
| 971 | 962 | function getEmailAddressWidgetDuplicatesView($focus) |
@@ -1041,6 +1032,7 @@ discard block |
||
| 1041 | 1032 | /** |
| 1042 | 1033 | * getFormBaseURL |
| 1043 | 1034 | * |
| 1035 | + * @param SugarBean $focus |
|
| 1044 | 1036 | */ |
| 1045 | 1037 | function getFormBaseURL($focus) { |
| 1046 | 1038 | $get = ""; |
@@ -1081,13 +1073,15 @@ discard block |
||
| 1081 | 1073 | |
| 1082 | 1074 | } |
| 1083 | 1075 | |
| 1076 | + /** |
|
| 1077 | + * @param string $view |
|
| 1078 | + */ |
|
| 1084 | 1079 | function setView($view) { |
| 1085 | 1080 | $this->view = $view; |
| 1086 | 1081 | } |
| 1087 | 1082 | |
| 1088 | 1083 | /** |
| 1089 | 1084 | * This function is here so the Employees/Users division can be handled cleanly in one place |
| 1090 | - * @param object $focus SugarBean |
|
| 1091 | 1085 | * @return string The value for the bean_module column in the email_addr_bean_rel table |
| 1092 | 1086 | */ |
| 1093 | 1087 | function getCorrectedModule(&$module) { |
@@ -1119,7 +1113,7 @@ discard block |
||
| 1119 | 1113 | |
| 1120 | 1114 | /** |
| 1121 | 1115 | * Convenience function for MVC (Mystique) |
| 1122 | - * @param object $focus SugarBean |
|
| 1116 | + * @param SugarBean $focus SugarBean |
|
| 1123 | 1117 | * @param string $field unused |
| 1124 | 1118 | * @param string $value unused |
| 1125 | 1119 | * @param string $view DetailView or EditView |