Passed
Push — scrutinizer-code-quality ( eedb15...27193c )
by Adam
54:15 queued 15s
created
modules/ModuleBuilder/parsers/ParserFactory.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
     public static function getParser ( $view , $moduleName , $packageName = null , $subpanelName = null )
59 59
     {
60 60
         $GLOBALS [ 'log' ]->info ( "ParserFactory->getParser($view,$moduleName,$packageName,$subpanelName )" ) ;
61
-		$sm = null;
61
+        $sm = null;
62 62
         $lView = strtolower ( $view );
63 63
         if ( empty ( $packageName ) || ( $packageName == 'studio' ) )
64 64
         {
Please login to merge, or discard this patch.
modules/ModuleBuilder/parsers/parser.modifylistview.php 1 patch
Indentation   +262 added lines, -262 removed lines patch added patch discarded remove patch
@@ -43,144 +43,144 @@  discard block
 block discarded – undo
43 43
 require_once ('modules/ModuleBuilder/parsers/ModuleBuilderParser.php') ;
44 44
 class ParserModifyListView extends ModuleBuilderParser
45 45
 {
46
-	var $listViewDefs = false ;
47
-	var $defaults = array ( ) ;
48
-	var $additional = array ( ) ;
49
-	var $available = array ( ) ;
50
-	var $reserved = array(); // fields marked by 'studio'=>false in the listviewdefs; need to be preserved
51
-	//	var $language_module = '';
52
-	var $columns = array ( 'LBL_DEFAULT' => 'getDefaultFields' , 'LBL_AVAILABLE' => 'getAdditionalFields' , 'LBL_HIDDEN' => 'getAvailableFields' ) ;
53
-	function init ( $module_name , $submodule = '' )
54
-	{
55
-		global $app_list_strings ;
56
-		$this->module_name = $module_name ;
57
-		$mod_strings = return_module_language ( $GLOBALS [ 'current_language' ], $this->module_name ) ; // needed solely so that listviewdefs that reference this can be included without error
58
-		$class = $GLOBALS [ 'beanList' ] [ $this->module_name ] ;
59
-		require_once ($GLOBALS [ 'beanFiles' ] [ $class ]) ;
60
-		$this->module = new $class ( ) ;
46
+    var $listViewDefs = false ;
47
+    var $defaults = array ( ) ;
48
+    var $additional = array ( ) ;
49
+    var $available = array ( ) ;
50
+    var $reserved = array(); // fields marked by 'studio'=>false in the listviewdefs; need to be preserved
51
+    //	var $language_module = '';
52
+    var $columns = array ( 'LBL_DEFAULT' => 'getDefaultFields' , 'LBL_AVAILABLE' => 'getAdditionalFields' , 'LBL_HIDDEN' => 'getAvailableFields' ) ;
53
+    function init ( $module_name , $submodule = '' )
54
+    {
55
+        global $app_list_strings ;
56
+        $this->module_name = $module_name ;
57
+        $mod_strings = return_module_language ( $GLOBALS [ 'current_language' ], $this->module_name ) ; // needed solely so that listviewdefs that reference this can be included without error
58
+        $class = $GLOBALS [ 'beanList' ] [ $this->module_name ] ;
59
+        require_once ($GLOBALS [ 'beanFiles' ] [ $class ]) ;
60
+        $this->module = new $class ( ) ;
61 61
 
62
-		$loaded = $this->_loadFromFile('ListView','modules/' . $this->module_name . '/metadata/listviewdefs.php',$this->module_name);
63
-		$this->originalListViewDefs = $loaded['viewdefs'] [ $this->module_name ] ;
64
-		$this->_variables = $loaded['variables'];
65
-		//		_pp($loaded);
66
-		$this->customFile = 'custom/modules/' . $this->module_name . '/metadata/listviewdefs.php' ;
67
-		if (file_exists ( $this->customFile ))
68
-		{
69
-			$loaded = $this->_loadFromFile('ListView',$this->customFile,$this->module_name);
70
-			$this->listViewDefs = $loaded['viewdefs'] [ $this->module_name ] ;
71
-			$this->_variables = $loaded['variables'];
72
-		} else
73
-		{
74
-			$this->listViewDefs = & $this->originalListViewDefs ;
75
-		}
62
+        $loaded = $this->_loadFromFile('ListView','modules/' . $this->module_name . '/metadata/listviewdefs.php',$this->module_name);
63
+        $this->originalListViewDefs = $loaded['viewdefs'] [ $this->module_name ] ;
64
+        $this->_variables = $loaded['variables'];
65
+        //		_pp($loaded);
66
+        $this->customFile = 'custom/modules/' . $this->module_name . '/metadata/listviewdefs.php' ;
67
+        if (file_exists ( $this->customFile ))
68
+        {
69
+            $loaded = $this->_loadFromFile('ListView',$this->customFile,$this->module_name);
70
+            $this->listViewDefs = $loaded['viewdefs'] [ $this->module_name ] ;
71
+            $this->_variables = $loaded['variables'];
72
+        } else
73
+        {
74
+            $this->listViewDefs = & $this->originalListViewDefs ;
75
+        }
76 76
 
77
-		$this->fixKeys ( $this->originalListViewDefs ) ;
78
-		$this->fixKeys ( $this->listViewDefs ) ;
79
-		$this->language_module = $this->module_name ;
80
-	}
77
+        $this->fixKeys ( $this->originalListViewDefs ) ;
78
+        $this->fixKeys ( $this->listViewDefs ) ;
79
+        $this->language_module = $this->module_name ;
80
+    }
81 81
 	
82
-	function getLanguage()
83
-	{
84
-	    return $this->language_module;
85
-	}
86
-	// re-key array so that every entry has a key=name and all keys are lowercase - makes it easier in handleSave() later...
87
-	function fixKeys ( &$defs )
88
-	{
89
-		$temp = array ( ) ;
90
-		foreach ( $defs as $key => $value )
91
-		{
92
-			if (! is_array ( $value ))
93
-			{
94
-				$key = $value ;
95
-				$def = array ( ) ;
96
-				$def [ 'name' ] = (isset ( $this->module->field_defs [ $key ] )) ? $this->module->field_defs [ $key ] [ 'name' ] : $key ;
97
-				$value = $def ;
98
-			}
99
-			if (isset ( $value [ 'name' ] ))
100
-			{
101
-				$key = $value [ 'name' ] ; // override key with name, needed when the entry lacks a key
102
-			}
103
-			$temp [ strtolower ( $key ) ] = $value ;
104
-		}
105
-		$defs = $temp ;
106
-	}
82
+    function getLanguage()
83
+    {
84
+        return $this->language_module;
85
+    }
86
+    // re-key array so that every entry has a key=name and all keys are lowercase - makes it easier in handleSave() later...
87
+    function fixKeys ( &$defs )
88
+    {
89
+        $temp = array ( ) ;
90
+        foreach ( $defs as $key => $value )
91
+        {
92
+            if (! is_array ( $value ))
93
+            {
94
+                $key = $value ;
95
+                $def = array ( ) ;
96
+                $def [ 'name' ] = (isset ( $this->module->field_defs [ $key ] )) ? $this->module->field_defs [ $key ] [ 'name' ] : $key ;
97
+                $value = $def ;
98
+            }
99
+            if (isset ( $value [ 'name' ] ))
100
+            {
101
+                $key = $value [ 'name' ] ; // override key with name, needed when the entry lacks a key
102
+            }
103
+            $temp [ strtolower ( $key ) ] = $value ;
104
+        }
105
+        $defs = $temp ;
106
+    }
107 107
 	
108
-	/**
109
-	 * returns the default fields for a listview
110
-	 * Called only when displaying the listview for editing; not called when saving
111
-	 */
112
-	function getDefaultFields ()
113
-	{
114
-		$this->defaults = array ( ) ;
115
-		foreach ( $this->listViewDefs as $key => $def )
116
-		{
117
-		    // add in the default fields from the listviewdefs, stripping out any field with 'studio' set to a value other than true
118
-		    // Important: the 'studio' fields must be added back into the layout on save, as they're not editable rather than hidden
119
-			if (! empty ( $def [ 'default' ] ))
120
-			{
121
-			    if (! isset($def['studio']) || $def['studio'] === true)
122
-			    {
123
-			        $this->defaults [ $key ] = $def ;
124
-			    }
125
-			    else
126
-			    // anything which doesn't go into the defaults is a reserved field - this makes sure we don't miss anything
127
-			    {
128
-			        $this->reserved [ $key ] = $def;
129
-			    }
130
-			}
131
-		}
132
-		return $this->defaults ;
133
-	}
134
-	/**
135
-	 * returns additional fields available for users to create fields
136
-	 */
137
-	function getAdditionalFields ()
138
-	{
139
-		$this->additional = array ( ) ;
140
-		foreach ( $this->listViewDefs as $key => $def )
141
-		{
142
-			if (empty ( $def [ 'default' ] ))
143
-			{
144
-				$key = strtolower ( $key ) ;
145
-				$this->additional [ $key ] = $def ;
146
-			}
147
-		}
148
-		return $this->additional ;
149
-	}
150
-	/**
151
-	 * returns unused fields that are available for using in either default or additional list views
152
-	 */
153
-	function getAvailableFields ()
154
-	{
155
-		$this->availableFields = array ( ) ;
156
-		$lowerFieldList = array_change_key_case ( $this->listViewDefs ) ;
157
-		foreach ( $this->originalListViewDefs as $key => $def )
158
-		{
159
-			$key = strtolower ( $key ) ;
160
-			if (! isset ( $lowerFieldList [ $key ] ))
161
-			{
162
-				$this->availableFields [ $key ] = $def ;
163
-			}
164
-		}
165
-		$GLOBALS['log']->debug('parser.modifylistview.php->getAvailableFields(): field_defs='.print_r($this->availableFields,true));
166
-		$modFields = !empty($this->module->field_name_map) ? $this->module->field_name_map : $this->module->field_defs;
167
-		foreach ( $modFields as $key => $def )
168
-		{
169
-			$fieldName = strtolower ( $key ) ;
108
+    /**
109
+     * returns the default fields for a listview
110
+     * Called only when displaying the listview for editing; not called when saving
111
+     */
112
+    function getDefaultFields ()
113
+    {
114
+        $this->defaults = array ( ) ;
115
+        foreach ( $this->listViewDefs as $key => $def )
116
+        {
117
+            // add in the default fields from the listviewdefs, stripping out any field with 'studio' set to a value other than true
118
+            // Important: the 'studio' fields must be added back into the layout on save, as they're not editable rather than hidden
119
+            if (! empty ( $def [ 'default' ] ))
120
+            {
121
+                if (! isset($def['studio']) || $def['studio'] === true)
122
+                {
123
+                    $this->defaults [ $key ] = $def ;
124
+                }
125
+                else
126
+                // anything which doesn't go into the defaults is a reserved field - this makes sure we don't miss anything
127
+                {
128
+                    $this->reserved [ $key ] = $def;
129
+                }
130
+            }
131
+        }
132
+        return $this->defaults ;
133
+    }
134
+    /**
135
+     * returns additional fields available for users to create fields
136
+     */
137
+    function getAdditionalFields ()
138
+    {
139
+        $this->additional = array ( ) ;
140
+        foreach ( $this->listViewDefs as $key => $def )
141
+        {
142
+            if (empty ( $def [ 'default' ] ))
143
+            {
144
+                $key = strtolower ( $key ) ;
145
+                $this->additional [ $key ] = $def ;
146
+            }
147
+        }
148
+        return $this->additional ;
149
+    }
150
+    /**
151
+     * returns unused fields that are available for using in either default or additional list views
152
+     */
153
+    function getAvailableFields ()
154
+    {
155
+        $this->availableFields = array ( ) ;
156
+        $lowerFieldList = array_change_key_case ( $this->listViewDefs ) ;
157
+        foreach ( $this->originalListViewDefs as $key => $def )
158
+        {
159
+            $key = strtolower ( $key ) ;
160
+            if (! isset ( $lowerFieldList [ $key ] ))
161
+            {
162
+                $this->availableFields [ $key ] = $def ;
163
+            }
164
+        }
165
+        $GLOBALS['log']->debug('parser.modifylistview.php->getAvailableFields(): field_defs='.print_r($this->availableFields,true));
166
+        $modFields = !empty($this->module->field_name_map) ? $this->module->field_name_map : $this->module->field_defs;
167
+        foreach ( $modFields as $key => $def )
168
+        {
169
+            $fieldName = strtolower ( $key ) ;
170 170
             if ($fieldName == 'currency_id')
171 171
                 continue;
172
-			if (!isset ( $lowerFieldList [ $fieldName ] )) // bug 16728 - check this first, so that other conditions (e.g., studio == visible) can't override and add duplicate entries
173
-			{
172
+            if (!isset ( $lowerFieldList [ $fieldName ] )) // bug 16728 - check this first, so that other conditions (e.g., studio == visible) can't override and add duplicate entries
173
+            {
174 174
             // bug 19656: this test changed after 5.0.0b - we now remove all ID type fields - whether set as type, or dbtype, from the fielddefs
175 175
             if ($this->isValidField($key, $def)){
176
-					$label = (isset ( $def [ 'vname' ] )) ? $def [ 'vname' ] : (isset($def [ 'label' ]) ? $def['label'] : $def['name']) ;
177
-					$this->availableFields [ $fieldName ] = array ( 'width' => '10' , 'label' => $label ) ;
178
-				}
179
-			}
180
-		}
176
+                    $label = (isset ( $def [ 'vname' ] )) ? $def [ 'vname' ] : (isset($def [ 'label' ]) ? $def['label'] : $def['name']) ;
177
+                    $this->availableFields [ $fieldName ] = array ( 'width' => '10' , 'label' => $label ) ;
178
+                }
179
+            }
180
+        }
181 181
 
182
-		return $this->availableFields ;
183
-	}
182
+        return $this->availableFields ;
183
+    }
184 184
 
185 185
     function getFieldDefs()
186 186
     {
@@ -188,146 +188,146 @@  discard block
 block discarded – undo
188 188
     }
189 189
 
190 190
 	
191
-	function isValidField($key, $def) {
192
-	    //Allow fields that are studio visible  
193
-		if (! empty ( $def [ 'studio' ] ) && $def [ 'studio' ] == 'visible')
194
-		  return true;
191
+    function isValidField($key, $def) {
192
+        //Allow fields that are studio visible  
193
+        if (! empty ( $def [ 'studio' ] ) && $def [ 'studio' ] == 'visible')
194
+            return true;
195 195
 		  
196
-		//No ID fields
197
-		if  ((!empty ( $def [ 'dbType' ] ) && $def [ 'dbType' ] == 'id') || (!empty ( $def [ 'type' ] ) && $def [ 'type' ] == 'id'))
198
-		  return false;
196
+        //No ID fields
197
+        if  ((!empty ( $def [ 'dbType' ] ) && $def [ 'dbType' ] == 'id') || (!empty ( $def [ 'type' ] ) && $def [ 'type' ] == 'id'))
198
+            return false;
199 199
 		  
200
-		//only allow DB and custom fields (if a source is specified)
201
-	    if (!empty($def [ 'source' ]) && $def [ 'source' ] != 'db' && $def [ 'source' ] != 'custom_fields')
202
-		  return false;
200
+        //only allow DB and custom fields (if a source is specified)
201
+        if (!empty($def [ 'source' ]) && $def [ 'source' ] != 'db' && $def [ 'source' ] != 'custom_fields')
202
+            return false;
203 203
 
204
-		//Dont ever show the "deleted" fields or "_name" fields
205
-		if (strcmp ( $key, 'deleted' ) == 0 || (isset ( $def [ 'name' ] ) && strpos ( $def [ 'name' ], "_name" ) !== false))
206
-	       return false;
204
+        //Dont ever show the "deleted" fields or "_name" fields
205
+        if (strcmp ( $key, 'deleted' ) == 0 || (isset ( $def [ 'name' ] ) && strpos ( $def [ 'name' ], "_name" ) !== false))
206
+            return false;
207 207
 
208
-	    //If none of the "ifs" are true, the field is valid
209
-	    return true;
210
-	}
208
+        //If none of the "ifs" are true, the field is valid
209
+        return true;
210
+    }
211 211
 	
212 212
 	
213
-	function getField ( $fieldName )
214
-	{
215
-		$fieldName = strtolower ( $fieldName ) ;
216
-		foreach ( $this->listViewDefs as $key => $def )
217
-		{
218
-			$key = strtolower ( $key ) ;
219
-			if ($key == $fieldName)
220
-			{
221
-				return $def ;
222
-			}
223
-		}
224
-		foreach ( $this->module->field_defs as $key => $def )
225
-		{
226
-			$key = strtolower ( $key ) ;
227
-			if ($key == $fieldName)
228
-			{
229
-				return $def ;
230
-			}
231
-		}
232
-		return array ( ) ;
233
-	}
234
-	function addRelateData($fieldname, $listfielddef) {
235
-		$modFieldDef = $this->module->field_defs [ strtolower ( $fieldname ) ];
236
-		if (!empty($modFieldDef['module']) && !empty($modFieldDef['id_name'])) {
237
-			$listfielddef['module'] = $modFieldDef['module'];
238
-			$listfielddef['id'] = strtoupper($modFieldDef['id_name']);
239
-			$listfielddef['link'] = true;
240
-			$listfielddef['related_fields'] = array (strtolower($modFieldDef['id_name']));
241
-		}
242
-		return $listfielddef;
243
-	}
244
-	function _loadLayoutFromRequest ()
245
-	{
246
-	    $GLOBALS['log']->debug("ParserModifyListView->_loadLayoutFromRequest()");
247
-		$fields = array ( ) ;
248
-		$rejectTypes = array ( 'html' , 'enum' , 'text' ) ;
249
-		for ( $i = 0 ; isset ( $_POST [ 'group_' . $i ] ) && $i < 2 ; $i ++ )
250
-		{
251
-			//echo "\n***group-$i Size:".sizeof($_POST['group_' . $i])."\n";
252
-			foreach ( $_POST [ 'group_' . $i ] as $field )
253
-			{
254
-				$fieldname = strtoupper ( $field ) ;
255
-				//originalListViewDefs are all lower case
256
-				$lowerFieldName = strtolower ( $field ) ;
257
-				if (isset ( $this->originalListViewDefs [ $lowerFieldName ] ))
258
-				{
259
-					$fields [ $fieldname ] = $this->originalListViewDefs [ $lowerFieldName ] ;
260
-				} else
261
-				{
262
-					//check if we have the case wrong for custom fields
263
-					if (! isset ( $this->module->field_defs [ $fieldname ] ))
264
-					{
265
-						foreach ( $this->module->field_defs as $key => $value )
266
-						{
267
-							if (strtoupper ( $key ) == $fieldname)
268
-							{
269
-								$fields [ $fieldname ] = array ( 'width' => 10 , 'label' => $this->module->field_defs [ $key ] [ 'vname' ] ) ;
270
-								break ;
271
-							}
272
-						}
273
-					} else
274
-					{
275
-						$fields [ $fieldname ] = array ( 'width' => 10 , 'label' => $this->module->field_defs [ $fieldname ] [ 'vname' ] ) ;
276
-					}
277
-					// sorting fields of certain types will cause a database engine problems
278
-					// we only check this for custom fields, as we assume that OOB fields have been independently confirmed as ok
279
-					if (isset ( $this->module->field_defs [ strtolower ( $fieldname ) ] ) && (in_array ( $this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type' ], $rejectTypes ) || isset($this->module->field_defs [ strtolower ( $fieldname ) ]['custom_module'])))
280
-					{
281
-						$fields [ $fieldname ] [ 'sortable' ] = false ;
282
-					}
283
-					// Bug 23728 - Make adding a currency type field default to setting the 'currency_format' to true
284
-					if (isset ( $this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type ' ] ) && $this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type' ] == 'currency') 
285
-					{
286
-						$fields [ $fieldname ] [ 'currency_format' ] = true;
287
-					}
288
-				}
289
-				if (isset ( $_REQUEST [ strtolower ( $fieldname ) . 'width' ] ))
290
-				{
291
-					$width = substr ( $_REQUEST [ strtolower ( $fieldname ) . 'width' ], 6, 3 ) ;
292
-					if (strpos ( $width, "%" ) !== false)
293
-					{
294
-						$width = substr ( $width, 0, 2 ) ;
295
-					}
296
-					if ($width < 101 && $width > 0)
297
-					{
298
-						$fields [ $fieldname ] [ 'width' ] = $width ;
299
-					}
300
-				} else if (isset ( $this->listViewDefs [ $fieldname ] [ 'width' ] ))
301
-				{
302
-					$fields [ $fieldname ] [ 'width' ] = $this->listViewDefs [ $fieldname ] [ 'width' ] ;
303
-				}
304
-				//Get additional Data for relate fields
305
-				if (isset($this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type' ]) && $this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type' ] == 'relate') {
306
-					$fields [ $fieldname ] = $this->addRelateData($field, $fields [ $fieldname ]);
307
-				}
308
-				$fields [ $fieldname ] [ 'default' ] = ($i == 0) ;
309
-			}
310
-		}
311
-		// Add the reserved fields back in to the end of the default fields in the layout
312
-		// ASSUMPTION: reserved fields go back at the end
313
-		// First, load the reserved fields - we cannot assume that getDefaultFields has been called earlier when saving
314
-		$this->getDefaultFields();
315
-		foreach ( $this->reserved as $key => $def)
316
-		{
317
-		    $fields[ $key ] = $def;
318
-		}
213
+    function getField ( $fieldName )
214
+    {
215
+        $fieldName = strtolower ( $fieldName ) ;
216
+        foreach ( $this->listViewDefs as $key => $def )
217
+        {
218
+            $key = strtolower ( $key ) ;
219
+            if ($key == $fieldName)
220
+            {
221
+                return $def ;
222
+            }
223
+        }
224
+        foreach ( $this->module->field_defs as $key => $def )
225
+        {
226
+            $key = strtolower ( $key ) ;
227
+            if ($key == $fieldName)
228
+            {
229
+                return $def ;
230
+            }
231
+        }
232
+        return array ( ) ;
233
+    }
234
+    function addRelateData($fieldname, $listfielddef) {
235
+        $modFieldDef = $this->module->field_defs [ strtolower ( $fieldname ) ];
236
+        if (!empty($modFieldDef['module']) && !empty($modFieldDef['id_name'])) {
237
+            $listfielddef['module'] = $modFieldDef['module'];
238
+            $listfielddef['id'] = strtoupper($modFieldDef['id_name']);
239
+            $listfielddef['link'] = true;
240
+            $listfielddef['related_fields'] = array (strtolower($modFieldDef['id_name']));
241
+        }
242
+        return $listfielddef;
243
+    }
244
+    function _loadLayoutFromRequest ()
245
+    {
246
+        $GLOBALS['log']->debug("ParserModifyListView->_loadLayoutFromRequest()");
247
+        $fields = array ( ) ;
248
+        $rejectTypes = array ( 'html' , 'enum' , 'text' ) ;
249
+        for ( $i = 0 ; isset ( $_POST [ 'group_' . $i ] ) && $i < 2 ; $i ++ )
250
+        {
251
+            //echo "\n***group-$i Size:".sizeof($_POST['group_' . $i])."\n";
252
+            foreach ( $_POST [ 'group_' . $i ] as $field )
253
+            {
254
+                $fieldname = strtoupper ( $field ) ;
255
+                //originalListViewDefs are all lower case
256
+                $lowerFieldName = strtolower ( $field ) ;
257
+                if (isset ( $this->originalListViewDefs [ $lowerFieldName ] ))
258
+                {
259
+                    $fields [ $fieldname ] = $this->originalListViewDefs [ $lowerFieldName ] ;
260
+                } else
261
+                {
262
+                    //check if we have the case wrong for custom fields
263
+                    if (! isset ( $this->module->field_defs [ $fieldname ] ))
264
+                    {
265
+                        foreach ( $this->module->field_defs as $key => $value )
266
+                        {
267
+                            if (strtoupper ( $key ) == $fieldname)
268
+                            {
269
+                                $fields [ $fieldname ] = array ( 'width' => 10 , 'label' => $this->module->field_defs [ $key ] [ 'vname' ] ) ;
270
+                                break ;
271
+                            }
272
+                        }
273
+                    } else
274
+                    {
275
+                        $fields [ $fieldname ] = array ( 'width' => 10 , 'label' => $this->module->field_defs [ $fieldname ] [ 'vname' ] ) ;
276
+                    }
277
+                    // sorting fields of certain types will cause a database engine problems
278
+                    // we only check this for custom fields, as we assume that OOB fields have been independently confirmed as ok
279
+                    if (isset ( $this->module->field_defs [ strtolower ( $fieldname ) ] ) && (in_array ( $this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type' ], $rejectTypes ) || isset($this->module->field_defs [ strtolower ( $fieldname ) ]['custom_module'])))
280
+                    {
281
+                        $fields [ $fieldname ] [ 'sortable' ] = false ;
282
+                    }
283
+                    // Bug 23728 - Make adding a currency type field default to setting the 'currency_format' to true
284
+                    if (isset ( $this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type ' ] ) && $this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type' ] == 'currency') 
285
+                    {
286
+                        $fields [ $fieldname ] [ 'currency_format' ] = true;
287
+                    }
288
+                }
289
+                if (isset ( $_REQUEST [ strtolower ( $fieldname ) . 'width' ] ))
290
+                {
291
+                    $width = substr ( $_REQUEST [ strtolower ( $fieldname ) . 'width' ], 6, 3 ) ;
292
+                    if (strpos ( $width, "%" ) !== false)
293
+                    {
294
+                        $width = substr ( $width, 0, 2 ) ;
295
+                    }
296
+                    if ($width < 101 && $width > 0)
297
+                    {
298
+                        $fields [ $fieldname ] [ 'width' ] = $width ;
299
+                    }
300
+                } else if (isset ( $this->listViewDefs [ $fieldname ] [ 'width' ] ))
301
+                {
302
+                    $fields [ $fieldname ] [ 'width' ] = $this->listViewDefs [ $fieldname ] [ 'width' ] ;
303
+                }
304
+                //Get additional Data for relate fields
305
+                if (isset($this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type' ]) && $this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type' ] == 'relate') {
306
+                    $fields [ $fieldname ] = $this->addRelateData($field, $fields [ $fieldname ]);
307
+                }
308
+                $fields [ $fieldname ] [ 'default' ] = ($i == 0) ;
309
+            }
310
+        }
311
+        // Add the reserved fields back in to the end of the default fields in the layout
312
+        // ASSUMPTION: reserved fields go back at the end
313
+        // First, load the reserved fields - we cannot assume that getDefaultFields has been called earlier when saving
314
+        $this->getDefaultFields();
315
+        foreach ( $this->reserved as $key => $def)
316
+        {
317
+            $fields[ $key ] = $def;
318
+        }
319 319
 		
320
-		return $fields ;
321
-	}
322
-	function handleSave ()
323
-	{
324
-		$fields = $this->_loadLayoutFromRequest();
325
-		$this->_writeToFile($this->customFile,'ListView',$this->module_name,$fields,$this->_variables);
320
+        return $fields ;
321
+    }
322
+    function handleSave ()
323
+    {
324
+        $fields = $this->_loadLayoutFromRequest();
325
+        $this->_writeToFile($this->customFile,'ListView',$this->module_name,$fields,$this->_variables);
326 326
 
327
-		$GLOBALS [ "listViewDefs" ] [ $this->module_name ] = $fields ;
328
-		// now clear the cache so that the results are immediately visible
329
-		include_once ('include/TemplateHandler/TemplateHandler.php') ;
330
-		TemplateHandler::clearCache ( $this->module_name, "ListView.tpl" ) ; // not currently cached, but here for the future
331
-	}
327
+        $GLOBALS [ "listViewDefs" ] [ $this->module_name ] = $fields ;
328
+        // now clear the cache so that the results are immediately visible
329
+        include_once ('include/TemplateHandler/TemplateHandler.php') ;
330
+        TemplateHandler::clearCache ( $this->module_name, "ListView.tpl" ) ; // not currently cached, but here for the future
331
+    }
332 332
 }
333 333
 ?>
Please login to merge, or discard this patch.
modules/SchedulersJobs/field_arrays.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -40,23 +40,23 @@
 block discarded – undo
40 40
 
41 41
 
42 42
 $fields_array['Schedulers_jobs'] = array (
43
-	'column_fields' => array (
44
-		'id',
45
-		'deleted',
46
-		'date_entered',
47
-		'date_modified',
48
-		'job_id',
49
-		'execute_time',
50
-		'status',
51
-	),
52
-	'list_fields' => array (
53
-		'id',
54
-		'job_id',
55
-		'execute_time'
56
-	),
57
-	'required_fields' => array (
58
-		'job_id' => 1,
59
-		'execute_time' => 1
60
-	)
43
+    'column_fields' => array (
44
+        'id',
45
+        'deleted',
46
+        'date_entered',
47
+        'date_modified',
48
+        'job_id',
49
+        'execute_time',
50
+        'status',
51
+    ),
52
+    'list_fields' => array (
53
+        'id',
54
+        'job_id',
55
+        'execute_time'
56
+    ),
57
+    'required_fields' => array (
58
+        'job_id' => 1,
59
+        'execute_time' => 1
60
+    )
61 61
 );
62 62
 ?>
Please login to merge, or discard this patch.
modules/Import/maps/ImportMapOutlook.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
 
50 50
 class ImportMapOutlook extends ImportMapOther
51 51
 {
52
-	/**
52
+    /**
53 53
      * String identifier for this import
54 54
      */
55 55
     public $name = 'outlook';
56
-	/**
56
+    /**
57 57
      * Field delimiter
58 58
      */
59 59
     public $delimiter = ',';
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      * Field enclosure
62 62
      */
63 63
     public $enclosure = '"';
64
-	/**
64
+    /**
65 65
      * Do we have a header?
66 66
      */
67 67
     public $has_header = true;
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      * @param  string $module
73 73
      * @return array field mappings
74 74
      */
75
-	public function getMapping(
75
+    public function getMapping(
76 76
         $module
77 77
         )
78 78
     {
Please login to merge, or discard this patch.
modules/Import/maps/ImportMapGoogle.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
 class ImportMapGoogle extends ImportMapOther
46 46
 {
47
-	/**
47
+    /**
48 48
      * String identifier for this import
49 49
      */
50 50
     public $name = 'google';
@@ -55,38 +55,38 @@  discard block
 block discarded – undo
55 55
      * @param  string $module
56 56
      * @return array field mappings
57 57
      */
58
-	public function getMapping($module)
58
+    public function getMapping($module)
59 59
     {
60
-         $return_array = array(
61
-             'first_name' => array('sugar_key' => 'first_name', 'sugar_label' => '', 'default_label' => 'Given Name'),
62
-             'last_name' => array('sugar_key' => 'last_name', 'sugar_label' => '', 'default_label' => 'Family Name'),
63
-             'birthday' => array('sugar_key' => 'birthdate', 'sugar_label' => '', 'default_label' => 'Birthday'),
64
-             'title' => array('sugar_key' => 'title', 'sugar_label' => '', 'default_label' => 'Title'),
65
-             'notes' => array('sugar_key' => 'description', 'sugar_label' => '', 'default_label' => 'Notes'),
60
+            $return_array = array(
61
+                'first_name' => array('sugar_key' => 'first_name', 'sugar_label' => '', 'default_label' => 'Given Name'),
62
+                'last_name' => array('sugar_key' => 'last_name', 'sugar_label' => '', 'default_label' => 'Family Name'),
63
+                'birthday' => array('sugar_key' => 'birthdate', 'sugar_label' => '', 'default_label' => 'Birthday'),
64
+                'title' => array('sugar_key' => 'title', 'sugar_label' => '', 'default_label' => 'Title'),
65
+                'notes' => array('sugar_key' => 'description', 'sugar_label' => '', 'default_label' => 'Notes'),
66 66
 
67
-             'alt_address_street' => array('sugar_key' => 'alt_address_street', 'sugar_label' => '', 'default_label' => 'Home Street'),
68
-             'alt_address_postcode' => array('sugar_key' => 'alt_address_postalcode', 'sugar_label' => '', 'default_label' => 'Home Postcode'),
69
-             'alt_address_city' => array('sugar_key' => 'alt_address_city', 'sugar_label' => '', 'default_label' => 'Home City'),
70
-             'alt_address_state' => array('sugar_key' => 'alt_address_state', 'sugar_label' => '', 'default_label' => 'Home State'),
71
-             'alt_address_country' => array('sugar_key' => 'alt_address_country', 'sugar_label' => '', 'default_label' => 'Home Country'),
67
+                'alt_address_street' => array('sugar_key' => 'alt_address_street', 'sugar_label' => '', 'default_label' => 'Home Street'),
68
+                'alt_address_postcode' => array('sugar_key' => 'alt_address_postalcode', 'sugar_label' => '', 'default_label' => 'Home Postcode'),
69
+                'alt_address_city' => array('sugar_key' => 'alt_address_city', 'sugar_label' => '', 'default_label' => 'Home City'),
70
+                'alt_address_state' => array('sugar_key' => 'alt_address_state', 'sugar_label' => '', 'default_label' => 'Home State'),
71
+                'alt_address_country' => array('sugar_key' => 'alt_address_country', 'sugar_label' => '', 'default_label' => 'Home Country'),
72 72
 
73
-             'primary_address_street' => array('sugar_key' => 'primary_address_street', 'sugar_label' => '', 'default_label' => 'Work Street'),
74
-             'primary_address_postcode' => array('sugar_key' => 'primary_address_postalcode', 'sugar_label' => '', 'default_label' => 'Work Postcode'),
75
-             'primary_address_city' => array('sugar_key' => 'primary_address_city', 'sugar_label' => '', 'default_label' => 'Work City'),
76
-             'primary_address_state' => array('sugar_key' => 'primary_address_state', 'sugar_label' => '', 'default_label' => 'Work State'),
77
-             'primary_address_country' => array('sugar_key' => 'primary_address_country', 'sugar_label' => '', 'default_label' => 'Work Country'),
73
+                'primary_address_street' => array('sugar_key' => 'primary_address_street', 'sugar_label' => '', 'default_label' => 'Work Street'),
74
+                'primary_address_postcode' => array('sugar_key' => 'primary_address_postalcode', 'sugar_label' => '', 'default_label' => 'Work Postcode'),
75
+                'primary_address_city' => array('sugar_key' => 'primary_address_city', 'sugar_label' => '', 'default_label' => 'Work City'),
76
+                'primary_address_state' => array('sugar_key' => 'primary_address_state', 'sugar_label' => '', 'default_label' => 'Work State'),
77
+                'primary_address_country' => array('sugar_key' => 'primary_address_country', 'sugar_label' => '', 'default_label' => 'Work Country'),
78 78
 
79
-             'phone_main' => array('sugar_key' => 'phone_other', 'sugar_label' => '', 'default_label' => 'Main Phone'),
80
-             'phone_mobile' => array('sugar_key' => 'phone_mobile', 'sugar_label' => '', 'default_label' => 'Mobile Phone'),
81
-             'phone_home' => array('sugar_key' => 'phone_home', 'sugar_label' => '', 'default_label' => 'Home phone'),
82
-             'phone_work' => array('sugar_key' => 'phone_work', 'sugar_label' => '', 'default_label' => 'Work phone'),
83
-             'phone_fax' => array('sugar_key' => 'phone_fax', 'sugar_label' => '', 'default_label' => 'Fax phone'),
79
+                'phone_main' => array('sugar_key' => 'phone_other', 'sugar_label' => '', 'default_label' => 'Main Phone'),
80
+                'phone_mobile' => array('sugar_key' => 'phone_mobile', 'sugar_label' => '', 'default_label' => 'Mobile Phone'),
81
+                'phone_home' => array('sugar_key' => 'phone_home', 'sugar_label' => '', 'default_label' => 'Home phone'),
82
+                'phone_work' => array('sugar_key' => 'phone_work', 'sugar_label' => '', 'default_label' => 'Work phone'),
83
+                'phone_fax' => array('sugar_key' => 'phone_fax', 'sugar_label' => '', 'default_label' => 'Fax phone'),
84 84
 
85
-             'email1' => array('sugar_key' => 'email1', 'sugar_label' => 'LBL_EMAIL_ADDRESS', 'default_label' => 'Email Address'),
86
-             'email2' => array('sugar_key' => 'email2', 'sugar_label' => 'LBL_OTHER_EMAIL_ADDRESS', 'default_label' => 'Other Email'),
85
+                'email1' => array('sugar_key' => 'email1', 'sugar_label' => 'LBL_EMAIL_ADDRESS', 'default_label' => 'Email Address'),
86
+                'email2' => array('sugar_key' => 'email2', 'sugar_label' => 'LBL_OTHER_EMAIL_ADDRESS', 'default_label' => 'Other Email'),
87 87
 
88
-             'assigned_user_name' => array('sugar_key' => 'assigned_user_name', 'sugar_help_key' => 'LBL_EXTERNAL_ASSIGNED_TOOLTIP', 'sugar_label' => 'LBL_ASSIGNED_TO_NAME', 'default_label' => 'Assigned To'),
89
-             'team_name' => array('sugar_key' => 'team_name', 'sugar_help_key' => 'LBL_EXTERNAL_TEAM_TOOLTIP','sugar_label' => 'LBL_TEAMS', 'default_label' => 'Teams'),
88
+                'assigned_user_name' => array('sugar_key' => 'assigned_user_name', 'sugar_help_key' => 'LBL_EXTERNAL_ASSIGNED_TOOLTIP', 'sugar_label' => 'LBL_ASSIGNED_TO_NAME', 'default_label' => 'Assigned To'),
89
+                'team_name' => array('sugar_key' => 'team_name', 'sugar_help_key' => 'LBL_EXTERNAL_TEAM_TOOLTIP','sugar_label' => 'LBL_TEAMS', 'default_label' => 'Teams'),
90 90
             );
91 91
 
92 92
         if($module == 'Users')
Please login to merge, or discard this patch.
modules/Import/maps/ImportMapSalesforce.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
 
50 50
 class ImportMapSalesforce extends ImportMapOther
51 51
 {
52
-	/**
52
+    /**
53 53
      * String identifier for this import
54 54
      */
55 55
     public $name = 'salesforce';
56
-	/**
56
+    /**
57 57
      * Field delimiter
58 58
      */
59 59
     public $delimiter = ',';
@@ -61,18 +61,18 @@  discard block
 block discarded – undo
61 61
      * Field enclosure
62 62
      */
63 63
     public $enclosure = '"';
64
-	/**
64
+    /**
65 65
      * Do we have a header?
66 66
      */
67 67
     public $has_header = true;
68 68
 
69
-	/**
69
+    /**
70 70
      * Gets the default mapping for a module
71 71
      *
72 72
      * @param  string $module
73 73
      * @return array field mappings
74 74
      */
75
-	public function getMapping(
75
+    public function getMapping(
76 76
         $module
77 77
         )
78 78
     {
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
         }
152 152
     }
153 153
 	
154
-	/**
155
-	* @see ImportMapOther::getIgnoredFields()
154
+    /**
155
+     * @see ImportMapOther::getIgnoredFields()
156 156
      */
157
-	public function getIgnoredFields(
158
-		$module
159
-		)
160
-	{
161
-		return array_merge(parent::getIgnoredFields($module),array('id'));
162
-	}
157
+    public function getIgnoredFields(
158
+        $module
159
+        )
160
+    {
161
+        return array_merge(parent::getIgnoredFields($module),array('id'));
162
+    }
163 163
 }
164 164
 
165 165
 
Please login to merge, or discard this patch.
modules/Import/maps/ImportMapOther.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
 
48 48
 class ImportMapOther
49 49
 {
50
-	/**
50
+    /**
51 51
      * String identifier for this import
52 52
      */
53 53
     public $name = 'other';
54
-	/**
54
+    /**
55 55
      * Field delimiter
56 56
      */
57 57
     public $delimiter;
@@ -59,18 +59,18 @@  discard block
 block discarded – undo
59 59
      * Field enclosure
60 60
      */
61 61
     public $enclosure;
62
-	/**
62
+    /**
63 63
      * Do we have a header?
64 64
      */
65 65
     public $has_header = true;
66 66
 
67
-	/**
67
+    /**
68 68
      * Gets the default mapping for a module
69 69
      *
70 70
      * @param  string $module
71 71
      * @return array field mappings
72 72
      */
73
-	public function getMapping(
73
+    public function getMapping(
74 74
         $module
75 75
         )
76 76
     {
@@ -142,18 +142,18 @@  discard block
 block discarded – undo
142 142
         }
143 143
     }
144 144
 	
145
-	/**
145
+    /**
146 146
      * Returns a list of fields that should be ignorred for the module during import
147 147
      *
148 148
      * @param  string $module
149 149
      * @return array of fields to ignor
150 150
      */
151
-	public function getIgnoredFields(
152
-		$module
153
-		)
154
-	{
155
-		return array();
156
-	}
151
+    public function getIgnoredFields(
152
+        $module
153
+        )
154
+    {
155
+        return array();
156
+    }
157 157
 }
158 158
 
159 159
 
Please login to merge, or discard this patch.
modules/Import/maps/ImportMap.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -175,19 +175,19 @@  discard block
 block discarded – undo
175 175
      * @see SugarBean::retrieve()
176 176
      */
177 177
     public function retrieve($id = -1, $encode=true,$deleted=true)
178
-	{
179
-	    $returnVal = parent::retrieve($id,$encode,$deleted);
178
+    {
179
+        $returnVal = parent::retrieve($id,$encode,$deleted);
180 180
 
181
-	    if ( !($returnVal instanceOf $this) ) {
182
-	        return $returnVal;
183
-	    }
181
+        if ( !($returnVal instanceOf $this) ) {
182
+            return $returnVal;
183
+        }
184 184
 
185
-	    if ( $this->source == 'tab' && $this->delimiter == '' ) {
186
-	        $this->delimiter = "\t";
187
-	    }
185
+        if ( $this->source == 'tab' && $this->delimiter == '' ) {
186
+            $this->delimiter = "\t";
187
+        }
188 188
 
189
-	    return $this;
190
-	}
189
+        return $this;
190
+    }
191 191
 
192 192
     /**
193 193
      * Save
@@ -372,10 +372,10 @@  discard block
 block discarded – undo
372 372
         //list of field values we track during import wizard
373 373
         $import_step_fields = array(
374 374
         //step1
375
-          //  'import_module', 'source', 'custom_enclosure', 'custom_enclosure_other', 'custom_delimiter', 'type',
375
+            //  'import_module', 'source', 'custom_enclosure', 'custom_enclosure_other', 'custom_delimiter', 'type',
376 376
         //step2
377
-           // 'custom_delimiter', 'custom_enclosure', 'type', 'source', 'source_id', 'import_module', 'has_header',
378
-         //step3
377
+            // 'custom_delimiter', 'custom_enclosure', 'type', 'source', 'source_id', 'import_module', 'has_header',
378
+            //step3
379 379
             'display_tabs_def','custom_delimiter', 'custom_enclosure', 'import_type', 'source', 'source_id', 'import_module', 'has_header', 'importlocale_charset',
380 380
             'importlocale_dateformat', 'importlocale_timeformat', 'importlocale_timezone', 'importlocale_currency',
381 381
             'importlocale_default_currency_significant_digits', 'importlocale_num_grp_sep', 'importlocale_dec_sep',
Please login to merge, or discard this patch.
modules/Cases/metadata/accountsquickcreatedefs.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -40,39 +40,39 @@
 block discarded – undo
40 40
 $viewdefs['Cases']['AccountsQuickCreate'] = array(
41 41
 'templateMeta' => array('form' => 
42 42
                             array (
43
-                              'hidden' => 
44
-                              array (
43
+                                'hidden' => 
44
+                                array (
45 45
                                 0 => '<input type="hidden" name="account_id" value="{$smarty.request.account_id}">',
46 46
                                 1 => '<input type="hidden" name="account_name" value="{$smarty.request.account_name}">',
47
-                              ),
47
+                                ),
48 48
                             ),
49 49
                         'maxColumns' => '2', 
50 50
                         'widths' => array(
51 51
                                         array('label' => '10', 'field' => '30'), 
52 52
                                         array('label' => '10', 'field' => '30')
53 53
                                         ),
54
-                       ),
54
+                        ),
55 55
 'panels' =>
56 56
 
57 57
 array (
58 58
   
59
-  array (
59
+    array (
60 60
     array ('name'=>'name', 'displayParams'=>array('size'=>65, 'required'=>true)),
61 61
     'priority'
62
-  ),
62
+    ),
63 63
   
64
-  array (
64
+    array (
65 65
     'status',
66 66
     array('name'=>'account_name', 'type'=>'readonly'),
67
-  ),
67
+    ),
68 68
   
69
-  array (
70 69
     array (
71
-      'name' => 'description',
72
-      'displayParams' => array ('rows' => '4','cols' => '60'),
73
-      'nl2br' => true,
70
+    array (
71
+        'name' => 'description',
72
+        'displayParams' => array ('rows' => '4','cols' => '60'),
73
+        'nl2br' => true,
74
+    ),
74 75
     ),
75
-  ),
76 76
 
77 77
 ),
78 78
 
Please login to merge, or discard this patch.