Test Failed
Push — CI ( 02428e...3e0292 )
by Adam
55:43
created
include/SugarFields/Parsers/EditViewMetaParser.php 3 patches
Indentation   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 class EditViewMetaParser extends MetaParser {
53 53
 
54 54
 function EditViewMetaParser() {
55
-   $this->mView = 'EditView';
55
+    $this->mView = 'EditView';
56 56
 }
57 57
 
58 58
 /**
@@ -67,277 +67,277 @@  discard block
 block discarded – undo
67 67
  **/
68 68
 function parse($filePath, $vardefs = array(), $moduleDir = '', $merge=false, $masterCopy=null) {
69 69
 
70
-   global $app_strings;
71
-   $contents = file_get_contents($filePath);
72
-   $contents = $this->trimHTML($contents);
73
-   $contents = $this->stripFlavorTags($contents);
74
-   $moduleName = '';
70
+    global $app_strings;
71
+    $contents = file_get_contents($filePath);
72
+    $contents = $this->trimHTML($contents);
73
+    $contents = $this->stripFlavorTags($contents);
74
+    $moduleName = '';
75 75
    
76
-   $contents = $this->fixDuplicateTrTags($contents);
77
-   $contents = $this->fixRowsWithMissingTr($contents);   
76
+    $contents = $this->fixDuplicateTrTags($contents);
77
+    $contents = $this->fixRowsWithMissingTr($contents);   
78 78
    
79
-   $tables = $this->getElementsByType("table", $contents);
80
-   $formElements = $this->getFormElements($tables[0]);
81
-   $hiddenInputs = array();
82
-   foreach($formElements as $elem) {
83
-   	      $type = $this->getTagAttribute("type", $elem);
84
-   	      if(preg_match('/hidden/si',$type)) {
85
-   	         $name = $this->getTagAttribute("name", $elem);
86
-   	         $value = $this->getTagAttribute("value", $elem);
87
-   	         $hiddenInputs[$name] = $value;
88
-   	      }
89
-   }
79
+    $tables = $this->getElementsByType("table", $contents);
80
+    $formElements = $this->getFormElements($tables[0]);
81
+    $hiddenInputs = array();
82
+    foreach($formElements as $elem) {
83
+                $type = $this->getTagAttribute("type", $elem);
84
+                if(preg_match('/hidden/si',$type)) {
85
+                $name = $this->getTagAttribute("name", $elem);
86
+                $value = $this->getTagAttribute("value", $elem);
87
+                $hiddenInputs[$name] = $value;
88
+                }
89
+    }
90 90
 
91
-   // Get the second table in the page and onward
92
-   $tables = array_slice($tables, 1);
93
-   $panels = array();
94
-   $tableCount = 0;
95
-   $addedElements = array();
96
-   $maxTableCountNum = 0;
97
-   $tableCount = 0;
98
-   foreach($tables as $table) {
99
-   	      $table = $this->fixTablesWithMissingTr($table);
100
-   	      $toptr = $this->getElementsByType("tr", $table);
101
-          foreach($toptr as $tr) {
102
-          	      $tabledata = $this->getElementsByType("table", $tr);
103
-          	      $data = array();
104
-          	      $panelKey = $tableCount == 0 ? "default" : '';
105
-          	      foreach($tabledata as $t) {
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)) {
108
-          	      	      	array_shift($vals);
109
-          	      	      	$panelKey = count($matches[0]) == 3 ? strtolower($matches[0][2]) : $panelKey;
110
-          	      	      }
91
+    // Get the second table in the page and onward
92
+    $tables = array_slice($tables, 1);
93
+    $panels = array();
94
+    $tableCount = 0;
95
+    $addedElements = array();
96
+    $maxTableCountNum = 0;
97
+    $tableCount = 0;
98
+    foreach($tables as $table) {
99
+                $table = $this->fixTablesWithMissingTr($table);
100
+                $toptr = $this->getElementsByType("tr", $table);
101
+            foreach($toptr as $tr) {
102
+                    $tabledata = $this->getElementsByType("table", $tr);
103
+                    $data = array();
104
+                    $panelKey = $tableCount == 0 ? "default" : '';
105
+                    foreach($tabledata as $t) {
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)) {
108
+                                    array_shift($vals);
109
+                                    $panelKey = count($matches[0]) == 3 ? strtolower($matches[0][2]) : $panelKey;
110
+                                }
111 111
           	      	      
112
-          	      	      //If $panelKey is empty use the maxTableCountNum value
113
-          	      	      if(empty($panelKey)) {
114
-          	      	      	$panels[$maxTableCountNum++] = $vals;
115
-          	      	      } else {
116
-          	      	        $panels[$panelKey] = $vals; 
117
-          	      	      }
118
-   	              } //foreach    
119
-                  $tableCount++;
120
-          } //foreach;
121
-   } //foreach
112
+                                //If $panelKey is empty use the maxTableCountNum value
113
+                                if(empty($panelKey)) {
114
+                                    $panels[$maxTableCountNum++] = $vals;
115
+                                } else {
116
+                                $panels[$panelKey] = $vals; 
117
+                                }
118
+                        } //foreach    
119
+                    $tableCount++;
120
+            } //foreach;
121
+    } //foreach
122 122
    
