@@ -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. |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @param $masterCopy The file path of the mater copy of the metadata file to merge against |
| 66 | 66 | * @return String format of metadata contents |
| 67 | 67 | **/ |
| 68 | -function parse($filePath, $vardefs = array(), $moduleDir = '', $merge=false, $masterCopy=null) { |
|
| 68 | +function parse($filePath, $vardefs = array(), $moduleDir = '', $merge = false, $masterCopy = null) { |
|
| 69 | 69 | |
| 70 | 70 | global $app_strings; |
| 71 | 71 | $contents = file_get_contents($filePath); |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | $tables = $this->getElementsByType("table", $contents); |
| 80 | 80 | $formElements = $this->getFormElements($tables[0]); |
| 81 | 81 | $hiddenInputs = array(); |
| 82 | - foreach($formElements as $elem) { |
|
| 82 | + foreach ($formElements as $elem) { |
|
| 83 | 83 | $type = $this->getTagAttribute("type", $elem); |
| 84 | - if(preg_match('/hidden/si',$type)) { |
|
| 84 | + if (preg_match('/hidden/si', $type)) { |
|
| 85 | 85 | $name = $this->getTagAttribute("name", $elem); |
| 86 | 86 | $value = $this->getTagAttribute("value", $elem); |
| 87 | 87 | $hiddenInputs[$name] = $value; |
@@ -95,22 +95,22 @@ discard block |
||
| 95 | 95 | $addedElements = array(); |
| 96 | 96 | $maxTableCountNum = 0; |
| 97 | 97 | $tableCount = 0; |
| 98 | - foreach($tables as $table) { |
|
| 98 | + foreach ($tables as $table) { |
|
| 99 | 99 | $table = $this->fixTablesWithMissingTr($table); |
| 100 | 100 | $toptr = $this->getElementsByType("tr", $table); |
| 101 | - foreach($toptr as $tr) { |
|
| 101 | + foreach ($toptr as $tr) { |
|
| 102 | 102 | $tabledata = $this->getElementsByType("table", $tr); |
| 103 | 103 | $data = array(); |
| 104 | 104 | $panelKey = $tableCount == 0 ? "default" : ''; |
| 105 | - foreach($tabledata as $t) { |
|
| 105 | + foreach ($tabledata as $t) { |
|
| 106 | 106 | $vals = array_values($this->getElementsByType("tr", $t)); |
| 107 | - if(preg_match_all('/<h4[^>]*?>.*?(\{MOD\.|\{APP\.)(LBL_[^\}]*?)[\}].*?<\/h4>/s', $vals[0], $matches, PREG_SET_ORDER)) { |
|
| 107 | + if (preg_match_all('/<h4[^>]*?>.*?(\{MOD\.|\{APP\.)(LBL_[^\}]*?)[\}].*?<\/h4>/s', $vals[0], $matches, PREG_SET_ORDER)) { |
|
| 108 | 108 | array_shift($vals); |
| 109 | 109 | $panelKey = count($matches[0]) == 3 ? strtolower($matches[0][2]) : $panelKey; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | //If $panelKey is empty use the maxTableCountNum value |
| 113 | - if(empty($panelKey)) { |
|
| 113 | + if (empty($panelKey)) { |
|
| 114 | 114 | $panels[$maxTableCountNum++] = $vals; |
| 115 | 115 | } else { |
| 116 | 116 | $panels[$panelKey] = $vals; |
@@ -120,37 +120,37 @@ discard block |
||
| 120 | 120 | } //foreach; |
| 121 | 121 | } //foreach |
| 122 | 122 | |
| 123 | - foreach($panels as $id=>$tablerows) { |
|
| 123 | + foreach ($panels as $id=>$tablerows) { |
|
| 124 | 124 | |
| 125 | 125 | $metarow = array(); |
| 126 | 126 | |
| 127 | - foreach($tablerows as $trow) { |
|
| 127 | + foreach ($tablerows as $trow) { |
|
| 128 | 128 | |
| 129 | 129 | $emptyCount = 0; |
| 130 | 130 | $tablecolumns = $this->getElementsByType("td", $trow); |
| 131 | 131 | $col = array(); |
| 132 | 132 | $slot = 0; |
| 133 | 133 | |
| 134 | - foreach($tablecolumns as $tcols) { |
|
| 134 | + foreach ($tablecolumns as $tcols) { |
|
| 135 | 135 | $hasRequiredLabel = false; |
| 136 | 136 | |
| 137 | 137 | //Get the sugar attribute value in the span elements of each table row |
| 138 | 138 | $sugarAttrLabel = $this->getTagAttribute("sugar", $tcols, "'^slot[^b]+$'"); |
| 139 | 139 | |
| 140 | 140 | //If there was no sugar attribute, try id (some versions of EditView.html used this instead) |
| 141 | - if(empty($sugarAttrLabel)) { |
|
| 141 | + if (empty($sugarAttrLabel)) { |
|
| 142 | 142 | $sugarAttrLabel = $this->getTagAttribute("id", $tcols, "'^slot[^b]+$'"); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | //Check if this field is required |
| 146 | - if(!empty($sugarAttrLabel)) { |
|
| 146 | + if (!empty($sugarAttrLabel)) { |
|
| 147 | 147 | $hasRequiredLabel = $this->hasRequiredSpanLabel($tcols); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | $sugarAttrValue = $this->getTagAttribute("sugar", $tcols, "'slot[0-9]+b$'"); |
| 151 | 151 | |
| 152 | 152 | //If there was no sugar attribute, try id (some versions of EditView.html used this instead) |
| 153 | - if(empty($sugarAttrValue)) { |
|
| 153 | + if (empty($sugarAttrValue)) { |
|
| 154 | 154 | $sugarAttrValue = $this->getTagAttribute("id", $tcols, "'slot[0-9]+b$'"); |
| 155 | 155 | } |
| 156 | 156 | |
@@ -159,15 +159,15 @@ discard block |
||
| 159 | 159 | $sugarAttrValue = count($sugarAttrValue) != 0 ? $sugarAttrValue : ($slot % 2 == 1) ? true : false; |
| 160 | 160 | $slot++; |
| 161 | 161 | |
| 162 | - if($sugarAttrValue) { |
|
| 162 | + if ($sugarAttrValue) { |
|
| 163 | 163 | |
| 164 | 164 | $spanValue = $this->getElementValue("span", $tcols); |
| 165 | 165 | |
| 166 | - if(empty($spanValue)) { |
|
| 166 | + if (empty($spanValue)) { |
|
| 167 | 167 | $spanValue = $this->getElementValue("slot", $tcols); |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if(empty($spanValue)) { |
|
| 170 | + if (empty($spanValue)) { |
|
| 171 | 171 | $spanValue = $this->getElementValue("td", $tcols); |
| 172 | 172 | } |
| 173 | 173 | |
@@ -179,25 +179,25 @@ discard block |
||
| 179 | 179 | $fields = null; |
| 180 | 180 | $customCode = null; |
| 181 | 181 | |
| 182 | - if(!empty($customField)) { |
|
| 182 | + if (!empty($customField)) { |
|
| 183 | 183 | // If it's a custom field we just set the name |
| 184 | 184 | $name = $customField; |
| 185 | 185 | |
| 186 | - } else if(empty($formElementNames) && preg_match_all('/[\{]([^\}]*?)[\}]/s', $spanValue, $matches, PREG_SET_ORDER)) { |
|
| 186 | + } else if (empty($formElementNames) && preg_match_all('/[\{]([^\}]*?)[\}]/s', $spanValue, $matches, PREG_SET_ORDER)) { |
|
| 187 | 187 | // We are here if the $spanValue did not contain a form element for editing. |
| 188 | 188 | // We will assume that it is read only (since there were no edit form elements) |
| 189 | 189 | |
| 190 | 190 | |
| 191 | 191 | // If there is more than one matching {} value then try to find the right one to key off |
| 192 | 192 | // based on vardefs.php file. Also, use the entire spanValue as customCode |
| 193 | - if(count($matches) > 1) { |
|
| 193 | + if (count($matches) > 1) { |
|
| 194 | 194 | $name = $matches[0][1]; |
| 195 | 195 | $customCode = $spanValue; |
| 196 | - foreach($matches as $pair) { |
|
| 197 | - if(preg_match("/^(mod[\.]|app[\.]).*?/i", $pair[1])) { |
|
| 196 | + foreach ($matches as $pair) { |
|
| 197 | + if (preg_match("/^(mod[\.]|app[\.]).*?/i", $pair[1])) { |
|
| 198 | 198 | $customCode = str_replace($pair[1], '$'.strtoupper($pair[1]), $customCode); |
| 199 | 199 | } else { |
| 200 | - if(!empty($vardefs[$pair[1]])) { |
|
| 200 | + if (!empty($vardefs[$pair[1]])) { |
|
| 201 | 201 | $name = $pair[1]; |
| 202 | 202 | $customCode = str_replace($pair[1], '$fields.'.strtolower($pair[1]).'.value', $customCode); |
| 203 | 203 | } else { |
@@ -208,24 +208,24 @@ discard block |
||
| 208 | 208 | } //foreach |
| 209 | 209 | } else { |
| 210 | 210 | //If it is only a label, skip |
| 211 | - if(preg_match("/^(mod[\.]|app[\.]).*?/i", $matches[0][1])) { |
|
| 211 | + if (preg_match("/^(mod[\.]|app[\.]).*?/i", $matches[0][1])) { |
|
| 212 | 212 | continue; |
| 213 | 213 | } |
| 214 | 214 | $name = strtolower($matches[0][1]); |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - } else if(is_array($formElementNames)) { |
|
| 217 | + } else if (is_array($formElementNames)) { |
|
| 218 | 218 | |
| 219 | - if(count($formElementNames) == 1) { |
|
| 219 | + if (count($formElementNames) == 1) { |
|
| 220 | 220 | |
| 221 | - if(!empty($vardefs[$formElementNames[0]])) { |
|
| 221 | + if (!empty($vardefs[$formElementNames[0]])) { |
|
| 222 | 222 | $name = $formElementNames[0]; |
| 223 | 223 | } else { |
| 224 | 224 | // Try to use the EdtiView.php file to find author's intent |
| 225 | 225 | $name = $this->findAssignedVariableName($formElementNames[0], $filePath); |
| 226 | 226 | |
| 227 | 227 | //If it's still empty, just use the entire block as customCode |
| 228 | - if(empty($vardefs[$name])) { |
|
| 228 | + if (empty($vardefs[$name])) { |
|
| 229 | 229 | //Replace any { characters just in case |
| 230 | 230 | $customCode = str_replace('{', '{$', $spanValue); |
| 231 | 231 | } |
@@ -233,16 +233,16 @@ discard block |
||
| 233 | 233 | } else { |
| 234 | 234 | //If it is an Array of form elements, it is likely the _id and _name relate field combo |
| 235 | 235 | $relateName = $this->getRelateFieldName($formElementNames); |
| 236 | - if(!empty($relateName)) { |
|
| 236 | + if (!empty($relateName)) { |
|
| 237 | 237 | $name = $relateName; |
| 238 | 238 | } else { |
| 239 | 239 | //One last attempt to scan $formElementNames for one vardef field only |
| 240 | 240 | $name = $this->findSingleVardefElement($formElementNames, $vardefs); |
| 241 | - if(empty($name)) { |
|
| 241 | + if (empty($name)) { |
|
| 242 | 242 | $fields = array(); |
| 243 | 243 | $name = $formElementNames[0]; |
| 244 | - foreach($formElementNames as $elementName) { |
|
| 245 | - if(isset($vardefs[$elementName])) { |
|
| 244 | + foreach ($formElementNames as $elementName) { |
|
| 245 | + if (isset($vardefs[$elementName])) { |
|
| 246 | 246 | $fields[] = $elementName; |
| 247 | 247 | } else { |
| 248 | 248 | $fields[] = $this->findAssignedVariableName($elementName, $filePath); |
@@ -254,13 +254,13 @@ discard block |
||
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | // Build the entry |
| 257 | - if(preg_match("/<textarea/si", $spanValue)) { |
|
| 257 | + if (preg_match("/<textarea/si", $spanValue)) { |
|
| 258 | 258 | //special case for textarea form elements (add the displayParams) |
| 259 | 259 | $displayParams = array(); |
| 260 | 260 | $displayParams['rows'] = $this->getTagAttribute("rows", $spanValue); |
| 261 | 261 | $displayParams['cols'] = $this->getTagAttribute("cols", $spanValue); |
| 262 | 262 | |
| 263 | - if(!empty($displayParams['rows']) && !empty($displayParams['cols'])) { |
|
| 263 | + if (!empty($displayParams['rows']) && !empty($displayParams['cols'])) { |
|
| 264 | 264 | $field = array(); |
| 265 | 265 | $field['name'] = $name; |
| 266 | 266 | $field['displayParams'] = $displayParams; |
@@ -269,13 +269,13 @@ discard block |
||
| 269 | 269 | } |
| 270 | 270 | } else { |
| 271 | 271 | |
| 272 | - if(isset($fields) || isset($customCode)) { |
|
| 272 | + if (isset($fields) || isset($customCode)) { |
|
| 273 | 273 | $field = array(); |
| 274 | 274 | $field['name'] = $name; |
| 275 | - if(isset($fields)) { |
|
| 275 | + if (isset($fields)) { |
|
| 276 | 276 | $field['fields'] = $fields; |
| 277 | 277 | } |
| 278 | - if(isset($customCode)) { |
|
| 278 | + if (isset($customCode)) { |
|
| 279 | 279 | $field['customCode'] = $customCode; |
| 280 | 280 | $field['description'] = 'This field was auto generated'; |
| 281 | 281 | } |
@@ -286,12 +286,12 @@ discard block |
||
| 286 | 286 | } //if-else if-else block |
| 287 | 287 | |
| 288 | 288 | $addedField = is_array($field) ? $field['name'] : $field; |
| 289 | - if(empty($addedField) || empty($addedElements[$addedField])) { |
|
| 289 | + if (empty($addedField) || empty($addedElements[$addedField])) { |
|
| 290 | 290 | //Add the meta-data definition for required fields |
| 291 | - if($hasRequiredLabel) { |
|
| 292 | - if(is_array($field)) { |
|
| 293 | - if(isset($field['displayParams']) && is_array($field['displayParams'])) { |
|
| 294 | - $field['displayParams']['required']=true; |
|
| 291 | + if ($hasRequiredLabel) { |
|
| 292 | + if (is_array($field)) { |
|
| 293 | + if (isset($field['displayParams']) && is_array($field['displayParams'])) { |
|
| 294 | + $field['displayParams']['required'] = true; |
|
| 295 | 295 | } else { |
| 296 | 296 | $field['displayParams'] = array('required'=>true); |
| 297 | 297 | } |
@@ -306,14 +306,14 @@ discard block |
||
| 306 | 306 | } //foreach |
| 307 | 307 | |
| 308 | 308 | // One last final check. If $emptyCount does not equal Array $col count, don't add |
| 309 | - if($emptyCount != count($col)) { |
|
| 309 | + if ($emptyCount != count($col)) { |
|
| 310 | 310 | |
| 311 | - if($hasRequiredLabel) { |
|
| 312 | - if(is_array($col)) { |
|
| 313 | - if(isset($col['displayParams'])) { |
|
| 314 | - $col['displayParams']['required']=true; |
|
| 311 | + if ($hasRequiredLabel) { |
|
| 312 | + if (is_array($col)) { |
|
| 313 | + if (isset($col['displayParams'])) { |
|
| 314 | + $col['displayParams']['required'] = true; |
|
| 315 | 315 | } else { |
| 316 | - $col['displayParams']=array('required'=>true); |
|
| 316 | + $col['displayParams'] = array('required'=>true); |
|
| 317 | 317 | } |
| 318 | 318 | } else { |
| 319 | 319 | $col = array('name'=>strtolower($col), 'displayParams'=>array('required'=>true)); |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | $panels = $this->applyPreRules($moduleDir, $panels); |
| 333 | 333 | |
| 334 | 334 | $templateMeta = array(); |
| 335 | - if($merge && !empty($masterCopy) && file_exists($masterCopy)) { |
|
| 335 | + if ($merge && !empty($masterCopy) && file_exists($masterCopy)) { |
|
| 336 | 336 | $panels = $this->mergePanels($panels, $vardefs, $moduleDir, $masterCopy); |
| 337 | 337 | $templateMeta = $this->mergeTemplateMeta($templateMeta, $moduleDir, $masterCopy); |
| 338 | 338 | } |
@@ -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. |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * @param $masterCopy The file path of the mater copy of the metadata file to merge against |
| 74 | 74 | * @return String format of metadata contents |
| 75 | 75 | **/ |
| 76 | -function parse($filePath, $vardefs = array(), $moduleDir = '', $merge=false, $masterCopy=null) { |
|
| 76 | +function parse($filePath, $vardefs = array(), $moduleDir = '', $merge = false, $masterCopy = null) { |
|
| 77 | 77 | |
| 78 | 78 | // Grab file contents |
| 79 | 79 | $contents = file_get_contents($filePath); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | |
| 86 | 86 | // Notes DetailView.html file is messed up |
| 87 | -if($moduleDir == 'Notes') { |
|
| 87 | +if ($moduleDir == 'Notes') { |
|
| 88 | 88 | $contents = str_replace('{PAGINATION}<tr><td>', '{PAGINATION}', $contents); |
| 89 | 89 | $contents = str_replace('</td></tr></table><script>', '</table><script>', $contents); |
| 90 | 90 | $contents = str_replace("<tr><div id='portal_flag_row' name='portal_flag_row' style='display:none'>", "<div id='portal_flag_row' name='portal_flag_row' style='display:none'>", $contents); |
@@ -102,39 +102,39 @@ discard block |
||
| 102 | 102 | $panels = array(); |
| 103 | 103 | $tableCount = 0; |
| 104 | 104 | $metarow = array(); |
| 105 | -foreach($tables as $table) { |
|
| 105 | +foreach ($tables as $table) { |
|
| 106 | 106 | |
| 107 | 107 | $table = $this->fixTablesWithMissingTr($table); |
| 108 | 108 | $tablerows = $this->getElementsByType("tr", $table); |
| 109 | 109 | |
| 110 | - foreach($tablerows as $trow) { |
|
| 110 | + foreach ($tablerows as $trow) { |
|
| 111 | 111 | |
| 112 | 112 | $metacolumns = array(); |
| 113 | 113 | $columns = $this->getElementsByType("td", $trow); |
| 114 | 114 | $columns = array_reverse($columns, true); |
| 115 | - foreach($columns as $tcols) { |
|
| 115 | + foreach ($columns as $tcols) { |
|
| 116 | 116 | |
| 117 | 117 | $sugarAttrValue = $this->getTagAttribute("sugar", $tcols, "'slot[0-9]+b$'"); |
| 118 | - if(empty($sugarAttrValue)) { |
|
| 118 | + if (empty($sugarAttrValue)) { |
|
| 119 | 119 | continue; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | $def = ''; |
| 123 | 123 | $field = $this->getElementValue("span", $tcols); |
| 124 | 124 | //If it's a space, simply add a blank string |
| 125 | - if($field == ' ') { |
|
| 125 | + if ($field == ' ') { |
|
| 126 | 126 | $metacolumns[] = ""; |
| 127 | - } else if(!empty($field)) { |
|
| 127 | + } else if (!empty($field)) { |
|
| 128 | 128 | |
| 129 | 129 | preg_match_all('/[\{]([^\}].*?)[\}]/s', $field, $matches, PREG_SET_ORDER); |
| 130 | - if(!empty($matches)) { |
|
| 131 | - if(count($matches) > 1) { |
|
| 130 | + if (!empty($matches)) { |
|
| 131 | + if (count($matches) > 1) { |
|
| 132 | 132 | |
| 133 | 133 | $def = array(); |
| 134 | 134 | |
| 135 | 135 | $def['name'] = preg_match('/_c$/i', $matches[0][1]) ? $matches[0][1] : strtolower($matches[0][1]); |
| 136 | - foreach($matches as $m) { |
|
| 137 | - if(isset($vardefs[strtolower($m[1])])) { |
|
| 136 | + foreach ($matches as $m) { |
|
| 137 | + if (isset($vardefs[strtolower($m[1])])) { |
|
| 138 | 138 | $def['name'] = strtolower($m[1]); |
| 139 | 139 | } |
| 140 | 140 | } |
@@ -142,16 +142,16 @@ discard block |
||
| 142 | 142 | $field = preg_replace('/<\{tag\.[a-z_]*?\}/i', '<a', $field); |
| 143 | 143 | $field = preg_replace('/<\/\{tag\.[a-z_]*?\}>/i', '</a>', $field); |
| 144 | 144 | |
| 145 | - foreach($matches as $tag[1]) { |
|
| 146 | - if(preg_match("/^(mod[\.]|app[\.]).*?/i", $tag[1][1])) { |
|
| 145 | + foreach ($matches as $tag[1]) { |
|
| 146 | + if (preg_match("/^(mod[\.]|app[\.]).*?/i", $tag[1][1])) { |
|
| 147 | 147 | $field = str_replace($tag[1][1], '$'.$tag[1][1], $field); |
| 148 | 148 | } else { |
| 149 | 149 | $theField = preg_match('/_c$/i', $tag[1][1]) ? $tag[1][1] : strtolower($tag[1][1]); |
| 150 | - if(!empty($vardefs[$theField])) { |
|
| 151 | - $field = str_replace($tag[1][1], '$fields.'. $theField.'.value', $field); |
|
| 150 | + if (!empty($vardefs[$theField])) { |
|
| 151 | + $field = str_replace($tag[1][1], '$fields.'.$theField.'.value', $field); |
|
| 152 | 152 | } else { |
| 153 | 153 | $phpName = $this->findAssignedVariableName($tag[1][1], $filePath); |
| 154 | - $field = str_replace($tag[1][1], '$fields.'. $theField.'.value', $field); |
|
| 154 | + $field = str_replace($tag[1][1], '$fields.'.$theField.'.value', $field); |
|
| 155 | 155 | } //if-else |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | $panels = $this->applyPreRules($moduleDir, $panels); |
| 181 | 181 | |
| 182 | 182 | $templateMeta = array(); |
| 183 | -if($merge && !empty($masterCopy) && file_exists($masterCopy)) { |
|
| 183 | +if ($merge && !empty($masterCopy) && file_exists($masterCopy)) { |
|
| 184 | 184 | $panels = $this->mergePanels($panels, $vardefs, $moduleDir, $masterCopy); |
| 185 | 185 | $templateMeta = $this->mergeTemplateMeta($templateMeta, $moduleDir, $masterCopy); |
| 186 | 186 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @param $mixed |
| 51 | 51 | * @return $obj A MetaDataBean instance |
| 52 | 52 | **/ |
| 53 | -function parse($filePath, $vardefs = array(), $moduleDir = '', $merge=false, $masterCopy=null) { |
|
| 53 | +function parse($filePath, $vardefs = array(), $moduleDir = '', $merge = false, $masterCopy = null) { |
|
| 54 | 54 | |
| 55 | 55 | $contents = file_get_contents($filePath); |
| 56 | 56 | $contents = $this->trimHTML($contents); |
@@ -60,16 +60,16 @@ discard block |
||
| 60 | 60 | //basic search table |
| 61 | 61 | $basicSection = $this->processSection("basic", $tables[0], $filePath, $vardefs); |
| 62 | 62 | $advancedSection = $this->processSection("advanced", $tables[1], $filePath, $vardefs); |
| 63 | - if(file_exists($masterCopy)) { |
|
| 63 | + if (file_exists($masterCopy)) { |
|
| 64 | 64 | require($masterCopy); |
| 65 | 65 | $layouts = $searchdefs[$moduleDir]['layout']; |
| 66 | 66 | |
| 67 | - if(isset($layouts['basic_search'])) { |
|
| 67 | + if (isset($layouts['basic_search'])) { |
|
| 68 | 68 | $basicSection = $this->mergeSection($basicSection, $layouts['basic_search']); |
| 69 | 69 | $basicSection = $this->applyRules($moduleDir, $basicSection); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if(isset($layouts['advanced_search'])) { |
|
| 72 | + if (isset($layouts['advanced_search'])) { |
|
| 73 | 73 | $advancedSection = $this->mergeSection($advancedSection, $layouts['advanced_search']); |
| 74 | 74 | $advancedSection = $this->applyRules($moduleDir, $advancedSection); |
| 75 | 75 | } |
@@ -80,15 +80,15 @@ discard block |
||
| 80 | 80 | 'templateMeta' => array('maxColumns' => '3', 'widths' => array('label' => '10', 'field' => '30')), |
| 81 | 81 | 'layout' => array( |
| 82 | 82 | \n\t'basic_search' =>"; |
| 83 | -$header .= "\t" . var_export($basicSection, true); |
|
| 83 | +$header .= "\t".var_export($basicSection, true); |
|
| 84 | 84 | $header .= "\n\t,'advanced_search' =>"; |
| 85 | -$header .= "\t" . var_export($advancedSection, true); |
|
| 85 | +$header .= "\t".var_export($advancedSection, true); |
|
| 86 | 86 | $header .= " |
| 87 | 87 | ),\n |
| 88 | 88 | ); |
| 89 | 89 | ?>"; |
| 90 | 90 | |
| 91 | -$header = preg_replace('/(\d+)[\s]=>[\s]?/',"",$header); |
|
| 91 | +$header = preg_replace('/(\d+)[\s]=>[\s]?/', "", $header); |
|
| 92 | 92 | return $header; |
| 93 | 93 | |
| 94 | 94 | } |
@@ -99,18 +99,18 @@ discard block |
||
| 99 | 99 | $existingElements = array(); |
| 100 | 100 | $existingLocation = array(); |
| 101 | 101 | |
| 102 | - foreach($section as $rowKey=>$row) { |
|
| 103 | - if(is_array($row) && !empty($row['name'])) { |
|
| 102 | + foreach ($section as $rowKey=>$row) { |
|
| 103 | + if (is_array($row) && !empty($row['name'])) { |
|
| 104 | 104 | $existingElements[$row['name']] = $row['name']; |
| 105 | 105 | $existingLocation[$row['name']] = array("row"=>$rowKey); |
| 106 | - } else if(!is_array($row) && !empty($row)) { |
|
| 106 | + } else if (!is_array($row) && !empty($row)) { |
|
| 107 | 107 | $existingElements[$row] = $row; |
| 108 | 108 | $existingLocation[$row] = array("row"=>$rowKey); |
| 109 | 109 | } |
| 110 | 110 | } //foreach |
| 111 | 111 | |
| 112 | 112 | // Now check against the $masterCopy |
| 113 | - foreach($masterSection as $row) { |
|
| 113 | + foreach ($masterSection as $row) { |
|
| 114 | 114 | |
| 115 | 115 | $addEntry = ''; |
| 116 | 116 | $id = is_array($row) ? $row['name'] : $row; |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | */ |
| 123 | 123 | |
| 124 | - if(isset($existingElements[$id])) { |
|
| 124 | + if (isset($existingElements[$id])) { |
|
| 125 | 125 | //Use master copy instead |
| 126 | 126 | $section[$existingLocation[$id]['row']] = $row; |
| 127 | 127 | } |
@@ -137,11 +137,11 @@ discard block |
||
| 137 | 137 | return $section; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | -function processSection($section, $table, $filePath, $vardefs=array()) { |
|
| 140 | +function processSection($section, $table, $filePath, $vardefs = array()) { |
|
| 141 | 141 | |
| 142 | 142 | $toptr = $this->getElementsByType("tr", $table); |
| 143 | 143 | |
| 144 | - if(!is_array($toptr) || empty($toptr)) { |
|
| 144 | + if (!is_array($toptr) || empty($toptr)) { |
|
| 145 | 145 | $GLOBALS['log']->error("Could not process top row (<tr>) for $section section"); |
| 146 | 146 | $GLOBALS['log']->error($table); |
| 147 | 147 | return array(); |
@@ -149,31 +149,31 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | $tabledata = $this->getElementsByType("table", $toptr[0]); |
| 151 | 151 | |
| 152 | - if(empty($tabledata)) { |
|
| 152 | + if (empty($tabledata)) { |
|
| 153 | 153 | $GLOBALS['log']->error("Error: HTML format for SearchForm.html not as expected, results may not be accurate"); |
| 154 | 154 | $GLOBALS['log']->error($toptr[0]); |
| 155 | 155 | $tabledata[0] = "<table>{$table}</table>"; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - if(is_array($tabledata) && !empty($tabledata[0])) { |
|
| 158 | + if (is_array($tabledata) && !empty($tabledata[0])) { |
|
| 159 | 159 | $rows = $this->getElementsByType("tr", $tabledata[0]); |
| 160 | 160 | } else { |
| 161 | 161 | $rows = $toptr[0]; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - if(!is_array($rows)) { |
|
| 164 | + if (!is_array($rows)) { |
|
| 165 | 165 | return array(); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | $metarow = array(); |
| 169 | - foreach($rows as $trow) { |
|
| 169 | + foreach ($rows as $trow) { |
|
| 170 | 170 | $tablecolumns = $this->getElementsByType("td", $trow); |
| 171 | 171 | |
| 172 | 172 | $emptyCount = 0; |
| 173 | 173 | $metacolumn = array(); |
| 174 | 174 | $col = null; |
| 175 | 175 | |
| 176 | - foreach($tablecolumns as $tcols) { |
|
| 176 | + foreach ($tablecolumns as $tcols) { |
|
| 177 | 177 | |
| 178 | 178 | $spanValue = strtolower($this->getElementValue("span", $tcols)); |
| 179 | 179 | $spanValue2 = strtolower($this->getElementValue("slot", $tcols)); |
@@ -189,27 +189,27 @@ discard block |
||
| 189 | 189 | $fields = null; |
| 190 | 190 | $customCode = null; |
| 191 | 191 | |
| 192 | - if(!empty($customField)) { |
|
| 192 | + if (!empty($customField)) { |
|
| 193 | 193 | // If it's a custom field we just set the name |
| 194 | 194 | $name = $customField; |
| 195 | - } else if(is_array($formElementNames) && count($formElementNames) == 1 |
|
| 195 | + } else if (is_array($formElementNames) && count($formElementNames) == 1 |
|
| 196 | 196 | && (isset($vardefs[$formElementNames[0]]) || $formElementNames[0] == 'current_user_only')) { |
| 197 | 197 | $name = $formElementNames[0]; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | //Skip and continue if $name is empty |
| 201 | - if(empty($name)) { |
|
| 201 | + if (empty($name)) { |
|
| 202 | 202 | continue; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | // Build the entry |
| 206 | - if(preg_match("/<textarea/si", $spanValue)) { |
|
| 206 | + if (preg_match("/<textarea/si", $spanValue)) { |
|
| 207 | 207 | //special case for textarea form elements (add the displayParams) |
| 208 | 208 | $displayParams = array(); |
| 209 | 209 | $displayParams['rows'] = $this->getTagAttribute("rows", $spanValue); |
| 210 | 210 | $displayParams['cols'] = $this->getTagAttribute("cols", $spanValue); |
| 211 | 211 | |
| 212 | - if(!empty($displayParams['rows']) && !empty($displayParams['cols'])) { |
|
| 212 | + if (!empty($displayParams['rows']) && !empty($displayParams['cols'])) { |
|
| 213 | 213 | $field = array(); |
| 214 | 214 | $field['name'] = $name; |
| 215 | 215 | $field['displayParams'] = $displayParams; |
@@ -221,14 +221,14 @@ discard block |
||
| 221 | 221 | |
| 222 | 222 | } else { |
| 223 | 223 | |
| 224 | - if(isset($fields)) { |
|
| 224 | + if (isset($fields)) { |
|
| 225 | 225 | $field = array(); |
| 226 | 226 | $field['name'] = $name; |
| 227 | - if(isset($fields)) { |
|
| 227 | + if (isset($fields)) { |
|
| 228 | 228 | $field['fields'] = $fields; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - if(!empty($customCode)) { |
|
| 231 | + if (!empty($customCode)) { |
|
| 232 | 232 | $field['customCode'] = $customCode; |
| 233 | 233 | } |
| 234 | 234 | |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | } //foreach |
| 243 | 243 | |
| 244 | 244 | // One last final check. If $emptyCount does not equal Array $col count, don't add |
| 245 | - if($emptyCount != count($col)) { |
|
| 245 | + if ($emptyCount != count($col)) { |
|
| 246 | 246 | //$metarow[] = $col; |
| 247 | 247 | } //if |
| 248 | 248 | |
@@ -251,17 +251,17 @@ discard block |
||
| 251 | 251 | return $metarow; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | -function applyRules($moduleDir, $section=array()) { |
|
| 254 | +function applyRules($moduleDir, $section = array()) { |
|
| 255 | 255 | require_once('include/SugarFields/Parsers/Rules/BaseRule.php'); |
| 256 | 256 | $baseRule = new BaseRule(); |
| 257 | - if(!is_array($section)) { |
|
| 257 | + if (!is_array($section)) { |
|
| 258 | 258 | $GLOBALS['log']->error("Error: SearchFormMetaParser->applyRules expects Array"); |
| 259 | 259 | return $section; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - foreach($section as $key=>$row) { |
|
| 262 | + foreach ($section as $key=>$row) { |
|
| 263 | 263 | //Override email1 fields |
| 264 | - if($baseRule->matches($row, '/^email1$/si')) { |
|
| 264 | + if ($baseRule->matches($row, '/^email1$/si')) { |
|
| 265 | 265 | $section[$key] = array('name' => 'email', 'label' =>'LBL_ANY_EMAIL', 'type' => 'name'); |
| 266 | 266 | } |
| 267 | 267 | } |
@@ -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); |
@@ -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); |