@@ -43,144 +43,144 @@ discard block |
||
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 |
||
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 | ?> |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined ( 'sugarEntry' ) || ! sugarEntry) |
|
3 | -die ( 'Not A Valid Entry Point' ) ; |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) |
|
3 | +die ('Not A Valid Entry Point'); |
|
4 | 4 | /********************************************************************************* |
5 | 5 | * SugarCRM Community Edition is a customer relationship management program developed by |
6 | 6 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -40,43 +40,43 @@ discard block |
||
40 | 40 | ********************************************************************************/ |
41 | 41 | |
42 | 42 | |
43 | -require_once ('modules/ModuleBuilder/parsers/ModuleBuilderParser.php') ; |
|
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 ( ) ; |
|
46 | + var $listViewDefs = false; |
|
47 | + var $defaults = array( ); |
|
48 | + var $additional = array( ); |
|
49 | + var $available = array( ); |
|
50 | 50 | var $reserved = array(); // fields marked by 'studio'=>false in the listviewdefs; need to be preserved |
51 | 51 | // var $language_module = ''; |
52 | - var $columns = array ( 'LBL_DEFAULT' => 'getDefaultFields' , 'LBL_AVAILABLE' => 'getAdditionalFields' , 'LBL_HIDDEN' => 'getAvailableFields' ) ; |
|
53 | - function init ( $module_name , $submodule = '' ) |
|
52 | + var $columns = array('LBL_DEFAULT' => 'getDefaultFields', 'LBL_AVAILABLE' => 'getAdditionalFields', 'LBL_HIDDEN' => 'getAvailableFields'); |
|
53 | + function init($module_name, $submodule = '') |
|
54 | 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 ( ) ; |
|
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 ] ; |
|
62 | + $loaded = $this->_loadFromFile('ListView', 'modules/'.$this->module_name.'/metadata/listviewdefs.php', $this->module_name); |
|
63 | + $this->originalListViewDefs = $loaded['viewdefs'] [$this->module_name]; |
|
64 | 64 | $this->_variables = $loaded['variables']; |
65 | 65 | // _pp($loaded); |
66 | - $this->customFile = 'custom/modules/' . $this->module_name . '/metadata/listviewdefs.php' ; |
|
67 | - if (file_exists ( $this->customFile )) |
|
66 | + $this->customFile = 'custom/modules/'.$this->module_name.'/metadata/listviewdefs.php'; |
|
67 | + if (file_exists($this->customFile)) |
|
68 | 68 | { |
69 | - $loaded = $this->_loadFromFile('ListView',$this->customFile,$this->module_name); |
|
70 | - $this->listViewDefs = $loaded['viewdefs'] [ $this->module_name ] ; |
|
69 | + $loaded = $this->_loadFromFile('ListView', $this->customFile, $this->module_name); |
|
70 | + $this->listViewDefs = $loaded['viewdefs'] [$this->module_name]; |
|
71 | 71 | $this->_variables = $loaded['variables']; |
72 | 72 | } else |
73 | 73 | { |
74 | - $this->listViewDefs = & $this->originalListViewDefs ; |
|
74 | + $this->listViewDefs = & $this->originalListViewDefs; |
|
75 | 75 | } |
76 | 76 | |
77 | - $this->fixKeys ( $this->originalListViewDefs ) ; |
|
78 | - $this->fixKeys ( $this->listViewDefs ) ; |
|
79 | - $this->language_module = $this->module_name ; |
|
77 | + $this->fixKeys($this->originalListViewDefs); |
|
78 | + $this->fixKeys($this->listViewDefs); |
|
79 | + $this->language_module = $this->module_name; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | function getLanguage() |
@@ -84,102 +84,102 @@ discard block |
||
84 | 84 | return $this->language_module; |
85 | 85 | } |
86 | 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 ) |
|
87 | + function fixKeys(&$defs) |
|
88 | 88 | { |
89 | - $temp = array ( ) ; |
|
90 | - foreach ( $defs as $key => $value ) |
|
89 | + $temp = array( ); |
|
90 | + foreach ($defs as $key => $value) |
|
91 | 91 | { |
92 | - if (! is_array ( $value )) |
|
92 | + if (!is_array($value)) |
|
93 | 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 ; |
|
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 | 98 | } |
99 | - if (isset ( $value [ 'name' ] )) |
|
99 | + if (isset ($value ['name'])) |
|
100 | 100 | { |
101 | - $key = $value [ 'name' ] ; // override key with name, needed when the entry lacks a key |
|
101 | + $key = $value ['name']; // override key with name, needed when the entry lacks a key |
|
102 | 102 | } |
103 | - $temp [ strtolower ( $key ) ] = $value ; |
|
103 | + $temp [strtolower($key)] = $value; |
|
104 | 104 | } |
105 | - $defs = $temp ; |
|
105 | + $defs = $temp; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
109 | 109 | * returns the default fields for a listview |
110 | 110 | * Called only when displaying the listview for editing; not called when saving |
111 | 111 | */ |
112 | - function getDefaultFields () |
|
112 | + function getDefaultFields() |
|
113 | 113 | { |
114 | - $this->defaults = array ( ) ; |
|
115 | - foreach ( $this->listViewDefs as $key => $def ) |
|
114 | + $this->defaults = array( ); |
|
115 | + foreach ($this->listViewDefs as $key => $def) |
|
116 | 116 | { |
117 | 117 | // add in the default fields from the listviewdefs, stripping out any field with 'studio' set to a value other than true |
118 | 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' ] )) |
|
119 | + if (!empty ($def ['default'])) |
|
120 | 120 | { |
121 | - if (! isset($def['studio']) || $def['studio'] === true) |
|
121 | + if (!isset($def['studio']) || $def['studio'] === true) |
|
122 | 122 | { |
123 | - $this->defaults [ $key ] = $def ; |
|
123 | + $this->defaults [$key] = $def; |
|
124 | 124 | } |
125 | 125 | else |
126 | 126 | // anything which doesn't go into the defaults is a reserved field - this makes sure we don't miss anything |
127 | 127 | { |
128 | - $this->reserved [ $key ] = $def; |
|
128 | + $this->reserved [$key] = $def; |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | } |
132 | - return $this->defaults ; |
|
132 | + return $this->defaults; |
|
133 | 133 | } |
134 | 134 | /** |
135 | 135 | * returns additional fields available for users to create fields |
136 | 136 | */ |
137 | - function getAdditionalFields () |
|
137 | + function getAdditionalFields() |
|
138 | 138 | { |
139 | - $this->additional = array ( ) ; |
|
140 | - foreach ( $this->listViewDefs as $key => $def ) |
|
139 | + $this->additional = array( ); |
|
140 | + foreach ($this->listViewDefs as $key => $def) |
|
141 | 141 | { |
142 | - if (empty ( $def [ 'default' ] )) |
|
142 | + if (empty ($def ['default'])) |
|
143 | 143 | { |
144 | - $key = strtolower ( $key ) ; |
|
145 | - $this->additional [ $key ] = $def ; |
|
144 | + $key = strtolower($key); |
|
145 | + $this->additional [$key] = $def; |
|
146 | 146 | } |
147 | 147 | } |
148 | - return $this->additional ; |
|
148 | + return $this->additional; |
|
149 | 149 | } |
150 | 150 | /** |
151 | 151 | * returns unused fields that are available for using in either default or additional list views |
152 | 152 | */ |
153 | - function getAvailableFields () |
|
153 | + function getAvailableFields() |
|
154 | 154 | { |
155 | - $this->availableFields = array ( ) ; |
|
156 | - $lowerFieldList = array_change_key_case ( $this->listViewDefs ) ; |
|
157 | - foreach ( $this->originalListViewDefs as $key => $def ) |
|
155 | + $this->availableFields = array( ); |
|
156 | + $lowerFieldList = array_change_key_case($this->listViewDefs); |
|
157 | + foreach ($this->originalListViewDefs as $key => $def) |
|
158 | 158 | { |
159 | - $key = strtolower ( $key ) ; |
|
160 | - if (! isset ( $lowerFieldList [ $key ] )) |
|
159 | + $key = strtolower($key); |
|
160 | + if (!isset ($lowerFieldList [$key])) |
|
161 | 161 | { |
162 | - $this->availableFields [ $key ] = $def ; |
|
162 | + $this->availableFields [$key] = $def; |
|
163 | 163 | } |
164 | 164 | } |
165 | - $GLOBALS['log']->debug('parser.modifylistview.php->getAvailableFields(): field_defs='.print_r($this->availableFields,true)); |
|
165 | + $GLOBALS['log']->debug('parser.modifylistview.php->getAvailableFields(): field_defs='.print_r($this->availableFields, true)); |
|
166 | 166 | $modFields = !empty($this->module->field_name_map) ? $this->module->field_name_map : $this->module->field_defs; |
167 | - foreach ( $modFields as $key => $def ) |
|
167 | + foreach ($modFields as $key => $def) |
|
168 | 168 | { |
169 | - $fieldName = strtolower ( $key ) ; |
|
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 |
|
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 | 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 | - 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 ) ; |
|
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 | 178 | } |
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | - return $this->availableFields ; |
|
182 | + return $this->availableFields; |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | function getFieldDefs() |
@@ -190,19 +190,19 @@ discard block |
||
190 | 190 | |
191 | 191 | function isValidField($key, $def) { |
192 | 192 | //Allow fields that are studio visible |
193 | - if (! empty ( $def [ 'studio' ] ) && $def [ 'studio' ] == 'visible') |
|
193 | + if (!empty ($def ['studio']) && $def ['studio'] == 'visible') |
|
194 | 194 | return true; |
195 | 195 | |
196 | 196 | //No ID fields |
197 | - if ((!empty ( $def [ 'dbType' ] ) && $def [ 'dbType' ] == 'id') || (!empty ( $def [ 'type' ] ) && $def [ 'type' ] == 'id')) |
|
197 | + if ((!empty ($def ['dbType']) && $def ['dbType'] == 'id') || (!empty ($def ['type']) && $def ['type'] == 'id')) |
|
198 | 198 | return false; |
199 | 199 | |
200 | 200 | //only allow DB and custom fields (if a source is specified) |
201 | - if (!empty($def [ 'source' ]) && $def [ 'source' ] != 'db' && $def [ 'source' ] != 'custom_fields') |
|
201 | + if (!empty($def ['source']) && $def ['source'] != 'db' && $def ['source'] != 'custom_fields') |
|
202 | 202 | return false; |
203 | 203 | |
204 | 204 | //Dont ever show the "deleted" fields or "_name" fields |
205 | - if (strcmp ( $key, 'deleted' ) == 0 || (isset ( $def [ 'name' ] ) && strpos ( $def [ 'name' ], "_name" ) !== false)) |
|
205 | + if (strcmp($key, 'deleted') == 0 || (isset ($def ['name']) && strpos($def ['name'], "_name") !== false)) |
|
206 | 206 | return false; |
207 | 207 | |
208 | 208 | //If none of the "ifs" are true, the field is valid |
@@ -210,124 +210,124 @@ discard block |
||
210 | 210 | } |
211 | 211 | |
212 | 212 | |
213 | - function getField ( $fieldName ) |
|
213 | + function getField($fieldName) |
|
214 | 214 | { |
215 | - $fieldName = strtolower ( $fieldName ) ; |
|
216 | - foreach ( $this->listViewDefs as $key => $def ) |
|
215 | + $fieldName = strtolower($fieldName); |
|
216 | + foreach ($this->listViewDefs as $key => $def) |
|
217 | 217 | { |
218 | - $key = strtolower ( $key ) ; |
|
218 | + $key = strtolower($key); |
|
219 | 219 | if ($key == $fieldName) |
220 | 220 | { |
221 | - return $def ; |
|
221 | + return $def; |
|
222 | 222 | } |
223 | 223 | } |
224 | - foreach ( $this->module->field_defs as $key => $def ) |
|
224 | + foreach ($this->module->field_defs as $key => $def) |
|
225 | 225 | { |
226 | - $key = strtolower ( $key ) ; |
|
226 | + $key = strtolower($key); |
|
227 | 227 | if ($key == $fieldName) |
228 | 228 | { |
229 | - return $def ; |
|
229 | + return $def; |
|
230 | 230 | } |
231 | 231 | } |
232 | - return array ( ) ; |
|
232 | + return array( ); |
|
233 | 233 | } |
234 | 234 | function addRelateData($fieldname, $listfielddef) { |
235 | - $modFieldDef = $this->module->field_defs [ strtolower ( $fieldname ) ]; |
|
235 | + $modFieldDef = $this->module->field_defs [strtolower($fieldname)]; |
|
236 | 236 | if (!empty($modFieldDef['module']) && !empty($modFieldDef['id_name'])) { |
237 | 237 | $listfielddef['module'] = $modFieldDef['module']; |
238 | 238 | $listfielddef['id'] = strtoupper($modFieldDef['id_name']); |
239 | 239 | $listfielddef['link'] = true; |
240 | - $listfielddef['related_fields'] = array (strtolower($modFieldDef['id_name'])); |
|
240 | + $listfielddef['related_fields'] = array(strtolower($modFieldDef['id_name'])); |
|
241 | 241 | } |
242 | 242 | return $listfielddef; |
243 | 243 | } |
244 | - function _loadLayoutFromRequest () |
|
244 | + function _loadLayoutFromRequest() |
|
245 | 245 | { |
246 | 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 ++ ) |
|
247 | + $fields = array( ); |
|
248 | + $rejectTypes = array('html', 'enum', 'text'); |
|
249 | + for ($i = 0; isset ($_POST ['group_'.$i]) && $i < 2; $i++) |
|
250 | 250 | { |
251 | 251 | //echo "\n***group-$i Size:".sizeof($_POST['group_' . $i])."\n"; |
252 | - foreach ( $_POST [ 'group_' . $i ] as $field ) |
|
252 | + foreach ($_POST ['group_'.$i] as $field) |
|
253 | 253 | { |
254 | - $fieldname = strtoupper ( $field ) ; |
|
254 | + $fieldname = strtoupper($field); |
|
255 | 255 | //originalListViewDefs are all lower case |
256 | - $lowerFieldName = strtolower ( $field ) ; |
|
257 | - if (isset ( $this->originalListViewDefs [ $lowerFieldName ] )) |
|
256 | + $lowerFieldName = strtolower($field); |
|
257 | + if (isset ($this->originalListViewDefs [$lowerFieldName])) |
|
258 | 258 | { |
259 | - $fields [ $fieldname ] = $this->originalListViewDefs [ $lowerFieldName ] ; |
|
259 | + $fields [$fieldname] = $this->originalListViewDefs [$lowerFieldName]; |
|
260 | 260 | } else |
261 | 261 | { |
262 | 262 | //check if we have the case wrong for custom fields |
263 | - if (! isset ( $this->module->field_defs [ $fieldname ] )) |
|
263 | + if (!isset ($this->module->field_defs [$fieldname])) |
|
264 | 264 | { |
265 | - foreach ( $this->module->field_defs as $key => $value ) |
|
265 | + foreach ($this->module->field_defs as $key => $value) |
|
266 | 266 | { |
267 | - if (strtoupper ( $key ) == $fieldname) |
|
267 | + if (strtoupper($key) == $fieldname) |
|
268 | 268 | { |
269 | - $fields [ $fieldname ] = array ( 'width' => 10 , 'label' => $this->module->field_defs [ $key ] [ 'vname' ] ) ; |
|
270 | - break ; |
|
269 | + $fields [$fieldname] = array('width' => 10, 'label' => $this->module->field_defs [$key] ['vname']); |
|
270 | + break; |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | } else |
274 | 274 | { |
275 | - $fields [ $fieldname ] = array ( 'width' => 10 , 'label' => $this->module->field_defs [ $fieldname ] [ 'vname' ] ) ; |
|
275 | + $fields [$fieldname] = array('width' => 10, 'label' => $this->module->field_defs [$fieldname] ['vname']); |
|
276 | 276 | } |
277 | 277 | // sorting fields of certain types will cause a database engine problems |
278 | 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']))) |
|
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 | 280 | { |
281 | - $fields [ $fieldname ] [ 'sortable' ] = false ; |
|
281 | + $fields [$fieldname] ['sortable'] = false; |
|
282 | 282 | } |
283 | 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') |
|
284 | + if (isset ($this->module->field_defs [strtolower($fieldname)] ['type ']) && $this->module->field_defs [strtolower($fieldname)] ['type'] == 'currency') |
|
285 | 285 | { |
286 | - $fields [ $fieldname ] [ 'currency_format' ] = true; |
|
286 | + $fields [$fieldname] ['currency_format'] = true; |
|
287 | 287 | } |
288 | 288 | } |
289 | - if (isset ( $_REQUEST [ strtolower ( $fieldname ) . 'width' ] )) |
|
289 | + if (isset ($_REQUEST [strtolower($fieldname).'width'])) |
|
290 | 290 | { |
291 | - $width = substr ( $_REQUEST [ strtolower ( $fieldname ) . 'width' ], 6, 3 ) ; |
|
292 | - if (strpos ( $width, "%" ) !== false) |
|
291 | + $width = substr($_REQUEST [strtolower($fieldname).'width'], 6, 3); |
|
292 | + if (strpos($width, "%") !== false) |
|
293 | 293 | { |
294 | - $width = substr ( $width, 0, 2 ) ; |
|
294 | + $width = substr($width, 0, 2); |
|
295 | 295 | } |
296 | 296 | if ($width < 101 && $width > 0) |
297 | 297 | { |
298 | - $fields [ $fieldname ] [ 'width' ] = $width ; |
|
298 | + $fields [$fieldname] ['width'] = $width; |
|
299 | 299 | } |
300 | - } else if (isset ( $this->listViewDefs [ $fieldname ] [ 'width' ] )) |
|
300 | + } else if (isset ($this->listViewDefs [$fieldname] ['width'])) |
|
301 | 301 | { |
302 | - $fields [ $fieldname ] [ 'width' ] = $this->listViewDefs [ $fieldname ] [ 'width' ] ; |
|
302 | + $fields [$fieldname] ['width'] = $this->listViewDefs [$fieldname] ['width']; |
|
303 | 303 | } |
304 | 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 ]); |
|
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 | 307 | } |
308 | - $fields [ $fieldname ] [ 'default' ] = ($i == 0) ; |
|
308 | + $fields [$fieldname] ['default'] = ($i == 0); |
|
309 | 309 | } |
310 | 310 | } |
311 | 311 | // Add the reserved fields back in to the end of the default fields in the layout |
312 | 312 | // ASSUMPTION: reserved fields go back at the end |
313 | 313 | // First, load the reserved fields - we cannot assume that getDefaultFields has been called earlier when saving |
314 | 314 | $this->getDefaultFields(); |
315 | - foreach ( $this->reserved as $key => $def) |
|
315 | + foreach ($this->reserved as $key => $def) |
|
316 | 316 | { |
317 | - $fields[ $key ] = $def; |
|
317 | + $fields[$key] = $def; |
|
318 | 318 | } |
319 | 319 | |
320 | - return $fields ; |
|
320 | + return $fields; |
|
321 | 321 | } |
322 | - function handleSave () |
|
322 | + function handleSave() |
|
323 | 323 | { |
324 | 324 | $fields = $this->_loadLayoutFromRequest(); |
325 | - $this->_writeToFile($this->customFile,'ListView',$this->module_name,$fields,$this->_variables); |
|
325 | + $this->_writeToFile($this->customFile, 'ListView', $this->module_name, $fields, $this->_variables); |
|
326 | 326 | |
327 | - $GLOBALS [ "listViewDefs" ] [ $this->module_name ] = $fields ; |
|
327 | + $GLOBALS ["listViewDefs"] [$this->module_name] = $fields; |
|
328 | 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 |
|
329 | + include_once ('include/TemplateHandler/TemplateHandler.php'); |
|
330 | + TemplateHandler::clearCache($this->module_name, "ListView.tpl"); // not currently cached, but here for the future |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | ?> |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined ( 'sugarEntry' ) || ! sugarEntry) |
|
3 | -die ( 'Not A Valid Entry Point' ) ; |
|
2 | +if (! defined ( 'sugarEntry' ) || ! sugarEntry) { |
|
3 | + die ( 'Not A Valid Entry Point' ) ; |
|
4 | +} |
|
4 | 5 | /********************************************************************************* |
5 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
6 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -121,8 +122,7 @@ discard block |
||
121 | 122 | if (! isset($def['studio']) || $def['studio'] === true) |
122 | 123 | { |
123 | 124 | $this->defaults [ $key ] = $def ; |
124 | - } |
|
125 | - else |
|
125 | + } else |
|
126 | 126 | // anything which doesn't go into the defaults is a reserved field - this makes sure we don't miss anything |
127 | 127 | { |
128 | 128 | $this->reserved [ $key ] = $def; |
@@ -167,13 +167,16 @@ discard block |
||
167 | 167 | foreach ( $modFields as $key => $def ) |
168 | 168 | { |
169 | 169 | $fieldName = strtolower ( $key ) ; |
170 | - if ($fieldName == 'currency_id') |
|
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 |
|
170 | + if ($fieldName == 'currency_id') { |
|
171 | + continue; |
|
172 | + } |
|
173 | + if (!isset ( $lowerFieldList [ $fieldName ] )) { |
|
174 | + // bug 16728 - check this first, so that other conditions (e.g., studio == visible) can't override and add duplicate entries |
|
173 | 175 | { |
174 | 176 | // 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 | 177 | if ($this->isValidField($key, $def)){ |
176 | 178 | $label = (isset ( $def [ 'vname' ] )) ? $def [ 'vname' ] : (isset($def [ 'label' ]) ? $def['label'] : $def['name']) ; |
179 | + } |
|
177 | 180 | $this->availableFields [ $fieldName ] = array ( 'width' => '10' , 'label' => $label ) ; |
178 | 181 | } |
179 | 182 | } |
@@ -190,20 +193,24 @@ discard block |
||
190 | 193 | |
191 | 194 | function isValidField($key, $def) { |
192 | 195 | //Allow fields that are studio visible |
193 | - if (! empty ( $def [ 'studio' ] ) && $def [ 'studio' ] == 'visible') |
|
194 | - return true; |
|
196 | + if (! empty ( $def [ 'studio' ] ) && $def [ 'studio' ] == 'visible') { |
|
197 | + return true; |
|
198 | + } |
|
195 | 199 | |
196 | 200 | //No ID fields |
197 | - if ((!empty ( $def [ 'dbType' ] ) && $def [ 'dbType' ] == 'id') || (!empty ( $def [ 'type' ] ) && $def [ 'type' ] == 'id')) |
|
198 | - return false; |
|
201 | + if ((!empty ( $def [ 'dbType' ] ) && $def [ 'dbType' ] == 'id') || (!empty ( $def [ 'type' ] ) && $def [ 'type' ] == 'id')) { |
|
202 | + return false; |
|
203 | + } |
|
199 | 204 | |
200 | 205 | //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; |
|
206 | + if (!empty($def [ 'source' ]) && $def [ 'source' ] != 'db' && $def [ 'source' ] != 'custom_fields') { |
|
207 | + return false; |
|
208 | + } |
|
203 | 209 | |
204 | 210 | //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; |
|
211 | + if (strcmp ( $key, 'deleted' ) == 0 || (isset ( $def [ 'name' ] ) && strpos ( $def [ 'name' ], "_name" ) !== false)) { |
|
212 | + return false; |
|
213 | + } |
|
207 | 214 | |
208 | 215 | //If none of the "ifs" are true, the field is valid |
209 | 216 | return true; |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | 'table'=>'aor_fields', |
27 | 27 | 'audited'=>false, |
28 | 28 | 'duplicate_merge'=>true, |
29 | - 'fields'=>array ( |
|
29 | + 'fields'=>array( |
|
30 | 30 | 'aor_report_id' => |
31 | - array ( |
|
31 | + array( |
|
32 | 32 | 'required' => false, |
33 | 33 | 'name' => 'aor_report_id', |
34 | 34 | 'vname' => 'LBL_AOR_REPORT_ID', |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | 'size' => '20', |
48 | 48 | ), |
49 | 49 | 'field_order' => |
50 | - array ( |
|
50 | + array( |
|
51 | 51 | 'required' => false, |
52 | 52 | 'name' => 'field_order', |
53 | 53 | 'vname' => 'LBL_ORDER', |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | 'disable_num_format' => '', |
69 | 69 | ), |
70 | 70 | 'module_path' => |
71 | - array ( |
|
71 | + array( |
|
72 | 72 | 'name' => 'module_path', |
73 | 73 | 'type' => 'longtext', |
74 | 74 | 'vname' => 'LBL_MODULE_PATH', |
75 | 75 | 'isnull' => true, |
76 | 76 | ), |
77 | 77 | 'field' => |
78 | - array ( |
|
78 | + array( |
|
79 | 79 | 'required' => false, |
80 | 80 | 'name' => 'field', |
81 | 81 | 'vname' => 'LBL_FIELD', |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | 'dependency' => false, |
98 | 98 | ), |
99 | 99 | 'display' => |
100 | - array ( |
|
100 | + array( |
|
101 | 101 | 'required' => false, |
102 | 102 | 'name' => 'display', |
103 | 103 | 'vname' => 'LBL_DISPLAY', |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | 'studio' => 'visible', |
116 | 116 | ), |
117 | 117 | 'link' => |
118 | - array ( |
|
118 | + array( |
|
119 | 119 | 'required' => false, |
120 | 120 | 'name' => 'link', |
121 | 121 | 'vname' => 'LBL_LINK', |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | 'studio' => 'visible', |
134 | 134 | ), |
135 | 135 | 'label' => |
136 | - array ( |
|
136 | + array( |
|
137 | 137 | 'required' => false, |
138 | 138 | 'name' => 'label', |
139 | 139 | 'vname' => 'LBL_LABEL', |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | 'size' => '20', |
153 | 153 | ), |
154 | 154 | 'field_function' => |
155 | - array ( |
|
155 | + array( |
|
156 | 156 | 'required' => false, |
157 | 157 | 'name' => 'field_function', |
158 | 158 | 'vname' => 'LBL_FUNCTION', |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | 'dependency' => false, |
175 | 175 | ), |
176 | 176 | 'sort_by' => |
177 | - array ( |
|
177 | + array( |
|
178 | 178 | 'required' => false, |
179 | 179 | 'name' => 'sort_by', |
180 | 180 | 'vname' => 'LBL_SORT', |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | 'dependency' => false, |
197 | 197 | ), |
198 | 198 | 'format' => |
199 | - array ( |
|
199 | + array( |
|
200 | 200 | 'required' => false, |
201 | 201 | 'name' => 'format', |
202 | 202 | 'vname' => 'LBL_FORMAT', |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | 'dependency' => false, |
219 | 219 | ), |
220 | 220 | 'total' => |
221 | - array ( |
|
221 | + array( |
|
222 | 222 | 'required' => false, |
223 | 223 | 'name' => 'total', |
224 | 224 | 'vname' => 'LBL_TOTAL', |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | 'dependency' => false, |
241 | 241 | ), |
242 | 242 | 'sort_order' => |
243 | - array ( |
|
243 | + array( |
|
244 | 244 | 'required' => false, |
245 | 245 | 'name' => 'sort_order', |
246 | 246 | 'vname' => 'LBL_SORT_ORDER', |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | 'dependency' => false, |
263 | 263 | ), |
264 | 264 | 'group_by' => |
265 | - array ( |
|
265 | + array( |
|
266 | 266 | 'required' => false, |
267 | 267 | 'name' => 'group_by', |
268 | 268 | 'vname' => 'LBL_GROUP', |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | 'studio' => 'visible', |
281 | 281 | ), |
282 | 282 | 'group_order' => |
283 | - array ( |
|
283 | + array( |
|
284 | 284 | 'required' => false, |
285 | 285 | 'name' => 'group_order', |
286 | 286 | 'vname' => 'LBL_GROUP_ORDER', |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | 'dependency' => false, |
303 | 303 | ), |
304 | 304 | 'group_display' => |
305 | - array ( |
|
305 | + array( |
|
306 | 306 | 'required' => false, |
307 | 307 | 'name' => 'group_display', |
308 | 308 | 'vname' => 'LBL_GROUP_DISPLAY', |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | 'studio' => 'visible', |
321 | 321 | ), |
322 | 322 | 'aor_reports' => |
323 | - array ( |
|
323 | + array( |
|
324 | 324 | 'name' => 'aor_reports', |
325 | 325 | 'type' => 'link', |
326 | 326 | 'relationship' => 'aor_report_aor_fields', |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | 'source'=>'non-db', |
330 | 330 | ), |
331 | 331 | ), |
332 | - 'relationships'=>array ( |
|
332 | + 'relationships'=>array( |
|
333 | 333 | ), |
334 | 334 | 'indices' => array( |
335 | 335 | array( |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | 'optimistic_locking'=>true, |
342 | 342 | 'unified_search'=>true, |
343 | 343 | ); |
344 | -if (!class_exists('VardefManager')){ |
|
344 | +if (!class_exists('VardefManager')) { |
|
345 | 345 | require_once('include/SugarObjects/VardefManager.php'); |
346 | 346 | } |
347 | -VardefManager::createVardef('AOR_Fields','AOR_Field', array('basic')); |
|
347 | +VardefManager::createVardef('AOR_Fields', 'AOR_Field', array('basic')); |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | $dictionary['AOR_Field'] = array( |
26 | - 'table'=>'aor_fields', |
|
27 | - 'audited'=>false, |
|
28 | - 'duplicate_merge'=>true, |
|
29 | - 'fields'=>array ( |
|
26 | + 'table'=>'aor_fields', |
|
27 | + 'audited'=>false, |
|
28 | + 'duplicate_merge'=>true, |
|
29 | + 'fields'=>array ( |
|
30 | 30 | 'aor_report_id' => |
31 | 31 | array ( |
32 | 32 | 'required' => false, |
@@ -338,8 +338,8 @@ discard block |
||
338 | 338 | 'fields' => array('aor_report_id'), |
339 | 339 | ), |
340 | 340 | ), |
341 | - 'optimistic_locking'=>true, |
|
342 | - 'unified_search'=>true, |
|
341 | + 'optimistic_locking'=>true, |
|
342 | + 'unified_search'=>true, |
|
343 | 343 | ); |
344 | 344 | if (!class_exists('VardefManager')){ |
345 | 345 | require_once('include/SugarObjects/VardefManager.php'); |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | parent::Basic(); |
61 | 61 | } |
62 | 62 | |
63 | - public function bean_implements($interface){ |
|
64 | - switch($interface){ |
|
63 | + public function bean_implements($interface) { |
|
64 | + switch ($interface) { |
|
65 | 65 | case 'ACL': return true; |
66 | 66 | } |
67 | 67 | return false; |
@@ -75,13 +75,13 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public static function saveRemindersInviteesData($reminderId, $inviteesData) { |
77 | 77 | $savedInviteeIds = array(); |
78 | - foreach($inviteesData as $k => $inviteeData) { |
|
79 | - if(isset($_POST['isDuplicate']) && $_POST['isDuplicate']) $inviteeData->id = ''; |
|
78 | + foreach ($inviteesData as $k => $inviteeData) { |
|
79 | + if (isset($_POST['isDuplicate']) && $_POST['isDuplicate']) $inviteeData->id = ''; |
|
80 | 80 | $reminderInviteeBean = BeanFactory::getBean('Reminders_Invitees', $inviteeData->id); |
81 | 81 | $reminderInviteeBean->reminder_id = $reminderId; |
82 | 82 | $reminderInviteeBean->related_invitee_module = $inviteeData->module; |
83 | 83 | $reminderInviteeBean->related_invitee_module_id = $inviteeData->module_id; |
84 | - if(!$inviteeData->id) { |
|
84 | + if (!$inviteeData->id) { |
|
85 | 85 | $reminderInviteeBean->save(); |
86 | 86 | $savedInviteeIds[] = $reminderInviteeBean->id; |
87 | 87 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $ret = array(); |
109 | 109 | $reminderInviteeBeen = new Reminder_Invitee(); |
110 | 110 | $reminderInvitees = $reminderInviteeBeen->get_full_list("reminders_invitees.date_entered", "reminders_invitees.reminder_id = '$reminderId'"); |
111 | - if($reminderInvitees) { |
|
111 | + if ($reminderInvitees) { |
|
112 | 112 | foreach ($reminderInvitees as $reminderInvitee) { |
113 | 113 | $ret[] = array( |
114 | 114 | 'id' => $isDuplicate ? null : $reminderInvitee->id, |
@@ -125,21 +125,21 @@ discard block |
||
125 | 125 | $retValue = "unknown"; |
126 | 126 | |
127 | 127 | $bean = BeanFactory::getBean($module, $moduleId); |
128 | - switch($module) { |
|
128 | + switch ($module) { |
|
129 | 129 | case 'Users': |
130 | 130 | case 'Contacts': |
131 | 131 | case 'Leads': |
132 | 132 | default: |
133 | - if(isset($bean->first_name) && isset($bean->last_name)) { |
|
133 | + if (isset($bean->first_name) && isset($bean->last_name)) { |
|
134 | 134 | $retValue = "{$bean->first_name} {$bean->last_name}"; |
135 | 135 | } |
136 | - else if(isset($bean->name)) { |
|
136 | + else if (isset($bean->name)) { |
|
137 | 137 | $retValue = $bean->name; |
138 | 138 | } |
139 | - else if(isset($bean->email)) { |
|
139 | + else if (isset($bean->email)) { |
|
140 | 140 | $retValue = $bean->email; |
141 | 141 | } |
142 | - if(!$retValue) { |
|
142 | + if (!$retValue) { |
|
143 | 143 | $retValue = "$module ($moduleId)"; |
144 | 144 | } |
145 | 145 | break; |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public static function deleteRemindersInviteesMultiple($reminderId, $inviteeIds = array()) { |
157 | 157 | $invitees = BeanFactory::getBean('Reminders_Invitees')->get_full_list("", "reminders_invitees.reminder_id = '$reminderId'"); |
158 | - if($invitees) { |
|
158 | + if ($invitees) { |
|
159 | 159 | foreach ($invitees as $invitee) { |
160 | 160 | if (!in_array($invitee->id, $inviteeIds)) { |
161 | 161 | $invitee->mark_deleted($invitee->id); |
@@ -76,7 +76,9 @@ discard block |
||
76 | 76 | public static function saveRemindersInviteesData($reminderId, $inviteesData) { |
77 | 77 | $savedInviteeIds = array(); |
78 | 78 | foreach($inviteesData as $k => $inviteeData) { |
79 | - if(isset($_POST['isDuplicate']) && $_POST['isDuplicate']) $inviteeData->id = ''; |
|
79 | + if(isset($_POST['isDuplicate']) && $_POST['isDuplicate']) { |
|
80 | + $inviteeData->id = ''; |
|
81 | + } |
|
80 | 82 | $reminderInviteeBean = BeanFactory::getBean('Reminders_Invitees', $inviteeData->id); |
81 | 83 | $reminderInviteeBean->reminder_id = $reminderId; |
82 | 84 | $reminderInviteeBean->related_invitee_module = $inviteeData->module; |
@@ -84,8 +86,7 @@ discard block |
||
84 | 86 | if(!$inviteeData->id) { |
85 | 87 | $reminderInviteeBean->save(); |
86 | 88 | $savedInviteeIds[] = $reminderInviteeBean->id; |
87 | - } |
|
88 | - else { |
|
89 | + } else { |
|
89 | 90 | $addedInvitees = BeanFactory::getBean('Reminders_Invitees')->get_full_list("", "reminders_invitees.id != '{$inviteeData->id}' AND reminders_invitees.reminder_id = '{$reminderInviteeBean->reminder_id}' AND reminders_invitees.related_invitee_module = '{$reminderInviteeBean->related_invitee_module}' AND reminders_invitees.related_invitee_module_id = '{$reminderInviteeBean->related_invitee_module_id}'"); |
90 | 91 | if (!$addedInvitees) { |
91 | 92 | $reminderInviteeBean->save(); |
@@ -132,11 +133,9 @@ discard block |
||
132 | 133 | default: |
133 | 134 | if(isset($bean->first_name) && isset($bean->last_name)) { |
134 | 135 | $retValue = "{$bean->first_name} {$bean->last_name}"; |
135 | - } |
|
136 | - else if(isset($bean->name)) { |
|
136 | + } else if(isset($bean->name)) { |
|
137 | 137 | $retValue = $bean->name; |
138 | - } |
|
139 | - else if(isset($bean->email)) { |
|
138 | + } else if(isset($bean->email)) { |
|
140 | 139 | $retValue = $bean->email; |
141 | 140 | } |
142 | 141 | if(!$retValue) { |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | return false; |
68 | 68 | } |
69 | 69 | |
70 | - /** |
|
71 | - * Save multiple reminders invitees data. |
|
72 | - * |
|
73 | - * @param string $reminderId Related Reminder GUID |
|
74 | - * @param array $inviteesData Invitees Data |
|
75 | - */ |
|
70 | + /** |
|
71 | + * Save multiple reminders invitees data. |
|
72 | + * |
|
73 | + * @param string $reminderId Related Reminder GUID |
|
74 | + * @param array $inviteesData Invitees Data |
|
75 | + */ |
|
76 | 76 | public static function saveRemindersInviteesData($reminderId, $inviteesData) { |
77 | 77 | $savedInviteeIds = array(); |
78 | 78 | foreach($inviteesData as $k => $inviteeData) { |
@@ -98,16 +98,16 @@ discard block |
||
98 | 98 | self::deleteRemindersInviteesMultiple($reminderId, $savedInviteeIds); |
99 | 99 | } |
100 | 100 | |
101 | - /** |
|
102 | - * Load reminders invitees data. |
|
103 | - * |
|
104 | - * @param string $reminderId Related Reminder GUID |
|
105 | - * @return array Invitees data |
|
106 | - */ |
|
107 | - public static function loadRemindersInviteesData($reminderId, $isDuplicate = false) { |
|
108 | - $ret = array(); |
|
109 | - $reminderInviteeBeen = new Reminder_Invitee(); |
|
110 | - $reminderInvitees = $reminderInviteeBeen->get_full_list("reminders_invitees.date_entered", "reminders_invitees.reminder_id = '$reminderId'"); |
|
101 | + /** |
|
102 | + * Load reminders invitees data. |
|
103 | + * |
|
104 | + * @param string $reminderId Related Reminder GUID |
|
105 | + * @return array Invitees data |
|
106 | + */ |
|
107 | + public static function loadRemindersInviteesData($reminderId, $isDuplicate = false) { |
|
108 | + $ret = array(); |
|
109 | + $reminderInviteeBeen = new Reminder_Invitee(); |
|
110 | + $reminderInvitees = $reminderInviteeBeen->get_full_list("reminders_invitees.date_entered", "reminders_invitees.reminder_id = '$reminderId'"); |
|
111 | 111 | if($reminderInvitees) { |
112 | 112 | foreach ($reminderInvitees as $reminderInvitee) { |
113 | 113 | $ret[] = array( |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | ); |
119 | 119 | } |
120 | 120 | } |
121 | - return $ret; |
|
122 | - } |
|
121 | + return $ret; |
|
122 | + } |
|
123 | 123 | |
124 | 124 | private static function getInviteeName($module, $moduleId) { |
125 | 125 | $retValue = "unknown"; |
@@ -147,12 +147,12 @@ discard block |
||
147 | 147 | return $retValue; |
148 | 148 | } |
149 | 149 | |
150 | - /** |
|
151 | - * Delete reminders invitees multiple. |
|
152 | - * |
|
153 | - * @param string $reminderId Related Reminder GUID |
|
154 | - * @param array $inviteeIds (optional) Exluded Invitees GUIDs, the invitee will not deleted if this argument contains that. Default is empty array. |
|
155 | - */ |
|
150 | + /** |
|
151 | + * Delete reminders invitees multiple. |
|
152 | + * |
|
153 | + * @param string $reminderId Related Reminder GUID |
|
154 | + * @param array $inviteeIds (optional) Exluded Invitees GUIDs, the invitee will not deleted if this argument contains that. Default is empty array. |
|
155 | + */ |
|
156 | 156 | public static function deleteRemindersInviteesMultiple($reminderId, $inviteeIds = array()) { |
157 | 157 | $invitees = BeanFactory::getBean('Reminders_Invitees')->get_full_list("", "reminders_invitees.reminder_id = '$reminderId'"); |
158 | 158 | if($invitees) { |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $bDate = $b->fetched_row['date_entered']; |
160 | 160 | if($aDate < $bDate){ |
161 | 161 | return -1; |
162 | - }elseif($aDate > $bDate){ |
|
162 | + } elseif($aDate > $bDate){ |
|
163 | 163 | return 1; |
164 | 164 | } |
165 | 165 | return 0; |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | global $mod_strings; |
196 | 196 | if($update->contact_id){ |
197 | 197 | $name = $update->getUpdateContact()->name; |
198 | - }elseif($update->assigned_user_id){ |
|
198 | + } elseif($update->assigned_user_id){ |
|
199 | 199 | $name = $update->getUpdateUser()->name; |
200 | - }else{ |
|
200 | + } else{ |
|
201 | 201 | $name = "Unknown"; |
202 | 202 | } |
203 | 203 | $html = "<a href='' onclick='toggleCaseUpdate(\"".$update->id."\");return false;'>"; |
@@ -281,7 +281,9 @@ discard block |
||
281 | 281 | global $action; |
282 | 282 | |
283 | 283 | //on DetailView only |
284 | - if($action != 'DetailView') return; |
|
284 | + if($action != 'DetailView') { |
|
285 | + return; |
|
286 | + } |
|
285 | 287 | |
286 | 288 | //current record id |
287 | 289 | $record = $_GET['record']; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | |
26 | -function display_updates($focus, $field, $value, $view){ |
|
26 | +function display_updates($focus, $field, $value, $view) { |
|
27 | 27 | global $mod_strings; |
28 | 28 | |
29 | 29 | $hideImage = SugarThemeRegistry::current()->getImageURL('basic_search.gif'); |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | </script> |
128 | 128 | A; |
129 | 129 | |
130 | - $updates = $focus->get_linked_beans('aop_case_updates',"AOP_Case_Updates"); |
|
131 | - if(!$updates || is_null($focus->id)){ |
|
130 | + $updates = $focus->get_linked_beans('aop_case_updates', "AOP_Case_Updates"); |
|
131 | + if (!$updates || is_null($focus->id)) { |
|
132 | 132 | $html .= quick_edit_case_updates($focus); |
133 | 133 | return $html; |
134 | 134 | //return $mod_strings['LBL_NO_CASE_UPDATES']; |
@@ -154,18 +154,18 @@ discard block |
||
154 | 154 | EOD; |
155 | 155 | |
156 | 156 | |
157 | - usort($updates,function($a,$b){ |
|
157 | + usort($updates, function($a, $b) { |
|
158 | 158 | $aDate = $a->fetched_row['date_entered']; |
159 | 159 | $bDate = $b->fetched_row['date_entered']; |
160 | - if($aDate < $bDate){ |
|
160 | + if ($aDate < $bDate) { |
|
161 | 161 | return -1; |
162 | - }elseif($aDate > $bDate){ |
|
162 | + }elseif ($aDate > $bDate) { |
|
163 | 163 | return 1; |
164 | 164 | } |
165 | 165 | return 0; |
166 | 166 | }); |
167 | 167 | |
168 | - foreach($updates as $update){ |
|
168 | + foreach ($updates as $update) { |
|
169 | 169 | $html .= display_single_update($update, $hideImage); |
170 | 170 | } |
171 | 171 | $html .= "</div>"; |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | /** |
179 | 179 | * @return mixed|string|void |
180 | 180 | */ |
181 | -function display_update_form(){ |
|
181 | +function display_update_form() { |
|
182 | 182 | global $mod_strings, $app_strings; |
183 | - $sugar_smarty = new Sugar_Smarty(); |
|
183 | + $sugar_smarty = new Sugar_Smarty(); |
|
184 | 184 | $sugar_smarty->assign('MOD', $mod_strings); |
185 | 185 | $sugar_smarty->assign('APP', $app_strings); |
186 | 186 | return $sugar_smarty->fetch('modules/AOP_Case_Updates/tpl/caseUpdateForm.tpl'); |
@@ -191,23 +191,23 @@ discard block |
||
191 | 191 | * @param SugarBean $update |
192 | 192 | * @return string - html to be displayed |
193 | 193 | */ |
194 | -function getUpdateDisplayHead(SugarBean $update){ |
|
194 | +function getUpdateDisplayHead(SugarBean $update) { |
|
195 | 195 | global $mod_strings; |
196 | - if($update->contact_id){ |
|
196 | + if ($update->contact_id) { |
|
197 | 197 | $name = $update->getUpdateContact()->name; |
198 | - }elseif($update->assigned_user_id){ |
|
198 | + }elseif ($update->assigned_user_id) { |
|
199 | 199 | $name = $update->getUpdateUser()->name; |
200 | - }else{ |
|
200 | + } else { |
|
201 | 201 | $name = "Unknown"; |
202 | 202 | } |
203 | 203 | $html = "<a href='' onclick='toggleCaseUpdate(\"".$update->id."\");return false;'>"; |
204 | 204 | $html .= "<img id='caseUpdate".$update->id."Image' class='caseUpdateImage' src='".SugarThemeRegistry::current()->getImageURL('basic_search.gif')."'>"; |
205 | 205 | $html .= "</a>"; |
206 | - $html .= "<span>".($update->internal ? "<strong>" . $mod_strings['LBL_INTERNAL'] . "</strong> " : '') .$name . " ".$update->date_entered."</span><br>"; |
|
207 | - $notes = $update->get_linked_beans('notes','Notes'); |
|
208 | - if($notes){ |
|
209 | - $html.= $mod_strings['LBL_AOP_CASE_ATTACHMENTS']; |
|
210 | - foreach($notes as $note){ |
|
206 | + $html .= "<span>".($update->internal ? "<strong>".$mod_strings['LBL_INTERNAL']."</strong> " : '').$name." ".$update->date_entered."</span><br>"; |
|
207 | + $notes = $update->get_linked_beans('notes', 'Notes'); |
|
208 | + if ($notes) { |
|
209 | + $html .= $mod_strings['LBL_AOP_CASE_ATTACHMENTS']; |
|
210 | + foreach ($notes as $note) { |
|
211 | 211 | $html .= "<a href='index.php?module=Notes&action=DetailView&record={$note->id}'>{$note->filename}</a> "; |
212 | 212 | } |
213 | 213 | } |
@@ -220,12 +220,12 @@ discard block |
||
220 | 220 | * @param AOP_Case_Updates $update |
221 | 221 | * @return string - the html for the update |
222 | 222 | */ |
223 | -function display_single_update(AOP_Case_Updates $update){ |
|
223 | +function display_single_update(AOP_Case_Updates $update) { |
|
224 | 224 | |
225 | 225 | /*if assigned user*/ |
226 | - if($update->assigned_user_id){ |
|
226 | + if ($update->assigned_user_id) { |
|
227 | 227 | /*if internal update*/ |
228 | - if ($update->internal){ |
|
228 | + if ($update->internal) { |
|
229 | 229 | $html = "<div id='caseStyleInternal'>".getUpdateDisplayHead($update); |
230 | 230 | $html .= "<div id='caseUpdate".$update->id."' class='caseUpdate'>"; |
231 | 231 | $html .= nl2br(html_entity_decode($update->description)); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | } |
244 | 244 | |
245 | 245 | /*if contact user*/ |
246 | - if($update->contact_id){ |
|
246 | + if ($update->contact_id) { |
|
247 | 247 | $html = "<div id='extramargin'><div id='caseStyleContact'>".getUpdateDisplayHead($update); |
248 | 248 | $html .= "<div id='caseUpdate".$update->id."' class='caseUpdate'>"; |
249 | 249 | $html .= nl2br(html_entity_decode($update->description)); |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | * @param $case |
260 | 260 | * @return string - html link |
261 | 261 | */ |
262 | -function display_case_attachments($case){ |
|
262 | +function display_case_attachments($case) { |
|
263 | 263 | $html = ''; |
264 | - $notes = $case->get_linked_beans('notes','Notes'); |
|
265 | - if($notes){ |
|
266 | - foreach($notes as $note){ |
|
264 | + $notes = $case->get_linked_beans('notes', 'Notes'); |
|
265 | + if ($notes) { |
|
266 | + foreach ($notes as $note) { |
|
267 | 267 | $html .= "<a href='index.php?module=Notes&action=DetailView&record={$note->id}'>{$note->filename}</a> "; |
268 | 268 | } |
269 | 269 | } |
@@ -277,11 +277,11 @@ discard block |
||
277 | 277 | * |
278 | 278 | * @return string - the html to be displayed and javascript |
279 | 279 | */ |
280 | -function quick_edit_case_updates($case){ |
|
280 | +function quick_edit_case_updates($case) { |
|
281 | 281 | global $action; |
282 | 282 | |
283 | 283 | //on DetailView only |
284 | - if($action != 'DetailView') return; |
|
284 | + if ($action != 'DetailView') return; |
|
285 | 285 | |
286 | 286 | //current record id |
287 | 287 | $record = $_GET['record']; |
@@ -294,12 +294,12 @@ discard block |
||
294 | 294 | $roles = $acl->getUserRoles($id); |
295 | 295 | |
296 | 296 | //Return if user cannot edit cases |
297 | - if(in_array( "no edit cases", $roles) || $roles === "no edit cases"){ |
|
297 | + if (in_array("no edit cases", $roles) || $roles === "no edit cases") { |
|
298 | 298 | |
299 | 299 | return; |
300 | 300 | } |
301 | 301 | $internalChecked = ''; |
302 | - if($case->internal){ |
|
302 | + if ($case->internal) { |
|
303 | 303 | $internalChecked = "checked='checked'"; |
304 | 304 | } |
305 | 305 | $html = <<< EOD |
@@ -1,76 +1,76 @@ discard block |
||
1 | 1 | <?php |
2 | -class AOPAssignManager{ |
|
2 | +class AOPAssignManager { |
|
3 | 3 | private $ieX = false; |
4 | 4 | private $distributionMethod = ''; |
5 | 5 | private $aopFallback = true; |
6 | 6 | private $assignableUsers = array(); |
7 | 7 | |
8 | - function __construct($ieX = false){ |
|
8 | + function __construct($ieX = false) { |
|
9 | 9 | global $sugar_config; |
10 | 10 | $this->ieX = $ieX; |
11 | - if($ieX) { |
|
11 | + if ($ieX) { |
|
12 | 12 | $inboundDistribMethod = $ieX->get_stored_options("distrib_method", ""); |
13 | - }else{ |
|
13 | + } else { |
|
14 | 14 | $inboundDistribMethod = ''; |
15 | 15 | } |
16 | - if($this->isAOPFallback($inboundDistribMethod)){ |
|
16 | + if ($this->isAOPFallback($inboundDistribMethod)) { |
|
17 | 17 | $this->distributionMethod = $sugar_config['aop']['distribution_method']; |
18 | 18 | $this->aopFallback = true; |
19 | - }else{ |
|
19 | + } else { |
|
20 | 20 | $this->distributionMethod = $inboundDistribMethod; |
21 | 21 | $this->aopFallback = false; |
22 | 22 | } |
23 | 23 | $this->assignableUsers = $this->getAssignableUsers(); |
24 | 24 | } |
25 | 25 | |
26 | - private function isAOPFallback($distribMethod){ |
|
26 | + private function isAOPFallback($distribMethod) { |
|
27 | 27 | return empty($distribMethod) || $distribMethod == 'AOPDefault'; |
28 | 28 | } |
29 | 29 | |
30 | - private function getDistributionOptions(){ |
|
30 | + private function getDistributionOptions() { |
|
31 | 31 | global $sugar_config; |
32 | - if($this->aopFallback){ |
|
32 | + if ($this->aopFallback) { |
|
33 | 33 | return $sugar_config['aop']['distribution_options']; |
34 | - }else{ |
|
34 | + } else { |
|
35 | 35 | return $this->ieX->get_stored_options("distribution_options", ''); |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | - private function getRoleUsers($roleId){ |
|
39 | + private function getRoleUsers($roleId) { |
|
40 | 40 | require_once('modules/ACLRoles/ACLRole.php'); |
41 | 41 | $role = new ACLRole(); |
42 | 42 | $role->retrieve($roleId); |
43 | - $role_users = $role->get_linked_beans( 'users','User'); |
|
43 | + $role_users = $role->get_linked_beans('users', 'User'); |
|
44 | 44 | $r_users = array(); |
45 | - foreach($role_users as $role_user){ |
|
45 | + foreach ($role_users as $role_user) { |
|
46 | 46 | $r_users[$role_user->id] = $role_user->name; |
47 | 47 | } |
48 | 48 | return $r_users; |
49 | 49 | } |
50 | 50 | |
51 | - private function getAssignableUsers(){ |
|
52 | - if($this->distributionMethod == 'singleUser'){ |
|
51 | + private function getAssignableUsers() { |
|
52 | + if ($this->distributionMethod == 'singleUser') { |
|
53 | 53 | return array(); |
54 | 54 | } |
55 | 55 | $distributionOptions = $this->getDistributionOptions(); |
56 | 56 | |
57 | - if(empty($distributionOptions)){ |
|
57 | + if (empty($distributionOptions)) { |
|
58 | 58 | return array(); |
59 | 59 | } |
60 | - switch($distributionOptions[0]) { |
|
60 | + switch ($distributionOptions[0]) { |
|
61 | 61 | Case 'security_group': |
62 | - if(file_exists('modules/SecurityGroups/SecurityGroup.php')){ |
|
62 | + if (file_exists('modules/SecurityGroups/SecurityGroup.php')) { |
|
63 | 63 | require_once('modules/SecurityGroups/SecurityGroup.php'); |
64 | 64 | $security_group = new SecurityGroup(); |
65 | 65 | $security_group->retrieve($distributionOptions[1]); |
66 | - $group_users = $security_group->get_linked_beans( 'users','User'); |
|
66 | + $group_users = $security_group->get_linked_beans('users', 'User'); |
|
67 | 67 | $users = array(); |
68 | 68 | $r_users = array(); |
69 | - if($distributionOptions[2] != ''){ |
|
69 | + if ($distributionOptions[2] != '') { |
|
70 | 70 | $r_users = $this->getRoleUsers($distributionOptions[2]); |
71 | 71 | } |
72 | - foreach($group_users as $group_user){ |
|
73 | - if($distributionOptions[2] != '' && !isset($r_users[$group_user->id])){ |
|
72 | + foreach ($group_users as $group_user) { |
|
73 | + if ($distributionOptions[2] != '' && !isset($r_users[$group_user->id])) { |
|
74 | 74 | continue; |
75 | 75 | } |
76 | 76 | $users[$group_user->id] = $group_user->name; |
@@ -90,57 +90,57 @@ discard block |
||
90 | 90 | |
91 | 91 | } |
92 | 92 | |
93 | - private function getSingleUser(){ |
|
93 | + private function getSingleUser() { |
|
94 | 94 | global $sugar_config; |
95 | - if($this->singleUser){ |
|
95 | + if ($this->singleUser) { |
|
96 | 96 | return $this->singleUser; |
97 | 97 | } |
98 | - if($this->aopFallback){ |
|
98 | + if ($this->aopFallback) { |
|
99 | 99 | $this->singleUser = !empty($sugar_config['aop']['distribution_user_id']) ? $sugar_config['aop']['distribution_user_id'] : ''; |
100 | - }else{ |
|
100 | + } else { |
|
101 | 101 | $this->singleUser = $this->ieX->get_stored_options("distribution_user_id", ""); |
102 | 102 | } |
103 | 103 | return $this->singleUser; |
104 | 104 | } |
105 | 105 | |
106 | - private function getLeastBusyCounts(){ |
|
107 | - if($this->leastBusyUsers){ |
|
106 | + private function getLeastBusyCounts() { |
|
107 | + if ($this->leastBusyUsers) { |
|
108 | 108 | return $this->leastBusyUsers; |
109 | 109 | } |
110 | 110 | global $db; |
111 | - $idIn = implode("','",$db->arrayQuote(array_keys($this->assignableUsers))); |
|
112 | - if($idIn){ |
|
111 | + $idIn = implode("','", $db->arrayQuote(array_keys($this->assignableUsers))); |
|
112 | + if ($idIn) { |
|
113 | 113 | $idIn = "'".$idIn."'"; |
114 | 114 | } |
115 | 115 | $res = $db->query("SELECT assigned_user_id, COUNT(*) AS c FROM cases WHERE assigned_user_id IN ({$idIn}) AND deleted = 0 GROUP BY assigned_user_id ORDER BY COUNT(*)"); |
116 | 116 | $this->leastBusyUsers = array(); |
117 | - while($row = $db->fetchByAssoc($res)){ |
|
117 | + while ($row = $db->fetchByAssoc($res)) { |
|
118 | 118 | $this->leastBusyUsers[$row['assigned_user_id']] = $row['c']; |
119 | 119 | } |
120 | 120 | return $this->leastBusyUsers; |
121 | 121 | } |
122 | 122 | |
123 | - private function getLeastBusyUser(){ |
|
123 | + private function getLeastBusyUser() { |
|
124 | 124 | $leastBusyCounts = $this->getLeastBusyCounts(); |
125 | 125 | asort($leastBusyCounts); |
126 | 126 | reset($leastBusyCounts); |
127 | 127 | return key($leastBusyCounts); |
128 | 128 | } |
129 | 129 | |
130 | - private function updateLeastBusy($id){ |
|
131 | - if(!$this->leastBusyUsers){ |
|
130 | + private function updateLeastBusy($id) { |
|
131 | + if (!$this->leastBusyUsers) { |
|
132 | 132 | $this->getLeastBusyCounts(); |
133 | 133 | } |
134 | 134 | $this->leastBusyUsers[$id] = $this->leastBusyUsers[$id] + 1; |
135 | 135 | } |
136 | 136 | |
137 | - private function getRandomUser(){ |
|
137 | + private function getRandomUser() { |
|
138 | 138 | $randKey = array_rand($this->assignableUsers); |
139 | 139 | return $this->assignableUsers[$randKey]; |
140 | 140 | } |
141 | 141 | |
142 | - function getNextAssignedUser(){ |
|
143 | - switch($this->distributionMethod){ |
|
142 | + function getNextAssignedUser() { |
|
143 | + switch ($this->distributionMethod) { |
|
144 | 144 | case 'singleUser': |
145 | 145 | $userId = $this->getSingleUser(); |
146 | 146 | break; |
@@ -163,20 +163,20 @@ discard block |
||
163 | 163 | |
164 | 164 | private function getRoundRobinUser() { |
165 | 165 | $id = empty($this->ieX) ? '' : $this->ieX->id; |
166 | - $file = create_cache_directory('modules/AOP_Case_Updates/Users/') . $id . 'lastUser.cache.php'; |
|
167 | - if(isset($_SESSION['AOPlastuser'][$id]) && $_SESSION['AOPlastuser'][$id] != '') { |
|
166 | + $file = create_cache_directory('modules/AOP_Case_Updates/Users/').$id.'lastUser.cache.php'; |
|
167 | + if (isset($_SESSION['AOPlastuser'][$id]) && $_SESSION['AOPlastuser'][$id] != '') { |
|
168 | 168 | $lastUserId = $_SESSION['AOPlastuser'][$id]; |
169 | 169 | } |
170 | - else if (is_file($file)){ |
|
170 | + else if (is_file($file)) { |
|
171 | 171 | include $file; |
172 | - if(isset($lastUser['User']) && $lastUser['User'] != '') { |
|
172 | + if (isset($lastUser['User']) && $lastUser['User'] != '') { |
|
173 | 173 | $lastUserId = $lastUser['User']; |
174 | 174 | } |
175 | 175 | } |
176 | 176 | $users = array_keys($this->assignableUsers); |
177 | - $lastOffset = array_search($lastUserId,$users); |
|
177 | + $lastOffset = array_search($lastUserId, $users); |
|
178 | 178 | $newOffset = ($lastOffset + 1) % count($users); |
179 | - if(!empty($users[$newOffset])) { |
|
179 | + if (!empty($users[$newOffset])) { |
|
180 | 180 | return $users[$newOffset]; |
181 | 181 | } |
182 | 182 | return reset($users); |
@@ -185,14 +185,14 @@ discard block |
||
185 | 185 | private function setLastRoundRobinUser($user_id) { |
186 | 186 | $id = empty($this->ieX) ? '' : $this->ieX->id; |
187 | 187 | $_SESSION['AOPlastuser'][$id] = $user_id; |
188 | - $file = create_cache_directory('modules/AOP_Case_Updates/Users/') . $id . 'lastUser.cache.php'; |
|
188 | + $file = create_cache_directory('modules/AOP_Case_Updates/Users/').$id.'lastUser.cache.php'; |
|
189 | 189 | $arrayString = var_export_helper(array('User' => $user_id)); |
190 | - $content =<<<eoq |
|
190 | + $content = <<<eoq |
|
191 | 191 | <?php |
192 | 192 | \$lastUser = {$arrayString}; |
193 | 193 | ?> |
194 | 194 | eoq; |
195 | - if($fh = @sugar_fopen($file, 'w')) { |
|
195 | + if ($fh = @sugar_fopen($file, 'w')) { |
|
196 | 196 | fputs($fh, $content); |
197 | 197 | fclose($fh); |
198 | 198 | } |
@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | $this->ieX = $ieX; |
11 | 11 | if($ieX) { |
12 | 12 | $inboundDistribMethod = $ieX->get_stored_options("distrib_method", ""); |
13 | - }else{ |
|
13 | + } else{ |
|
14 | 14 | $inboundDistribMethod = ''; |
15 | 15 | } |
16 | 16 | if($this->isAOPFallback($inboundDistribMethod)){ |
17 | 17 | $this->distributionMethod = $sugar_config['aop']['distribution_method']; |
18 | 18 | $this->aopFallback = true; |
19 | - }else{ |
|
19 | + } else{ |
|
20 | 20 | $this->distributionMethod = $inboundDistribMethod; |
21 | 21 | $this->aopFallback = false; |
22 | 22 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | global $sugar_config; |
32 | 32 | if($this->aopFallback){ |
33 | 33 | return $sugar_config['aop']['distribution_options']; |
34 | - }else{ |
|
34 | + } else{ |
|
35 | 35 | return $this->ieX->get_stored_options("distribution_options", ''); |
36 | 36 | } |
37 | 37 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | } |
98 | 98 | if($this->aopFallback){ |
99 | 99 | $this->singleUser = !empty($sugar_config['aop']['distribution_user_id']) ? $sugar_config['aop']['distribution_user_id'] : ''; |
100 | - }else{ |
|
100 | + } else{ |
|
101 | 101 | $this->singleUser = $this->ieX->get_stored_options("distribution_user_id", ""); |
102 | 102 | } |
103 | 103 | return $this->singleUser; |
@@ -166,8 +166,7 @@ discard block |
||
166 | 166 | $file = create_cache_directory('modules/AOP_Case_Updates/Users/') . $id . 'lastUser.cache.php'; |
167 | 167 | if(isset($_SESSION['AOPlastuser'][$id]) && $_SESSION['AOPlastuser'][$id] != '') { |
168 | 168 | $lastUserId = $_SESSION['AOPlastuser'][$id]; |
169 | - } |
|
170 | - else if (is_file($file)){ |
|
169 | + } else if (is_file($file)){ |
|
171 | 170 | include $file; |
172 | 171 | if(isset($lastUser['User']) && $lastUser['User'] != '') { |
173 | 172 | $lastUserId = $lastUser['User']; |
@@ -40,23 +40,23 @@ |
||
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 | ?> |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | ********************************************************************************/ |
40 | 40 | |
41 | 41 | |
42 | -$fields_array['Schedulers_jobs'] = array ( |
|
43 | - 'column_fields' => array ( |
|
42 | +$fields_array['Schedulers_jobs'] = array( |
|
43 | + 'column_fields' => array( |
|
44 | 44 | 'id', |
45 | 45 | 'deleted', |
46 | 46 | 'date_entered', |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | 'execute_time', |
50 | 50 | 'status', |
51 | 51 | ), |
52 | - 'list_fields' => array ( |
|
52 | + 'list_fields' => array( |
|
53 | 53 | 'id', |
54 | 54 | 'job_id', |
55 | 55 | 'execute_time' |
56 | 56 | ), |
57 | - 'required_fields' => array ( |
|
57 | + 'required_fields' => array( |
|
58 | 58 | 'job_id' => 1, |
59 | 59 | 'execute_time' => 1 |
60 | 60 | ) |
@@ -1,5 +1,7 @@ |
||
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. |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | |
4 | 4 | /********************************************************************************* |
5 | 5 | * SugarCRM Community Edition is a customer relationship management program developed by |
@@ -87,24 +87,24 @@ discard block |
||
87 | 87 | { |
88 | 88 | static $sfh; |
89 | 89 | |
90 | - if(!isset($sfh)) { |
|
90 | + if (!isset($sfh)) { |
|
91 | 91 | require_once('include/SugarFields/SugarFieldHandler.php'); |
92 | 92 | $sfh = new SugarFieldHandler(); |
93 | 93 | } |
94 | 94 | $value = $params[0]; |
95 | 95 | $vardef = $params[1]; |
96 | - if ( isset($params[2]) ) |
|
96 | + if (isset($params[2])) |
|
97 | 97 | $focus = $params[2]; |
98 | 98 | else |
99 | 99 | $focus = null; |
100 | - if ( $name == 'relate' && !empty($params[3]) ) |
|
100 | + if ($name == 'relate' && !empty($params[3])) |
|
101 | 101 | $this->addRelatedBean = true; |
102 | 102 | else |
103 | 103 | $this->addRelatedBean = false; |
104 | 104 | |
105 | 105 | $field = $sfh->getSugarField(ucfirst($name)); |
106 | - if ( $field instanceOf SugarFieldBase ) { |
|
107 | - $value = $field->importSanitize($value,$vardef,$focus,$this); |
|
106 | + if ($field instanceOf SugarFieldBase) { |
|
107 | + $value = $field->importSanitize($value, $vardef, $focus, $this); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | return $value; |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | |
129 | 129 | $format = $this->dateformat; |
130 | 130 | |
131 | - if ( !$timedate->check_matching_format($value, $format) ) |
|
131 | + if (!$timedate->check_matching_format($value, $format)) |
|
132 | 132 | return false; |
133 | 133 | |
134 | - if ( !$this->isValidTimeDate($value, $format) ) |
|
134 | + if (!$this->isValidTimeDate($value, $format)) |
|
135 | 135 | return false; |
136 | 136 | |
137 | 137 | $value = $timedate->swap_formats( |
@@ -156,11 +156,11 @@ discard block |
||
156 | 156 | // cache $sea instance |
157 | 157 | static $sea; |
158 | 158 | |
159 | - if ( !($sea instanceof SugarEmailAddress) ) { |
|
159 | + if (!($sea instanceof SugarEmailAddress)) { |
|
160 | 160 | $sea = new SugarEmailAddress; |
161 | 161 | } |
162 | 162 | |
163 | - if ( !empty($value) && !preg_match($sea->regex,$value) ) { |
|
163 | + if (!empty($value) && !preg_match($sea->regex, $value)) { |
|
164 | 164 | return false; |
165 | 165 | } |
166 | 166 | |
@@ -184,18 +184,18 @@ discard block |
||
184 | 184 | static $focus_user; |
185 | 185 | |
186 | 186 | // cache this object since we'll be reusing it a bunch |
187 | - if ( !($focus_user instanceof User) ) { |
|
187 | + if (!($focus_user instanceof User)) { |
|
188 | 188 | |
189 | 189 | $focus_user = new User(); |
190 | 190 | } |
191 | 191 | |
192 | 192 | |
193 | - if ( !empty($value) && strtolower($value) != "all" ) { |
|
194 | - $theList = explode(",",$value); |
|
193 | + if (!empty($value) && strtolower($value) != "all") { |
|
194 | + $theList = explode(",", $value); |
|
195 | 195 | $isValid = true; |
196 | 196 | $bad_names = array(); |
197 | 197 | foreach ($theList as $eachItem) { |
198 | - if ( $focus_user->retrieve_user_id($eachItem) |
|
198 | + if ($focus_user->retrieve_user_id($eachItem) |
|
199 | 199 | || $focus_user->retrieve($eachItem) |
200 | 200 | ) { |
201 | 201 | // all good |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | continue; |
207 | 207 | } |
208 | 208 | } |
209 | - if(!$isValid) { |
|
209 | + if (!$isValid) { |
|
210 | 210 | return false; |
211 | 211 | } |
212 | 212 | } |
@@ -232,10 +232,10 @@ discard block |
||
232 | 232 | |
233 | 233 | $format = $this->timeformat; |
234 | 234 | |
235 | - if ( !$timedate->check_matching_format($value, $format) ) |
|
235 | + if (!$timedate->check_matching_format($value, $format)) |
|
236 | 236 | return false; |
237 | 237 | |
238 | - if ( !$this->isValidTimeDate($value, $format) ) |
|
238 | + if (!$this->isValidTimeDate($value, $format)) |
|
239 | 239 | return false; |
240 | 240 | |
241 | 241 | $value = $timedate->swap_formats( |
@@ -266,46 +266,46 @@ discard block |
||
266 | 266 | $reg = $timedate->get_regular_expression($format); |
267 | 267 | preg_match('@'.$reg['format'].'@', $value, $dateparts); |
268 | 268 | |
269 | - if ( empty($dateparts) ) |
|
269 | + if (empty($dateparts)) |
|
270 | 270 | return false; |
271 | - if ( isset($reg['positions']['a']) |
|
272 | - && !in_array($dateparts[$reg['positions']['a']], array('am','pm')) ) |
|
271 | + if (isset($reg['positions']['a']) |
|
272 | + && !in_array($dateparts[$reg['positions']['a']], array('am', 'pm'))) |
|
273 | 273 | return false; |
274 | - if ( isset($reg['positions']['A']) |
|
275 | - && !in_array($dateparts[$reg['positions']['A']], array('AM','PM')) ) |
|
274 | + if (isset($reg['positions']['A']) |
|
275 | + && !in_array($dateparts[$reg['positions']['A']], array('AM', 'PM'))) |
|
276 | 276 | return false; |
277 | - if ( isset($reg['positions']['h']) && ( |
|
277 | + if (isset($reg['positions']['h']) && ( |
|
278 | 278 | !is_numeric($dateparts[$reg['positions']['h']]) |
279 | 279 | || $dateparts[$reg['positions']['h']] < 1 |
280 | - || $dateparts[$reg['positions']['h']] > 12 ) ) |
|
280 | + || $dateparts[$reg['positions']['h']] > 12 )) |
|
281 | 281 | return false; |
282 | - if ( isset($reg['positions']['H']) && ( |
|
282 | + if (isset($reg['positions']['H']) && ( |
|
283 | 283 | !is_numeric($dateparts[$reg['positions']['H']]) |
284 | 284 | || $dateparts[$reg['positions']['H']] < 0 |
285 | - || $dateparts[$reg['positions']['H']] > 23 ) ) |
|
285 | + || $dateparts[$reg['positions']['H']] > 23 )) |
|
286 | 286 | return false; |
287 | - if ( isset($reg['positions']['i']) && ( |
|
287 | + if (isset($reg['positions']['i']) && ( |
|
288 | 288 | !is_numeric($dateparts[$reg['positions']['i']]) |
289 | 289 | || $dateparts[$reg['positions']['i']] < 0 |
290 | - || $dateparts[$reg['positions']['i']] > 59 ) ) |
|
290 | + || $dateparts[$reg['positions']['i']] > 59 )) |
|
291 | 291 | return false; |
292 | - if ( isset($reg['positions']['s']) && ( |
|
292 | + if (isset($reg['positions']['s']) && ( |
|
293 | 293 | !is_numeric($dateparts[$reg['positions']['s']]) |
294 | 294 | || $dateparts[$reg['positions']['s']] < 0 |
295 | - || $dateparts[$reg['positions']['s']] > 59 ) ) |
|
295 | + || $dateparts[$reg['positions']['s']] > 59 )) |
|
296 | 296 | return false; |
297 | - if ( isset($reg['positions']['d']) && ( |
|
297 | + if (isset($reg['positions']['d']) && ( |
|
298 | 298 | !is_numeric($dateparts[$reg['positions']['d']]) |
299 | 299 | || $dateparts[$reg['positions']['d']] < 1 |
300 | - || $dateparts[$reg['positions']['d']] > 31 ) ) |
|
300 | + || $dateparts[$reg['positions']['d']] > 31 )) |
|
301 | 301 | return false; |
302 | - if ( isset($reg['positions']['m']) && ( |
|
302 | + if (isset($reg['positions']['m']) && ( |
|
303 | 303 | !is_numeric($dateparts[$reg['positions']['m']]) |
304 | 304 | || $dateparts[$reg['positions']['m']] < 1 |
305 | - || $dateparts[$reg['positions']['m']] > 12 ) ) |
|
305 | + || $dateparts[$reg['positions']['m']] > 12 )) |
|
306 | 306 | return false; |
307 | - if ( isset($reg['positions']['Y']) && |
|
308 | - !is_numeric($dateparts[$reg['positions']['Y']]) ) |
|
307 | + if (isset($reg['positions']['Y']) && |
|
308 | + !is_numeric($dateparts[$reg['positions']['Y']])) |
|
309 | 309 | return false; |
310 | 310 | |
311 | 311 | return true; |
@@ -1,5 +1,7 @@ discard block |
||
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 | /********************************************************************************* |
5 | 7 | * SugarCRM Community Edition is a customer relationship management program developed by |
@@ -93,14 +95,16 @@ discard block |
||
93 | 95 | } |
94 | 96 | $value = $params[0]; |
95 | 97 | $vardef = $params[1]; |
96 | - if ( isset($params[2]) ) |
|
97 | - $focus = $params[2]; |
|
98 | - else |
|
99 | - $focus = null; |
|
100 | - if ( $name == 'relate' && !empty($params[3]) ) |
|
101 | - $this->addRelatedBean = true; |
|
102 | - else |
|
103 | - $this->addRelatedBean = false; |
|
98 | + if ( isset($params[2]) ) { |
|
99 | + $focus = $params[2]; |
|
100 | + } else { |
|
101 | + $focus = null; |
|
102 | + } |
|
103 | + if ( $name == 'relate' && !empty($params[3]) ) { |
|
104 | + $this->addRelatedBean = true; |
|
105 | + } else { |
|
106 | + $this->addRelatedBean = false; |
|
107 | + } |
|
104 | 108 | |
105 | 109 | $field = $sfh->getSugarField(ucfirst($name)); |
106 | 110 | if ( $field instanceOf SugarFieldBase ) { |
@@ -128,11 +132,13 @@ discard block |
||
128 | 132 | |
129 | 133 | $format = $this->dateformat; |
130 | 134 | |
131 | - if ( !$timedate->check_matching_format($value, $format) ) |
|
132 | - return false; |
|
135 | + if ( !$timedate->check_matching_format($value, $format) ) { |
|
136 | + return false; |
|
137 | + } |
|
133 | 138 | |
134 | - if ( !$this->isValidTimeDate($value, $format) ) |
|
135 | - return false; |
|
139 | + if ( !$this->isValidTimeDate($value, $format) ) { |
|
140 | + return false; |
|
141 | + } |
|
136 | 142 | |
137 | 143 | $value = $timedate->swap_formats( |
138 | 144 | $value, $format, $timedate->get_date_format()); |
@@ -199,8 +205,7 @@ discard block |
||
199 | 205 | || $focus_user->retrieve($eachItem) |
200 | 206 | ) { |
201 | 207 | // all good |
202 | - } |
|
203 | - else { |
|
208 | + } else { |
|
204 | 209 | $isValid = false; |
205 | 210 | $bad_names[] = $eachItem; |
206 | 211 | continue; |
@@ -232,11 +237,13 @@ discard block |
||
232 | 237 | |
233 | 238 | $format = $this->timeformat; |
234 | 239 | |
235 | - if ( !$timedate->check_matching_format($value, $format) ) |
|
236 | - return false; |
|
240 | + if ( !$timedate->check_matching_format($value, $format) ) { |
|
241 | + return false; |
|
242 | + } |
|
237 | 243 | |
238 | - if ( !$this->isValidTimeDate($value, $format) ) |
|
239 | - return false; |
|
244 | + if ( !$this->isValidTimeDate($value, $format) ) { |
|
245 | + return false; |
|
246 | + } |
|
240 | 247 | |
241 | 248 | $value = $timedate->swap_formats( |
242 | 249 | $value, $format, $timedate->get_time_format()); |
@@ -266,47 +273,57 @@ discard block |
||
266 | 273 | $reg = $timedate->get_regular_expression($format); |
267 | 274 | preg_match('@'.$reg['format'].'@', $value, $dateparts); |
268 | 275 | |
269 | - if ( empty($dateparts) ) |
|
270 | - return false; |
|
276 | + if ( empty($dateparts) ) { |
|
277 | + return false; |
|
278 | + } |
|
271 | 279 | if ( isset($reg['positions']['a']) |
272 | - && !in_array($dateparts[$reg['positions']['a']], array('am','pm')) ) |
|
273 | - return false; |
|
280 | + && !in_array($dateparts[$reg['positions']['a']], array('am','pm')) ) { |
|
281 | + return false; |
|
282 | + } |
|
274 | 283 | if ( isset($reg['positions']['A']) |
275 | - && !in_array($dateparts[$reg['positions']['A']], array('AM','PM')) ) |
|
276 | - return false; |
|
284 | + && !in_array($dateparts[$reg['positions']['A']], array('AM','PM')) ) { |
|
285 | + return false; |
|
286 | + } |
|
277 | 287 | if ( isset($reg['positions']['h']) && ( |
278 | 288 | !is_numeric($dateparts[$reg['positions']['h']]) |
279 | 289 | || $dateparts[$reg['positions']['h']] < 1 |
280 | - || $dateparts[$reg['positions']['h']] > 12 ) ) |
|
281 | - return false; |
|
290 | + || $dateparts[$reg['positions']['h']] > 12 ) ) { |
|
291 | + return false; |
|
292 | + } |
|
282 | 293 | if ( isset($reg['positions']['H']) && ( |
283 | 294 | !is_numeric($dateparts[$reg['positions']['H']]) |
284 | 295 | || $dateparts[$reg['positions']['H']] < 0 |
285 | - || $dateparts[$reg['positions']['H']] > 23 ) ) |
|
286 | - return false; |
|
296 | + || $dateparts[$reg['positions']['H']] > 23 ) ) { |
|
297 | + return false; |
|
298 | + } |
|
287 | 299 | if ( isset($reg['positions']['i']) && ( |
288 | 300 | !is_numeric($dateparts[$reg['positions']['i']]) |
289 | 301 | || $dateparts[$reg['positions']['i']] < 0 |
290 | - || $dateparts[$reg['positions']['i']] > 59 ) ) |
|
291 | - return false; |
|
302 | + || $dateparts[$reg['positions']['i']] > 59 ) ) { |
|
303 | + return false; |
|
304 | + } |
|
292 | 305 | if ( isset($reg['positions']['s']) && ( |
293 | 306 | !is_numeric($dateparts[$reg['positions']['s']]) |
294 | 307 | || $dateparts[$reg['positions']['s']] < 0 |
295 | - || $dateparts[$reg['positions']['s']] > 59 ) ) |
|
296 | - return false; |
|
308 | + || $dateparts[$reg['positions']['s']] > 59 ) ) { |
|
309 | + return false; |
|
310 | + } |
|
297 | 311 | if ( isset($reg['positions']['d']) && ( |
298 | 312 | !is_numeric($dateparts[$reg['positions']['d']]) |
299 | 313 | || $dateparts[$reg['positions']['d']] < 1 |
300 | - || $dateparts[$reg['positions']['d']] > 31 ) ) |
|
301 | - return false; |
|
314 | + || $dateparts[$reg['positions']['d']] > 31 ) ) { |
|
315 | + return false; |
|
316 | + } |
|
302 | 317 | if ( isset($reg['positions']['m']) && ( |
303 | 318 | !is_numeric($dateparts[$reg['positions']['m']]) |
304 | 319 | || $dateparts[$reg['positions']['m']] < 1 |
305 | - || $dateparts[$reg['positions']['m']] > 12 ) ) |
|
306 | - return false; |
|
320 | + || $dateparts[$reg['positions']['m']] > 12 ) ) { |
|
321 | + return false; |
|
322 | + } |
|
307 | 323 | if ( isset($reg['positions']['Y']) && |
308 | - !is_numeric($dateparts[$reg['positions']['Y']]) ) |
|
309 | - return false; |
|
324 | + !is_numeric($dateparts[$reg['positions']['Y']]) ) { |
|
325 | + return false; |
|
326 | + } |
|
310 | 327 | |
311 | 328 | return true; |
312 | 329 | } |
@@ -49,11 +49,11 @@ discard block |
||
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 |
||
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 |
||
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 | { |
@@ -78,19 +78,19 @@ |
||
78 | 78 | { |
79 | 79 | $return_array = parent::getMapping($module); |
80 | 80 | switch ($module) { |
81 | - case 'Contacts': |
|
82 | - case 'Leads': |
|
83 | - return $return_array + array( |
|
84 | - "Job Title"=>"title", |
|
85 | - "Home Country"=>"alt_address_country", |
|
86 | - "E-mail 2 Address"=>"email2", |
|
87 | - ); |
|
88 | - break; |
|
89 | - case 'Accounts': |
|
90 | - return $return_array; |
|
91 | - break; |
|
92 | - default: |
|
93 | - return $return_array; |
|
81 | + case 'Contacts': |
|
82 | + case 'Leads': |
|
83 | + return $return_array + array( |
|
84 | + "Job Title"=>"title", |
|
85 | + "Home Country"=>"alt_address_country", |
|
86 | + "E-mail 2 Address"=>"email2", |
|
87 | + ); |
|
88 | + break; |
|
89 | + case 'Accounts': |
|
90 | + return $return_array; |
|
91 | + break; |
|
92 | + default: |
|
93 | + return $return_array; |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | } |
@@ -1,5 +1,5 @@ |
||
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. |
@@ -1,5 +1,7 @@ |
||
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. |
@@ -44,7 +44,7 @@ discard block |
||
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 |
||
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') |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | 'email2' => array('sugar_key' => 'email2', 'sugar_label' => 'LBL_OTHER_EMAIL_ADDRESS', 'default_label' => 'Other Email'), |
87 | 87 | |
88 | 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'), |
|
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 | - if($module == 'Users') |
|
92 | + if ($module == 'Users') |
|
93 | 93 | { |
94 | - $return_array['status'] = array('sugar_key' => 'status', 'sugar_label' => '', 'default_label' => 'Status'); |
|
95 | - $return_array['full_name'] = array('sugar_key' => 'user_name', 'sugar_label' => '', 'default_label' => 'Full Name'); |
|
94 | + $return_array['status'] = array('sugar_key' => 'status', 'sugar_label' => '', 'default_label' => 'Status'); |
|
95 | + $return_array['full_name'] = array('sugar_key' => 'user_name', 'sugar_label' => '', 'default_label' => 'Full Name'); |
|
96 | 96 | } |
97 | 97 | return $return_array; |
98 | 98 | } |
@@ -1,5 +1,7 @@ |
||
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. |