123
-   foreach($panels as $id=>$tablerows) {
123
+    foreach($panels as $id=>$tablerows) {
124 124
    	
125
-       $metarow = array();
125
+        $metarow = array();
126 126
        	       
127
-	   foreach($tablerows as $trow) {
127
+        foreach($tablerows as $trow) {
128 128
 	   	
129
-	   	   $emptyCount = 0;
130
-	   	   $tablecolumns = $this->getElementsByType("td", $trow);
131
-	       $col = array();
132
-	       $slot = 0;
129
+                $emptyCount = 0;
130
+                $tablecolumns = $this->getElementsByType("td", $trow);
131
+            $col = array();
132
+            $slot = 0;
133 133
 	       
134
-		   foreach($tablecolumns as $tcols) {
135
-		   	  $hasRequiredLabel = false;
134
+            foreach($tablecolumns as $tcols) {
135
+                    $hasRequiredLabel = false;
136 136
 		   	  
137
-		   	  //Get the sugar attribute value in the span elements of each table row
138
-		   	  $sugarAttrLabel = $this->getTagAttribute("sugar", $tcols, "'^slot[^b]+$'");
137
+                    //Get the sugar attribute value in the span elements of each table row
138
+                    $sugarAttrLabel = $this->getTagAttribute("sugar", $tcols, "'^slot[^b]+$'");
139 139
 		   	  
140
-		   	  //If there was no sugar attribute, try id (some versions of EditView.html used this instead)
141
-		   	  if(empty($sugarAttrLabel)) {
142
-		   	     $sugarAttrLabel = $this->getTagAttribute("id", $tcols, "'^slot[^b]+$'");	
143
-		   	  }
140
+                    //If there was no sugar attribute, try id (some versions of EditView.html used this instead)
141
+                    if(empty($sugarAttrLabel)) {
142
+                    $sugarAttrLabel = $this->getTagAttribute("id", $tcols, "'^slot[^b]+$'");	
143
+                    }
144 144
 		   	  
145
-		   	  //Check if this field is required
146
-		   	  if(!empty($sugarAttrLabel)) {
147
-		   	  	 $hasRequiredLabel = $this->hasRequiredSpanLabel($tcols);
148
-		   	  }
145
+                    //Check if this field is required
146
+                    if(!empty($sugarAttrLabel)) {
147
+                        $hasRequiredLabel = $this->hasRequiredSpanLabel($tcols);
148
+                    }
149 149
 		   	  
150
-		   	  $sugarAttrValue = $this->getTagAttribute("sugar", $tcols, "'slot[0-9]+b$'");
150
+                    $sugarAttrValue = $this->getTagAttribute("sugar", $tcols, "'slot[0-9]+b$'");
151 151
               
152
-		   	  //If there was no sugar attribute, try id (some versions of EditView.html used this instead)
153
-              if(empty($sugarAttrValue)) {
154
-              	 $sugarAttrValue = $this->getTagAttribute("id", $tcols, "'slot[0-9]+b$'");
155
-              }
152
+                    //If there was no sugar attribute, try id (some versions of EditView.html used this instead)
153
+                if(empty($sugarAttrValue)) {
154
+                    $sugarAttrValue = $this->getTagAttribute("id", $tcols, "'slot[0-9]+b$'");
155
+                }
156 156
               
157
-              // If there wasn't any slot numbering/lettering then just default to expect label->vallue pairs
158
-	          $sugarAttrLabel = count($sugarAttrLabel) != 0 ? $sugarAttrLabel : ($slot % 2 == 0) ? true : false;
159
-	          $sugarAttrValue = count($sugarAttrValue) != 0 ? $sugarAttrValue : ($slot % 2 == 1) ? true : false;
160
-	          $slot++;
157
+                // If there wasn't any slot numbering/lettering then just default to expect label->vallue pairs
158
+                $sugarAttrLabel = count($sugarAttrLabel) != 0 ? $sugarAttrLabel : ($slot % 2 == 0) ? true : false;
159
+                $sugarAttrValue = count($sugarAttrValue) != 0 ? $sugarAttrValue : ($slot % 2 == 1) ? true : false;
160
+                $slot++;
161 161
 	          
162
-              if($sugarAttrValue) {
162
+                if($sugarAttrValue) {
163 163
 		   	     	 
164
-				   	  	 $spanValue = $this->getElementValue("span", $tcols);
164
+                                $spanValue = $this->getElementValue("span", $tcols);
165 165
 		                 
166
-				   	  	 if(empty($spanValue)) {
167
-		                    $spanValue = $this->getElementValue("slot", $tcols);	
168
-		                 }
166
+                                if(empty($spanValue)) {
167
+                            $spanValue = $this->getElementValue("slot", $tcols);	
168
+                            }
169 169
 		                 
170
-		                 if(empty($spanValue)) {
171
-		                    $spanValue = $this->getElementValue("td", $tcols);
172
-		                 }
170
+                            if(empty($spanValue)) {
171
+                            $spanValue = $this->getElementValue("td", $tcols);
172
+                            }
173 173
 		                 
174
-		                 //Get all the editable form elements' names
175
-				   	  	 $formElementNames = $this->getFormElementsNames($spanValue);		   	  	 
176
-				   	  	 $customField = $this->getCustomField($formElementNames);
174
+                            //Get all the editable form elements' names
175
+                                $formElementNames = $this->getFormElementsNames($spanValue);		   	  	 
176
+                                $customField = $this->getCustomField($formElementNames);
177 177
 				   	  	 
178
-				   	  	 $name = '';
179
-		                 $fields = null;
180
-		                 $customCode = null;
178
+                                $name = '';
179
+                            $fields = null;
180
+                            $customCode = null;
181 181
 
182
-		                 if(!empty($customField)) {           
183
-		                   // If it's a custom field we just set the name
184
-		                   $name = $customField;
182
+                            if(!empty($customField)) {           
183
+                            // If it's a custom field we just set the name
184
+                            $name = $customField;
185 185
 		                         
186
-		                 } else if(empty($formElementNames) && preg_match_all('/[\{]([^\}]*?)[\}]/s', $spanValue, $matches, PREG_SET_ORDER)) {
187
-				   	  	   // We are here if the $spanValue did not contain a form element for editing.
188
-				   	  	   // We will assume that it is read only (since there were no edit form elements)
186
+                            } else if(empty($formElementNames) && preg_match_all('/[\{]([^\}]*?)[\}]/s', $spanValue, $matches, PREG_SET_ORDER)) {
187
+                                // We are here if the $spanValue did not contain a form element for editing.
188
+                                // We will assume that it is read only (since there were no edit form elements)
189 189
 				   	  	   
190 190
 		
191
-					           // If there is more than one matching {} value then try to find the right one to key off
192
-					           // based on vardefs.php file.  Also, use the entire spanValue as customCode
193
-					           	if(count($matches) > 1) {
194
-							       $name = $matches[0][1];  
195
-							       $customCode = $spanValue;
196
-							       foreach($matches as $pair) {
197
-						   	  	 	   if(preg_match("/^(mod[\.]|app[\.]).*?/i", $pair[1])) {
198
-						   	  	 	       $customCode = str_replace($pair[1], '$'.strtoupper($pair[1]), $customCode);      
199
-						   	  	 	   } else {
200
-						   	  	 	       if(!empty($vardefs[$pair[1]])) {
201
-						   	  	 	       	  $name = $pair[1];
202
-						   	  	 	          $customCode = str_replace($pair[1], '$fields.'.strtolower($pair[1]).'.value', $customCode);
203
-						   	  	 	       } else {
204
-						   	  	 	       	  $phpName = $this->findAssignedVariableName($pair[1], $filePath);
205
-						   	  	 	       	  $customCode = str_replace($pair[1], '$fields.'.strtolower($phpName).'.value', $customCode);
206
-						   	  	 	       } //if-else
207
-						   	  	 	   }
208
-						           } //foreach
209
-						       } else {
210
-						       	   //If it is only a label, skip
211
-						       	   if(preg_match("/^(mod[\.]|app[\.]).*?/i", $matches[0][1])) {
212
-						       	   	  continue;
213
-						       	   }
214
-						   	  	   $name = strtolower($matches[0][1]);    
215
-						   	   }
191
+                                // If there is more than one matching {} value then try to find the right one to key off
192
+                                // based on vardefs.php file.  Also, use the entire spanValue as customCode
193
+                                    if(count($matches) > 1) {
194
+                                    $name = $matches[0][1];  
195
+                                    $customCode = $spanValue;
196
+                                    foreach($matches as $pair) {
197
+                                                if(preg_match("/^(mod[\.]|app[\.]).*?/i", $pair[1])) {
198
+                                                    $customCode = str_replace($pair[1], '$'.strtoupper($pair[1]), $customCode);      
199
+                                                } else {
200
+                                                    if(!empty($vardefs[$pair[1]])) {
201
+                                                        $name = $pair[1];
202
+                                                    $customCode = str_replace($pair[1], '$fields.'.strtolower($pair[1]).'.value', $customCode);
203
+                                                    } else {
204
+                                                        $phpName = $this->findAssignedVariableName($pair[1], $filePath);
205
+                                                        $customCode = str_replace($pair[1], '$fields.'.strtolower($phpName).'.value', $customCode);
206
+                                                    } //if-else
207
+                                                }
208
+                                    } //foreach
209
+                                } else {
210
+                                        //If it is only a label, skip
211
+                                        if(preg_match("/^(mod[\.]|app[\.]).*?/i", $matches[0][1])) {
212
+                                            continue;
213
+                                        }
214
+                                        $name = strtolower($matches[0][1]);    
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]])) {
222
-				   	  	            $name = $formElementNames[0];
223
-				   	  	      	 } else {
224
-				   	  	      	 	// Try to use the EdtiView.php file to find author's intent
225
-				   	  	      	 	$name = $this->findAssignedVariableName($formElementNames[0], $filePath);
221
+                                        if(!empty($vardefs[$formElementNames[0]])) {
222
+                                            $name = $formElementNames[0];
223
+                                        } else {
224
+                                            // Try to use the EdtiView.php file to find author's intent
225
+                                            $name = $this->findAssignedVariableName($formElementNames[0], $filePath);
226 226
 		
227
-				   	  	      	 	//If it's still empty, just use the entire block as customCode
228
-				   	  	      	 	if(empty($vardefs[$name])) {
229
-				   	  	      	 	   //Replace any { characters just in case   
230
-				   	  	      	 	   $customCode = str_replace('{', '{$', $spanValue);
231
-				   	  	      	 	}
232
-				   	  	      	 } //if-else
233
-				   	  	      } else {
234
-				   	  	      	 //If it is an Array of form elements, it is likely the _id and _name relate field combo
235
-		                         $relateName = $this->getRelateFieldName($formElementNames);
236
-		                         if(!empty($relateName)) {
237
-		                            $name = $relateName;
238
-		                         } else {
239
-		                         	 //One last attempt to scan $formElementNames for one vardef field only
240
-		                         	 $name = $this->findSingleVardefElement($formElementNames, $vardefs);
241
-		                         	 if(empty($name)) {
242
-					   	  	      	 	 $fields = array();
243
-			                         	 $name = $formElementNames[0];
244
-						   	  	      	 foreach($formElementNames as $elementName) {
245
-						   	  	      	 	if(isset($vardefs[$elementName])) {
246
-						   	  	      	 	   $fields[] = $elementName;
247
-						   	  	      	 	} else {
248
-						   	  	      	 	   $fields[] = $this->findAssignedVariableName($elementName, $filePath);
249
-						   	  	      	 	} //if-else
250
-					   	  	      	 	} //foreach
251
-		                         	} //if
252
-		                         } //if-else
253
-				   	  	      } //if-else
254
-				   	  	 }
227
+                                            //If it's still empty, just use the entire block as customCode
228
+                                            if(empty($vardefs[$name])) {
229
+                                                //Replace any { characters just in case   
230
+                                                $customCode = str_replace('{', '{$', $spanValue);
231
+                                            }
232
+                                        } //if-else
233
+                                    } else {
234
+                                        //If it is an Array of form elements, it is likely the _id and _name relate field combo
235
+                                    $relateName = $this->getRelateFieldName($formElementNames);
236
+                                    if(!empty($relateName)) {
237
+                                    $name = $relateName;
238
+                                    } else {
239
+                                        //One last attempt to scan $formElementNames for one vardef field only
240
+                                        $name = $this->findSingleVardefElement($formElementNames, $vardefs);
241
+                                        if(empty($name)) {
242
+                                                    $fields = array();
243
+                                            $name = $formElementNames[0];
244
+                                                foreach($formElementNames as $elementName) {
245
+                                                    if(isset($vardefs[$elementName])) {
246
+                                                        $fields[] = $elementName;
247
+                                                    } else {
248
+                                                        $fields[] = $this->findAssignedVariableName($elementName, $filePath);
249
+                                                    } //if-else
250
+                                                } //foreach
251
+                                        } //if
252
+                                    } //if-else
253
+                                    } //if-else
254
+                                }
255 255
 				   	  	 
256
-				   	  	 // Build the entry
257
-				   	  	 if(preg_match("/<textarea/si", $spanValue)) {
258
-				   	  	 	//special case for textarea form elements (add the displayParams)
259
-				   	  	 	$displayParams = array();
260
-				   	  	    $displayParams['rows'] = $this->getTagAttribute("rows", $spanValue);
261
-				   	  	    $displayParams['cols'] = $this->getTagAttribute("cols", $spanValue);
256
+                                // Build the entry
257
+                                if(preg_match("/<textarea/si", $spanValue)) {
258
+                                    //special case for textarea form elements (add the displayParams)
259
+                                    $displayParams = array();
260
+                                    $displayParams['rows'] = $this->getTagAttribute("rows", $spanValue);
261
+                                    $displayParams['cols'] = $this->getTagAttribute("cols", $spanValue);
262 262
 		
263
-				   	  	    if(!empty($displayParams['rows']) && !empty($displayParams['cols'])) {
264
-					   	  	    $field = array();
265
-					   	  	    $field['name'] = $name;
266
-								$field['displayParams'] = $displayParams;
267
-				   	  	    } else {
268
-				   	  	        $field = $name;	
269
-				   	  	    }
270
-				   	  	 } else {
263
+                                    if(!empty($displayParams['rows']) && !empty($displayParams['cols'])) {
264
+                                        $field = array();
265
+                                        $field['name'] = $name;
266
+                                $field['displayParams'] = $displayParams;
267
+                                    } else {
268
+                                        $field = $name;	
269
+                                    }
270
+                                } else {
271 271
 		
272
-				   	  	 	if(isset($fields) || isset($customCode)) {
273
-				   	  	 	   $field = array();
274
-				   	  	 	   $field['name'] = $name;
275
-				   	  	 	   if(isset($fields)) {
276
-				   	  	 	   	  $field['fields'] = $fields;
277
-				   	  	 	   }
278
-				   	  	 	   if(isset($customCode)) {
279
-				   	  	 	   	  $field['customCode'] = $customCode;
280
-				   	  	 	   	  $field['description'] = 'This field was auto generated';
281
-				   	  	 	   }
282
-				   	  	 	} else {
283
-				   	  	 	   $emptyCount = $name == '' ? $emptyCount + 1 : $emptyCount;
284
-				   	  	 	   $field = $name;
285
-				   	  	 	}	
286
-				   	  	 } //if-else if-else block
272
+                                    if(isset($fields) || isset($customCode)) {
273
+                                        $field = array();
274
+                                        $field['name'] = $name;
275
+                                        if(isset($fields)) {
276
+                                            $field['fields'] = $fields;
277
+                                        }
278
+                                        if(isset($customCode)) {
279
+                                            $field['customCode'] = $customCode;
280
+                                            $field['description'] = 'This field was auto generated';
281
+                                        }
282
+                                    } else {
283
+                                        $emptyCount = $name == '' ? $emptyCount + 1 : $emptyCount;
284
+                                        $field = $name;
285
+                                    }	
286
+                                } //if-else if-else block
287 287
 				   	  	 
288
-				   	  	 $addedField = is_array($field) ? $field['name'] : $field;
289
-				   	  	 if(empty($addedField) || empty($addedElements[$addedField])) {
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;
295
-				   	  	 	   	  } else {
296
-				   	  	 	   	     $field['displayParams'] = array('required'=>true);
297
-				   	  	 	   	  }
298
-				   	  	 	   } else {
299
-				   	  	 	   	  $field = array('name'=>strtolower($field), 'displayParams'=>array('required'=>true));
300
-				   	  	 	   }
301
-				   	  	 	}
302
-				   	  	  	$col[] = is_array($field) ? $field : strtolower($field);
303
-				   	  	  	$addedElements[$addedField] = $addedField;
304
-				   	  	 }
305
-		   	  } //if($sugarAttValue)
306
-		   } //foreach
288
+                                $addedField = is_array($field) ? $field['name'] : $field;
289
+                                if(empty($addedField) || empty($addedElements[$addedField])) {
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;
295
+                                            } else {
296
+                                                $field['displayParams'] = array('required'=>true);
297
+                                            }
298
+                                        } else {
299
+                                            $field = array('name'=>strtolower($field), 'displayParams'=>array('required'=>true));
300
+                                        }
301
+                                    }
302
+                                    $col[] = is_array($field) ? $field : strtolower($field);
303
+                                    $addedElements[$addedField] = $addedField;
304
+                                }
305
+                    } //if($sugarAttValue)
306
+            } //foreach
307 307
 		   
