@@ -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; |
@@ -1,32 +1,32 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Advanced OpenReports, SugarCRM Reporting. |
|
4 | - * @package Advanced OpenReports for SugarCRM |
|
5 | - * @copyright SalesAgility Ltd http://www.salesagility.com |
|
6 | - * |
|
7 | - * This program is free software; you can redistribute it and/or modify |
|
8 | - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by |
|
9 | - * the Free Software Foundation; either version 3 of the License, or |
|
10 | - * (at your option) any later version. |
|
11 | - * |
|
12 | - * This program is distributed in the hope that it will be useful, |
|
13 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 | - * GNU General Public License for more details. |
|
16 | - * |
|
17 | - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
18 | - * along with this program; if not, see http://www.gnu.org/licenses |
|
19 | - * or write to the Free Software Foundation,Inc., 51 Franklin Street, |
|
20 | - * Fifth Floor, Boston, MA 02110-1301 USA |
|
21 | - * |
|
22 | - * @author SalesAgility <[email protected]> |
|
23 | - */ |
|
3 | + * Advanced OpenReports, SugarCRM Reporting. |
|
4 | + * @package Advanced OpenReports for SugarCRM |
|
5 | + * @copyright SalesAgility Ltd http://www.salesagility.com |
|
6 | + * |
|
7 | + * This program is free software; you can redistribute it and/or modify |
|
8 | + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by |
|
9 | + * the Free Software Foundation; either version 3 of the License, or |
|
10 | + * (at your option) any later version. |
|
11 | + * |
|
12 | + * This program is distributed in the hope that it will be useful, |
|
13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 | + * GNU General Public License for more details. |
|
16 | + * |
|
17 | + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
18 | + * along with this program; if not, see http://www.gnu.org/licenses |
|
19 | + * or write to the Free Software Foundation,Inc., 51 Franklin Street, |
|
20 | + * Fifth Floor, Boston, MA 02110-1301 USA |
|
21 | + * |
|
22 | + * @author SalesAgility <[email protected]> |
|
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'); |
@@ -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')); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | var $table_name = 'aor_fields'; |
30 | 30 | var $tracker_visibility = false; |
31 | 31 | var $importable = true; |
32 | - var $disable_row_level_security = true ; |
|
32 | + var $disable_row_level_security = true; |
|
33 | 33 | |
34 | 34 | var $id; |
35 | 35 | var $name; |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | var $group_by; |
54 | 54 | var $group_order; |
55 | 55 | |
56 | - function AOR_Field(){ |
|
56 | + function AOR_Field() { |
|
57 | 57 | parent::Basic(); |
58 | 58 | } |
59 | 59 | |
60 | - function save_lines($post_data, $parent, $key = ''){ |
|
60 | + function save_lines($post_data, $parent, $key = '') { |
|
61 | 61 | |
62 | 62 | require_once('modules/AOW_WorkFlow/aow_utils.php'); |
63 | 63 | |
@@ -65,45 +65,45 @@ discard block |
||
65 | 65 | $j = 0; |
66 | 66 | for ($i = 0; $i < $line_count; ++$i) { |
67 | 67 | |
68 | - if($post_data[$key.'deleted'][$i] == 1){ |
|
68 | + if ($post_data[$key.'deleted'][$i] == 1) { |
|
69 | 69 | $this->mark_deleted($post_data[$key.'id'][$i]); |
70 | 70 | } else { |
71 | 71 | $field = new AOR_Field(); |
72 | 72 | $field->group_display = false; |
73 | 73 | |
74 | - if($key == 'aor_fields_') { |
|
75 | - foreach($post_data['aor_fields_group_display'] as $gdKey => $gdValue) { |
|
76 | - if($gdValue == $i) { |
|
77 | - $field->group_display = $gdKey+1; |
|
74 | + if ($key == 'aor_fields_') { |
|
75 | + foreach ($post_data['aor_fields_group_display'] as $gdKey => $gdValue) { |
|
76 | + if ($gdValue == $i) { |
|
77 | + $field->group_display = $gdKey + 1; |
|
78 | 78 | break; |
79 | 79 | } |
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | - foreach($this->field_defs as $field_def) { |
|
84 | - if(is_array($post_data[$key.$field_def['name']])) { |
|
85 | - if ($field_def['name'] != 'group_display' && isset($post_data[$key . $field_def['name']][$i])) { |
|
86 | - if (is_array($post_data[$key . $field_def['name']][$i])) { |
|
87 | - $post_data[$key . $field_def['name']][$i] = base64_encode(serialize($post_data[$key . $field_def['name']][$i])); |
|
83 | + foreach ($this->field_defs as $field_def) { |
|
84 | + if (is_array($post_data[$key.$field_def['name']])) { |
|
85 | + if ($field_def['name'] != 'group_display' && isset($post_data[$key.$field_def['name']][$i])) { |
|
86 | + if (is_array($post_data[$key.$field_def['name']][$i])) { |
|
87 | + $post_data[$key.$field_def['name']][$i] = base64_encode(serialize($post_data[$key.$field_def['name']][$i])); |
|
88 | 88 | } else if ($field_def['name'] == 'value') { |
89 | - $post_data[$key . $field_def['name']][$i] = fixUpFormatting($_REQUEST['report_module'], $field->field, $post_data[$key . $field_def['name']][$i]); |
|
89 | + $post_data[$key.$field_def['name']][$i] = fixUpFormatting($_REQUEST['report_module'], $field->field, $post_data[$key.$field_def['name']][$i]); |
|
90 | 90 | } |
91 | 91 | if ($field_def['name'] == 'module_path') { |
92 | - $post_data[$key . $field_def['name']][$i] = base64_encode(serialize(explode(":", $post_data[$key . $field_def['name']][$i]))); |
|
92 | + $post_data[$key.$field_def['name']][$i] = base64_encode(serialize(explode(":", $post_data[$key.$field_def['name']][$i]))); |
|
93 | 93 | } |
94 | 94 | |
95 | - $field->$field_def['name'] = $post_data[$key . $field_def['name']][$i]; |
|
95 | + $field->$field_def['name'] = $post_data[$key.$field_def['name']][$i]; |
|
96 | 96 | } |
97 | 97 | } |
98 | - else if(is_null($post_data[$key.$field_def['name']])) { |
|
98 | + else if (is_null($post_data[$key.$field_def['name']])) { |
|
99 | 99 | // do nothing |
100 | 100 | } |
101 | 101 | else { |
102 | - throw new Exception('illegal type in post data at key ' . $key.$field_def['name'] . ' ' . gettype($post_data[$key.$field_def['name']])); |
|
102 | + throw new Exception('illegal type in post data at key '.$key.$field_def['name'].' '.gettype($post_data[$key.$field_def['name']])); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | } |
106 | - if(trim($field->field) != ''){ |
|
106 | + if (trim($field->field) != '') { |
|
107 | 107 | $field->aor_report_id = $parent->id; |
108 | 108 | $field->save(); |
109 | 109 | } |
@@ -94,11 +94,9 @@ |
||
94 | 94 | |
95 | 95 | $field->$field_def['name'] = $post_data[$key . $field_def['name']][$i]; |
96 | 96 | } |
97 | - } |
|
98 | - else if(is_null($post_data[$key.$field_def['name']])) { |
|
97 | + } else if(is_null($post_data[$key.$field_def['name']])) { |
|
99 | 98 | // do nothing |
100 | - } |
|
101 | - else { |
|
99 | + } else { |
|
102 | 100 | throw new Exception('illegal type in post data at key ' . $key.$field_def['name'] . ' ' . gettype($post_data[$key.$field_def['name']])); |
103 | 101 | } |
104 | 102 |
@@ -23,26 +23,26 @@ discard block |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | class AOR_Field extends Basic { |
26 | - var $new_schema = true; |
|
27 | - var $module_dir = 'AOR_Fields'; |
|
28 | - var $object_name = 'AOR_Field'; |
|
29 | - var $table_name = 'aor_fields'; |
|
26 | + var $new_schema = true; |
|
27 | + var $module_dir = 'AOR_Fields'; |
|
28 | + var $object_name = 'AOR_Field'; |
|
29 | + var $table_name = 'aor_fields'; |
|
30 | 30 | var $tracker_visibility = false; |
31 | - var $importable = true; |
|
32 | - var $disable_row_level_security = true ; |
|
31 | + var $importable = true; |
|
32 | + var $disable_row_level_security = true ; |
|
33 | 33 | |
34 | - var $id; |
|
35 | - var $name; |
|
36 | - var $date_entered; |
|
37 | - var $date_modified; |
|
38 | - var $modified_user_id; |
|
39 | - var $modified_by_name; |
|
40 | - var $created_by; |
|
41 | - var $created_by_name; |
|
42 | - var $description; |
|
43 | - var $deleted; |
|
44 | - var $created_by_link; |
|
45 | - var $modified_user_link; |
|
34 | + var $id; |
|
35 | + var $name; |
|
36 | + var $date_entered; |
|
37 | + var $date_modified; |
|
38 | + var $modified_user_id; |
|
39 | + var $modified_by_name; |
|
40 | + var $created_by; |
|
41 | + var $created_by_name; |
|
42 | + var $description; |
|
43 | + var $deleted; |
|
44 | + var $created_by_link; |
|
45 | + var $modified_user_link; |
|
46 | 46 | var $field_order; |
47 | 47 | var $field; |
48 | 48 | var $display; |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | var $group_by; |
54 | 54 | var $group_order; |
55 | 55 | |
56 | - function AOR_Field(){ |
|
57 | - parent::Basic(); |
|
58 | - } |
|
56 | + function AOR_Field(){ |
|
57 | + parent::Basic(); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | function save_lines($post_data, $parent, $key = ''){ |
61 | 61 |
@@ -57,6 +57,9 @@ |
||
57 | 57 | parent::Basic(); |
58 | 58 | } |
59 | 59 | |
60 | + /** |
|
61 | + * @param AOR_Report $parent |
|
62 | + */ |
|
60 | 63 | function save_lines($post_data, $parent, $key = ''){ |
61 | 64 | |
62 | 65 | require_once('modules/AOW_WorkFlow/aow_utils.php'); |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
38 | 38 | ********************************************************************************/ |
39 | 39 | |
40 | -$dictionary['Reminder_Invitee']['table']= 'reminders_invitees'; |
|
41 | -$dictionary['Reminder_Invitee']['audited']= false; |
|
42 | -$dictionary['Reminder_Invitee']['fields']= array( |
|
40 | +$dictionary['Reminder_Invitee']['table'] = 'reminders_invitees'; |
|
41 | +$dictionary['Reminder_Invitee']['audited'] = false; |
|
42 | +$dictionary['Reminder_Invitee']['fields'] = array( |
|
43 | 43 | 'reminder_id' => array( |
44 | 44 | 'name' => 'reminder_id', |
45 | 45 | 'vname' => 'LBL_REMINDER_ID', |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | //); |
73 | 73 | |
74 | 74 | |
75 | -if (!class_exists('VardefManager')){ |
|
75 | +if (!class_exists('VardefManager')) { |
|
76 | 76 | require_once('include/SugarObjects/VardefManager.php'); |
77 | 77 | } |
78 | -VardefManager::createVardef('Reminders_Invitees','Reminder_Invitee', array('basic','assignable')); |
|
78 | +VardefManager::createVardef('Reminders_Invitees', 'Reminder_Invitee', array('basic', 'assignable')); |
|
79 | 79 | |
80 | 80 | ?> |
81 | 81 | \ No newline at end of file |
@@ -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) { |
@@ -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) { |
@@ -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(); |
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(){ |
|
280 | +function quick_edit_case_updates() { |
|
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,7 +294,7 @@ 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 | } |
@@ -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']; |
@@ -1,26 +1,26 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * |
|
4 | - * @package Advanced OpenPortal |
|
5 | - * @copyright SalesAgility Ltd http://www.salesagility.com |
|
6 | - * |
|
7 | - * This program is free software; you can redistribute it and/or modify |
|
8 | - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by |
|
9 | - * the Free Software Foundation; either version 3 of the License, or |
|
10 | - * (at your option) any later version. |
|
11 | - * |
|
12 | - * This program is distributed in the hope that it will be useful, |
|
13 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 | - * GNU General Public License for more details. |
|
16 | - * |
|
17 | - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
18 | - * along with this program; if not, see http://www.gnu.org/licenses |
|
19 | - * or write to the Free Software Foundation,Inc., 51 Franklin Street, |
|
20 | - * Fifth Floor, Boston, MA 02110-1301 USA |
|
21 | - * |
|
22 | - * @author Salesagility Ltd <[email protected]> |
|
23 | - */ |
|
3 | + * |
|
4 | + * @package Advanced OpenPortal |
|
5 | + * @copyright SalesAgility Ltd http://www.salesagility.com |
|
6 | + * |
|
7 | + * This program is free software; you can redistribute it and/or modify |
|
8 | + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by |
|
9 | + * the Free Software Foundation; either version 3 of the License, or |
|
10 | + * (at your option) any later version. |
|
11 | + * |
|
12 | + * This program is distributed in the hope that it will be useful, |
|
13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 | + * GNU General Public License for more details. |
|
16 | + * |
|
17 | + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
18 | + * along with this program; if not, see http://www.gnu.org/licenses |
|
19 | + * or write to the Free Software Foundation,Inc., 51 Franklin Street, |
|
20 | + * Fifth Floor, Boston, MA 02110-1301 USA |
|
21 | + * |
|
22 | + * @author Salesagility Ltd <[email protected]> |
|
23 | + */ |
|
24 | 24 | require_once 'util.php'; |
25 | 25 | class CaseUpdatesHook { |
26 | 26 | private $slug_size = 50; |
@@ -30,35 +30,35 @@ discard block |
||
30 | 30 | require_once 'include/clean.php'; |
31 | 31 | class AOP_Case_Updates extends AOP_Case_Updates_sugar { |
32 | 32 | |
33 | - function AOP_Case_Updates(){ |
|
33 | + function AOP_Case_Updates() { |
|
34 | 34 | parent::AOP_Case_Updates_sugar(); |
35 | 35 | } |
36 | 36 | |
37 | - function save($check_notify = false){ |
|
37 | + function save($check_notify = false) { |
|
38 | 38 | $this->name = SugarCleaner::cleanHtml($this->name); |
39 | 39 | $this->description = SugarCleaner::cleanHtml($this->description); |
40 | 40 | global $current_user, $sugar_config; |
41 | 41 | parent::save($check_notify); |
42 | 42 | $email_template = new EmailTemplate(); |
43 | - if($_REQUEST['module'] == 'Import'){ |
|
43 | + if ($_REQUEST['module'] == 'Import') { |
|
44 | 44 | //Don't send email on import |
45 | 45 | return; |
46 | 46 | } |
47 | - if(!isAOPEnabled()){ |
|
47 | + if (!isAOPEnabled()) { |
|
48 | 48 | return; |
49 | 49 | } |
50 | - if($this->internal){ |
|
50 | + if ($this->internal) { |
|
51 | 51 | return; |
52 | 52 | } |
53 | 53 | $signature = array(); |
54 | 54 | $addDelimiter = true; |
55 | 55 | $aop_config = $sugar_config['aop']; |
56 | - if($this->assigned_user_id){ |
|
57 | - if($aop_config['contact_email_template_id']){ |
|
56 | + if ($this->assigned_user_id) { |
|
57 | + if ($aop_config['contact_email_template_id']) { |
|
58 | 58 | $email_template = $email_template->retrieve($aop_config['contact_email_template_id']); |
59 | 59 | $signature = $current_user->getDefaultSignature(); |
60 | 60 | } |
61 | - if($email_template) { |
|
61 | + if ($email_template) { |
|
62 | 62 | foreach ($this->getContacts() as $contact) { |
63 | 63 | $GLOBALS['log']->info("AOPCaseUpdates: Calling send email"); |
64 | 64 | $emails = array(); |
@@ -66,15 +66,15 @@ discard block |
||
66 | 66 | $res = $this->sendEmail($emails, $email_template, $signature, $this->case_id, $addDelimiter, $contact->id); |
67 | 67 | } |
68 | 68 | } |
69 | - }else{ |
|
69 | + } else { |
|
70 | 70 | $emails = $this->getEmailForUser(); |
71 | - if($aop_config['user_email_template_id']){ |
|
71 | + if ($aop_config['user_email_template_id']) { |
|
72 | 72 | $email_template = $email_template->retrieve($aop_config['user_email_template_id']); |
73 | 73 | } |
74 | 74 | $addDelimiter = false; |
75 | - if($emails && $email_template){ |
|
75 | + if ($emails && $email_template) { |
|
76 | 76 | $GLOBALS['log']->info("AOPCaseUpdates: Calling send email"); |
77 | - $res = $this->sendEmail($emails, $email_template, $signature, $this->case_id, $addDelimiter,$this->contact_id); |
|
77 | + $res = $this->sendEmail($emails, $email_template, $signature, $this->case_id, $addDelimiter, $this->contact_id); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -83,68 +83,68 @@ discard block |
||
83 | 83 | /** |
84 | 84 | * @return aCase |
85 | 85 | */ |
86 | - public function getCase(){ |
|
87 | - $case = BeanFactory::getBean("Cases",$this->case_id); |
|
86 | + public function getCase() { |
|
87 | + $case = BeanFactory::getBean("Cases", $this->case_id); |
|
88 | 88 | return $case; |
89 | 89 | } |
90 | 90 | |
91 | - public function getContacts(){ |
|
91 | + public function getContacts() { |
|
92 | 92 | $case = $this->getCase(); |
93 | - if($case){ |
|
94 | - return $case->get_linked_beans("contacts","Contacts"); |
|
93 | + if ($case) { |
|
94 | + return $case->get_linked_beans("contacts", "Contacts"); |
|
95 | 95 | } |
96 | 96 | return null; |
97 | 97 | } |
98 | 98 | |
99 | - public function getUpdateContact(){ |
|
100 | - if($this->contact_id){ |
|
101 | - return BeanFactory::getBean("Contacts",$this->contact_id); |
|
99 | + public function getUpdateContact() { |
|
100 | + if ($this->contact_id) { |
|
101 | + return BeanFactory::getBean("Contacts", $this->contact_id); |
|
102 | 102 | } |
103 | 103 | return null; |
104 | 104 | } |
105 | - public function getUser(){ |
|
106 | - $user = BeanFactory::getBean('Users',$this->getCase()->assigned_user_id); |
|
105 | + public function getUser() { |
|
106 | + $user = BeanFactory::getBean('Users', $this->getCase()->assigned_user_id); |
|
107 | 107 | return $user; |
108 | 108 | } |
109 | - public function getUpdateUser(){ |
|
110 | - $user = BeanFactory::getBean('Users',$this->assigned_user_id); |
|
109 | + public function getUpdateUser() { |
|
110 | + $user = BeanFactory::getBean('Users', $this->assigned_user_id); |
|
111 | 111 | return $user; |
112 | 112 | } |
113 | 113 | |
114 | - private function getEmailForUser(){ |
|
114 | + private function getEmailForUser() { |
|
115 | 115 | $user = $this->getUser(); |
116 | - if($user){ |
|
116 | + if ($user) { |
|
117 | 117 | return array($user->emailAddress->getPrimaryAddress($user)); |
118 | 118 | } |
119 | 119 | return array(); |
120 | 120 | } |
121 | 121 | |
122 | - private function populateTemplate(EmailTemplate $template, $addDelimiter = true, $contactId = null){ |
|
122 | + private function populateTemplate(EmailTemplate $template, $addDelimiter = true, $contactId = null) { |
|
123 | 123 | global $app_strings, $sugar_config; |
124 | 124 | //Order of beans seems to matter here so we place contact first. |
125 | 125 | $userId = ''; |
126 | 126 | $user = $this->getUpdateUser(); |
127 | - if(!$user){ |
|
127 | + if (!$user) { |
|
128 | 128 | $this->getUser(); |
129 | 129 | } |
130 | - $beans = array("Contacts" => $contactId,"Cases" => $this->getCase()->id, "Users" => $user->id, "AOP_Case_Updates" => $this->id); |
|
130 | + $beans = array("Contacts" => $contactId, "Cases" => $this->getCase()->id, "Users" => $user->id, "AOP_Case_Updates" => $this->id); |
|
131 | 131 | $ret = array(); |
132 | - $ret['subject'] = from_html(aop_parse_template($template->subject,$beans)); |
|
133 | - $body = aop_parse_template(str_replace("\$sugarurl",$sugar_config['site_url'],$template->body_html),$beans); |
|
134 | - $bodyAlt = aop_parse_template(str_replace("\$sugarurl",$sugar_config['site_url'],$template->body),$beans); |
|
135 | - if($addDelimiter){ |
|
136 | - $body = $app_strings['LBL_AOP_EMAIL_REPLY_DELIMITER'] . $body; |
|
137 | - $bodyAlt = $app_strings['LBL_AOP_EMAIL_REPLY_DELIMITER'] . $bodyAlt; |
|
132 | + $ret['subject'] = from_html(aop_parse_template($template->subject, $beans)); |
|
133 | + $body = aop_parse_template(str_replace("\$sugarurl", $sugar_config['site_url'], $template->body_html), $beans); |
|
134 | + $bodyAlt = aop_parse_template(str_replace("\$sugarurl", $sugar_config['site_url'], $template->body), $beans); |
|
135 | + if ($addDelimiter) { |
|
136 | + $body = $app_strings['LBL_AOP_EMAIL_REPLY_DELIMITER'].$body; |
|
137 | + $bodyAlt = $app_strings['LBL_AOP_EMAIL_REPLY_DELIMITER'].$bodyAlt; |
|
138 | 138 | } |
139 | 139 | $ret['body'] = from_html($body); |
140 | 140 | $ret['body_alt'] = strip_tags(from_html($bodyAlt)); |
141 | 141 | return $ret; |
142 | 142 | } |
143 | 143 | |
144 | - private function sendEmail($emails, $template, $signature = array(), $caseId = null, $addDelimiter = true, $contactId = null){ |
|
144 | + private function sendEmail($emails, $template, $signature = array(), $caseId = null, $addDelimiter = true, $contactId = null) { |
|
145 | 145 | $GLOBALS['log']->info("AOPCaseUpdates: sendEmail called"); |
146 | 146 | require_once("include/SugarPHPMailer.php"); |
147 | - $mailer=new SugarPHPMailer(); |
|
147 | + $mailer = new SugarPHPMailer(); |
|
148 | 148 | $admin = new Administration(); |
149 | 149 | $admin->retrieveSettings(); |
150 | 150 | |
@@ -152,36 +152,36 @@ discard block |
||
152 | 152 | $mailer->setMailerForSystem(); |
153 | 153 | |
154 | 154 | $signatureHTML = ""; |
155 | - if($signature && array_key_exists("signature_html",$signature)){ |
|
155 | + if ($signature && array_key_exists("signature_html", $signature)) { |
|
156 | 156 | $signatureHTML = from_html($signature['signature_html']); |
157 | 157 | } |
158 | 158 | $signaturePlain = ""; |
159 | - if($signature && array_key_exists("signature",$signature)){ |
|
159 | + if ($signature && array_key_exists("signature", $signature)) { |
|
160 | 160 | $signaturePlain = $signature['signature']; |
161 | 161 | } |
162 | 162 | $emailSettings = getPortalEmailSettings(); |
163 | - $GLOBALS['log']->info("AOPCaseUpdates: sendEmail email portal settings are ".print_r($emailSettings,true)); |
|
163 | + $GLOBALS['log']->info("AOPCaseUpdates: sendEmail email portal settings are ".print_r($emailSettings, true)); |
|
164 | 164 | $text = $this->populateTemplate($template, $addDelimiter, $contactId); |
165 | 165 | $mailer->Subject = $text['subject']; |
166 | - $mailer->Body = $text['body'] . $signatureHTML; |
|
166 | + $mailer->Body = $text['body'].$signatureHTML; |
|
167 | 167 | $mailer->IsHTML(true); |
168 | - $mailer->AltBody = $text['body_alt'] . $signaturePlain; |
|
168 | + $mailer->AltBody = $text['body_alt'].$signaturePlain; |
|
169 | 169 | $mailer->From = $emailSettings['from_address']; |
170 | 170 | $mailer->FromName = $emailSettings['from_name']; |
171 | - foreach($emails as $email){ |
|
171 | + foreach ($emails as $email) { |
|
172 | 172 | $mailer->AddAddress($email); |
173 | 173 | } |
174 | - if ($mailer->Send()){ |
|
174 | + if ($mailer->Send()) { |
|
175 | 175 | require_once('modules/Emails/Email.php'); |
176 | 176 | $emailObj = new Email(); |
177 | - $emailObj->to_addrs = implode(",",$emails); |
|
178 | - $emailObj->type= 'out'; |
|
177 | + $emailObj->to_addrs = implode(",", $emails); |
|
178 | + $emailObj->type = 'out'; |
|
179 | 179 | $emailObj->deleted = '0'; |
180 | 180 | $emailObj->name = $mailer->Subject; |
181 | 181 | $emailObj->description = $mailer->AltBody; |
182 | 182 | $emailObj->description_html = $mailer->Body; |
183 | 183 | $emailObj->from_addr = $mailer->From; |
184 | - if ( $caseId) { |
|
184 | + if ($caseId) { |
|
185 | 185 | $emailObj->parent_type = "Cases"; |
186 | 186 | $emailObj->parent_id = $caseId; |
187 | 187 | } |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | $emailObj->created_by = '1'; |
191 | 191 | $emailObj->status = 'sent'; |
192 | 192 | $emailObj->save(); |
193 | - }else{ |
|
194 | - $GLOBALS['log']->info("AOPCaseUpdates: Could not send email: " . $mailer->ErrorInfo); |
|
193 | + } else { |
|
194 | + $GLOBALS['log']->info("AOPCaseUpdates: Could not send email: ".$mailer->ErrorInfo); |
|
195 | 195 | return false; |
196 | 196 | } |
197 | 197 | return true; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $res = $this->sendEmail($emails, $email_template, $signature, $this->case_id, $addDelimiter, $contact->id); |
67 | 67 | } |
68 | 68 | } |
69 | - }else{ |
|
69 | + } else{ |
|
70 | 70 | $emails = $this->getEmailForUser(); |
71 | 71 | if($aop_config['user_email_template_id']){ |
72 | 72 | $email_template = $email_template->retrieve($aop_config['user_email_template_id']); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $emailObj->created_by = '1'; |
191 | 191 | $emailObj->status = 'sent'; |
192 | 192 | $emailObj->save(); |
193 | - }else{ |
|
193 | + } else{ |
|
194 | 194 | $GLOBALS['log']->info("AOPCaseUpdates: Could not send email: " . $mailer->ErrorInfo); |
195 | 195 | return false; |
196 | 196 | } |
@@ -279,6 +279,9 @@ |
||
279 | 279 | return true; |
280 | 280 | } |
281 | 281 | |
282 | + /** |
|
283 | + * @param EmailTemplate $template |
|
284 | + */ |
|
282 | 285 | function parse_template(SugarBean $bean, &$template, $object_override = array()){ |
283 | 286 | global $sugar_config; |
284 | 287 |
@@ -25,27 +25,27 @@ discard block |
||
25 | 25 | class CaseUpdatesHook { |
26 | 26 | private $slug_size = 50; |
27 | 27 | |
28 | - private function getCaseCounts(){ |
|
28 | + private function getCaseCounts() { |
|
29 | 29 | global $db; |
30 | 30 | $counts = array(); |
31 | 31 | $r = $db->query("SELECT users.id,count(cases.id) AS c FROM users LEFT JOIN cases ON (cases.assigned_user_id = users.id AND cases.status != 'Closed' AND cases.status != 'Duplicate' AND cases.status != 'Rejected') WHERE NOT users.deleted GROUP BY users.id"); |
32 | - while($a = $db->fetchByAssoc($r)){ |
|
32 | + while ($a = $db->fetchByAssoc($r)) { |
|
33 | 33 | $counts[$a['id']] = $a['c']; |
34 | 34 | } |
35 | 35 | return $counts; |
36 | 36 | } |
37 | 37 | |
38 | - private function getAssignToUser(){ |
|
38 | + private function getAssignToUser() { |
|
39 | 39 | require_once 'modules/AOP_Case_Updates/AOPAssignManager.php'; |
40 | 40 | $assignManager = new AOPAssignManager(); |
41 | 41 | return $assignManager->getNextAssignedUser(); |
42 | 42 | } |
43 | 43 | |
44 | - private function arrangeFilesArray(){ |
|
44 | + private function arrangeFilesArray() { |
|
45 | 45 | $count = 0; |
46 | - foreach($_FILES['case_update_file'] as $key => $vals){ |
|
47 | - foreach($vals as $index => $val){ |
|
48 | - if(!array_key_exists('case_update_file'.$index,$_FILES)){ |
|
46 | + foreach ($_FILES['case_update_file'] as $key => $vals) { |
|
47 | + foreach ($vals as $index => $val) { |
|
48 | + if (!array_key_exists('case_update_file'.$index, $_FILES)) { |
|
49 | 49 | $_FILES['case_update_file'.$index] = array(); |
50 | 50 | $count++; |
51 | 51 | } |
@@ -56,34 +56,34 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | |
59 | - public function saveUpdate($bean, $event, $arguments){ |
|
60 | - if(!isAOPEnabled()){ |
|
59 | + public function saveUpdate($bean, $event, $arguments) { |
|
60 | + if (!isAOPEnabled()) { |
|
61 | 61 | return; |
62 | 62 | } |
63 | 63 | global $current_user, $app_list_strings; |
64 | - if(empty($bean->fetched_row) || !$bean->id){ |
|
64 | + if (empty($bean->fetched_row) || !$bean->id) { |
|
65 | 65 | |
66 | - if(!$bean->state){ |
|
66 | + if (!$bean->state) { |
|
67 | 67 | $bean->state = $app_list_strings['case_state_default_key']; |
68 | 68 | } |
69 | - if($bean->status == "New"){ |
|
69 | + if ($bean->status == "New") { |
|
70 | 70 | $bean->status = $app_list_strings['case_status_default_key']; |
71 | 71 | } |
72 | 72 | |
73 | 73 | //New case - assign |
74 | - if(!$bean->assigned_user_id){ |
|
74 | + if (!$bean->assigned_user_id) { |
|
75 | 75 | $userId = $this->getAssignToUser(); |
76 | 76 | $bean->assigned_user_id = $userId; |
77 | 77 | $bean->notify_inworkflow = true; |
78 | 78 | } |
79 | 79 | return; |
80 | 80 | } |
81 | - if($_REQUEST['module'] == 'Import'){ |
|
81 | + if ($_REQUEST['module'] == 'Import') { |
|
82 | 82 | return; |
83 | 83 | } |
84 | 84 | //Grab the update field and create a new update with it. |
85 | 85 | $text = $bean->update_text; |
86 | - if(!$text && empty($_FILES['case_update_file'])){ |
|
86 | + if (!$text && empty($_FILES['case_update_file'])) { |
|
87 | 87 | //No text or files, so nothing really to save. |
88 | 88 | return; |
89 | 89 | } |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | $case_update->internal = $bean->internal; |
94 | 94 | $bean->internal = false; |
95 | 95 | $case_update->assigned_user_id = $current_user->id; |
96 | - if(strlen($text) > $this->slug_size){ |
|
97 | - $case_update->name = substr($text,0,$this->slug_size)."..."; |
|
96 | + if (strlen($text) > $this->slug_size) { |
|
97 | + $case_update->name = substr($text, 0, $this->slug_size)."..."; |
|
98 | 98 | } |
99 | 99 | $case_update->description = nl2br($text); |
100 | 100 | $case_update->case_id = $bean->id; |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | |
103 | 103 | $fileCount = $this->arrangeFilesArray(); |
104 | 104 | |
105 | - for($x = 0; $x < $fileCount; $x++){ |
|
106 | - if($_FILES['case_update_file']['error'][$x] == UPLOAD_ERR_NO_FILE){ |
|
105 | + for ($x = 0; $x < $fileCount; $x++) { |
|
106 | + if ($_FILES['case_update_file']['error'][$x] == UPLOAD_ERR_NO_FILE) { |
|
107 | 107 | continue; |
108 | 108 | } |
109 | 109 | $uploadFile = new UploadFile('case_update_file'.$x); |
110 | - if(!$uploadFile->confirm_upload()){ |
|
110 | + if (!$uploadFile->confirm_upload()) { |
|
111 | 111 | continue; |
112 | 112 | } |
113 | 113 | $note = $this->newNote($case_update->id); |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | $uploadFile->final_move($note->id); |
119 | 119 | } |
120 | 120 | $postPrefix = 'case_update_id_'; |
121 | - foreach($_POST as $key => $val){ |
|
122 | - if(strpos($key, $postPrefix) !== 0 || empty($val)){ |
|
121 | + foreach ($_POST as $key => $val) { |
|
122 | + if (strpos($key, $postPrefix) !== 0 || empty($val)) { |
|
123 | 123 | continue; |
124 | 124 | } |
125 | 125 | //Val is selected doc id |
126 | - $doc = BeanFactory::getBean('Documents',$val); |
|
127 | - if(!$doc){ |
|
126 | + $doc = BeanFactory::getBean('Documents', $val); |
|
127 | + if (!$doc) { |
|
128 | 128 | continue; |
129 | 129 | } |
130 | 130 | $note = $this->newNote($case_update->id); |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | $note->save(); |
135 | 135 | $srcFile = "upload://{$doc->document_revision_id}"; |
136 | 136 | $destFile = "upload://{$note->id}"; |
137 | - copy($srcFile,$destFile); |
|
137 | + copy($srcFile, $destFile); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
141 | - private function newNote($caseUpdateId){ |
|
141 | + private function newNote($caseUpdateId) { |
|
142 | 142 | $note = BeanFactory::newBean('Notes'); |
143 | 143 | $note->parent_type = 'AOP_Case_Updates'; |
144 | 144 | $note->parent_id = $caseUpdateId; |
@@ -146,30 +146,30 @@ discard block |
||
146 | 146 | return $note; |
147 | 147 | } |
148 | 148 | |
149 | - private function linkAccountAndCase($case_id,$account_id){ |
|
150 | - if(!$account_id || !$case_id){ |
|
149 | + private function linkAccountAndCase($case_id, $account_id) { |
|
150 | + if (!$account_id || !$case_id) { |
|
151 | 151 | return; |
152 | 152 | } |
153 | - $case = BeanFactory::getBean("Cases",$case_id); |
|
154 | - if(!$case->account_id){ |
|
153 | + $case = BeanFactory::getBean("Cases", $case_id); |
|
154 | + if (!$case->account_id) { |
|
155 | 155 | $case->account_id = $account_id; |
156 | 156 | $case->save(); |
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
160 | - public function assignAccount($bean, $event, $arguments){ |
|
161 | - if($arguments['module'] != "Cases" || $arguments['related_module'] != "Contacts"){ |
|
160 | + public function assignAccount($bean, $event, $arguments) { |
|
161 | + if ($arguments['module'] != "Cases" || $arguments['related_module'] != "Contacts") { |
|
162 | 162 | return; |
163 | 163 | } |
164 | - if(!isAOPEnabled()){ |
|
164 | + if (!isAOPEnabled()) { |
|
165 | 165 | return; |
166 | 166 | } |
167 | - $contact = BeanFactory::getBean("Contacts",$arguments['related_id']); |
|
167 | + $contact = BeanFactory::getBean("Contacts", $arguments['related_id']); |
|
168 | 168 | $contact->load_relationship("accounts"); |
169 | - if(!$contact || !$contact->account_id){ |
|
169 | + if (!$contact || !$contact->account_id) { |
|
170 | 170 | return; |
171 | 171 | } |
172 | - $this->linkAccountAndCase($bean->id,$contact->account_id); |
|
172 | + $this->linkAccountAndCase($bean->id, $contact->account_id); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -178,26 +178,26 @@ discard block |
||
178 | 178 | * @param $event |
179 | 179 | * @param $arguments |
180 | 180 | */ |
181 | - public function saveEmailUpdate($bean, $event, $arguments){ |
|
181 | + public function saveEmailUpdate($bean, $event, $arguments) { |
|
182 | 182 | global $mod_strings; |
183 | - if($bean->intent != "createcase" || $bean->parent_type != "Cases"){ |
|
183 | + if ($bean->intent != "createcase" || $bean->parent_type != "Cases") { |
|
184 | 184 | $GLOBALS['log']->warn("CaseUpdatesHook: saveEmailUpdate: Not a create case or wrong parent type"); |
185 | 185 | return; |
186 | 186 | } |
187 | - if(!isAOPEnabled()){ |
|
187 | + if (!isAOPEnabled()) { |
|
188 | 188 | return; |
189 | 189 | } |
190 | - if(!$bean->parent_id ){ |
|
190 | + if (!$bean->parent_id) { |
|
191 | 191 | $GLOBALS['log']->warn("CaseUpdatesHook: saveEmailUpdate No parent id"); |
192 | 192 | return; |
193 | 193 | } |
194 | 194 | |
195 | - if($bean->cases){ |
|
195 | + if ($bean->cases) { |
|
196 | 196 | $GLOBALS['log']->warn("CaseUpdatesHook: saveEmailUpdate cases already set"); |
197 | 197 | return; |
198 | 198 | } |
199 | 199 | |
200 | - if($bean->fetched_row['parent_id']){ |
|
200 | + if ($bean->fetched_row['parent_id']) { |
|
201 | 201 | //Will have been processed already |
202 | 202 | return; |
203 | 203 | } |
@@ -206,10 +206,10 @@ discard block |
||
206 | 206 | $ea = new SugarEmailAddress(); |
207 | 207 | $beans = $ea->getBeansByEmailAddress($bean->from_addr); |
208 | 208 | $contact_id = null; |
209 | - foreach($beans as $emailBean){ |
|
210 | - if($emailBean->module_name == "Contacts" && !empty($emailBean->id)){ |
|
209 | + foreach ($beans as $emailBean) { |
|
210 | + if ($emailBean->module_name == "Contacts" && !empty($emailBean->id)) { |
|
211 | 211 | $contact_id = $emailBean->id; |
212 | - $this->linkAccountAndCase($bean->parent_id,$emailBean->account_id); |
|
212 | + $this->linkAccountAndCase($bean->parent_id, $emailBean->account_id); |
|
213 | 213 | } |
214 | 214 | } |
215 | 215 | $case_update = new AOP_Case_Updates(); |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | $case_update->internal = false; |
221 | 221 | $case_update->case_id = $bean->parent_id; |
222 | 222 | $case_update->save(); |
223 | - $notes = $bean->get_linked_beans('notes','Notes'); |
|
224 | - foreach($notes as $note){ |
|
223 | + $notes = $bean->get_linked_beans('notes', 'Notes'); |
|
224 | + foreach ($notes as $note) { |
|
225 | 225 | //Link notes to case update also |
226 | 226 | $newNote = BeanFactory::newBean('Notes'); |
227 | 227 | $newNote->name = $note->name; |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | $newNote->save(); |
233 | 233 | $srcFile = "upload://{$note->id}"; |
234 | 234 | $destFile = "upload://{$newNote->id}"; |
235 | - copy($srcFile,$destFile); |
|
235 | + copy($srcFile, $destFile); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | $this->updateCaseStatus($case_update->case_id); |
@@ -242,71 +242,71 @@ discard block |
||
242 | 242 | * Changes the status of the supplied case based on the case_status_changes config values. |
243 | 243 | * @param $caseId |
244 | 244 | */ |
245 | - private function updateCaseStatus($caseId){ |
|
245 | + private function updateCaseStatus($caseId) { |
|
246 | 246 | global $sugar_config; |
247 | - if(empty($caseId)){ |
|
247 | + if (empty($caseId)) { |
|
248 | 248 | return; |
249 | 249 | } |
250 | - if(empty($sugar_config['aop']['case_status_changes'])){ |
|
250 | + if (empty($sugar_config['aop']['case_status_changes'])) { |
|
251 | 251 | return; |
252 | 252 | } |
253 | - $statusMap = json_decode($sugar_config['aop']['case_status_changes'],1); |
|
254 | - if(empty($statusMap)){ |
|
253 | + $statusMap = json_decode($sugar_config['aop']['case_status_changes'], 1); |
|
254 | + if (empty($statusMap)) { |
|
255 | 255 | return; |
256 | 256 | } |
257 | - $case = BeanFactory::getBean('Cases',$caseId); |
|
258 | - if(empty($case)){ |
|
257 | + $case = BeanFactory::getBean('Cases', $caseId); |
|
258 | + if (empty($case)) { |
|
259 | 259 | return; |
260 | 260 | } |
261 | - if(array_key_exists($case->status,$statusMap)){ |
|
261 | + if (array_key_exists($case->status, $statusMap)) { |
|
262 | 262 | $case->status = $statusMap[$case->status]; |
263 | - $statusBits = explode('_',$case->status); |
|
263 | + $statusBits = explode('_', $case->status); |
|
264 | 264 | $case->state = array_shift($statusBits); |
265 | 265 | $case->save(); |
266 | 266 | } |
267 | 267 | |
268 | 268 | } |
269 | 269 | |
270 | - private function unquoteEmail($text){ |
|
270 | + private function unquoteEmail($text) { |
|
271 | 271 | global $app_strings; |
272 | 272 | $text = html_entity_decode($text); |
273 | - $text = preg_replace('/(\r\n|\r|\n)/s',"\n",$text); |
|
274 | - $pos = strpos($text,$app_strings['LBL_AOP_EMAIL_REPLY_DELIMITER']); |
|
275 | - if($pos !== false){ |
|
276 | - $text = substr($text,0,$pos); |
|
273 | + $text = preg_replace('/(\r\n|\r|\n)/s', "\n", $text); |
|
274 | + $pos = strpos($text, $app_strings['LBL_AOP_EMAIL_REPLY_DELIMITER']); |
|
275 | + if ($pos !== false) { |
|
276 | + $text = substr($text, 0, $pos); |
|
277 | 277 | } |
278 | 278 | return $text; |
279 | 279 | } |
280 | 280 | |
281 | - public function closureNotifyPrep($bean, $event, $arguments){ |
|
282 | - if($_REQUEST['module'] == 'Import'){ |
|
281 | + public function closureNotifyPrep($bean, $event, $arguments) { |
|
282 | + if ($_REQUEST['module'] == 'Import') { |
|
283 | 283 | return; |
284 | 284 | } |
285 | - if($bean->state!= "Closed" || $bean->fetched_row['state'] == "Closed"){ |
|
285 | + if ($bean->state != "Closed" || $bean->fetched_row['state'] == "Closed") { |
|
286 | 286 | $bean->send_closure_email = false; |
287 | - }else{ |
|
287 | + } else { |
|
288 | 288 | $bean->send_closure_email = true; |
289 | 289 | } |
290 | 290 | |
291 | 291 | } |
292 | 292 | |
293 | - public function closureNotify($bean, $event, $arguments){ |
|
294 | - if($_REQUEST['module'] == 'Import'){ |
|
293 | + public function closureNotify($bean, $event, $arguments) { |
|
294 | + if ($_REQUEST['module'] == 'Import') { |
|
295 | 295 | return; |
296 | 296 | } |
297 | - if($bean->state != "Closed" || !$bean->send_closure_email){ |
|
297 | + if ($bean->state != "Closed" || !$bean->send_closure_email) { |
|
298 | 298 | return; |
299 | 299 | } |
300 | 300 | $this->sendClosureEmail($bean, $arguments['related_bean']); |
301 | 301 | } |
302 | 302 | |
303 | - private function sendClosureEmail(aCase $bean){ |
|
304 | - if(!isAOPEnabled()){ |
|
303 | + private function sendClosureEmail(aCase $bean) { |
|
304 | + if (!isAOPEnabled()) { |
|
305 | 305 | return; |
306 | 306 | } |
307 | 307 | $GLOBALS['log']->warn("CaseUpdatesHook: sendClosureEmail called"); |
308 | 308 | require_once("include/SugarPHPMailer.php"); |
309 | - $mailer=new SugarPHPMailer(); |
|
309 | + $mailer = new SugarPHPMailer(); |
|
310 | 310 | $admin = new Administration(); |
311 | 311 | $admin->retrieveSettings(); |
312 | 312 | |
@@ -315,18 +315,18 @@ discard block |
||
315 | 315 | |
316 | 316 | $email_template = new EmailTemplate(); |
317 | 317 | $aop_config = $this->getAOPConfig(); |
318 | - $GLOBALS['log']->warn("CaseUpdatesHook: sendClosureEmail Config is ".print_r($aop_config,true)); |
|
318 | + $GLOBALS['log']->warn("CaseUpdatesHook: sendClosureEmail Config is ".print_r($aop_config, true)); |
|
319 | 319 | $email_template = $email_template->retrieve($aop_config['case_closure_email_template_id']); |
320 | 320 | |
321 | - if(!$email_template){ |
|
321 | + if (!$email_template) { |
|
322 | 322 | $GLOBALS['log']->warn("CaseUpdatesHook: sendClosureEmail template is empty"); |
323 | 323 | return false; |
324 | 324 | } |
325 | 325 | |
326 | - $contact = $bean->get_linked_beans("contacts","Contact"); |
|
327 | - if($contact){ |
|
326 | + $contact = $bean->get_linked_beans("contacts", "Contact"); |
|
327 | + if ($contact) { |
|
328 | 328 | $contact = $contact[0]; |
329 | - }else{ |
|
329 | + } else { |
|
330 | 330 | return false; |
331 | 331 | } |
332 | 332 | |
@@ -343,10 +343,10 @@ discard block |
||
343 | 343 | $email = $contact->emailAddress->getPrimaryAddress($contact); |
344 | 344 | |
345 | 345 | $mailer->AddAddress($email); |
346 | - if (!$mailer->Send()){ |
|
347 | - $GLOBALS['log']->info("CaseUpdatesHook: Could not send email: " . $mailer->ErrorInfo); |
|
346 | + if (!$mailer->Send()) { |
|
347 | + $GLOBALS['log']->info("CaseUpdatesHook: Could not send email: ".$mailer->ErrorInfo); |
|
348 | 348 | return false; |
349 | - }else{ |
|
349 | + } else { |
|
350 | 350 | $this->logEmail($email, $mailer, $bean->id); |
351 | 351 | return true; |
352 | 352 | } |
@@ -359,25 +359,25 @@ discard block |
||
359 | 359 | * @param $event |
360 | 360 | * @param $arguments |
361 | 361 | */ |
362 | - public function creationNotify($bean, $event, $arguments){ |
|
363 | - if($_REQUEST['module'] == 'Import'){ |
|
362 | + public function creationNotify($bean, $event, $arguments) { |
|
363 | + if ($_REQUEST['module'] == 'Import') { |
|
364 | 364 | return; |
365 | 365 | } |
366 | - if($arguments['module'] != "Cases" || $arguments['related_module'] != "Contacts"){ |
|
366 | + if ($arguments['module'] != "Cases" || $arguments['related_module'] != "Contacts") { |
|
367 | 367 | return; |
368 | 368 | } |
369 | - if(!$bean->fetched_row){ |
|
369 | + if (!$bean->fetched_row) { |
|
370 | 370 | return; |
371 | 371 | } |
372 | - if(!empty($arguments['related_bean'])){ |
|
372 | + if (!empty($arguments['related_bean'])) { |
|
373 | 373 | $contact = $arguments['related_bean']; |
374 | - }else{ |
|
375 | - $contact = BeanFactory::getBean("Contacts",$arguments['related_id']); |
|
374 | + } else { |
|
375 | + $contact = BeanFactory::getBean("Contacts", $arguments['related_id']); |
|
376 | 376 | } |
377 | 377 | $this->sendCreationEmail($bean, $contact); |
378 | 378 | } |
379 | 379 | |
380 | - private function populateTemplate(EmailTemplate $template, aCase $bean, $contact){ |
|
380 | + private function populateTemplate(EmailTemplate $template, aCase $bean, $contact) { |
|
381 | 381 | global $app_strings, $sugar_config; |
382 | 382 | //Order of beans seems to matter here so we place contact first. |
383 | 383 | $beans = array( |
@@ -386,26 +386,26 @@ discard block |
||
386 | 386 | "Users" => $bean->assigned_user_id |
387 | 387 | ); |
388 | 388 | $ret = array(); |
389 | - $ret['subject'] = from_html(aop_parse_template($template->subject,$beans)); |
|
390 | - $ret['body'] = from_html($app_strings['LBL_AOP_EMAIL_REPLY_DELIMITER'].aop_parse_template(str_replace("\$sugarurl",$sugar_config['site_url'],$template->body_html),$beans)); |
|
391 | - $ret['body_alt'] = strip_tags(from_html(aop_parse_template(str_replace("\$sugarurl",$sugar_config['site_url'],$template->body),$beans))); |
|
389 | + $ret['subject'] = from_html(aop_parse_template($template->subject, $beans)); |
|
390 | + $ret['body'] = from_html($app_strings['LBL_AOP_EMAIL_REPLY_DELIMITER'].aop_parse_template(str_replace("\$sugarurl", $sugar_config['site_url'], $template->body_html), $beans)); |
|
391 | + $ret['body_alt'] = strip_tags(from_html(aop_parse_template(str_replace("\$sugarurl", $sugar_config['site_url'], $template->body), $beans))); |
|
392 | 392 | return $ret; |
393 | 393 | } |
394 | 394 | |
395 | - private function getAOPConfig(){ |
|
395 | + private function getAOPConfig() { |
|
396 | 396 | global $sugar_config; |
397 | - if(!array_key_exists("aop",$sugar_config)){ |
|
397 | + if (!array_key_exists("aop", $sugar_config)) { |
|
398 | 398 | return array(); |
399 | 399 | } |
400 | 400 | return $sugar_config['aop']; |
401 | 401 | } |
402 | 402 | |
403 | - private function sendCreationEmail(aCase $bean, $contact){ |
|
404 | - if(!isAOPEnabled()){ |
|
403 | + private function sendCreationEmail(aCase $bean, $contact) { |
|
404 | + if (!isAOPEnabled()) { |
|
405 | 405 | return; |
406 | 406 | } |
407 | 407 | require_once("include/SugarPHPMailer.php"); |
408 | - $mailer=new SugarPHPMailer(); |
|
408 | + $mailer = new SugarPHPMailer(); |
|
409 | 409 | $admin = new Administration(); |
410 | 410 | $admin->retrieveSettings(); |
411 | 411 | |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | |
417 | 417 | $aop_config = $this->getAOPConfig(); |
418 | 418 | $email_template = $email_template->retrieve($aop_config['case_creation_email_template_id']); |
419 | - if(!$aop_config['case_creation_email_template_id'] || !$email_template){ |
|
419 | + if (!$aop_config['case_creation_email_template_id'] || !$email_template) { |
|
420 | 420 | $GLOBALS['log']->warn("CaseUpdatesHook: sendCreationEmail template is empty"); |
421 | 421 | return false; |
422 | 422 | } |
@@ -430,24 +430,24 @@ discard block |
||
430 | 430 | $mailer->From = $emailSettings['from_address']; |
431 | 431 | $mailer->FromName = $emailSettings['from_name']; |
432 | 432 | $email = $contact->emailAddress->getPrimaryAddress($contact); |
433 | - if(empty($email) && !empty($contact->email1)){ |
|
433 | + if (empty($email) && !empty($contact->email1)) { |
|
434 | 434 | $email = $contact->email1; |
435 | 435 | } |
436 | 436 | $mailer->AddAddress($email); |
437 | - if (!$mailer->Send()){ |
|
438 | - $GLOBALS['log']->info("CaseUpdatesHook: Could not send email: " . $mailer->ErrorInfo); |
|
437 | + if (!$mailer->Send()) { |
|
438 | + $GLOBALS['log']->info("CaseUpdatesHook: Could not send email: ".$mailer->ErrorInfo); |
|
439 | 439 | return false; |
440 | - }else{ |
|
440 | + } else { |
|
441 | 441 | $this->logEmail($email, $mailer, $bean->id); |
442 | 442 | return true; |
443 | 443 | } |
444 | 444 | } |
445 | 445 | |
446 | - private function logEmail($email, $mailer, $caseId = null){ |
|
446 | + private function logEmail($email, $mailer, $caseId = null) { |
|
447 | 447 | require_once('modules/Emails/Email.php'); |
448 | 448 | $emailObj = new Email(); |
449 | 449 | $emailObj->to_addrs = $email; |
450 | - $emailObj->type= 'out'; |
|
450 | + $emailObj->type = 'out'; |
|
451 | 451 | $emailObj->deleted = '0'; |
452 | 452 | $emailObj->name = $mailer->Subject; |
453 | 453 | $emailObj->description = $mailer->AltBody; |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | $emailObj->save(); |
465 | 465 | } |
466 | 466 | |
467 | - public function filterHTML($bean, $event, $arguments){ |
|
468 | - $bean->description = SugarCleaner::cleanHtml($bean->description,true); |
|
467 | + public function filterHTML($bean, $event, $arguments) { |
|
468 | + $bean->description = SugarCleaner::cleanHtml($bean->description, true); |
|
469 | 469 | } |
470 | 470 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | } |
285 | 285 | if($bean->state!= "Closed" || $bean->fetched_row['state'] == "Closed"){ |
286 | 286 | $bean->send_closure_email = false; |
287 | - }else{ |
|
287 | + } else{ |
|
288 | 288 | $bean->send_closure_email = true; |
289 | 289 | } |
290 | 290 | |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | $contact = $bean->get_linked_beans("contacts","Contact"); |
327 | 327 | if($contact){ |
328 | 328 | $contact = $contact[0]; |
329 | - }else{ |
|
329 | + } else{ |
|
330 | 330 | return false; |
331 | 331 | } |
332 | 332 | |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | if (!$mailer->Send()){ |
347 | 347 | $GLOBALS['log']->info("CaseUpdatesHook: Could not send email: " . $mailer->ErrorInfo); |
348 | 348 | return false; |
349 | - }else{ |
|
349 | + } else{ |
|
350 | 350 | $this->logEmail($email, $mailer, $bean->id); |
351 | 351 | return true; |
352 | 352 | } |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | } |
372 | 372 | if(!empty($arguments['related_bean'])){ |
373 | 373 | $contact = $arguments['related_bean']; |
374 | - }else{ |
|
374 | + } else{ |
|
375 | 375 | $contact = BeanFactory::getBean("Contacts",$arguments['related_id']); |
376 | 376 | } |
377 | 377 | $this->sendCreationEmail($bean, $contact); |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | if (!$mailer->Send()){ |
438 | 438 | $GLOBALS['log']->info("CaseUpdatesHook: Could not send email: " . $mailer->ErrorInfo); |
439 | 439 | return false; |
440 | - }else{ |
|
440 | + } else{ |
|
441 | 441 | $this->logEmail($email, $mailer, $bean->id); |
442 | 442 | return true; |
443 | 443 | } |
@@ -443,6 +443,9 @@ |
||
443 | 443 | } |
444 | 444 | } |
445 | 445 | |
446 | + /** |
|
447 | + * @param SugarPHPMailer $mailer |
|
448 | + */ |
|
446 | 449 | private function logEmail($email, $mailer, $caseId = null){ |
447 | 450 | require_once('modules/Emails/Email.php'); |
448 | 451 | $emailObj = new Email(); |
@@ -1,26 +1,26 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * |
|
4 | - * @package Advanced OpenPortal |
|
5 | - * @copyright SalesAgility Ltd http://www.salesagility.com |
|
6 | - * |
|
7 | - * This program is free software; you can redistribute it and/or modify |
|
8 | - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by |
|
9 | - * the Free Software Foundation; either version 3 of the License, or |
|
10 | - * (at your option) any later version. |
|
11 | - * |
|
12 | - * This program is distributed in the hope that it will be useful, |
|
13 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 | - * GNU General Public License for more details. |
|
16 | - * |
|
17 | - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
18 | - * along with this program; if not, see http://www.gnu.org/licenses |
|
19 | - * or write to the Free Software Foundation,Inc., 51 Franklin Street, |
|
20 | - * Fifth Floor, Boston, MA 02110-1301 USA |
|
21 | - * |
|
22 | - * @author Salesagility Ltd <[email protected]> |
|
23 | - */ |
|
3 | + * |
|
4 | + * @package Advanced OpenPortal |
|
5 | + * @copyright SalesAgility Ltd http://www.salesagility.com |
|
6 | + * |
|
7 | + * This program is free software; you can redistribute it and/or modify |
|
8 | + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by |
|
9 | + * the Free Software Foundation; either version 3 of the License, or |
|
10 | + * (at your option) any later version. |
|
11 | + * |
|
12 | + * This program is distributed in the hope that it will be useful, |
|
13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 | + * GNU General Public License for more details. |
|
16 | + * |
|
17 | + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
18 | + * along with this program; if not, see http://www.gnu.org/licenses |
|
19 | + * or write to the Free Software Foundation,Inc., 51 Franklin Street, |
|
20 | + * Fifth Floor, Boston, MA 02110-1301 USA |
|
21 | + * |
|
22 | + * @author Salesagility Ltd <[email protected]> |
|
23 | + */ |
|
24 | 24 | |
25 | 25 | |
26 | 26 | function display_updates($focus, $field, $value, $view){ |
@@ -1,26 +1,26 @@ discard block |
||
1 | 1 | <?PHP |
2 | 2 | /** |
3 | - * |
|
4 | - * @package Advanced OpenPortal |
|
5 | - * @copyright SalesAgility Ltd http://www.salesagility.com |
|
6 | - * |
|
7 | - * This program is free software; you can redistribute it and/or modify |
|
8 | - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by |
|
9 | - * the Free Software Foundation; either version 3 of the License, or |
|
10 | - * (at your option) any later version. |
|
11 | - * |
|
12 | - * This program is distributed in the hope that it will be useful, |
|
13 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 | - * GNU General Public License for more details. |
|
16 | - * |
|
17 | - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
18 | - * along with this program; if not, see http://www.gnu.org/licenses |
|
19 | - * or write to the Free Software Foundation,Inc., 51 Franklin Street, |
|
20 | - * Fifth Floor, Boston, MA 02110-1301 USA |
|
21 | - * |
|
22 | - * @author Salesagility Ltd <[email protected]> |
|
23 | - */ |
|
3 | + * |
|
4 | + * @package Advanced OpenPortal |
|
5 | + * @copyright SalesAgility Ltd http://www.salesagility.com |
|
6 | + * |
|
7 | + * This program is free software; you can redistribute it and/or modify |
|
8 | + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by |
|
9 | + * the Free Software Foundation; either version 3 of the License, or |
|
10 | + * (at your option) any later version. |
|
11 | + * |
|
12 | + * This program is distributed in the hope that it will be useful, |
|
13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 | + * GNU General Public License for more details. |
|
16 | + * |
|
17 | + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
18 | + * along with this program; if not, see http://www.gnu.org/licenses |
|
19 | + * or write to the Free Software Foundation,Inc., 51 Franklin Street, |
|
20 | + * Fifth Floor, Boston, MA 02110-1301 USA |
|
21 | + * |
|
22 | + * @author Salesagility Ltd <[email protected]> |
|
23 | + */ |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * THIS CLASS IS GENERATED BY MODULE BUILDER |
@@ -30,37 +30,37 @@ discard block |
||
30 | 30 | |
31 | 31 | |
32 | 32 | class AOP_Case_Updates_sugar extends Basic { |
33 | - var $new_schema = true; |
|
34 | - var $module_dir = 'AOP_Case_Updates'; |
|
35 | - var $object_name = 'AOP_Case_Updates'; |
|
36 | - var $table_name = 'aop_case_updates'; |
|
37 | - var $tracker_visibility = false; |
|
38 | - var $importable = false; |
|
39 | - var $disable_row_level_security = true ; // to ensure that modules created and deployed under CE will continue to function under team security if the instance is upgraded to PRO |
|
40 | - var $id; |
|
41 | - var $name; |
|
42 | - var $date_entered; |
|
43 | - var $date_modified; |
|
44 | - var $modified_user_id; |
|
45 | - var $modified_by_name; |
|
46 | - var $created_by; |
|
47 | - var $created_by_name; |
|
48 | - var $description; |
|
49 | - var $deleted; |
|
50 | - var $created_by_link; |
|
51 | - var $modified_user_link; |
|
52 | - var $assigned_user_id; |
|
53 | - var $assigned_user_name; |
|
54 | - var $assigned_user_link; |
|
55 | - function AOP_Case_Updates_sugar(){ |
|
56 | - parent::Basic(); |
|
57 | - } |
|
33 | + var $new_schema = true; |
|
34 | + var $module_dir = 'AOP_Case_Updates'; |
|
35 | + var $object_name = 'AOP_Case_Updates'; |
|
36 | + var $table_name = 'aop_case_updates'; |
|
37 | + var $tracker_visibility = false; |
|
38 | + var $importable = false; |
|
39 | + var $disable_row_level_security = true ; // to ensure that modules created and deployed under CE will continue to function under team security if the instance is upgraded to PRO |
|
40 | + var $id; |
|
41 | + var $name; |
|
42 | + var $date_entered; |
|
43 | + var $date_modified; |
|
44 | + var $modified_user_id; |
|
45 | + var $modified_by_name; |
|
46 | + var $created_by; |
|
47 | + var $created_by_name; |
|
48 | + var $description; |
|
49 | + var $deleted; |
|
50 | + var $created_by_link; |
|
51 | + var $modified_user_link; |
|
52 | + var $assigned_user_id; |
|
53 | + var $assigned_user_name; |
|
54 | + var $assigned_user_link; |
|
55 | + function AOP_Case_Updates_sugar(){ |
|
56 | + parent::Basic(); |
|
57 | + } |
|
58 | 58 | |
59 | - function bean_implements($interface){ |
|
60 | - switch($interface){ |
|
61 | - case 'ACL': return true; |
|
62 | - } |
|
63 | - return false; |
|
59 | + function bean_implements($interface){ |
|
60 | + switch($interface){ |
|
61 | + case 'ACL': return true; |
|
62 | + } |
|
63 | + return false; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | var $table_name = 'aop_case_updates'; |
37 | 37 | var $tracker_visibility = false; |
38 | 38 | var $importable = false; |
39 | - var $disable_row_level_security = true ; // to ensure that modules created and deployed under CE will continue to function under team security if the instance is upgraded to PRO |
|
39 | + var $disable_row_level_security = true; // to ensure that modules created and deployed under CE will continue to function under team security if the instance is upgraded to PRO |
|
40 | 40 | var $id; |
41 | 41 | var $name; |
42 | 42 | var $date_entered; |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | var $assigned_user_id; |
53 | 53 | var $assigned_user_name; |
54 | 54 | var $assigned_user_link; |
55 | - function AOP_Case_Updates_sugar(){ |
|
55 | + function AOP_Case_Updates_sugar() { |
|
56 | 56 | parent::Basic(); |
57 | 57 | } |
58 | 58 | |
59 | - function bean_implements($interface){ |
|
60 | - switch($interface){ |
|
59 | + function bean_implements($interface) { |
|
60 | + switch ($interface) { |
|
61 | 61 | case 'ACL': return true; |
62 | 62 | } |
63 | 63 | return false; |