@@ -35,6 +35,7 @@ discard block |
||
35 | 35 | * reads record from backend if identifier is given. |
36 | 36 | * |
37 | 37 | * @param string $_identifier |
38 | + * @return void |
|
38 | 39 | */ |
39 | 40 | public function __construct( $_identifier='' ); |
40 | 41 | |
@@ -50,6 +51,7 @@ discard block |
||
50 | 51 | * |
51 | 52 | * @param string $_attribute_name |
52 | 53 | * @param data $data |
54 | + * @return void |
|
53 | 55 | */ |
54 | 56 | public function __set($_attribute_name, $data); |
55 | 57 | |
@@ -126,6 +128,7 @@ discard block |
||
126 | 128 | /** |
127 | 129 | * destructor |
128 | 130 | * |
131 | + * @return void |
|
129 | 132 | */ |
130 | 133 | public function __destruct(); |
131 | 134 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @param string $_identifier |
38 | 38 | */ |
39 | - public function __construct( $_identifier='' ); |
|
39 | + public function __construct($_identifier = ''); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * magic method to set attributes of record |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @return string identifier |
99 | 99 | */ |
100 | - public function save ( $_dst_identifier ); |
|
100 | + public function save($_dst_identifier); |
|
101 | 101 | |
102 | 102 | /** |
103 | 103 | * copys current record to record identified by $_dst_identifier |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @param string $_dst_identifier |
106 | 106 | * @return string dst_identifier |
107 | 107 | */ |
108 | - public function copy ( $_dst_identifier ); |
|
108 | + public function copy($_dst_identifier); |
|
109 | 109 | |
110 | 110 | /** |
111 | 111 | * moves current record to record identified by $_dst_identifier |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | * @param string $_dst_identifier |
115 | 115 | * @return string dst_identifier |
116 | 116 | */ |
117 | - public function move ( $_dst_identifier ); |
|
117 | + public function move($_dst_identifier); |
|
118 | 118 | |
119 | 119 | /** |
120 | 120 | * delets current record from backend |
121 | 121 | * @return void |
122 | 122 | * |
123 | 123 | */ |
124 | - public function delete (); |
|
124 | + public function delete(); |
|
125 | 125 | |
126 | 126 | /** |
127 | 127 | * destructor |
@@ -107,7 +107,7 @@ |
||
107 | 107 | * and automatic conversions. In most cases they are named <appname>_egw_record, |
108 | 108 | * but projectmanager is an exception to this. |
109 | 109 | * |
110 | - * @return string; |
|
110 | + * @return string |
|
111 | 111 | */ |
112 | 112 | public static function get_egw_record_class(); |
113 | 113 | } // end of iface_export_plugin |
@@ -34,7 +34,8 @@ |
||
34 | 34 | * |
35 | 35 | * get_selector(); //returns array |
36 | 36 | */ |
37 | -interface importexport_iface_export_plugin { |
|
37 | +interface importexport_iface_export_plugin |
|
38 | +{ |
|
38 | 39 | |
39 | 40 | /** |
40 | 41 | * exports entries according to given definition object. |
@@ -54,7 +54,7 @@ |
||
54 | 54 | * destructor |
55 | 55 | * |
56 | 56 | * @return |
57 | - */ |
|
57 | + void |
|
58 | 58 | public function __destruct( ); |
59 | 59 | |
60 | 60 | } // end of iface_export_record |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param array $_options options for specific backends |
34 | 34 | * @return bool |
35 | 35 | */ |
36 | - public function __construct( $_stream, array $_options ); |
|
36 | + public function __construct($_stream, array $_options); |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * exports a record into resource of handle |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param object of interface egw_record _record |
42 | 42 | * @return bool |
43 | 43 | */ |
44 | - public function export_record( importexport_iface_egw_record $_record ); |
|
44 | + public function export_record(importexport_iface_egw_record $_record); |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Retruns total number of exported records. |
@@ -29,8 +29,8 @@ |
||
29 | 29 | /** |
30 | 30 | * imports entries according to given definition object. |
31 | 31 | * |
32 | - * @param stram $_stram |
|
33 | - * @param definition $_definition |
|
32 | + * @param stram $_stream |
|
33 | + * @param importexport_definition $_definition |
|
34 | 34 | * @return int number of successful imports |
35 | 35 | */ |
36 | 36 | public function import( $_stream, importexport_definition $_definition ); |
@@ -88,33 +88,33 @@ |
||
88 | 88 | public function get_selectors_etpl(); |
89 | 89 | |
90 | 90 | /** |
91 | - * Returns errors that were encountered during importing |
|
92 | - * Maximum of one error message per record, but you can concatenate them if you need to |
|
93 | - * |
|
94 | - * @return Array ( |
|
95 | - * record_# => error message |
|
96 | - * ) |
|
97 | - */ |
|
91 | + * Returns errors that were encountered during importing |
|
92 | + * Maximum of one error message per record, but you can concatenate them if you need to |
|
93 | + * |
|
94 | + * @return Array ( |
|
95 | + * record_# => error message |
|
96 | + * ) |
|
97 | + */ |
|
98 | 98 | public function get_errors(); |
99 | 99 | |
100 | 100 | /** |
101 | - * Returns warnings that were encountered during importing |
|
102 | - * Maximum of one warning message per record, but you can concatenate them if you need to |
|
103 | - * |
|
104 | - * @return Array ( |
|
105 | - * record_# => warning message |
|
106 | - * ) |
|
107 | - */ |
|
101 | + * Returns warnings that were encountered during importing |
|
102 | + * Maximum of one warning message per record, but you can concatenate them if you need to |
|
103 | + * |
|
104 | + * @return Array ( |
|
105 | + * record_# => warning message |
|
106 | + * ) |
|
107 | + */ |
|
108 | 108 | public function get_warnings(); |
109 | 109 | |
110 | 110 | /** |
111 | - * Returns a list of actions taken, and the number of records for that action. |
|
112 | - * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
113 | - * |
|
114 | - * @return Array ( |
|
115 | - * action => record count |
|
116 | - * ) |
|
117 | - */ |
|
111 | + * Returns a list of actions taken, and the number of records for that action. |
|
112 | + * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
113 | + * |
|
114 | + * @return Array ( |
|
115 | + * action => record count |
|
116 | + * ) |
|
117 | + */ |
|
118 | 118 | public function get_results(); |
119 | 119 | |
120 | 120 | } // end of iface_export_plugin |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * @param definition $_definition |
34 | 34 | * @return int number of successful imports |
35 | 35 | */ |
36 | - public function import( $_stream, importexport_definition $_definition ); |
|
36 | + public function import($_stream, importexport_definition $_definition); |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Reads entries, and presents them back as they will be understood |
@@ -24,7 +24,8 @@ |
||
24 | 24 | * So this interface just garanties the interaction with userinterfaces. It |
25 | 25 | * has nothing to do with datatypes. |
26 | 26 | */ |
27 | -interface importexport_iface_import_plugin { |
|
27 | +interface importexport_iface_import_plugin |
|
28 | +{ |
|
28 | 29 | |
29 | 30 | /** |
30 | 31 | * imports entries according to given definition object. |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * cleanup |
34 | 34 | * |
35 | 35 | * @return |
36 | - */ |
|
36 | + void |
|
37 | 37 | public function __destruct( ); |
38 | 38 | |
39 | 39 | /** |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @param array $_options options for specific backends |
28 | 28 | * @return bool |
29 | 29 | */ |
30 | - public function __construct( $_stream, array $_options ); |
|
30 | + public function __construct($_stream, array $_options); |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * cleanup |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param string _position may be: {first|last|next|previous|somenumber} |
43 | 43 | * @return bool |
44 | 44 | */ |
45 | - public function get_record( $_position = 'next' ); |
|
45 | + public function get_record($_position = 'next'); |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Retruns total number of records for the open resource. |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | /** |
138 | 138 | * updates $this->record |
139 | 139 | * |
140 | - * @param mixed $_position |
|
141 | - * @return bool |
|
140 | + * @param string $_position |
|
141 | + * @return null|false |
|
142 | 142 | */ |
143 | 143 | private function get_raw_record( $_position = 'next' ) { |
144 | 144 | switch ($_position) { |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | /** |
245 | 245 | * does conversions according to $this->conversion |
246 | 246 | * |
247 | - * @return bool |
|
247 | + * @return boolean|null |
|
248 | 248 | */ |
249 | 249 | protected function do_conversions() { |
250 | 250 | if ( $record = importexport_helper_functions::conversion( $this->record, $this->conversion, $this->conversion_class )) { |
@@ -264,7 +264,7 @@ |
||
264 | 264 | * |
265 | 265 | * @return string warnings, if any |
266 | 266 | */ |
267 | - public static function convert(Array &$record, Array $fields = array(), $appname = null, Array $selects = array(), $format=0) { |
|
267 | + public static function convert(array &$record, array $fields = array(), $appname = null, array $selects = array(), $format=0) { |
|
268 | 268 | $warnings = array(); |
269 | 269 | |
270 | 270 | // Automatic conversions |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | * @param string $_resource resource containing data. May be each valid php-stream |
84 | 84 | * @param array $_options options for the resource array with keys: charset and fieldsep |
85 | 85 | */ |
86 | - public function __construct( $_resource, array $_options ) { |
|
86 | + public function __construct($_resource, array $_options) { |
|
87 | 87 | $this->resource = $_resource; |
88 | 88 | $this->csv_fieldsep = $_options['fieldsep']; |
89 | - if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
89 | + if ($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
90 | 90 | $this->csv_charset = $_options['charset']; |
91 | 91 | return; |
92 | 92 | } // end of member function __construct |
@@ -103,20 +103,20 @@ discard block |
||
103 | 103 | * @param mixed _position may be: {current|first|last|next|previous|somenumber} |
104 | 104 | * @return mixed array with data / false if no furtor records |
105 | 105 | */ |
106 | - public function get_record( $_position = 'next' ) { |
|
106 | + public function get_record($_position = 'next') { |
|
107 | 107 | |
108 | - if ($this->get_raw_record( $_position ) === false) { |
|
108 | + if ($this->get_raw_record($_position) === false) { |
|
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | |
112 | 112 | // skip empty records |
113 | - if( count( array_unique( $this->record ) ) < 2 ) return $this->get_record( $_position ); |
|
113 | + if (count(array_unique($this->record)) < 2) return $this->get_record($_position); |
|
114 | 114 | |
115 | - if ( !empty( $this->conversion ) ) { |
|
115 | + if (!empty($this->conversion)) { |
|
116 | 116 | $this->do_conversions(); |
117 | 117 | } |
118 | 118 | |
119 | - if ( !empty( $this->mapping ) ) { |
|
119 | + if (!empty($this->mapping)) { |
|
120 | 120 | $this->do_fieldmapping(); |
121 | 121 | } |
122 | 122 | |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @param int $_numToSkip |
130 | 130 | */ |
131 | - public function skip_records( $_numToSkip ) { |
|
132 | - while ( (int)$_numToSkip-- !== 0 ) { |
|
133 | - fgetcsv( $this->resource, self::csv_max_linelength, $this->csv_fieldsep); |
|
131 | + public function skip_records($_numToSkip) { |
|
132 | + while ((int)$_numToSkip-- !== 0) { |
|
133 | + fgetcsv($this->resource, self::csv_max_linelength, $this->csv_fieldsep); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @param mixed $_position |
141 | 141 | * @return bool |
142 | 142 | */ |
143 | - private function get_raw_record( $_position = 'next' ) { |
|
143 | + private function get_raw_record($_position = 'next') { |
|
144 | 144 | switch ($_position) { |
145 | 145 | case 'current' : |
146 | 146 | if ($this->current_position == 0) { |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | } |
155 | 155 | |
156 | 156 | case 'next' : |
157 | - $csv_data = fgetcsv( $this->resource, self::csv_max_linelength, $this->csv_fieldsep); |
|
157 | + $csv_data = fgetcsv($this->resource, self::csv_max_linelength, $this->csv_fieldsep); |
|
158 | 158 | if (!is_array($csv_data)) { |
159 | 159 | return false; |
160 | 160 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $this->record = array(); |
236 | 236 | foreach ($this->mapping as $cvs_idx => $new_idx) |
237 | 237 | { |
238 | - if( $new_idx == '' ) continue; |
|
238 | + if ($new_idx == '') continue; |
|
239 | 239 | $this->record[$new_idx] = $record[$cvs_idx]; |
240 | 240 | } |
241 | 241 | return true; |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * @return bool |
248 | 248 | */ |
249 | 249 | protected function do_conversions() { |
250 | - if ( $record = importexport_helper_functions::conversion( $this->record, $this->conversion, $this->conversion_class )) { |
|
250 | + if ($record = importexport_helper_functions::conversion($this->record, $this->conversion, $this->conversion_class)) { |
|
251 | 251 | $this->record = $record; |
252 | 252 | return; |
253 | 253 | } |
@@ -264,25 +264,25 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @return string warnings, if any |
266 | 266 | */ |
267 | - public static function convert(Array &$record, Array $fields = array(), $appname = null, Array $selects = array(), $format=0) { |
|
267 | + public static function convert(Array &$record, Array $fields = array(), $appname = null, Array $selects = array(), $format = 0) { |
|
268 | 268 | $warnings = array(); |
269 | 269 | |
270 | 270 | // Automatic conversions |
271 | - if($appname) { |
|
271 | + if ($appname) { |
|
272 | 272 | |
273 | 273 | // Load translations |
274 | 274 | Api\Translation::add_app($appname); |
275 | 275 | |
276 | - if(!self::$cf_parse_cache[$appname]) { |
|
276 | + if (!self::$cf_parse_cache[$appname]) { |
|
277 | 277 | $c_fields = importexport_export_csv::convert_parse_custom_fields($appname, $selects, $links, $methods); |
278 | 278 | self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods); |
279 | 279 | } |
280 | 280 | list($c_fields, $c_selects, $links, $methods) = self::$cf_parse_cache[$appname]; |
281 | 281 | |
282 | 282 | // Add in any fields that are keys to another app |
283 | - foreach((array)$fields['links'] as $link_field => $app) |
|
283 | + foreach ((array)$fields['links'] as $link_field => $app) |
|
284 | 284 | { |
285 | - if(is_numeric($link_field)) continue; |
|
285 | + if (is_numeric($link_field)) continue; |
|
286 | 286 | $links[$link_field] = $app; |
287 | 287 | // Set it as a normal link field |
288 | 288 | $fields['links'][] = $link_field; |
@@ -290,9 +290,9 @@ discard block |
||
290 | 290 | } |
291 | 291 | |
292 | 292 | // Not quite a recursive merge, since only one level |
293 | - foreach($fields as $type => &$list) |
|
293 | + foreach ($fields as $type => &$list) |
|
294 | 294 | { |
295 | - if($c_fields[$type]) { |
|
295 | + if ($c_fields[$type]) { |
|
296 | 296 | $list = array_merge($c_fields[$type], $list); |
297 | 297 | unset($c_fields[$type]); |
298 | 298 | } |
@@ -300,26 +300,26 @@ discard block |
||
300 | 300 | $fields += $c_fields; |
301 | 301 | $selects += $c_selects; |
302 | 302 | } |
303 | - if($fields) { |
|
304 | - foreach((array)$fields['select'] as $name) { |
|
303 | + if ($fields) { |
|
304 | + foreach ((array)$fields['select'] as $name) { |
|
305 | 305 | $record[$name] = static::find_select_key($record[$name], $selects[$name]); |
306 | 306 | } |
307 | 307 | |
308 | - foreach((array)$fields['links'] as $name) { |
|
309 | - if($record[$name] && $links[$name]) |
|
308 | + foreach ((array)$fields['links'] as $name) { |
|
309 | + if ($record[$name] && $links[$name]) |
|
310 | 310 | { |
311 | 311 | // Primary key to another app, not a link |
312 | 312 | // Text - search for a matching record |
313 | - if(!is_numeric($record[$name])) |
|
313 | + if (!is_numeric($record[$name])) |
|
314 | 314 | { |
315 | 315 | $results = Link::query($links[$name], $record[$name]); |
316 | - if(count($results) >= 1) |
|
316 | + if (count($results) >= 1) |
|
317 | 317 | { |
318 | 318 | // More than 1 result. Check for exact match |
319 | 319 | $exact_count = 0; |
320 | - foreach($results as $id => $title) |
|
320 | + foreach ($results as $id => $title) |
|
321 | 321 | { |
322 | - if($title == $record[$name]) |
|
322 | + if ($title == $record[$name]) |
|
323 | 323 | { |
324 | 324 | $exact_count++; |
325 | 325 | $app_id = $id; |
@@ -328,11 +328,11 @@ discard block |
||
328 | 328 | unset($results[$id]); |
329 | 329 | } |
330 | 330 | // Too many exact matches, or none good enough |
331 | - if($exact_count > 1 || count($results) == 0) |
|
331 | + if ($exact_count > 1 || count($results) == 0) |
|
332 | 332 | { |
333 | 333 | $warnings[] = lang('Unable to link to %1 "%2"', |
334 | 334 | lang($links[$name]), $record[$name]). |
335 | - ' - ' .lang('too many matches'); |
|
335 | + ' - '.lang('too many matches'); |
|
336 | 336 | continue; |
337 | 337 | } |
338 | 338 | elseif ($exact_count == 1) |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | { |
346 | 346 | $warnings[] = lang('Unable to link to %1 "%2"', |
347 | 347 | lang($links[$name]), $record[$name]). |
348 | - ' - ' . lang('no matches'); |
|
348 | + ' - '.lang('no matches'); |
|
349 | 349 | continue; |
350 | 350 | } else { |
351 | 351 | $record[$name] = key($results); |
@@ -353,17 +353,17 @@ discard block |
||
353 | 353 | } |
354 | 354 | } |
355 | 355 | } |
356 | - foreach((array)$fields['select-account'] as $name) { |
|
356 | + foreach ((array)$fields['select-account'] as $name) { |
|
357 | 357 | // Compare against null to deal with empty arrays |
358 | 358 | if ($record[$name]) { |
359 | 359 | // Automatically handle text owner without explicit translation |
360 | 360 | $new_owner = importexport_helper_functions::account_name2id($record[$name]); |
361 | - if(count($new_owner) != count(explode(',',$record[$name]))) |
|
361 | + if (count($new_owner) != count(explode(',', $record[$name]))) |
|
362 | 362 | { |
363 | 363 | // Unable to parse value into account |
364 | - $warnings[] = $name . ': ' .lang('%1 is not a known user or group', $record[$name]); |
|
364 | + $warnings[] = $name.': '.lang('%1 is not a known user or group', $record[$name]); |
|
365 | 365 | } |
366 | - if($new_owner != '') { |
|
366 | + if ($new_owner != '') { |
|
367 | 367 | $record[$name] = $new_owner; |
368 | 368 | } else { |
369 | 369 | // Clear it to prevent trouble later on |
@@ -371,24 +371,24 @@ discard block |
||
371 | 371 | } |
372 | 372 | } |
373 | 373 | } |
374 | - foreach((array)$fields['select-bool'] as $name) { |
|
375 | - if($record[$name] != null && $record[$name] != '') { |
|
374 | + foreach ((array)$fields['select-bool'] as $name) { |
|
375 | + if ($record[$name] != null && $record[$name] != '') { |
|
376 | 376 | $record[$name] = ($record[$name] == lang('Yes') || $record[$name] == '1' ? 1 : 0); |
377 | 377 | } |
378 | 378 | } |
379 | - foreach((array)$fields['date-time'] as $name) { |
|
379 | + foreach ((array)$fields['date-time'] as $name) { |
|
380 | 380 | if (isset($record[$name]) && !is_numeric($record[$name]) && strlen(trim($record[$name])) > 0) |
381 | 381 | { |
382 | 382 | // Need to handle format first |
383 | - if($format == 1) |
|
383 | + if ($format == 1) |
|
384 | 384 | { |
385 | 385 | $formatted = Api\DateTime::createFromFormat( |
386 | - '!'.Api\DateTime::$user_dateformat . ' ' .Api\DateTime::$user_timeformat, |
|
386 | + '!'.Api\DateTime::$user_dateformat.' '.Api\DateTime::$user_timeformat, |
|
387 | 387 | $record[$name], |
388 | 388 | Api\DateTime::$user_timezone |
389 | 389 | ); |
390 | 390 | |
391 | - if(!$formatted && $errors = Api\DateTime::getLastErrors()) |
|
391 | + if (!$formatted && $errors = Api\DateTime::getLastErrors()) |
|
392 | 392 | { |
393 | 393 | // Try again, without time |
394 | 394 | $formatted = Api\DateTime::createFromFormat( |
@@ -397,70 +397,70 @@ discard block |
||
397 | 397 | Api\DateTime::$user_timezone |
398 | 398 | ); |
399 | 399 | |
400 | - if(!$formatted && $errors = Api\DateTime::getLastErrors()) |
|
400 | + if (!$formatted && $errors = Api\DateTime::getLastErrors()) |
|
401 | 401 | { |
402 | 402 | // Try again, anything goes |
403 | 403 | try { |
404 | 404 | $formatted = new Api\DateTime($record[$name]); |
405 | 405 | } catch (Exception $e) { |
406 | - $warnings[] = $name.': ' . $e->getMessage() . "\n" . |
|
407 | - 'Format: '.'!'.Api\DateTime::$user_dateformat . ' ' .Api\DateTime::$user_timeformat; |
|
406 | + $warnings[] = $name.': '.$e->getMessage()."\n". |
|
407 | + 'Format: '.'!'.Api\DateTime::$user_dateformat.' '.Api\DateTime::$user_timeformat; |
|
408 | 408 | continue; |
409 | 409 | } |
410 | 410 | $errors = Api\DateTime::getLastErrors(); |
411 | - foreach($errors['errors'] as $char => $msg) |
|
411 | + foreach ($errors['errors'] as $char => $msg) |
|
412 | 412 | { |
413 | 413 | $warnings[] = "$name: [$char] $msg\n". |
414 | - 'Format: '.'!'.Api\DateTime::$user_dateformat . ' ' .Api\DateTime::$user_timeformat; |
|
414 | + 'Format: '.'!'.Api\DateTime::$user_dateformat.' '.Api\DateTime::$user_timeformat; |
|
415 | 415 | } |
416 | 416 | } |
417 | 417 | } |
418 | - if($formatted) |
|
418 | + if ($formatted) |
|
419 | 419 | { |
420 | 420 | $record[$name] = $formatted->getTimestamp(); |
421 | 421 | // Timestamp is apparently in server time, but apps will do the same conversion |
422 | - $record[$name] = Api\DateTime::server2user($record[$name],'ts'); |
|
422 | + $record[$name] = Api\DateTime::server2user($record[$name], 'ts'); |
|
423 | 423 | } |
424 | 424 | } |
425 | 425 | |
426 | - if(is_array(self::$cf_parse_cache[$appname][0]['date-time']) && |
|
426 | + if (is_array(self::$cf_parse_cache[$appname][0]['date-time']) && |
|
427 | 427 | in_array($name, self::$cf_parse_cache[$appname][0]['date-time'])) { |
428 | 428 | // Custom fields stored in a particular format (from customfields_widget) |
429 | 429 | $record[$name] = date('Y-m-d H:i:s', $record[$name]); |
430 | 430 | } |
431 | 431 | } |
432 | - if(array_key_exists($name, $record) && strlen(trim($record[$name])) == 0) |
|
432 | + if (array_key_exists($name, $record) && strlen(trim($record[$name])) == 0) |
|
433 | 433 | { |
434 | 434 | $record[$name] = null; |
435 | 435 | } |
436 | 436 | } |
437 | - foreach((array)$fields['date'] as $name) { |
|
437 | + foreach ((array)$fields['date'] as $name) { |
|
438 | 438 | if (isset($record[$name]) && !is_numeric($record[$name]) && strlen(trim($record[$name])) > 0) |
439 | 439 | { |
440 | 440 | // Need to handle format first |
441 | - if($format == 1) |
|
441 | + if ($format == 1) |
|
442 | 442 | { |
443 | 443 | $formatted = Api\DateTime::createFromFormat('!'.Api\DateTime::$user_dateformat, $record[$name]); |
444 | - if($formatted && $errors = Api\DateTime::getLastErrors() && $errors['error_count'] == 0) |
|
444 | + if ($formatted && $errors = Api\DateTime::getLastErrors() && $errors['error_count'] == 0) |
|
445 | 445 | { |
446 | 446 | $record[$name] = $formatted->getTimestamp(); |
447 | 447 | } |
448 | 448 | } |
449 | - $record[$name] = Api\DateTime::server2user($record[$name],'ts'); |
|
450 | - if(is_array(self::$cf_parse_cache[$appname][0]['date']) && |
|
449 | + $record[$name] = Api\DateTime::server2user($record[$name], 'ts'); |
|
450 | + if (is_array(self::$cf_parse_cache[$appname][0]['date']) && |
|
451 | 451 | in_array($name, self::$cf_parse_cache[$appname][0]['date'])) { |
452 | 452 | // Custom fields stored in a particular format (from customfields_widget) |
453 | 453 | $record[$name] = date('Y-m-d', $record[$name]); |
454 | 454 | } |
455 | 455 | } |
456 | - if(array_key_exists($name, $record) && strlen(trim($record[$name])) == 0) |
|
456 | + if (array_key_exists($name, $record) && strlen(trim($record[$name])) == 0) |
|
457 | 457 | { |
458 | 458 | $record[$name] = null; |
459 | 459 | } |
460 | 460 | } |
461 | - foreach((array)$fields['float'] as $name) |
|
461 | + foreach ((array)$fields['float'] as $name) |
|
462 | 462 | { |
463 | - if($record[$name] != null && $record[$name] != '') { |
|
463 | + if ($record[$name] != null && $record[$name] != '') { |
|
464 | 464 | $dec_point = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0]; |
465 | 465 | if (empty($dec_point)) $dec_point = '.'; |
466 | 466 | $record[$name] = floatval(str_replace($dec_point, '.', preg_replace('/[^\d'.preg_quote($dec_point).']/', '', $record[$name]))); |
@@ -468,23 +468,23 @@ discard block |
||
468 | 468 | } |
469 | 469 | |
470 | 470 | // Some custom methods for conversion |
471 | - foreach((array)$methods as $name => $method) { |
|
472 | - if($record[$name]) $record[$name] = ExecMethod($method, $record[$name]); |
|
471 | + foreach ((array)$methods as $name => $method) { |
|
472 | + if ($record[$name]) $record[$name] = ExecMethod($method, $record[$name]); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | // cat_name2id will use currentapp to create new categories |
476 | 476 | $current_app = $GLOBALS['egw_info']['flags']['currentapp']; |
477 | - if($appname) { |
|
477 | + if ($appname) { |
|
478 | 478 | $GLOBALS['egw_info']['flags']['currentapp'] = $appname; |
479 | 479 | } |
480 | - $categories = new Api\Categories('',$appname); |
|
481 | - foreach((array)$fields['select-cat'] as $name) { |
|
482 | - if($record[$name]) { |
|
480 | + $categories = new Api\Categories('', $appname); |
|
481 | + foreach ((array)$fields['select-cat'] as $name) { |
|
482 | + if ($record[$name]) { |
|
483 | 483 | // Only parse name if it needs it |
484 | - if($format == 1) |
|
484 | + if ($format == 1) |
|
485 | 485 | { |
486 | - $existing_cat = $categories->exists('all',$record[$name]); |
|
487 | - if($existing_cat) |
|
486 | + $existing_cat = $categories->exists('all', $record[$name]); |
|
487 | + if ($existing_cat) |
|
488 | 488 | { |
489 | 489 | $cat_id = $existing_cat; |
490 | 490 | } |
@@ -493,14 +493,14 @@ discard block |
||
493 | 493 | $cat_id = importexport_helper_functions::cat_name2id($record[$name]); |
494 | 494 | } |
495 | 495 | // Don't clear it if it wasn't found |
496 | - if($cat_id) $record[$name] = $cat_id; |
|
496 | + if ($cat_id) $record[$name] = $cat_id; |
|
497 | 497 | } |
498 | 498 | } |
499 | 499 | } |
500 | 500 | $GLOBALS['egw_info']['flags']['currentapp'] = $current_app; |
501 | 501 | } |
502 | 502 | |
503 | - return implode("\n",$warnings); |
|
503 | + return implode("\n", $warnings); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | /** |
@@ -514,36 +514,36 @@ discard block |
||
514 | 514 | */ |
515 | 515 | protected static function find_select_key($record_value, $selects) |
516 | 516 | { |
517 | - if($record_value != null && is_array($selects)) { |
|
518 | - if(is_array($record_value) || is_string($record_value) && strpos($record_value, ',') !== FALSE) |
|
517 | + if ($record_value != null && is_array($selects)) { |
|
518 | + if (is_array($record_value) || is_string($record_value) && strpos($record_value, ',') !== FALSE) |
|
519 | 519 | { |
520 | 520 | // Array, or CSV |
521 | 521 | $key = array(); |
522 | - $subs = explode(',',$record_value); |
|
523 | - for($sub_index = 0; $sub_index < count($subs); $sub_index++) |
|
522 | + $subs = explode(',', $record_value); |
|
523 | + for ($sub_index = 0; $sub_index < count($subs); $sub_index++) |
|
524 | 524 | { |
525 | 525 | $sub_key = static::find_select_key($subs[$sub_index], $selects); |
526 | - if(!$sub_key) |
|
526 | + if (!$sub_key) |
|
527 | 527 | { |
528 | - $sub_key = static::find_select_key($subs[$sub_index].','.$subs[$sub_index+1], $selects); |
|
529 | - if($sub_key) $sub_index++; |
|
528 | + $sub_key = static::find_select_key($subs[$sub_index].','.$subs[$sub_index + 1], $selects); |
|
529 | + if ($sub_key) $sub_index++; |
|
530 | 530 | } |
531 | - if($sub_key) |
|
531 | + if ($sub_key) |
|
532 | 532 | { |
533 | 533 | $key[] = $sub_key; |
534 | 534 | } |
535 | 535 | } |
536 | 536 | return $key; |
537 | 537 | } |
538 | - $key = array_search(strtolower($record_value), array_map('strtolower',$selects)); |
|
539 | - if($key !== false) |
|
538 | + $key = array_search(strtolower($record_value), array_map('strtolower', $selects)); |
|
539 | + if ($key !== false) |
|
540 | 540 | { |
541 | 541 | $record_value = $key; |
542 | 542 | } |
543 | 543 | else |
544 | 544 | { |
545 | - $key = array_search(strtolower($record_value), array_map('strtolower',array_map('lang',$selects))); |
|
546 | - if($key !== false) $record_value = $key; |
|
545 | + $key = array_search(strtolower($record_value), array_map('strtolower', array_map('lang', $selects))); |
|
546 | + if ($key !== false) $record_value = $key; |
|
547 | 547 | } |
548 | 548 | } |
549 | 549 |
@@ -22,7 +22,9 @@ discard block |
||
22 | 22 | * @todo Throw away spechial chars and trim() entries ? |
23 | 23 | * @todo Check for XSS like userinput! (see common_functions) |
24 | 24 | */ |
25 | -class importexport_import_csv implements importexport_iface_import_record { //, Iterator { |
|
25 | +class importexport_import_csv implements importexport_iface_import_record |
|
26 | +{ |
|
27 | +//, Iterator { |
|
26 | 28 | |
27 | 29 | const csv_max_linelength = 8000; |
28 | 30 | |
@@ -83,10 +85,14 @@ discard block |
||
83 | 85 | * @param string $_resource resource containing data. May be each valid php-stream |
84 | 86 | * @param array $_options options for the resource array with keys: charset and fieldsep |
85 | 87 | */ |
86 | - public function __construct( $_resource, array $_options ) { |
|
88 | + public function __construct( $_resource, array $_options ) |
|
89 | + { |
|
87 | 90 | $this->resource = $_resource; |
88 | 91 | $this->csv_fieldsep = $_options['fieldsep']; |
89 | - if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
92 | + if($_options['charset'] == 'user') |
|
93 | + { |
|
94 | + $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
95 | + } |
|
90 | 96 | $this->csv_charset = $_options['charset']; |
91 | 97 | return; |
92 | 98 | } // end of member function __construct |
@@ -94,7 +100,8 @@ discard block |
||
94 | 100 | /** |
95 | 101 | * cleanup |
96 | 102 | */ |
97 | - public function __destruct( ) { |
|
103 | + public function __destruct( ) |
|
104 | + { |
|
98 | 105 | } // end of member function __destruct |
99 | 106 | |
100 | 107 | /** |
@@ -103,20 +110,27 @@ discard block |
||
103 | 110 | * @param mixed _position may be: {current|first|last|next|previous|somenumber} |
104 | 111 | * @return mixed array with data / false if no furtor records |
105 | 112 | */ |
106 | - public function get_record( $_position = 'next' ) { |
|
113 | + public function get_record( $_position = 'next' ) |
|
114 | + { |
|
107 | 115 | |
108 | - if ($this->get_raw_record( $_position ) === false) { |
|
116 | + if ($this->get_raw_record( $_position ) === false) |
|
117 | + { |
|
109 | 118 | return false; |
110 | 119 | } |
111 | 120 | |
112 | 121 | // skip empty records |
113 | - if( count( array_unique( $this->record ) ) < 2 ) return $this->get_record( $_position ); |
|
122 | + if( count( array_unique( $this->record ) ) < 2 ) |
|
123 | + { |
|
124 | + return $this->get_record( $_position ); |
|
125 | + } |
|
114 | 126 | |
115 | - if ( !empty( $this->conversion ) ) { |
|
127 | + if ( !empty( $this->conversion ) ) |
|
128 | + { |
|
116 | 129 | $this->do_conversions(); |
117 | 130 | } |
118 | 131 | |
119 | - if ( !empty( $this->mapping ) ) { |
|
132 | + if ( !empty( $this->mapping ) ) |
|
133 | + { |
|
120 | 134 | $this->do_fieldmapping(); |
121 | 135 | } |
122 | 136 | |
@@ -128,8 +142,10 @@ discard block |
||
128 | 142 | * |
129 | 143 | * @param int $_numToSkip |
130 | 144 | */ |
131 | - public function skip_records( $_numToSkip ) { |
|
132 | - while ( (int)$_numToSkip-- !== 0 ) { |
|
145 | + public function skip_records( $_numToSkip ) |
|
146 | + { |
|
147 | + while ( (int)$_numToSkip-- !== 0 ) |
|
148 | + { |
|
133 | 149 | fgetcsv( $this->resource, self::csv_max_linelength, $this->csv_fieldsep); |
134 | 150 | } |
135 | 151 | } |
@@ -140,22 +156,27 @@ discard block |
||
140 | 156 | * @param mixed $_position |
141 | 157 | * @return bool |
142 | 158 | */ |
143 | - private function get_raw_record( $_position = 'next' ) { |
|
144 | - switch ($_position) { |
|
159 | + private function get_raw_record( $_position = 'next' ) |
|
160 | + { |
|
161 | + switch ($_position) |
|
162 | + { |
|
145 | 163 | case 'current' : |
146 | - if ($this->current_position == 0) { |
|
164 | + if ($this->current_position == 0) |
|
165 | + { |
|
147 | 166 | return; |
148 | 167 | } |
149 | 168 | break; |
150 | 169 | case 'first' : |
151 | - if (!$this->current_position == 0) { |
|
170 | + if (!$this->current_position == 0) |
|
171 | + { |
|
152 | 172 | $this->current_position = 0; |
153 | 173 | rewind($this->resource); |
154 | 174 | } |
155 | 175 | |
156 | 176 | case 'next' : |
157 | 177 | $csv_data = fgetcsv( $this->resource, self::csv_max_linelength, $this->csv_fieldsep); |
158 | - if (!is_array($csv_data)) { |
|
178 | + if (!is_array($csv_data)) |
|
179 | + { |
|
159 | 180 | return false; |
160 | 181 | } |
161 | 182 | $this->current_position++; |
@@ -163,33 +184,41 @@ discard block |
||
163 | 184 | break; |
164 | 185 | |
165 | 186 | case 'previous' : |
166 | - if ($this->current_position < 2) { |
|
187 | + if ($this->current_position < 2) |
|
188 | + { |
|
167 | 189 | throw new Exception('Error: There is no previous record!'); |
168 | 190 | } |
169 | 191 | $final_position = --$this->current_position; |
170 | 192 | $this->current_position = 0; |
171 | 193 | rewind($this->resource); |
172 | - while ($this->current_position !== $final_position) { |
|
194 | + while ($this->current_position !== $final_position) |
|
195 | + { |
|
173 | 196 | $this->get_raw_record(); |
174 | 197 | } |
175 | 198 | break; |
176 | 199 | |
177 | 200 | case 'last' : |
178 | - while ($this->get_raw_record()) {} |
|
201 | + while ($this->get_raw_record()) |
|
202 | + { |
|
203 | +} |
|
179 | 204 | break; |
180 | 205 | |
181 | 206 | default: //somenumber |
182 | - if (!is_int($_position)) { |
|
207 | + if (!is_int($_position)) |
|
208 | + { |
|
183 | 209 | throw new Exception('Error: $position must be one of {current|first|last|next|previous} or an integer value'); |
184 | 210 | } |
185 | - if ($_position == $this->current_position) { |
|
211 | + if ($_position == $this->current_position) |
|
212 | + { |
|
186 | 213 | break; |
187 | 214 | } |
188 | - elseif ($_position < $this->current_position) { |
|
215 | + elseif ($_position < $this->current_position) |
|
216 | + { |
|
189 | 217 | $this->current_position = 0; |
190 | 218 | rewind($this->resource); |
191 | 219 | } |
192 | - while ($this->current_position !== $_position) { |
|
220 | + while ($this->current_position !== $_position) |
|
221 | + { |
|
193 | 222 | $this->get_raw_record(); |
194 | 223 | } |
195 | 224 | break; |
@@ -202,12 +231,16 @@ discard block |
||
202 | 231 | * |
203 | 232 | * @return int |
204 | 233 | */ |
205 | - public function get_num_of_records( ) { |
|
206 | - if ($this->num_of_records > 0) { |
|
234 | + public function get_num_of_records( ) |
|
235 | + { |
|
236 | + if ($this->num_of_records > 0) |
|
237 | + { |
|
207 | 238 | return $this->num_of_records; |
208 | 239 | } |
209 | 240 | $current_position = $this->current_position; |
210 | - while ($this->get_raw_record()) {} |
|
241 | + while ($this->get_raw_record()) |
|
242 | + { |
|
243 | +} |
|
211 | 244 | $this->num_of_records = $this->current_position; |
212 | 245 | $this->get_record($current_position); |
213 | 246 | return $this->num_of_records; |
@@ -218,7 +251,8 @@ discard block |
||
218 | 251 | * |
219 | 252 | * @return int |
220 | 253 | */ |
221 | - public function get_current_position( ) { |
|
254 | + public function get_current_position( ) |
|
255 | + { |
|
222 | 256 | |
223 | 257 | return $this->current_position; |
224 | 258 | |
@@ -230,12 +264,16 @@ discard block |
||
230 | 264 | * |
231 | 265 | * @return |
232 | 266 | */ |
233 | - protected function do_fieldmapping( ) { |
|
267 | + protected function do_fieldmapping( ) |
|
268 | + { |
|
234 | 269 | $record = $this->record; |
235 | 270 | $this->record = array(); |
236 | 271 | foreach ($this->mapping as $cvs_idx => $new_idx) |
237 | 272 | { |
238 | - if( $new_idx == '' ) continue; |
|
273 | + if( $new_idx == '' ) |
|
274 | + { |
|
275 | + continue; |
|
276 | + } |
|
239 | 277 | $this->record[$new_idx] = $record[$cvs_idx]; |
240 | 278 | } |
241 | 279 | return true; |
@@ -246,8 +284,10 @@ discard block |
||
246 | 284 | * |
247 | 285 | * @return bool |
248 | 286 | */ |
249 | - protected function do_conversions() { |
|
250 | - if ( $record = importexport_helper_functions::conversion( $this->record, $this->conversion, $this->conversion_class )) { |
|
287 | + protected function do_conversions() |
|
288 | + { |
|
289 | + if ( $record = importexport_helper_functions::conversion( $this->record, $this->conversion, $this->conversion_class )) |
|
290 | + { |
|
251 | 291 | $this->record = $record; |
252 | 292 | return; |
253 | 293 | } |
@@ -264,16 +304,19 @@ discard block |
||
264 | 304 | * |
265 | 305 | * @return string warnings, if any |
266 | 306 | */ |
267 | - public static function convert(Array &$record, Array $fields = array(), $appname = null, Array $selects = array(), $format=0) { |
|
307 | + public static function convert(Array &$record, Array $fields = array(), $appname = null, Array $selects = array(), $format=0) |
|
308 | + { |
|
268 | 309 | $warnings = array(); |
269 | 310 | |
270 | 311 | // Automatic conversions |
271 | - if($appname) { |
|
312 | + if($appname) |
|
313 | + { |
|
272 | 314 | |
273 | 315 | // Load translations |
274 | 316 | Api\Translation::add_app($appname); |
275 | 317 | |
276 | - if(!self::$cf_parse_cache[$appname]) { |
|
318 | + if(!self::$cf_parse_cache[$appname]) |
|
319 | + { |
|
277 | 320 | $c_fields = importexport_export_csv::convert_parse_custom_fields($appname, $selects, $links, $methods); |
278 | 321 | self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods); |
279 | 322 | } |
@@ -282,7 +325,10 @@ discard block |
||
282 | 325 | // Add in any fields that are keys to another app |
283 | 326 | foreach((array)$fields['links'] as $link_field => $app) |
284 | 327 | { |
285 | - if(is_numeric($link_field)) continue; |
|
328 | + if(is_numeric($link_field)) |
|
329 | + { |
|
330 | + continue; |
|
331 | + } |
|
286 | 332 | $links[$link_field] = $app; |
287 | 333 | // Set it as a normal link field |
288 | 334 | $fields['links'][] = $link_field; |
@@ -292,7 +338,8 @@ discard block |
||
292 | 338 | // Not quite a recursive merge, since only one level |
293 | 339 | foreach($fields as $type => &$list) |
294 | 340 | { |
295 | - if($c_fields[$type]) { |
|
341 | + if($c_fields[$type]) |
|
342 | + { |
|
296 | 343 | $list = array_merge($c_fields[$type], $list); |
297 | 344 | unset($c_fields[$type]); |
298 | 345 | } |
@@ -300,12 +347,15 @@ discard block |
||
300 | 347 | $fields += $c_fields; |
301 | 348 | $selects += $c_selects; |
302 | 349 | } |
303 | - if($fields) { |
|
304 | - foreach((array)$fields['select'] as $name) { |
|
350 | + if($fields) |
|
351 | + { |
|
352 | + foreach((array)$fields['select'] as $name) |
|
353 | + { |
|
305 | 354 | $record[$name] = static::find_select_key($record[$name], $selects[$name]); |
306 | 355 | } |
307 | 356 | |
308 | - foreach((array)$fields['links'] as $name) { |
|
357 | + foreach((array)$fields['links'] as $name) |
|
358 | + { |
|
309 | 359 | if($record[$name] && $links[$name]) |
310 | 360 | { |
311 | 361 | // Primary key to another app, not a link |
@@ -347,15 +397,19 @@ discard block |
||
347 | 397 | lang($links[$name]), $record[$name]). |
348 | 398 | ' - ' . lang('no matches'); |
349 | 399 | continue; |
350 | - } else { |
|
400 | + } |
|
401 | + else |
|
402 | + { |
|
351 | 403 | $record[$name] = key($results); |
352 | 404 | } |
353 | 405 | } |
354 | 406 | } |
355 | 407 | } |
356 | - foreach((array)$fields['select-account'] as $name) { |
|
408 | + foreach((array)$fields['select-account'] as $name) |
|
409 | + { |
|
357 | 410 | // Compare against null to deal with empty arrays |
358 | - if ($record[$name]) { |
|
411 | + if ($record[$name]) |
|
412 | + { |
|
359 | 413 | // Automatically handle text owner without explicit translation |
360 | 414 | $new_owner = importexport_helper_functions::account_name2id($record[$name]); |
361 | 415 | if(count($new_owner) != count(explode(',',$record[$name]))) |
@@ -363,20 +417,26 @@ discard block |
||
363 | 417 | // Unable to parse value into account |
364 | 418 | $warnings[] = $name . ': ' .lang('%1 is not a known user or group', $record[$name]); |
365 | 419 | } |
366 | - if($new_owner != '') { |
|
420 | + if($new_owner != '') |
|
421 | + { |
|
367 | 422 | $record[$name] = $new_owner; |
368 | - } else { |
|
423 | + } |
|
424 | + else |
|
425 | + { |
|
369 | 426 | // Clear it to prevent trouble later on |
370 | 427 | $record[$name] = ''; |
371 | 428 | } |
372 | 429 | } |
373 | 430 | } |
374 | - foreach((array)$fields['select-bool'] as $name) { |
|
375 | - if($record[$name] != null && $record[$name] != '') { |
|
431 | + foreach((array)$fields['select-bool'] as $name) |
|
432 | + { |
|
433 | + if($record[$name] != null && $record[$name] != '') |
|
434 | + { |
|
376 | 435 | $record[$name] = ($record[$name] == lang('Yes') || $record[$name] == '1' ? 1 : 0); |
377 | 436 | } |
378 | 437 | } |
379 | - foreach((array)$fields['date-time'] as $name) { |
|
438 | + foreach((array)$fields['date-time'] as $name) |
|
439 | + { |
|
380 | 440 | if (isset($record[$name]) && !is_numeric($record[$name]) && strlen(trim($record[$name])) > 0) |
381 | 441 | { |
382 | 442 | // Need to handle format first |
@@ -402,7 +462,8 @@ discard block |
||
402 | 462 | // Try again, anything goes |
403 | 463 | try { |
404 | 464 | $formatted = new Api\DateTime($record[$name]); |
405 | - } catch (Exception $e) { |
|
465 | + } |
|
466 | + catch (Exception $e) { |
|
406 | 467 | $warnings[] = $name.': ' . $e->getMessage() . "\n" . |
407 | 468 | 'Format: '.'!'.Api\DateTime::$user_dateformat . ' ' .Api\DateTime::$user_timeformat; |
408 | 469 | continue; |
@@ -424,7 +485,8 @@ discard block |
||
424 | 485 | } |
425 | 486 | |
426 | 487 | if(is_array(self::$cf_parse_cache[$appname][0]['date-time']) && |
427 | - in_array($name, self::$cf_parse_cache[$appname][0]['date-time'])) { |
|
488 | + in_array($name, self::$cf_parse_cache[$appname][0]['date-time'])) |
|
489 | + { |
|
428 | 490 | // Custom fields stored in a particular format (from customfields_widget) |
429 | 491 | $record[$name] = date('Y-m-d H:i:s', $record[$name]); |
430 | 492 | } |
@@ -434,7 +496,8 @@ discard block |
||
434 | 496 | $record[$name] = null; |
435 | 497 | } |
436 | 498 | } |
437 | - foreach((array)$fields['date'] as $name) { |
|
499 | + foreach((array)$fields['date'] as $name) |
|
500 | + { |
|
438 | 501 | if (isset($record[$name]) && !is_numeric($record[$name]) && strlen(trim($record[$name])) > 0) |
439 | 502 | { |
440 | 503 | // Need to handle format first |
@@ -448,7 +511,8 @@ discard block |
||
448 | 511 | } |
449 | 512 | $record[$name] = Api\DateTime::server2user($record[$name],'ts'); |
450 | 513 | if(is_array(self::$cf_parse_cache[$appname][0]['date']) && |
451 | - in_array($name, self::$cf_parse_cache[$appname][0]['date'])) { |
|
514 | + in_array($name, self::$cf_parse_cache[$appname][0]['date'])) |
|
515 | + { |
|
452 | 516 | // Custom fields stored in a particular format (from customfields_widget) |
453 | 517 | $record[$name] = date('Y-m-d', $record[$name]); |
454 | 518 | } |
@@ -460,26 +524,37 @@ discard block |
||
460 | 524 | } |
461 | 525 | foreach((array)$fields['float'] as $name) |
462 | 526 | { |
463 | - if($record[$name] != null && $record[$name] != '') { |
|
527 | + if($record[$name] != null && $record[$name] != '') |
|
528 | + { |
|
464 | 529 | $dec_point = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0]; |
465 | - if (empty($dec_point)) $dec_point = '.'; |
|
530 | + if (empty($dec_point)) |
|
531 | + { |
|
532 | + $dec_point = '.'; |
|
533 | + } |
|
466 | 534 | $record[$name] = floatval(str_replace($dec_point, '.', preg_replace('/[^\d'.preg_quote($dec_point).']/', '', $record[$name]))); |
467 | 535 | } |
468 | 536 | } |
469 | 537 | |
470 | 538 | // Some custom methods for conversion |
471 | - foreach((array)$methods as $name => $method) { |
|
472 | - if($record[$name]) $record[$name] = ExecMethod($method, $record[$name]); |
|
539 | + foreach((array)$methods as $name => $method) |
|
540 | + { |
|
541 | + if($record[$name]) |
|
542 | + { |
|
543 | + $record[$name] = ExecMethod($method, $record[$name]); |
|
544 | + } |
|
473 | 545 | } |
474 | 546 | |
475 | 547 | // cat_name2id will use currentapp to create new categories |
476 | 548 | $current_app = $GLOBALS['egw_info']['flags']['currentapp']; |
477 | - if($appname) { |
|
549 | + if($appname) |
|
550 | + { |
|
478 | 551 | $GLOBALS['egw_info']['flags']['currentapp'] = $appname; |
479 | 552 | } |
480 | 553 | $categories = new Api\Categories('',$appname); |
481 | - foreach((array)$fields['select-cat'] as $name) { |
|
482 | - if($record[$name]) { |
|
554 | + foreach((array)$fields['select-cat'] as $name) |
|
555 | + { |
|
556 | + if($record[$name]) |
|
557 | + { |
|
483 | 558 | // Only parse name if it needs it |
484 | 559 | if($format == 1) |
485 | 560 | { |
@@ -493,7 +568,10 @@ discard block |
||
493 | 568 | $cat_id = importexport_helper_functions::cat_name2id($record[$name]); |
494 | 569 | } |
495 | 570 | // Don't clear it if it wasn't found |
496 | - if($cat_id) $record[$name] = $cat_id; |
|
571 | + if($cat_id) |
|
572 | + { |
|
573 | + $record[$name] = $cat_id; |
|
574 | + } |
|
497 | 575 | } |
498 | 576 | } |
499 | 577 | } |
@@ -514,7 +592,8 @@ discard block |
||
514 | 592 | */ |
515 | 593 | protected static function find_select_key($record_value, $selects) |
516 | 594 | { |
517 | - if($record_value != null && is_array($selects)) { |
|
595 | + if($record_value != null && is_array($selects)) |
|
596 | + { |
|
518 | 597 | if(is_array($record_value) || is_string($record_value) && strpos($record_value, ',') !== FALSE) |
519 | 598 | { |
520 | 599 | // Array, or CSV |
@@ -526,7 +605,10 @@ discard block |
||
526 | 605 | if(!$sub_key) |
527 | 606 | { |
528 | 607 | $sub_key = static::find_select_key($subs[$sub_index].','.$subs[$sub_index+1], $selects); |
529 | - if($sub_key) $sub_index++; |
|
608 | + if($sub_key) |
|
609 | + { |
|
610 | + $sub_index++; |
|
611 | + } |
|
530 | 612 | } |
531 | 613 | if($sub_key) |
532 | 614 | { |
@@ -543,7 +625,10 @@ discard block |
||
543 | 625 | else |
544 | 626 | { |
545 | 627 | $key = array_search(strtolower($record_value), array_map('strtolower',array_map('lang',$selects))); |
546 | - if($key !== false) $record_value = $key; |
|
628 | + if($key !== false) |
|
629 | + { |
|
630 | + $record_value = $key; |
|
631 | + } |
|
547 | 632 | } |
548 | 633 | } |
549 | 634 |
@@ -295,7 +295,7 @@ |
||
295 | 295 | * |
296 | 296 | * @param importexport_iface_import_plugin $plugin Instance of plugin to be used |
297 | 297 | * @param resource $stream |
298 | - * @param importexport_definition $definition |
|
298 | + * @param importexport_definition $definition_obj |
|
299 | 299 | * @return String HTML fragment illustrating how the data will be understood by Egw |
300 | 300 | */ |
301 | 301 | protected function preview(importexport_iface_import_plugin &$plugin, &$stream, importexport_definition &$definition_obj) |
@@ -226,7 +226,7 @@ |
||
226 | 226 | /** |
227 | 227 | * Get options for select boxes |
228 | 228 | */ |
229 | - public static function get_select_options(Array $data) { |
|
229 | + public static function get_select_options(array $data) { |
|
230 | 230 | $options = array( |
231 | 231 | 'delimiter' => array( |
232 | 232 | '' => lang('From definition'), |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
43 | - * Step user through importing their file |
|
44 | - */ |
|
43 | + * Step user through importing their file |
|
44 | + */ |
|
45 | 45 | public function import_dialog($content = array()) { |
46 | 46 | $appname = $_GET['appname'] ? $_GET['appname'] : $content['appname']; |
47 | 47 | $definition = $_GET['definition'] ? $_GET['definition'] : $content['definition']; |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
226 | - * Get options for select boxes |
|
227 | - */ |
|
226 | + * Get options for select boxes |
|
227 | + */ |
|
228 | 228 | public static function get_select_options(Array $data) { |
229 | 229 | $options = array( |
230 | 230 | 'delimiter' => array( |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | private $plugins; |
37 | 37 | |
38 | 38 | public function __construct() { |
39 | - $this->plugins = importexport_helper_functions::get_plugins('all','import'); |
|
39 | + $this->plugins = importexport_helper_functions::get_plugins('all', 'import'); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -52,20 +52,20 @@ discard block |
||
52 | 52 | $template = new Etemplate('importexport.import_dialog'); |
53 | 53 | |
54 | 54 | // Load application's translations |
55 | - if($appname) |
|
55 | + if ($appname) |
|
56 | 56 | { |
57 | 57 | Api\Translation::add_app($appname); |
58 | 58 | } |
59 | - if($content['import'] && $definition) { |
|
59 | + if ($content['import'] && $definition) { |
|
60 | 60 | try { |
61 | 61 | $definition_obj = new importexport_definition($content['definition']); |
62 | - if($content['dry-run']) { |
|
62 | + if ($content['dry-run']) { |
|
63 | 63 | // Set this so plugin doesn't do any data changes |
64 | 64 | $definition_obj->plugin_options = (array)$definition_obj->plugin_options + array('dry_run' => true); |
65 | 65 | } |
66 | - $options =& $definition_obj->plugin_options; |
|
66 | + $options = & $definition_obj->plugin_options; |
|
67 | 67 | $options['no_notification'] = $content['no_notifications']; |
68 | - if($content['delimiter']) { |
|
68 | + if ($content['delimiter']) { |
|
69 | 69 | $options['fieldsep'] = |
70 | 70 | $content['delimiter'] == 'other' ? $content['other_delimiter'] : $content['delimiter']; |
71 | 71 | } |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | $plugin = new $definition_obj->plugin; |
75 | 75 | |
76 | 76 | // Check file encoding matches import |
77 | - $sample = file_get_contents($content['file']['tmp_name'],false, null, 0, 1024); |
|
78 | - if($appname == 'addressbook' && $definition_obj->plugin == 'addressbook_import_vcard') |
|
77 | + $sample = file_get_contents($content['file']['tmp_name'], false, null, 0, 1024); |
|
78 | + if ($appname == 'addressbook' && $definition_obj->plugin == 'addressbook_import_vcard') |
|
79 | 79 | { |
80 | 80 | $preference = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; |
81 | 81 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | } |
86 | 86 | $required = $options['charset'] == 'user' || !$options['charset'] ? $preference : $options['charset']; |
87 | 87 | $encoding = Api\Translation::detect_encoding($sample, $required); |
88 | - if($encoding && strtoupper($required) != strtoupper($encoding)) |
|
88 | + if ($encoding && strtoupper($required) != strtoupper($encoding)) |
|
89 | 89 | { |
90 | 90 | $this->message = lang("Encoding mismatch. Expected %1 file, you uploaded %2.<br />\n", |
91 | 91 | $required, |
@@ -100,37 +100,37 @@ discard block |
||
100 | 100 | $GLOBALS['egw_info']['flags']['currentapp'] = $appname; |
101 | 101 | |
102 | 102 | // Destination if we need to hold the file |
103 | - if($file) |
|
103 | + if ($file) |
|
104 | 104 | { |
105 | 105 | $cachefile = new Api\Cache\Files(array()); |
106 | 106 | $dst_file = $cachefile->filename(Api\Cache::keys(Api\Cache::INSTANCE, 'importexport', |
107 | - 'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id']), true),true); |
|
107 | + 'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id']), true), true); |
|
108 | 108 | // Keep file |
109 | - if($dst_file) |
|
109 | + if ($dst_file) |
|
110 | 110 | { |
111 | - if($content['file']['name'] && copy($content['file']['tmp_name'],$dst_file)) { |
|
111 | + if ($content['file']['name'] && copy($content['file']['tmp_name'], $dst_file)) { |
|
112 | 112 | $preserve['file']['tmp_name'] = $dst_file; |
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | 116 | // Check on matching columns |
117 | 117 | $check_message = array(); |
118 | - if(!self::check_file($file, $definition_obj, $check_message, $dst_file)) |
|
118 | + if (!self::check_file($file, $definition_obj, $check_message, $dst_file)) |
|
119 | 119 | { |
120 | 120 | // Set this so plugin doesn't do any data changes |
121 | 121 | $content['dry-run'] = true; |
122 | 122 | importexport_helper_functions::$dry_run = true; |
123 | - $this->message .= '<b>' . lang('Import aborted').":</b><br />\n"; |
|
123 | + $this->message .= '<b>'.lang('Import aborted').":</b><br />\n"; |
|
124 | 124 | $definition_obj->plugin_options = (array)$definition_obj->plugin_options + array('dry_run' => true); |
125 | 125 | } |
126 | - if(count($check_message)) |
|
126 | + if (count($check_message)) |
|
127 | 127 | { |
128 | - $this->message .= implode($check_message, "<br />\n") . "<br />\n"; |
|
128 | + $this->message .= implode($check_message, "<br />\n")."<br />\n"; |
|
129 | 129 | } |
130 | - if($content['dry-run']) |
|
130 | + if ($content['dry-run']) |
|
131 | 131 | { |
132 | 132 | $preview = $this->preview($plugin, $file, $definition_obj); |
133 | - if(trim($this->message) == '') |
|
133 | + if (trim($this->message) == '') |
|
134 | 134 | { |
135 | 135 | // Clear first, to prevent request from being collected if the result is the same |
136 | 136 | $template->setElementAttribute('preview', 'value', ''); |
@@ -149,34 +149,34 @@ discard block |
||
149 | 149 | $this->message .= lang('please select file to import'."<br />\n"); |
150 | 150 | } |
151 | 151 | |
152 | - if($content['dry-run']) |
|
152 | + if ($content['dry-run']) |
|
153 | 153 | { |
154 | - $this->message .= '<b>' . lang('test only').":</b><br />\n"; |
|
154 | + $this->message .= '<b>'.lang('test only').":</b><br />\n"; |
|
155 | 155 | } |
156 | 156 | $this->message .= lang('%1 records processed', $count); |
157 | 157 | |
158 | 158 | // Refresh opening window |
159 | - if(!$content['dry-run']) |
|
159 | + if (!$content['dry-run']) |
|
160 | 160 | { |
161 | - Framework::refresh_opener(lang('%1 records processed',$count), $appname, null,null,$appname); |
|
161 | + Framework::refresh_opener(lang('%1 records processed', $count), $appname, null, null, $appname); |
|
162 | 162 | } |
163 | 163 | $total_processed = 0; |
164 | - foreach($plugin->get_results() as $action => $a_count) { |
|
165 | - $this->message .= "<br />\n" . lang($action) . ": $a_count"; |
|
164 | + foreach ($plugin->get_results() as $action => $a_count) { |
|
165 | + $this->message .= "<br />\n".lang($action).": $a_count"; |
|
166 | 166 | $total_processed += $a_count; |
167 | 167 | } |
168 | - if(count($plugin->get_warnings())) { |
|
168 | + if (count($plugin->get_warnings())) { |
|
169 | 169 | $this->message .= "<br />\n".lang('Warnings').':'; |
170 | - foreach($plugin->get_warnings() as $record => $message) { |
|
170 | + foreach ($plugin->get_warnings() as $record => $message) { |
|
171 | 171 | $this->message .= "\n$record: $message"; |
172 | 172 | } |
173 | 173 | } |
174 | - if(count($plugin->get_errors())) { |
|
174 | + if (count($plugin->get_errors())) { |
|
175 | 175 | $this->message .= "<br />\n".lang('Problems during import:'); |
176 | - foreach($plugin->get_errors() as $record => $message) { |
|
176 | + foreach ($plugin->get_errors() as $record => $message) { |
|
177 | 177 | $this->message .= "<br />\n$record: $message"; |
178 | 178 | } |
179 | - if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
179 | + if ($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
180 | 180 | } |
181 | 181 | if ($dst_file && $content['file']['tmp_name'] == $dst_file) { |
182 | 182 | // Remove file |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | $this->message .= $e->getMessage(); |
190 | 190 | } |
191 | 191 | } |
192 | - elseif($content['cancel']) |
|
192 | + elseif ($content['cancel']) |
|
193 | 193 | { |
194 | 194 | egw_framework::set_onload('window.close();'); |
195 | 195 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | ); |
203 | 203 | } |
204 | 204 | |
205 | - if(!array_key_exists('dry-run',$content)) |
|
205 | + if (!array_key_exists('dry-run', $content)) |
|
206 | 206 | { |
207 | 207 | $data['dry-run'] = true; |
208 | 208 | } |
@@ -210,14 +210,14 @@ discard block |
||
210 | 210 | $data['appname'] = $preserve['appname'] = $appname ? $appname : ($definition_obj ? $definition_obj->application : ''); |
211 | 211 | $data['definition'] = $definition; |
212 | 212 | $data['delimiter'] = $definition_obj->plugin_options['delimiter']; |
213 | - $data['no_notifications'] = true; // switch notifications off by default |
|
213 | + $data['no_notifications'] = true; // switch notifications off by default |
|
214 | 214 | |
215 | 215 | $sel_options = self::get_select_options($data); |
216 | 216 | |
217 | 217 | $data['message'] = $this->message; |
218 | - Framework::includeJS('.','importexport','importexport'); |
|
218 | + Framework::includeJS('.', 'importexport', 'importexport'); |
|
219 | 219 | |
220 | - if($_GET['appname']) $readonlys['appname'] = true; |
|
220 | + if ($_GET['appname']) $readonlys['appname'] = true; |
|
221 | 221 | |
222 | 222 | $template->exec('importexport.importexport_import_ui.import_dialog', $data, $sel_options, $readonlys, $preserve, 2); |
223 | 223 | } |
@@ -239,12 +239,12 @@ discard block |
||
239 | 239 | ); |
240 | 240 | |
241 | 241 | (array)$apps = importexport_helper_functions::get_apps('import'); |
242 | - $options['appname'] = array('' => lang('Select one')) + array_combine($apps,$apps); |
|
242 | + $options['appname'] = array('' => lang('Select one')) + array_combine($apps, $apps); |
|
243 | 243 | |
244 | - if($data['appname']) { |
|
244 | + if ($data['appname']) { |
|
245 | 245 | $options['definition'] = array(); |
246 | 246 | |
247 | - if($data['file'] && !is_array($data['file'])) { |
|
247 | + if ($data['file'] && !is_array($data['file'])) { |
|
248 | 248 | $extension = substr($data['file'], -3); |
249 | 249 | } |
250 | 250 | $definitions = new importexport_definitions_bo(array( |
@@ -282,28 +282,28 @@ discard block |
||
282 | 282 | * @param importexport_definition $definition |
283 | 283 | * @return String HTML fragment illustrating how the data will be understood by Egw |
284 | 284 | */ |
285 | - protected function preview(importexport_iface_import_plugin &$plugin, &$stream, importexport_definition &$definition_obj) |
|
285 | + protected function preview(importexport_iface_import_plugin&$plugin, &$stream, importexport_definition&$definition_obj) |
|
286 | 286 | { |
287 | - if(method_exists($plugin, 'preview')) |
|
287 | + if (method_exists($plugin, 'preview')) |
|
288 | 288 | { |
289 | 289 | $preview = $plugin->preview($stream, $definition_obj); |
290 | 290 | } |
291 | - elseif($definition_obj->plugin_options['csv_fields']) |
|
291 | + elseif ($definition_obj->plugin_options['csv_fields']) |
|
292 | 292 | { |
293 | - $import_csv = new importexport_import_csv( $stream, array( |
|
293 | + $import_csv = new importexport_import_csv($stream, array( |
|
294 | 294 | 'fieldsep' => $definition_obj->plugin_options['fieldsep'], |
295 | 295 | 'charset' => $definition_obj->plugin_options['charset'], |
296 | 296 | )); |
297 | 297 | // set FieldMapping. |
298 | 298 | $import_csv->mapping = $definition_obj->plugin_options['field_mapping']; |
299 | 299 | |
300 | - $rows = array('h1'=>array(),'f1'=>array(),'.h1'=>'class=th'); |
|
301 | - for($row = 0; $row < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; $row++) |
|
300 | + $rows = array('h1'=>array(), 'f1'=>array(), '.h1'=>'class=th'); |
|
301 | + for ($row = 0; $row < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; $row++) |
|
302 | 302 | { |
303 | 303 | $row_data = $import_csv->get_record(); |
304 | - if($row_data === false) break; |
|
304 | + if ($row_data === false) break; |
|
305 | 305 | $rows[$import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines'] ? 'h1' : $row] = $row_data; |
306 | - if($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) $row--; |
|
306 | + if ($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) $row--; |
|
307 | 307 | } |
308 | 308 | $preview = Api\Html::table($rows); |
309 | 309 | rewind($stream); |
@@ -312,22 +312,22 @@ discard block |
||
312 | 312 | { |
313 | 313 | $preview = lang('Preview not supported by %1', $plugin->get_name()); |
314 | 314 | } |
315 | - if(count($plugin->get_warnings())) { |
|
315 | + if (count($plugin->get_warnings())) { |
|
316 | 316 | $this->message .= "<br />\n".lang('Warnings').':'; |
317 | - foreach($plugin->get_warnings() as $record => $message) { |
|
317 | + foreach ($plugin->get_warnings() as $record => $message) { |
|
318 | 318 | $this->message .= "\n$record: $message"; |
319 | 319 | } |
320 | 320 | $this->message .= "<br />\n"; |
321 | 321 | }; |
322 | - if(count($plugin->get_errors())) { |
|
322 | + if (count($plugin->get_errors())) { |
|
323 | 323 | $this->message .= "<br />\n".lang('Problems during import:'); |
324 | - foreach($plugin->get_errors() as $record => $message) { |
|
324 | + foreach ($plugin->get_errors() as $record => $message) { |
|
325 | 325 | $this->message .= "<br />\n$record: $message"; |
326 | 326 | } |
327 | - if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
327 | + if ($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
328 | 328 | $this->message .= "<br />\n"; |
329 | 329 | } |
330 | - return '<div class="header">' . lang('Preview') . ' - ' . $plugin->get_name() . '</div>' . $preview; |
|
330 | + return '<div class="header">'.lang('Preview').' - '.$plugin->get_name().'</div>'.$preview; |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -345,24 +345,24 @@ discard block |
||
345 | 345 | */ |
346 | 346 | public static function check_file(&$file, &$definition, &$message = array(), $dst_file = false) |
347 | 347 | { |
348 | - $options =& $definition->plugin_options; |
|
348 | + $options = & $definition->plugin_options; |
|
349 | 349 | $message_count = count($message); |
350 | 350 | |
351 | 351 | // Only CSV files |
352 | - if(!$options['csv_fields']) return true; |
|
352 | + if (!$options['csv_fields']) return true; |
|
353 | 353 | |
354 | 354 | // Can't check if definition has no header |
355 | - if($options['num_header_lines'] == 0) return true; |
|
355 | + if ($options['num_header_lines'] == 0) return true; |
|
356 | 356 | |
357 | 357 | $preference = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
358 | 358 | $charset = $options['charset'] == 'user' || !$options['charset'] ? $preference : $options['charset']; |
359 | 359 | |
360 | 360 | $data = fgetcsv($file, 8000, $options['fieldsep']); |
361 | 361 | rewind($file); |
362 | - $data = Api\Translation::convert($data,$charset); |
|
362 | + $data = Api\Translation::convert($data, $charset); |
|
363 | 363 | |
364 | 364 | $ok = true; |
365 | - if(count($data) != count($options['csv_fields']) && max(array_keys($data)) != max(array_keys($options['csv_fields']))) |
|
365 | + if (count($data) != count($options['csv_fields']) && max(array_keys($data)) != max(array_keys($options['csv_fields']))) |
|
366 | 366 | { |
367 | 367 | $message[] = lang("Column mismatch. Expected %1 columns, your file has %2.", |
368 | 368 | count($options['field_mapping']), |
@@ -370,9 +370,9 @@ discard block |
||
370 | 370 | ); |
371 | 371 | $ok = false; |
372 | 372 | } |
373 | - foreach($data as $index => $header) |
|
373 | + foreach ($data as $index => $header) |
|
374 | 374 | { |
375 | - if($index < count($options['csv_fields']) && !$options['field_mapping'][$index]) |
|
375 | + if ($index < count($options['csv_fields']) && !$options['field_mapping'][$index]) |
|
376 | 376 | { |
377 | 377 | // Skipped column in definition |
378 | 378 | continue; |
@@ -384,16 +384,16 @@ discard block |
||
384 | 384 | } |
385 | 385 | |
386 | 386 | // Check for matching headers |
387 | - if($options['csv_fields'][$index] == $header) |
|
387 | + if ($options['csv_fields'][$index] == $header) |
|
388 | 388 | { |
389 | 389 | // Simple match |
390 | 390 | continue; |
391 | 391 | } |
392 | 392 | // Check column headers, taking into account different translations - make sure no * |
393 | - $lang_defn = mb_strtoupper(Api\Translation::translate($options['csv_fields'][$index],false,'')); |
|
394 | - $lang_file = mb_strtoupper(Api\Translation::translate($header,false,'')); |
|
393 | + $lang_defn = mb_strtoupper(Api\Translation::translate($options['csv_fields'][$index], false, '')); |
|
394 | + $lang_file = mb_strtoupper(Api\Translation::translate($header, false, '')); |
|
395 | 395 | |
396 | - if($lang_defn == $lang_file || |
|
396 | + if ($lang_defn == $lang_file || |
|
397 | 397 | $lang_defn == mb_strtoupper($header) || |
398 | 398 | $lang_file == mb_strtoupper($options['csv_fields'][$index]) |
399 | 399 | ) |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | $file_message_id = Api\Translation::get_message_id($header, $definition->application); |
406 | 406 | $defn_message_id = Api\Translation::get_message_id($options['csv_fields'][$index], $definition->application); |
407 | 407 | |
408 | - if($file_message_id && $defn_message_id && $file_message_id == $defn_message_id) |
|
408 | + if ($file_message_id && $defn_message_id && $file_message_id == $defn_message_id) |
|
409 | 409 | { |
410 | 410 | continue; |
411 | 411 | } |
@@ -413,19 +413,19 @@ discard block |
||
413 | 413 | |
414 | 414 | // Problem |
415 | 415 | $message[] = lang("Column mismatch: %1 should be %2, not %3", |
416 | - $index,$options['csv_fields'][$index], $header); |
|
416 | + $index, $options['csv_fields'][$index], $header); |
|
417 | 417 | // But can still continue |
418 | 418 | // $ok = false; |
419 | 419 | } |
420 | - if(!$ok || count($message) != $message_count) |
|
420 | + if (!$ok || count($message) != $message_count) |
|
421 | 421 | { |
422 | 422 | // Add links for new / edit definition |
423 | 423 | $config = Api\Config::read('importexport'); |
424 | - if($GLOBALS['egw_info']['user']['apps']['admin'] || $config['users_create_definitions']) |
|
424 | + if ($GLOBALS['egw_info']['user']['apps']['admin'] || $config['users_create_definitions']) |
|
425 | 425 | { |
426 | 426 | $actions = ''; |
427 | 427 | // New definition |
428 | - $add_link = Egw::link('/index.php',array( |
|
428 | + $add_link = Egw::link('/index.php', array( |
|
429 | 429 | 'menuaction' => 'importexport.importexport_definitions_ui.edit', |
430 | 430 | 'application' => $definition->application, |
431 | 431 | 'plugin' => $definition->plugin, |
@@ -437,13 +437,13 @@ discard block |
||
437 | 437 | 'menuaction' => 'importexport.importexport_import_ui.import_dialog', |
438 | 438 | // Don't set appname, or user won't be able to select & see their new definition |
439 | 439 | //'appname' => $definition->application, |
440 | - )) . "'; |
|
440 | + ))."'; |
|
441 | 441 | egw_openWindowCentered2('$add_link','_blank',500,500,'yes'); |
442 | 442 | "; |
443 | 443 | $actions[] = lang('Create a <a href="%1">new definition</a> for this file', $add_link); |
444 | 444 | |
445 | 445 | // Edit selected definition, if allowed |
446 | - if($definition->owner == $GLOBALS['egw_info']['user']['account_id'] || |
|
446 | + if ($definition->owner == $GLOBALS['egw_info']['user']['account_id'] || |
|
447 | 447 | !$definition->owner && $GLOBALS['egw_info']['user']['apps']['admin']) |
448 | 448 | { |
449 | 449 | $edit_link = array( |
@@ -452,20 +452,20 @@ discard block |
||
452 | 452 | // Jump to file step |
453 | 453 | 'step' => 'wizard_step21' |
454 | 454 | ); |
455 | - if($dst_file) |
|
455 | + if ($dst_file) |
|
456 | 456 | { |
457 | 457 | // Still have uploaded file, jump there |
458 | - Api\Cache::setSession($definition->application,'csvfile',$dst_file); |
|
458 | + Api\Cache::setSession($definition->application, 'csvfile', $dst_file); |
|
459 | 459 | $edit_link['step'] = 'wizard_step30'; |
460 | 460 | } |
461 | - $edit_link = Egw::link('/index.php',$edit_link); |
|
461 | + $edit_link = Egw::link('/index.php', $edit_link); |
|
462 | 462 | $edit_link = "javascript:egw_openWindowCentered2('$edit_link','_blank',500,500,'yes')"; |
463 | 463 | $actions[] = lang('Edit definition <a href="%1">%2</a> to match your file', |
464 | - $edit_link, $definition->name ); |
|
464 | + $edit_link, $definition->name); |
|
465 | 465 | } |
466 | - $actions[] = lang('Edit your file to match the definition:') . ' ' |
|
467 | - . implode(array_map('lang',array_intersect_key($options['csv_fields'],$options['field_mapping'])),', '); |
|
468 | - $message[] = "\n<li>".implode($actions,"\n<li>"); |
|
466 | + $actions[] = lang('Edit your file to match the definition:').' ' |
|
467 | + . implode(array_map('lang', array_intersect_key($options['csv_fields'], $options['field_mapping'])), ', '); |
|
468 | + $message[] = "\n<li>".implode($actions, "\n<li>"); |
|
469 | 469 | } |
470 | 470 | } |
471 | 471 | return $ok; |
@@ -20,7 +20,8 @@ discard block |
||
20 | 20 | * |
21 | 21 | */ |
22 | 22 | |
23 | - class importexport_import_ui { |
|
23 | + class importexport_import_ui |
|
24 | + { |
|
24 | 25 | |
25 | 26 | const _appname = 'importexport'; |
26 | 27 | |
@@ -35,14 +36,16 @@ discard block |
||
35 | 36 | */ |
36 | 37 | private $plugins; |
37 | 38 | |
38 | - public function __construct() { |
|
39 | + public function __construct() |
|
40 | + { |
|
39 | 41 | $this->plugins = importexport_helper_functions::get_plugins('all','import'); |
40 | 42 | } |
41 | 43 | |
42 | 44 | /** |
43 | 45 | * Step user through importing their file |
44 | 46 | */ |
45 | - public function import_dialog($content = array()) { |
|
47 | + public function import_dialog($content = array()) |
|
48 | + { |
|
46 | 49 | $appname = $_GET['appname'] ? $_GET['appname'] : $content['appname']; |
47 | 50 | $definition = $_GET['definition'] ? $_GET['definition'] : $content['definition']; |
48 | 51 | |
@@ -56,16 +59,19 @@ discard block |
||
56 | 59 | { |
57 | 60 | Api\Translation::add_app($appname); |
58 | 61 | } |
59 | - if($content['import'] && $definition) { |
|
62 | + if($content['import'] && $definition) |
|
63 | + { |
|
60 | 64 | try { |
61 | 65 | $definition_obj = new importexport_definition($content['definition']); |
62 | - if($content['dry-run']) { |
|
66 | + if($content['dry-run']) |
|
67 | + { |
|
63 | 68 | // Set this so plugin doesn't do any data changes |
64 | 69 | $definition_obj->plugin_options = (array)$definition_obj->plugin_options + array('dry_run' => true); |
65 | 70 | } |
66 | 71 | $options =& $definition_obj->plugin_options; |
67 | 72 | $options['no_notification'] = $content['no_notifications']; |
68 | - if($content['delimiter']) { |
|
73 | + if($content['delimiter']) |
|
74 | + { |
|
69 | 75 | $options['fieldsep'] = |
70 | 76 | $content['delimiter'] == 'other' ? $content['other_delimiter'] : $content['delimiter']; |
71 | 77 | } |
@@ -108,7 +114,8 @@ discard block |
||
108 | 114 | // Keep file |
109 | 115 | if($dst_file) |
110 | 116 | { |
111 | - if($content['file']['name'] && copy($content['file']['tmp_name'],$dst_file)) { |
|
117 | + if($content['file']['name'] && copy($content['file']['tmp_name'],$dst_file)) |
|
118 | + { |
|
112 | 119 | $preserve['file']['tmp_name'] = $dst_file; |
113 | 120 | } |
114 | 121 | } |
@@ -161,33 +168,44 @@ discard block |
||
161 | 168 | Framework::refresh_opener(lang('%1 records processed',$count), $appname, null,null,$appname); |
162 | 169 | } |
163 | 170 | $total_processed = 0; |
164 | - foreach($plugin->get_results() as $action => $a_count) { |
|
171 | + foreach($plugin->get_results() as $action => $a_count) |
|
172 | + { |
|
165 | 173 | $this->message .= "<br />\n" . lang($action) . ": $a_count"; |
166 | 174 | $total_processed += $a_count; |
167 | 175 | } |
168 | - if(count($plugin->get_warnings())) { |
|
176 | + if(count($plugin->get_warnings())) |
|
177 | + { |
|
169 | 178 | $this->message .= "<br />\n".lang('Warnings').':'; |
170 | - foreach($plugin->get_warnings() as $record => $message) { |
|
179 | + foreach($plugin->get_warnings() as $record => $message) |
|
180 | + { |
|
171 | 181 | $this->message .= "\n$record: $message"; |
172 | 182 | } |
173 | 183 | } |
174 | - if(count($plugin->get_errors())) { |
|
184 | + if(count($plugin->get_errors())) |
|
185 | + { |
|
175 | 186 | $this->message .= "<br />\n".lang('Problems during import:'); |
176 | - foreach($plugin->get_errors() as $record => $message) { |
|
187 | + foreach($plugin->get_errors() as $record => $message) |
|
188 | + { |
|
177 | 189 | $this->message .= "<br />\n$record: $message"; |
178 | 190 | } |
179 | - if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
191 | + if($count != $total_processed) |
|
192 | + { |
|
193 | + $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
194 | + } |
|
180 | 195 | } |
181 | - if ($dst_file && $content['file']['tmp_name'] == $dst_file) { |
|
196 | + if ($dst_file && $content['file']['tmp_name'] == $dst_file) |
|
197 | + { |
|
182 | 198 | // Remove file |
183 | 199 | $cachefile->delete(Api\Cache::keys(Api\Cache::INSTANCE, 'importexport', |
184 | 200 | 'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id']))); |
185 | 201 | unset($dst_file); |
186 | 202 | } |
187 | 203 | |
188 | - } catch (Api\Db\Exception $db_ex) { |
|
204 | + } |
|
205 | + catch (Api\Db\Exception $db_ex) { |
|
189 | 206 | $this->message .= lang('Database error'); |
190 | - } catch (Exception $e) { |
|
207 | + } |
|
208 | + catch (Exception $e) { |
|
191 | 209 | $this->message .= $e->getMessage(); |
192 | 210 | } |
193 | 211 | } |
@@ -219,7 +237,10 @@ discard block |
||
219 | 237 | $data['message'] = $this->message; |
220 | 238 | Framework::includeJS('.','importexport','importexport'); |
221 | 239 | |
222 | - if($_GET['appname']) $readonlys['appname'] = true; |
|
240 | + if($_GET['appname']) |
|
241 | + { |
|
242 | + $readonlys['appname'] = true; |
|
243 | + } |
|
223 | 244 | |
224 | 245 | $template->exec('importexport.importexport_import_ui.import_dialog', $data, $sel_options, $readonlys, $preserve, 2); |
225 | 246 | } |
@@ -227,7 +248,8 @@ discard block |
||
227 | 248 | /** |
228 | 249 | * Get options for select boxes |
229 | 250 | */ |
230 | - public static function get_select_options(Array $data) { |
|
251 | + public static function get_select_options(Array $data) |
|
252 | + { |
|
231 | 253 | $options = array( |
232 | 254 | 'delimiter' => array( |
233 | 255 | '' => lang('From definition'), |
@@ -243,17 +265,20 @@ discard block |
||
243 | 265 | (array)$apps = importexport_helper_functions::get_apps('import'); |
244 | 266 | $options['appname'] = array('' => lang('Select one')) + array_combine($apps,$apps); |
245 | 267 | |
246 | - if($data['appname']) { |
|
268 | + if($data['appname']) |
|
269 | + { |
|
247 | 270 | $options['definition'] = array(); |
248 | 271 | |
249 | - if($data['file'] && !is_array($data['file'])) { |
|
272 | + if($data['file'] && !is_array($data['file'])) |
|
273 | + { |
|
250 | 274 | $extension = substr($data['file'], -3); |
251 | 275 | } |
252 | 276 | $definitions = new importexport_definitions_bo(array( |
253 | 277 | 'type' => 'import', |
254 | 278 | 'application' => $data['appname'] |
255 | 279 | )); |
256 | - foreach ((array)$definitions->get_definitions() as $identifier) { |
|
280 | + foreach ((array)$definitions->get_definitions() as $identifier) |
|
281 | + { |
|
257 | 282 | try |
258 | 283 | { |
259 | 284 | $definition = new importexport_definition($identifier); |
@@ -263,7 +288,8 @@ discard block |
||
263 | 288 | // Permission error |
264 | 289 | continue; |
265 | 290 | } |
266 | - if ($title = $definition->get_title()) { |
|
291 | + if ($title = $definition->get_title()) |
|
292 | + { |
|
267 | 293 | $options['definition'][$title] = $title; |
268 | 294 | } |
269 | 295 | unset($definition); |
@@ -303,9 +329,15 @@ discard block |
||
303 | 329 | for($row = 0; $row < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; $row++) |
304 | 330 | { |
305 | 331 | $row_data = $import_csv->get_record(); |
306 | - if($row_data === false) break; |
|
332 | + if($row_data === false) |
|
333 | + { |
|
334 | + break; |
|
335 | + } |
|
307 | 336 | $rows[$import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines'] ? 'h1' : $row] = $row_data; |
308 | - if($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) $row--; |
|
337 | + if($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) |
|
338 | + { |
|
339 | + $row--; |
|
340 | + } |
|
309 | 341 | } |
310 | 342 | $preview = Api\Html::table($rows); |
311 | 343 | rewind($stream); |
@@ -314,19 +346,26 @@ discard block |
||
314 | 346 | { |
315 | 347 | $preview = lang('Preview not supported by %1', $plugin->get_name()); |
316 | 348 | } |
317 | - if(count($plugin->get_warnings())) { |
|
349 | + if(count($plugin->get_warnings())) |
|
350 | + { |
|
318 | 351 | $this->message .= "<br />\n".lang('Warnings').':'; |
319 | - foreach($plugin->get_warnings() as $record => $message) { |
|
352 | + foreach($plugin->get_warnings() as $record => $message) |
|
353 | + { |
|
320 | 354 | $this->message .= "\n$record: $message"; |
321 | 355 | } |
322 | 356 | $this->message .= "<br />\n"; |
323 | 357 | }; |
324 | - if(count($plugin->get_errors())) { |
|
358 | + if(count($plugin->get_errors())) |
|
359 | + { |
|
325 | 360 | $this->message .= "<br />\n".lang('Problems during import:'); |
326 | - foreach($plugin->get_errors() as $record => $message) { |
|
361 | + foreach($plugin->get_errors() as $record => $message) |
|
362 | + { |
|
327 | 363 | $this->message .= "<br />\n$record: $message"; |
328 | 364 | } |
329 | - if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
365 | + if($count != $total_processed) |
|
366 | + { |
|
367 | + $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
368 | + } |
|
330 | 369 | $this->message .= "<br />\n"; |
331 | 370 | } |
332 | 371 | return '<div class="header">' . lang('Preview') . ' - ' . $plugin->get_name() . '</div>' . $preview; |
@@ -351,10 +390,16 @@ discard block |
||
351 | 390 | $message_count = count($message); |
352 | 391 | |
353 | 392 | // Only CSV files |
354 | - if(!$options['csv_fields']) return true; |
|
393 | + if(!$options['csv_fields']) |
|
394 | + { |
|
395 | + return true; |
|
396 | + } |
|
355 | 397 | |
356 | 398 | // Can't check if definition has no header |
357 | - if($options['num_header_lines'] == 0) return true; |
|
399 | + if($options['num_header_lines'] == 0) |
|
400 | + { |
|
401 | + return true; |
|
402 | + } |
|
358 | 403 | |
359 | 404 | $preference = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
360 | 405 | $charset = $options['charset'] == 'user' || !$options['charset'] ? $preference : $options['charset']; |
@@ -398,8 +443,7 @@ discard block |
||
398 | 443 | if($lang_defn == $lang_file || |
399 | 444 | $lang_defn == mb_strtoupper($header) || |
400 | 445 | $lang_file == mb_strtoupper($options['csv_fields'][$index]) |
401 | - ) |
|
402 | - { |
|
446 | + ) { |
|
403 | 447 | continue; |
404 | 448 | } |
405 | 449 |
@@ -1226,7 +1226,7 @@ discard block |
||
1226 | 1226 | * Is called as hook to participate in the linking |
1227 | 1227 | * |
1228 | 1228 | * @param int|array $info int info_id or array with infolog entry |
1229 | - * @return string|boolean string with the title, null if $info not found, false if no perms to view |
|
1229 | + * @return string string with the title, null if $info not found, false if no perms to view |
|
1230 | 1230 | */ |
1231 | 1231 | function link_title($info) |
1232 | 1232 | { |
@@ -1324,9 +1324,6 @@ discard block |
||
1324 | 1324 | /** |
1325 | 1325 | * hook called be calendar to include events or todos in the cal-dayview |
1326 | 1326 | * |
1327 | - * @param int $args[year], $args[month], $args[day] date of the events |
|
1328 | - * @param int $args[owner] owner of the events |
|
1329 | - * @param string $args[location] calendar_include_{events|todos} |
|
1330 | 1327 | * @return array of events (array with keys starttime, endtime, title, view, icon, content) |
1331 | 1328 | */ |
1332 | 1329 | function cal_to_include($args) |
@@ -1515,7 +1512,7 @@ discard block |
||
1515 | 1512 | * Get names for categories specified by their id's |
1516 | 1513 | * |
1517 | 1514 | * @param array|string $cat_id_list array or comma-sparated list of id's |
1518 | - * @return array with names |
|
1515 | + * @return string|boolean with names |
|
1519 | 1516 | */ |
1520 | 1517 | function get_categories($cat_id_list) |
1521 | 1518 | { |
@@ -1272,7 +1272,7 @@ |
||
1272 | 1272 | * @param array $options Array of options for the search |
1273 | 1273 | * @return array with info_id - title pairs of the matching entries |
1274 | 1274 | */ |
1275 | - function link_query($pattern, Array &$options = array()) |
|
1275 | + function link_query($pattern, array &$options = array()) |
|
1276 | 1276 | { |
1277 | 1277 | $query = array( |
1278 | 1278 | 'search' => $pattern, |
@@ -701,21 +701,21 @@ discard block |
||
701 | 701 | } |
702 | 702 | |
703 | 703 | /** |
704 | - * writes the given $values to InfoLog, a new entry gets created if info_id is not set or 0 |
|
705 | - * |
|
706 | - * checks and asures ACL |
|
707 | - * |
|
708 | - * @param array &$values values to write |
|
709 | - * @param boolean $check_defaults = true check and set certain defaults |
|
710 | - * @param boolean|int $touch_modified = true touch the modification date and sets the modifier's user-id, 2: only modifier |
|
711 | - * @param boolean $user2server = true conversion between user- and server-time necessary |
|
712 | - * @param boolean $skip_notification = false true = do NOT send notification, false (default) = send notifications |
|
713 | - * @param boolean $throw_exception = false Throw an exception (if required fields are not set) |
|
714 | - * @param string $purge_cfs = null null=dont, 'ical'=only iCal X-properties (cfs name starting with "#"), 'all'=all cfs |
|
715 | - * @param boolean $ignore_acl =true |
|
716 | - * |
|
717 | - * @return int|boolean info_id on a successfull write or false |
|
718 | - */ |
|
704 | + * writes the given $values to InfoLog, a new entry gets created if info_id is not set or 0 |
|
705 | + * |
|
706 | + * checks and asures ACL |
|
707 | + * |
|
708 | + * @param array &$values values to write |
|
709 | + * @param boolean $check_defaults = true check and set certain defaults |
|
710 | + * @param boolean|int $touch_modified = true touch the modification date and sets the modifier's user-id, 2: only modifier |
|
711 | + * @param boolean $user2server = true conversion between user- and server-time necessary |
|
712 | + * @param boolean $skip_notification = false true = do NOT send notification, false (default) = send notifications |
|
713 | + * @param boolean $throw_exception = false Throw an exception (if required fields are not set) |
|
714 | + * @param string $purge_cfs = null null=dont, 'ical'=only iCal X-properties (cfs name starting with "#"), 'all'=all cfs |
|
715 | + * @param boolean $ignore_acl =true |
|
716 | + * |
|
717 | + * @return int|boolean info_id on a successfull write or false |
|
718 | + */ |
|
719 | 719 | function write(&$values_in, $check_defaults=true, $touch_modified=true, $user2server=true, |
720 | 720 | $skip_notification=false, $throw_exception=false, $purge_cfs=null, $ignore_acl=false) |
721 | 721 | { |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | } |
753 | 753 | } |
754 | 754 | if (!$ignore_acl && ($values['info_id'] && !$this->check_access($values['info_id'],Acl::EDIT) && !$status_only || |
755 | - !$values['info_id'] && $values['info_id_parent'] && !$this->check_access($values['info_id_parent'],Acl::ADD))) |
|
755 | + !$values['info_id'] && $values['info_id_parent'] && !$this->check_access($values['info_id_parent'],Acl::ADD))) |
|
756 | 756 | { |
757 | 757 | return false; |
758 | 758 | } |
@@ -232,7 +232,10 @@ discard block |
||
232 | 232 | $this->enums['type'] += $config_data['types']; |
233 | 233 | //echo "types:<pre>"; print_r($this->enums['type']); echo "</pre>\n"; |
234 | 234 | } |
235 | - if ($config_data['group_owners']) $this->group_owners = $config_data['group_owners']; |
|
235 | + if ($config_data['group_owners']) |
|
236 | + { |
|
237 | + $this->group_owners = $config_data['group_owners']; |
|
238 | + } |
|
236 | 239 | |
237 | 240 | $this->customfields = Api\Storage\Customfields::get('infolog'); |
238 | 241 | if ($this->customfields) |
@@ -242,17 +245,35 @@ discard block |
||
242 | 245 | // old infolog customefield record |
243 | 246 | if(empty($field['type'])) |
244 | 247 | { |
245 | - if (count($field['values'])) $field['type'] = 'select'; // selectbox |
|
246 | - elseif ($field['rows'] > 1) $field['type'] = 'textarea'; // textarea |
|
247 | - elseif (intval($field['len']) > 0) $field['type'] = 'text'; // regular input field |
|
248 | - else $field['type'] = 'label'; // header-row |
|
248 | + if (count($field['values'])) |
|
249 | + { |
|
250 | + $field['type'] = 'select'; |
|
251 | + } |
|
252 | + // selectbox |
|
253 | + elseif ($field['rows'] > 1) |
|
254 | + { |
|
255 | + $field['type'] = 'textarea'; |
|
256 | + } |
|
257 | + // textarea |
|
258 | + elseif (intval($field['len']) > 0) |
|
259 | + { |
|
260 | + $field['type'] = 'text'; |
|
261 | + } |
|
262 | + // regular input field |
|
263 | + else { |
|
264 | + $field['type'] = 'label'; |
|
265 | + } |
|
266 | + // header-row |
|
249 | 267 | $field['type2'] = $field['typ']; |
250 | 268 | unset($field['typ']); |
251 | 269 | $this->customfields[$name] = $field; |
252 | 270 | $save_config = true; |
253 | 271 | } |
254 | 272 | } |
255 | - if ($save_config) Api\Config::save_value('customfields',$this->customfields,'infolog'); |
|
273 | + if ($save_config) |
|
274 | + { |
|
275 | + Api\Config::save_value('customfields',$this->customfields,'infolog'); |
|
276 | + } |
|
256 | 277 | } |
257 | 278 | if (is_array($config_data['responsible_edit'])) |
258 | 279 | { |
@@ -279,7 +300,10 @@ discard block |
||
279 | 300 | // sort types by there translation |
280 | 301 | foreach($this->enums['type'] as $key => $val) |
281 | 302 | { |
282 | - if (($val = lang($key)) != $key.'*') $this->enums['type'][$key] = lang($key); |
|
303 | + if (($val = lang($key)) != $key.'*') |
|
304 | + { |
|
305 | + $this->enums['type'][$key] = lang($key); |
|
306 | + } |
|
283 | 307 | } |
284 | 308 | natcasesort($this->enums['type']); |
285 | 309 | |
@@ -334,11 +358,18 @@ discard block |
||
334 | 358 | |
335 | 359 | $info_id = is_array($info) ? $info['info_id'] : $info; |
336 | 360 | |
337 | - if (!$user) $user = $this->user; |
|
361 | + if (!$user) |
|
362 | + { |
|
363 | + $user = $this->user; |
|
364 | + } |
|
338 | 365 | if ($user == $this->user) |
339 | 366 | { |
340 | 367 | $grants = $this->grants; |
341 | - if ($info_id) $access =& $cache[$info_id][$required_rights]; // we only cache the current user! |
|
368 | + if ($info_id) |
|
369 | + { |
|
370 | + $access =& $cache[$info_id][$required_rights]; |
|
371 | + } |
|
372 | + // we only cache the current user! |
|
342 | 373 | } |
343 | 374 | else |
344 | 375 | { |
@@ -357,16 +388,22 @@ discard block |
||
357 | 388 | // handle delete for the various history modes |
358 | 389 | if ($this->history) |
359 | 390 | { |
360 | - if (!is_array($info) && !($info = $this->so->read(array('info_id' => $info_id)))) return false; |
|
391 | + if (!is_array($info) && !($info = $this->so->read(array('info_id' => $info_id)))) |
|
392 | + { |
|
393 | + return false; |
|
394 | + } |
|
361 | 395 | |
362 | 396 | if ($info['info_status'] == 'deleted' && |
363 | 397 | ($required_rights == Acl::EDIT || // no edit rights for deleted entries |
364 | 398 | $required_rights == Acl::ADD || // no add rights for deleted entries |
365 | 399 | $required_rights == Acl::DELETE && ($this->history == 'history_no_delete' || // no delete at all! |
366 | - $this->history == 'history_admin_delete' && (!isset($GLOBALS['egw_info']['user']['apps']['admin']) || $user!=$this->user)))) // delete only for admins |
|
400 | + $this->history == 'history_admin_delete' && (!isset($GLOBALS['egw_info']['user']['apps']['admin']) || $user!=$this->user)))) |
|
401 | + { |
|
402 | + // delete only for admins |
|
367 | 403 | { |
368 | 404 | $access = false; |
369 | 405 | } |
406 | + } |
|
370 | 407 | elseif ($required_rights == self::ACL_UNDELETE) |
371 | 408 | { |
372 | 409 | if ($info['info_status'] != 'deleted') |
@@ -427,11 +464,14 @@ discard block |
||
427 | 464 | |
428 | 465 | if ($info['info_link_id'] > 0 && |
429 | 466 | (isset($info['links']) && ($link = $info['links'][$info['info_link_id']]) || // use supplied links info |
430 | - ($link = Link::get_link($info['info_link_id'])) !== False)) // if link not found in supplied links, we always search! |
|
467 | + ($link = Link::get_link($info['info_link_id'])) !== False)) |
|
468 | + { |
|
469 | + // if link not found in supplied links, we always search! |
|
431 | 470 | { |
432 | 471 | if (isset($info['links']) && isset($link['app'])) |
433 | 472 | { |
434 | 473 | $app = $link['app']; |
474 | + } |
|
435 | 475 | $id = $link['id']; |
436 | 476 | } |
437 | 477 | else |
@@ -442,10 +482,13 @@ discard block |
||
442 | 482 | } |
443 | 483 | $title = Link::title($app,$id); |
444 | 484 | |
445 | - if ((string)$info['info_custom_from'] === '') // old entry |
|
485 | + if ((string)$info['info_custom_from'] === '') |
|
486 | + { |
|
487 | + // old entry |
|
446 | 488 | { |
447 | 489 | $info['info_custom_from'] = (int) ($title != $info['info_from'] && @htmlentities($title) != $info['info_from']); |
448 | 490 | } |
491 | + } |
|
449 | 492 | if (!$info['info_custom_from']) |
450 | 493 | { |
451 | 494 | $info['info_from'] = ''; |
@@ -495,12 +538,15 @@ discard block |
||
495 | 538 | function time2time(&$values, $fromTZId=false, $toTZId=null) |
496 | 539 | { |
497 | 540 | |
498 | - if ($fromTZId === $toTZId) return; |
|
541 | + if ($fromTZId === $toTZId) |
|
542 | + { |
|
543 | + return; |
|
544 | + } |
|
499 | 545 | |
500 | 546 | $tz = Api\DateTime::$server_timezone; |
501 | 547 | |
502 | 548 | if ($fromTZId) |
503 | - { |
|
549 | + { |
|
504 | 550 | if (!isset(self::$tz_cache[$fromTZId])) |
505 | 551 | { |
506 | 552 | self::$tz_cache[$fromTZId] = calendar_timezones::DateTimeZone($fromTZId); |
@@ -534,7 +580,7 @@ discard block |
||
534 | 580 | } |
535 | 581 | //error_log(__METHOD__.'(values[info_enddate]='.date('Y-m-d H:i:s',$values['info_enddate']).", from=".array2string($fromTZId).", to=".array2string($toTZId).") tz=".$tz->getName().', fromTZ='.$fromTZ->getName().', toTZ='.$toTZ->getName().', userTZ='.Api\DateTime::$user_timezone->getName()); |
536 | 582 | foreach($this->timestamps as $key) |
537 | - { |
|
583 | + { |
|
538 | 584 | if ($values[$key]) |
539 | 585 | { |
540 | 586 | $time = new Api\DateTime($values[$key], $tz); |
@@ -564,7 +610,10 @@ discard block |
||
564 | 610 | */ |
565 | 611 | function date2usertime($ts,$date_format='ts') |
566 | 612 | { |
567 | - if (empty($ts) || $date_format == 'server') return $ts; |
|
613 | + if (empty($ts) || $date_format == 'server') |
|
614 | + { |
|
615 | + return $ts; |
|
616 | + } |
|
568 | 617 | |
569 | 618 | return Api\DateTime::server2user($ts,$date_format); |
570 | 619 | } |
@@ -601,16 +650,22 @@ discard block |
||
601 | 650 | return null; |
602 | 651 | } |
603 | 652 | |
604 | - if (!$ignore_acl && !$this->check_access($data,Acl::READ)) // check behind read, to prevent a double read |
|
653 | + if (!$ignore_acl && !$this->check_access($data,Acl::READ)) |
|
654 | + { |
|
655 | + // check behind read, to prevent a double read |
|
605 | 656 | { |
606 | 657 | return False; |
607 | 658 | } |
659 | + } |
|
608 | 660 | |
609 | 661 | if ($data['info_subject'] == $this->subject_from_des($data['info_des'])) |
610 | 662 | { |
611 | 663 | $data['info_subject'] = ''; |
612 | 664 | } |
613 | - if ($run_link_id2from) $this->link_id2from($data); |
|
665 | + if ($run_link_id2from) |
|
666 | + { |
|
667 | + $this->link_id2from($data); |
|
668 | + } |
|
614 | 669 | |
615 | 670 | // convert server- to user-time |
616 | 671 | if ($date_format == 'ts') |
@@ -673,7 +728,11 @@ discard block |
||
673 | 728 | // if we have history switched on and not an already deleted item --> set only status deleted |
674 | 729 | if ($this->history && $info['info_status'] != 'deleted') |
675 | 730 | { |
676 | - if ($info['info_status'] == 'deleted') return false; // entry already deleted |
|
731 | + if ($info['info_status'] == 'deleted') |
|
732 | + { |
|
733 | + return false; |
|
734 | + } |
|
735 | + // entry already deleted |
|
677 | 736 | |
678 | 737 | $this->so->write($deleted); |
679 | 738 | |
@@ -685,7 +744,9 @@ discard block |
||
685 | 744 | |
686 | 745 | Link::unlink(0,'infolog',$info_id); |
687 | 746 | } |
688 | - if ($info['info_status'] != 'deleted') // dont notify of final purge of already deleted items |
|
747 | + if ($info['info_status'] != 'deleted') |
|
748 | + { |
|
749 | + // dont notify of final purge of already deleted items |
|
689 | 750 | { |
690 | 751 | // send email notifications and do the history logging |
691 | 752 | if(!$skip_notification) |
@@ -693,6 +754,7 @@ discard block |
||
693 | 754 | if (!is_object($this->tracking)) |
694 | 755 | { |
695 | 756 | $this->tracking = new infolog_tracking($this); |
757 | + } |
|
696 | 758 | } |
697 | 759 | $this->tracking->track($deleted,$info,$this->user,true); |
698 | 760 | } |
@@ -742,10 +804,13 @@ discard block |
||
742 | 804 | { |
743 | 805 | $responsible = $values['info_responsible']; |
744 | 806 | } |
745 | - if (!($status_only = in_array($this->user, (array)$responsible))) // responsible has implicit right to change status |
|
807 | + if (!($status_only = in_array($this->user, (array)$responsible))) |
|
808 | + { |
|
809 | + // responsible has implicit right to change status |
|
746 | 810 | { |
747 | 811 | $status_only = !!array_intersect((array)$responsible,array_keys($GLOBALS['egw']->accounts->memberships($this->user))); |
748 | 812 | } |
813 | + } |
|
749 | 814 | if (!$status_only && $values['info_status'] != 'deleted') |
750 | 815 | { |
751 | 816 | $status_only = $undelete = $this->check_access($values['info_id'],self::ACL_UNDELETE); |
@@ -766,17 +831,23 @@ discard block |
||
766 | 831 | $values['info_status'] = $this->status['defaults'][$values['info_type']]; |
767 | 832 | } |
768 | 833 | } |
769 | - if ($status_only && !$undelete) // make sure only status gets writen |
|
834 | + if ($status_only && !$undelete) |
|
835 | + { |
|
836 | + // make sure only status gets writen |
|
770 | 837 | { |
771 | 838 | $set_completed = !$values['info_datecompleted'] && // set date completed of finished job, only if its not already set |
772 | 839 | in_array($values['info_status'],array('done','billed','cancelled')); |
840 | + } |
|
773 | 841 | |
774 | 842 | $values = $old; |
775 | 843 | // only overwrite explicitly allowed fields |
776 | 844 | $values['info_datemodified'] = $values_in['info_datemodified']; |
777 | 845 | foreach ($this->responsible_edit as $name) |
778 | 846 | { |
779 | - if (isset($values_in[$name])) $values[$name] = $values_in[$name]; |
|
847 | + if (isset($values_in[$name])) |
|
848 | + { |
|
849 | + $values[$name] = $values_in[$name]; |
|
850 | + } |
|
780 | 851 | } |
781 | 852 | if ($set_completed) |
782 | 853 | { |
@@ -784,21 +855,30 @@ discard block |
||
784 | 855 | $values['info_percent'] = 100; |
785 | 856 | $forcestatus = true; |
786 | 857 | $status = 'done'; |
787 | - if (isset($values['info_type']) && !in_array($values['info_status'],array('done','billed','cancelled'))) { |
|
858 | + if (isset($values['info_type']) && !in_array($values['info_status'],array('done','billed','cancelled'))) |
|
859 | + { |
|
788 | 860 | $forcestatus = false; |
789 | 861 | //echo "set_completed:"; _debug_array($this->status[$values['info_type']]); |
790 | - if (isset($this->status[$values['info_type']]['done'])) { |
|
862 | + if (isset($this->status[$values['info_type']]['done'])) |
|
863 | + { |
|
791 | 864 | $forcestatus = true; |
792 | 865 | $status = 'done'; |
793 | - } elseif (isset($this->status[$values['info_type']]['billed'])) { |
|
866 | + } |
|
867 | + elseif (isset($this->status[$values['info_type']]['billed'])) |
|
868 | + { |
|
794 | 869 | $forcestatus = true; |
795 | 870 | $status = 'billed'; |
796 | - } elseif (isset($this->status[$values['info_type']]['cancelled'])) { |
|
871 | + } |
|
872 | + elseif (isset($this->status[$values['info_type']]['cancelled'])) |
|
873 | + { |
|
797 | 874 | $forcestatus = true; |
798 | 875 | $status = 'cancelled'; |
799 | 876 | } |
800 | 877 | } |
801 | - if ($forcestatus && !in_array($values['info_status'],array('done','billed','cancelled'))) $values['info_status'] = $status; |
|
878 | + if ($forcestatus && !in_array($values['info_status'],array('done','billed','cancelled'))) |
|
879 | + { |
|
880 | + $values['info_status'] = $status; |
|
881 | + } |
|
802 | 882 | } |
803 | 883 | $check_defaults = false; |
804 | 884 | } |
@@ -830,14 +910,22 @@ discard block |
||
830 | 910 | //echo "check_defaults:"; _debug_array($this->status[$values['info_type']]); |
831 | 911 | //$values['info_status'] = 'done'; |
832 | 912 | $status = 'done'; |
833 | - if (isset($values['info_type'])) { |
|
834 | - if (isset($this->status[$values['info_type']]['done'])) { |
|
913 | + if (isset($values['info_type'])) |
|
914 | + { |
|
915 | + if (isset($this->status[$values['info_type']]['done'])) |
|
916 | + { |
|
835 | 917 | $status = 'done'; |
836 | - } elseif (isset($this->status[$values['info_type']]['billed'])) { |
|
918 | + } |
|
919 | + elseif (isset($this->status[$values['info_type']]['billed'])) |
|
920 | + { |
|
837 | 921 | $status = 'billed'; |
838 | - } elseif (isset($this->status[$values['info_type']]['cancelled'])) { |
|
922 | + } |
|
923 | + elseif (isset($this->status[$values['info_type']]['cancelled'])) |
|
924 | + { |
|
839 | 925 | $status = 'cancelled'; |
840 | - } else { |
|
926 | + } |
|
927 | + else |
|
928 | + { |
|
841 | 929 | // since the comlete stati above do not exist for that type, dont change it |
842 | 930 | $status = $values['info_status']; |
843 | 931 | } |
@@ -859,7 +947,10 @@ discard block |
||
859 | 947 | $custom = Api\Storage\Customfields::get('infolog'); |
860 | 948 | foreach($custom as $c_name => $c_field) |
861 | 949 | { |
862 | - if($c_field['type2']) $type2 = is_array($c_field['type2']) ? $c_field['type2'] : explode(',',$c_field['type2']); |
|
950 | + if($c_field['type2']) |
|
951 | + { |
|
952 | + $type2 = is_array($c_field['type2']) ? $c_field['type2'] : explode(',',$c_field['type2']); |
|
953 | + } |
|
863 | 954 | if($c_field['needed'] && (!$c_field['type2'] || $c_field['type2'] && in_array($values['info_type'],$type2))) |
864 | 955 | { |
865 | 956 | // Required custom field |
@@ -878,8 +969,7 @@ discard block |
||
878 | 969 | { |
879 | 970 | if (!$this->check_access($values['info_id'],Acl::EDIT) || |
880 | 971 | !$values['info_id'] && !$this->check_access($values,Acl::ADD) |
881 | - ) |
|
882 | - { |
|
972 | + ) { |
|
883 | 973 | return false; // no edit rights from the group-owner and no implicit rights (delegated and sufficient rights) |
884 | 974 | } |
885 | 975 | } |
@@ -938,10 +1028,16 @@ discard block |
||
938 | 1028 | $to_write['info_id'] = $info_id; |
939 | 1029 | |
940 | 1030 | // if the info responbsible array is not passed, fetch it from old. |
941 | - if (!array_key_exists('info_responsible',$values)) $values['info_responsible'] = $old['info_responsible']; |
|
942 | - if (!is_array($values['info_responsible'])) // this should not happen, bug it does ;-) |
|
1031 | + if (!array_key_exists('info_responsible',$values)) |
|
1032 | + { |
|
1033 | + $values['info_responsible'] = $old['info_responsible']; |
|
1034 | + } |
|
1035 | + if (!is_array($values['info_responsible'])) |
|
1036 | + { |
|
1037 | + // this should not happen, bug it does ;-) |
|
943 | 1038 | { |
944 | 1039 | $values['info_responsible'] = $values['info_responsible'] ? explode(',',$values['info_responsible']) : array(); |
1040 | + } |
|
945 | 1041 | $to_write['info_responsible'] = $values['info_responsible']; |
946 | 1042 | } |
947 | 1043 | |
@@ -1013,7 +1109,10 @@ discard block |
||
1013 | 1109 | $this->tracking->track($to_write,$old,$this->user,$values['info_status'] == 'deleted' || $old['info_status'] == 'deleted', |
1014 | 1110 | null,$skip_notification); |
1015 | 1111 | |
1016 | - if ($info_from_set) $values['info_from'] = ''; |
|
1112 | + if ($info_from_set) |
|
1113 | + { |
|
1114 | + $values['info_from'] = ''; |
|
1115 | + } |
|
1017 | 1116 | |
1018 | 1117 | // Change new values back to user time before sending them back |
1019 | 1118 | if($user2server) |
@@ -1126,13 +1225,25 @@ discard block |
||
1126 | 1225 | |
1127 | 1226 | if($query['filter'] == 'bydate') |
1128 | 1227 | { |
1129 | - if (is_int($query['startdate'])) $query['col_filter'][] = 'info_startdate >= '.$GLOBALS['egw']->db->quote($query['startdate']); |
|
1130 | - if (is_int($query['enddate'])) $query['col_filter'][] = 'info_startdate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1); |
|
1228 | + if (is_int($query['startdate'])) |
|
1229 | + { |
|
1230 | + $query['col_filter'][] = 'info_startdate >= '.$GLOBALS['egw']->db->quote($query['startdate']); |
|
1231 | + } |
|
1232 | + if (is_int($query['enddate'])) |
|
1233 | + { |
|
1234 | + $query['col_filter'][] = 'info_startdate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1); |
|
1235 | + } |
|
1131 | 1236 | } |
1132 | 1237 | elseif ($query['filter'] == 'duedate') |
1133 | 1238 | { |
1134 | - if (is_int($query['startdate'])) $query['col_filter'][] = 'info_enddate >= '.$GLOBALS['egw']->db->quote($query['startdate']); |
|
1135 | - if (is_int($query['enddate'])) $query['col_filter'][] = 'info_enddate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1); |
|
1239 | + if (is_int($query['startdate'])) |
|
1240 | + { |
|
1241 | + $query['col_filter'][] = 'info_enddate >= '.$GLOBALS['egw']->db->quote($query['startdate']); |
|
1242 | + } |
|
1243 | + if (is_int($query['enddate'])) |
|
1244 | + { |
|
1245 | + $query['col_filter'][] = 'info_enddate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1); |
|
1246 | + } |
|
1136 | 1247 | } |
1137 | 1248 | elseif ($query['filter'] == 'private') |
1138 | 1249 | { |
@@ -1214,7 +1325,10 @@ discard block |
||
1214 | 1325 | |
1215 | 1326 | $result =& $this->search($filter); |
1216 | 1327 | |
1217 | - if (empty($result)) return 'EGw-empty-wGE'; |
|
1328 | + if (empty($result)) |
|
1329 | + { |
|
1330 | + return 'EGw-empty-wGE'; |
|
1331 | + } |
|
1218 | 1332 | |
1219 | 1333 | $entry = array_shift($result); |
1220 | 1334 | |
@@ -1261,7 +1375,10 @@ discard block |
||
1261 | 1375 | 'to_id' => 0, |
1262 | 1376 | ), |
1263 | 1377 | ); |
1264 | - if ($GLOBALS['egw_info']['user']['preferences']['infolog']['cat_add_default']) $info['info_cat'] = $GLOBALS['egw_info']['user']['preferences']['infolog']['cat_add_default']; |
|
1378 | + if ($GLOBALS['egw_info']['user']['preferences']['infolog']['cat_add_default']) |
|
1379 | + { |
|
1380 | + $info['info_cat'] = $GLOBALS['egw_info']['user']['preferences']['infolog']['cat_add_default']; |
|
1381 | + } |
|
1265 | 1382 | // find the addressbookentry to link with |
1266 | 1383 | $addressbook = new Api\Contacts(); |
1267 | 1384 | $contacts = array(); |
@@ -1522,7 +1639,10 @@ discard block |
||
1522 | 1639 | { |
1523 | 1640 | foreach($anzSubs as $info_id => $subs) |
1524 | 1641 | { |
1525 | - if ($subs) $infos[$info_id]['class'] .= ' infolog_rowHasSubs'; |
|
1642 | + if ($subs) |
|
1643 | + { |
|
1644 | + $infos[$info_id]['class'] .= ' infolog_rowHasSubs'; |
|
1645 | + } |
|
1526 | 1646 | } |
1527 | 1647 | } |
1528 | 1648 | } |
@@ -1649,7 +1769,10 @@ discard block |
||
1649 | 1769 | $save_prefs = $GLOBALS['egw_info']['user']['preferences']; |
1650 | 1770 | foreach($users as $user) |
1651 | 1771 | { |
1652 | - if (!($email = $GLOBALS['egw']->accounts->id2name($user,'account_email'))) continue; |
|
1772 | + if (!($email = $GLOBALS['egw']->accounts->id2name($user,'account_email'))) |
|
1773 | + { |
|
1774 | + continue; |
|
1775 | + } |
|
1653 | 1776 | // create the enviroment for $user |
1654 | 1777 | $this->user = $GLOBALS['egw_info']['user']['account_id'] = $user; |
1655 | 1778 | $GLOBALS['egw']->preferences->__construct($user); |
@@ -1667,7 +1790,10 @@ discard block |
||
1667 | 1790 | 'notify_start_delegated' => 'open-delegated-date', |
1668 | 1791 | ) as $pref => $filter) |
1669 | 1792 | { |
1670 | - if (!($pref_value = $GLOBALS['egw_info']['user']['preferences']['infolog'][$pref])) continue; |
|
1793 | + if (!($pref_value = $GLOBALS['egw_info']['user']['preferences']['infolog'][$pref])) |
|
1794 | + { |
|
1795 | + continue; |
|
1796 | + } |
|
1671 | 1797 | |
1672 | 1798 | $filter .= date('Y-m-d',time()+24*60*60*(int)$pref_value); |
1673 | 1799 | //error_log(__METHOD__."() checking with filter '$filter' ($pref_value) for user $user ($email)"); |
@@ -1676,7 +1802,10 @@ discard block |
||
1676 | 1802 | foreach($this->so->search($params) as $info) |
1677 | 1803 | { |
1678 | 1804 | // check if we already send a notification for that infolog entry, eg. starting and due on same day |
1679 | - if (in_array($info['info_id'],$notified_info_ids)) continue; |
|
1805 | + if (in_array($info['info_id'],$notified_info_ids)) |
|
1806 | + { |
|
1807 | + continue; |
|
1808 | + } |
|
1680 | 1809 | |
1681 | 1810 | if (is_null($this->tracking) || $this->tracking->user != $user) |
1682 | 1811 | { |
@@ -1805,11 +1934,17 @@ discard block |
||
1805 | 1934 | $statis = $icons = array(); |
1806 | 1935 | foreach($this->status as $t => $stati) |
1807 | 1936 | { |
1808 | - if ($t === 'defaults') continue; |
|
1937 | + if ($t === 'defaults') |
|
1938 | + { |
|
1939 | + continue; |
|
1940 | + } |
|
1809 | 1941 | foreach($stati as $val => $label) |
1810 | 1942 | { |
1811 | 1943 | $statis[$val][$label] = lang($label); |
1812 | - if (!isset($icons[$val])) $icons[$val] = $label; |
|
1944 | + if (!isset($icons[$val])) |
|
1945 | + { |
|
1946 | + $icons[$val] = $label; |
|
1947 | + } |
|
1813 | 1948 | } |
1814 | 1949 | } |
1815 | 1950 | foreach($statis as $val => &$labels) |
@@ -1885,7 +2020,10 @@ discard block |
||
1885 | 2020 | { |
1886 | 2021 | return array($egwData['info_id']); |
1887 | 2022 | } |
1888 | - if (!$relax) return array(); |
|
2023 | + if (!$relax) |
|
2024 | + { |
|
2025 | + return array(); |
|
2026 | + } |
|
1889 | 2027 | } |
1890 | 2028 | unset($infoData['info_id']); |
1891 | 2029 | |
@@ -1894,7 +2032,10 @@ discard block |
||
1894 | 2032 | $filter = array('col_filter' => array('info_uid' => $infoData['info_uid'])); |
1895 | 2033 | foreach($this->so->search($filter) as $egwData) |
1896 | 2034 | { |
1897 | - if (!$this->check_access($egwData,Acl::READ)) continue; |
|
2035 | + if (!$this->check_access($egwData,Acl::READ)) |
|
2036 | + { |
|
2037 | + continue; |
|
2038 | + } |
|
1898 | 2039 | $foundInfoLogs[$egwData['info_id']] = $egwData['info_id']; |
1899 | 2040 | } |
1900 | 2041 | return $foundInfoLogs; |
@@ -1946,7 +2087,10 @@ discard block |
||
1946 | 2087 | |
1947 | 2088 | foreach ($this->so->search($filter) as $itemID => $egwData) |
1948 | 2089 | { |
1949 | - if (!$this->check_access($egwData,Acl::READ)) continue; |
|
2090 | + if (!$this->check_access($egwData,Acl::READ)) |
|
2091 | + { |
|
2092 | + continue; |
|
2093 | + } |
|
1950 | 2094 | |
1951 | 2095 | switch ($infoData['info_type']) |
1952 | 2096 | { |
@@ -2019,7 +2163,10 @@ discard block |
||
2019 | 2163 | // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
2020 | 2164 | foreach ($this->so->search($filter) as $itemID => $egwData) |
2021 | 2165 | { |
2022 | - if (!$this->check_access($egwData,Acl::READ)) continue; |
|
2166 | + if (!$this->check_access($egwData,Acl::READ)) |
|
2167 | + { |
|
2168 | + continue; |
|
2169 | + } |
|
2023 | 2170 | // Horde::logMessage("findVTODO Trying\n" |
2024 | 2171 | // . print_r($egwData, true), |
2025 | 2172 | // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | var $total; |
42 | 42 | var $vfs; |
43 | - var $vfs_basedir='/infolog'; |
|
43 | + var $vfs_basedir = '/infolog'; |
|
44 | 44 | /** |
45 | 45 | * Set Logging |
46 | 46 | * |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @var array |
67 | 67 | */ |
68 | - var $timestamps = array('info_startdate','info_enddate','info_datemodified','info_datecompleted','info_created'); |
|
68 | + var $timestamps = array('info_startdate', 'info_enddate', 'info_datemodified', 'info_datecompleted', 'info_created'); |
|
69 | 69 | /** |
70 | 70 | * fields the responsible user can change |
71 | 71 | * |
72 | 72 | * @var array |
73 | 73 | */ |
74 | - var $responsible_edit=array('info_status','info_percent','info_datecompleted'); |
|
74 | + var $responsible_edit = array('info_status', 'info_percent', 'info_datecompleted'); |
|
75 | 75 | /** |
76 | 76 | * Fields to exclude from copy, if an entry is copied, the ones below are excluded by default. |
77 | 77 | * |
@@ -95,19 +95,19 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @var string |
97 | 97 | */ |
98 | - var $implicit_rights='read'; |
|
98 | + var $implicit_rights = 'read'; |
|
99 | 99 | /** |
100 | 100 | * Custom fields read from the infolog config |
101 | 101 | * |
102 | 102 | * @var array |
103 | 103 | */ |
104 | - var $customfields=array(); |
|
104 | + var $customfields = array(); |
|
105 | 105 | /** |
106 | 106 | * Group owners for certain types read from the infolog config |
107 | 107 | * |
108 | 108 | * @var array |
109 | 109 | */ |
110 | - var $group_owners=array(); |
|
110 | + var $group_owners = array(); |
|
111 | 111 | /** |
112 | 112 | * Current user |
113 | 113 | * |
@@ -174,55 +174,55 @@ discard block |
||
174 | 174 | function __construct($info_id = 0) |
175 | 175 | { |
176 | 176 | $this->enums = $this->stock_enums = array( |
177 | - 'priority' => array ( |
|
177 | + 'priority' => array( |
|
178 | 178 | 3 => 'urgent', |
179 | 179 | 2 => 'high', |
180 | 180 | 1 => 'normal', |
181 | 181 | 0 => 'low' |
182 | 182 | ), |
183 | 183 | 'confirm' => array( |
184 | - 'not' => 'not','accept' => 'accept','finish' => 'finish', |
|
184 | + 'not' => 'not', 'accept' => 'accept', 'finish' => 'finish', |
|
185 | 185 | 'both' => 'both' ), |
186 | 186 | 'type' => array( |
187 | - 'task' => 'task','phone' => 'phone','note' => 'note','email' => 'email' |
|
187 | + 'task' => 'task', 'phone' => 'phone', 'note' => 'note', 'email' => 'email' |
|
188 | 188 | /* ,'confirm' => 'confirm','reject' => 'reject','fax' => 'fax' not implemented so far */ ) |
189 | 189 | ); |
190 | 190 | $this->status = $this->stock_status = array( |
191 | 191 | 'defaults' => array( |
192 | - 'task' => 'not-started', 'phone' => 'not-started', 'note' => 'done','email' => 'done'), |
|
192 | + 'task' => 'not-started', 'phone' => 'not-started', 'note' => 'done', 'email' => 'done'), |
|
193 | 193 | 'task' => array( |
194 | - 'offer' => 'offer', // --> NEEDS-ACTION |
|
195 | - 'not-started' => 'not-started', // iCal NEEDS-ACTION |
|
196 | - 'ongoing' => 'ongoing', // iCal IN-PROCESS |
|
197 | - 'done' => 'done', // iCal COMPLETED |
|
198 | - 'cancelled' => 'cancelled', // iCal CANCELLED |
|
199 | - 'billed' => 'billed', // --> DONE |
|
200 | - 'template' => 'template', // --> cancelled |
|
201 | - 'nonactive' => 'nonactive', // --> cancelled |
|
202 | - 'archive' => 'archive' ), // --> cancelled |
|
194 | + 'offer' => 'offer', // --> NEEDS-ACTION |
|
195 | + 'not-started' => 'not-started', // iCal NEEDS-ACTION |
|
196 | + 'ongoing' => 'ongoing', // iCal IN-PROCESS |
|
197 | + 'done' => 'done', // iCal COMPLETED |
|
198 | + 'cancelled' => 'cancelled', // iCal CANCELLED |
|
199 | + 'billed' => 'billed', // --> DONE |
|
200 | + 'template' => 'template', // --> cancelled |
|
201 | + 'nonactive' => 'nonactive', // --> cancelled |
|
202 | + 'archive' => 'archive' ), // --> cancelled |
|
203 | 203 | 'phone' => array( |
204 | - 'not-started' => 'call', // iCal NEEDS-ACTION |
|
205 | - 'ongoing' => 'will-call', // iCal IN-PROCESS |
|
206 | - 'done' => 'done', // iCal COMPLETED |
|
207 | - 'billed' => 'billed' ), // --> DONE |
|
204 | + 'not-started' => 'call', // iCal NEEDS-ACTION |
|
205 | + 'ongoing' => 'will-call', // iCal IN-PROCESS |
|
206 | + 'done' => 'done', // iCal COMPLETED |
|
207 | + 'billed' => 'billed' ), // --> DONE |
|
208 | 208 | 'note' => array( |
209 | - 'ongoing' => 'ongoing', // iCal has no status on notes |
|
209 | + 'ongoing' => 'ongoing', // iCal has no status on notes |
|
210 | 210 | 'done' => 'done' ), |
211 | 211 | 'email' => array( |
212 | - 'ongoing' => 'ongoing', // iCal has no status on notes |
|
212 | + 'ongoing' => 'ongoing', // iCal has no status on notes |
|
213 | 213 | 'done' => 'done' ), |
214 | 214 | ); |
215 | 215 | if (($config_data = Api\Config::read('infolog'))) |
216 | 216 | { |
217 | 217 | if (isset($config_data['status']) && is_array($config_data['status'])) |
218 | 218 | { |
219 | - foreach(array_keys($config_data['status']) as $key) |
|
219 | + foreach (array_keys($config_data['status']) as $key) |
|
220 | 220 | { |
221 | 221 | if (!is_array($this->status[$key])) |
222 | 222 | { |
223 | 223 | $this->status[$key] = array(); |
224 | 224 | } |
225 | - $this->status[$key] = array_merge($this->status[$key],(array)$config_data['status'][$key]); |
|
225 | + $this->status[$key] = array_merge($this->status[$key], (array)$config_data['status'][$key]); |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | if (isset($config_data['types']) && is_array($config_data['types'])) |
@@ -237,10 +237,10 @@ discard block |
||
237 | 237 | $this->customfields = Api\Storage\Customfields::get('infolog'); |
238 | 238 | if ($this->customfields) |
239 | 239 | { |
240 | - foreach($this->customfields as $name => $field) |
|
240 | + foreach ($this->customfields as $name => $field) |
|
241 | 241 | { |
242 | 242 | // old infolog customefield record |
243 | - if(empty($field['type'])) |
|
243 | + if (empty($field['type'])) |
|
244 | 244 | { |
245 | 245 | if (count($field['values'])) $field['type'] = 'select'; // selectbox |
246 | 246 | elseif ($field['rows'] > 1) $field['type'] = 'textarea'; // textarea |
@@ -252,23 +252,23 @@ discard block |
||
252 | 252 | $save_config = true; |
253 | 253 | } |
254 | 254 | } |
255 | - if ($save_config) Api\Config::save_value('customfields',$this->customfields,'infolog'); |
|
255 | + if ($save_config) Api\Config::save_value('customfields', $this->customfields, 'infolog'); |
|
256 | 256 | } |
257 | 257 | if (is_array($config_data['responsible_edit'])) |
258 | 258 | { |
259 | - $this->responsible_edit = array_merge($this->responsible_edit,$config_data['responsible_edit']); |
|
259 | + $this->responsible_edit = array_merge($this->responsible_edit, $config_data['responsible_edit']); |
|
260 | 260 | } |
261 | 261 | if (is_array($config_data['copy_excludefields'])) |
262 | 262 | { |
263 | - $this->copy_excludefields = array_merge($this->copy_excludefields,$config_data['copy_excludefields']); |
|
263 | + $this->copy_excludefields = array_merge($this->copy_excludefields, $config_data['copy_excludefields']); |
|
264 | 264 | } |
265 | 265 | if (is_array($config_data['sub_excludefields']) && $config_data['sub_excludefields']) |
266 | 266 | { |
267 | - $this->sub_excludefields = array_merge($this->sub_excludefields,$config_data['sub_excludefields']); |
|
267 | + $this->sub_excludefields = array_merge($this->sub_excludefields, $config_data['sub_excludefields']); |
|
268 | 268 | } |
269 | 269 | else |
270 | 270 | { |
271 | - $this->sub_excludefields = array_merge($this->sub_excludefields,$this->default_sub_excludefields); |
|
271 | + $this->sub_excludefields = array_merge($this->sub_excludefields, $this->default_sub_excludefields); |
|
272 | 272 | } |
273 | 273 | if ($config_data['implicit_rights'] == 'edit') |
274 | 274 | { |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | $this->history = $config_data['history']; |
278 | 278 | } |
279 | 279 | // sort types by there translation |
280 | - foreach($this->enums['type'] as $key => $val) |
|
280 | + foreach ($this->enums['type'] as $key => $val) |
|
281 | 281 | { |
282 | 282 | if (($val = lang($key)) != $key.'*') $this->enums['type'][$key] = lang($key); |
283 | 283 | } |
@@ -286,14 +286,14 @@ discard block |
||
286 | 286 | $this->user = $GLOBALS['egw_info']['user']['account_id']; |
287 | 287 | |
288 | 288 | $this->now = time(); |
289 | - $this->user_time_now = Api\DateTime::server2user($this->now,'ts'); |
|
289 | + $this->user_time_now = Api\DateTime::server2user($this->now, 'ts'); |
|
290 | 290 | |
291 | - $this->grants = $GLOBALS['egw']->acl->get_grants('infolog',$this->group_owners ? $this->group_owners : true); |
|
291 | + $this->grants = $GLOBALS['egw']->acl->get_grants('infolog', $this->group_owners ? $this->group_owners : true); |
|
292 | 292 | $this->so = new infolog_so($this->grants); |
293 | 293 | |
294 | 294 | if ($info_id) |
295 | 295 | { |
296 | - $this->read( $info_id ); |
|
296 | + $this->read($info_id); |
|
297 | 297 | } |
298 | 298 | else |
299 | 299 | { |
@@ -309,9 +309,9 @@ discard block |
||
309 | 309 | */ |
310 | 310 | function has_customfields($type) |
311 | 311 | { |
312 | - foreach($this->customfields as $field) |
|
312 | + foreach ($this->customfields as $field) |
|
313 | 313 | { |
314 | - if ((!$type || empty($field['type2']) || in_array($type,is_array($field['type2']) ? $field['type2'] : explode(',',$field['type2'])))) |
|
314 | + if ((!$type || empty($field['type2']) || in_array($type, is_array($field['type2']) ? $field['type2'] : explode(',', $field['type2'])))) |
|
315 | 315 | { |
316 | 316 | return True; |
317 | 317 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @param int $user = null user whos rights to check, default current user |
329 | 329 | * @return boolean |
330 | 330 | */ |
331 | - function check_access($info,$required_rights,$other=0,$user=null) |
|
331 | + function check_access($info, $required_rights, $other = 0, $user = null) |
|
332 | 332 | { |
333 | 333 | static $cache = array(); |
334 | 334 | |
@@ -338,17 +338,17 @@ discard block |
||
338 | 338 | if ($user == $this->user) |
339 | 339 | { |
340 | 340 | $grants = $this->grants; |
341 | - if ($info_id) $access =& $cache[$info_id][$required_rights]; // we only cache the current user! |
|
341 | + if ($info_id) $access = & $cache[$info_id][$required_rights]; // we only cache the current user! |
|
342 | 342 | } |
343 | 343 | else |
344 | 344 | { |
345 | - $grants = $GLOBALS['egw']->acl->get_grants('infolog',$this->group_owners ? $this->group_owners : true,$user); |
|
345 | + $grants = $GLOBALS['egw']->acl->get_grants('infolog', $this->group_owners ? $this->group_owners : true, $user); |
|
346 | 346 | } |
347 | 347 | if (!$info) |
348 | 348 | { |
349 | 349 | $owner = $other ? $other : $user; |
350 | 350 | $grant = $grants[$owner]; |
351 | - return $grant & $required_rights; |
|
351 | + return $grant&$required_rights; |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | |
@@ -360,10 +360,10 @@ discard block |
||
360 | 360 | if (!is_array($info) && !($info = $this->so->read(array('info_id' => $info_id)))) return false; |
361 | 361 | |
362 | 362 | if ($info['info_status'] == 'deleted' && |
363 | - ($required_rights == Acl::EDIT || // no edit rights for deleted entries |
|
364 | - $required_rights == Acl::ADD || // no add rights for deleted entries |
|
363 | + ($required_rights == Acl::EDIT || // no edit rights for deleted entries |
|
364 | + $required_rights == Acl::ADD || // no add rights for deleted entries |
|
365 | 365 | $required_rights == Acl::DELETE && ($this->history == 'history_no_delete' || // no delete at all! |
366 | - $this->history == 'history_admin_delete' && (!isset($GLOBALS['egw_info']['user']['apps']['admin']) || $user!=$this->user)))) // delete only for admins |
|
366 | + $this->history == 'history_admin_delete' && (!isset($GLOBALS['egw_info']['user']['apps']['admin']) || $user != $this->user)))) // delete only for admins |
|
367 | 367 | { |
368 | 368 | $access = false; |
369 | 369 | } |
@@ -371,12 +371,12 @@ discard block |
||
371 | 371 | { |
372 | 372 | if ($info['info_status'] != 'deleted') |
373 | 373 | { |
374 | - $access = false; // can only undelete deleted items |
|
374 | + $access = false; // can only undelete deleted items |
|
375 | 375 | } |
376 | 376 | else |
377 | 377 | { |
378 | 378 | // undelete requires edit rights |
379 | - $access = $this->so->check_access( $info,Acl::EDIT,$this->implicit_rights == 'edit',$grants,$user ); |
|
379 | + $access = $this->so->check_access($info, Acl::EDIT, $this->implicit_rights == 'edit', $grants, $user); |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | } |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | } |
387 | 387 | if (!isset($access)) |
388 | 388 | { |
389 | - $access = $this->so->check_access( $info,$required_rights,$this->implicit_rights == 'edit',$grants,$user ); |
|
389 | + $access = $this->so->check_access($info, $required_rights, $this->implicit_rights == 'edit', $grants, $user); |
|
390 | 390 | } |
391 | 391 | } |
392 | 392 | // else $cached = ' (from cache)'; |
@@ -421,12 +421,12 @@ discard block |
||
421 | 421 | * @param string $not_id = '' id to exclude |
422 | 422 | * @return boolean True if we have a linked item, False otherwise |
423 | 423 | */ |
424 | - function link_id2from(&$info,$not_app='',$not_id='') |
|
424 | + function link_id2from(&$info, $not_app = '', $not_id = '') |
|
425 | 425 | { |
426 | 426 | //error_log(__METHOD__ . "(subject='{$info['info_subject']}', link_id='{$info['info_link_id']}', from='{$info['info_from']}', not_app='$not_app', not_id='$not_id')"); |
427 | 427 | |
428 | 428 | if ($info['info_link_id'] > 0 && |
429 | - (isset($info['links']) && ($link = $info['links'][$info['info_link_id']]) || // use supplied links info |
|
429 | + (isset($info['links']) && ($link = $info['links'][$info['info_link_id']]) || // use supplied links info |
|
430 | 430 | ($link = Link::get_link($info['info_link_id'])) !== False)) // if link not found in supplied links, we always search! |
431 | 431 | { |
432 | 432 | if (isset($info['links']) && isset($link['app'])) |
@@ -440,11 +440,11 @@ discard block |
||
440 | 440 | $app = $link['link_app'.$nr]; |
441 | 441 | $id = $link['link_id'.$nr]; |
442 | 442 | } |
443 | - $title = Link::title($app,$id); |
|
443 | + $title = Link::title($app, $id); |
|
444 | 444 | |
445 | 445 | if ((string)$info['info_custom_from'] === '') // old entry |
446 | 446 | { |
447 | - $info['info_custom_from'] = (int) ($title != $info['info_from'] && @htmlentities($title) != $info['info_from']); |
|
447 | + $info['info_custom_from'] = (int)($title != $info['info_from'] && @htmlentities($title) != $info['info_from']); |
|
448 | 448 | } |
449 | 449 | if (!$info['info_custom_from']) |
450 | 450 | { |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | return $info['blur_title'] = $title; |
467 | 467 | } |
468 | 468 | $info['info_link'] = array('title' => $info['info_from']); |
469 | - $info['info_link_id'] = 0; // link might have been deleted |
|
469 | + $info['info_link_id'] = 0; // link might have been deleted |
|
470 | 470 | $info['info_custom_from'] = (int)!!$info['info_from']; |
471 | 471 | |
472 | 472 | return False; |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | */ |
478 | 478 | static function subject_from_des($des) |
479 | 479 | { |
480 | - return substr($des,0,60).' ...'; |
|
480 | + return substr($des, 0, 60).' ...'; |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | /** |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | * or NULL for timestamps in user-time |
493 | 493 | * or false for timestamps in server-time |
494 | 494 | */ |
495 | - function time2time(&$values, $fromTZId=false, $toTZId=null) |
|
495 | + function time2time(&$values, $fromTZId = false, $toTZId = null) |
|
496 | 496 | { |
497 | 497 | |
498 | 498 | if ($fromTZId === $toTZId) return; |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | $toTZ = Api\DateTime::$server_timezone; |
534 | 534 | } |
535 | 535 | //error_log(__METHOD__.'(values[info_enddate]='.date('Y-m-d H:i:s',$values['info_enddate']).", from=".array2string($fromTZId).", to=".array2string($toTZId).") tz=".$tz->getName().', fromTZ='.$fromTZ->getName().', toTZ='.$toTZ->getName().', userTZ='.Api\DateTime::$user_timezone->getName()); |
536 | - foreach($this->timestamps as $key) |
|
536 | + foreach ($this->timestamps as $key) |
|
537 | 537 | { |
538 | 538 | if ($values[$key]) |
539 | 539 | { |
@@ -542,14 +542,14 @@ discard block |
||
542 | 542 | if ($time->format('Hi') == '0000') |
543 | 543 | { |
544 | 544 | // we keep dates the same in new timezone |
545 | - $arr = Api\DateTime::to($time,'array'); |
|
545 | + $arr = Api\DateTime::to($time, 'array'); |
|
546 | 546 | $time = new Api\DateTime($arr, $toTZ); |
547 | 547 | } |
548 | 548 | else |
549 | 549 | { |
550 | 550 | $time->setTimezone($toTZ); |
551 | 551 | } |
552 | - $values[$key] = Api\DateTime::to($time,'ts'); |
|
552 | + $values[$key] = Api\DateTime::to($time, 'ts'); |
|
553 | 553 | } |
554 | 554 | } |
555 | 555 | //error_log(__METHOD__.'() --> values[info_enddate]='.date('Y-m-d H:i:s',$values['info_enddate'])); |
@@ -562,11 +562,11 @@ discard block |
||
562 | 562 | * @param string $date_format = 'ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format |
563 | 563 | * @return mixed depending of $date_format |
564 | 564 | */ |
565 | - function date2usertime($ts,$date_format='ts') |
|
565 | + function date2usertime($ts, $date_format = 'ts') |
|
566 | 566 | { |
567 | 567 | if (empty($ts) || $date_format == 'server') return $ts; |
568 | 568 | |
569 | - return Api\DateTime::server2user($ts,$date_format); |
|
569 | + return Api\DateTime::server2user($ts, $date_format); |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | /** |
@@ -581,10 +581,10 @@ discard block |
||
581 | 581 | * |
582 | 582 | * @return array|boolean infolog entry, null if not found or false if no permission to read it |
583 | 583 | */ |
584 | - function &read($info_id,$run_link_id2from=true,$date_format='ts',$ignore_acl=false) |
|
584 | + function &read($info_id, $run_link_id2from = true, $date_format = 'ts', $ignore_acl = false) |
|
585 | 585 | { |
586 | 586 | //error_log(__METHOD__.'('.array2string($info_id).', '.array2string($run_link_id2from).", '$date_format') ".function_backtrace()); |
587 | - if (is_scalar($info_id) || isset($info_id[count($info_id)-1])) |
|
587 | + if (is_scalar($info_id) || isset($info_id[count($info_id) - 1])) |
|
588 | 588 | { |
589 | 589 | if (is_scalar($info_id) && !is_numeric($info_id)) |
590 | 590 | { |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | return null; |
602 | 602 | } |
603 | 603 | |
604 | - if (!$ignore_acl && !$this->check_access($data,Acl::READ)) // check behind read, to prevent a double read |
|
604 | + if (!$ignore_acl && !$this->check_access($data, Acl::READ)) // check behind read, to prevent a double read |
|
605 | 605 | { |
606 | 606 | return False; |
607 | 607 | } |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | * @param boolean $skip_notification Do not send notification of delete |
634 | 634 | * @return boolean True if delete was successful, False otherwise ($info_id does not exist or no rights) |
635 | 635 | */ |
636 | - function delete($info_id,$delete_children=False,$new_parent=False, $skip_notification=False) |
|
636 | + function delete($info_id, $delete_children = False, $new_parent = False, $skip_notification = False) |
|
637 | 637 | { |
638 | 638 | if (is_array($info_id)) |
639 | 639 | { |
@@ -643,18 +643,18 @@ discard block |
||
643 | 643 | { |
644 | 644 | return False; |
645 | 645 | } |
646 | - if (!$this->check_access($info,Acl::DELETE)) |
|
646 | + if (!$this->check_access($info, Acl::DELETE)) |
|
647 | 647 | { |
648 | 648 | return False; |
649 | 649 | } |
650 | 650 | // check if we have children and delete or re-parent them |
651 | 651 | if (($children = $this->so->get_children($info_id))) |
652 | 652 | { |
653 | - foreach($children as $id => $owner) |
|
653 | + foreach ($children as $id => $owner) |
|
654 | 654 | { |
655 | - if ($delete_children && $this->so->grants[$owner] & Acl::DELETE) |
|
655 | + if ($delete_children && $this->so->grants[$owner]&Acl::DELETE) |
|
656 | 656 | { |
657 | - $this->delete($id,$delete_children,$new_parent,$skip_notification); // call ourself recursive to delete the child |
|
657 | + $this->delete($id, $delete_children, $new_parent, $skip_notification); // call ourself recursive to delete the child |
|
658 | 658 | } |
659 | 659 | else // dont delete or no rights to delete the child --> re-parent it |
660 | 660 | { |
@@ -673,28 +673,28 @@ discard block |
||
673 | 673 | // if we have history switched on and not an already deleted item --> set only status deleted |
674 | 674 | if ($this->history && $info['info_status'] != 'deleted') |
675 | 675 | { |
676 | - if ($info['info_status'] == 'deleted') return false; // entry already deleted |
|
676 | + if ($info['info_status'] == 'deleted') return false; // entry already deleted |
|
677 | 677 | |
678 | 678 | $this->so->write($deleted); |
679 | 679 | |
680 | - Link::unlink(0,'infolog',$info_id,'','!file','',true); // keep the file attachments, hide the rest |
|
680 | + Link::unlink(0, 'infolog', $info_id, '', '!file', '', true); // keep the file attachments, hide the rest |
|
681 | 681 | } |
682 | 682 | else |
683 | 683 | { |
684 | - $this->so->delete($info_id,false); // we delete the children via bo to get all notifications! |
|
684 | + $this->so->delete($info_id, false); // we delete the children via bo to get all notifications! |
|
685 | 685 | |
686 | - Link::unlink(0,'infolog',$info_id); |
|
686 | + Link::unlink(0, 'infolog', $info_id); |
|
687 | 687 | } |
688 | 688 | if ($info['info_status'] != 'deleted') // dont notify of final purge of already deleted items |
689 | 689 | { |
690 | 690 | // send email notifications and do the history logging |
691 | - if(!$skip_notification) |
|
691 | + if (!$skip_notification) |
|
692 | 692 | { |
693 | 693 | if (!is_object($this->tracking)) |
694 | 694 | { |
695 | 695 | $this->tracking = new infolog_tracking($this); |
696 | 696 | } |
697 | - $this->tracking->track($deleted,$info,$this->user,true); |
|
697 | + $this->tracking->track($deleted, $info, $this->user, true); |
|
698 | 698 | } |
699 | 699 | } |
700 | 700 | return True; |
@@ -716,13 +716,13 @@ discard block |
||
716 | 716 | * |
717 | 717 | * @return int|boolean info_id on a successfull write or false |
718 | 718 | */ |
719 | - function write(&$values_in, $check_defaults=true, $touch_modified=true, $user2server=true, |
|
720 | - $skip_notification=false, $throw_exception=false, $purge_cfs=null, $ignore_acl=false) |
|
719 | + function write(&$values_in, $check_defaults = true, $touch_modified = true, $user2server = true, |
|
720 | + $skip_notification = false, $throw_exception = false, $purge_cfs = null, $ignore_acl = false) |
|
721 | 721 | { |
722 | 722 | $values = $values_in; |
723 | 723 | //echo "boinfolog::write()values="; _debug_array($values); |
724 | - if (!$ignore_acl && (!$values['info_id'] && !$this->check_access(0,Acl::EDIT,$values['info_owner']) && |
|
725 | - !$this->check_access(0,Acl::ADD,$values['info_owner']))) |
|
724 | + if (!$ignore_acl && (!$values['info_id'] && !$this->check_access(0, Acl::EDIT, $values['info_owner']) && |
|
725 | + !$this->check_access(0, Acl::ADD, $values['info_owner']))) |
|
726 | 726 | { |
727 | 727 | return false; |
728 | 728 | } |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | $old = $this->read($values['info_id'], false, 'server', $ignore_acl); |
733 | 733 | } |
734 | 734 | |
735 | - if (($status_only = !$ignore_acl && $values['info_id'] && !$this->check_access($values,Acl::EDIT))) |
|
735 | + if (($status_only = !$ignore_acl && $values['info_id'] && !$this->check_access($values, Acl::EDIT))) |
|
736 | 736 | { |
737 | 737 | if (!isset($values['info_responsible'])) |
738 | 738 | { |
@@ -744,21 +744,21 @@ discard block |
||
744 | 744 | } |
745 | 745 | if (!($status_only = in_array($this->user, (array)$responsible))) // responsible has implicit right to change status |
746 | 746 | { |
747 | - $status_only = !!array_intersect((array)$responsible,array_keys($GLOBALS['egw']->accounts->memberships($this->user))); |
|
747 | + $status_only = !!array_intersect((array)$responsible, array_keys($GLOBALS['egw']->accounts->memberships($this->user))); |
|
748 | 748 | } |
749 | 749 | if (!$status_only && $values['info_status'] != 'deleted') |
750 | 750 | { |
751 | - $status_only = $undelete = $this->check_access($values['info_id'],self::ACL_UNDELETE); |
|
751 | + $status_only = $undelete = $this->check_access($values['info_id'], self::ACL_UNDELETE); |
|
752 | 752 | } |
753 | 753 | } |
754 | - if (!$ignore_acl && ($values['info_id'] && !$this->check_access($values['info_id'],Acl::EDIT) && !$status_only || |
|
755 | - !$values['info_id'] && $values['info_id_parent'] && !$this->check_access($values['info_id_parent'],Acl::ADD))) |
|
754 | + if (!$ignore_acl && ($values['info_id'] && !$this->check_access($values['info_id'], Acl::EDIT) && !$status_only || |
|
755 | + !$values['info_id'] && $values['info_id_parent'] && !$this->check_access($values['info_id_parent'], Acl::ADD))) |
|
756 | 756 | { |
757 | 757 | return false; |
758 | 758 | } |
759 | 759 | |
760 | 760 | // Make sure status is still valid if the type changes |
761 | - if($old['info_type'] != $values['info_type'] && $values['info_status']) |
|
761 | + if ($old['info_type'] != $values['info_type'] && $values['info_status']) |
|
762 | 762 | { |
763 | 763 | if (isset($this->status[$values['info_type']]) && |
764 | 764 | !in_array($values['info_status'], array_keys($this->status[$values['info_type']]))) |
@@ -768,8 +768,8 @@ discard block |
||
768 | 768 | } |
769 | 769 | if ($status_only && !$undelete) // make sure only status gets writen |
770 | 770 | { |
771 | - $set_completed = !$values['info_datecompleted'] && // set date completed of finished job, only if its not already set |
|
772 | - in_array($values['info_status'],array('done','billed','cancelled')); |
|
771 | + $set_completed = !$values['info_datecompleted'] && // set date completed of finished job, only if its not already set |
|
772 | + in_array($values['info_status'], array('done', 'billed', 'cancelled')); |
|
773 | 773 | |
774 | 774 | $values = $old; |
775 | 775 | // only overwrite explicitly allowed fields |
@@ -784,7 +784,7 @@ discard block |
||
784 | 784 | $values['info_percent'] = 100; |
785 | 785 | $forcestatus = true; |
786 | 786 | $status = 'done'; |
787 | - if (isset($values['info_type']) && !in_array($values['info_status'],array('done','billed','cancelled'))) { |
|
787 | + if (isset($values['info_type']) && !in_array($values['info_status'], array('done', 'billed', 'cancelled'))) { |
|
788 | 788 | $forcestatus = false; |
789 | 789 | //echo "set_completed:"; _debug_array($this->status[$values['info_type']]); |
790 | 790 | if (isset($this->status[$values['info_type']]['done'])) { |
@@ -798,19 +798,19 @@ discard block |
||
798 | 798 | $status = 'cancelled'; |
799 | 799 | } |
800 | 800 | } |
801 | - if ($forcestatus && !in_array($values['info_status'],array('done','billed','cancelled'))) $values['info_status'] = $status; |
|
801 | + if ($forcestatus && !in_array($values['info_status'], array('done', 'billed', 'cancelled'))) $values['info_status'] = $status; |
|
802 | 802 | } |
803 | 803 | $check_defaults = false; |
804 | 804 | } |
805 | 805 | if ($check_defaults) |
806 | 806 | { |
807 | 807 | if (!$values['info_datecompleted'] && |
808 | - (in_array($values['info_status'],array('done','billed')))) |
|
808 | + (in_array($values['info_status'], array('done', 'billed')))) |
|
809 | 809 | { |
810 | - $values['info_datecompleted'] = $user2server ? $this->user_time_now : $this->now; // set date completed to today if status == done |
|
810 | + $values['info_datecompleted'] = $user2server ? $this->user_time_now : $this->now; // set date completed to today if status == done |
|
811 | 811 | } |
812 | 812 | // Check for valid status / percent combinations |
813 | - if (in_array($values['info_status'],array('done','billed'))) |
|
813 | + if (in_array($values['info_status'], array('done', 'billed'))) |
|
814 | 814 | { |
815 | 815 | $values['info_percent'] = 100; |
816 | 816 | } |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | // We change percent to match status, not status to match percent |
826 | 826 | $values['info_percent'] = 10; |
827 | 827 | } |
828 | - if ((int)$values['info_percent'] == 100 && !in_array($values['info_status'],array('done','billed','cancelled','archive'))) |
|
828 | + if ((int)$values['info_percent'] == 100 && !in_array($values['info_status'], array('done', 'billed', 'cancelled', 'archive'))) |
|
829 | 829 | { |
830 | 830 | //echo "check_defaults:"; _debug_array($this->status[$values['info_type']]); |
831 | 831 | //$values['info_status'] = 'done'; |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | } |
847 | 847 | if ($values['info_responsible'] && $values['info_status'] == 'offer') |
848 | 848 | { |
849 | - $values['info_status'] = 'not-started'; // have to match if not finished |
|
849 | + $values['info_status'] = 'not-started'; // have to match if not finished |
|
850 | 850 | } |
851 | 851 | if (isset($values['info_subject']) && empty($values['info_subject'])) |
852 | 852 | { |
@@ -854,18 +854,18 @@ discard block |
||
854 | 854 | } |
855 | 855 | |
856 | 856 | // Check required custom fields |
857 | - if($throw_exception) |
|
857 | + if ($throw_exception) |
|
858 | 858 | { |
859 | 859 | $custom = Api\Storage\Customfields::get('infolog'); |
860 | - foreach($custom as $c_name => $c_field) |
|
860 | + foreach ($custom as $c_name => $c_field) |
|
861 | 861 | { |
862 | - if($c_field['type2']) $type2 = is_array($c_field['type2']) ? $c_field['type2'] : explode(',',$c_field['type2']); |
|
863 | - if($c_field['needed'] && (!$c_field['type2'] || $c_field['type2'] && in_array($values['info_type'],$type2))) |
|
862 | + if ($c_field['type2']) $type2 = is_array($c_field['type2']) ? $c_field['type2'] : explode(',', $c_field['type2']); |
|
863 | + if ($c_field['needed'] && (!$c_field['type2'] || $c_field['type2'] && in_array($values['info_type'], $type2))) |
|
864 | 864 | { |
865 | 865 | // Required custom field |
866 | - if(!$values['#'.$c_name]) |
|
866 | + if (!$values['#'.$c_name]) |
|
867 | 867 | { |
868 | - throw new Api\Exception\WrongUserinput(lang('For infolog type %1, %2 is required',lang($values['info_type']),$c_field['label'])); |
|
868 | + throw new Api\Exception\WrongUserinput(lang('For infolog type %1, %2 is required', lang($values['info_type']), $c_field['label'])); |
|
869 | 869 | } |
870 | 870 | } |
871 | 871 | } |
@@ -874,16 +874,16 @@ discard block |
||
874 | 874 | if (isset($this->group_owners[$values['info_type']])) |
875 | 875 | { |
876 | 876 | $values['info_owner'] = $this->group_owners[$values['info_type']]; |
877 | - if (!$ignore_acl && !($this->grants[$this->group_owners[$values['info_type']]] & Acl::EDIT)) |
|
877 | + if (!$ignore_acl && !($this->grants[$this->group_owners[$values['info_type']]]&Acl::EDIT)) |
|
878 | 878 | { |
879 | - if (!$this->check_access($values['info_id'],Acl::EDIT) || |
|
880 | - !$values['info_id'] && !$this->check_access($values,Acl::ADD) |
|
879 | + if (!$this->check_access($values['info_id'], Acl::EDIT) || |
|
880 | + !$values['info_id'] && !$this->check_access($values, Acl::ADD) |
|
881 | 881 | ) |
882 | 882 | { |
883 | - return false; // no edit rights from the group-owner and no implicit rights (delegated and sufficient rights) |
|
883 | + return false; // no edit rights from the group-owner and no implicit rights (delegated and sufficient rights) |
|
884 | 884 | } |
885 | 885 | } |
886 | - $values['info_access'] = 'public'; // group-owners are allways public |
|
886 | + $values['info_access'] = 'public'; // group-owners are allways public |
|
887 | 887 | } |
888 | 888 | elseif (!$values['info_id'] && !$values['info_owner'] || $GLOBALS['egw']->accounts->get_type($values['info_owner']) == 'g') |
889 | 889 | { |
@@ -938,10 +938,10 @@ discard block |
||
938 | 938 | $to_write['info_id'] = $info_id; |
939 | 939 | |
940 | 940 | // if the info responbsible array is not passed, fetch it from old. |
941 | - if (!array_key_exists('info_responsible',$values)) $values['info_responsible'] = $old['info_responsible']; |
|
941 | + if (!array_key_exists('info_responsible', $values)) $values['info_responsible'] = $old['info_responsible']; |
|
942 | 942 | if (!is_array($values['info_responsible'])) // this should not happen, bug it does ;-) |
943 | 943 | { |
944 | - $values['info_responsible'] = $values['info_responsible'] ? explode(',',$values['info_responsible']) : array(); |
|
944 | + $values['info_responsible'] = $values['info_responsible'] ? explode(',', $values['info_responsible']) : array(); |
|
945 | 945 | $to_write['info_responsible'] = $values['info_responsible']; |
946 | 946 | } |
947 | 947 | |
@@ -949,11 +949,11 @@ discard block |
||
949 | 949 | if (!$old && is_array($to_write['link_to']['to_id']) && count($to_write['link_to']['to_id'])) |
950 | 950 | { |
951 | 951 | //echo "<p>writing links for new entry $info_id</p>\n"; _debug_array($content['link_to']['to_id']); |
952 | - Link::link('infolog',$info_id,$to_write['link_to']['to_id']); |
|
952 | + Link::link('infolog', $info_id, $to_write['link_to']['to_id']); |
|
953 | 953 | $values['link_to']['to_id'] = $info_id; |
954 | 954 | } |
955 | 955 | $this->write_check_links($to_write); |
956 | - if(!$values['info_link_id'] || $values['info_link_id'] != $to_write['info_link_id']) |
|
956 | + if (!$values['info_link_id'] || $values['info_link_id'] != $to_write['info_link_id']) |
|
957 | 957 | { |
958 | 958 | // Just got a link ID, need to save it |
959 | 959 | $this->so->write($to_write); |
@@ -968,20 +968,20 @@ discard block |
||
968 | 968 | } |
969 | 969 | |
970 | 970 | // create (and remove) links in custom fields |
971 | - if(!is_array($old)) |
|
971 | + if (!is_array($old)) |
|
972 | 972 | { |
973 | 973 | $old = array(); |
974 | 974 | } |
975 | - Api\Storage\Customfields::update_links('infolog',$values,$old,'info_id'); |
|
975 | + Api\Storage\Customfields::update_links('infolog', $values, $old, 'info_id'); |
|
976 | 976 | |
977 | 977 | // Check for restore of deleted entry, restore held links |
978 | - if($old['info_status'] == 'deleted' && $values['info_status'] != 'deleted') |
|
978 | + if ($old['info_status'] == 'deleted' && $values['info_status'] != 'deleted') |
|
979 | 979 | { |
980 | 980 | Link::restore('infolog', $info_id); |
981 | 981 | } |
982 | 982 | |
983 | 983 | // notify the link-class about the update, as other apps may be subscribt to it |
984 | - Link::notify_update('infolog',$info_id,$values); |
|
984 | + Link::notify_update('infolog', $info_id, $values); |
|
985 | 985 | |
986 | 986 | // pre-cache the new values |
987 | 987 | self::set_link_cache($values); |
@@ -992,39 +992,39 @@ discard block |
||
992 | 992 | $this->tracking = new infolog_tracking($this); |
993 | 993 | } |
994 | 994 | |
995 | - if ($old && ($missing_fields = array_diff_key($old,$values))) |
|
995 | + if ($old && ($missing_fields = array_diff_key($old, $values))) |
|
996 | 996 | { |
997 | 997 | // Some custom fields (multiselect with nothing selected) will be missing, |
998 | 998 | // and that's OK. Don't put them back. |
999 | - foreach(array_keys($missing_fields) as $field) |
|
999 | + foreach (array_keys($missing_fields) as $field) |
|
1000 | 1000 | { |
1001 | - if(array_key_exists($field, $values_in)) |
|
1001 | + if (array_key_exists($field, $values_in)) |
|
1002 | 1002 | { |
1003 | 1003 | unset($missing_fields[$field]); |
1004 | 1004 | } |
1005 | 1005 | } |
1006 | - $values = array_merge($values,$missing_fields); |
|
1006 | + $values = array_merge($values, $missing_fields); |
|
1007 | 1007 | } |
1008 | 1008 | // Add keys missing in the $to_write array |
1009 | - if (($missing_fields = array_diff_key($values,$to_write))) |
|
1009 | + if (($missing_fields = array_diff_key($values, $to_write))) |
|
1010 | 1010 | { |
1011 | - $to_write = array_merge($to_write,$missing_fields); |
|
1011 | + $to_write = array_merge($to_write, $missing_fields); |
|
1012 | 1012 | } |
1013 | - $this->tracking->track($to_write,$old,$this->user,$values['info_status'] == 'deleted' || $old['info_status'] == 'deleted', |
|
1014 | - null,$skip_notification); |
|
1013 | + $this->tracking->track($to_write, $old, $this->user, $values['info_status'] == 'deleted' || $old['info_status'] == 'deleted', |
|
1014 | + null, $skip_notification); |
|
1015 | 1015 | |
1016 | 1016 | if ($info_from_set) $values['info_from'] = ''; |
1017 | 1017 | |
1018 | 1018 | // Change new values back to user time before sending them back |
1019 | - if($user2server) |
|
1019 | + if ($user2server) |
|
1020 | 1020 | { |
1021 | 1021 | $this->time2time($values); |
1022 | 1022 | } |
1023 | 1023 | // merge changes (keeping extra values from the UI) |
1024 | - $values_in = array_merge($values_in,$values); |
|
1024 | + $values_in = array_merge($values_in, $values); |
|
1025 | 1025 | |
1026 | 1026 | // Update modified timestamp of parent |
1027 | - if($values['info_id_parent'] && $touch_modified) |
|
1027 | + if ($values['info_id_parent'] && $touch_modified) |
|
1028 | 1028 | { |
1029 | 1029 | $parent = $this->read($values['info_id_parent'], false, 'server', true); |
1030 | 1030 | $this->write($parent, false, true, false, true, false, null, $ignore_acl); |
@@ -1044,9 +1044,9 @@ discard block |
||
1044 | 1044 | protected function write_check_links(&$values) |
1045 | 1045 | { |
1046 | 1046 | $old_link_id = (int)$values['info_link_id']; |
1047 | - if($values['info_contact']) |
|
1047 | + if ($values['info_contact']) |
|
1048 | 1048 | { |
1049 | - if(is_array($values['info_contact'])) |
|
1049 | + if (is_array($values['info_contact'])) |
|
1050 | 1050 | { |
1051 | 1051 | // eTemplate2 returns the array all ready |
1052 | 1052 | $app = $values['info_contact']['app']; |
@@ -1063,14 +1063,14 @@ discard block |
||
1063 | 1063 | } |
1064 | 1064 | elseif ($app && $id) |
1065 | 1065 | { |
1066 | - if(!is_array($values['link_to'])) |
|
1066 | + if (!is_array($values['link_to'])) |
|
1067 | 1067 | { |
1068 | 1068 | $values['link_to'] = array(); |
1069 | 1069 | } |
1070 | 1070 | $values['info_link_id'] = (int)($info_link_id = Link::link( |
1071 | 1071 | 'infolog', |
1072 | 1072 | $values['info_id'], |
1073 | - $app,$id |
|
1073 | + $app, $id |
|
1074 | 1074 | )); |
1075 | 1075 | } |
1076 | 1076 | else |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | { |
1083 | 1083 | $link = Link::get_link($old_link_id); |
1084 | 1084 | // remove selected project, if removed link is that project |
1085 | - if($link['link_app2'] == 'projectmanager' && $link['link_id2'] == $values['old_pm_id']) |
|
1085 | + if ($link['link_app2'] == 'projectmanager' && $link['link_id2'] == $values['old_pm_id']) |
|
1086 | 1086 | { |
1087 | 1087 | unset($values['pm_id'], $values['old_pm_id']); |
1088 | 1088 | } |
@@ -1101,9 +1101,9 @@ discard block |
||
1101 | 1101 | * @param int|array $info_id id |
1102 | 1102 | * @return int|array number of subs |
1103 | 1103 | */ |
1104 | - function anzSubs( $info_id ) |
|
1104 | + function anzSubs($info_id) |
|
1105 | 1105 | { |
1106 | - return $this->so->anzSubs( $info_id ); |
|
1106 | + return $this->so->anzSubs($info_id); |
|
1107 | 1107 | } |
1108 | 1108 | |
1109 | 1109 | /** |
@@ -1120,23 +1120,23 @@ discard block |
||
1120 | 1120 | * @param boolean $no_acl =false true: ignore all acl |
1121 | 1121 | * @return array with id's as key of the matching log-entries |
1122 | 1122 | */ |
1123 | - function &search(&$query, $no_acl=false) |
|
1123 | + function &search(&$query, $no_acl = false) |
|
1124 | 1124 | { |
1125 | 1125 | //error_log(__METHOD__.'('.array2string($query).')'); |
1126 | 1126 | |
1127 | - if($query['filter'] == 'bydate') |
|
1127 | + if ($query['filter'] == 'bydate') |
|
1128 | 1128 | { |
1129 | 1129 | if (is_int($query['startdate'])) $query['col_filter'][] = 'info_startdate >= '.$GLOBALS['egw']->db->quote($query['startdate']); |
1130 | - if (is_int($query['enddate'])) $query['col_filter'][] = 'info_startdate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1); |
|
1130 | + if (is_int($query['enddate'])) $query['col_filter'][] = 'info_startdate <= '.$GLOBALS['egw']->db->quote($query['enddate'] + (60 * 60 * 24) - 1); |
|
1131 | 1131 | } |
1132 | 1132 | elseif ($query['filter'] == 'duedate') |
1133 | 1133 | { |
1134 | 1134 | if (is_int($query['startdate'])) $query['col_filter'][] = 'info_enddate >= '.$GLOBALS['egw']->db->quote($query['startdate']); |
1135 | - if (is_int($query['enddate'])) $query['col_filter'][] = 'info_enddate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1); |
|
1135 | + if (is_int($query['enddate'])) $query['col_filter'][] = 'info_enddate <= '.$GLOBALS['egw']->db->quote($query['enddate'] + (60 * 60 * 24) - 1); |
|
1136 | 1136 | } |
1137 | 1137 | elseif ($query['filter'] == 'private') |
1138 | 1138 | { |
1139 | - $query['col_filter'][] = 'info_access = ' . $GLOBALS['egw']->db->quote('private'); |
|
1139 | + $query['col_filter'][] = 'info_access = '.$GLOBALS['egw']->db->quote('private'); |
|
1140 | 1140 | } |
1141 | 1141 | if (!isset($query['date_format']) || $query['date_format'] != 'server') |
1142 | 1142 | { |
@@ -1146,7 +1146,7 @@ discard block |
||
1146 | 1146 | { |
1147 | 1147 | if (!empty($query['col_filter'][$key])) |
1148 | 1148 | { |
1149 | - $query['col_filter'][$key] = Api\DateTime::user2server($query['col_filter'][$key],'ts'); |
|
1149 | + $query['col_filter'][$key] = Api\DateTime::user2server($query['col_filter'][$key], 'ts'); |
|
1150 | 1150 | } |
1151 | 1151 | } |
1152 | 1152 | } |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | { |
1160 | 1160 | foreach ($ret as $id => &$data) |
1161 | 1161 | { |
1162 | - if (!$no_acl && !$this->check_access($data,Acl::READ)) |
|
1162 | + if (!$no_acl && !$this->check_access($data, Acl::READ)) |
|
1163 | 1163 | { |
1164 | 1164 | unset($ret[$id]); |
1165 | 1165 | continue; |
@@ -1175,7 +1175,7 @@ discard block |
||
1175 | 1175 | if ($time->format('Hi') == '0000') |
1176 | 1176 | { |
1177 | 1177 | // we keep dates the same in user-time |
1178 | - $arr = Api\DateTime::to($time,'array'); |
|
1178 | + $arr = Api\DateTime::to($time, 'array'); |
|
1179 | 1179 | $time = new Api\DateTime($arr, Api\DateTime::$user_timezone); |
1180 | 1180 | } |
1181 | 1181 | else |
@@ -1183,7 +1183,7 @@ discard block |
||
1183 | 1183 | $time->setTimezone(Api\DateTime::$user_timezone); |
1184 | 1184 | } |
1185 | 1185 | } |
1186 | - $data[$key] = Api\DateTime::to($time,'ts'); |
|
1186 | + $data[$key] = Api\DateTime::to($time, 'ts'); |
|
1187 | 1187 | } |
1188 | 1188 | } |
1189 | 1189 | // pre-cache title and file access |
@@ -1200,7 +1200,7 @@ discard block |
||
1200 | 1200 | * @param array $filter = array('filter'=>'own','info_type'=>'task') |
1201 | 1201 | * @return string |
1202 | 1202 | */ |
1203 | - public function getctag(array $filter=array('filter'=>'own','info_type'=>'task')) |
|
1203 | + public function getctag(array $filter = array('filter'=>'own', 'info_type'=>'task')) |
|
1204 | 1204 | { |
1205 | 1205 | $filter += array( |
1206 | 1206 | 'order' => 'info_datemodified', |
@@ -1212,7 +1212,7 @@ discard block |
||
1212 | 1212 | // we need to query deleted entries too for a ctag! |
1213 | 1213 | $filter['filter'] .= '+deleted'; |
1214 | 1214 | |
1215 | - $result =& $this->search($filter); |
|
1215 | + $result = & $this->search($filter); |
|
1216 | 1216 | |
1217 | 1217 | if (empty($result)) return 'EGw-empty-wGE'; |
1218 | 1218 | |
@@ -1234,12 +1234,12 @@ discard block |
||
1234 | 1234 | * @param string $_date |
1235 | 1235 | * @return array $content array for uiinfolog |
1236 | 1236 | */ |
1237 | - function import_mail($_addresses,$_subject,$_message,$_attachments,$_date) |
|
1237 | + function import_mail($_addresses, $_subject, $_message, $_attachments, $_date) |
|
1238 | 1238 | { |
1239 | - foreach($_addresses as $address) |
|
1239 | + foreach ($_addresses as $address) |
|
1240 | 1240 | { |
1241 | 1241 | $names[] = $address['name']; |
1242 | - $emails[] =$address['email']; |
|
1242 | + $emails[] = $address['email']; |
|
1243 | 1243 | } |
1244 | 1244 | |
1245 | 1245 | $type = isset($this->enums['type']['email']) ? 'email' : 'note'; |
@@ -1247,8 +1247,8 @@ discard block |
||
1247 | 1247 | $info = array( |
1248 | 1248 | 'info_id' => 0, |
1249 | 1249 | 'info_type' => $type, |
1250 | - 'info_from' => implode(', ',$names), |
|
1251 | - 'info_addr' => implode(', ',$emails), |
|
1250 | + 'info_from' => implode(', ', $names), |
|
1251 | + 'info_addr' => implode(', ', $emails), |
|
1252 | 1252 | 'info_subject' => $_subject, |
1253 | 1253 | 'info_des' => $_message, |
1254 | 1254 | 'info_startdate' => Api\DateTime::server2user($_date), |
@@ -1267,16 +1267,16 @@ discard block |
||
1267 | 1267 | $contacts = array(); |
1268 | 1268 | foreach ($emails as $mailadr) |
1269 | 1269 | { |
1270 | - $contacts = array_merge($contacts,(array)$addressbook->search( |
|
1270 | + $contacts = array_merge($contacts, (array)$addressbook->search( |
|
1271 | 1271 | array( |
1272 | 1272 | 'email' => $mailadr, |
1273 | 1273 | 'email_home' => $mailadr |
1274 | - ),True,'','','',false,'OR',false,null,'',false)); |
|
1274 | + ), True, '', '', '', false, 'OR', false, null, '', false)); |
|
1275 | 1275 | } |
1276 | 1276 | if (!$contacts || !is_array($contacts) || !is_array($contacts[0])) |
1277 | 1277 | { |
1278 | - $info['msg'] = lang('Attention: No Contact with address %1 found.',$info['info_addr']); |
|
1279 | - $info['info_custom_from'] = true; // show the info_from line and NOT only the link |
|
1278 | + $info['msg'] = lang('Attention: No Contact with address %1 found.', $info['info_addr']); |
|
1279 | + $info['info_custom_from'] = true; // show the info_from line and NOT only the link |
|
1280 | 1280 | } |
1281 | 1281 | else |
1282 | 1282 | { |
@@ -1286,21 +1286,21 @@ discard block |
||
1286 | 1286 | // create the rest a "ordinary" links |
1287 | 1287 | foreach ($contacts as $contact) |
1288 | 1288 | { |
1289 | - Link::link('infolog',$info['link_to']['to_id'],'addressbook',$contact['id']); |
|
1289 | + Link::link('infolog', $info['link_to']['to_id'], 'addressbook', $contact['id']); |
|
1290 | 1290 | } |
1291 | 1291 | } |
1292 | 1292 | if (is_array($_attachments)) |
1293 | 1293 | { |
1294 | 1294 | foreach ($_attachments as $attachment) |
1295 | 1295 | { |
1296 | - if($attachment['egw_data']) |
|
1296 | + if ($attachment['egw_data']) |
|
1297 | 1297 | { |
1298 | - Link::link('infolog',$info['link_to']['to_id'],Link::DATA_APPNAME, $attachment); |
|
1298 | + Link::link('infolog', $info['link_to']['to_id'], Link::DATA_APPNAME, $attachment); |
|
1299 | 1299 | } |
1300 | - else if(is_readable($attachment['tmp_name']) || |
|
1300 | + else if (is_readable($attachment['tmp_name']) || |
|
1301 | 1301 | (Vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs')) |
1302 | 1302 | { |
1303 | - Link::link('infolog',$info['link_to']['to_id'],'file', $attachment); |
|
1303 | + Link::link('infolog', $info['link_to']['to_id'], 'file', $attachment); |
|
1304 | 1304 | } |
1305 | 1305 | } |
1306 | 1306 | } |
@@ -1319,14 +1319,14 @@ discard block |
||
1319 | 1319 | { |
1320 | 1320 | if (!is_array($info)) |
1321 | 1321 | { |
1322 | - $info = $this->read( $info,false ); |
|
1322 | + $info = $this->read($info, false); |
|
1323 | 1323 | } |
1324 | 1324 | if (!$info) |
1325 | 1325 | { |
1326 | 1326 | return $info; |
1327 | 1327 | } |
1328 | - $title = !empty($info['info_subject']) ? $info['info_subject'] :self::subject_from_des($info['info_descr']); |
|
1329 | - return $title.($GLOBALS['egw_info']['user']['preferences']['infolog']['show_id']?' (#'.$info['info_id'].')':''); |
|
1328 | + $title = !empty($info['info_subject']) ? $info['info_subject'] : self::subject_from_des($info['info_descr']); |
|
1329 | + return $title.($GLOBALS['egw_info']['user']['preferences']['infolog']['show_id'] ? ' (#'.$info['info_id'].')' : ''); |
|
1330 | 1330 | } |
1331 | 1331 | |
1332 | 1332 | /** |
@@ -1337,15 +1337,15 @@ discard block |
||
1337 | 1337 | function link_titles(array $ids) |
1338 | 1338 | { |
1339 | 1339 | $titles = array(); |
1340 | - foreach ($this->search($params=array( |
|
1340 | + foreach ($this->search($params = array( |
|
1341 | 1341 | 'col_filter' => array('info_id' => $ids), |
1342 | 1342 | )) as $info) |
1343 | 1343 | { |
1344 | 1344 | $titles[$info['info_id']] = $this->link_title($info); |
1345 | 1345 | } |
1346 | - foreach (array_diff($ids,array_keys($titles)) as $id) |
|
1346 | + foreach (array_diff($ids, array_keys($titles)) as $id) |
|
1347 | 1347 | { |
1348 | - $titles[$id] = false; // we assume every not returned entry to be not readable, as we notify the link class about all deletes |
|
1348 | + $titles[$id] = false; // we assume every not returned entry to be not readable, as we notify the link class about all deletes |
|
1349 | 1349 | } |
1350 | 1350 | return $titles; |
1351 | 1351 | } |
@@ -1372,7 +1372,7 @@ discard block |
||
1372 | 1372 | $content = array(); |
1373 | 1373 | if (is_array($ids)) |
1374 | 1374 | { |
1375 | - foreach(array_keys($ids) as $id) |
|
1375 | + foreach (array_keys($ids) as $id) |
|
1376 | 1376 | { |
1377 | 1377 | $content[$id] = $this->link_title($id); |
1378 | 1378 | } |
@@ -1389,10 +1389,10 @@ discard block |
||
1389 | 1389 | * @param int $user = null for which user to check, default current user |
1390 | 1390 | * @return boolean true if access is granted or false otherwise |
1391 | 1391 | */ |
1392 | - function file_access($id,$check,$rel_path=null,$user=null) |
|
1392 | + function file_access($id, $check, $rel_path = null, $user = null) |
|
1393 | 1393 | { |
1394 | - unset($rel_path); // not used |
|
1395 | - return $this->check_access($id,$check,0,$user); |
|
1394 | + unset($rel_path); // not used |
|
1395 | + return $this->check_access($id, $check, 0, $user); |
|
1396 | 1396 | } |
1397 | 1397 | |
1398 | 1398 | /** |
@@ -1402,10 +1402,9 @@ discard block |
||
1402 | 1402 | */ |
1403 | 1403 | function set_link_cache(array $info) |
1404 | 1404 | { |
1405 | - Link::set_cache('infolog',$info['info_id'], |
|
1405 | + Link::set_cache('infolog', $info['info_id'], |
|
1406 | 1406 | $this->link_title($info), |
1407 | - $this->file_access($info,Acl::EDIT) ? EGW_ACL_READ|EGW_ACL_EDIT : |
|
1408 | - ($this->file_access($info,Acl::READ) ? Acl::READ : 0)); |
|
1407 | + $this->file_access($info, Acl::EDIT) ? EGW_ACL_READ|EGW_ACL_EDIT : ($this->file_access($info, Acl::READ) ? Acl::READ : 0)); |
|
1409 | 1408 | } |
1410 | 1409 | |
1411 | 1410 | /** |
@@ -1419,8 +1418,8 @@ discard block |
||
1419 | 1418 | function cal_to_include($args) |
1420 | 1419 | { |
1421 | 1420 | //echo "<p>cal_to_include("; print_r($args); echo ")</p>\n"; |
1422 | - $user = (int) $args['owner']; |
|
1423 | - if ($user <= 0 && !checkdate($args['month'],$args['day'],$args['year'])) |
|
1421 | + $user = (int)$args['owner']; |
|
1422 | + if ($user <= 0 && !checkdate($args['month'], $args['day'], $args['year'])) |
|
1424 | 1423 | { |
1425 | 1424 | return False; |
1426 | 1425 | } |
@@ -1428,7 +1427,7 @@ discard block |
||
1428 | 1427 | |
1429 | 1428 | $do_events = $args['location'] == 'calendar_include_events'; |
1430 | 1429 | $to_include = array(); |
1431 | - $date_wanted = sprintf('%04d/%02d/%02d',$args['year'],$args['month'],$args['day']); |
|
1430 | + $date_wanted = sprintf('%04d/%02d/%02d', $args['year'], $args['month'], $args['day']); |
|
1432 | 1431 | $query = array( |
1433 | 1432 | 'order' => $args['order'] ? $args['order'] : 'info_startdate', |
1434 | 1433 | 'sort' => $args['sort'] ? $args['sort'] : ($do_events ? 'ASC' : 'DESC'), |
@@ -1437,34 +1436,34 @@ discard block |
||
1437 | 1436 | ); |
1438 | 1437 | if ($GLOBALS['egw_info']['user']['preferences']['infolog']['cal_show'] || $GLOBALS['egw_info']['user']['preferences']['infolog']['cal_show'] === '0') |
1439 | 1438 | { |
1440 | - $query['col_filter']['info_type'] = explode(',',$GLOBALS['egw_info']['user']['preferences']['infolog']['cal_show']); |
|
1439 | + $query['col_filter']['info_type'] = explode(',', $GLOBALS['egw_info']['user']['preferences']['infolog']['cal_show']); |
|
1441 | 1440 | } |
1442 | 1441 | elseif ($this->customfields && !$GLOBALS['egw_info']['user']['preferences']['infolog']['cal_show_custom']) |
1443 | 1442 | { |
1444 | - $query['col_filter']['info_type'] = array('task','phone','note','email'); |
|
1443 | + $query['col_filter']['info_type'] = array('task', 'phone', 'note', 'email'); |
|
1445 | 1444 | } |
1446 | 1445 | while ($infos = $this->search($query)) |
1447 | 1446 | { |
1448 | 1447 | foreach ($infos as $info) |
1449 | 1448 | { |
1450 | - $start = new Api\DateTime($info['info_startdate'],Api\DateTime::$user_timezone); |
|
1449 | + $start = new Api\DateTime($info['info_startdate'], Api\DateTime::$user_timezone); |
|
1451 | 1450 | $title = ($do_events ? $start->format(false).' ' : ''). |
1452 | 1451 | $info['info_subject']; |
1453 | - $view = Link::view('infolog',$info['info_id']); |
|
1452 | + $view = Link::view('infolog', $info['info_id']); |
|
1454 | 1453 | $size = null; |
1455 | - $edit = Link::edit('infolog',$info['info_id'], $size); |
|
1454 | + $edit = Link::edit('infolog', $info['info_id'], $size); |
|
1456 | 1455 | $edit['size'] = $size; |
1457 | - $content=array(); |
|
1456 | + $content = array(); |
|
1458 | 1457 | $status = $this->status[$info['info_type']][$info['info_status']]; |
1459 | 1458 | $icons = array(); |
1460 | - foreach(array( |
|
1459 | + foreach (array( |
|
1461 | 1460 | $info['info_type'] => 'navbar', |
1462 | 1461 | $status => 'status' |
1463 | 1462 | ) as $icon => $default) |
1464 | 1463 | { |
1465 | - $icons[Api\Image::find('infolog',$icon) ? $icon : $default] = $icon; |
|
1464 | + $icons[Api\Image::find('infolog', $icon) ? $icon : $default] = $icon; |
|
1466 | 1465 | } |
1467 | - $content[] = Api\Html::a_href($title,$view); |
|
1466 | + $content[] = Api\Html::a_href($title, $view); |
|
1468 | 1467 | $html = Api\Html::table(array(1 => $content)); |
1469 | 1468 | |
1470 | 1469 | $to_include[] = array( |
@@ -1477,9 +1476,9 @@ discard block |
||
1477 | 1476 | 'content' => $html, |
1478 | 1477 | ); |
1479 | 1478 | } |
1480 | - if ($query['total'] <= ($query['start']+=count($infos))) |
|
1479 | + if ($query['total'] <= ($query['start'] += count($infos))) |
|
1481 | 1480 | { |
1482 | - break; // no more availible |
|
1481 | + break; // no more availible |
|
1483 | 1482 | } |
1484 | 1483 | } |
1485 | 1484 | //echo "boinfolog::cal_to_include("; print_r($args); echo ")<pre>"; print_r($to_include); echo "</pre>\n"; |
@@ -1502,7 +1501,7 @@ discard block |
||
1502 | 1501 | 'cols' => 'main.info_id,info_type,info_status,info_percent,info_id_parent', |
1503 | 1502 | ); |
1504 | 1503 | $infos = array(); |
1505 | - foreach($this->search($query) as $row) |
|
1504 | + foreach ($this->search($query) as $row) |
|
1506 | 1505 | { |
1507 | 1506 | $infos[$row['info_id']] = array( |
1508 | 1507 | 'status' => $row['info_type'] != 'phone' && $row['info_status'] == 'ongoing' ? |
@@ -1511,16 +1510,16 @@ discard block |
||
1511 | 1510 | 'ongoing' : 'infolog/'.$row['info_status'], |
1512 | 1511 | 'class' => $row['info_id_parent'] ? 'infolog_rowHasParent' : null, |
1513 | 1512 | ); |
1514 | - if (Api\Image::find('infolog', $icon=$row['info_type'].'_element') || |
|
1515 | - Api\Image::find('infolog', $icon=$row['info_type'])) |
|
1513 | + if (Api\Image::find('infolog', $icon = $row['info_type'].'_element') || |
|
1514 | + Api\Image::find('infolog', $icon = $row['info_type'])) |
|
1516 | 1515 | { |
1517 | 1516 | $infos[$row['info_id']]['icon'] = 'infolog/'.$icon; |
1518 | 1517 | } |
1519 | 1518 | } |
1520 | 1519 | $anzSubs = $this->anzSubs(array_keys($infos)); |
1521 | - if($anzSubs && is_array($anzSubs)) |
|
1520 | + if ($anzSubs && is_array($anzSubs)) |
|
1522 | 1521 | { |
1523 | - foreach($anzSubs as $info_id => $subs) |
|
1522 | + foreach ($anzSubs as $info_id => $subs) |
|
1524 | 1523 | { |
1525 | 1524 | if ($subs) $infos[$info_id]['class'] .= ' infolog_rowHasSubs'; |
1526 | 1525 | } |
@@ -1540,18 +1539,18 @@ discard block |
||
1540 | 1539 | * by the ones the user normally does not see due to category permissions - used to preserve categories |
1541 | 1540 | * @return array category ids (found, added and preserved categories) |
1542 | 1541 | */ |
1543 | - function find_or_add_categories($catname_list, $info_id=-1) |
|
1542 | + function find_or_add_categories($catname_list, $info_id = -1) |
|
1544 | 1543 | { |
1545 | 1544 | if (!is_object($this->categories)) |
1546 | 1545 | { |
1547 | - $this->categories = new Api\Categories($this->user,'infolog'); |
|
1546 | + $this->categories = new Api\Categories($this->user, 'infolog'); |
|
1548 | 1547 | } |
1549 | 1548 | $old_cats_preserve = array(); |
1550 | 1549 | if ($info_id && $info_id > 0) |
1551 | 1550 | { |
1552 | 1551 | // preserve Api\Categories without users read access |
1553 | 1552 | $old_infolog = $this->read($info_id); |
1554 | - $old_categories = explode(',',$old_infolog['info_cat']); |
|
1553 | + $old_categories = explode(',', $old_infolog['info_cat']); |
|
1555 | 1554 | if (is_array($old_categories) && count($old_categories) > 0) |
1556 | 1555 | { |
1557 | 1556 | foreach ($old_categories as $cat_id) |
@@ -1612,15 +1611,15 @@ discard block |
||
1612 | 1611 | { |
1613 | 1612 | if (!is_object($this->categories)) |
1614 | 1613 | { |
1615 | - $this->categories = new Api\Categories($this->user,'infolog'); |
|
1614 | + $this->categories = new Api\Categories($this->user, 'infolog'); |
|
1616 | 1615 | } |
1617 | 1616 | |
1618 | 1617 | if (!is_array($cat_id_list)) |
1619 | 1618 | { |
1620 | - $cat_id_list = explode(',',$cat_id_list); |
|
1619 | + $cat_id_list = explode(',', $cat_id_list); |
|
1621 | 1620 | } |
1622 | 1621 | $cat_list = array(); |
1623 | - foreach($cat_id_list as $cat_id) |
|
1622 | + foreach ($cat_id_list as $cat_id) |
|
1624 | 1623 | { |
1625 | 1624 | if ($cat_id && $this->categories->check_perms(Acl::READ, $cat_id) && |
1626 | 1625 | ($cat_name = $this->categories->id2name($cat_id)) && $cat_name != '--') |
@@ -1647,19 +1646,19 @@ discard block |
||
1647 | 1646 | |
1648 | 1647 | $save_account_id = $GLOBALS['egw_info']['user']['account_id']; |
1649 | 1648 | $save_prefs = $GLOBALS['egw_info']['user']['preferences']; |
1650 | - foreach($users as $user) |
|
1649 | + foreach ($users as $user) |
|
1651 | 1650 | { |
1652 | - if (!($email = $GLOBALS['egw']->accounts->id2name($user,'account_email'))) continue; |
|
1651 | + if (!($email = $GLOBALS['egw']->accounts->id2name($user, 'account_email'))) continue; |
|
1653 | 1652 | // create the enviroment for $user |
1654 | 1653 | $this->user = $GLOBALS['egw_info']['user']['account_id'] = $user; |
1655 | 1654 | $GLOBALS['egw']->preferences->__construct($user); |
1656 | 1655 | $GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository(); |
1657 | 1656 | $GLOBALS['egw']->acl->__construct($user); |
1658 | - $this->grants = $GLOBALS['egw']->acl->get_grants('infolog',$this->group_owners ? $this->group_owners : true); |
|
1659 | - $this->so = new infolog_so($this->grants); // so caches it's filters |
|
1657 | + $this->grants = $GLOBALS['egw']->acl->get_grants('infolog', $this->group_owners ? $this->group_owners : true); |
|
1658 | + $this->so = new infolog_so($this->grants); // so caches it's filters |
|
1660 | 1659 | |
1661 | 1660 | $notified_info_ids = array(); |
1662 | - foreach(array( |
|
1661 | + foreach (array( |
|
1663 | 1662 | 'notify_due_responsible' => 'open-responsible-enddate', |
1664 | 1663 | 'notify_due_delegated' => 'open-delegated-enddate', |
1665 | 1664 | 'notify_start_responsible' => 'open-responsible-date', |
@@ -1668,44 +1667,44 @@ discard block |
||
1668 | 1667 | { |
1669 | 1668 | if (!($pref_value = $GLOBALS['egw_info']['user']['preferences']['infolog'][$pref])) continue; |
1670 | 1669 | |
1671 | - $filter .= date('Y-m-d',time()+24*60*60*(int)$pref_value); |
|
1670 | + $filter .= date('Y-m-d', time() + 24 * 60 * 60 * (int)$pref_value); |
|
1672 | 1671 | //error_log(__METHOD__."() checking with filter '$filter' ($pref_value) for user $user ($email)"); |
1673 | 1672 | |
1674 | 1673 | $params = array('filter' => $filter, 'custom_fields' => true, 'subs' => true); |
1675 | - foreach($this->so->search($params) as $info) |
|
1674 | + foreach ($this->so->search($params) as $info) |
|
1676 | 1675 | { |
1677 | 1676 | // check if we already send a notification for that infolog entry, eg. starting and due on same day |
1678 | - if (in_array($info['info_id'],$notified_info_ids)) continue; |
|
1677 | + if (in_array($info['info_id'], $notified_info_ids)) continue; |
|
1679 | 1678 | |
1680 | 1679 | if (is_null($this->tracking) || $this->tracking->user != $user) |
1681 | 1680 | { |
1682 | 1681 | $this->tracking = new infolog_tracking($this); |
1683 | 1682 | } |
1684 | - switch($pref) |
|
1683 | + switch ($pref) |
|
1685 | 1684 | { |
1686 | 1685 | case 'notify_due_responsible': |
1687 | - $info['prefix'] = lang('Due %1',$this->enums['type'][$info['info_type']]); |
|
1688 | - $info['message'] = lang('%1 you are responsible for is due at %2',$this->enums['type'][$info['info_type']], |
|
1689 | - $this->tracking->datetime($info['info_enddate'],false)); |
|
1686 | + $info['prefix'] = lang('Due %1', $this->enums['type'][$info['info_type']]); |
|
1687 | + $info['message'] = lang('%1 you are responsible for is due at %2', $this->enums['type'][$info['info_type']], |
|
1688 | + $this->tracking->datetime($info['info_enddate'], false)); |
|
1690 | 1689 | break; |
1691 | 1690 | case 'notify_due_delegated': |
1692 | - $info['prefix'] = lang('Due %1',$this->enums['type'][$info['info_type']]); |
|
1693 | - $info['message'] = lang('%1 you delegated is due at %2',$this->enums['type'][$info['info_type']], |
|
1694 | - $this->tracking->datetime($info['info_enddate'],false)); |
|
1691 | + $info['prefix'] = lang('Due %1', $this->enums['type'][$info['info_type']]); |
|
1692 | + $info['message'] = lang('%1 you delegated is due at %2', $this->enums['type'][$info['info_type']], |
|
1693 | + $this->tracking->datetime($info['info_enddate'], false)); |
|
1695 | 1694 | break; |
1696 | 1695 | case 'notify_start_responsible': |
1697 | - $info['prefix'] = lang('Starting %1',$this->enums['type'][$info['info_type']]); |
|
1698 | - $info['message'] = lang('%1 you are responsible for is starting at %2',$this->enums['type'][$info['info_type']], |
|
1699 | - $this->tracking->datetime($info['info_startdate'],null)); |
|
1696 | + $info['prefix'] = lang('Starting %1', $this->enums['type'][$info['info_type']]); |
|
1697 | + $info['message'] = lang('%1 you are responsible for is starting at %2', $this->enums['type'][$info['info_type']], |
|
1698 | + $this->tracking->datetime($info['info_startdate'], null)); |
|
1700 | 1699 | break; |
1701 | 1700 | case 'notify_start_delegated': |
1702 | - $info['prefix'] = lang('Starting %1',$this->enums['type'][$info['info_type']]); |
|
1703 | - $info['message'] = lang('%1 you delegated is starting at %2',$this->enums['type'][$info['info_type']], |
|
1704 | - $this->tracking->datetime($info['info_startdate'],null)); |
|
1701 | + $info['prefix'] = lang('Starting %1', $this->enums['type'][$info['info_type']]); |
|
1702 | + $info['message'] = lang('%1 you delegated is starting at %2', $this->enums['type'][$info['info_type']], |
|
1703 | + $this->tracking->datetime($info['info_startdate'], null)); |
|
1705 | 1704 | break; |
1706 | 1705 | } |
1707 | 1706 | //error_log("notifiying $user($email) about $info[info_subject]: $info[message]"); |
1708 | - $this->tracking->send_notification($info,null,$email,$user,$pref); |
|
1707 | + $this->tracking->send_notification($info, null, $email, $user, $pref); |
|
1709 | 1708 | |
1710 | 1709 | $notified_info_ids[] = $info['info_id']; |
1711 | 1710 | } |
@@ -1768,7 +1767,7 @@ discard block |
||
1768 | 1767 | * @param string $x_infolog_status preserved original infolog status |
1769 | 1768 | * @return string |
1770 | 1769 | */ |
1771 | - function vtodo2status($_vtodo_status,$x_infolog_status=null) |
|
1770 | + function vtodo2status($_vtodo_status, $x_infolog_status = null) |
|
1772 | 1771 | { |
1773 | 1772 | $vtodo_status = strtoupper($_vtodo_status); |
1774 | 1773 | |
@@ -1792,7 +1791,7 @@ discard block |
||
1792 | 1791 | * @param array &$icons = null on return name of icons |
1793 | 1792 | * @return array value => (commaseparated) translations |
1794 | 1793 | */ |
1795 | - function get_status($type=null, array &$icons=null) |
|
1794 | + function get_status($type = null, array &$icons = null) |
|
1796 | 1795 | { |
1797 | 1796 | // if filtered by type, show only the stati of the filtered type |
1798 | 1797 | if ($type && isset($this->status[$type])) |
@@ -1802,16 +1801,16 @@ discard block |
||
1802 | 1801 | else // show all stati |
1803 | 1802 | { |
1804 | 1803 | $statis = $icons = array(); |
1805 | - foreach($this->status as $t => $stati) |
|
1804 | + foreach ($this->status as $t => $stati) |
|
1806 | 1805 | { |
1807 | 1806 | if ($t === 'defaults') continue; |
1808 | - foreach($stati as $val => $label) |
|
1807 | + foreach ($stati as $val => $label) |
|
1809 | 1808 | { |
1810 | 1809 | $statis[$val][$label] = lang($label); |
1811 | 1810 | if (!isset($icons[$val])) $icons[$val] = $label; |
1812 | 1811 | } |
1813 | 1812 | } |
1814 | - foreach($statis as $val => &$labels) |
|
1813 | + foreach ($statis as $val => &$labels) |
|
1815 | 1814 | { |
1816 | 1815 | $labels = implode(', ', $labels); |
1817 | 1816 | } |
@@ -1827,7 +1826,7 @@ discard block |
||
1827 | 1826 | */ |
1828 | 1827 | function activate($info) |
1829 | 1828 | { |
1830 | - switch((int)$info['info_percent']) |
|
1829 | + switch ((int)$info['info_percent']) |
|
1831 | 1830 | { |
1832 | 1831 | case 0: return 'not-started'; |
1833 | 1832 | case 100: return 'done'; |
@@ -1846,8 +1845,8 @@ discard block |
||
1846 | 1845 | #Horde::logMessage("getParentID($_guid)", __FILE__, __LINE__, PEAR_LOG_DEBUG); |
1847 | 1846 | |
1848 | 1847 | $parentID = False; |
1849 | - $myfilter = array('col_filter' => array('info_uid'=>$_guid)) ; |
|
1850 | - if ($_guid && ($found=$this->search($myfilter)) && ($uidmatch = array_shift($found))) |
|
1848 | + $myfilter = array('col_filter' => array('info_uid'=>$_guid)); |
|
1849 | + if ($_guid && ($found = $this->search($myfilter)) && ($uidmatch = array_shift($found))) |
|
1851 | 1850 | { |
1852 | 1851 | $parentID = $uidmatch['info_id']; |
1853 | 1852 | } |
@@ -1864,7 +1863,7 @@ discard block |
||
1864 | 1863 | * |
1865 | 1864 | * @return array of infolog_ids of matching entries |
1866 | 1865 | */ |
1867 | - function findInfo($infoData, $relax=false, $tzid=null) |
|
1866 | + function findInfo($infoData, $relax = false, $tzid = null) |
|
1868 | 1867 | { |
1869 | 1868 | $foundInfoLogs = array(); |
1870 | 1869 | $filter = array(); |
@@ -1872,7 +1871,7 @@ discard block |
||
1872 | 1871 | if ($this->log) |
1873 | 1872 | { |
1874 | 1873 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
1875 | - . '('. ($relax ? 'RELAX, ': 'EXACT, ') . $tzid . ')[InfoData]:' |
|
1874 | + . '('.($relax ? 'RELAX, ' : 'EXACT, ').$tzid.')[InfoData]:' |
|
1876 | 1875 | . array2string($infoData)); |
1877 | 1876 | } |
1878 | 1877 | |
@@ -1891,9 +1890,9 @@ discard block |
||
1891 | 1890 | if (!$relax && !empty($infoData['info_uid'])) |
1892 | 1891 | { |
1893 | 1892 | $filter = array('col_filter' => array('info_uid' => $infoData['info_uid'])); |
1894 | - foreach($this->so->search($filter) as $egwData) |
|
1893 | + foreach ($this->so->search($filter) as $egwData) |
|
1895 | 1894 | { |
1896 | - if (!$this->check_access($egwData,Acl::READ)) continue; |
|
1895 | + if (!$this->check_access($egwData, Acl::READ)) continue; |
|
1897 | 1896 | $foundInfoLogs[$egwData['info_id']] = $egwData['info_id']; |
1898 | 1897 | } |
1899 | 1898 | return $foundInfoLogs; |
@@ -1921,7 +1920,7 @@ discard block |
||
1921 | 1920 | $text = ''; |
1922 | 1921 | foreach ($matches as $chunk) |
1923 | 1922 | { |
1924 | - if (strlen($text) < strlen($chunk[0])) |
|
1923 | + if (strlen($text) < strlen($chunk[0])) |
|
1925 | 1924 | { |
1926 | 1925 | $text = $chunk[0]; |
1927 | 1926 | } |
@@ -1945,7 +1944,7 @@ discard block |
||
1945 | 1944 | |
1946 | 1945 | foreach ($this->so->search($filter) as $itemID => $egwData) |
1947 | 1946 | { |
1948 | - if (!$this->check_access($egwData,Acl::READ)) continue; |
|
1947 | + if (!$this->check_access($egwData, Acl::READ)) continue; |
|
1949 | 1948 | |
1950 | 1949 | switch ($infoData['info_type']) |
1951 | 1950 | { |
@@ -1962,7 +1961,7 @@ discard block |
||
1962 | 1961 | { |
1963 | 1962 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
1964 | 1963 | . '()[location mismatch]: ' |
1965 | - . $infoData['info_location'] . ' <> ' . $egwData['info_location']); |
|
1964 | + . $infoData['info_location'].' <> '.$egwData['info_location']); |
|
1966 | 1965 | } |
1967 | 1966 | continue; |
1968 | 1967 | } |
@@ -1979,7 +1978,7 @@ discard block |
||
1979 | 1978 | { |
1980 | 1979 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
1981 | 1980 | . '()[description mismatch]: ' |
1982 | - . $infoData['info_des'] . ' <> ' . $egwData['info_des']); |
|
1981 | + . $infoData['info_des'].' <> '.$egwData['info_des']); |
|
1983 | 1982 | } |
1984 | 1983 | continue; |
1985 | 1984 | } |
@@ -1993,7 +1992,7 @@ discard block |
||
1993 | 1992 | if ($this->log) |
1994 | 1993 | { |
1995 | 1994 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
1996 | - . '()[FOUND]:' . array2string($foundInfoLogs)); |
|
1995 | + . '()[FOUND]:'.array2string($foundInfoLogs)); |
|
1997 | 1996 | } |
1998 | 1997 | return $foundInfoLogs; |
1999 | 1998 | } |
@@ -2018,7 +2017,7 @@ discard block |
||
2018 | 2017 | // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
2019 | 2018 | foreach ($this->so->search($filter) as $itemID => $egwData) |
2020 | 2019 | { |
2021 | - if (!$this->check_access($egwData,Acl::READ)) continue; |
|
2020 | + if (!$this->check_access($egwData, Acl::READ)) continue; |
|
2022 | 2021 | // Horde::logMessage("findVTODO Trying\n" |
2023 | 2022 | // . print_r($egwData, true), |
2024 | 2023 | // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
@@ -2030,7 +2029,7 @@ discard block |
||
2030 | 2029 | { |
2031 | 2030 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2032 | 2031 | . '()[category mismatch]: ' |
2033 | - . $infoData['info_cat'] . ' <> ' . $egwData['info_cat']); |
|
2032 | + . $infoData['info_cat'].' <> '.$egwData['info_cat']); |
|
2034 | 2033 | } |
2035 | 2034 | continue; |
2036 | 2035 | } |
@@ -2040,15 +2039,15 @@ discard block |
||
2040 | 2039 | if (isset($egwData['info_startdate']) && $egwData['info_startdate']) |
2041 | 2040 | { |
2042 | 2041 | // We compare the date only |
2043 | - $taskTime = new Api\DateTime($infoData['info_startdate'],Api\DateTime::$server_timezone); |
|
2044 | - $egwTime = new Api\DateTime($egwData['info_startdate'],Api\DateTime::$server_timezone); |
|
2042 | + $taskTime = new Api\DateTime($infoData['info_startdate'], Api\DateTime::$server_timezone); |
|
2043 | + $egwTime = new Api\DateTime($egwData['info_startdate'], Api\DateTime::$server_timezone); |
|
2045 | 2044 | if ($taskTime->format('Ymd') != $egwTime->format('Ymd')) |
2046 | 2045 | { |
2047 | 2046 | if ($this->log) |
2048 | 2047 | { |
2049 | 2048 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2050 | 2049 | . '()[start mismatch]: ' |
2051 | - . $taskTime->format('Ymd') . ' <> ' . $egwTime->format('Ymd')); |
|
2050 | + . $taskTime->format('Ymd').' <> '.$egwTime->format('Ymd')); |
|
2052 | 2051 | } |
2053 | 2052 | continue; |
2054 | 2053 | } |
@@ -2075,7 +2074,7 @@ discard block |
||
2075 | 2074 | { |
2076 | 2075 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2077 | 2076 | . '()[status mismatch]: ' |
2078 | - . $infoData['info_status'] . ' <> ' . $egwData['info_status']); |
|
2077 | + . $infoData['info_status'].' <> '.$egwData['info_status']); |
|
2079 | 2078 | } |
2080 | 2079 | continue; |
2081 | 2080 | } |
@@ -2085,15 +2084,15 @@ discard block |
||
2085 | 2084 | if (isset($egwData['info_enddate']) && $egwData['info_enddate']) |
2086 | 2085 | { |
2087 | 2086 | // We compare the date only |
2088 | - $taskTime = new Api\DateTime($infoData['info_enddate'],Api\DateTime::$server_timezone); |
|
2089 | - $egwTime = new Api\DateTime($egwData['info_enddate'],Api\DateTime::$server_timezone); |
|
2087 | + $taskTime = new Api\DateTime($infoData['info_enddate'], Api\DateTime::$server_timezone); |
|
2088 | + $egwTime = new Api\DateTime($egwData['info_enddate'], Api\DateTime::$server_timezone); |
|
2090 | 2089 | if ($taskTime->format('Ymd') != $egwTime->format('Ymd')) |
2091 | 2090 | { |
2092 | 2091 | if ($this->log) |
2093 | 2092 | { |
2094 | 2093 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2095 | 2094 | . '()[DUE mismatch]: ' |
2096 | - . $taskTime->format('Ymd') . ' <> ' . $egwTime->format('Ymd')); |
|
2095 | + . $taskTime->format('Ymd').' <> '.$egwTime->format('Ymd')); |
|
2097 | 2096 | } |
2098 | 2097 | continue; |
2099 | 2098 | } |
@@ -2114,15 +2113,15 @@ discard block |
||
2114 | 2113 | if (isset($egwData['info_datecompleted']) && $egwData['info_datecompleted']) |
2115 | 2114 | { |
2116 | 2115 | // We compare the date only |
2117 | - $taskTime = new Api\DateTime($infoData['info_datecompleted'],Api\DateTime::$server_timezone); |
|
2118 | - $egwTime = new Api\DateTime($egwData['info_datecompleted'],Api\DateTime::$server_timezone); |
|
2116 | + $taskTime = new Api\DateTime($infoData['info_datecompleted'], Api\DateTime::$server_timezone); |
|
2117 | + $egwTime = new Api\DateTime($egwData['info_datecompleted'], Api\DateTime::$server_timezone); |
|
2119 | 2118 | if ($taskTime->format('Ymd') != $egwTime->format('Ymd')) |
2120 | 2119 | { |
2121 | 2120 | if ($this->log) |
2122 | 2121 | { |
2123 | 2122 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2124 | 2123 | . '()[completed mismatch]: ' |
2125 | - . $taskTime->format('Ymd') . ' <> ' . $egwTime->format('Ymd')); |
|
2124 | + . $taskTime->format('Ymd').' <> '.$egwTime->format('Ymd')); |
|
2126 | 2125 | } |
2127 | 2126 | continue; |
2128 | 2127 | } |
@@ -2152,7 +2151,7 @@ discard block |
||
2152 | 2151 | if ($this->log) |
2153 | 2152 | { |
2154 | 2153 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2155 | - . '()[FOUND]:' . array2string($foundInfoLogs)); |
|
2154 | + . '()[FOUND]:'.array2string($foundInfoLogs)); |
|
2156 | 2155 | } |
2157 | 2156 | return $foundInfoLogs; |
2158 | 2157 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @param array &$options |
142 | 142 | * @param array &$files |
143 | 143 | * @param int $user account_id |
144 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
144 | + * @return boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
145 | 145 | */ |
146 | 146 | function propfind($path,&$options,&$files,$user,$id='') |
147 | 147 | { |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @param string $path |
223 | 223 | * @param array $filter |
224 | - * @param array|boolean $start =false false=return all or array(start,num) |
|
224 | + * @param integer[] $start =false false=return all or array(start,num) |
|
225 | 225 | * @return array with "files" array with values for keys path and props |
226 | 226 | */ |
227 | 227 | function &propfind_callback($path,array $filter,$start=false) |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | * @param array &$options |
522 | 522 | * @param int $id |
523 | 523 | * @param int $user =null account_id |
524 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
524 | + * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
525 | 525 | */ |
526 | 526 | function get(&$options,$id,$user=null) |
527 | 527 | { |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | * @param int $id |
547 | 547 | * @param int $user =null account_id of owner, default null |
548 | 548 | * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook) |
549 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
549 | + * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
550 | 550 | */ |
551 | 551 | function put(&$options,$id,$user=null,$prefix=null) |
552 | 552 | { |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | * |
683 | 683 | * @param array &$options |
684 | 684 | * @param int $id |
685 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
685 | + * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
686 | 686 | */ |
687 | 687 | function delete(&$options,$id) |
688 | 688 | { |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | * etag currently uses the modifcation time (info_datemodified), 1.9.002 adds etag column, but it's not yet used! |
758 | 758 | * |
759 | 759 | * @param array|int $info array with infolog entry or info_id |
760 | - * @return string|boolean string with etag or false |
|
760 | + * @return false|string string with etag or false |
|
761 | 761 | */ |
762 | 762 | function get_etag($info) |
763 | 763 | { |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | if ($path == '/infolog/') |
114 | 114 | { |
115 | - $task_filter= 'own'; |
|
115 | + $task_filter = 'own'; |
|
116 | 116 | } |
117 | 117 | else |
118 | 118 | { |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | } |
123 | 123 | else |
124 | 124 | { |
125 | - $task_filter = 'user' . $user; |
|
125 | + $task_filter = 'user'.$user; |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param int $user account_id |
144 | 144 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
145 | 145 | */ |
146 | - function propfind($path,&$options,&$files,$user,$id='') |
|
146 | + function propfind($path, &$options, &$files, $user, $id = '') |
|
147 | 147 | { |
148 | 148 | // todo add a filter to limit how far back entries from the past get synced |
149 | 149 | $filter = $this->get_infolog_filter($path, $user); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | // enable time-range filter for tests via propfind / autoindex |
160 | 160 | //$filter[] = $sql = $this->_time_range_filter(array('end' => '20001231T000000Z')); |
161 | 161 | |
162 | - if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback |
|
162 | + if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback |
|
163 | 163 | |
164 | 164 | if ($this->debug > 1) |
165 | 165 | { |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | if (!($filter['calendar_data'] = $options['props'] == 'all' && |
172 | 172 | $options['root']['ns'] == Api\CalDAV::CALDAV) && is_array($options['props'])) |
173 | 173 | { |
174 | - foreach($options['props'] as $prop) |
|
174 | + foreach ($options['props'] as $prop) |
|
175 | 175 | { |
176 | 176 | if ($prop['name'] == 'calendar-data') |
177 | 177 | { |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | $this->sync_collection_token = null; |
193 | 193 | |
194 | - $filter['order'] = 'info_datemodified ASC'; // return oldest modifications first |
|
194 | + $filter['order'] = 'info_datemodified ASC'; // return oldest modifications first |
|
195 | 195 | $filter['sync-collection'] = true; |
196 | 196 | } |
197 | 197 | |
@@ -205,13 +205,13 @@ discard block |
||
205 | 205 | if ($options['root']['name'] == 'sync-collection' && $this->bo->total > $nresults) |
206 | 206 | { |
207 | 207 | --$this->sync_collection_token; |
208 | - $files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries |
|
208 | + $files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | else |
212 | 212 | { |
213 | 213 | // return iterator, calling ourself to return result in chunks |
214 | - $files['files'] = new Api\CalDAV\PropfindIterator($this,$path,$filter,$files['files']); |
|
214 | + $files['files'] = new Api\CalDAV\PropfindIterator($this, $path, $filter, $files['files']); |
|
215 | 215 | } |
216 | 216 | return true; |
217 | 217 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @param array|boolean $start =false false=return all or array(start,num) |
225 | 225 | * @return array with "files" array with values for keys path and props |
226 | 226 | */ |
227 | - function &propfind_callback($path,array $filter,$start=false) |
|
227 | + function &propfind_callback($path, array $filter, $start = false) |
|
228 | 228 | { |
229 | 229 | if ($this->debug) $starttime = microtime(true); |
230 | 230 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | 'filter' => $task_filter, |
252 | 252 | 'date_format' => 'server', |
253 | 253 | 'col_filter' => $filter, |
254 | - 'custom_fields' => true, // otherwise custom fields get NOT loaded! |
|
254 | + 'custom_fields' => true, // otherwise custom fields get NOT loaded! |
|
255 | 255 | ); |
256 | 256 | |
257 | 257 | if (!$calendar_data) |
@@ -273,10 +273,10 @@ discard block |
||
273 | 273 | |
274 | 274 | $files = array(); |
275 | 275 | // ToDo: add parameter to only return id & etag |
276 | - $tasks =& $this->bo->search($query); |
|
276 | + $tasks = & $this->bo->search($query); |
|
277 | 277 | if ($tasks && $offset == $query['start']) |
278 | 278 | { |
279 | - foreach($tasks as $task) |
|
279 | + foreach ($tasks as $task) |
|
280 | 280 | { |
281 | 281 | // remove task from requested multiget ids, to be able to report not found urls |
282 | 282 | if ($requested_multiget_ids && ($k = array_search($task[self::$path_attr], $requested_multiget_ids)) !== false) |
@@ -290,15 +290,15 @@ discard block |
||
290 | 290 | continue; |
291 | 291 | } |
292 | 292 | $props = array( |
293 | - 'getcontenttype' => $this->agent != 'kde' ? 'text/calendar; charset=utf-8; component=VTODO' : 'text/calendar', // Konqueror (3.5) dont understand it otherwise |
|
293 | + 'getcontenttype' => $this->agent != 'kde' ? 'text/calendar; charset=utf-8; component=VTODO' : 'text/calendar', // Konqueror (3.5) dont understand it otherwise |
|
294 | 294 | 'getlastmodified' => $task['info_datemodified'], |
295 | 295 | 'displayname' => $task['info_subject'], |
296 | 296 | ); |
297 | 297 | if ($calendar_data) |
298 | 298 | { |
299 | - $content = $handler->exportVTODO($task, '2.0', null); // no METHOD:PUBLISH for CalDAV |
|
299 | + $content = $handler->exportVTODO($task, '2.0', null); // no METHOD:PUBLISH for CalDAV |
|
300 | 300 | $props['getcontentlength'] = bytes($content); |
301 | - $props[] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data',$content); |
|
301 | + $props[] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-data', $content); |
|
302 | 302 | } |
303 | 303 | $files[] = $this->add_resource($path, $task, $props); |
304 | 304 | } |
@@ -306,13 +306,13 @@ discard block |
||
306 | 306 | // report not found multiget urls |
307 | 307 | if ($requested_multiget_ids) |
308 | 308 | { |
309 | - foreach($requested_multiget_ids as $id) |
|
309 | + foreach ($requested_multiget_ids as $id) |
|
310 | 310 | { |
311 | 311 | $files[] = array('path' => $path.$id.self::$path_extension); |
312 | 312 | } |
313 | 313 | } |
314 | 314 | // sync-collection report --> return modified of last contact as sync-token |
315 | - $sync_collection_report = $filter['sync-collection']; |
|
315 | + $sync_collection_report = $filter['sync-collection']; |
|
316 | 316 | if ($sync_collection_report) |
317 | 317 | { |
318 | 318 | $this->sync_collection_token = $task['date_modified']; |
@@ -338,18 +338,18 @@ discard block |
||
338 | 338 | * @param int &$nresult on return limit for number or results or unchanged/null |
339 | 339 | * @return boolean true if filter could be processed |
340 | 340 | */ |
341 | - function _report_filters($options,&$cal_filters,$id, &$nresults) |
|
341 | + function _report_filters($options, &$cal_filters, $id, &$nresults) |
|
342 | 342 | { |
343 | 343 | if ($options['filters']) |
344 | 344 | { |
345 | - foreach($options['filters'] as $filter) |
|
345 | + foreach ($options['filters'] as $filter) |
|
346 | 346 | { |
347 | - switch($filter['name']) |
|
347 | + switch ($filter['name']) |
|
348 | 348 | { |
349 | 349 | case 'comp-filter': |
350 | 350 | if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'"); |
351 | 351 | |
352 | - switch($filter['attrs']['name']) |
|
352 | + switch ($filter['attrs']['name']) |
|
353 | 353 | { |
354 | 354 | case 'VTODO': |
355 | 355 | case 'VCALENDAR': |
@@ -392,9 +392,9 @@ discard block |
||
392 | 392 | <B:nresults>10</B:nresults> |
393 | 393 | </B:limit> |
394 | 394 | */ |
395 | - foreach((array)$options['other'] as $option) |
|
395 | + foreach ((array)$options['other'] as $option) |
|
396 | 396 | { |
397 | - switch($option['name']) |
|
397 | + switch ($option['name']) |
|
398 | 398 | { |
399 | 399 | case 'nresults': |
400 | 400 | $nresults = (int)$option['data']; |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | case 'limit': |
404 | 404 | break; |
405 | 405 | case 'href': |
406 | - break; // from addressbook-multiget, handled below |
|
406 | + break; // from addressbook-multiget, handled below |
|
407 | 407 | // rfc 6578 sync-report |
408 | 408 | case 'sync-token': |
409 | 409 | if (!empty($option['data'])) |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | $parts = explode('/', $option['data']); |
412 | 412 | $sync_token = array_pop($parts); |
413 | 413 | $cal_filters[] = 'info_datemodified>'.(int)$sync_token; |
414 | - $cal_filters['filter'] .= '+deleted'; // to return deleted entries too |
|
414 | + $cal_filters['filter'] .= '+deleted'; // to return deleted entries too |
|
415 | 415 | } |
416 | 416 | break; |
417 | 417 | case 'sync-level': |
@@ -433,24 +433,24 @@ discard block |
||
433 | 433 | if ($id) |
434 | 434 | { |
435 | 435 | $cal_filters[self::$path_attr] = self::$path_extension ? |
436 | - basename($id,self::$path_extension) : $id; |
|
436 | + basename($id, self::$path_extension) : $id; |
|
437 | 437 | } |
438 | 438 | else // fetch all given url's |
439 | 439 | { |
440 | - foreach($options['other'] as $option) |
|
440 | + foreach ($options['other'] as $option) |
|
441 | 441 | { |
442 | 442 | if ($option['name'] == 'href') |
443 | 443 | { |
444 | - $parts = explode('/',$option['data']); |
|
444 | + $parts = explode('/', $option['data']); |
|
445 | 445 | if (($id = basename(urldecode(array_pop($parts))))) |
446 | 446 | { |
447 | 447 | $cal_filters[self::$path_attr][] = self::$path_extension ? |
448 | - basename($id,self::$path_extension) : $id; |
|
448 | + basename($id, self::$path_extension) : $id; |
|
449 | 449 | } |
450 | 450 | } |
451 | 451 | } |
452 | 452 | } |
453 | - if ($this->debug > 1) error_log(__METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids)); |
|
453 | + if ($this->debug > 1) error_log(__METHOD__."($options[path],...,$id) calendar-multiget: ids=".implode(',', $ids)); |
|
454 | 454 | } |
455 | 455 | return true; |
456 | 456 | } |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | elseif (empty($attrs['start'])) |
479 | 479 | { |
480 | 480 | $this->caldav->log(__METHOD__.'('.array2string($attrs).') minimum one of start or end is required!'); |
481 | - return '1'; // to not give sql error, but simply not filter out anything |
|
481 | + return '1'; // to not give sql error, but simply not filter out anything |
|
482 | 482 | } |
483 | 483 | // we dont need to care for DURATION line in rfc4791#section-9.9, as we always put that in DUE/info_enddate |
484 | 484 | |
@@ -508,10 +508,10 @@ discard block |
||
508 | 508 | "info_datecompleted > 0".(isset($start) ? " AND ($start <= info_datecompleted OR $start <= info_created)" : ''). |
509 | 509 | (isset($end) ? " AND (info_datecompleted <= $end OR info_created <= $end)" : '').' OR '. |
510 | 510 | // we have no completed date, but always a created date |
511 | - "NOT info_datecompleted > 0". (isset($end) ? " AND info_created < $end" : ''). |
|
511 | + "NOT info_datecompleted > 0".(isset($end) ? " AND info_created < $end" : ''). |
|
512 | 512 | ')'; |
513 | 513 | $sql = '('.implode(' OR ', $to_or).')'; |
514 | - if ($this->debug > 1) error_log(__FILE__ . __METHOD__.'('.array2string($attrs).") time-range=$attrs[start]-$attrs[end] --> $sql"); |
|
514 | + if ($this->debug > 1) error_log(__FILE__.__METHOD__.'('.array2string($attrs).") time-range=$attrs[start]-$attrs[end] --> $sql"); |
|
515 | 515 | return $sql; |
516 | 516 | } |
517 | 517 | |
@@ -523,16 +523,16 @@ discard block |
||
523 | 523 | * @param int $user =null account_id |
524 | 524 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
525 | 525 | */ |
526 | - function get(&$options,$id,$user=null) |
|
526 | + function get(&$options, $id, $user = null) |
|
527 | 527 | { |
528 | - unset($user); // not used, but required by function signature |
|
528 | + unset($user); // not used, but required by function signature |
|
529 | 529 | |
530 | - if (!is_array($task = $this->_common_get_put_delete('GET',$options,$id))) |
|
530 | + if (!is_array($task = $this->_common_get_put_delete('GET', $options, $id))) |
|
531 | 531 | { |
532 | 532 | return $task; |
533 | 533 | } |
534 | 534 | $handler = $this->_get_handler(); |
535 | - $options['data'] = $handler->exportVTODO($task, '2.0', null); // no METHOD:PUBLISH for CalDAV |
|
535 | + $options['data'] = $handler->exportVTODO($task, '2.0', null); // no METHOD:PUBLISH for CalDAV |
|
536 | 536 | $options['mimetype'] = 'text/calendar; charset=utf-8'; |
537 | 537 | header('Content-Encoding: identity'); |
538 | 538 | header('ETag: "'.$this->get_etag($task).'"'); |
@@ -548,13 +548,13 @@ discard block |
||
548 | 548 | * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook) |
549 | 549 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
550 | 550 | */ |
551 | - function put(&$options,$id,$user=null,$prefix=null) |
|
551 | + function put(&$options, $id, $user = null, $prefix = null) |
|
552 | 552 | { |
553 | - unset($prefix); // not used, but required by function signature |
|
553 | + unset($prefix); // not used, but required by function signature |
|
554 | 554 | |
555 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
555 | + if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options, true)); |
|
556 | 556 | |
557 | - $oldTask = $this->_common_get_put_delete('PUT',$options,$id); |
|
557 | + $oldTask = $this->_common_get_put_delete('PUT', $options, $id); |
|
558 | 558 | if (!is_null($oldTask) && !is_array($oldTask)) |
559 | 559 | { |
560 | 560 | return $oldTask; |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | * @param array $oldTask =null |
620 | 620 | * @return array modified task data |
621 | 621 | */ |
622 | - public function cat_action(array $task, $oldTask=null) |
|
622 | + public function cat_action(array $task, $oldTask = null) |
|
623 | 623 | { |
624 | 624 | $action = $GLOBALS['egw_info']['user']['preferences']['groupdav']['infolog-cat-action']; |
625 | 625 | |
@@ -650,13 +650,13 @@ discard block |
||
650 | 650 | { |
651 | 651 | unset($task['info_responsible'][$key]); |
652 | 652 | } |
653 | - switch($action) |
|
653 | + switch ($action) |
|
654 | 654 | { |
655 | 655 | case 'set': |
656 | 656 | $task['info_responsible'] = array(); |
657 | 657 | // fall through |
658 | 658 | case 'set-user': |
659 | - foreach($task['info_responsible'] as $key => $account_id) |
|
659 | + foreach ($task['info_responsible'] as $key => $account_id) |
|
660 | 660 | { |
661 | 661 | if ($GLOBALS['egw']->accounts->get_type($account_id) == 'u') |
662 | 662 | { |
@@ -684,9 +684,9 @@ discard block |
||
684 | 684 | * @param int $id |
685 | 685 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
686 | 686 | */ |
687 | - function delete(&$options,$id) |
|
687 | + function delete(&$options, $id) |
|
688 | 688 | { |
689 | - if (!is_array($task = $this->_common_get_put_delete('DELETE',$options,$id))) |
|
689 | + if (!is_array($task = $this->_common_get_put_delete('DELETE', $options, $id))) |
|
690 | 690 | { |
691 | 691 | return $task; |
692 | 692 | } |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | */ |
705 | 705 | function read($id) |
706 | 706 | { |
707 | - return $this->bo->read(array(self::$path_attr => $id, "info_status!='deleted'"),false,'server'); |
|
707 | + return $this->bo->read(array(self::$path_attr => $id, "info_status!='deleted'"), false, 'server'); |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | /** |
@@ -727,15 +727,15 @@ discard block |
||
727 | 727 | * @param array|int $task task-array or id |
728 | 728 | * @return boolean null if entry does not exist, false if no access, true if access permitted |
729 | 729 | */ |
730 | - function check_access($acl,$task) |
|
730 | + function check_access($acl, $task) |
|
731 | 731 | { |
732 | 732 | if (is_null($task)) return true; |
733 | 733 | |
734 | - $access = $this->bo->check_access($task,$acl); |
|
734 | + $access = $this->bo->check_access($task, $acl); |
|
735 | 735 | |
736 | 736 | if (!$access && $acl == Acl::EDIT && $this->bo->is_responsible($task)) |
737 | 737 | { |
738 | - $access = true; // access limited to $this->bo->responsible_edit fields (handled in infolog_bo::write()) |
|
738 | + $access = true; // access limited to $this->bo->responsible_edit fields (handled in infolog_bo::write()) |
|
739 | 739 | } |
740 | 740 | if ($this->debug > 1) error_log(__METHOD__."($acl, ".array2string($task).') returning '.array2string($access)); |
741 | 741 | return $access; |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | * |
747 | 747 | * @return string |
748 | 748 | */ |
749 | - public function getctag($path,$user) |
|
749 | + public function getctag($path, $user) |
|
750 | 750 | { |
751 | 751 | return $this->bo->getctag($this->get_infolog_filter($path, $user)); |
752 | 752 | } |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | { |
764 | 764 | if (!is_array($info)) |
765 | 765 | { |
766 | - $info = $this->bo->read($info,true,'server'); |
|
766 | + $info = $this->bo->read($info, true, 'server'); |
|
767 | 767 | } |
768 | 768 | if (!is_array($info) || !isset($info['info_id']) || !isset($info['info_datemodified'])) |
769 | 769 | { |
@@ -781,39 +781,39 @@ discard block |
||
781 | 781 | * @param int $user =null account_id of owner of collection |
782 | 782 | * @return array |
783 | 783 | */ |
784 | - public function extra_properties(array $props, $displayname, $base_uri=null,$user=null) |
|
784 | + public function extra_properties(array $props, $displayname, $base_uri = null, $user = null) |
|
785 | 785 | { |
786 | - unset($base_uri); // not used, but required by function signature |
|
786 | + unset($base_uri); // not used, but required by function signature |
|
787 | 787 | |
788 | 788 | // calendar description |
789 | - $displayname = Api\Translation::convert(lang('Tasks of'),Api\Translation::charset(),'utf-8').' '.$displayname; |
|
790 | - $props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-description',$displayname); |
|
789 | + $displayname = Api\Translation::convert(lang('Tasks of'), Api\Translation::charset(), 'utf-8').' '.$displayname; |
|
790 | + $props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-description', $displayname); |
|
791 | 791 | // supported components, currently only VEVENT |
792 | - $props['supported-calendar-component-set'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'supported-calendar-component-set',array( |
|
793 | - Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VCALENDAR')), |
|
794 | - Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VTODO')), |
|
792 | + $props['supported-calendar-component-set'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'supported-calendar-component-set', array( |
|
793 | + Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'comp', array('name' => 'VCALENDAR')), |
|
794 | + Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'comp', array('name' => 'VTODO')), |
|
795 | 795 | )); |
796 | 796 | // supported reports |
797 | 797 | $props['supported-report-set'] = array( |
798 | - 'calendar-query' => Api\CalDAV::mkprop('supported-report',array( |
|
799 | - Api\CalDAV::mkprop('report',array( |
|
800 | - Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-query',''))))), |
|
801 | - 'calendar-multiget' => Api\CalDAV::mkprop('supported-report',array( |
|
802 | - Api\CalDAV::mkprop('report',array( |
|
803 | - Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-multiget',''))))), |
|
798 | + 'calendar-query' => Api\CalDAV::mkprop('supported-report', array( |
|
799 | + Api\CalDAV::mkprop('report', array( |
|
800 | + Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-query', ''))))), |
|
801 | + 'calendar-multiget' => Api\CalDAV::mkprop('supported-report', array( |
|
802 | + Api\CalDAV::mkprop('report', array( |
|
803 | + Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-multiget', ''))))), |
|
804 | 804 | ); |
805 | 805 | // only advertice rfc 6578 sync-collection report, if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted |
806 | 806 | $config = Api\Config::read('infolog'); |
807 | 807 | if ($config['history']) |
808 | 808 | { |
809 | - $props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report',array( |
|
810 | - Api\CalDAV::mkprop('report',array( |
|
811 | - Api\CalDAV::mkprop('sync-collection',''))))); |
|
809 | + $props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report', array( |
|
810 | + Api\CalDAV::mkprop('report', array( |
|
811 | + Api\CalDAV::mkprop('sync-collection', ''))))); |
|
812 | 812 | } |
813 | 813 | // get timezone of calendar |
814 | 814 | if ($this->caldav->prop_requested('calendar-timezone')) |
815 | 815 | { |
816 | - $props['calendar-timezone'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-timezone', |
|
816 | + $props['calendar-timezone'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-timezone', |
|
817 | 817 | calendar_timezones::user_timezone($user)); |
818 | 818 | } |
819 | 819 | return $props; |
@@ -827,8 +827,8 @@ discard block |
||
827 | 827 | private function _get_handler() |
828 | 828 | { |
829 | 829 | $handler = new infolog_ical(); |
830 | - $handler->tzid = false; // as we read server-time timestamps (!= null=user-time), exports UTC times |
|
831 | - $handler->setSupportedFields('GroupDAV',$this->agent); |
|
830 | + $handler->tzid = false; // as we read server-time timestamps (!= null=user-time), exports UTC times |
|
831 | + $handler->setSupportedFields('GroupDAV', $this->agent); |
|
832 | 832 | |
833 | 833 | return $handler; |
834 | 834 | } |
@@ -91,7 +91,10 @@ discard block |
||
91 | 91 | } |
92 | 92 | else |
93 | 93 | { |
94 | - if (!is_array($info)) $info = $this->bo->read($info); |
|
94 | + if (!is_array($info)) |
|
95 | + { |
|
96 | + $info = $this->bo->read($info); |
|
97 | + } |
|
95 | 98 | $name = $info[self::$path_attr]; |
96 | 99 | } |
97 | 100 | return $name.self::$path_extension; |
@@ -159,7 +162,11 @@ discard block |
||
159 | 162 | // enable time-range filter for tests via propfind / autoindex |
160 | 163 | //$filter[] = $sql = $this->_time_range_filter(array('end' => '20001231T000000Z')); |
161 | 164 | |
162 | - if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback |
|
165 | + if ($id) |
|
166 | + { |
|
167 | + $path = dirname($path).'/'; |
|
168 | + } |
|
169 | + // caldav_name get's added anyway in the callback |
|
163 | 170 | |
164 | 171 | if ($this->debug > 1) |
165 | 172 | { |
@@ -226,7 +233,10 @@ discard block |
||
226 | 233 | */ |
227 | 234 | function &propfind_callback($path,array $filter,$start=false) |
228 | 235 | { |
229 | - if ($this->debug) $starttime = microtime(true); |
|
236 | + if ($this->debug) |
|
237 | + { |
|
238 | + $starttime = microtime(true); |
|
239 | + } |
|
230 | 240 | |
231 | 241 | if (($calendar_data = $filter['calendar_data'])) |
232 | 242 | { |
@@ -242,7 +252,10 @@ discard block |
||
242 | 252 | if (preg_match('/^([a-z0-9_]+)( DESC| ASC)?$/i', $filter['order'], $matches)) |
243 | 253 | { |
244 | 254 | $order = $matches[1]; |
245 | - if ($matches[2]) $sort = $matches[2]; |
|
255 | + if ($matches[2]) |
|
256 | + { |
|
257 | + $sort = $matches[2]; |
|
258 | + } |
|
246 | 259 | unset($filter['order']); |
247 | 260 | } |
248 | 261 | $query = array( |
@@ -325,7 +338,10 @@ discard block |
||
325 | 338 | --$this->sync_collection_token; |
326 | 339 | } |
327 | 340 | } |
328 | - if ($this->debug) error_log(__METHOD__."($path) took ".(microtime(true) - $starttime).' to return '.count($files).' items'); |
|
341 | + if ($this->debug) |
|
342 | + { |
|
343 | + error_log(__METHOD__."($path) took ".(microtime(true) - $starttime).' to return '.count($files).' items'); |
|
344 | + } |
|
329 | 345 | return $files; |
330 | 346 | } |
331 | 347 | |
@@ -347,7 +363,10 @@ discard block |
||
347 | 363 | switch($filter['name']) |
348 | 364 | { |
349 | 365 | case 'comp-filter': |
350 | - if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'"); |
|
366 | + if ($this->debug > 1) |
|
367 | + { |
|
368 | + error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'"); |
|
369 | + } |
|
351 | 370 | |
352 | 371 | switch($filter['attrs']['name']) |
353 | 372 | { |
@@ -359,14 +378,23 @@ discard block |
||
359 | 378 | } |
360 | 379 | break; |
361 | 380 | case 'prop-filter': |
362 | - if ($this->debug > 1) error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'"); |
|
381 | + if ($this->debug > 1) |
|
382 | + { |
|
383 | + error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'"); |
|
384 | + } |
|
363 | 385 | $prop_filter = $filter['attrs']['name']; |
364 | 386 | break; |
365 | 387 | case 'text-match': |
366 | - if ($this->debug > 1) error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'"); |
|
388 | + if ($this->debug > 1) |
|
389 | + { |
|
390 | + error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'"); |
|
391 | + } |
|
367 | 392 | if (!isset($this->filter_prop2infolog[strtoupper($prop_filter)])) |
368 | 393 | { |
369 | - if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored"); |
|
394 | + if ($this->debug) |
|
395 | + { |
|
396 | + error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored"); |
|
397 | + } |
|
370 | 398 | } |
371 | 399 | else |
372 | 400 | { |
@@ -375,13 +403,19 @@ discard block |
||
375 | 403 | unset($prop_filter); |
376 | 404 | break; |
377 | 405 | case 'param-filter': |
378 | - if ($this->debug) error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
|
406 | + if ($this->debug) |
|
407 | + { |
|
408 | + error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
|
409 | + } |
|
379 | 410 | break; |
380 | 411 | case 'time-range': |
381 | 412 | $cal_filters[] = $this->_time_range_filter($filter['attrs']); |
382 | 413 | break; |
383 | 414 | default: |
384 | - if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored"); |
|
415 | + if ($this->debug) |
|
416 | + { |
|
417 | + error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored"); |
|
418 | + } |
|
385 | 419 | break; |
386 | 420 | } |
387 | 421 | } |
@@ -450,7 +484,10 @@ discard block |
||
450 | 484 | } |
451 | 485 | } |
452 | 486 | } |
453 | - if ($this->debug > 1) error_log(__METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids)); |
|
487 | + if ($this->debug > 1) |
|
488 | + { |
|
489 | + error_log(__METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids)); |
|
490 | + } |
|
454 | 491 | } |
455 | 492 | return true; |
456 | 493 | } |
@@ -511,7 +548,10 @@ discard block |
||
511 | 548 | "NOT info_datecompleted > 0". (isset($end) ? " AND info_created < $end" : ''). |
512 | 549 | ')'; |
513 | 550 | $sql = '('.implode(' OR ', $to_or).')'; |
514 | - if ($this->debug > 1) error_log(__FILE__ . __METHOD__.'('.array2string($attrs).") time-range=$attrs[start]-$attrs[end] --> $sql"); |
|
551 | + if ($this->debug > 1) |
|
552 | + { |
|
553 | + error_log(__FILE__ . __METHOD__.'('.array2string($attrs).") time-range=$attrs[start]-$attrs[end] --> $sql"); |
|
554 | + } |
|
515 | 555 | return $sql; |
516 | 556 | } |
517 | 557 | |
@@ -552,7 +592,10 @@ discard block |
||
552 | 592 | { |
553 | 593 | unset($prefix); // not used, but required by function signature |
554 | 594 | |
555 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
595 | + if ($this->debug) |
|
596 | + { |
|
597 | + error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
598 | + } |
|
556 | 599 | |
557 | 600 | $oldTask = $this->_common_get_put_delete('PUT',$options,$id); |
558 | 601 | if (!is_null($oldTask) && !is_array($oldTask)) |
@@ -580,7 +623,10 @@ discard block |
||
580 | 623 | } |
581 | 624 | if (!($infoId = $handler->importVTODO($vTodo, $taskId, false, $user, null, $id, $callback_data))) |
582 | 625 | { |
583 | - if ($this->debug) error_log(__METHOD__."(,$id) import_vtodo($options[content]) returned false"); |
|
626 | + if ($this->debug) |
|
627 | + { |
|
628 | + error_log(__METHOD__."(,$id) import_vtodo($options[content]) returned false"); |
|
629 | + } |
|
584 | 630 | return '403 Forbidden'; |
585 | 631 | } |
586 | 632 | |
@@ -592,11 +638,13 @@ discard block |
||
592 | 638 | // send evtl. necessary respose headers: Location, etag, ... |
593 | 639 | // but only for new entries, as X-INFOLOG-STATUS get's not updated on client, if we confirm with an etag |
594 | 640 | if ($retval !== true) |
595 | - // POST with add-member query parameter |
|
641 | + { |
|
642 | + // POST with add-member query parameter |
|
596 | 643 | //$_SERVER['REQUEST_METHOD'] == 'POST' && isset($_GET['add-member']))) |
597 | 644 | { |
598 | 645 | $this->put_response_headers($infoId, $options['path'], $retval, self::$path_attr == 'caldav_name'); |
599 | 646 | } |
647 | + } |
|
600 | 648 | return $retval; |
601 | 649 | } |
602 | 650 | |
@@ -607,7 +655,10 @@ discard block |
||
607 | 655 | */ |
608 | 656 | public function update_tags($entry) |
609 | 657 | { |
610 | - if (!is_array($entry)) $entry = $this->read($entry); |
|
658 | + if (!is_array($entry)) |
|
659 | + { |
|
660 | + $entry = $this->read($entry); |
|
661 | + } |
|
611 | 662 | |
612 | 663 | $this->bo->write($entry, true); |
613 | 664 | } |
@@ -729,7 +780,10 @@ discard block |
||
729 | 780 | */ |
730 | 781 | function check_access($acl,$task) |
731 | 782 | { |
732 | - if (is_null($task)) return true; |
|
783 | + if (is_null($task)) |
|
784 | + { |
|
785 | + return true; |
|
786 | + } |
|
733 | 787 | |
734 | 788 | $access = $this->bo->check_access($task,$acl); |
735 | 789 | |
@@ -737,7 +791,10 @@ discard block |
||
737 | 791 | { |
738 | 792 | $access = true; // access limited to $this->bo->responsible_edit fields (handled in infolog_bo::write()) |
739 | 793 | } |
740 | - if ($this->debug > 1) error_log(__METHOD__."($acl, ".array2string($task).') returning '.array2string($access)); |
|
794 | + if ($this->debug > 1) |
|
795 | + { |
|
796 | + error_log(__METHOD__."($acl, ".array2string($task).') returning '.array2string($access)); |
|
797 | + } |
|
741 | 798 | return $access; |
742 | 799 | } |
743 | 800 |