308
-		   // One last final check.  If $emptyCount does not equal Array $col count, don't add 
309
-		   if($emptyCount != count($col)) {
308
+            // One last final check.  If $emptyCount does not equal Array $col count, don't add 
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;
315
-			   	  	    } else {
316
-			   	  	       $col['displayParams']=array('required'=>true);
317
-			   	  	    }
318
-			   	  	 } else {
319
-			   	  	    $col = array('name'=>strtolower($col), 'displayParams'=>array('required'=>true));	
320
-			   	  	 }
321
-			   	  }
311
+                        if($hasRequiredLabel) {
312
+                            if(is_array($col)) {
313
+                                if(isset($col['displayParams'])) {
314
+                                $col['displayParams']['required']=true;
315
+                                } else {
316
+                                $col['displayParams']=array('required'=>true);
317
+                                }
318
+                            } else {
319
+                                $col = array('name'=>strtolower($col), 'displayParams'=>array('required'=>true));	
320
+                            }
321
+                        }
322 322
 
323
-	   	      $metarow[] = $col;
324
-		   } //if
325
-	   } //foreach
323
+                    $metarow[] = $col;
324
+            } //if
325
+        } //foreach
326 326
 	  
327
-	   $panels[$id] = $metarow;
327
+        $panels[$id] = $metarow;
328 328
 	  
329
-   } //foreach
329
+    } //foreach
330 330
 
331
-   $this->mCustomPanels = $panels; 
332
-   $panels = $this->applyPreRules($moduleDir, $panels);
331
+    $this->mCustomPanels = $panels; 
332
+    $panels = $this->applyPreRules($moduleDir, $panels);
333 333
    
334
-   $templateMeta = array();
335
-   if($merge && !empty($masterCopy) && file_exists($masterCopy)) {
336
-      $panels = $this->mergePanels($panels, $vardefs, $moduleDir, $masterCopy);
337
-      $templateMeta = $this->mergeTemplateMeta($templateMeta, $moduleDir, $masterCopy);
338
-   }
339
-   $panels = $this->applyRules($moduleDir, $panels);
340
-   return $this->createFileContents($moduleDir, $panels, $templateMeta, $filePath);
334
+    $templateMeta = array();
335
+    if($merge && !empty($masterCopy) && file_exists($masterCopy)) {
336
+        $panels = $this->mergePanels($panels, $vardefs, $moduleDir, $masterCopy);
337
+        $templateMeta = $this->mergeTemplateMeta($templateMeta, $moduleDir, $masterCopy);
338
+    }
339
+    $panels = $this->applyRules($moduleDir, $panels);
340
+    return $this->createFileContents($moduleDir, $panels, $templateMeta, $filePath);
341 341
 }
342 342
 
343 343
 
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
    }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
Please login to merge, or discard this patch.
include/SugarFields/Parsers/DetailViewMetaParser.php 4 patches
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 class DetailViewMetaParser extends MetaParser {
60 60
 
61 61
 function DetailViewMetaParser() {
62
-   $this->mView = 'DetailView';
62
+    $this->mView = 'DetailView';
63 63
 }
64 64
 
65 65
 
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 
86 86
 // Notes DetailView.html file is messed up
87 87
 if($moduleDir == 'Notes') {
88
-   $contents = str_replace('{PAGINATION}<tr><td>', '{PAGINATION}', $contents); 
89
-   $contents = str_replace('</td></tr></table><script>', '</table><script>', $contents);
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); 
88
+    $contents = str_replace('{PAGINATION}<tr><td>', '{PAGINATION}', $contents); 
89
+    $contents = str_replace('</td></tr></table><script>', '</table><script>', $contents);
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); 
91 91
 }
92 92
 
93 93
 $contents = $this->fixDuplicateTrTags($contents);
@@ -104,75 +104,75 @@  discard block
 block discarded – undo
104 104
 $metarow = array();
105 105
 foreach($tables as $table) {   
106 106
    
107
-   $table = $this->fixTablesWithMissingTr($table);
108
-   $tablerows = $this->getElementsByType("tr", $table);
107
+    $table = $this->fixTablesWithMissingTr($table);
108
+    $tablerows = $this->getElementsByType("tr", $table);
109 109
 
110
-   foreach($tablerows as $trow) {
110
+    foreach($tablerows as $trow) {
111 111
 
112
-       $metacolumns = array();  
113
-   	   $columns = $this->getElementsByType("td", $trow);
114
-       $columns = array_reverse($columns, true);
115
-	   foreach($columns as $tcols) {
112
+        $metacolumns = array();  
113
+            $columns = $this->getElementsByType("td", $trow);
114
+        $columns = array_reverse($columns, true);
115
+        foreach($columns as $tcols) {
116 116
 
117
-	   	  $sugarAttrValue = $this->getTagAttribute("sugar", $tcols, "'slot[0-9]+b$'");
118
-	   	  if(empty($sugarAttrValue)) {
119
-	   	  	 continue;
120
-	   	  }	   	
117
+                $sugarAttrValue = $this->getTagAttribute("sugar", $tcols, "'slot[0-9]+b$'");
118
+                if(empty($sugarAttrValue)) {
119
+                    continue;
120
+                }	   	
121 121
 	   	
122
-          $def = '';
123
-	   	  $field = $this->getElementValue("span", $tcols);
124
-	   	  //If it's a space, simply add a blank string	   	  
125
-	   	  if($field == '&nbsp;') {
126
-	   	  	 $metacolumns[] = "";
127
-	   	  } else if(!empty($field)) {
122
+            $def = '';
123
+                $field = $this->getElementValue("span", $tcols);
124
+                //If it's a space, simply add a blank string	   	  
125
+                if($field == '&nbsp;') {
126
+                    $metacolumns[] = "";
127
+                } else if(!empty($field)) {
128 128
 	   	  	
129
-          	 preg_match_all('/[\{]([^\}].*?)[\}]/s', $field, $matches, PREG_SET_ORDER);
130
-          	 if(!empty($matches)) { 	
131
-          	 	if(count($matches) > 1) {
129
+                preg_match_all('/[\{]([^\}].*?)[\}]/s', $field, $matches, PREG_SET_ORDER);
130
+                if(!empty($matches)) { 	
131
+                    if(count($matches) > 1) {
132 132
           	 		  
133
-	          	 	  $def = array();
134
-
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])])) {
138
-                      	 	$def['name'] = strtolower($m[1]);
139
-                      	 }
140
-                      }
141
-
142
-	          	 	  $field = preg_replace('/<\{tag\.[a-z_]*?\}/i', '<a', $field);
143
-	          	 	  $field = preg_replace('/<\/\{tag\.[a-z_]*?\}>/i', '</a>', $field);
144
-
145
-	          	 	  foreach($matches as $tag[1]) {
146
-		   	  	 	    if(preg_match("/^(mod[\.]|app[\.]).*?/i", $tag[1][1])) {
147
-		   	  	 	       $field = str_replace($tag[1][1], '$'.$tag[1][1], $field);      
148
-		   	  	 	    } else {
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);
152
-		   	  	 	       } else {
153
-		   	  	 	       	  $phpName = $this->findAssignedVariableName($tag[1][1], $filePath);
154
-		   	  	 	       	  $field = str_replace($tag[1][1], '$fields.'. $theField.'.value', $field);
155
-		   	  	 	       } //if-else
156
-		   	  	 	    }
157
-		   	  	 	  }
158
-
159
-		   	  	 	  $def['customCode'] = $field;
160
-		   	  	 	  $def['description'] = 'This field was auto generated';
161
-          	 	} else {
162
-	          	 	  $def = strtolower($matches[0][1]);
163
-          	 	}
164
-          	 } //if
165
-             $metacolumns[] = $def;
166
-          } //if
167
-	   } //foreach($tablecolumns as $tcols)
168
-
169
-   	   $metarow[] = array_reverse($metacolumns);
170
-   } //foreach($tablerows as $trow) 
133
+                            $def = array();
134
+
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])])) {
138
+                                $def['name'] = strtolower($m[1]);
139
+                            }
140
+                        }
141
+
142
+                            $field = preg_replace('/<\{tag\.[a-z_]*?\}/i', '<a', $field);
143
+                            $field = preg_replace('/<\/\{tag\.[a-z_]*?\}>/i', '</a>', $field);
144
+
145
+                            foreach($matches as $tag[1]) {
146
+                                if(preg_match("/^(mod[\.]|app[\.]).*?/i", $tag[1][1])) {
147
+                                    $field = str_replace($tag[1][1], '$'.$tag[1][1], $field);      
148
+                                } else {
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);
152
+                                    } else {
153
+                                        $phpName = $this->findAssignedVariableName($tag[1][1], $filePath);
154
+                                        $field = str_replace($tag[1][1], '$fields.'. $theField.'.value', $field);
155
+                                    } //if-else
156
+                                }
157
+                            }
158
+
159
+                            $def['customCode'] = $field;
160
+                            $def['description'] = 'This field was auto generated';
161
+                    } else {
162
+                            $def = strtolower($matches[0][1]);
163
+                    }
164
+                } //if
165
+                $metacolumns[] = $def;
166
+            } //if
167
+        } //foreach($tablecolumns as $tcols)
168
+
169
+            $metarow[] = array_reverse($metacolumns);
170
+    } //foreach($tablerows as $trow) 
171 171
    
172 172
    
173
-   $id = $tableCount == 0 ? 'default' : $tableCount;
174
-   $tableCount++;
175
-   $panels[$id] = $metarow;
173
+    $id = $tableCount == 0 ? 'default' : $tableCount;
174
+    $tableCount++;
175
+    $panels[$id] = $metarow;
176 176
    
177 177
 } //foreach($tables as $table)
178 178
 
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 
182 182
 $templateMeta = array();
183 183
 if($merge && !empty($masterCopy) && file_exists($masterCopy)) {
184
-   $panels = $this->mergePanels($panels, $vardefs, $moduleDir, $masterCopy);
185
-   $templateMeta = $this->mergeTemplateMeta($templateMeta, $moduleDir, $masterCopy);
184
+    $panels = $this->mergePanels($panels, $vardefs, $moduleDir, $masterCopy);
185
+    $templateMeta = $this->mergeTemplateMeta($templateMeta, $moduleDir, $masterCopy);
186 186
 }
187 187
 
188 188
 $panels = $this->applyRules($moduleDir, $panels);
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 == '&nbsp;') {
125
+	   	  if ($field == '&nbsp;') {
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
 /**
67 67
  * parse
68 68
  * 
69
- * @param $filePath The file path of the HTML file to parse
69
+ * @param string $filePath The file path of the HTML file to parse
70 70
  * @param $vardefs The module's vardefs
71 71
  * @param $moduleDir The module's directory
72 72
  * @param $merge boolean value indicating whether or not to merge the parsed contents
Please login to merge, or discard this patch.
include/SugarFields/Parsers/SearchFormMetaParser.php 3 patches
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 class SearchFormMetaParser extends MetaParser {
43 43
 
44 44
 function SearchFormMetaParser() {
45
-	$this->mView = 'Search';
45
+    $this->mView = 'Search';
46 46
 }
47 47
 
48 48
 /**
@@ -52,28 +52,28 @@  discard block
 block discarded – undo
52 52
  **/
53 53
 function parse($filePath, $vardefs = array(), $moduleDir = '', $merge=false, $masterCopy=null) {
54 54
 
55
-   $contents = file_get_contents($filePath);
56
-   $contents = $this->trimHTML($contents);
55
+    $contents = file_get_contents($filePath);
56
+    $contents = $this->trimHTML($contents);
57 57
    
58
-   // Get the second table in the page and onward
59
-   $tables = $this->getElementsByType("table", $contents);
60
-   //basic search table
61
-   $basicSection = $this->processSection("basic", $tables[0], $filePath, $vardefs);
62
-   $advancedSection = $this->processSection("advanced", $tables[1], $filePath, $vardefs);
63
-   if(file_exists($masterCopy)) {
64
-	   require($masterCopy);
65
-	   $layouts = $searchdefs[$moduleDir]['layout'];
58
+    // Get the second table in the page and onward
59
+    $tables = $this->getElementsByType("table", $contents);
60
+    //basic search table
61
+    $basicSection = $this->processSection("basic", $tables[0], $filePath, $vardefs);
62
+    $advancedSection = $this->processSection("advanced", $tables[1], $filePath, $vardefs);
63
+    if(file_exists($masterCopy)) {
64
+        require($masterCopy);
65
+        $layouts = $searchdefs[$moduleDir]['layout'];
66 66
 	
67
-	   if(isset($layouts['basic_search'])) {
68
-		  $basicSection = $this->mergeSection($basicSection, $layouts['basic_search']);
69
-	      $basicSection = $this->applyRules($moduleDir, $basicSection);
70
-	   }
67
+        if(isset($layouts['basic_search'])) {
68
+            $basicSection = $this->mergeSection($basicSection, $layouts['basic_search']);
69
+            $basicSection = $this->applyRules($moduleDir, $basicSection);
70
+        }
71 71
 	
72
-	   if(isset($layouts['advanced_search'])) {
73
-		  $advancedSection = $this->mergeSection($advancedSection, $layouts['advanced_search']);
74
-	      $advancedSection = $this->applyRules($moduleDir, $advancedSection);
75
-	   }
76
-   } //if
72
+        if(isset($layouts['advanced_search'])) {
73
+            $advancedSection = $this->mergeSection($advancedSection, $layouts['advanced_search']);
74
+            $advancedSection = $this->applyRules($moduleDir, $advancedSection);
75
+        }
76
+    } //if
77 77
 
78 78
 $header = "<?php\n\n";
79 79
 $header .= "\$searchdefs['$moduleDir'] = array(
@@ -95,177 +95,177 @@  discard block
 block discarded – undo
95 95
 
96 96
 function mergeSection($section, $masterSection) {
97 97
 
98
-  // Get all the names in the panel
99
-  $existingElements = array();
100
-  $existingLocation = array();
98
+    // Get all the names in the panel
99
+    $existingElements = array();
100
+    $existingLocation = array();
101 101
   
102
-  foreach($section as $rowKey=>$row) {
103
-  	   if(is_array($row) && !empty($row['name'])) {
104
-  	 	   $existingElements[$row['name']] = $row['name'];
105
-  	 	   $existingLocation[$row['name']] = array("row"=>$rowKey);	
106
-  	   } else if(!is_array($row) && !empty($row)) {
107
-	 	   $existingElements[$row] = $row;
108
-	 	   $existingLocation[$row] = array("row"=>$rowKey);
109
-  	   }
110
-  } //foreach
102
+    foreach($section as $rowKey=>$row) {
103
+            if(is_array($row) && !empty($row['name'])) {
104
+                $existingElements[$row['name']] = $row['name'];
105
+                $existingLocation[$row['name']] = array("row"=>$rowKey);	
106
+            } else if(!is_array($row) && !empty($row)) {
107
+            $existingElements[$row] = $row;
108
+            $existingLocation[$row] = array("row"=>$rowKey);
109
+            }
110
+    } //foreach
111 111
   
112
-  // Now check against the $masterCopy
113
-  foreach($masterSection as $row) {
112
+    // Now check against the $masterCopy
113
+    foreach($masterSection as $row) {
114 114
   	
115
-  	 $addEntry = '';
116
-  	 $id = is_array($row) ? $row['name'] : $row;
115
+        $addEntry = '';
116
+        $id = is_array($row) ? $row['name'] : $row;
117 117
 
118
-     /*
118
+        /*
119 119
   	 if(!isset($existingElements[$id])) {
120 120
   	 	//$addEntry = $row;
121 121
   	 }
122 122
   	 */
123 123
   	 
124
-  	 if(isset($existingElements[$id])) {
125
-  	 	//Use master copy instead
126
-  	 	$section[$existingLocation[$id]['row']] = $row;
127
-  	 }
124
+        if(isset($existingElements[$id])) {
125
+            //Use master copy instead
126
+            $section[$existingLocation[$id]['row']] = $row;
127
+        }
128 128
      
129
-  	 // Add it to the $panels 
130
-  	 /*
129
+        // Add it to the $panels 
130
+        /*
131 131
   	 if(!empty($addEntry)) {
132 132
   	 	$section[] = $addEntry;
133 133
   	 }
134 134
   	 */
135
-  } //foreach
135
+    } //foreach
136 136
 
137
-  return $section;
137
+    return $section;
138 138
 }
139 139
 
140 140
 function processSection($section, $table, $filePath, $vardefs=array()) {
141 141
    
142
-   $toptr = $this->getElementsByType("tr", $table);
142
+    $toptr = $this->getElementsByType("tr", $table);
143 143
    
144
-   if(!is_array($toptr) || empty($toptr)) {
145
-   	  $GLOBALS['log']->error("Could not process top row (<tr>) for $section section");
146
-   	  $GLOBALS['log']->error($table);
147
-   	  return array(); 
148
-   }
144
+    if(!is_array($toptr) || empty($toptr)) {
145
+            $GLOBALS['log']->error("Could not process top row (<tr>) for $section section");
146
+            $GLOBALS['log']->error($table);
147
+            return array(); 
148
+    }
149 149
    
150
-   $tabledata = $this->getElementsByType("table", $toptr[0]);
150
+    $tabledata = $this->getElementsByType("table", $toptr[0]);
151 151
    
152
-   if(empty($tabledata)) {
153
-   	  $GLOBALS['log']->error("Error: HTML format for SearchForm.html not as expected, results may not be accurate");
154
-   	  $GLOBALS['log']->error($toptr[0]);
155
-   	  $tabledata[0] = "<table>{$table}</table>";
156
-   }
152
+    if(empty($tabledata)) {
153
+            $GLOBALS['log']->error("Error: HTML format for SearchForm.html not as expected, results may not be accurate");
154
+            $GLOBALS['log']->error($toptr[0]);
155
+            $tabledata[0] = "<table>{$table}</table>";
156
+    }
157 157
 
158
-   if(is_array($tabledata) && !empty($tabledata[0])) {
159
-      $rows = $this->getElementsByType("tr", $tabledata[0]);
160
-   } else {
161
-   	  $rows = $toptr[0];
162
-   }
158
+    if(is_array($tabledata) && !empty($tabledata[0])) {
159
+        $rows = $this->getElementsByType("tr", $tabledata[0]);
160
+    } else {
161
+            $rows = $toptr[0];
162
+    }
163 163
 
164
-   if(!is_array($rows)) {
165
-   	  return array();
166
-   }
164
+    if(!is_array($rows)) {
165
+            return array();
166
+    }
167 167
    
168
-   $metarow = array();
169
-   foreach($rows as $trow) {
170
-   	   $tablecolumns = $this->getElementsByType("td", $trow);
168
+    $metarow = array();
169
+    foreach($rows as $trow) {
170
+            $tablecolumns = $this->getElementsByType("td", $trow);
171 171
           
172
-       $emptyCount = 0;   
173
-       $metacolumn = array();
174
-       $col = null;
172
+        $emptyCount = 0;   
173
+        $metacolumn = array();
174
+        $col = null;
175 175
 
176
-	   foreach($tablecolumns as $tcols) {
176
+        foreach($tablecolumns as $tcols) {
177 177
 
178
-	   	  	 $spanValue = strtolower($this->getElementValue("span", $tcols));
179
-             $spanValue2 = strtolower($this->getElementValue("slot", $tcols));	
180
-             $spanValue = !empty($spanValue2) ? $spanValue2 : $spanValue;
181
-             $spanValue3 = strtolower($this->getElementValue("td", $tcols));
182
-             $spanValue = !empty($spanValue3) ? $spanValue3 : $spanValue; 
178
+                    $spanValue = strtolower($this->getElementValue("span", $tcols));
179
+                $spanValue2 = strtolower($this->getElementValue("slot", $tcols));	
180
+                $spanValue = !empty($spanValue2) ? $spanValue2 : $spanValue;
181
+                $spanValue3 = strtolower($this->getElementValue("td", $tcols));
182
+                $spanValue = !empty($spanValue3) ? $spanValue3 : $spanValue; 
183 183
              
184
-             //Get all the editable form elements' names
185
-	   	  	 $formElementNames = $this->getFormElementsNames($spanValue);  	  	 
186
-	   	  	 $customField = $this->getCustomField($formElementNames);
184
+                //Get all the editable form elements' names
185
+                    $formElementNames = $this->getFormElementsNames($spanValue);  	  	 
186
+                    $customField = $this->getCustomField($formElementNames);
187 187
 	   	  	 
188
-	   	  	 $name = '';
189
-             $fields = null;
190
-             $customCode = null;
188
+                    $name = '';
189
+                $fields = null;
190
+                $customCode = null;
191 191
                         
192
-             if(!empty($customField)) {           
193
-               // If it's a custom field we just set the name
194
-               $name = $customField;
195
-	   	  	 } else if(is_array($formElementNames) && count($formElementNames) == 1 
196
-	   	  	           && (isset($vardefs[$formElementNames[0]]) || $formElementNames[0] == 'current_user_only')) {
197
-	   	  	   $name = $formElementNames[0];
198
-	   	  	 } 
192
+                if(!empty($customField)) {           
193
+                // If it's a custom field we just set the name
194
+                $name = $customField;
195
+                    } else if(is_array($formElementNames) && count($formElementNames) == 1 
196
+                            && (isset($vardefs[$formElementNames[0]]) || $formElementNames[0] == 'current_user_only')) {
197
+                    $name = $formElementNames[0];
198
+                    } 
199 199
 
200
-	   	  	 //Skip and continue if $name is empty
201
-	   	  	 if(empty($name)) {
202
-	   	  	    continue;	
203
-	   	  	 }
200
+                    //Skip and continue if $name is empty
201
+                    if(empty($name)) {
202
+                        continue;	
203
+                    }
204 204
 	   	  	 
205
-	   	  	 // Build the entry
206
-	   	  	 if(preg_match("/<textarea/si", $spanValue)) {
207
-	   	  	 	//special case for textarea form elements (add the displayParams)
208
-	   	  	 	$displayParams = array();
209
-	   	  	    $displayParams['rows'] = $this->getTagAttribute("rows", $spanValue);
210
-	   	  	    $displayParams['cols'] = $this->getTagAttribute("cols", $spanValue);
205
+                    // Build the entry
206
+                    if(preg_match("/<textarea/si", $spanValue)) {
207
+                        //special case for textarea form elements (add the displayParams)
208
+                        $displayParams = array();
209
+                        $displayParams['rows'] = $this->getTagAttribute("rows", $spanValue);
210
+                        $displayParams['cols'] = $this->getTagAttribute("cols", $spanValue);
211 211
 
212
-	   	  	    if(!empty($displayParams['rows']) && !empty($displayParams['cols'])) {
213
-		   	  	    $field = array();
214
-		   	  	    $field['name'] = $name;
215
-					$field['displayParams'] = $displayParams;
216
-	   	  	    } else {
217
-	   	  	        $field = $name;	
218
-	   	  	    }
212
+                        if(!empty($displayParams['rows']) && !empty($displayParams['cols'])) {
213
+                            $field = array();
214
+                            $field['name'] = $name;
215
+                    $field['displayParams'] = $displayParams;
216
+                        } else {
217
+                            $field = $name;	
218
+                        }
219 219
 	   	  	    
220
-	   	  	    $col = $field;
220
+                        $col = $field;
221 221
 	   	  	   
222
-	   	  	 } else {
222
+                    } else {
223 223
 
224
-	   	  	 	if(isset($fields)) {
225
-	   	  	 	   $field = array();
226
-	   	  	 	   $field['name'] = $name;
227
-	   	  	 	   if(isset($fields)) {
228
-	   	  	 	   	  $field['fields'] = $fields;
229
-	   	  	 	   }
224
+                        if(isset($fields)) {
225
+                            $field = array();
226
+                            $field['name'] = $name;
227
+                            if(isset($fields)) {
228
+                                $field['fields'] = $fields;
229
+                            }
230 230
 	   	  	 	   
231
-	   	  	 	   if(!empty($customCode)) {
232
-	   	  	 	   	  $field['customCode'] = $customCode;
233
-	   	  	 	   }
231
+                            if(!empty($customCode)) {
232
+                                $field['customCode'] = $customCode;
233
+                            }
234 234
   	 	   
235
-	   	  	 	   $col = $field;
236
-	   	  	 	} else {
237
-	   	  	 	   $emptyCount = $name == '' ? $emptyCount + 1 : $emptyCount;
238
-	   	  	 	   $col = $name;
239
-	   	  	 	}	
240
-	   	  	 } //if-else if-else block
241
-             $metarow[] = $col;
242
-	   } //foreach
235
+                            $col = $field;
236
+                        } else {
237
+                            $emptyCount = $name == '' ? $emptyCount + 1 : $emptyCount;
238
+                            $col = $name;
239
+                        }	
240
+                    } //if-else if-else block
241
+                $metarow[] = $col;
242
+        } //foreach
243 243
 
244
-	   // One last final check.  If $emptyCount does not equal Array $col count, don't add 
245
-	   if($emptyCount != count($col)) {
246
-   	      //$metarow[] = $col;
247
-	   } //if
244
+        // One last final check.  If $emptyCount does not equal Array $col count, don't add 
245
+        if($emptyCount != count($col)) {
246
+                //$metarow[] = $col;
247
+        } //if
248 248
 
249
-   } //foreach  
249
+    } //foreach  
250 250
 	
251
-   return $metarow;
251
+    return $metarow;
252 252
 }
253 253
 
254 254
 function applyRules($moduleDir, $section=array()) {
255
-   require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
256
-   $baseRule = new BaseRule();
257
-   if(!is_array($section)) {
258
-   	  $GLOBALS['log']->error("Error: SearchFormMetaParser->applyRules expects Array");
259
-   	  return $section;
260
-   }
255
+    require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
256
+    $baseRule = new BaseRule();
257
+    if(!is_array($section)) {
258
+            $GLOBALS['log']->error("Error: SearchFormMetaParser->applyRules expects Array");
259
+            return $section;
260
+    }
261 261
    
262
-   foreach($section as $key=>$row) {
263
-   	  //Override email1 fields
264
-   	  if($baseRule->matches($row, '/^email1$/si')) {
265
-   	  	 $section[$key] = array('name' => 'email', 'label' =>'LBL_ANY_EMAIL', 'type' => 'name');
266
-   	  }
267
-   }
268
-   return $section;
262
+    foreach($section as $key=>$row) {
263
+            //Override email1 fields
264
+            if($baseRule->matches($row, '/^email1$/si')) {
265
+                $section[$key] = array('name' => 'email', 'label' =>'LBL_ANY_EMAIL', 'type' => 'name');
266
+            }
267
+    }
268
+    return $section;
269 269
 }
270 270
 
271 271
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
    }
Please login to merge, or discard this patch.
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -137,6 +137,9 @@  discard block
 block discarded – undo
137 137
   return $section;
138 138
 }
139 139
 
140
+/**
141
+ * @param string $section
142
+ */
140 143
 function processSection($section, $table, $filePath, $vardefs=array()) {
141 144
    
142 145
    $toptr = $this->getElementsByType("tr", $table);
@@ -251,6 +254,9 @@  discard block
 block discarded – undo
251 254
    return $metarow;
252 255
 }
253 256
 
257
+/**
258
+ * @param string $moduleDir
259
+ */
254 260
 function applyRules($moduleDir, $section=array()) {
255 261
    require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
256 262
    $baseRule = new BaseRule();
Please login to merge, or discard this patch.
include/SugarFields/SugarFieldHandler.php 4 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -49,24 +49,24 @@  discard block
 block discarded – undo
49 49
 
50 50
     static function fixupFieldType($field) {
51 51
             switch($field) {
52
-               case 'double':
52
+                case 'double':
53 53
                case 'decimal':
54 54
                     $field = 'float';
55 55
                     break;
56
-               case 'uint':
56
+                case 'uint':
57 57
                case 'ulong':
58 58
                case 'long':
59 59
                case 'short':
60 60
                case 'tinyint':
61 61
                     $field = 'int';
62 62
                     break;
63
-               case 'date':
63
+                case 'date':
64 64
                     $field = 'datetime';
65 65
                     break;
66
-               case 'url':
67
-               		$field = 'link';
68
-               		break;
69
-               case 'varchar':
66
+                case 'url':
67
+                       $field = 'link';
68
+                        break;
69
+                case 'varchar':
70 70
                     $field = 'base';
71 71
                     break;
72 72
             }
@@ -86,34 +86,34 @@  discard block
 block discarded – undo
86 86
         $field = ucfirst($field);
87 87
 
88 88
         if(!isset($sugarFieldObjects[$field])) {
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';
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';
92 92
                 $type = $field;
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';
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';
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 101
                     !is_dir('include/SugarFields/Fields/'.$field) ) {
102 102
                     return null;
103 103
                 }
104
-        		$file = 'include/SugarFields/Fields/Base/SugarFieldBase.php';
104
+                $file = 'include/SugarFields/Fields/Base/SugarFieldBase.php';
105 105
                 $type = 'Base';
106
-        	}
107
-			require_once($file);
106
+            }
107
+            require_once($file);
108 108
 
109
-			$class = 'SugarField' . $type;
110
-			//could be a custom class check it
111
-			$customClass = 'Custom' . $class;
112
-        	if(class_exists($customClass)){
113
-        		$sugarFieldObjects[$field] = new $customClass($field);
114
-        	}else{
115
-        		$sugarFieldObjects[$field] = new $class($field);
116
-        	}
109
+            $class = 'SugarField' . $type;
110
+            //could be a custom class check it
111
+            $customClass = 'Custom' . $class;
112
+            if(class_exists($customClass)){
113
+                $sugarFieldObjects[$field] = new $customClass($field);
114
+            }else{
115
+                $sugarFieldObjects[$field] = new $class($field);
116
+            }
117 117
         }
118 118
         return $sugarFieldObjects[$field];
119 119
     }
@@ -134,22 +134,22 @@  discard block
 block discarded – undo
134 134
         $string = '';
135 135
         $displayTypeFunc = 'get' . $displayType . 'Smarty'; // getDetailViewSmarty, getEditViewSmarty, etc...
136 136
 
137
-		// This will handle custom type fields.
138
-		// The incoming $vardef Array may have custom_type set.
139
-		// If so, set $vardef['type'] to the $vardef['custom_type'] value
140
-		if(isset($vardef['custom_type'])) {
141
-		   $vardef['type'] = $vardef['custom_type'];
142
-		}
143
-		if(empty($vardef['type'])) {
144
-			$vardef['type'] = 'varchar';
145
-		}
137
+        // This will handle custom type fields.
138
+        // The incoming $vardef Array may have custom_type set.
139
+        // If so, set $vardef['type'] to the $vardef['custom_type'] value
140
+        if(isset($vardef['custom_type'])) {
141
+            $vardef['type'] = $vardef['custom_type'];
142
+        }
143
+        if(empty($vardef['type'])) {
144
+            $vardef['type'] = 'varchar';
145
+        }
146 146
 
147
-		$field = self::getSugarField($vardef['type']);
148
-		if ( !empty($vardef['function']) ) {
149
-			$string = $field->displayFromFunc($displayType, $parentFieldArray, $vardef, $displayParams, $tabindex);
150
-		} else {
151
-			$string = $field->$displayTypeFunc($parentFieldArray, $vardef, $displayParams, $tabindex);
152
-		}
147
+        $field = self::getSugarField($vardef['type']);
148
+        if ( !empty($vardef['function']) ) {
149
+            $string = $field->displayFromFunc($displayType, $parentFieldArray, $vardef, $displayParams, $tabindex);
150
+        } else {
151
+            $string = $field->$displayTypeFunc($parentFieldArray, $vardef, $displayParams, $tabindex);
152
+        }
153 153
 
154 154
         return $string;
155 155
     }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 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')){
94
+			} else if(file_exists('include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php')){
95 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 99
         		if( $returnNullIfBase &&
100 100
                     !is_dir('custom/include/SugarFields/Fields/'.$field) &&
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 			$customClass = 'Custom' . $class;
112 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
         }
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -47,6 +47,9 @@
 block discarded – undo
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':
Please login to merge, or discard this patch.
include/SugarFields/Fields/Datetimecombo/SugarFieldDatetimecombo.php 3 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -44,19 +44,19 @@  discard block
 block discarded – undo
44 44
     function getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
45 45
         // Create Smarty variables for the Calendar picker widget
46 46
         if(!isset($displayParams['showMinutesDropdown'])) {
47
-           $displayParams['showMinutesDropdown'] = false;
47
+            $displayParams['showMinutesDropdown'] = false;
48 48
         }
49 49
 
50 50
         if(!isset($displayParams['showHoursDropdown'])) {
51
-           $displayParams['showHoursDropdown'] = false;
51
+            $displayParams['showHoursDropdown'] = false;
52 52
         }
53 53
 
54 54
         if(!isset($displayParams['showNoneCheckbox'])) {
55
-           $displayParams['showNoneCheckbox'] = false;
55
+            $displayParams['showNoneCheckbox'] = false;
56 56
         }
57 57
 
58 58
         if(!isset($displayParams['showFormats'])) {
59
-           $displayParams['showFormats'] = false;
59
+            $displayParams['showFormats'] = false;
60 60
         }
61 61
 
62 62
         global $timedate;
@@ -75,44 +75,44 @@  discard block
 block discarded – undo
75 75
 	
76 76
     function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
77 77
 
78
-    	 if($this->isRangeSearchView($vardef)) {
79
-           $displayParams['showMinutesDropdown'] = false;
80
-           $displayParams['showHoursDropdown'] = false;
81
-           $displayParams['showNoneCheckbox'] = false;
82
-           $displayParams['showFormats'] = false;
83
-	       global $timedate, $current_language;
84
-	       $displayParams['dateFormat'] = $timedate->get_cal_date_format();
85
-	       $displayParams['timeFormat'] = $timedate->get_user_time_format();
86
-
87
-           $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
88
-           $id = isset($displayParams['idName']) ? $displayParams['idName'] : $vardef['name'];
89
-           $this->ss->assign('original_id', "{$id}");
90
-           $this->ss->assign('id_range', "range_{$id}");
91
-           $this->ss->assign('id_range_start', "start_range_{$id}");
92
-           $this->ss->assign('id_range_end', "end_range_{$id}");
93
-           $this->ss->assign('id_range_choice', "{$id}_range_choice");
94
-           if(file_exists('custom/include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl'))
95
-           {
96
-              return $this->fetch('custom/include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl');
97
-           }
98
-           return $this->fetch('include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl');
78
+            if($this->isRangeSearchView($vardef)) {
79
+            $displayParams['showMinutesDropdown'] = false;
80
+            $displayParams['showHoursDropdown'] = false;
81
+            $displayParams['showNoneCheckbox'] = false;
82
+            $displayParams['showFormats'] = false;
83
+            global $timedate, $current_language;
84
+            $displayParams['dateFormat'] = $timedate->get_cal_date_format();
85
+            $displayParams['timeFormat'] = $timedate->get_user_time_format();
86
+
87
+            $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
88
+            $id = isset($displayParams['idName']) ? $displayParams['idName'] : $vardef['name'];
89
+            $this->ss->assign('original_id', "{$id}");
90
+            $this->ss->assign('id_range', "range_{$id}");
91
+            $this->ss->assign('id_range_start', "start_range_{$id}");
92
+            $this->ss->assign('id_range_end', "end_range_{$id}");
93
+            $this->ss->assign('id_range_choice', "{$id}_range_choice");
94
+            if(file_exists('custom/include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl'))
95
+            {
96
+                return $this->fetch('custom/include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl');
97
+            }
98
+            return $this->fetch('include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl');
99 99
         }
100 100
 
101
-    	// Create Smarty variables for the Calendar picker widget
101
+        // Create Smarty variables for the Calendar picker widget
102 102
         if(!isset($displayParams['showMinutesDropdown'])) {
103
-           $displayParams['showMinutesDropdown'] = false;
103
+            $displayParams['showMinutesDropdown'] = false;
104 104
         }
105 105
 
106 106
         if(!isset($displayParams['showHoursDropdown'])) {
107
-           $displayParams['showHoursDropdown'] = false;
107
+            $displayParams['showHoursDropdown'] = false;
108 108
         }
109 109
 
110 110
         if(!isset($displayParams['showNoneCheckbox'])) {
111
-           $displayParams['showNoneCheckbox'] = false;
111
+            $displayParams['showNoneCheckbox'] = false;
112 112
         }
113 113
 
114 114
         if(!isset($displayParams['showFormats'])) {
115
-           $displayParams['showFormats'] = false;
115
+            $displayParams['showFormats'] = false;
116 116
         }
117 117
 
118 118
         global $timedate;
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
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 129
         if(isset($context['notify_user'])) {
130 130
             $user = $context['notify_user'];
@@ -143,14 +143,14 @@  discard block
 block discarded – undo
143 143
 
144 144
         if(strpos($params[$prefix.$field], ' ') > 0) {
145 145
             if ($timedate->check_matching_format($params[$prefix.$field], TimeDate::DB_DATETIME_FORMAT)) {
146
-	            $bean->$field = $params[$prefix.$field];
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]);
152
-	        //Default to assume date format value
153
-        	if ($timedate->check_matching_format($params[$prefix.$field], TimeDate::DB_DATE_FORMAT)) {
151
+            $GLOBALS['log']->error('Field ' . $prefix.$field . ' expecting datetime format, but got value: ' . $params[$prefix.$field]);
152
+            //Default to assume date format value
153
+            if ($timedate->check_matching_format($params[$prefix.$field], TimeDate::DB_DATE_FORMAT)) {
154 154
                 $bean->$field = $params[$prefix.$field];
155 155
             } else {
156 156
                 $bean->$field = $timedate->to_db_date($params[$prefix.$field]);
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
         if ( !$timedate->check_matching_format($value, $format) ) {
176 176
             $parts = $timedate->split_date_time($value);
177 177
             if(empty($parts[0])) {
178
-               $datepart = $timedate->getNow()->format($settings->dateformat);
178
+                $datepart = $timedate->getNow()->format($settings->dateformat);
179 179
             }
180 180
             else {
181
-               $datepart = $parts[0];
181
+                $datepart = $parts[0];
182 182
             }
183 183
             if(empty($parts[1])) {
184 184
                 $timepart = $timedate->fromTimestamp(0)->format($settings->timeformat);
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -43,19 +43,19 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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();
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,8 +55,7 @@
 block discarded – undo
55 55
             }
56 56
             if(isset($parameters[$condition_item['condition_order']])) {
57 57
                 $parameters[] = $condition_item;
58
-            }
59
-            else {
58
+            } else {
60 59
                 $parameters[$condition_item['condition_order']] = $condition_item;
61 60
             }
62 61
         }
Please login to merge, or discard this patch.
SugarFields/Fields/Assigned_user_name/SugarFieldAssigned_user_name.php 3 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -41,14 +41,14 @@
 block discarded – undo
41 41
 
42 42
 class SugarFieldAssigned_user_name extends SugarFieldBase {
43 43
 
44
-	function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
45
-    	$vardef['options'] = get_user_array(false);
46
-		if(!empty($vardef['function']['returns']) && $vardef['function']['returns']== 'html'){
47
-    	   $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
48
-           return $this->fetch($this->findTemplate('EditViewFunction'));
49
-    	}else{
50
-    	   $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
51
-           return $this->fetch($this->findTemplate('SearchView'));
52
-    	}
44
+    function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
45
+        $vardef['options'] = get_user_array(false);
46
+        if(!empty($vardef['function']['returns']) && $vardef['function']['returns']== 'html'){
47
+            $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
48
+            return $this->fetch($this->findTemplate('EditViewFunction'));
49
+        }else{
50
+            $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
51
+            return $this->fetch($this->findTemplate('SearchView'));
52
+        }
53 53
     }
54 54
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@
 block discarded – undo
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
     	}
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 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
     	}
Please login to merge, or discard this patch.
include/SugarFields/Fields/Text/SugarFieldText.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 require_once 'include/clean.php';
42 42
 class SugarFieldText extends SugarFieldBase {
43 43
 
44
-	function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
44
+    function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
45 45
         if(!isset($displayParams['nl2br'])){
46 46
             $displayParams['nl2br'] = true;
47 47
         }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         if(!isset($displayParams['url2html'])) {
52 52
             $displayParams['url2html'] = true;
53 53
         }
54
-		return parent::getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex);
54
+        return parent::getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex);
55 55
     }
56 56
     function getClassicEditView($field_id='description', $value='', $prefix='', $rich_text=false, $maxlength='', $tabindex=1, $cols=80, $rows=4) {
57 57
 
@@ -68,19 +68,19 @@  discard block
 block discarded – undo
68 68
 
69 69
 
70 70
         $this->ss->assign('displayParams', $displayParams);
71
-		if(isset($GLOBALS['current_user'])) {
72
-			$height = $GLOBALS['current_user']->getPreference('text_editor_height');
73
-			$width = $GLOBALS['current_user']->getPreference('text_editor_width');
74
-			$height = isset($height) ? $height : '300px';
75
-	        $width = isset($width) ? $width : '95%';
76
-			$this->ss->assign('RICH_TEXT_EDITOR_HEIGHT', $height);
77
-			$this->ss->assign('RICH_TEXT_EDITOR_WIDTH', $width);
78
-		} else {
79
-			$this->ss->assign('RICH_TEXT_EDITOR_HEIGHT', '100px');
80
-			$this->ss->assign('RICH_TEXT_EDITOR_WIDTH', '95%');
81
-		}
71
+        if(isset($GLOBALS['current_user'])) {
72
+            $height = $GLOBALS['current_user']->getPreference('text_editor_height');
73
+            $width = $GLOBALS['current_user']->getPreference('text_editor_width');
74
+            $height = isset($height) ? $height : '300px';
75
+            $width = isset($width) ? $width : '95%';
76
+            $this->ss->assign('RICH_TEXT_EDITOR_HEIGHT', $height);
77
+            $this->ss->assign('RICH_TEXT_EDITOR_WIDTH', $width);
78
+        } else {
79
+            $this->ss->assign('RICH_TEXT_EDITOR_HEIGHT', '100px');
80
+            $this->ss->assign('RICH_TEXT_EDITOR_WIDTH', '95%');
81
+        }
82 82
 
83
-		return $this->ss->fetch($this->findTemplate('ClassicEditView'));
83
+        return $this->ss->fetch($this->findTemplate('ClassicEditView'));
84 84
     }
85 85
 }
86 86
 ?>
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,18 +42,18 @@  discard block
 block discarded – undo
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
 block discarded – undo
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';
Please login to merge, or discard this patch.
include/SugarFields/Fields/CronSchedule/SugarFieldCronSchedule.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -3,48 +3,48 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
include/SugarEmailAddress/SugarEmailAddress.php 4 patches
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
     var $object_name = 'EmailAddress';
57 57
 
58 58
     //bug 40068, According to rules in page 6 of http://www.apps.ietf.org/rfc/rfc3696.html#sec-3,
59
-	//allowed special characters ! # $ % & ' * + - / = ?  ^ _ ` . { | } ~ in local part
59
+    //allowed special characters ! # $ % & ' * + - / = ?  ^ _ ` . { | } ~ in local part
60 60
     var $regex = "/^(?:['\.\-\+&#!\$\*=\?\^_`\{\}~\/\w]+)@(?:(?:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|\w+(?:[\.-]*\w+)*(?:\.[\w-]{2,})+)\$/";
61 61
     var $disable_custom_fields = true;
62 62
     var $db;
@@ -391,8 +391,8 @@  discard block
 block discarded – undo
391 391
             // determine which array to process
392 392
             foreach($_REQUEST as $k => $v) {
393 393
                 if(strpos($k, 'emailAddress') !== false) {
394
-                   $fromRequest = true;
395
-                   break;
394
+                    $fromRequest = true;
395
+                    break;
396 396
                 }
397 397
             $widget_id = $_REQUEST[$module .'_email_widget_id'];
398 398
     }
@@ -409,30 +409,30 @@  discard block
 block discarded – undo
409 409
 
410 410
                 $eId = $module . $widget_id;
411 411
                 if(isset($_REQUEST[$eId . 'emailAddressPrimaryFlag'])) {
412
-                   $primaryValue = $_REQUEST[$eId . 'emailAddressPrimaryFlag'];
412
+                    $primaryValue = $_REQUEST[$eId . 'emailAddressPrimaryFlag'];
413 413
                 } else if(isset($_REQUEST[$module . 'emailAddressPrimaryFlag'])) {
414
-                   $primaryValue = $_REQUEST[$module . 'emailAddressPrimaryFlag'];
414
+                    $primaryValue = $_REQUEST[$module . 'emailAddressPrimaryFlag'];
415 415
                 }
416 416
 
417 417
                 $optOutValues = array();
418 418
                 if(isset($_REQUEST[$eId .'emailAddressOptOutFlag'])) {
419
-                   $optOutValues = $_REQUEST[$eId .'emailAddressOptOutFlag'];
419
+                    $optOutValues = $_REQUEST[$eId .'emailAddressOptOutFlag'];
420 420
                 } else if(isset($_REQUEST[$module . 'emailAddressOptOutFlag'])) {
421
-                   $optOutValues = $_REQUEST[$module . 'emailAddressOptOutFlag'];
421
+                    $optOutValues = $_REQUEST[$module . 'emailAddressOptOutFlag'];
422 422
                 }
423 423
 
424 424
                 $invalidValues = array();
425 425
                 if(isset($_REQUEST[$eId .'emailAddressInvalidFlag'])) {
426
-                   $invalidValues = $_REQUEST[$eId .'emailAddressInvalidFlag'];
426
+                    $invalidValues = $_REQUEST[$eId .'emailAddressInvalidFlag'];
427 427
                 } else if(isset($_REQUEST[$module . 'emailAddressInvalidFlag'])) {
428
-                   $invalidValues = $_REQUEST[$module . 'emailAddressInvalidFlag'];
428
+                    $invalidValues = $_REQUEST[$module . 'emailAddressInvalidFlag'];
429 429
                 }
430 430
 
431 431
                 $deleteValues = array();
432 432
                 if(isset($_REQUEST[$eId .'emailAddressDeleteFlag'])) {
433
-                   $deleteValues = $_REQUEST[$eId .'emailAddressDeleteFlag'];
433
+                    $deleteValues = $_REQUEST[$eId .'emailAddressDeleteFlag'];
434 434
                 } else if(isset($_REQUEST[$module . 'emailAddressDeleteFlag'])) {
435
-                   $deleteValues = $_REQUEST[$module . 'emailAddressDeleteFlag'];
435
+                    $deleteValues = $_REQUEST[$module . 'emailAddressDeleteFlag'];
436 436
                 }
437 437
 
438 438
                 // prep from form save
@@ -446,9 +446,9 @@  discard block
 block discarded – undo
446 446
 
447 447
                 if($fromRequest && empty($replyTo)) {
448 448
                     if(isset($_REQUEST[$eId .'emailAddressReplyToFlag'])) {
449
-                       $replyToField = $_REQUEST[$eId .'emailAddressReplyToFlag'];
449
+                        $replyToField = $_REQUEST[$eId .'emailAddressReplyToFlag'];
450 450
                     } else if(isset($_REQUEST[$module . 'emailAddressReplyToFlag'])) {
451
-                       $replyToField = $_REQUEST[$module . 'emailAddressReplyToFlag'];
451
+                        $replyToField = $_REQUEST[$module . 'emailAddressReplyToFlag'];
452 452
                     }
453 453
                 }
454 454
                 if($fromRequest && empty($new_addrs)) {
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 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
-                              $new_addrs[$k] = $v;
475
+                                $new_addrs[$k] = $v;
476 476
                         }
477 477
                     }
478 478
                 }
@@ -484,18 +484,18 @@  discard block
 block discarded – undo
484 484
                     $optOutValues = array();
485 485
                     $invalidValues = array();
486 486
                     foreach($new_addrs as $k=>$email) {
487
-                       preg_match('/emailAddress([0-9])+$/', $k, $matches);
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'])) {
493
-                             $optOutValues[$k] = "emailAddress$count";
494
-                          }
495
-                          if(!empty($row['invalid_email'])) {
496
-                             $invalidValues[$k] = "emailAddress$count";
497
-                          }
498
-                       }
487
+                        preg_match('/emailAddress([0-9])+$/', $k, $matches);
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'])) {
493
+                                $optOutValues[$k] = "emailAddress$count";
494
+                            }
495
+                            if(!empty($row['invalid_email'])) {
496
+                                $invalidValues[$k] = "emailAddress$count";
497
+                            }
498
+                        }
499 499
                     }
500 500
                 }
501 501
                 // Re-populate the addresses class variable if we have new address(es).
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 
523 523
         //If no widgets, set addresses array to empty
524 524
         if($post_from_email_address_widget && !$hasEmailValue) {
525
-           $this->addresses = array();
525
+            $this->addresses = array();
526 526
         }
527 527
     }
528 528
 
@@ -861,14 +861,14 @@  discard block
 block discarded – undo
861 861
             $count = 0;
862 862
             $key = $module . $widget_id . 'emailAddress'.$count;
863 863
             while(isset($_REQUEST[$key])) {
864
-                   $email = $_REQUEST[$key];
865
-                   $prefillDataArr[] =  array('email_address'=>$email,
866
-                                             'primary_address'=>isset($_REQUEST['emailAddressPrimaryFlag']) && $_REQUEST['emailAddressPrimaryFlag'] == $key,
867
-                                             'invalid_email'=>isset($_REQUEST['emailAddressInvalidFlag']) && in_array($key, $_REQUEST['emailAddressInvalidFlag']),
868
-                                             'opt_out'=>isset($_REQUEST['emailAddressOptOutFlag']) && in_array($key, $_REQUEST['emailAddressOptOutFlag']),
869
-                                             'reply_to_address'=>false
864
+                    $email = $_REQUEST[$key];
865
+                    $prefillDataArr[] =  array('email_address'=>$email,
866
+                                                'primary_address'=>isset($_REQUEST['emailAddressPrimaryFlag']) && $_REQUEST['emailAddressPrimaryFlag'] == $key,
867
+                                                'invalid_email'=>isset($_REQUEST['emailAddressInvalidFlag']) && in_array($key, $_REQUEST['emailAddressInvalidFlag']),
868
+                                                'opt_out'=>isset($_REQUEST['emailAddressOptOutFlag']) && in_array($key, $_REQUEST['emailAddressOptOutFlag']),
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
 
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
         $this->smarty->assign('emailAddressWidget',$_POST['emailAddressWidget']);
986 986
 
987 987
         if(isset($_POST[$mod . $widget_id . 'emailAddressPrimaryFlag'])) {
988
-           $primary = $_POST[$mod . $widget_id . 'emailAddressPrimaryFlag'];
988
+            $primary = $_POST[$mod . $widget_id . 'emailAddressPrimaryFlag'];
989 989
         }
990 990
 
991 991
         while(isset($_POST[$mod . $widget_id . "emailAddress" . $count])) {
@@ -994,31 +994,31 @@  discard block
 block discarded – undo
994 994
         }
995 995
 
996 996
         if($count == 0) {
997
-           return "";
997
+            return "";
998 998
         }
999 999
 
1000 1000
         if(isset($_POST[$mod . $widget_id . 'emailAddressOptOutFlag'])) {
1001
-           foreach($_POST[$mod . $widget_id . 'emailAddressOptOutFlag'] as $v) {
1002
-              $optOut[] = $v;
1003
-           }
1001
+            foreach($_POST[$mod . $widget_id . 'emailAddressOptOutFlag'] as $v) {
1002
+                $optOut[] = $v;
1003
+            }
1004 1004
         }
1005 1005
 
1006 1006
         if(isset($_POST[$mod . $widget_id . 'emailAddressInvalidFlag'])) {
1007
-           foreach($_POST[$mod . $widget_id . 'emailAddressInvalidFlag'] as $v) {
1008
-              $invalid[] = $v;
1009
-           }
1007
+            foreach($_POST[$mod . $widget_id . 'emailAddressInvalidFlag'] as $v) {
1008
+                $invalid[] = $v;
1009
+            }
1010 1010
         }
1011 1011
 
1012 1012
         if(isset($_POST[$mod . $widget_id . 'emailAddressReplyToFlag'])) {
1013
-           foreach($_POST[$mod . $widget_id . 'emailAddressReplyToFlag'] as $v) {
1014
-              $replyTo[] = $v;
1015
-           }
1013
+            foreach($_POST[$mod . $widget_id . 'emailAddressReplyToFlag'] as $v) {
1014
+                $replyTo[] = $v;
1015
+            }
1016 1016
         }
1017 1017
 
1018 1018
         if(isset($_POST[$mod . $widget_id . 'emailAddressDeleteFlag'])) {
1019
-           foreach($_POST[$mod . $widget_id . 'emailAddressDeleteFlag'] as $v) {
1020
-              $delete[] = $v;
1021
-           }
1019
+            foreach($_POST[$mod . $widget_id . 'emailAddressDeleteFlag'] as $v) {
1020
+                $delete[] = $v;
1021
+            }
1022 1022
         }
1023 1023
 
1024 1024
         while(isset($_POST[$mod . $widget_id . "emailAddressVerifiedValue" . $count])) {
@@ -1052,13 +1052,13 @@  discard block
 block discarded – undo
1052 1052
         $get .= '&emailAddressWidget='.$_POST['emailAddressWidget'];
1053 1053
 
1054 1054
         while(isset($_REQUEST[$mod . $widget_id . 'emailAddress' . $count])) {
1055
-              $get .= "&" . $mod . $widget_id . "emailAddress" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddress' . $count]);
1056
-              $count++;
1055
+                $get .= "&" . $mod . $widget_id . "emailAddress" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddress' . $count]);
1056
+                $count++;
1057 1057
         } //while
1058 1058
 
1059 1059
         while(isset($_REQUEST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count])) {
1060
-              $get .= "&" . $mod . $widget_id . "emailAddressVerifiedValue" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count]);
1061
-              $count++;
1060
+                $get .= "&" . $mod . $widget_id . "emailAddressVerifiedValue" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count]);
1061
+                $count++;
1062 1062
         } //while
1063 1063
 
1064 1064
         $options = array('emailAddressPrimaryFlag', 'emailAddressOptOutFlag', 'emailAddressInvalidFlag', 'emailAddressDeleteFlag', 'emailAddressReplyToFlag');
@@ -1067,14 +1067,14 @@  discard block
 block discarded – undo
1067 1067
             $count = 0;
1068 1068
             $optionIdentifier = $mod.$widget_id.$option;
1069 1069
             if(isset($_REQUEST[$optionIdentifier])) {
1070
-               if(is_array($_REQUEST[$optionIdentifier])) {
1071
-                   foreach($_REQUEST[$optionIdentifier] as $optOut) {
1072
-                      $get .= "&" . $optionIdentifier . "[" . $count . "]=" . $optOut;
1073
-                      $count++;
1074
-                   } //foreach
1075
-               } else {
1076
-                   $get .= "&" . $optionIdentifier . "=" . $_REQUEST[$optionIdentifier];
1077
-               }
1070
+                if(is_array($_REQUEST[$optionIdentifier])) {
1071
+                    foreach($_REQUEST[$optionIdentifier] as $optOut) {
1072
+                        $get .= "&" . $optionIdentifier . "[" . $count . "]=" . $optOut;
1073
+                        $count++;
1074
+                    } //foreach
1075
+                } else {
1076
+                    $get .= "&" . $optionIdentifier . "=" . $_REQUEST[$optionIdentifier];
1077
+                }
1078 1078
             } //if
1079 1079
         } //foreach
1080 1080
         return $get;
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
     }
1083 1083
 
1084 1084
     function setView($view) {
1085
-       $this->view = $view;
1085
+        $this->view = $view;
1086 1086
     }
1087 1087
 
1088 1088
 /**
Please login to merge, or discard this patch.
Spacing   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
Braces   +39 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -132,8 +134,9 @@  discard block
 block discarded – undo
132 134
         $alternate_found = false;
133 135
         $alternate2_found = false;
134 136
         foreach($this->addresses as $k=>$address) {
135
-            if ($primary_found && $alternate_found)
136
-                break;
137
+            if ($primary_found && $alternate_found) {
138
+                            break;
139
+            }
137 140
             if ($address['primary_address'] == 1 && !$primary_found) {
138 141
                 $primary_index = $k;
139 142
                 $primary_found = true;
@@ -271,8 +274,9 @@  discard block
 block discarded – undo
271 274
         )
272 275
     {
273 276
         $emailCaps = strtoupper(trim($email));
274
-        if(empty($emailCaps))
275
-            return 0;
277
+        if(empty($emailCaps)) {
278
+                    return 0;
279
+        }
276 280
 
277 281
         $q = "SELECT *
278 282
                 FROM email_addr_bean_rel eabl JOIN email_addresses ea
@@ -288,7 +292,9 @@  discard block
 block discarded – undo
288 292
 
289 293
         // do it this way to make the count accurate in oracle
290 294
         $i = 0;
291
-        while ($this->db->fetchByAssoc($r)) ++$i;
295
+        while ($this->db->fetchByAssoc($r)) {
296
+            ++$i;
297
+        }
292 298
 
293 299
         return $i;
294 300
     }
@@ -471,8 +477,9 @@  discard block
 block discarded – undo
471 477
                     foreach($_REQUEST as $k => $v) {
472 478
                         if(preg_match('/'.$eId.'emailAddressVerifiedValue[0-9]+$/i', $k) && !empty($v)) {
473 479
                             $validateFlag = str_replace("Value", "Flag", $k);
474
-                            if (isset($_REQUEST[$validateFlag]) && $_REQUEST[$validateFlag] == "true")
475
-                              $new_addrs[$k] = $v;
480
+                            if (isset($_REQUEST[$validateFlag]) && $_REQUEST[$validateFlag] == "true") {
481
+                                                          $new_addrs[$k] = $v;
482
+                            }
476 483
                         }
477 484
                     }
478 485
                 }
@@ -675,8 +682,7 @@  discard block
 block discarded – undo
675 682
         if ($id) {
676 683
             $r = $this->db->query("SELECT * FROM email_addresses WHERE id='".$this->db->quote($id)."'");
677 684
             $current_email = $this->db->fetchByAssoc($r);
678
-        }
679
-        else {
685
+        } else {
680 686
             $current_email = null;
681 687
         }
682 688
 
@@ -716,8 +722,7 @@  discard block
 block discarded – undo
716 722
                 $upd_r = $this->db->query($upd_q);
717 723
             }
718 724
             return $duplicate_email['id'];
719
-        }
720
-        else {
725
+        } else {
721 726
             // no case-insensitive address match - it's new, or undeleted.
722 727
             $guid = '';
723 728
             if(!empty($address)){
@@ -783,8 +788,7 @@  discard block
 block discarded – undo
783 788
             // otherwise
784 789
             $q .= "
785 790
                 ORDER BY ear.reply_to_address DESC";
786
-        }
787
-        else
791
+        } else
788 792
         {
789 793
             // retrieve reply-to address only
790 794
             $q .= "
@@ -835,8 +839,9 @@  discard block
 block discarded – undo
835 839
      */
836 840
     function getEmailAddressWidgetEditView($id, $module, $asMetadata=false, $tpl='',$tabindex='0')
837 841
     {
838
-        if ( !($this->smarty instanceOf Sugar_Smarty ) )
839
-            $this->smarty = new Sugar_Smarty();
842
+        if ( !($this->smarty instanceOf Sugar_Smarty ) ) {
843
+                    $this->smarty = new Sugar_Smarty();
844
+        }
840 845
 
841 846
         global $app_strings, $dictionary, $beanList;
842 847
 
@@ -854,8 +859,9 @@  discard block
 block discarded – undo
854 859
         if(!empty($id)) {
855 860
             $prefillDataArr = $this->getAddressesByGUID($id, $module);
856 861
             //When coming from convert leads, sometimes module is Contacts while the id is for a lead.
857
-            if (empty($prefillDataArr) && $module == "Contacts")
858
-                $prefillDataArr = $this->getAddressesByGUID($id, "Leads");
862
+            if (empty($prefillDataArr) && $module == "Contacts") {
863
+                            $prefillDataArr = $this->getAddressesByGUID($id, "Leads");
864
+            }
859 865
         } else if(isset($_REQUEST['full_form']) && !empty($_REQUEST['emailAddressWidget'])){
860 866
             $widget_id = isset($_REQUEST[$module . '_email_widget_id']) ? $_REQUEST[$module . '_email_widget_id'] : '0';
861 867
             $count = 0;
@@ -880,8 +886,9 @@  discard block
 block discarded – undo
880 886
 
881 887
         $required = false;
882 888
         $vardefs = $dictionary[$beanList[$passedModule]]['fields'];
883
-        if (!empty($vardefs['email1']) && isset($vardefs['email1']['required']) && $vardefs['email1']['required'])
884
-            $required = true;
889
+        if (!empty($vardefs['email1']) && isset($vardefs['email1']['required']) && $vardefs['email1']['required']) {
890
+                    $required = true;
891
+        }
885 892
         $this->smarty->assign('required', $required);
886 893
 
887 894
         $this->smarty->assign('module', $saveModule);
@@ -935,13 +942,16 @@  discard block
 block discarded – undo
935 942
      */
936 943
     function getEmailAddressWidgetDetailView($focus, $tpl='')
937 944
     {
938
-        if ( !($this->smarty instanceOf Sugar_Smarty ) )
939
-            $this->smarty = new Sugar_Smarty();
945
+        if ( !($this->smarty instanceOf Sugar_Smarty ) ) {
946
+                    $this->smarty = new Sugar_Smarty();
947
+        }
940 948
 
941 949
         global $app_strings;
942 950
         global $current_user;
943 951
         $assign = array();
944
-        if(empty($focus->id))return '';
952
+        if(empty($focus->id)) {
953
+            return '';
954
+        }
945 955
         $prefillData = $this->getAddressesByGUID($focus->id, $focus->module_dir);
946 956
 
947 957
         foreach($prefillData as $addressItem) {
@@ -970,8 +980,9 @@  discard block
 block discarded – undo
970 980
      */
971 981
     function getEmailAddressWidgetDuplicatesView($focus)
972 982
     {
973
-        if ( !($this->smarty instanceOf Sugar_Smarty ) )
974
-            $this->smarty = new Sugar_Smarty();
983
+        if ( !($this->smarty instanceOf Sugar_Smarty ) ) {
984
+                    $this->smarty = new Sugar_Smarty();
985
+        }
975 986
 
976 987
         $count = 0;
977 988
         $emails = array();
@@ -1131,7 +1142,9 @@  discard block
 block discarded – undo
1131 1142
 
1132 1143
         if($view == 'EditView' || $view == 'QuickCreate' || $view == 'ConvertLead') {
1133 1144
             $module = $focus->module_dir;
1134
-            if ($view == 'ConvertLead' && $module == "Contacts")  $module = "Leads";
1145
+            if ($view == 'ConvertLead' && $module == "Contacts") {
1146
+                $module = "Leads";
1147
+            }
1135 1148
 
1136 1149
             return $sea->getEmailAddressWidgetEditView($focus->id, $module, false,'',$tabindex);
1137 1150
         }
Please login to merge, or discard this patch.
Doc Comments   +10 added lines, -16 removed lines patch added patch discarded remove patch
@@ -80,8 +80,6 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.