Passed
Pull Request — master (#46)
by Neo
33:01
created
importexport/inc/class.importexport_iface_import_plugin.inc.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@
 block discarded – undo
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 );
Please login to merge, or discard this patch.
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -88,33 +88,33 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,8 @@
 block discarded – undo
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.
Please login to merge, or discard this patch.
importexport/inc/class.importexport_iface_import_record.inc.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 	 * cleanup
34 34
 	 *
35 35
 	 * @return 
36
-	 */
36
+	 void
37 37
 	public function __destruct( );
38 38
 
39 39
 	/**
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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.
Please login to merge, or discard this patch.
importexport/inc/class.importexport_import_csv.inc.php 4 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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 )) {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -264,7 +264,7 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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] = (strtolower($record[$name]) == strtolower(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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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(trim($subs[$sub_index]), $selects);
526
-					if(!$sub_key)
526
+					if (!$sub_key)
527 527
 					{
528
-						$sub_key = static::find_select_key(trim($subs[$sub_index]).','.trim($subs[$sub_index+1]), $selects);
529
-						if($sub_key) $sub_index++;
528
+						$sub_key = static::find_select_key(trim($subs[$sub_index]).','.trim($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
 
Please login to merge, or discard this patch.
Braces   +147 added lines, -62 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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] = (strtolower($record[$name]) == strtolower(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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
526 605
 					if(!$sub_key)
527 606
 					{
528 607
 						$sub_key = static::find_select_key(trim($subs[$sub_index]).','.trim($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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
importexport/inc/class.importexport_import_ui.inc.php 5 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -295,7 +295,7 @@
 block discarded – undo
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)
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -226,7 +226,7 @@
 block discarded – undo
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'),
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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(
Please login to merge, or discard this patch.
Braces   +77 added lines, -33 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 					}
@@ -109,7 +115,8 @@  discard block
 block discarded – undo
109 115
 						// Keep file
110 116
 						if($dst_file)
111 117
 						{
112
-							if($content['file']['name'] && copy($content['file']['tmp_name'],$dst_file)) {
118
+							if($content['file']['name'] && copy($content['file']['tmp_name'],$dst_file))
119
+							{
113 120
 								$preserve['file']['tmp_name'] = $dst_file;
114 121
 							}
115 122
 						}
@@ -162,33 +169,44 @@  discard block
 block discarded – undo
162 169
 						Framework::refresh_opener(lang('%1 records processed',$count), $appname, null,null,$appname);
163 170
 					}
164 171
 					$total_processed = 0;
165
-					foreach($plugin->get_results() as $action => $a_count) {
172
+					foreach($plugin->get_results() as $action => $a_count)
173
+					{
166 174
 						$this->message .= "<br />\n" . lang($action) . ": $a_count";
167 175
 						$total_processed += $a_count;
168 176
 					}
169
-					if(count($plugin->get_warnings())) {
177
+					if(count($plugin->get_warnings()))
178
+					{
170 179
 						$this->message .= "<br />\n".lang('Warnings').':';
171
-						foreach($plugin->get_warnings() as $record => $message) {
180
+						foreach($plugin->get_warnings() as $record => $message)
181
+						{
172 182
 							$this->message .= "<br />\n$record: $message";
173 183
 						}
174 184
 					}
175
-					if(count($plugin->get_errors())) {
185
+					if(count($plugin->get_errors()))
186
+					{
176 187
 						$this->message .= "<br />\n".lang('Problems during import:');
177
-						foreach($plugin->get_errors() as $record => $message) {
188
+						foreach($plugin->get_errors() as $record => $message)
189
+						{
178 190
 							$this->message .= "<br />\n$record: $message";
179 191
 						}
180
-						if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported');
192
+						if($count != $total_processed)
193
+						{
194
+							$this->message .= "<br />\n".lang('Some records may not have been imported');
195
+						}
181 196
 					}
182
-					if ($dst_file && $content['file']['tmp_name'] == $dst_file) {
197
+					if ($dst_file && $content['file']['tmp_name'] == $dst_file)
198
+					{
183 199
 						// Remove file
184 200
 						$cachefile->delete(Api\Cache::keys(Api\Cache::INSTANCE, 'importexport',
185 201
 							'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id'])));
186 202
 						unset($dst_file);
187 203
 					}
188 204
 
189
-				} catch (Api\Db\Exception $db_ex) {
205
+				}
206
+				catch (Api\Db\Exception $db_ex) {
190 207
 					$this->message .= lang('Database error');
191
-				} catch (Exception $e) {
208
+				}
209
+				catch (Exception $e) {
192 210
 					$this->message .= $e->getMessage();
193 211
 				}
194 212
 			}
@@ -220,7 +238,10 @@  discard block
 block discarded – undo
220 238
 			$data['message'] = $this->message;
221 239
 			Framework::includeJS('.','importexport','importexport');
222 240
 
223
-			if($_GET['appname']) $readonlys['appname'] = true;
241
+			if($_GET['appname'])
242
+			{
243
+				$readonlys['appname'] = true;
244
+			}
224 245
 
225 246
 			$template->exec('importexport.importexport_import_ui.import_dialog', $data, $sel_options, $readonlys, $preserve, 2);
226 247
 		}
@@ -228,7 +249,8 @@  discard block
 block discarded – undo
228 249
 		/**
229 250
 		* Get options for select boxes
230 251
 		*/
231
-		public static function get_select_options(Array $data) {
252
+		public static function get_select_options(Array $data)
253
+		{
232 254
 			$options = array(
233 255
 				'delimiter' => array(
234 256
 					''	=>	lang('From definition'),
@@ -244,17 +266,20 @@  discard block
 block discarded – undo
244 266
 			(array)$apps = importexport_helper_functions::get_apps('import');
245 267
 			$options['appname'] = array('' => lang('Select one')) + array_combine($apps,$apps);
246 268
 
247
-			if($data['appname']) {
269
+			if($data['appname'])
270
+			{
248 271
 				$options['definition'] = array();
249 272
 
250
-				if($data['file'] && !is_array($data['file'])) {
273
+				if($data['file'] && !is_array($data['file']))
274
+				{
251 275
 					$extension = substr($data['file'], -3);
252 276
 				}
253 277
 				$definitions = new importexport_definitions_bo(array(
254 278
 					'type' => 'import',
255 279
 					'application' => $data['appname']
256 280
 				));
257
-				foreach ((array)$definitions->get_definitions() as $identifier) {
281
+				foreach ((array)$definitions->get_definitions() as $identifier)
282
+				{
258 283
 					try
259 284
 					{
260 285
 						$definition = new importexport_definition($identifier);
@@ -264,7 +289,8 @@  discard block
 block discarded – undo
264 289
 						// Permission error
265 290
 						continue;
266 291
 					}
267
-					if ($title = $definition->get_title()) {
292
+					if ($title = $definition->get_title())
293
+					{
268 294
 						$options['definition'][$title] = $title;
269 295
 					}
270 296
 					unset($definition);
@@ -304,9 +330,15 @@  discard block
 block discarded – undo
304 330
 				for($row = 0; $row < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; $row++)
305 331
 				{
306 332
 					$row_data = $import_csv->get_record();
307
-					if($row_data === false) break;
333
+					if($row_data === false)
334
+					{
335
+						break;
336
+					}
308 337
 					$rows[$import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines'] ? 'h1' : $row] = $row_data;
309
-					if($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) $row--;
338
+					if($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines'])
339
+					{
340
+						$row--;
341
+					}
310 342
 				}
311 343
 				$preview = Api\Html::table($rows);
312 344
 				rewind($stream);
@@ -315,19 +347,26 @@  discard block
 block discarded – undo
315 347
 			{
316 348
 				$preview = lang('Preview not supported by %1', $plugin->get_name());
317 349
 			}
318
-			if(count($plugin->get_warnings())) {
350
+			if(count($plugin->get_warnings()))
351
+			{
319 352
 				$this->message .= "<br />\n".lang('Warnings').':';
320
-				foreach($plugin->get_warnings() as $record => $message) {
353
+				foreach($plugin->get_warnings() as $record => $message)
354
+				{
321 355
 					$this->message .= "\n$record: $message";
322 356
 				}
323 357
 				$this->message .= "<br />\n";
324 358
 			};
325
-			if(count($plugin->get_errors())) {
359
+			if(count($plugin->get_errors()))
360
+			{
326 361
 				$this->message .= "<br />\n".lang('Problems during import:');
327
-				foreach($plugin->get_errors() as $record => $message) {
362
+				foreach($plugin->get_errors() as $record => $message)
363
+				{
328 364
 					$this->message .= "<br />\n$record: $message";
329 365
 				}
330
-				if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported');
366
+				if($count != $total_processed)
367
+				{
368
+					$this->message .= "<br />\n".lang('Some records may not have been imported');
369
+				}
331 370
 				$this->message .= "<br />\n";
332 371
 			}
333 372
 			return '<div class="header">' . lang('Preview') . ' - ' . $plugin->get_name() . '</div>' . $preview;
@@ -352,10 +391,16 @@  discard block
 block discarded – undo
352 391
 			$message_count = count($message);
353 392
 
354 393
 			// Only CSV files
355
-			if(!$options['csv_fields']) return true;
394
+			if(!$options['csv_fields'])
395
+			{
396
+				return true;
397
+			}
356 398
 
357 399
 			// Can't check if definition has no header
358
-			if($options['num_header_lines'] == 0) return true;
400
+			if($options['num_header_lines'] == 0)
401
+			{
402
+				return true;
403
+			}
359 404
 
360 405
 			$preference = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
361 406
 			$charset = $options['charset'] == 'user' || !$options['charset'] ? $preference : $options['charset'];
@@ -399,8 +444,7 @@  discard block
 block discarded – undo
399 444
 				if($lang_defn == $lang_file ||
400 445
 					$lang_defn == mb_strtoupper($header) ||
401 446
 					$lang_file == mb_strtoupper($options['csv_fields'][$index])
402
-				)
403
-				{
447
+				) {
404 448
 					continue;
405 449
 				}
406 450
 
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 					}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 					// Check file encoding matches import
77 77
 					$sample = mb_substr(file_get_contents($content['file']['tmp_name'], false, null, 0, 2048), 1024);
78 78
 
79
-					if($appname == 'addressbook' && $definition_obj->plugin == 'addressbook_import_vcard')
79
+					if ($appname == 'addressbook' && $definition_obj->plugin == 'addressbook_import_vcard')
80 80
 					{
81 81
 						$preference = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset'];
82 82
 					}
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 					}
87 87
 					$required = $options['charset'] == 'user' || !$options['charset'] ? $preference : $options['charset'];
88 88
 					$encoding = Api\Translation::detect_encoding($sample, $required);
89
-					if($encoding && strtoupper($required) != strtoupper($encoding))
89
+					if ($encoding && strtoupper($required) != strtoupper($encoding))
90 90
 					{
91 91
 						$this->message = lang("Encoding mismatch.  Expected %1 file, you uploaded %2.<br />\n",
92 92
 							$required,
@@ -101,37 +101,37 @@  discard block
 block discarded – undo
101 101
 					$GLOBALS['egw_info']['flags']['currentapp'] = $appname;
102 102
 
103 103
 					// Destination if we need to hold the file
104
-					if($file)
104
+					if ($file)
105 105
 					{
106 106
 						$cachefile = new Api\Cache\Files(array());
107 107
 						$dst_file = $cachefile->filename(Api\Cache::keys(Api\Cache::INSTANCE, 'importexport',
108
-							'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id']), true),true);
108
+							'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id']), true), true);
109 109
 						// Keep file
110
-						if($dst_file)
110
+						if ($dst_file)
111 111
 						{
112
-							if($content['file']['name'] && copy($content['file']['tmp_name'],$dst_file)) {
112
+							if ($content['file']['name'] && copy($content['file']['tmp_name'], $dst_file)) {
113 113
 								$preserve['file']['tmp_name'] = $dst_file;
114 114
 							}
115 115
 						}
116 116
 
117 117
 						// Check on matching columns
118 118
 						$check_message = array();
119
-						if(!self::check_file($file, $definition_obj, $check_message, $dst_file))
119
+						if (!self::check_file($file, $definition_obj, $check_message, $dst_file))
120 120
 						{
121 121
 							// Set this so plugin doesn't do any data changes
122 122
 							$content['dry-run'] = true;
123 123
 							importexport_helper_functions::$dry_run = true;
124
-							$this->message .= '<b>' . lang('Import aborted').":</b><br />\n";
124
+							$this->message .= '<b>'.lang('Import aborted').":</b><br />\n";
125 125
 							$definition_obj->plugin_options = (array)$definition_obj->plugin_options + array('dry_run' => true);
126 126
 						}
127
-						if(count($check_message))
127
+						if (count($check_message))
128 128
 						{
129
-							$this->message .= implode($check_message, "<br />\n") . "<br />\n";
129
+							$this->message .= implode($check_message, "<br />\n")."<br />\n";
130 130
 						}
131
-						if($content['dry-run'])
131
+						if ($content['dry-run'])
132 132
 						{
133 133
 							$preview = $this->preview($plugin, $file, $definition_obj);
134
-							if(trim($this->message) == '')
134
+							if (trim($this->message) == '')
135 135
 							{
136 136
 								// Clear first, to prevent request from being collected if the result is the same
137 137
 								$template->setElementAttribute('preview', 'value', '');
@@ -150,34 +150,34 @@  discard block
 block discarded – undo
150 150
 						$this->message .= lang('please select file to import'."<br />\n");
151 151
 					}
152 152
 
153
-					if($content['dry-run'])
153
+					if ($content['dry-run'])
154 154
 					{
155
-						$this->message .= '<b>' . lang('test only').":</b><br />\n";
155
+						$this->message .= '<b>'.lang('test only').":</b><br />\n";
156 156
 					}
157 157
 					$this->message .= lang('%1 records processed', $count);
158 158
 
159 159
 					// Refresh opening window
160
-					if(!$content['dry-run'])
160
+					if (!$content['dry-run'])
161 161
 					{
162
-						Framework::refresh_opener(lang('%1 records processed',$count), $appname, null,null,$appname);
162
+						Framework::refresh_opener(lang('%1 records processed', $count), $appname, null, null, $appname);
163 163
 					}
164 164
 					$total_processed = 0;
165
-					foreach($plugin->get_results() as $action => $a_count) {
166
-						$this->message .= "<br />\n" . lang($action) . ": $a_count";
165
+					foreach ($plugin->get_results() as $action => $a_count) {
166
+						$this->message .= "<br />\n".lang($action).": $a_count";
167 167
 						$total_processed += $a_count;
168 168
 					}
169
-					if(count($plugin->get_warnings())) {
169
+					if (count($plugin->get_warnings())) {
170 170
 						$this->message .= "<br />\n".lang('Warnings').':';
171
-						foreach($plugin->get_warnings() as $record => $message) {
171
+						foreach ($plugin->get_warnings() as $record => $message) {
172 172
 							$this->message .= "<br />\n$record: $message";
173 173
 						}
174 174
 					}
175
-					if(count($plugin->get_errors())) {
175
+					if (count($plugin->get_errors())) {
176 176
 						$this->message .= "<br />\n".lang('Problems during import:');
177
-						foreach($plugin->get_errors() as $record => $message) {
177
+						foreach ($plugin->get_errors() as $record => $message) {
178 178
 							$this->message .= "<br />\n$record: $message";
179 179
 						}
180
-						if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported');
180
+						if ($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported');
181 181
 					}
182 182
 					if ($dst_file && $content['file']['tmp_name'] == $dst_file) {
183 183
 						// Remove file
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 					$this->message .= $e->getMessage();
193 193
 				}
194 194
 			}
195
-			elseif($content['cancel'])
195
+			elseif ($content['cancel'])
196 196
 			{
197 197
 				egw_framework::set_onload('window.close();');
198 198
 			}
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 				);
206 206
 			}
207 207
 
208
-			if(!array_key_exists('dry-run',$content))
208
+			if (!array_key_exists('dry-run', $content))
209 209
 			{
210 210
 				$data['dry-run'] = true;
211 211
 			}
@@ -213,14 +213,14 @@  discard block
 block discarded – undo
213 213
 			$data['appname'] = $preserve['appname'] = $appname ? $appname : ($definition_obj ? $definition_obj->application : '');
214 214
 			$data['definition'] = $definition;
215 215
 			$data['delimiter'] = $definition_obj->plugin_options['delimiter'];
216
-			$data['no_notifications'] = true;	// switch notifications off by default
216
+			$data['no_notifications'] = true; // switch notifications off by default
217 217
 
218 218
 			$sel_options = self::get_select_options($data);
219 219
 
220 220
 			$data['message'] = $this->message;
221
-			Framework::includeJS('.','importexport','importexport');
221
+			Framework::includeJS('.', 'importexport', 'importexport');
222 222
 
223
-			if($_GET['appname']) $readonlys['appname'] = true;
223
+			if ($_GET['appname']) $readonlys['appname'] = true;
224 224
 
225 225
 			$template->exec('importexport.importexport_import_ui.import_dialog', $data, $sel_options, $readonlys, $preserve, 2);
226 226
 		}
@@ -242,12 +242,12 @@  discard block
 block discarded – undo
242 242
 			);
243 243
 
244 244
 			(array)$apps = importexport_helper_functions::get_apps('import');
245
-			$options['appname'] = array('' => lang('Select one')) + array_combine($apps,$apps);
245
+			$options['appname'] = array('' => lang('Select one')) + array_combine($apps, $apps);
246 246
 
247
-			if($data['appname']) {
247
+			if ($data['appname']) {
248 248
 				$options['definition'] = array();
249 249
 
250
-				if($data['file'] && !is_array($data['file'])) {
250
+				if ($data['file'] && !is_array($data['file'])) {
251 251
 					$extension = substr($data['file'], -3);
252 252
 				}
253 253
 				$definitions = new importexport_definitions_bo(array(
@@ -287,26 +287,26 @@  discard block
 block discarded – undo
287 287
 		 */
288 288
 		protected function preview(importexport_iface_import_plugin &$plugin, &$stream, importexport_definition &$definition_obj)
289 289
 		{
290
-			if(method_exists($plugin, 'preview'))
290
+			if (method_exists($plugin, 'preview'))
291 291
 			{
292 292
 				$preview = $plugin->preview($stream, $definition_obj);
293 293
 			}
294
-			elseif($definition_obj->plugin_options['csv_fields'])
294
+			elseif ($definition_obj->plugin_options['csv_fields'])
295 295
 			{
296
-				$import_csv = new importexport_import_csv( $stream, array(
296
+				$import_csv = new importexport_import_csv($stream, array(
297 297
 					'fieldsep' => $definition_obj->plugin_options['fieldsep'],
298 298
 					'charset' => $definition_obj->plugin_options['charset'],
299 299
 				));
300 300
 				// set FieldMapping.
301 301
 				$import_csv->mapping = $definition_obj->plugin_options['field_mapping'];
302 302
 
303
-				$rows = array('h1'=>array(),'f1'=>array(),'.h1'=>'class=th');
304
-				for($row = 0; $row < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; $row++)
303
+				$rows = array('h1'=>array(), 'f1'=>array(), '.h1'=>'class=th');
304
+				for ($row = 0; $row < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; $row++)
305 305
 				{
306 306
 					$row_data = $import_csv->get_record();
307
-					if($row_data === false) break;
307
+					if ($row_data === false) break;
308 308
 					$rows[$import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines'] ? 'h1' : $row] = $row_data;
309
-					if($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) $row--;
309
+					if ($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) $row--;
310 310
 				}
311 311
 				$preview = Api\Html::table($rows);
312 312
 				rewind($stream);
@@ -315,22 +315,22 @@  discard block
 block discarded – undo
315 315
 			{
316 316
 				$preview = lang('Preview not supported by %1', $plugin->get_name());
317 317
 			}
318
-			if(count($plugin->get_warnings())) {
318
+			if (count($plugin->get_warnings())) {
319 319
 				$this->message .= "<br />\n".lang('Warnings').':';
320
-				foreach($plugin->get_warnings() as $record => $message) {
320
+				foreach ($plugin->get_warnings() as $record => $message) {
321 321
 					$this->message .= "\n$record: $message";
322 322
 				}
323 323
 				$this->message .= "<br />\n";
324 324
 			};
325
-			if(count($plugin->get_errors())) {
325
+			if (count($plugin->get_errors())) {
326 326
 				$this->message .= "<br />\n".lang('Problems during import:');
327
-				foreach($plugin->get_errors() as $record => $message) {
327
+				foreach ($plugin->get_errors() as $record => $message) {
328 328
 					$this->message .= "<br />\n$record: $message";
329 329
 				}
330
-				if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported');
330
+				if ($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported');
331 331
 				$this->message .= "<br />\n";
332 332
 			}
333
-			return '<div class="header">' . lang('Preview') . ' - ' . $plugin->get_name() . '</div>' . $preview;
333
+			return '<div class="header">'.lang('Preview').' - '.$plugin->get_name().'</div>'.$preview;
334 334
 		}
335 335
 
336 336
 		/**
@@ -348,24 +348,24 @@  discard block
 block discarded – undo
348 348
 		 */
349 349
 		public static function check_file(&$file, &$definition, &$message = array(), $dst_file = false)
350 350
 		{
351
-			$options =& $definition->plugin_options;
351
+			$options = & $definition->plugin_options;
352 352
 			$message_count = count($message);
353 353
 
354 354
 			// Only CSV files
355
-			if(!$options['csv_fields']) return true;
355
+			if (!$options['csv_fields']) return true;
356 356
 
357 357
 			// Can't check if definition has no header
358
-			if($options['num_header_lines'] == 0) return true;
358
+			if ($options['num_header_lines'] == 0) return true;
359 359
 
360 360
 			$preference = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
361 361
 			$charset = $options['charset'] == 'user' || !$options['charset'] ? $preference : $options['charset'];
362 362
 
363 363
 			$data = fgetcsv($file, 8000, $options['fieldsep']);
364 364
 			rewind($file);
365
-			$data = Api\Translation::convert($data,$charset);
365
+			$data = Api\Translation::convert($data, $charset);
366 366
 
367 367
 			$ok = true;
368
-			if(count($data) != count($options['csv_fields']) && max(array_keys($data)) != max(array_keys($options['csv_fields'])))
368
+			if (count($data) != count($options['csv_fields']) && max(array_keys($data)) != max(array_keys($options['csv_fields'])))
369 369
 			{
370 370
 				$message[] = lang("Column mismatch.  Expected %1 columns, your file has %2.",
371 371
 					count($options['field_mapping']),
@@ -373,9 +373,9 @@  discard block
 block discarded – undo
373 373
 				);
374 374
 				$ok = false;
375 375
 			}
376
-			foreach($data as $index => $header)
376
+			foreach ($data as $index => $header)
377 377
 			{
378
-				if($index < count($options['csv_fields']) && !$options['field_mapping'][$index])
378
+				if ($index < count($options['csv_fields']) && !$options['field_mapping'][$index])
379 379
 				{
380 380
 					// Skipped column in definition
381 381
 					continue;
@@ -387,16 +387,16 @@  discard block
 block discarded – undo
387 387
 				}
388 388
 
389 389
 				// Check for matching headers
390
-				if($options['csv_fields'][$index] == $header)
390
+				if ($options['csv_fields'][$index] == $header)
391 391
 				{
392 392
 					// Simple match
393 393
 					continue;
394 394
 				}
395 395
 				// Check column headers, taking into account different translations - make sure no *
396
-				$lang_defn = mb_strtoupper(Api\Translation::translate($options['csv_fields'][$index],false,''));
397
-				$lang_file = mb_strtoupper(Api\Translation::translate($header,false,''));
396
+				$lang_defn = mb_strtoupper(Api\Translation::translate($options['csv_fields'][$index], false, ''));
397
+				$lang_file = mb_strtoupper(Api\Translation::translate($header, false, ''));
398 398
 
399
-				if($lang_defn == $lang_file ||
399
+				if ($lang_defn == $lang_file ||
400 400
 					$lang_defn == mb_strtoupper($header) ||
401 401
 					$lang_file == mb_strtoupper($options['csv_fields'][$index])
402 402
 				)
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 				$file_message_id = Api\Translation::get_message_id($header, $definition->application);
409 409
 				$defn_message_id = Api\Translation::get_message_id($options['csv_fields'][$index], $definition->application);
410 410
 
411
-				if($file_message_id && $defn_message_id && $file_message_id == $defn_message_id)
411
+				if ($file_message_id && $defn_message_id && $file_message_id == $defn_message_id)
412 412
 				{
413 413
 					continue;
414 414
 				}
@@ -416,19 +416,19 @@  discard block
 block discarded – undo
416 416
 
417 417
 				// Problem
418 418
 				$message[] = lang("Column mismatch: %1 should be %2, not %3",
419
-					$index,$options['csv_fields'][$index], $header);
419
+					$index, $options['csv_fields'][$index], $header);
420 420
 				// But can still continue
421 421
 				// $ok = false;
422 422
 			}
423
-			if(!$ok || count($message) != $message_count)
423
+			if (!$ok || count($message) != $message_count)
424 424
 			{
425 425
 				// Add links for new / edit definition
426 426
 				$config = Api\Config::read('importexport');
427
-				if($GLOBALS['egw_info']['user']['apps']['admin'] || $config['users_create_definitions'])
427
+				if ($GLOBALS['egw_info']['user']['apps']['admin'] || $config['users_create_definitions'])
428 428
 				{
429 429
 					$actions = [];
430 430
 					// New definition
431
-					$add_link = Egw::link('/index.php',array(
431
+					$add_link = Egw::link('/index.php', array(
432 432
 						'menuaction' => 'importexport.importexport_definitions_ui.edit',
433 433
 						'application' => $definition->application,
434 434
 						'plugin' => $definition->plugin,
@@ -440,13 +440,13 @@  discard block
 block discarded – undo
440 440
 							'menuaction' => 'importexport.importexport_import_ui.import_dialog',
441 441
 							// Don't set appname, or user won't be able to select & see their new definition
442 442
 							//'appname' => $definition->application,
443
-						)) . "';
443
+						))."';
444 444
 						egw_openWindowCentered2('$add_link','_blank',500,500,'yes');
445 445
 					";
446 446
 					$actions[] = lang('Create a <a href="%1">new definition</a> for this file', $add_link);
447 447
 
448 448
 					// Edit selected definition, if allowed
449
-					if($definition->owner == $GLOBALS['egw_info']['user']['account_id'] ||
449
+					if ($definition->owner == $GLOBALS['egw_info']['user']['account_id'] ||
450 450
 						!$definition->owner && $GLOBALS['egw_info']['user']['apps']['admin'])
451 451
 					{
452 452
 						$edit_link = array(
@@ -455,20 +455,20 @@  discard block
 block discarded – undo
455 455
 							// Jump to file step
456 456
 							'step' => 'wizard_step21'
457 457
 						);
458
-						if($dst_file)
458
+						if ($dst_file)
459 459
 						{
460 460
 							// Still have uploaded file, jump there
461
-							Api\Cache::setSession($definition->application,'csvfile',$dst_file);
461
+							Api\Cache::setSession($definition->application, 'csvfile', $dst_file);
462 462
 							$edit_link['step'] = 'wizard_step30';
463 463
 						}
464
-						$edit_link = Egw::link('/index.php',$edit_link);
464
+						$edit_link = Egw::link('/index.php', $edit_link);
465 465
 						$edit_link = "javascript:egw_openWindowCentered2('$edit_link','_blank',500,500,'yes')";
466 466
 						$actions[] = lang('Edit definition <a href="%1">%2</a> to match your file',
467
-							$edit_link, $definition->name );
467
+							$edit_link, $definition->name);
468 468
 					}
469
-					$actions[] = lang('Edit your file to match the definition:') . ' '
470
-					. implode(array_map('lang',array_intersect_key($options['csv_fields'],$options['field_mapping'])),', ');
471
-					$message[] = "\n<li>".implode($actions,"\n<li>");
469
+					$actions[] = lang('Edit your file to match the definition:').' '
470
+					. implode(array_map('lang', array_intersect_key($options['csv_fields'], $options['field_mapping'])), ', ');
471
+					$message[] = "\n<li>".implode($actions, "\n<li>");
472 472
 				}
473 473
 			}
474 474
 			return $ok;
Please login to merge, or discard this patch.
infolog/inc/class.infolog_bo.inc.php 5 patches
Doc Comments   +2 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	{
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1272,7 +1272,7 @@
 block discarded – undo
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,
Please login to merge, or discard this patch.
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -701,21 +701,21 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
Braces   +203 added lines, -56 removed lines patch added patch discarded remove patch
@@ -232,7 +232,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'] = '';
@@ -493,7 +536,10 @@  discard block
 block discarded – undo
493 536
 		$pm_links = Link::get_links('infolog',$info['info_id'],'projectmanager');
494 537
 
495 538
 		$old_pm_id = is_array($pm_links) ? array_shift($pm_links) : $info['old_pm_id'];
496
-		if (!isset($info['pm_id']) && $old_pm_id) $info['pm_id'] = $old_pm_id;
539
+		if (!isset($info['pm_id']) && $old_pm_id)
540
+		{
541
+			$info['pm_id'] = $old_pm_id;
542
+		}
497 543
 		return $old_pm_id;
498 544
 	}
499 545
 
@@ -520,12 +566,15 @@  discard block
 block discarded – undo
520 566
 	 function time2time(&$values, $fromTZId=false, $toTZId=null)
521 567
 	 {
522 568
 
523
-		if ($fromTZId === $toTZId) return;
569
+		if ($fromTZId === $toTZId)
570
+		{
571
+			return;
572
+		}
524 573
 
525 574
 		$tz = Api\DateTime::$server_timezone;
526 575
 
527 576
 	 	if ($fromTZId)
528
-		{
577
+	 	{
529 578
 			if (!isset(self::$tz_cache[$fromTZId]))
530 579
 			{
531 580
 				self::$tz_cache[$fromTZId] = calendar_timezones::DateTimeZone($fromTZId);
@@ -559,7 +608,7 @@  discard block
 block discarded – undo
559 608
 		}
560 609
 		//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());
561 610
 	 	foreach($this->timestamps as $key)
562
-		{
611
+	 	{
563 612
 		 	if ($values[$key])
564 613
 		 	{
565 614
 			 	$time = new Api\DateTime($values[$key], $tz);
@@ -589,7 +638,10 @@  discard block
 block discarded – undo
589 638
 	 */
590 639
 	function date2usertime($ts,$date_format='ts')
591 640
 	{
592
-		if (empty($ts) || $date_format == 'server') return $ts;
641
+		if (empty($ts) || $date_format == 'server')
642
+		{
643
+			return $ts;
644
+		}
593 645
 
594 646
 		return Api\DateTime::server2user($ts,$date_format);
595 647
 	}
@@ -626,10 +678,13 @@  discard block
 block discarded – undo
626 678
 			return null;
627 679
 		}
628 680
 
629
-		if (!$ignore_acl && !$this->check_access($data,Acl::READ))	// check behind read, to prevent a double read
681
+		if (!$ignore_acl && !$this->check_access($data,Acl::READ))
682
+		{
683
+			// check behind read, to prevent a double read
630 684
 		{
631 685
 			return False;
632 686
 		}
687
+		}
633 688
 
634 689
 		if ($data['info_subject'] == $this->subject_from_des($data['info_des']))
635 690
 		{
@@ -700,7 +755,11 @@  discard block
 block discarded – undo
700 755
 		// if we have history switched on and not an already deleted item --> set only status deleted
701 756
 		if ($this->history && $info['info_status'] != 'deleted')
702 757
 		{
703
-			if ($info['info_status'] == 'deleted') return false;	// entry already deleted
758
+			if ($info['info_status'] == 'deleted')
759
+			{
760
+				return false;
761
+			}
762
+			// entry already deleted
704 763
 
705 764
 			$this->so->write($deleted);
706 765
 
@@ -712,7 +771,9 @@  discard block
 block discarded – undo
712 771
 
713 772
 			Link::unlink(0,'infolog',$info_id);
714 773
 		}
715
-		if ($info['info_status'] != 'deleted')	// dont notify of final purge of already deleted items
774
+		if ($info['info_status'] != 'deleted')
775
+		{
776
+			// dont notify of final purge of already deleted items
716 777
 		{
717 778
 			// send email notifications and do the history logging
718 779
 			if(!$skip_notification)
@@ -720,6 +781,7 @@  discard block
 block discarded – undo
720 781
 				if (!is_object($this->tracking))
721 782
 				{
722 783
 					$this->tracking = new infolog_tracking($this);
784
+		}
723 785
 				}
724 786
 				$this->tracking->track($deleted,$info,$this->user,true);
725 787
 			}
@@ -769,10 +831,13 @@  discard block
 block discarded – undo
769 831
 			{
770 832
 				$responsible = $values['info_responsible'];
771 833
 			}
772
-			if (!($status_only = in_array($this->user, (array)$responsible)))	// responsible has implicit right to change status
834
+			if (!($status_only = in_array($this->user, (array)$responsible)))
835
+			{
836
+				// responsible has implicit right to change status
773 837
 			{
774 838
 				$status_only = !!array_intersect((array)$responsible,array_keys($GLOBALS['egw']->accounts->memberships($this->user)));
775 839
 			}
840
+			}
776 841
 			if (!$status_only && $values['info_status'] != 'deleted')
777 842
 			{
778 843
 				$status_only = $undelete = $this->check_access($values['info_id'],self::ACL_UNDELETE);
@@ -793,17 +858,23 @@  discard block
 block discarded – undo
793 858
 				$values['info_status'] = $this->status['defaults'][$values['info_type']];
794 859
 			}
795 860
 		}
796
-		if ($status_only && !$undelete)	// make sure only status gets writen
861
+		if ($status_only && !$undelete)
862
+		{
863
+			// make sure only status gets writen
797 864
 		{
798 865
 			$set_completed = !$values['info_datecompleted'] &&	// set date completed of finished job, only if its not already set
799 866
 				in_array($values['info_status'],array('done','billed','cancelled'));
867
+		}
800 868
 
801 869
 			$values = $old;
802 870
 			// only overwrite explicitly allowed fields
803 871
 			$values['info_datemodified'] = $values_in['info_datemodified'];
804 872
 			foreach ($this->responsible_edit as $name)
805 873
 			{
806
-				if (isset($values_in[$name])) $values[$name] = $values_in[$name];
874
+				if (isset($values_in[$name]))
875
+				{
876
+					$values[$name] = $values_in[$name];
877
+				}
807 878
 			}
808 879
 			if ($set_completed)
809 880
 			{
@@ -811,21 +882,30 @@  discard block
 block discarded – undo
811 882
 				$values['info_percent'] = 100;
812 883
 				$forcestatus = true;
813 884
 				$status = 'done';
814
-				if (isset($values['info_type']) && !in_array($values['info_status'],array('done','billed','cancelled'))) {
885
+				if (isset($values['info_type']) && !in_array($values['info_status'],array('done','billed','cancelled')))
886
+				{
815 887
 					$forcestatus = false;
816 888
 					//echo "set_completed:"; _debug_array($this->status[$values['info_type']]);
817
-					if (isset($this->status[$values['info_type']]['done'])) {
889
+					if (isset($this->status[$values['info_type']]['done']))
890
+					{
818 891
 						$forcestatus = true;
819 892
 						$status = 'done';
820
-					} elseif (isset($this->status[$values['info_type']]['billed'])) {
893
+					}
894
+					elseif (isset($this->status[$values['info_type']]['billed']))
895
+					{
821 896
 						$forcestatus = true;
822 897
 						$status = 'billed';
823
-					} elseif (isset($this->status[$values['info_type']]['cancelled'])) {
898
+					}
899
+					elseif (isset($this->status[$values['info_type']]['cancelled']))
900
+					{
824 901
 						$forcestatus = true;
825 902
 						$status = 'cancelled';
826 903
 					}
827 904
 				}
828
-				if ($forcestatus && !in_array($values['info_status'],array('done','billed','cancelled'))) $values['info_status'] = $status;
905
+				if ($forcestatus && !in_array($values['info_status'],array('done','billed','cancelled')))
906
+				{
907
+					$values['info_status'] = $status;
908
+				}
829 909
 			}
830 910
 			$check_defaults = false;
831 911
 		}
@@ -857,14 +937,22 @@  discard block
 block discarded – undo
857 937
 				//echo "check_defaults:"; _debug_array($this->status[$values['info_type']]);
858 938
 				//$values['info_status'] = 'done';
859 939
 				$status = 'done';
860
-				if (isset($values['info_type'])) {
861
-					if (isset($this->status[$values['info_type']]['done'])) {
940
+				if (isset($values['info_type']))
941
+				{
942
+					if (isset($this->status[$values['info_type']]['done']))
943
+					{
862 944
 						$status = 'done';
863
-					} elseif (isset($this->status[$values['info_type']]['billed'])) {
945
+					}
946
+					elseif (isset($this->status[$values['info_type']]['billed']))
947
+					{
864 948
 						$status = 'billed';
865
-					} elseif (isset($this->status[$values['info_type']]['cancelled'])) {
949
+					}
950
+					elseif (isset($this->status[$values['info_type']]['cancelled']))
951
+					{
866 952
 						$status = 'cancelled';
867
-					} else {
953
+					}
954
+					else
955
+					{
868 956
 						// since the comlete stati above do not exist for that type, dont change it
869 957
 						$status = $values['info_status'];
870 958
 					}
@@ -886,7 +974,10 @@  discard block
 block discarded – undo
886 974
 				$custom = Api\Storage\Customfields::get('infolog');
887 975
 				foreach($custom as $c_name => $c_field)
888 976
 				{
889
-					if($c_field['type2']) $type2 = is_array($c_field['type2']) ? $c_field['type2'] : explode(',',$c_field['type2']);
977
+					if($c_field['type2'])
978
+					{
979
+						$type2 = is_array($c_field['type2']) ? $c_field['type2'] : explode(',',$c_field['type2']);
980
+					}
890 981
 					if($c_field['needed'] && (!$c_field['type2'] || $c_field['type2'] && in_array($values['info_type'],$type2)))
891 982
 					{
892 983
 						// Required custom field
@@ -905,8 +996,7 @@  discard block
 block discarded – undo
905 996
 			{
906 997
 				if (!$this->check_access($values['info_id'],Acl::EDIT) ||
907 998
 					!$values['info_id'] && !$this->check_access($values,Acl::ADD)
908
-				)
909
-				{
999
+				) {
910 1000
 					return false;	// no edit rights from the group-owner and no implicit rights (delegated and sufficient rights)
911 1001
 				}
912 1002
 			}
@@ -965,10 +1055,16 @@  discard block
 block discarded – undo
965 1055
 			$to_write['info_id'] = $info_id;
966 1056
 
967 1057
 			// if the info responbsible array is not passed, fetch it from old.
968
-			if (!array_key_exists('info_responsible',$values)) $values['info_responsible'] = $old['info_responsible'];
969
-			if (!is_array($values['info_responsible']))		// this should not happen, bug it does ;-)
1058
+			if (!array_key_exists('info_responsible',$values))
1059
+			{
1060
+				$values['info_responsible'] = $old['info_responsible'];
1061
+			}
1062
+			if (!is_array($values['info_responsible']))
1063
+			{
1064
+				// this should not happen, bug it does ;-)
970 1065
 			{
971 1066
 				$values['info_responsible'] = $values['info_responsible'] ? explode(',',$values['info_responsible']) : array();
1067
+			}
972 1068
 				$to_write['info_responsible'] = $values['info_responsible'];
973 1069
 			}
974 1070
 
@@ -1042,7 +1138,10 @@  discard block
 block discarded – undo
1042 1138
 			$this->tracking->track($to_write,$old,$this->user,$values['info_status'] == 'deleted' || $old['info_status'] == 'deleted',
1043 1139
 				null,$skip_notification);
1044 1140
 
1045
-			if ($info_from_set) $values['info_from'] = '';
1141
+			if ($info_from_set)
1142
+			{
1143
+				$values['info_from'] = '';
1144
+			}
1046 1145
 
1047 1146
 			// Change new values back to user time before sending them back
1048 1147
 			if($user2server)
@@ -1201,13 +1300,25 @@  discard block
 block discarded – undo
1201 1300
 
1202 1301
 		if($query['filter'] == 'bydate')
1203 1302
 		{
1204
-			if (is_int($query['startdate'])) $query['col_filter'][] = 'info_startdate >= '.$GLOBALS['egw']->db->quote($query['startdate']);
1205
-			if (is_int($query['enddate'])) $query['col_filter'][] = 'info_startdate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1);
1303
+			if (is_int($query['startdate']))
1304
+			{
1305
+				$query['col_filter'][] = 'info_startdate >= '.$GLOBALS['egw']->db->quote($query['startdate']);
1306
+			}
1307
+			if (is_int($query['enddate']))
1308
+			{
1309
+				$query['col_filter'][] = 'info_startdate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1);
1310
+			}
1206 1311
 		}
1207 1312
 		elseif ($query['filter'] == 'duedate')
1208 1313
 		{
1209
-			if (is_int($query['startdate'])) $query['col_filter'][] = 'info_enddate >= '.$GLOBALS['egw']->db->quote($query['startdate']);
1210
-			if (is_int($query['enddate'])) $query['col_filter'][] = 'info_enddate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1);
1314
+			if (is_int($query['startdate']))
1315
+			{
1316
+				$query['col_filter'][] = 'info_enddate >= '.$GLOBALS['egw']->db->quote($query['startdate']);
1317
+			}
1318
+			if (is_int($query['enddate']))
1319
+			{
1320
+				$query['col_filter'][] = 'info_enddate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1);
1321
+			}
1211 1322
 		}
1212 1323
 		elseif ($query['filter'] == 'private')
1213 1324
 		{
@@ -1289,7 +1400,10 @@  discard block
 block discarded – undo
1289 1400
 
1290 1401
 		$result =& $this->search($filter);
1291 1402
 
1292
-		if (empty($result)) return 'EGw-empty-wGE';
1403
+		if (empty($result))
1404
+		{
1405
+			return 'EGw-empty-wGE';
1406
+		}
1293 1407
 
1294 1408
 		$entry = array_shift($result);
1295 1409
 
@@ -1335,7 +1449,10 @@  discard block
 block discarded – undo
1335 1449
 				'to_id' => 0,
1336 1450
 			),
1337 1451
 		);
1338
-		if ($GLOBALS['egw_info']['user']['preferences']['infolog']['cat_add_default']) $info['info_cat'] = $GLOBALS['egw_info']['user']['preferences']['infolog']['cat_add_default'];
1452
+		if ($GLOBALS['egw_info']['user']['preferences']['infolog']['cat_add_default'])
1453
+		{
1454
+			$info['info_cat'] = $GLOBALS['egw_info']['user']['preferences']['infolog']['cat_add_default'];
1455
+		}
1339 1456
 		// find the addressbookentry to link with
1340 1457
 		$addressbook = new Api\Contacts();
1341 1458
 		$contacts = array();
@@ -1596,7 +1713,10 @@  discard block
 block discarded – undo
1596 1713
 			{
1597 1714
 				foreach($anzSubs as $info_id => $subs)
1598 1715
 				{
1599
-					if ($subs) $infos[$info_id]['class'] .= ' infolog_rowHasSubs';
1716
+					if ($subs)
1717
+					{
1718
+						$infos[$info_id]['class'] .= ' infolog_rowHasSubs';
1719
+					}
1600 1720
 				}
1601 1721
 			}
1602 1722
 		}
@@ -1723,7 +1843,10 @@  discard block
 block discarded – undo
1723 1843
 		$save_prefs      = $GLOBALS['egw_info']['user']['preferences'];
1724 1844
 		foreach($users as $user)
1725 1845
 		{
1726
-			if (!($email = $GLOBALS['egw']->accounts->id2name($user,'account_email'))) continue;
1846
+			if (!($email = $GLOBALS['egw']->accounts->id2name($user,'account_email')))
1847
+			{
1848
+				continue;
1849
+			}
1727 1850
 			// create the enviroment for $user
1728 1851
 			$this->user = $GLOBALS['egw_info']['user']['account_id'] = $user;
1729 1852
 			$GLOBALS['egw']->preferences->__construct($user);
@@ -1740,7 +1863,10 @@  discard block
 block discarded – undo
1740 1863
 				'notify_start_delegated'   => 'open-delegated-date',
1741 1864
 			) as $pref => $filter)
1742 1865
 			{
1743
-				if (!($pref_value = $GLOBALS['egw_info']['user']['preferences']['infolog'][$pref])) continue;
1866
+				if (!($pref_value = $GLOBALS['egw_info']['user']['preferences']['infolog'][$pref]))
1867
+				{
1868
+					continue;
1869
+				}
1744 1870
 
1745 1871
 				$filter .= date('Y-m-d',time()+24*60*60*(int)$pref_value);
1746 1872
 				//error_log(__METHOD__."() checking with filter '$filter' ($pref_value) for user $user ($email)");
@@ -1749,7 +1875,10 @@  discard block
 block discarded – undo
1749 1875
 				foreach($this->so->search($params) as $info)
1750 1876
 				{
1751 1877
 					// check if we already send a notification for that infolog entry, eg. starting and due on same day
1752
-					if (in_array($info['info_id'],$notified_info_ids)) continue;
1878
+					if (in_array($info['info_id'],$notified_info_ids))
1879
+					{
1880
+						continue;
1881
+					}
1753 1882
 
1754 1883
 					if (is_null($this->tracking) || $this->tracking->user != $user)
1755 1884
 					{
@@ -1878,11 +2007,17 @@  discard block
 block discarded – undo
1878 2007
 			$statis = $icons = array();
1879 2008
 			foreach($this->status as $t => $stati)
1880 2009
 			{
1881
-				if ($t === 'defaults') continue;
2010
+				if ($t === 'defaults')
2011
+				{
2012
+					continue;
2013
+				}
1882 2014
 				foreach($stati as $val => $label)
1883 2015
 				{
1884 2016
 					$statis[$val][$label] = lang($label);
1885
-					if (!isset($icons[$val])) $icons[$val] = $label;
2017
+					if (!isset($icons[$val]))
2018
+					{
2019
+						$icons[$val] = $label;
2020
+					}
1886 2021
 				}
1887 2022
 			}
1888 2023
 			foreach($statis as $val => &$labels)
@@ -1958,7 +2093,10 @@  discard block
 block discarded – undo
1958 2093
 			{
1959 2094
 				return array($egwData['info_id']);
1960 2095
 			}
1961
-			if (!$relax) return array();
2096
+			if (!$relax)
2097
+			{
2098
+				return array();
2099
+			}
1962 2100
 		}
1963 2101
 		unset($infoData['info_id']);
1964 2102
 
@@ -1967,7 +2105,10 @@  discard block
 block discarded – undo
1967 2105
 			$filter = array('col_filter' => array('info_uid' => $infoData['info_uid']));
1968 2106
 			foreach($this->so->search($filter) as $egwData)
1969 2107
 			{
1970
-				if (!$this->check_access($egwData,Acl::READ)) continue;
2108
+				if (!$this->check_access($egwData,Acl::READ))
2109
+				{
2110
+					continue;
2111
+				}
1971 2112
 				$foundInfoLogs[$egwData['info_id']] = $egwData['info_id'];
1972 2113
 			}
1973 2114
 			return $foundInfoLogs;
@@ -2019,7 +2160,10 @@  discard block
 block discarded – undo
2019 2160
 
2020 2161
 		foreach ($this->so->search($filter) as $itemID => $egwData)
2021 2162
 		{
2022
-			if (!$this->check_access($egwData,Acl::READ)) continue;
2163
+			if (!$this->check_access($egwData,Acl::READ))
2164
+			{
2165
+				continue;
2166
+			}
2023 2167
 
2024 2168
 			switch ($infoData['info_type'])
2025 2169
 			{
@@ -2092,7 +2236,10 @@  discard block
 block discarded – undo
2092 2236
 		//	__FILE__, __LINE__, PEAR_LOG_DEBUG);
2093 2237
 		foreach ($this->so->search($filter) as $itemID => $egwData)
2094 2238
 		{
2095
-			if (!$this->check_access($egwData,Acl::READ)) continue;
2239
+			if (!$this->check_access($egwData,Acl::READ))
2240
+			{
2241
+				continue;
2242
+			}
2096 2243
 			// Horde::logMessage("findVTODO Trying\n"
2097 2244
 			//	. print_r($egwData, true),
2098 2245
 			//	__FILE__, __LINE__, PEAR_LOG_DEBUG);
Please login to merge, or discard this patch.
Spacing   +252 added lines, -253 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	var $total;
41 41
 	var $vfs;
42
-	var $vfs_basedir='/infolog';
42
+	var $vfs_basedir = '/infolog';
43 43
 	/**
44 44
 	 * Set Logging
45 45
 	 *
@@ -64,13 +64,13 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @var array
66 66
 	 */
67
-	var $timestamps = array('info_startdate','info_enddate','info_datemodified','info_datecompleted','info_created');
67
+	var $timestamps = array('info_startdate', 'info_enddate', 'info_datemodified', 'info_datecompleted', 'info_created');
68 68
 	/**
69 69
 	 * fields the responsible user can change
70 70
 	 *
71 71
 	 * @var array
72 72
 	 */
73
-	var $responsible_edit=array('info_status','info_percent','info_datecompleted');
73
+	var $responsible_edit = array('info_status', 'info_percent', 'info_datecompleted');
74 74
 	/**
75 75
 	 * Fields to exclude from copy, if an entry is copied, the ones below are excluded by default.
76 76
 	 *
@@ -94,19 +94,19 @@  discard block
 block discarded – undo
94 94
 	 *
95 95
 	 * @var string
96 96
 	 */
97
-	var $implicit_rights='read';
97
+	var $implicit_rights = 'read';
98 98
 	/**
99 99
 	 * Custom fields read from the infolog config
100 100
 	 *
101 101
 	 * @var array
102 102
 	 */
103
-	var $customfields=array();
103
+	var $customfields = array();
104 104
 	/**
105 105
 	 * Group owners for certain types read from the infolog config
106 106
 	 *
107 107
 	 * @var array
108 108
 	 */
109
-	var $group_owners=array();
109
+	var $group_owners = array();
110 110
 	/**
111 111
 	 * Current user
112 112
 	 *
@@ -173,42 +173,42 @@  discard block
 block discarded – undo
173 173
 	function __construct($info_id = 0)
174 174
 	{
175 175
 		$this->enums = $this->stock_enums = array(
176
-			'priority' => array (
176
+			'priority' => array(
177 177
 				3 => 'urgent',
178 178
 				2 => 'high',
179 179
 				1 => 'normal',
180 180
 				0 => 'low'
181 181
 			),
182 182
 			'confirm'   => array(
183
-				'not' => 'not','accept' => 'accept','finish' => 'finish',
183
+				'not' => 'not', 'accept' => 'accept', 'finish' => 'finish',
184 184
 				'both' => 'both' ),
185 185
 			'type'      => array(
186
-				'task' => 'task','phone' => 'phone','note' => 'note','email' => 'email'
186
+				'task' => 'task', 'phone' => 'phone', 'note' => 'note', 'email' => 'email'
187 187
 			/*	,'confirm' => 'confirm','reject' => 'reject','fax' => 'fax' not implemented so far */ )
188 188
 		);
189 189
 		$this->status = $this->stock_status = array(
190 190
 			'defaults' => array(
191
-				'task' => 'not-started', 'phone' => 'not-started', 'note' => 'done','email' => 'done'),
191
+				'task' => 'not-started', 'phone' => 'not-started', 'note' => 'done', 'email' => 'done'),
192 192
 			'task' => array(
193
-				'offer' => 'offer',				// -->  NEEDS-ACTION
194
-				'not-started' => 'not-started',	// iCal NEEDS-ACTION
195
-				'ongoing' => 'ongoing',			// iCal IN-PROCESS
196
-				'done' => 'done',				// iCal COMPLETED
197
-				'cancelled' => 'cancelled',		// iCal CANCELLED
198
-				'billed' => 'billed',			// -->  DONE
199
-				'template' => 'template',		// -->  cancelled
200
-				'nonactive' => 'nonactive',		// -->  cancelled
201
-				'archive' => 'archive' ), 		// -->  cancelled
193
+				'offer' => 'offer', // -->  NEEDS-ACTION
194
+				'not-started' => 'not-started', // iCal NEEDS-ACTION
195
+				'ongoing' => 'ongoing', // iCal IN-PROCESS
196
+				'done' => 'done', // iCal COMPLETED
197
+				'cancelled' => 'cancelled', // iCal CANCELLED
198
+				'billed' => 'billed', // -->  DONE
199
+				'template' => 'template', // -->  cancelled
200
+				'nonactive' => 'nonactive', // -->  cancelled
201
+				'archive' => 'archive' ), // -->  cancelled
202 202
 			'phone' => array(
203
-				'not-started' => 'call',		// iCal NEEDS-ACTION
204
-				'ongoing' => 'will-call',		// iCal IN-PROCESS
205
-				'done' => 'done', 				// iCal COMPLETED
206
-				'billed' => 'billed' ),			// -->  DONE
203
+				'not-started' => 'call', // iCal NEEDS-ACTION
204
+				'ongoing' => 'will-call', // iCal IN-PROCESS
205
+				'done' => 'done', // iCal COMPLETED
206
+				'billed' => 'billed' ), // -->  DONE
207 207
 			'note' => array(
208
-				'ongoing' => 'ongoing',			// iCal has no status on notes
208
+				'ongoing' => 'ongoing', // iCal has no status on notes
209 209
 				'done' => 'done' ),
210 210
 			'email' => array(
211
-				'ongoing' => 'ongoing',			// iCal has no status on notes
211
+				'ongoing' => 'ongoing', // iCal has no status on notes
212 212
 				'done' => 'done' ),
213 213
 		);
214 214
 		if (($config_data = Api\Config::read('infolog')))
@@ -216,13 +216,13 @@  discard block
 block discarded – undo
216 216
 			$this->allow_past_due_date = $config_data['allow_past_due_date'] === null ? 1 : $config_data['allow_past_due_date'];
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 			{
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 
478 478
 		// Set ID to 'none' instead of unset to make it seem like there's a value
479 479
 		$info['info_link'] = $info['info_contact'] = $info['info_from'] ? array('id' => 'none', 'title' => $info['info_from']) : null;
480
-		$info['info_link_id'] = 0;	// link might have been deleted
480
+		$info['info_link_id'] = 0; // link might have been deleted
481 481
 		$info['info_custom_from'] = (int)!!$info['info_from'];
482 482
 
483 483
 		$this->get_pm_id($info);
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 	 */
493 493
 	public function get_pm_id(&$info)
494 494
 	{
495
-		$pm_links = Link::get_links('infolog',$info['info_id'],'projectmanager');
495
+		$pm_links = Link::get_links('infolog', $info['info_id'], 'projectmanager');
496 496
 
497 497
 		$old_pm_id = is_array($pm_links) ? array_shift($pm_links) : $info['old_pm_id'];
498 498
 		if (!isset($info['pm_id']) && $old_pm_id) $info['pm_id'] = $old_pm_id;
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 	 */
505 505
 	static function subject_from_des($des)
506 506
 	{
507
-		return substr($des,0,60).' ...';
507
+		return substr($des, 0, 60).' ...';
508 508
 	}
509 509
 
510 510
 	/**
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 	 * 			or NULL for timestamps in user-time
520 520
 	 * 			or false for timestamps in server-time
521 521
 	 */
522
-	 function time2time(&$values, $fromTZId=false, $toTZId=null)
522
+	 function time2time(&$values, $fromTZId = false, $toTZId = null)
523 523
 	 {
524 524
 
525 525
 		if ($fromTZId === $toTZId) return;
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 			$toTZ = Api\DateTime::$server_timezone;
561 561
 		}
562 562
 		//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());
563
-	 	foreach($this->timestamps as $key)
563
+	 	foreach ($this->timestamps as $key)
564 564
 		{
565 565
 		 	if ($values[$key])
566 566
 		 	{
@@ -569,14 +569,14 @@  discard block
 block discarded – undo
569 569
 			 	if ($time->format('Hi') == '0000')
570 570
 			 	{
571 571
 				 	// we keep dates the same in new timezone
572
-				 	$arr = Api\DateTime::to($time,'array');
572
+				 	$arr = Api\DateTime::to($time, 'array');
573 573
 				 	$time = new Api\DateTime($arr, $toTZ);
574 574
 			 	}
575 575
 			 	else
576 576
 			 	{
577 577
 				 	$time->setTimezone($toTZ);
578 578
 			 	}
579
-			 	$values[$key] = Api\DateTime::to($time,'ts');
579
+			 	$values[$key] = Api\DateTime::to($time, 'ts');
580 580
 		 	}
581 581
 		}
582 582
 		//error_log(__METHOD__.'() --> values[info_enddate]='.date('Y-m-d H:i:s',$values['info_enddate']));
@@ -589,11 +589,11 @@  discard block
 block discarded – undo
589 589
 	 * @param string $date_format = 'ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format
590 590
 	 * @return mixed depending of $date_format
591 591
 	 */
592
-	function date2usertime($ts,$date_format='ts')
592
+	function date2usertime($ts, $date_format = 'ts')
593 593
 	{
594 594
 		if (empty($ts) || $date_format == 'server') return $ts;
595 595
 
596
-		return Api\DateTime::server2user($ts,$date_format);
596
+		return Api\DateTime::server2user($ts, $date_format);
597 597
 	}
598 598
 
599 599
 	/**
@@ -608,10 +608,10 @@  discard block
 block discarded – undo
608 608
 	 *
609 609
 	 * @return array|boolean infolog entry, null if not found or false if no permission to read it
610 610
 	 */
611
-	function &read($info_id,$run_link_id2from=true,$date_format='ts',$ignore_acl=false)
611
+	function &read($info_id, $run_link_id2from = true, $date_format = 'ts', $ignore_acl = false)
612 612
 	{
613 613
 		//error_log(__METHOD__.'('.array2string($info_id).', '.array2string($run_link_id2from).", '$date_format') ".function_backtrace());
614
-		if (is_scalar($info_id) || isset($info_id[count($info_id)-1]))
614
+		if (is_scalar($info_id) || isset($info_id[count($info_id) - 1]))
615 615
 		{
616 616
 			if (is_scalar($info_id) && !is_numeric($info_id))
617 617
 			{
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 			return null;
629 629
 		}
630 630
 
631
-		if (!$ignore_acl && !$this->check_access($data,Acl::READ))	// check behind read, to prevent a double read
631
+		if (!$ignore_acl && !$this->check_access($data, Acl::READ))	// check behind read, to prevent a double read
632 632
 		{
633 633
 			return False;
634 634
 		}
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 	 * @param boolean $skip_notification Do not send notification of delete
663 663
 	 * @return boolean True if delete was successful, False otherwise ($info_id does not exist or no rights)
664 664
 	 */
665
-	function delete($info_id,$delete_children=False,$new_parent=False, $skip_notification=False)
665
+	function delete($info_id, $delete_children = False, $new_parent = False, $skip_notification = False)
666 666
 	{
667 667
 		if (is_array($info_id))
668 668
 		{
@@ -672,18 +672,18 @@  discard block
 block discarded – undo
672 672
 		{
673 673
 			return False;
674 674
 		}
675
-		if (!$this->check_access($info,Acl::DELETE))
675
+		if (!$this->check_access($info, Acl::DELETE))
676 676
 		{
677 677
 			return False;
678 678
 		}
679 679
 		// check if we have children and delete or re-parent them
680 680
 		if (($children = $this->so->get_children($info_id)))
681 681
 		{
682
-			foreach($children as $id => $owner)
682
+			foreach ($children as $id => $owner)
683 683
 			{
684
-				if ($delete_children && $this->so->grants[$owner] & Acl::DELETE)
684
+				if ($delete_children && $this->so->grants[$owner]&Acl::DELETE)
685 685
 				{
686
-					$this->delete($id,$delete_children,$new_parent,$skip_notification);	// call ourself recursive to delete the child
686
+					$this->delete($id, $delete_children, $new_parent, $skip_notification); // call ourself recursive to delete the child
687 687
 				}
688 688
 				else	// dont delete or no rights to delete the child --> re-parent it
689 689
 				{
@@ -702,28 +702,28 @@  discard block
 block discarded – undo
702 702
 		// if we have history switched on and not an already deleted item --> set only status deleted
703 703
 		if ($this->history && $info['info_status'] != 'deleted')
704 704
 		{
705
-			if ($info['info_status'] == 'deleted') return false;	// entry already deleted
705
+			if ($info['info_status'] == 'deleted') return false; // entry already deleted
706 706
 
707 707
 			$this->so->write($deleted);
708 708
 
709
-			Link::unlink(0,'infolog',$info_id,'','!file','',true);	// keep the file attachments, hide the rest
709
+			Link::unlink(0, 'infolog', $info_id, '', '!file', '', true); // keep the file attachments, hide the rest
710 710
 		}
711 711
 		else
712 712
 		{
713
-			$this->so->delete($info_id,false);	// we delete the children via bo to get all notifications!
713
+			$this->so->delete($info_id, false); // we delete the children via bo to get all notifications!
714 714
 
715
-			Link::unlink(0,'infolog',$info_id);
715
+			Link::unlink(0, 'infolog', $info_id);
716 716
 		}
717 717
 		if ($info['info_status'] != 'deleted')	// dont notify of final purge of already deleted items
718 718
 		{
719 719
 			// send email notifications and do the history logging
720
-			if(!$skip_notification)
720
+			if (!$skip_notification)
721 721
 			{
722 722
 				if (!is_object($this->tracking))
723 723
 				{
724 724
 					$this->tracking = new infolog_tracking($this);
725 725
 				}
726
-				$this->tracking->track($deleted,$info,$this->user,true);
726
+				$this->tracking->track($deleted, $info, $this->user, true);
727 727
 			}
728 728
 		}
729 729
 		return True;
@@ -745,13 +745,13 @@  discard block
 block discarded – undo
745 745
 	*
746 746
 	* @return int|boolean info_id on a successfull write or false
747 747
 	*/
748
-	function write(&$values_in, $check_defaults=true, $touch_modified=true, $user2server=true,
749
-		$skip_notification=false, $throw_exception=false, $purge_cfs=null, $ignore_acl=false)
748
+	function write(&$values_in, $check_defaults = true, $touch_modified = true, $user2server = true,
749
+		$skip_notification = false, $throw_exception = false, $purge_cfs = null, $ignore_acl = false)
750 750
 	{
751 751
 		$values = $values_in;
752 752
 		//echo "boinfolog::write()values="; _debug_array($values);
753
-		if (!$ignore_acl && (!$values['info_id'] && !$this->check_access(0,Acl::EDIT,$values['info_owner']) &&
754
-			!$this->check_access(0,Acl::ADD,$values['info_owner'])))
753
+		if (!$ignore_acl && (!$values['info_id'] && !$this->check_access(0, Acl::EDIT, $values['info_owner']) &&
754
+			!$this->check_access(0, Acl::ADD, $values['info_owner'])))
755 755
 		{
756 756
 			return false;
757 757
 		}
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 			$old = $this->read($values['info_id'], false, 'server', $ignore_acl);
762 762
 		}
763 763
 
764
-		if (($status_only = !$ignore_acl && $values['info_id'] && !$this->check_access($values,Acl::EDIT)))
764
+		if (($status_only = !$ignore_acl && $values['info_id'] && !$this->check_access($values, Acl::EDIT)))
765 765
 		{
766 766
 			if (!isset($values['info_responsible']))
767 767
 			{
@@ -773,21 +773,21 @@  discard block
 block discarded – undo
773 773
 			}
774 774
 			if (!($status_only = in_array($this->user, (array)$responsible)))	// responsible has implicit right to change status
775 775
 			{
776
-				$status_only = !!array_intersect((array)$responsible,array_keys($GLOBALS['egw']->accounts->memberships($this->user)));
776
+				$status_only = !!array_intersect((array)$responsible, array_keys($GLOBALS['egw']->accounts->memberships($this->user)));
777 777
 			}
778 778
 			if (!$status_only && $values['info_status'] != 'deleted')
779 779
 			{
780
-				$status_only = $undelete = $this->check_access($values['info_id'],self::ACL_UNDELETE);
780
+				$status_only = $undelete = $this->check_access($values['info_id'], self::ACL_UNDELETE);
781 781
 			}
782 782
 		}
783
-		if (!$ignore_acl && ($values['info_id'] && !$this->check_access($values['info_id'],Acl::EDIT) && !$status_only ||
784
-		    !$values['info_id'] && $values['info_id_parent'] && !$this->check_access($values['info_id_parent'],Acl::ADD)))
783
+		if (!$ignore_acl && ($values['info_id'] && !$this->check_access($values['info_id'], Acl::EDIT) && !$status_only ||
784
+		    !$values['info_id'] && $values['info_id_parent'] && !$this->check_access($values['info_id_parent'], Acl::ADD)))
785 785
 		{
786 786
 			return false;
787 787
 		}
788 788
 
789 789
 		// Make sure status is still valid if the type changes
790
-		if($old['info_type'] != $values['info_type'] && $values['info_status'])
790
+		if ($old['info_type'] != $values['info_type'] && $values['info_status'])
791 791
 		{
792 792
 			if (isset($this->status[$values['info_type']]) &&
793 793
 				!in_array($values['info_status'], array_keys($this->status[$values['info_type']])))
@@ -797,8 +797,8 @@  discard block
 block discarded – undo
797 797
 		}
798 798
 		if ($status_only && !$undelete)	// make sure only status gets writen
799 799
 		{
800
-			$set_completed = !$values['info_datecompleted'] &&	// set date completed of finished job, only if its not already set
801
-				in_array($values['info_status'],array('done','billed','cancelled'));
800
+			$set_completed = !$values['info_datecompleted'] && // set date completed of finished job, only if its not already set
801
+				in_array($values['info_status'], array('done', 'billed', 'cancelled'));
802 802
 
803 803
 			$values = $old;
804 804
 			// only overwrite explicitly allowed fields
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 				$values['info_percent'] = 100;
814 814
 				$forcestatus = true;
815 815
 				$status = 'done';
816
-				if (isset($values['info_type']) && !in_array($values['info_status'],array('done','billed','cancelled'))) {
816
+				if (isset($values['info_type']) && !in_array($values['info_status'], array('done', 'billed', 'cancelled'))) {
817 817
 					$forcestatus = false;
818 818
 					//echo "set_completed:"; _debug_array($this->status[$values['info_type']]);
819 819
 					if (isset($this->status[$values['info_type']]['done'])) {
@@ -827,19 +827,19 @@  discard block
 block discarded – undo
827 827
 						$status = 'cancelled';
828 828
 					}
829 829
 				}
830
-				if ($forcestatus && !in_array($values['info_status'],array('done','billed','cancelled'))) $values['info_status'] = $status;
830
+				if ($forcestatus && !in_array($values['info_status'], array('done', 'billed', 'cancelled'))) $values['info_status'] = $status;
831 831
 			}
832 832
 			$check_defaults = false;
833 833
 		}
834 834
 		if ($check_defaults)
835 835
 		{
836 836
 			if (!$values['info_datecompleted'] &&
837
-				(in_array($values['info_status'],array('done','billed'))))
837
+				(in_array($values['info_status'], array('done', 'billed'))))
838 838
 			{
839
-				$values['info_datecompleted'] = $user2server ? $this->user_time_now : $this->now;	// set date completed to today if status == done
839
+				$values['info_datecompleted'] = $user2server ? $this->user_time_now : $this->now; // set date completed to today if status == done
840 840
 			}
841 841
 			// Check for valid status / percent combinations
842
-			if (in_array($values['info_status'],array('done','billed')))
842
+			if (in_array($values['info_status'], array('done', 'billed')))
843 843
 			{
844 844
 				$values['info_percent'] = 100;
845 845
 			}
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
 				// We change percent to match status, not status to match percent
855 855
 				$values['info_percent'] = 10;
856 856
 			}
857
-			if ((int)$values['info_percent'] == 100 && !in_array($values['info_status'],array('done','billed','cancelled','archive')))
857
+			if ((int)$values['info_percent'] == 100 && !in_array($values['info_status'], array('done', 'billed', 'cancelled', 'archive')))
858 858
 			{
859 859
 				//echo "check_defaults:"; _debug_array($this->status[$values['info_type']]);
860 860
 				//$values['info_status'] = 'done';
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
 			}
876 876
 			if ($values['info_responsible'] && $values['info_status'] == 'offer')
877 877
 			{
878
-				$values['info_status'] = 'not-started';   // have to match if not finished
878
+				$values['info_status'] = 'not-started'; // have to match if not finished
879 879
 			}
880 880
 			if (isset($values['info_subject']) && empty($values['info_subject']))
881 881
 			{
@@ -883,18 +883,18 @@  discard block
 block discarded – undo
883 883
 			}
884 884
 
885 885
 			// Check required custom fields
886
-			if($throw_exception)
886
+			if ($throw_exception)
887 887
 			{
888 888
 				$custom = Api\Storage\Customfields::get('infolog');
889
-				foreach($custom as $c_name => $c_field)
889
+				foreach ($custom as $c_name => $c_field)
890 890
 				{
891
-					if($c_field['type2']) $type2 = is_array($c_field['type2']) ? $c_field['type2'] : explode(',',$c_field['type2']);
892
-					if($c_field['needed'] && (!$c_field['type2'] || $c_field['type2'] && in_array($values['info_type'],$type2)))
891
+					if ($c_field['type2']) $type2 = is_array($c_field['type2']) ? $c_field['type2'] : explode(',', $c_field['type2']);
892
+					if ($c_field['needed'] && (!$c_field['type2'] || $c_field['type2'] && in_array($values['info_type'], $type2)))
893 893
 					{
894 894
 						// Required custom field
895
-						if(!$values['#'.$c_name])
895
+						if (!$values['#'.$c_name])
896 896
 						{
897
-							throw new Api\Exception\WrongUserinput(lang('For infolog type %1, %2 is required',lang($values['info_type']),$c_field['label']));
897
+							throw new Api\Exception\WrongUserinput(lang('For infolog type %1, %2 is required', lang($values['info_type']), $c_field['label']));
898 898
 						}
899 899
 					}
900 900
 				}
@@ -903,16 +903,16 @@  discard block
 block discarded – undo
903 903
 		if (isset($this->group_owners[$values['info_type']]))
904 904
 		{
905 905
 			$values['info_owner'] = $this->group_owners[$values['info_type']];
906
-			if (!$ignore_acl && !($this->grants[$this->group_owners[$values['info_type']]] & Acl::EDIT))
906
+			if (!$ignore_acl && !($this->grants[$this->group_owners[$values['info_type']]]&Acl::EDIT))
907 907
 			{
908
-				if (!$this->check_access($values['info_id'],Acl::EDIT) ||
909
-					!$values['info_id'] && !$this->check_access($values,Acl::ADD)
908
+				if (!$this->check_access($values['info_id'], Acl::EDIT) ||
909
+					!$values['info_id'] && !$this->check_access($values, Acl::ADD)
910 910
 				)
911 911
 				{
912
-					return false;	// no edit rights from the group-owner and no implicit rights (delegated and sufficient rights)
912
+					return false; // no edit rights from the group-owner and no implicit rights (delegated and sufficient rights)
913 913
 				}
914 914
 			}
915
-			$values['info_access'] = 'public';	// group-owners are allways public
915
+			$values['info_access'] = 'public'; // group-owners are allways public
916 916
 		}
917 917
 		elseif (!$values['info_id'] && !$values['info_owner'] || $GLOBALS['egw']->accounts->get_type($values['info_owner']) == 'g')
918 918
 		{
@@ -967,10 +967,10 @@  discard block
 block discarded – undo
967 967
 			$to_write['info_id'] = $info_id;
968 968
 
969 969
 			// if the info responbsible array is not passed, fetch it from old.
970
-			if (!array_key_exists('info_responsible',$values)) $values['info_responsible'] = $old['info_responsible'];
970
+			if (!array_key_exists('info_responsible', $values)) $values['info_responsible'] = $old['info_responsible'];
971 971
 			if (!is_array($values['info_responsible']))		// this should not happen, bug it does ;-)
972 972
 			{
973
-				$values['info_responsible'] = $values['info_responsible'] ? explode(',',$values['info_responsible']) : array();
973
+				$values['info_responsible'] = $values['info_responsible'] ? explode(',', $values['info_responsible']) : array();
974 974
 				$to_write['info_responsible'] = $values['info_responsible'];
975 975
 			}
976 976
 
@@ -978,11 +978,11 @@  discard block
 block discarded – undo
978 978
 			if (!$old && is_array($to_write['link_to']['to_id']) && count($to_write['link_to']['to_id']))
979 979
 			{
980 980
 				//echo "<p>writing links for new entry $info_id</p>\n"; _debug_array($content['link_to']['to_id']);
981
-				Link::link('infolog',$info_id,$to_write['link_to']['to_id']);
981
+				Link::link('infolog', $info_id, $to_write['link_to']['to_id']);
982 982
 				$values['link_to']['to_id'] = $info_id;
983 983
 			}
984 984
 			$this->write_check_links($to_write);
985
-			if(!$values['info_link_id'] || $values['info_link_id'] != $to_write['info_link_id'])
985
+			if (!$values['info_link_id'] || $values['info_link_id'] != $to_write['info_link_id'])
986 986
 			{
987 987
 				// Just got a link ID, need to save it
988 988
 				$this->so->write($to_write);
@@ -999,20 +999,20 @@  discard block
 block discarded – undo
999 999
 			}
1000 1000
 
1001 1001
 			// create (and remove) links in custom fields
1002
-			if(!is_array($old))
1002
+			if (!is_array($old))
1003 1003
 			{
1004 1004
 				$old = array();
1005 1005
 			}
1006
-			Api\Storage\Customfields::update_links('infolog',$values,$old,'info_id');
1006
+			Api\Storage\Customfields::update_links('infolog', $values, $old, 'info_id');
1007 1007
 
1008 1008
 			// Check for restore of deleted entry, restore held links
1009
-			if($old['info_status'] == 'deleted' && $values['info_status'] != 'deleted')
1009
+			if ($old['info_status'] == 'deleted' && $values['info_status'] != 'deleted')
1010 1010
 			{
1011 1011
 				Link::restore('infolog', $info_id);
1012 1012
 			}
1013 1013
 
1014 1014
 			// notify the link-class about the update, as other apps may be subscribt to it
1015
-			Link::notify_update('infolog',$info_id,$values);
1015
+			Link::notify_update('infolog', $info_id, $values);
1016 1016
 
1017 1017
 			// pre-cache the new values
1018 1018
 			self::set_link_cache($values);
@@ -1023,39 +1023,39 @@  discard block
 block discarded – undo
1023 1023
 				$this->tracking = new infolog_tracking($this);
1024 1024
 			}
1025 1025
 
1026
-			if ($old && ($missing_fields = array_diff_key($old,$values)))
1026
+			if ($old && ($missing_fields = array_diff_key($old, $values)))
1027 1027
 			{
1028 1028
 				// Some custom fields (multiselect with nothing selected) will be missing,
1029 1029
 				// and that's OK.  Don't put them back.
1030
-				foreach(array_keys($missing_fields) as $field)
1030
+				foreach (array_keys($missing_fields) as $field)
1031 1031
 				{
1032
-					if(array_key_exists($field, $values_in))
1032
+					if (array_key_exists($field, $values_in))
1033 1033
 					{
1034 1034
 						unset($missing_fields[$field]);
1035 1035
 					}
1036 1036
 				}
1037
-				$values = array_merge($values,$missing_fields);
1037
+				$values = array_merge($values, $missing_fields);
1038 1038
 			}
1039 1039
 			// Add keys missing in the $to_write array
1040
-			if (($missing_fields = array_diff_key($values,$to_write)))
1040
+			if (($missing_fields = array_diff_key($values, $to_write)))
1041 1041
 			{
1042
-				$to_write = array_merge($to_write,$missing_fields);
1042
+				$to_write = array_merge($to_write, $missing_fields);
1043 1043
 			}
1044
-			$this->tracking->track($to_write,$old,$this->user,$values['info_status'] == 'deleted' || $old['info_status'] == 'deleted',
1045
-				null,$skip_notification);
1044
+			$this->tracking->track($to_write, $old, $this->user, $values['info_status'] == 'deleted' || $old['info_status'] == 'deleted',
1045
+				null, $skip_notification);
1046 1046
 
1047 1047
 			if ($info_from_set) $values['info_from'] = '';
1048 1048
 
1049 1049
 			// Change new values back to user time before sending them back
1050
-			if($user2server)
1050
+			if ($user2server)
1051 1051
 			{
1052 1052
 				$this->time2time($values);
1053 1053
 			}
1054 1054
 			// merge changes (keeping extra values from the UI)
1055
-			$values_in = array_merge($values_in,$values);
1055
+			$values_in = array_merge($values_in, $values);
1056 1056
 
1057 1057
 			// Update modified timestamp of parent
1058
-			if($values['info_id_parent'] && $touch_modified)
1058
+			if ($values['info_id_parent'] && $touch_modified)
1059 1059
 			{
1060 1060
 				$parent = $this->read($values['info_id_parent'], true, 'server', true);
1061 1061
 				$this->write($parent, false, true, false, true, false, null, $ignore_acl);
@@ -1077,14 +1077,14 @@  discard block
 block discarded – undo
1077 1077
 		$old_link_id = (int)$values['info_link_id'];
1078 1078
 		$from = $values['info_from'];
1079 1079
 
1080
-		if($values['info_contact'] && !(
1080
+		if ($values['info_contact'] && !(
1081 1081
 				is_array($values['info_contact']) && $values['info_contact']['id'] == 'none'
1082 1082
 			) || (
1083 1083
 				is_array($values['info_contact']) && $values['info_contact']['id'] == 'none' &&
1084 1084
 				array_key_exists('search', $values['info_contact'])
1085 1085
 		))
1086 1086
 		{
1087
-			if(is_array($values['info_contact']))
1087
+			if (is_array($values['info_contact']))
1088 1088
 			{
1089 1089
 				// eTemplate2 returns the array all ready
1090 1090
 				$app = $values['info_contact']['app'];
@@ -1102,17 +1102,17 @@  discard block
 block discarded – undo
1102 1102
 			}
1103 1103
 			else if ($app && $id)
1104 1104
 			{
1105
-				if(!is_array($values['link_to']))
1105
+				if (!is_array($values['link_to']))
1106 1106
 				{
1107 1107
 					$values['link_to'] = array();
1108 1108
 				}
1109 1109
 				$values['info_link_id'] = (int)($info_link_id = Link::link(
1110 1110
 						'infolog',
1111 1111
 						$values['info_id'],
1112
-						$app,$id
1112
+						$app, $id
1113 1113
 				));
1114 1114
 				$values['info_from'] = Link::title($app, $id);
1115
-				if($values['pm_id'])
1115
+				if ($values['pm_id'])
1116 1116
 				{
1117 1117
 					// They just changed the contact, don't clear the project
1118 1118
 					unset($old_link_id);
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
 			$values['info_link_id'] = (int)($info_link_id = Link::link(
1137 1137
 				'infolog',
1138 1138
 				$values['info_id'],
1139
-				$app,$id
1139
+				$app, $id
1140 1140
 			));
1141 1141
 		}
1142 1142
 		else
@@ -1145,14 +1145,14 @@  discard block
 block discarded – undo
1145 1145
 			unset($values['info_contact']);
1146 1146
 			$values['info_from'] = $from ? $from : null;
1147 1147
 		}
1148
-		if($values['info_id'] && $values['old_pm_id'] !== $values['pm_id'])
1148
+		if ($values['info_id'] && $values['old_pm_id'] !== $values['pm_id'])
1149 1149
 		{
1150
-			Link::unlink(0,'infolog',$values['info_id'],0,'projectmanager',$values['old_pm_id']);
1150
+			Link::unlink(0, 'infolog', $values['info_id'], 0, 'projectmanager', $values['old_pm_id']);
1151 1151
 			// Project has changed, but link is not to project
1152
-			if($values['pm_id'])
1152
+			if ($values['pm_id'])
1153 1153
 			{
1154 1154
 				$link_id = Link::link('infolog', $values['info_id'], 'projectmanager', $values['pm_id']);
1155
-				if(!$values['info_link_id'])
1155
+				if (!$values['info_link_id'])
1156 1156
 				{
1157 1157
 					$values['info_link_id'] = $link_id;
1158 1158
 				}
@@ -1167,7 +1167,7 @@  discard block
 block discarded – undo
1167 1167
 		{
1168 1168
 			$link = Link::get_link($old_link_id);
1169 1169
 			// remove selected project, if removed link is that project
1170
-			if($link['link_app2'] == 'projectmanager' && $link['link_id2'] == $values['old_pm_id'])
1170
+			if ($link['link_app2'] == 'projectmanager' && $link['link_id2'] == $values['old_pm_id'])
1171 1171
 			{
1172 1172
 				unset($values['pm_id'], $values['old_pm_id']);
1173 1173
 			}
@@ -1187,9 +1187,9 @@  discard block
 block discarded – undo
1187 1187
 	 * @param int|array $info_id id
1188 1188
 	 * @return int|array number of subs
1189 1189
 	 */
1190
-	function anzSubs( $info_id )
1190
+	function anzSubs($info_id)
1191 1191
 	{
1192
-		return $this->so->anzSubs( $info_id );
1192
+		return $this->so->anzSubs($info_id);
1193 1193
 	}
1194 1194
 
1195 1195
 	/**
@@ -1206,23 +1206,23 @@  discard block
 block discarded – undo
1206 1206
 	 * @param boolean $no_acl =false true: ignore all acl
1207 1207
 	 * @return array with id's as key of the matching log-entries
1208 1208
 	 */
1209
-	function &search(&$query, $no_acl=false)
1209
+	function &search(&$query, $no_acl = false)
1210 1210
 	{
1211 1211
 		//error_log(__METHOD__.'('.array2string($query).')');
1212 1212
 
1213
-		if($query['filter'] == 'bydate')
1213
+		if ($query['filter'] == 'bydate')
1214 1214
 		{
1215 1215
 			if (is_int($query['startdate'])) $query['col_filter'][] = 'info_startdate >= '.$GLOBALS['egw']->db->quote($query['startdate']);
1216
-			if (is_int($query['enddate'])) $query['col_filter'][] = 'info_startdate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1);
1216
+			if (is_int($query['enddate'])) $query['col_filter'][] = 'info_startdate <= '.$GLOBALS['egw']->db->quote($query['enddate'] + (60 * 60 * 24) - 1);
1217 1217
 		}
1218 1218
 		elseif ($query['filter'] == 'duedate')
1219 1219
 		{
1220 1220
 			if (is_int($query['startdate'])) $query['col_filter'][] = 'info_enddate >= '.$GLOBALS['egw']->db->quote($query['startdate']);
1221
-			if (is_int($query['enddate'])) $query['col_filter'][] = 'info_enddate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1);
1221
+			if (is_int($query['enddate'])) $query['col_filter'][] = 'info_enddate <= '.$GLOBALS['egw']->db->quote($query['enddate'] + (60 * 60 * 24) - 1);
1222 1222
 		}
1223 1223
 		elseif ($query['filter'] == 'private')
1224 1224
 		{
1225
-			$query['col_filter'][] = 'info_access = ' . $GLOBALS['egw']->db->quote('private');
1225
+			$query['col_filter'][] = 'info_access = '.$GLOBALS['egw']->db->quote('private');
1226 1226
 		}
1227 1227
 		if (!isset($query['date_format']) || $query['date_format'] != 'server')
1228 1228
 		{
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
 				{
1233 1233
 					if (!empty($query['col_filter'][$key]))
1234 1234
 					{
1235
-						$query['col_filter'][$key] = Api\DateTime::user2server($query['col_filter'][$key],'ts');
1235
+						$query['col_filter'][$key] = Api\DateTime::user2server($query['col_filter'][$key], 'ts');
1236 1236
 					}
1237 1237
 				}
1238 1238
 			}
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
 		{
1246 1246
 			foreach ($ret as $id => &$data)
1247 1247
 			{
1248
-				if (!$no_acl && !$this->check_access($data,Acl::READ))
1248
+				if (!$no_acl && !$this->check_access($data, Acl::READ))
1249 1249
 				{
1250 1250
 					unset($ret[$id]);
1251 1251
 					continue;
@@ -1261,7 +1261,7 @@  discard block
 block discarded – undo
1261 1261
 							if ($time->format('Hi') == '0000')
1262 1262
 							{
1263 1263
 								// we keep dates the same in user-time
1264
-								$arr = Api\DateTime::to($time,'array');
1264
+								$arr = Api\DateTime::to($time, 'array');
1265 1265
 								$time = new Api\DateTime($arr, Api\DateTime::$user_timezone);
1266 1266
 							}
1267 1267
 							else
@@ -1269,7 +1269,7 @@  discard block
 block discarded – undo
1269 1269
 								$time->setTimezone(Api\DateTime::$user_timezone);
1270 1270
 							}
1271 1271
 						}
1272
-						$data[$key] = Api\DateTime::to($time,'ts');
1272
+						$data[$key] = Api\DateTime::to($time, 'ts');
1273 1273
 					}
1274 1274
 				}
1275 1275
 				// pre-cache title and file access
@@ -1286,7 +1286,7 @@  discard block
 block discarded – undo
1286 1286
 	 * @param array $filter = array('filter'=>'own','info_type'=>'task')
1287 1287
 	 * @return string
1288 1288
 	 */
1289
-	public function getctag(array $filter=array('filter'=>'own','info_type'=>'task'))
1289
+	public function getctag(array $filter = array('filter'=>'own', 'info_type'=>'task'))
1290 1290
 	{
1291 1291
 		$filter += array(
1292 1292
 			'order'			=> 'info_datemodified',
@@ -1298,7 +1298,7 @@  discard block
 block discarded – undo
1298 1298
 		// we need to query deleted entries too for a ctag!
1299 1299
 		$filter['filter'] .= '+deleted';
1300 1300
 
1301
-		$result =& $this->search($filter);
1301
+		$result = & $this->search($filter);
1302 1302
 
1303 1303
 		if (empty($result)) return 'EGw-empty-wGE';
1304 1304
 
@@ -1320,12 +1320,12 @@  discard block
 block discarded – undo
1320 1320
 	 * @param string $_date
1321 1321
 	 * @return array $content array for uiinfolog
1322 1322
 	 */
1323
-	function import_mail($_addresses,$_subject,$_message,$_attachments,$_date)
1323
+	function import_mail($_addresses, $_subject, $_message, $_attachments, $_date)
1324 1324
 	{
1325
-		foreach($_addresses as $address)
1325
+		foreach ($_addresses as $address)
1326 1326
 		{
1327 1327
 			$names[] = $address['name'];
1328
-			$emails[] =$address['email'];
1328
+			$emails[] = $address['email'];
1329 1329
 		}
1330 1330
 
1331 1331
 		$type = isset($this->enums['type']['email']) ? 'email' : 'note';
@@ -1333,7 +1333,7 @@  discard block
 block discarded – undo
1333 1333
 		$info = array(
1334 1334
 			'info_id' => 0,
1335 1335
 			'info_type' => $type,
1336
-			'info_from' => implode(', ',$names) . implode(', ', $emails),
1336
+			'info_from' => implode(', ', $names).implode(', ', $emails),
1337 1337
 			'info_subject' => $_subject,
1338 1338
 			'info_des' => $_message,
1339 1339
 			'info_startdate' => Api\DateTime::server2user($_date),
@@ -1352,16 +1352,16 @@  discard block
 block discarded – undo
1352 1352
 		$contacts = array();
1353 1353
 		foreach ($emails as $mailadr)
1354 1354
 		{
1355
-			$contacts = array_merge($contacts,(array)$addressbook->search(
1355
+			$contacts = array_merge($contacts, (array)$addressbook->search(
1356 1356
 				array(
1357 1357
 					'email' => $mailadr,
1358 1358
 					'email_home' => $mailadr
1359
-				),True,'','','',false,'OR',false,null,'',false));
1359
+				), True, '', '', '', false, 'OR', false, null, '', false));
1360 1360
 		}
1361 1361
 		if (!$contacts || !is_array($contacts) || !is_array($contacts[0]))
1362 1362
 		{
1363
-			$info['msg'] = lang('Attention: No Contact with address %1 found.',$info['info_from']);
1364
-			$info['info_custom_from'] = true;	// show the info_from line and NOT only the link
1363
+			$info['msg'] = lang('Attention: No Contact with address %1 found.', $info['info_from']);
1364
+			$info['info_custom_from'] = true; // show the info_from line and NOT only the link
1365 1365
 		}
1366 1366
 		else
1367 1367
 		{
@@ -1371,21 +1371,21 @@  discard block
 block discarded – undo
1371 1371
 			// create the rest a "ordinary" links
1372 1372
 			foreach ($contacts as $contact)
1373 1373
 			{
1374
-				Link::link('infolog',$info['link_to']['to_id'],'addressbook',$contact['id']);
1374
+				Link::link('infolog', $info['link_to']['to_id'], 'addressbook', $contact['id']);
1375 1375
 			}
1376 1376
 		}
1377 1377
 		if (is_array($_attachments))
1378 1378
 		{
1379 1379
 			foreach ($_attachments as $attachment)
1380 1380
 			{
1381
-				if($attachment['egw_data'])
1381
+				if ($attachment['egw_data'])
1382 1382
 				{
1383
-					Link::link('infolog',$info['link_to']['to_id'],Link::DATA_APPNAME,  $attachment);
1383
+					Link::link('infolog', $info['link_to']['to_id'], Link::DATA_APPNAME, $attachment);
1384 1384
 				}
1385
-				else if(is_readable($attachment['tmp_name']) ||
1385
+				else if (is_readable($attachment['tmp_name']) ||
1386 1386
 					(Vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs'))
1387 1387
 				{
1388
-					Link::link('infolog',$info['link_to']['to_id'],'file',  $attachment);
1388
+					Link::link('infolog', $info['link_to']['to_id'], 'file', $attachment);
1389 1389
 				}
1390 1390
 			}
1391 1391
 		}
@@ -1404,14 +1404,14 @@  discard block
 block discarded – undo
1404 1404
 	{
1405 1405
 		if (!is_array($info))
1406 1406
 		{
1407
-			$info = $this->read( $info,false );
1407
+			$info = $this->read($info, false);
1408 1408
 		}
1409 1409
 		if (!$info)
1410 1410
 		{
1411 1411
 			return $info;
1412 1412
 		}
1413
-		$title = !empty($info['info_subject']) ? $info['info_subject'] :self::subject_from_des($info['info_descr']);
1414
-		return $title.($GLOBALS['egw_info']['user']['preferences']['infolog']['show_id']?' (#'.$info['info_id'].')':'');
1413
+		$title = !empty($info['info_subject']) ? $info['info_subject'] : self::subject_from_des($info['info_descr']);
1414
+		return $title.($GLOBALS['egw_info']['user']['preferences']['infolog']['show_id'] ? ' (#'.$info['info_id'].')' : '');
1415 1415
 	}
1416 1416
 
1417 1417
 	/**
@@ -1422,15 +1422,15 @@  discard block
 block discarded – undo
1422 1422
 	function link_titles(array $ids)
1423 1423
 	{
1424 1424
 		$titles = array();
1425
-		foreach ($this->search($params=array(
1425
+		foreach ($this->search($params = array(
1426 1426
 			'col_filter' => array('info_id' => $ids),
1427 1427
 		)) as $info)
1428 1428
 		{
1429 1429
 			$titles[$info['info_id']] = $this->link_title($info);
1430 1430
 		}
1431
-		foreach (array_diff($ids,array_keys($titles)) as $id)
1431
+		foreach (array_diff($ids, array_keys($titles)) as $id)
1432 1432
 		{
1433
-			$titles[$id] = false;	// we assume every not returned entry to be not readable, as we notify the link class about all deletes
1433
+			$titles[$id] = false; // we assume every not returned entry to be not readable, as we notify the link class about all deletes
1434 1434
 		}
1435 1435
 		return $titles;
1436 1436
 	}
@@ -1457,7 +1457,7 @@  discard block
 block discarded – undo
1457 1457
 		$content = array();
1458 1458
 		if (is_array($ids))
1459 1459
 		{
1460
-			foreach(array_keys($ids) as $id)
1460
+			foreach (array_keys($ids) as $id)
1461 1461
 			{
1462 1462
 				$content[$id] = $this->link_title($id);
1463 1463
 			}
@@ -1474,10 +1474,10 @@  discard block
 block discarded – undo
1474 1474
 	 * @param int $user = null for which user to check, default current user
1475 1475
 	 * @return boolean true if access is granted or false otherwise
1476 1476
 	 */
1477
-	function file_access($id,$check,$rel_path=null,$user=null)
1477
+	function file_access($id, $check, $rel_path = null, $user = null)
1478 1478
 	{
1479
-		unset($rel_path);	// not used
1480
-		return $this->check_access($id,$check,0,$user);
1479
+		unset($rel_path); // not used
1480
+		return $this->check_access($id, $check, 0, $user);
1481 1481
 	}
1482 1482
 
1483 1483
 	/**
@@ -1487,10 +1487,9 @@  discard block
 block discarded – undo
1487 1487
 	 */
1488 1488
 	function set_link_cache(array $info)
1489 1489
 	{
1490
-		Link::set_cache('infolog',$info['info_id'],
1490
+		Link::set_cache('infolog', $info['info_id'],
1491 1491
 			$this->link_title($info),
1492
-			$this->file_access($info,Acl::EDIT) ? EGW_ACL_READ|EGW_ACL_EDIT :
1493
-			($this->file_access($info,Acl::READ) ? Acl::READ : 0));
1492
+			$this->file_access($info, Acl::EDIT) ? EGW_ACL_READ|EGW_ACL_EDIT : ($this->file_access($info, Acl::READ) ? Acl::READ : 0));
1494 1493
 	}
1495 1494
 
1496 1495
 	/**
@@ -1504,8 +1503,8 @@  discard block
 block discarded – undo
1504 1503
 	function cal_to_include($args)
1505 1504
 	{
1506 1505
 		//echo "<p>cal_to_include("; print_r($args); echo ")</p>\n";
1507
-		$user = (int) $args['owner'];
1508
-		if ($user <= 0 && !checkdate($args['month'],$args['day'],$args['year']))
1506
+		$user = (int)$args['owner'];
1507
+		if ($user <= 0 && !checkdate($args['month'], $args['day'], $args['year']))
1509 1508
 		{
1510 1509
 			return False;
1511 1510
 		}
@@ -1513,7 +1512,7 @@  discard block
 block discarded – undo
1513 1512
 
1514 1513
 		$do_events = $args['location'] == 'calendar_include_events';
1515 1514
 		$to_include = array();
1516
-		$date_wanted = sprintf('%04d/%02d/%02d',$args['year'],$args['month'],$args['day']);
1515
+		$date_wanted = sprintf('%04d/%02d/%02d', $args['year'], $args['month'], $args['day']);
1517 1516
 		$query = array(
1518 1517
 			'order' => $args['order'] ? $args['order'] : 'info_startdate',
1519 1518
 			'sort'  => $args['sort'] ? $args['sort'] : ($do_events ? 'ASC' : 'DESC'),
@@ -1522,34 +1521,34 @@  discard block
 block discarded – undo
1522 1521
 		);
1523 1522
 		if ($GLOBALS['egw_info']['user']['preferences']['infolog']['cal_show'] || $GLOBALS['egw_info']['user']['preferences']['infolog']['cal_show'] === '0')
1524 1523
 		{
1525
-			$query['col_filter']['info_type'] = explode(',',$GLOBALS['egw_info']['user']['preferences']['infolog']['cal_show']);
1524
+			$query['col_filter']['info_type'] = explode(',', $GLOBALS['egw_info']['user']['preferences']['infolog']['cal_show']);
1526 1525
 		}
1527 1526
 		elseif ($this->customfields && !$GLOBALS['egw_info']['user']['preferences']['infolog']['cal_show_custom'])
1528 1527
 		{
1529
-			$query['col_filter']['info_type'] = array('task','phone','note','email');
1528
+			$query['col_filter']['info_type'] = array('task', 'phone', 'note', 'email');
1530 1529
 		}
1531 1530
 		while ($infos = $this->search($query))
1532 1531
 		{
1533 1532
 			foreach ($infos as $info)
1534 1533
 			{
1535
-				$start = new Api\DateTime($info['info_startdate'],Api\DateTime::$user_timezone);
1534
+				$start = new Api\DateTime($info['info_startdate'], Api\DateTime::$user_timezone);
1536 1535
 				$title = ($do_events ? $start->format(false).' ' : '').
1537 1536
 					$info['info_subject'];
1538
-				$view = Link::view('infolog',$info['info_id']);
1537
+				$view = Link::view('infolog', $info['info_id']);
1539 1538
 				$size = null;
1540
-				$edit = Link::edit('infolog',$info['info_id'], $size);
1539
+				$edit = Link::edit('infolog', $info['info_id'], $size);
1541 1540
 				$edit['size'] = $size;
1542
-				$content=array();
1541
+				$content = array();
1543 1542
 				$status = $this->status[$info['info_type']][$info['info_status']];
1544 1543
 				$icons = array();
1545
-				foreach(array(
1544
+				foreach (array(
1546 1545
 					$info['info_type'] => 'navbar',
1547 1546
 					$status => 'status'
1548 1547
 				) as $icon => $default)
1549 1548
 				{
1550
-					$icons[Api\Image::find('infolog',$icon) ? $icon : $default] = $icon;
1549
+					$icons[Api\Image::find('infolog', $icon) ? $icon : $default] = $icon;
1551 1550
 				}
1552
-				$content[] = Api\Html::a_href($title,$view);
1551
+				$content[] = Api\Html::a_href($title, $view);
1553 1552
 				$html = Api\Html::table(array(1 => $content));
1554 1553
 
1555 1554
 				$to_include[] = array(
@@ -1562,9 +1561,9 @@  discard block
 block discarded – undo
1562 1561
 					'content'   => $html,
1563 1562
 				);
1564 1563
 			}
1565
-			if ($query['total'] <= ($query['start']+=count($infos)))
1564
+			if ($query['total'] <= ($query['start'] += count($infos)))
1566 1565
 			{
1567
-				break;	// no more availible
1566
+				break; // no more availible
1568 1567
 			}
1569 1568
 		}
1570 1569
 		//echo "boinfolog::cal_to_include("; print_r($args); echo ")<pre>"; print_r($to_include); echo "</pre>\n";
@@ -1587,7 +1586,7 @@  discard block
 block discarded – undo
1587 1586
 				'cols' => 'main.info_id,info_type,info_status,info_percent,info_id_parent',
1588 1587
 			);
1589 1588
 			$infos = array();
1590
-			foreach($this->search($query) as $row)
1589
+			foreach ($this->search($query) as $row)
1591 1590
 			{
1592 1591
 				$infos[$row['info_id']] = array(
1593 1592
 					'status' => $row['info_type'] != 'phone' && $row['info_status'] == 'ongoing' ?
@@ -1596,16 +1595,16 @@  discard block
 block discarded – undo
1596 1595
 						'ongoing' : 'infolog/'.$row['info_status'],
1597 1596
 					'class'  => $row['info_id_parent'] ? 'infolog_rowHasParent' : null,
1598 1597
 				);
1599
-				if (Api\Image::find('infolog', $icon=$row['info_type'].'_element') ||
1600
-					Api\Image::find('infolog', $icon=$row['info_type']))
1598
+				if (Api\Image::find('infolog', $icon = $row['info_type'].'_element') ||
1599
+					Api\Image::find('infolog', $icon = $row['info_type']))
1601 1600
 				{
1602 1601
 					$infos[$row['info_id']]['icon'] = 'infolog/'.$icon;
1603 1602
 				}
1604 1603
 			}
1605 1604
 			$anzSubs = $this->anzSubs(array_keys($infos));
1606
-			if($anzSubs && is_array($anzSubs))
1605
+			if ($anzSubs && is_array($anzSubs))
1607 1606
 			{
1608
-				foreach($anzSubs as $info_id => $subs)
1607
+				foreach ($anzSubs as $info_id => $subs)
1609 1608
 				{
1610 1609
 					if ($subs) $infos[$info_id]['class'] .= ' infolog_rowHasSubs';
1611 1610
 				}
@@ -1625,18 +1624,18 @@  discard block
 block discarded – undo
1625 1624
 	 *  by the ones the user normally does not see due to category permissions - used to preserve categories
1626 1625
 	 * @return array category ids (found, added and preserved categories)
1627 1626
 	 */
1628
-	function find_or_add_categories($catname_list, $info_id=-1)
1627
+	function find_or_add_categories($catname_list, $info_id = -1)
1629 1628
 	{
1630 1629
 		if (!is_object($this->categories))
1631 1630
 		{
1632
-			$this->categories = new Api\Categories($this->user,'infolog');
1631
+			$this->categories = new Api\Categories($this->user, 'infolog');
1633 1632
 		}
1634 1633
 		$old_cats_preserve = array();
1635 1634
 		if ($info_id && $info_id > 0)
1636 1635
 		{
1637 1636
 			// preserve Api\Categories without users read access
1638 1637
 			$old_infolog = $this->read($info_id);
1639
-			$old_categories = explode(',',$old_infolog['info_cat']);
1638
+			$old_categories = explode(',', $old_infolog['info_cat']);
1640 1639
 			if (is_array($old_categories) && count($old_categories) > 0)
1641 1640
 			{
1642 1641
 				foreach ($old_categories as $cat_id)
@@ -1697,15 +1696,15 @@  discard block
 block discarded – undo
1697 1696
 	{
1698 1697
 		if (!is_object($this->categories))
1699 1698
 		{
1700
-			$this->categories = new Api\Categories($this->user,'infolog');
1699
+			$this->categories = new Api\Categories($this->user, 'infolog');
1701 1700
 		}
1702 1701
 
1703 1702
 		if (!is_array($cat_id_list))
1704 1703
 		{
1705
-			$cat_id_list = explode(',',$cat_id_list);
1704
+			$cat_id_list = explode(',', $cat_id_list);
1706 1705
 		}
1707 1706
 		$cat_list = array();
1708
-		foreach($cat_id_list as $cat_id)
1707
+		foreach ($cat_id_list as $cat_id)
1709 1708
 		{
1710 1709
 			if ($cat_id && $this->categories->check_perms(Acl::READ, $cat_id) &&
1711 1710
 					($cat_name = $this->categories->id2name($cat_id)) && $cat_name != '--')
@@ -1732,19 +1731,19 @@  discard block
 block discarded – undo
1732 1731
 
1733 1732
 		$save_account_id = $GLOBALS['egw_info']['user']['account_id'];
1734 1733
 		$save_prefs      = $GLOBALS['egw_info']['user']['preferences'];
1735
-		foreach($users as $user)
1734
+		foreach ($users as $user)
1736 1735
 		{
1737
-			if (!($email = $GLOBALS['egw']->accounts->id2name($user,'account_email'))) continue;
1736
+			if (!($email = $GLOBALS['egw']->accounts->id2name($user, 'account_email'))) continue;
1738 1737
 			// create the enviroment for $user
1739 1738
 			$this->user = $GLOBALS['egw_info']['user']['account_id'] = $user;
1740 1739
 			$GLOBALS['egw']->preferences->__construct($user);
1741 1740
 			$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository();
1742 1741
 			$GLOBALS['egw']->acl->__construct($user);
1743
-			$this->grants = $GLOBALS['egw']->acl->get_grants('infolog',$this->group_owners ? $this->group_owners : true);
1744
-			$this->so = new infolog_so($this->grants);	// so caches it's filters
1742
+			$this->grants = $GLOBALS['egw']->acl->get_grants('infolog', $this->group_owners ? $this->group_owners : true);
1743
+			$this->so = new infolog_so($this->grants); // so caches it's filters
1745 1744
 
1746 1745
 			$notified_info_ids = array();
1747
-			foreach(array(
1746
+			foreach (array(
1748 1747
 				'notify_due_responsible'   => 'open-responsible-enddate',
1749 1748
 				'notify_due_delegated'     => 'open-delegated-enddate',
1750 1749
 				'notify_start_responsible' => 'open-responsible-date',
@@ -1753,44 +1752,44 @@  discard block
 block discarded – undo
1753 1752
 			{
1754 1753
 				if (!($pref_value = $GLOBALS['egw_info']['user']['preferences']['infolog'][$pref])) continue;
1755 1754
 
1756
-				$filter .= date('Y-m-d',time()+24*60*60*(int)$pref_value);
1755
+				$filter .= date('Y-m-d', time() + 24 * 60 * 60 * (int)$pref_value);
1757 1756
 				//error_log(__METHOD__."() checking with filter '$filter' ($pref_value) for user $user ($email)");
1758 1757
 
1759 1758
 				$params = array('filter' => $filter, 'custom_fields' => true, 'subs' => true);
1760
-				foreach($this->so->search($params) as $info)
1759
+				foreach ($this->so->search($params) as $info)
1761 1760
 				{
1762 1761
 					// check if we already send a notification for that infolog entry, eg. starting and due on same day
1763
-					if (in_array($info['info_id'],$notified_info_ids)) continue;
1762
+					if (in_array($info['info_id'], $notified_info_ids)) continue;
1764 1763
 
1765 1764
 					if (is_null($this->tracking) || $this->tracking->user != $user)
1766 1765
 					{
1767 1766
 						$this->tracking = new infolog_tracking($this);
1768 1767
 					}
1769
-					switch($pref)
1768
+					switch ($pref)
1770 1769
 					{
1771 1770
 						case 'notify_due_responsible':
1772
-							$info['prefix'] = lang('Due %1',$this->enums['type'][$info['info_type']]);
1773
-							$info['message'] = lang('%1 you are responsible for is due at %2',$this->enums['type'][$info['info_type']],
1774
-								$this->tracking->datetime($info['info_enddate'],false));
1771
+							$info['prefix'] = lang('Due %1', $this->enums['type'][$info['info_type']]);
1772
+							$info['message'] = lang('%1 you are responsible for is due at %2', $this->enums['type'][$info['info_type']],
1773
+								$this->tracking->datetime($info['info_enddate'], false));
1775 1774
 							break;
1776 1775
 						case 'notify_due_delegated':
1777
-							$info['prefix'] = lang('Due %1',$this->enums['type'][$info['info_type']]);
1778
-							$info['message'] = lang('%1 you delegated is due at %2',$this->enums['type'][$info['info_type']],
1779
-								$this->tracking->datetime($info['info_enddate'],false));
1776
+							$info['prefix'] = lang('Due %1', $this->enums['type'][$info['info_type']]);
1777
+							$info['message'] = lang('%1 you delegated is due at %2', $this->enums['type'][$info['info_type']],
1778
+								$this->tracking->datetime($info['info_enddate'], false));
1780 1779
 							break;
1781 1780
 						case 'notify_start_responsible':
1782
-							$info['prefix'] = lang('Starting %1',$this->enums['type'][$info['info_type']]);
1783
-							$info['message'] = lang('%1 you are responsible for is starting at %2',$this->enums['type'][$info['info_type']],
1784
-								$this->tracking->datetime($info['info_startdate'],null));
1781
+							$info['prefix'] = lang('Starting %1', $this->enums['type'][$info['info_type']]);
1782
+							$info['message'] = lang('%1 you are responsible for is starting at %2', $this->enums['type'][$info['info_type']],
1783
+								$this->tracking->datetime($info['info_startdate'], null));
1785 1784
 							break;
1786 1785
 						case 'notify_start_delegated':
1787
-							$info['prefix'] = lang('Starting %1',$this->enums['type'][$info['info_type']]);
1788
-							$info['message'] = lang('%1 you delegated is starting at %2',$this->enums['type'][$info['info_type']],
1789
-								$this->tracking->datetime($info['info_startdate'],null));
1786
+							$info['prefix'] = lang('Starting %1', $this->enums['type'][$info['info_type']]);
1787
+							$info['message'] = lang('%1 you delegated is starting at %2', $this->enums['type'][$info['info_type']],
1788
+								$this->tracking->datetime($info['info_startdate'], null));
1790 1789
 							break;
1791 1790
 					}
1792 1791
 					//error_log("notifiying $user($email) about $info[info_subject]: $info[message]");
1793
-					$this->tracking->send_notification($info,null,$email,$user,$pref);
1792
+					$this->tracking->send_notification($info, null, $email, $user, $pref);
1794 1793
 
1795 1794
 					$notified_info_ids[] = $info['info_id'];
1796 1795
 				}
@@ -1853,7 +1852,7 @@  discard block
 block discarded – undo
1853 1852
 	 * @param string $x_infolog_status preserved original infolog status
1854 1853
 	 * @return string
1855 1854
 	 */
1856
-	function vtodo2status($_vtodo_status,$x_infolog_status=null)
1855
+	function vtodo2status($_vtodo_status, $x_infolog_status = null)
1857 1856
 	{
1858 1857
 		$vtodo_status = strtoupper($_vtodo_status);
1859 1858
 
@@ -1877,7 +1876,7 @@  discard block
 block discarded – undo
1877 1876
 	 * @param array &$icons = null on return name of icons
1878 1877
 	 * @return array value => (commaseparated) translations
1879 1878
 	 */
1880
-	function get_status($type=null, array &$icons=null)
1879
+	function get_status($type = null, array &$icons = null)
1881 1880
 	{
1882 1881
 		// if filtered by type, show only the stati of the filtered type
1883 1882
 		if ($type && isset($this->status[$type]))
@@ -1887,16 +1886,16 @@  discard block
 block discarded – undo
1887 1886
 		else	// show all stati
1888 1887
 		{
1889 1888
 			$statis = $icons = array();
1890
-			foreach($this->status as $t => $stati)
1889
+			foreach ($this->status as $t => $stati)
1891 1890
 			{
1892 1891
 				if ($t === 'defaults') continue;
1893
-				foreach($stati as $val => $label)
1892
+				foreach ($stati as $val => $label)
1894 1893
 				{
1895 1894
 					$statis[$val][$label] = lang($label);
1896 1895
 					if (!isset($icons[$val])) $icons[$val] = $label;
1897 1896
 				}
1898 1897
 			}
1899
-			foreach($statis as $val => &$labels)
1898
+			foreach ($statis as $val => &$labels)
1900 1899
 			{
1901 1900
 				$labels = implode(', ', $labels);
1902 1901
 			}
@@ -1912,7 +1911,7 @@  discard block
 block discarded – undo
1912 1911
 	 */
1913 1912
 	function activate($info)
1914 1913
 	{
1915
-		switch((int)$info['info_percent'])
1914
+		switch ((int)$info['info_percent'])
1916 1915
 		{
1917 1916
 			case 0:		return 'not-started';
1918 1917
 			case 100:	return 'done';
@@ -1931,8 +1930,8 @@  discard block
 block discarded – undo
1931 1930
 		#Horde::logMessage("getParentID($_guid)",  __FILE__, __LINE__, PEAR_LOG_DEBUG);
1932 1931
 
1933 1932
 		$parentID = False;
1934
-		$myfilter = array('col_filter' => array('info_uid'=>$_guid)) ;
1935
-		if ($_guid && ($found=$this->search($myfilter)) && ($uidmatch = array_shift($found)))
1933
+		$myfilter = array('col_filter' => array('info_uid'=>$_guid));
1934
+		if ($_guid && ($found = $this->search($myfilter)) && ($uidmatch = array_shift($found)))
1936 1935
 		{
1937 1936
 			$parentID = $uidmatch['info_id'];
1938 1937
 		}
@@ -1949,7 +1948,7 @@  discard block
 block discarded – undo
1949 1948
 	 *
1950 1949
 	 * @return array of infolog_ids of matching entries
1951 1950
 	 */
1952
-	function findInfo($infoData, $relax=false, $tzid=null)
1951
+	function findInfo($infoData, $relax = false, $tzid = null)
1953 1952
 	{
1954 1953
 		$foundInfoLogs = array();
1955 1954
 		$filter = array();
@@ -1957,7 +1956,7 @@  discard block
 block discarded – undo
1957 1956
 		if ($this->log)
1958 1957
 		{
1959 1958
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1960
-				. '('. ($relax ? 'RELAX, ': 'EXACT, ') . $tzid . ')[InfoData]:'
1959
+				. '('.($relax ? 'RELAX, ' : 'EXACT, ').$tzid.')[InfoData]:'
1961 1960
 				. array2string($infoData));
1962 1961
 		}
1963 1962
 
@@ -1976,9 +1975,9 @@  discard block
 block discarded – undo
1976 1975
 		if (!$relax && !empty($infoData['info_uid']))
1977 1976
 		{
1978 1977
 			$filter = array('col_filter' => array('info_uid' => $infoData['info_uid']));
1979
-			foreach($this->so->search($filter) as $egwData)
1978
+			foreach ($this->so->search($filter) as $egwData)
1980 1979
 			{
1981
-				if (!$this->check_access($egwData,Acl::READ)) continue;
1980
+				if (!$this->check_access($egwData, Acl::READ)) continue;
1982 1981
 				$foundInfoLogs[$egwData['info_id']] = $egwData['info_id'];
1983 1982
 			}
1984 1983
 			return $foundInfoLogs;
@@ -2006,7 +2005,7 @@  discard block
 block discarded – undo
2006 2005
 				$text = '';
2007 2006
 				foreach ($matches as $chunk)
2008 2007
 				{
2009
-					if (strlen($text) <  strlen($chunk[0]))
2008
+					if (strlen($text) < strlen($chunk[0]))
2010 2009
 					{
2011 2010
 						$text = $chunk[0];
2012 2011
 					}
@@ -2030,7 +2029,7 @@  discard block
 block discarded – undo
2030 2029
 
2031 2030
 		foreach ($this->so->search($filter) as $itemID => $egwData)
2032 2031
 		{
2033
-			if (!$this->check_access($egwData,Acl::READ)) continue;
2032
+			if (!$this->check_access($egwData, Acl::READ)) continue;
2034 2033
 
2035 2034
 			switch ($infoData['info_type'])
2036 2035
 			{
@@ -2047,7 +2046,7 @@  discard block
 block discarded – undo
2047 2046
 						{
2048 2047
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2049 2048
 								. '()[location mismatch]: '
2050
-								. $infoData['info_location'] . ' <> ' . $egwData['info_location']);
2049
+								. $infoData['info_location'].' <> '.$egwData['info_location']);
2051 2050
 						}
2052 2051
 						continue;
2053 2052
 					}
@@ -2064,7 +2063,7 @@  discard block
 block discarded – undo
2064 2063
 						{
2065 2064
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2066 2065
 								. '()[description mismatch]: '
2067
-								. $infoData['info_des'] . ' <> ' . $egwData['info_des']);
2066
+								. $infoData['info_des'].' <> '.$egwData['info_des']);
2068 2067
 						}
2069 2068
 						continue;
2070 2069
 					}
@@ -2078,7 +2077,7 @@  discard block
 block discarded – undo
2078 2077
 			if ($this->log)
2079 2078
 			{
2080 2079
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2081
-					. '()[FOUND]:' . array2string($foundInfoLogs));
2080
+					. '()[FOUND]:'.array2string($foundInfoLogs));
2082 2081
 			}
2083 2082
 			return $foundInfoLogs;
2084 2083
 		}
@@ -2103,7 +2102,7 @@  discard block
 block discarded – undo
2103 2102
 		//	__FILE__, __LINE__, PEAR_LOG_DEBUG);
2104 2103
 		foreach ($this->so->search($filter) as $itemID => $egwData)
2105 2104
 		{
2106
-			if (!$this->check_access($egwData,Acl::READ)) continue;
2105
+			if (!$this->check_access($egwData, Acl::READ)) continue;
2107 2106
 			// Horde::logMessage("findVTODO Trying\n"
2108 2107
 			//	. print_r($egwData, true),
2109 2108
 			//	__FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -2115,7 +2114,7 @@  discard block
 block discarded – undo
2115 2114
 				{
2116 2115
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2117 2116
 						. '()[category mismatch]: '
2118
-						. $infoData['info_cat'] . ' <> ' . $egwData['info_cat']);
2117
+						. $infoData['info_cat'].' <> '.$egwData['info_cat']);
2119 2118
 				}
2120 2119
 				continue;
2121 2120
 			}
@@ -2125,15 +2124,15 @@  discard block
 block discarded – undo
2125 2124
 				if (isset($egwData['info_startdate']) && $egwData['info_startdate'])
2126 2125
 				{
2127 2126
 					// We compare the date only
2128
-					$taskTime = new Api\DateTime($infoData['info_startdate'],Api\DateTime::$server_timezone);
2129
-					$egwTime = new Api\DateTime($egwData['info_startdate'],Api\DateTime::$server_timezone);
2127
+					$taskTime = new Api\DateTime($infoData['info_startdate'], Api\DateTime::$server_timezone);
2128
+					$egwTime = new Api\DateTime($egwData['info_startdate'], Api\DateTime::$server_timezone);
2130 2129
 					if ($taskTime->format('Ymd') != $egwTime->format('Ymd'))
2131 2130
 					{
2132 2131
 						if ($this->log)
2133 2132
 						{
2134 2133
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2135 2134
 								. '()[start mismatch]: '
2136
-								. $taskTime->format('Ymd') . ' <> ' . $egwTime->format('Ymd'));
2135
+								. $taskTime->format('Ymd').' <> '.$egwTime->format('Ymd'));
2137 2136
 						}
2138 2137
 						continue;
2139 2138
 					}
@@ -2160,7 +2159,7 @@  discard block
 block discarded – undo
2160 2159
 					{
2161 2160
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2162 2161
 							. '()[status mismatch]: '
2163
-							. $infoData['info_status'] . ' <> ' . $egwData['info_status']);
2162
+							. $infoData['info_status'].' <> '.$egwData['info_status']);
2164 2163
 					}
2165 2164
 					continue;
2166 2165
 				}
@@ -2170,15 +2169,15 @@  discard block
 block discarded – undo
2170 2169
 					if (isset($egwData['info_enddate']) && $egwData['info_enddate'])
2171 2170
 					{
2172 2171
 						// We compare the date only
2173
-						$taskTime = new Api\DateTime($infoData['info_enddate'],Api\DateTime::$server_timezone);
2174
-						$egwTime = new Api\DateTime($egwData['info_enddate'],Api\DateTime::$server_timezone);
2172
+						$taskTime = new Api\DateTime($infoData['info_enddate'], Api\DateTime::$server_timezone);
2173
+						$egwTime = new Api\DateTime($egwData['info_enddate'], Api\DateTime::$server_timezone);
2175 2174
 						if ($taskTime->format('Ymd') != $egwTime->format('Ymd'))
2176 2175
 						{
2177 2176
 							if ($this->log)
2178 2177
 							{
2179 2178
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2180 2179
 									. '()[DUE mismatch]: '
2181
-									. $taskTime->format('Ymd') . ' <> ' . $egwTime->format('Ymd'));
2180
+									. $taskTime->format('Ymd').' <> '.$egwTime->format('Ymd'));
2182 2181
 							}
2183 2182
 							continue;
2184 2183
 						}
@@ -2199,15 +2198,15 @@  discard block
 block discarded – undo
2199 2198
 					if (isset($egwData['info_datecompleted']) && $egwData['info_datecompleted'])
2200 2199
 					{
2201 2200
 						// We compare the date only
2202
-						$taskTime = new Api\DateTime($infoData['info_datecompleted'],Api\DateTime::$server_timezone);
2203
-						$egwTime = new Api\DateTime($egwData['info_datecompleted'],Api\DateTime::$server_timezone);
2201
+						$taskTime = new Api\DateTime($infoData['info_datecompleted'], Api\DateTime::$server_timezone);
2202
+						$egwTime = new Api\DateTime($egwData['info_datecompleted'], Api\DateTime::$server_timezone);
2204 2203
 						if ($taskTime->format('Ymd') != $egwTime->format('Ymd'))
2205 2204
 						{
2206 2205
 							if ($this->log)
2207 2206
 							{
2208 2207
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2209 2208
 									. '()[completed mismatch]: '
2210
-									. $taskTime->format('Ymd') . ' <> ' . $egwTime->format('Ymd'));
2209
+									. $taskTime->format('Ymd').' <> '.$egwTime->format('Ymd'));
2211 2210
 							}
2212 2211
 							continue;
2213 2212
 						}
@@ -2237,7 +2236,7 @@  discard block
 block discarded – undo
2237 2236
 		if ($this->log)
2238 2237
 		{
2239 2238
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2240
-				. '()[FOUND]:' . array2string($foundInfoLogs));
2239
+				. '()[FOUND]:'.array2string($foundInfoLogs));
2241 2240
 		}
2242 2241
 		return $foundInfoLogs;
2243 2242
 	}
Please login to merge, or discard this patch.
infolog/inc/class.infolog_groupdav.inc.php 3 patches
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	{
Please login to merge, or discard this patch.
Braces   +76 added lines, -19 removed lines patch added patch discarded remove patch
@@ -91,7 +91,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		$check_responsible = false;
257 257
 		if (substr($task_filter, -8) == '+deleted')
@@ -279,10 +279,10 @@  discard block
 block discarded – undo
279 279
 
280 280
 		$files = array();
281 281
 		// ToDo: add parameter to only return id & etag
282
-		$tasks =& $this->bo->search($query);
282
+		$tasks = & $this->bo->search($query);
283 283
 		if ($tasks && $offset == $query['start'])
284 284
 		{
285
-			foreach($tasks as $task)
285
+			foreach ($tasks as $task)
286 286
 			{
287 287
 				// remove task from requested multiget ids, to be able to report not found urls
288 288
 				if ($requested_multiget_ids && ($k = array_search($task[self::$path_attr], $requested_multiget_ids)) !== false)
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
 					continue;
300 300
 				}
301 301
 				$props = array(
302
-					'getcontenttype' => $this->agent != 'kde' ? 'text/calendar; charset=utf-8; component=VTODO' : 'text/calendar',	// Konqueror (3.5) dont understand it otherwise
302
+					'getcontenttype' => $this->agent != 'kde' ? 'text/calendar; charset=utf-8; component=VTODO' : 'text/calendar', // Konqueror (3.5) dont understand it otherwise
303 303
 					'getlastmodified' => $task['info_datemodified'],
304 304
 					'displayname' => $task['info_subject'],
305 305
 				);
306 306
 				if ($calendar_data)
307 307
 				{
308
-					$content = $handler->exportVTODO($task, '2.0', null);	// no METHOD:PUBLISH for CalDAV
308
+					$content = $handler->exportVTODO($task, '2.0', null); // no METHOD:PUBLISH for CalDAV
309 309
 					$props['getcontentlength'] = bytes($content);
310
-					$props[] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data',$content);
310
+					$props[] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-data', $content);
311 311
 				}
312 312
 				$files[] = $this->add_resource($path, $task, $props);
313 313
 			}
@@ -315,13 +315,13 @@  discard block
 block discarded – undo
315 315
 		// report not found multiget urls
316 316
 		if ($requested_multiget_ids)
317 317
 		{
318
-			foreach($requested_multiget_ids as $id)
318
+			foreach ($requested_multiget_ids as $id)
319 319
 			{
320 320
 				$files[] = array('path' => $path.$id.self::$path_extension);
321 321
 			}
322 322
 		}
323 323
 		// sync-collection report --> return modified of last contact as sync-token
324
-		$sync_collection_report =  $filter['sync-collection'];
324
+		$sync_collection_report = $filter['sync-collection'];
325 325
 		if ($sync_collection_report)
326 326
 		{
327 327
 			$this->sync_collection_token = $task['date_modified'];
@@ -347,18 +347,18 @@  discard block
 block discarded – undo
347 347
 	 * @param int &$nresult on return limit for number or results or unchanged/null
348 348
 	 * @return boolean true if filter could be processed
349 349
 	 */
350
-	function _report_filters($options,&$cal_filters,$id, &$nresults)
350
+	function _report_filters($options, &$cal_filters, $id, &$nresults)
351 351
 	{
352 352
 		if ($options['filters'])
353 353
 		{
354
-			foreach($options['filters'] as $filter)
354
+			foreach ($options['filters'] as $filter)
355 355
 			{
356
-				switch($filter['name'])
356
+				switch ($filter['name'])
357 357
 				{
358 358
 					case 'comp-filter':
359 359
 						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'");
360 360
 
361
-						switch($filter['attrs']['name'])
361
+						switch ($filter['attrs']['name'])
362 362
 						{
363 363
 							case 'VTODO':
364 364
 							case 'VCALENDAR':
@@ -401,9 +401,9 @@  discard block
 block discarded – undo
401 401
 		    <B:nresults>10</B:nresults>
402 402
 		  </B:limit>
403 403
 		*/
404
-		foreach((array)$options['other'] as $option)
404
+		foreach ((array)$options['other'] as $option)
405 405
 		{
406
-			switch($option['name'])
406
+			switch ($option['name'])
407 407
 			{
408 408
 				case 'nresults':
409 409
 					$nresults = (int)$option['data'];
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 				case 'limit':
413 413
 					break;
414 414
 				case 'href':
415
-					break;	// from addressbook-multiget, handled below
415
+					break; // from addressbook-multiget, handled below
416 416
 				// rfc 6578 sync-report
417 417
 				case 'sync-token':
418 418
 					if (!empty($option['data']))
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 						$parts = explode('/', $option['data']);
421 421
 						$sync_token = array_pop($parts);
422 422
 						$cal_filters[] = 'info_datemodified>'.(int)$sync_token;
423
-						$cal_filters['filter'] .= '+deleted';	// to return deleted entries too
423
+						$cal_filters['filter'] .= '+deleted'; // to return deleted entries too
424 424
 					}
425 425
 					break;
426 426
 				case 'sync-level':
@@ -442,24 +442,24 @@  discard block
 block discarded – undo
442 442
 			if ($id)
443 443
 			{
444 444
 				$cal_filters[self::$path_attr] = self::$path_extension ?
445
-					basename($id,self::$path_extension) : $id;
445
+					basename($id, self::$path_extension) : $id;
446 446
 			}
447 447
 			else	// fetch all given url's
448 448
 			{
449
-				foreach($options['other'] as $option)
449
+				foreach ($options['other'] as $option)
450 450
 				{
451 451
 					if ($option['name'] == 'href')
452 452
 					{
453
-						$parts = explode('/',$option['data']);
453
+						$parts = explode('/', $option['data']);
454 454
 						if (($id = basename(urldecode(array_pop($parts)))))
455 455
 						{
456 456
 							$cal_filters[self::$path_attr][] = self::$path_extension ?
457
-								basename($id,self::$path_extension) : $id;
457
+								basename($id, self::$path_extension) : $id;
458 458
 						}
459 459
 					}
460 460
 				}
461 461
 			}
462
-			if ($this->debug > 1) error_log(__METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids));
462
+			if ($this->debug > 1) error_log(__METHOD__."($options[path],...,$id) calendar-multiget: ids=".implode(',', $ids));
463 463
 		}
464 464
 		return true;
465 465
 	}
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 		elseif (empty($attrs['start']))
488 488
 		{
489 489
 			$this->caldav->log(__METHOD__.'('.array2string($attrs).') minimum one of start or end is required!');
490
-			return '1';	// to not give sql error, but simply not filter out anything
490
+			return '1'; // to not give sql error, but simply not filter out anything
491 491
 		}
492 492
 		// we dont need to care for DURATION line in rfc4791#section-9.9, as we always put that in DUE/info_enddate
493 493
 
@@ -517,10 +517,10 @@  discard block
 block discarded – undo
517 517
 			"info_datecompleted > 0".(isset($start) ? " AND ($start <= info_datecompleted OR $start <= info_created)" : '').
518 518
 				(isset($end) ? " AND (info_datecompleted <= $end OR info_created <= $end)" : '').' OR '.
519 519
 			// we have no completed date, but always a created date
520
- 			"NOT info_datecompleted > 0". (isset($end) ? " AND info_created < $end" : '').
520
+ 			"NOT info_datecompleted > 0".(isset($end) ? " AND info_created < $end" : '').
521 521
 		')';
522 522
 		$sql = '('.implode(' OR ', $to_or).')';
523
-		if ($this->debug > 1) error_log(__FILE__ . __METHOD__.'('.array2string($attrs).") time-range=$attrs[start]-$attrs[end] --> $sql");
523
+		if ($this->debug > 1) error_log(__FILE__.__METHOD__.'('.array2string($attrs).") time-range=$attrs[start]-$attrs[end] --> $sql");
524 524
 		return $sql;
525 525
 	}
526 526
 
@@ -532,16 +532,16 @@  discard block
 block discarded – undo
532 532
 	 * @param int $user =null account_id
533 533
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
534 534
 	 */
535
-	function get(&$options,$id,$user=null)
535
+	function get(&$options, $id, $user = null)
536 536
 	{
537
-		unset($user);	// not used, but required by function signature
537
+		unset($user); // not used, but required by function signature
538 538
 
539
-		if (!is_array($task = $this->_common_get_put_delete('GET',$options,$id)))
539
+		if (!is_array($task = $this->_common_get_put_delete('GET', $options, $id)))
540 540
 		{
541 541
 			return $task;
542 542
 		}
543 543
 		$handler = $this->_get_handler();
544
-		$options['data'] = $handler->exportVTODO($task, '2.0', null);	// no METHOD:PUBLISH for CalDAV
544
+		$options['data'] = $handler->exportVTODO($task, '2.0', null); // no METHOD:PUBLISH for CalDAV
545 545
 		$options['mimetype'] = 'text/calendar; charset=utf-8';
546 546
 		header('Content-Encoding: identity');
547 547
 		header('ETag: "'.$this->get_etag($task).'"');
@@ -557,13 +557,13 @@  discard block
 block discarded – undo
557 557
 	 * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook)
558 558
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
559 559
 	 */
560
-	function put(&$options,$id,$user=null,$prefix=null)
560
+	function put(&$options, $id, $user = null, $prefix = null)
561 561
 	{
562
-		unset($prefix);	// not used, but required by function signature
562
+		unset($prefix); // not used, but required by function signature
563 563
 
564
-		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true));
564
+		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options, true));
565 565
 
566
-		$oldTask = $this->_common_get_put_delete('PUT',$options,$id);
566
+		$oldTask = $this->_common_get_put_delete('PUT', $options, $id);
567 567
 		if (!is_null($oldTask) && !is_array($oldTask))
568 568
 		{
569 569
 			return $oldTask;
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 	 * @param array $oldTask =null
629 629
 	 * @return array modified task data
630 630
 	 */
631
-	public function cat_action(array $task, $oldTask=null)
631
+	public function cat_action(array $task, $oldTask = null)
632 632
 	{
633 633
 		$action = $GLOBALS['egw_info']['user']['preferences']['groupdav']['infolog-cat-action'];
634 634
 
@@ -661,13 +661,13 @@  discard block
 block discarded – undo
661 661
 			{
662 662
 				unset($task['info_responsible'][$key]);
663 663
 			}
664
-			switch($action)
664
+			switch ($action)
665 665
 			{
666 666
 				case 'set':
667 667
 					$task['info_responsible'] = array();
668 668
 					// fall through
669 669
 				case 'set-user':
670
-					foreach($task['info_responsible'] as $key => $account_id)
670
+					foreach ($task['info_responsible'] as $key => $account_id)
671 671
 					{
672 672
 						if ($GLOBALS['egw']->accounts->get_type($account_id) == 'u')
673 673
 						{
@@ -695,9 +695,9 @@  discard block
 block discarded – undo
695 695
 	 * @param int $id
696 696
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
697 697
 	 */
698
-	function delete(&$options,$id)
698
+	function delete(&$options, $id)
699 699
 	{
700
-		if (!is_array($task = $this->_common_get_put_delete('DELETE',$options,$id)))
700
+		if (!is_array($task = $this->_common_get_put_delete('DELETE', $options, $id)))
701 701
 		{
702 702
 			return $task;
703 703
 		}
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 	 */
716 716
 	function read($id)
717 717
 	{
718
-		return $this->bo->read(array(self::$path_attr => $id, "info_status!='deleted'"),false,'server');
718
+		return $this->bo->read(array(self::$path_attr => $id, "info_status!='deleted'"), false, 'server');
719 719
 	}
720 720
 
721 721
 	/**
@@ -738,15 +738,15 @@  discard block
 block discarded – undo
738 738
 	 * @param array|int $task task-array or id
739 739
 	 * @return boolean null if entry does not exist, false if no access, true if access permitted
740 740
 	 */
741
-	function check_access($acl,$task)
741
+	function check_access($acl, $task)
742 742
 	{
743 743
 		if (is_null($task)) return true;
744 744
 
745
-		$access = $this->bo->check_access($task,$acl);
745
+		$access = $this->bo->check_access($task, $acl);
746 746
 
747 747
 		if (!$access && $acl == Acl::EDIT && $this->bo->is_responsible($task))
748 748
 		{
749
-			$access = true;	// access limited to $this->bo->responsible_edit fields (handled in infolog_bo::write())
749
+			$access = true; // access limited to $this->bo->responsible_edit fields (handled in infolog_bo::write())
750 750
 		}
751 751
 		if ($this->debug > 1) error_log(__METHOD__."($acl, ".array2string($task).') returning '.array2string($access));
752 752
 		return $access;
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
 	 *
758 758
 	 * @return string
759 759
 	 */
760
-	public function getctag($path,$user)
760
+	public function getctag($path, $user)
761 761
 	{
762 762
 		return $this->bo->getctag($this->get_infolog_filter($path, $user));
763 763
 	}
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 	{
775 775
 		if (!is_array($info))
776 776
 		{
777
-			$info = $this->bo->read($info,true,'server');
777
+			$info = $this->bo->read($info, true, 'server');
778 778
 		}
779 779
 		if (!is_array($info) || !isset($info['info_id']) || !isset($info['info_datemodified']))
780 780
 		{
@@ -792,38 +792,38 @@  discard block
 block discarded – undo
792 792
 	 * @param int $user =null account_id of owner of collection
793 793
 	 * @return array
794 794
 	 */
795
-	public function extra_properties(array $props, $displayname, $base_uri=null,$user=null)
795
+	public function extra_properties(array $props, $displayname, $base_uri = null, $user = null)
796 796
 	{
797
-		unset($base_uri);	// not used, but required by function signature
797
+		unset($base_uri); // not used, but required by function signature
798 798
 
799 799
 		// calendar description
800
-		$displayname = Api\Translation::convert(lang('Tasks of'),Api\Translation::charset(),'utf-8').' '.$displayname;
801
-		$props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-description',$displayname);
800
+		$displayname = Api\Translation::convert(lang('Tasks of'), Api\Translation::charset(), 'utf-8').' '.$displayname;
801
+		$props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-description', $displayname);
802 802
 		// supported components, currently only VTODO
803
-		$props['supported-calendar-component-set'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'supported-calendar-component-set',array(
804
-			Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VTODO')),
803
+		$props['supported-calendar-component-set'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'supported-calendar-component-set', array(
804
+			Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'comp', array('name' => 'VTODO')),
805 805
 		));
806 806
 		// supported reports
807 807
 		$props['supported-report-set'] = array(
808
-			'calendar-query' => Api\CalDAV::mkprop('supported-report',array(
809
-				Api\CalDAV::mkprop('report',array(
810
-					Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-query',''))))),
811
-			'calendar-multiget' => Api\CalDAV::mkprop('supported-report',array(
812
-				Api\CalDAV::mkprop('report',array(
813
-					Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-multiget',''))))),
808
+			'calendar-query' => Api\CalDAV::mkprop('supported-report', array(
809
+				Api\CalDAV::mkprop('report', array(
810
+					Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-query', ''))))),
811
+			'calendar-multiget' => Api\CalDAV::mkprop('supported-report', array(
812
+				Api\CalDAV::mkprop('report', array(
813
+					Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-multiget', ''))))),
814 814
 		);
815 815
 		// only advertice rfc 6578 sync-collection report, if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted
816 816
 		$config = Api\Config::read('infolog');
817 817
 		if ($config['history'])
818 818
 		{
819
-			$props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report',array(
820
-				Api\CalDAV::mkprop('report',array(
821
-					Api\CalDAV::mkprop('sync-collection','')))));
819
+			$props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report', array(
820
+				Api\CalDAV::mkprop('report', array(
821
+					Api\CalDAV::mkprop('sync-collection', '')))));
822 822
 		}
823 823
 		// get timezone of calendar
824 824
 		if ($this->caldav->prop_requested('calendar-timezone'))
825 825
 		{
826
-			$props['calendar-timezone'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-timezone',
826
+			$props['calendar-timezone'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-timezone',
827 827
 				calendar_timezones::user_timezone($user));
828 828
 		}
829 829
 		return $props;
@@ -837,8 +837,8 @@  discard block
 block discarded – undo
837 837
 	private function _get_handler()
838 838
 	{
839 839
 		$handler = new infolog_ical();
840
-		$handler->tzid = false;	//	as we read server-time timestamps (!= null=user-time), exports UTC times
841
-		$handler->setSupportedFields('GroupDAV',$this->agent);
840
+		$handler->tzid = false; //	as we read server-time timestamps (!= null=user-time), exports UTC times
841
+		$handler->setSupportedFields('GroupDAV', $this->agent);
842 842
 
843 843
 		return $handler;
844 844
 	}
Please login to merge, or discard this patch.
infolog/inc/class.infolog_ical.inc.php 4 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1042,8 +1042,7 @@
 block discarded – undo
1042 1042
 	 * Search a matching infolog entry for the VNOTE data
1043 1043
 	 *
1044 1044
 	 * @param string $_vcalData		VNOTE
1045
-	 * @param int $contentID=null 	infolog_id (or null, if unkown)
1046
-	 * @param boolean $relax=false 	if true, a weaker match algorithm is used
1045
+	 * @param int $contentID 	infolog_id (or null, if unkown)
1047 1046
 	 * @param string $charset  The encoding charset for $text. Defaults to
1048 1047
      *                         utf-8 for new format, iso-8859-1 for old format.
1049 1048
 	 *
Please login to merge, or discard this patch.
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
 	var $productName = '';
68 68
 
69 69
 	/**
70
-	* Shall we use the UID extensions of the description field?
71
-	*
72
-	* @var boolean
73
-	*/
70
+	 * Shall we use the UID extensions of the description field?
71
+	 *
72
+	 * @var boolean
73
+	 */
74 74
 	var $uidExtension = false;
75 75
 
76 76
 	/**
@@ -509,10 +509,10 @@  discard block
 block discarded – undo
509 509
 	 * @param boolean $merge =false	merge data with existing entry (no longer used)
510 510
 	 * @param int $user =null delegate new task to this account_id, default null
511 511
 	 * @param string $charset =null The encoding charset for $text. Defaults to
512
-     *                         utf-8 for new format, iso-8859-1 for old format.
513
-     * @param string $caldav_name =null CalDAV URL name-part for new entries
514
-     * @param array $callback_data =null array with callback and further parameters, first param is task to save
515
-     * 	signature array callback($task, $param1, ...)
512
+	 *                         utf-8 for new format, iso-8859-1 for old format.
513
+	 * @param string $caldav_name =null CalDAV URL name-part for new entries
514
+	 * @param array $callback_data =null array with callback and further parameters, first param is task to save
515
+	 * 	signature array callback($task, $param1, ...)
516 516
 	 * @return int|boolean integer info_id or false on error
517 517
 	 */
518 518
 	function importVTODO(&$_vcalData, $_taskID=-1, $merge=false, $user=null, $charset=null, $caldav_name=null,
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 	 * @param int $contentID =null 	infolog_id (or null, if unkown)
598 598
 	 * @param boolean $relax =false 	if true, a weaker match algorithm is used
599 599
 	 * @param string $charset  The encoding charset for $text. Defaults to
600
-     *                         utf-8 for new format, iso-8859-1 for old format.
600
+	 *                         utf-8 for new format, iso-8859-1 for old format.
601 601
 	 *
602 602
 	 * @return array of infolog_ids of matching entries
603 603
 	 */
@@ -642,8 +642,8 @@  discard block
 block discarded – undo
642 642
 	 * @param string $_vcalData 	VTODO data
643 643
 	 * @param int $_taskID =-1		infolog_id of the entry
644 644
 	 * @param string $charset  The encoding charset for $text. Defaults to
645
-     *                         utf-8 for new format, iso-8859-1 for old format.
646
-     *
645
+	 *                         utf-8 for new format, iso-8859-1 for old format.
646
+	 *
647 647
 	 * @return array infolog entry or false on error
648 648
 	 */
649 649
 	function vtodotoegw($_vcalData, $_taskID=-1, $charset=null)
@@ -1010,8 +1010,8 @@  discard block
 block discarded – undo
1010 1010
 	 * @param int $_noteID =-1 info_id, default -1 = new entry
1011 1011
 	 * @param boolean $merge =false	merge data with existing entry (no longer used)
1012 1012
 	 * @param string $charset  The encoding charset for $text. Defaults to
1013
-     *                         utf-8 for new format, iso-8859-1 for old format.
1014
-     *
1013
+	 *                         utf-8 for new format, iso-8859-1 for old format.
1014
+	 *
1015 1015
 	 * @return int|boolean integer info_id or false on error
1016 1016
 	 */
1017 1017
 	function importVNOTE(&$_vcalData, $_type, $_noteID=-1, $merge=false, $charset=null)
@@ -1045,7 +1045,7 @@  discard block
 block discarded – undo
1045 1045
 	 * @param int $contentID=null 	infolog_id (or null, if unkown)
1046 1046
 	 * @param boolean $relax=false 	if true, a weaker match algorithm is used
1047 1047
 	 * @param string $charset  The encoding charset for $text. Defaults to
1048
-     *                         utf-8 for new format, iso-8859-1 for old format.
1048
+	 *                         utf-8 for new format, iso-8859-1 for old format.
1049 1049
 	 *
1050 1050
 	 * @return infolog_id of a matching entry or false, if nothing was found
1051 1051
 	 */
@@ -1067,8 +1067,8 @@  discard block
 block discarded – undo
1067 1067
 	 * @param string $_type		content type (eg.g text/plain)
1068 1068
 	 * @param int $_noteID =-1	infolog_id of the entry
1069 1069
 	 * @param string $charset  The encoding charset for $text. Defaults to
1070
-     *                         utf-8 for new format, iso-8859-1 for old format.
1071
-     *
1070
+	 *                         utf-8 for new format, iso-8859-1 for old format.
1071
+	 *
1072 1072
 	 * @return array infolog entry or false on error
1073 1073
 	 */
1074 1074
 	function vnotetoegw($_data, $_type, $_noteID=-1, $charset=null)
Please login to merge, or discard this patch.
Spacing   +125 added lines, -126 removed lines patch added patch discarded remove patch
@@ -23,39 +23,39 @@  discard block
 block discarded – undo
23 23
 	 * @var array $priority_egw2ical conversion of the priority egw => ical
24 24
 	 */
25 25
 	var $priority_egw2ical = array(
26
-		0 => 9,		// low
27
-		1 => 5,		// normal
28
-		2 => 3,		// high
29
-		3 => 1,		// urgent
26
+		0 => 9, // low
27
+		1 => 5, // normal
28
+		2 => 3, // high
29
+		3 => 1, // urgent
30 30
 	);
31 31
 
32 32
 	/**
33 33
 	 * @var array $priority_ical2egw conversion of the priority ical => egw
34 34
 	 */
35 35
 	var $priority_ical2egw = array(
36
-		9 => 0,	8 => 0, 7 => 0,	// low
37
-		6 => 1, 5 => 1, 4 => 1, 0 => 1,	// normal
38
-		3 => 2,	2 => 2,	// high
39
-		1 => 3,			// urgent
36
+		9 => 0, 8 => 0, 7 => 0, // low
37
+		6 => 1, 5 => 1, 4 => 1, 0 => 1, // normal
38
+		3 => 2, 2 => 2, // high
39
+		1 => 3, // urgent
40 40
 	);
41 41
 
42 42
 	/**
43 43
 	 * @var array $priority_egw2funambol conversion of the priority egw => funambol
44 44
 	 */
45 45
 	var $priority_egw2funambol = array(
46
-		0 => 0,		// low
47
-		1 => 1,		// normal
48
-		2 => 2,		// high
49
-		3 => 2,		// urgent
46
+		0 => 0, // low
47
+		1 => 1, // normal
48
+		2 => 2, // high
49
+		3 => 2, // urgent
50 50
 	);
51 51
 
52 52
 	/**
53 53
 	 * @var array $priority_funambol2egw conversion of the priority funambol => egw
54 54
 	 */
55 55
 	var $priority_funambol2egw = array(
56
-		0 => 0,		// low
57
-		1 => 1,		// normal
58
-		2 => 3,		// high
56
+		0 => 0, // low
57
+		1 => 1, // normal
58
+		2 => 3, // high
59 59
 	);
60 60
 
61 61
 	/**
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @var boolean
94 94
 	 */
95 95
 	var $log = false;
96
-	var $logfile="/tmp/log-infolog-vcal";
96
+	var $logfile = "/tmp/log-infolog-vcal";
97 97
 
98 98
 
99 99
 	/**
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
 	 * @param string $charset ='UTF-8'
118 118
 	 * @return string|boolean string with vCal or false on error (eg. no permission to read the event)
119 119
 	 */
120
-	function exportVCalendar(array $tasks, $_version='2.0', $_method=null, $charset='UTF-8')
120
+	function exportVCalendar(array $tasks, $_version = '2.0', $_method = null, $charset = 'UTF-8')
121 121
 	{
122 122
 		$vcal = new Horde_Icalendar;
123 123
 
124
-		foreach($tasks as $task)
124
+		foreach ($tasks as $task)
125 125
 		{
126 126
 			if (!$this->exportVTODO($task, $_version, $_method, $charset, $vcal))
127 127
 			{
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @return string|boolean string with vCal or false on error (eg. no permission to read the event)
144 144
 	 */
145
-	function exportVTODO($task, $_version='2.0',$_method='PUBLISH', $charset='UTF-8',Horde_Icalendar $vcal=null)
145
+	function exportVTODO($task, $_version = '2.0', $_method = 'PUBLISH', $charset = 'UTF-8', Horde_Icalendar $vcal = null)
146 146
 	{
147 147
 		if (is_array($task))
148 148
 		{
@@ -167,10 +167,10 @@  discard block
 block discarded – undo
167 167
 		{
168 168
 			if (!preg_match('/\[UID:.+\]/m', $taskData['info_des']))
169 169
 			{
170
-				$taskData['info_des'] .= "\n[UID:" . $taskData['info_uid'] . "]";
170
+				$taskData['info_des'] .= "\n[UID:".$taskData['info_uid']."]";
171 171
 				if ($taskData['info_id_parent'] != '')
172 172
 				{
173
-					$taskData['info_des'] .= "\n[PARENT_UID:" . $taskData['info_id_parent'] . "]";
173
+					$taskData['info_des'] .= "\n[PARENT_UID:".$taskData['info_id_parent']."]";
174 174
 				}
175 175
 			}
176 176
 		}
@@ -186,15 +186,15 @@  discard block
 block discarded – undo
186 186
 
187 187
 		if ($this->log)
188 188
 		{
189
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
190
-				array2string($taskData)."\n",3,$this->logfile);
189
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
190
+				array2string($taskData)."\n", 3, $this->logfile);
191 191
 		}
192 192
 
193 193
 		if (!isset($vcal)) $vcal = new Horde_Icalendar;
194
-		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware InfoLog '.$GLOBALS['egw_info']['apps']['infolog']['version'].'//'.
195
-			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']),array(),false);
196
-		$vcal->setAttribute('VERSION',$_version,array(),false);
197
-		if ($_method) $vcal->setAttribute('METHOD',$_method,array(),false);
194
+		$vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware InfoLog '.$GLOBALS['egw_info']['apps']['infolog']['version'].'//'.
195
+			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']), array(), false);
196
+		$vcal->setAttribute('VERSION', $_version, array(), false);
197
+		if ($_method) $vcal->setAttribute('METHOD', $_method, array(), false);
198 198
 
199 199
 		$tzid = $this->tzid;
200 200
 		if ($tzid && $tzid != 'UTC')
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 			}
213 213
 		}
214 214
 
215
-		$vevent = Horde_Icalendar::newComponent('VTODO',$vcal);
215
+		$vevent = Horde_Icalendar::newComponent('VTODO', $vcal);
216 216
 
217 217
 		if (!isset($this->clientProperties['SUMMARY']['Size']))
218 218
 		{
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
 				$noTruncate = $this->clientProperties[$field]['NoTruncate'];
237 237
 				if ($this->log && $size > 0)
238 238
 				{
239
-					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
240
-						"() $field Size: $size, NoTruncate: " .
241
-						($noTruncate ? 'TRUE' : 'FALSE') . "\n",3,$this->logfile);
239
+					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
240
+						"() $field Size: $size, NoTruncate: ".
241
+						($noTruncate ? 'TRUE' : 'FALSE')."\n", 3, $this->logfile);
242 242
 				}
243 243
 				//Horde::logMessage("VTODO $field Size: $size, NoTruncate: " .
244 244
 				//	($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -255,19 +255,19 @@  discard block
 block discarded – undo
255 255
 				{
256 256
 					if ($this->log)
257 257
 					{
258
-						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
259
-							"() $field omitted due to maximum size $size\n",3,$this->logfile);
258
+						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
259
+							"() $field omitted due to maximum size $size\n", 3, $this->logfile);
260 260
 					}
261 261
 					//Horde::logMessage("VTODO $field omitted due to maximum size $size",
262 262
 					//	__FILE__, __LINE__, PEAR_LOG_WARNING);
263 263
 					continue; // skip field
264 264
 				}
265 265
 				// truncate the value to size
266
-				$value = substr($value, 0, $size -1);
266
+				$value = substr($value, 0, $size - 1);
267 267
 				if ($this->log)
268 268
 				{
269
-					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
270
-						"() $field truncated to maximum size $size\n",3,$this->logfile);
269
+					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
270
+						"() $field truncated to maximum size $size\n", 3, $this->logfile);
271 271
 				}
272 272
 				//Horde::logMessage("VTODO $field truncated to maximum size $size",
273 273
 				//	__FILE__, __LINE__, PEAR_LOG_INFO);
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 
287 287
 			if ($_version == '1.0' && preg_match('/[^\x20-\x7F]/', $value))
288 288
 			{
289
-				$options['CHARSET']	= $charset;
289
+				$options['CHARSET'] = $charset;
290 290
 				switch ($this->productManufacturer)
291 291
 				{
292 292
 					case 'groupdav':
@@ -328,23 +328,23 @@  discard block
 block discarded – undo
328 328
 			self::setDateOrTime($vevent, 'COMPLETED', $taskData['info_datecompleted'], $tzid);
329 329
 		}
330 330
 
331
-		$vevent->setAttribute('DTSTAMP',time());
331
+		$vevent->setAttribute('DTSTAMP', time());
332 332
 		$vevent->setAttribute('CREATED', $taskData['info_created']);
333 333
 		$vevent->setAttribute('LAST-MODIFIED', $taskData['info_datemodified']);
334
-		$vevent->setAttribute('CLASS',$taskData['info_access'] == 'public' ? 'PUBLIC' : 'PRIVATE');
335
-		$vevent->setAttribute('STATUS',$this->status2vtodo($taskData['info_status']));
334
+		$vevent->setAttribute('CLASS', $taskData['info_access'] == 'public' ? 'PUBLIC' : 'PRIVATE');
335
+		$vevent->setAttribute('STATUS', $this->status2vtodo($taskData['info_status']));
336 336
 		// we try to preserv the original infolog status as X-INFOLOG-STATUS, so we can restore it, if the user does not modify STATUS
337
-		$vevent->setAttribute('X-INFOLOG-STATUS',$taskData['info_status']);
338
-		$vevent->setAttribute('PERCENT-COMPLETE',$taskData['info_percent']);
337
+		$vevent->setAttribute('X-INFOLOG-STATUS', $taskData['info_status']);
338
+		$vevent->setAttribute('PERCENT-COMPLETE', $taskData['info_percent']);
339 339
 		if ($this->productManufacturer == 'funambol' &&
340 340
 			(strpos($this->productName, 'outlook') !== false
341 341
 				|| strpos($this->productName, 'pocket pc') !== false))
342 342
 		{
343
-			$priority = (int) $this->priority_egw2funambol[$taskData['info_priority']];
343
+			$priority = (int)$this->priority_egw2funambol[$taskData['info_priority']];
344 344
 		}
345 345
 		else
346 346
 		{
347
-			$priority = (int) $this->priority_egw2ical[$taskData['info_priority']];
347
+			$priority = (int)$this->priority_egw2ical[$taskData['info_priority']];
348 348
 		}
349 349
 		$vevent->setAttribute('PRIORITY', $priority);
350 350
 
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 			(count($taskData['info_responsible']) > 1 ||
354 354
 				$taskData['info_responsible'][0] != $taskData['info_onwer']))
355 355
 		{
356
-			if (($url = $GLOBALS['egw']->accounts->id2name($taskData['info_owner'],'account_email')))
356
+			if (($url = $GLOBALS['egw']->accounts->id2name($taskData['info_owner'], 'account_email')))
357 357
 			{
358 358
 				$url = 'MAILTO:'.$url;
359 359
 			}
@@ -361,13 +361,13 @@  discard block
 block discarded – undo
361 361
 			{
362 362
 				$url = 'urn:uuid:'.Api\CalDAV::generate_uid('accounts', $taskData['info_owner']);
363 363
 			}
364
-			$vevent->setAttribute('ORGANIZER',$url,array(
365
-				'CN'		=>	$GLOBALS['egw']->accounts->id2name($taskData['info_owner'],'account_fullname'),
364
+			$vevent->setAttribute('ORGANIZER', $url, array(
365
+				'CN'		=>	$GLOBALS['egw']->accounts->id2name($taskData['info_owner'], 'account_fullname'),
366 366
 				'X-EGROUPWARE-UID'	=> $taskData['info_owner'],
367 367
 			), true);
368
-			foreach($taskData['info_responsible'] as $responsible)
368
+			foreach ($taskData['info_responsible'] as $responsible)
369 369
 			{
370
-				if (($url = $GLOBALS['egw']->accounts->id2name($responsible,'account_email')))
370
+				if (($url = $GLOBALS['egw']->accounts->id2name($responsible, 'account_email')))
371 371
 				{
372 372
 					$url = 'MAILTO:'.$url;
373 373
 				}
@@ -377,15 +377,15 @@  discard block
 block discarded – undo
377 377
 				}
378 378
 				if ($responsible > 0)
379 379
 				{
380
-					$vevent->setAttribute('ATTENDEE',$url,array(
381
-						'CN'		=>	$GLOBALS['egw']->accounts->id2name($responsible,'account_fullname'),
380
+					$vevent->setAttribute('ATTENDEE', $url, array(
381
+						'CN'		=>	$GLOBALS['egw']->accounts->id2name($responsible, 'account_fullname'),
382 382
 						'CUTYPE'	=> 'INDIVIDUAL',
383 383
 						'X-EGROUPWARE-UID'	=> $responsible,
384 384
 					), true);
385 385
 				}
386 386
 				elseif ($responsible < 0)
387 387
 				{
388
-					$vevent->setAttribute('ATTENDEE',$url,array(
388
+					$vevent->setAttribute('ATTENDEE', $url, array(
389 389
 						'CN'		=>	$GLOBALS['egw']->accounts->id2name($responsible),
390 390
 						'CUTYPE'	=> 'GROUP',
391 391
 						'X-EGROUPWARE-UID'	=> $responsible,
@@ -396,17 +396,17 @@  discard block
 block discarded – undo
396 396
 		// for CalDAV add all X-Properties previously parsed
397 397
 		if ($this->productManufacturer == 'groupdav')
398 398
 		{
399
-			foreach($taskData as $name => $value)
399
+			foreach ($taskData as $name => $value)
400 400
 			{
401 401
 				if (substr($name, 0, 2) == '##')
402 402
 				{
403 403
 					if ($name[2] == ':')
404 404
 					{
405 405
 						if (($v = json_php_unserialize($value)) && is_array($v)) $value = $v;
406
-						foreach((array)$value as $compvData)
406
+						foreach ((array)$value as $compvData)
407 407
 						{
408
-							$comp = Horde_Icalendar::newComponent(substr($name,3), $vevent);
409
-							$comp->parsevCalendar($compvData,substr($name,3));
408
+							$comp = Horde_Icalendar::newComponent(substr($name, 3), $vevent);
409
+							$comp->parsevCalendar($compvData, substr($name, 3));
410 410
 							$vevent->addComponent($comp);
411 411
 						}
412 412
 					}
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
 		$retval = $vcal->exportvCalendar();
427 427
 		if ($this->log)
428 428
 		{
429
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
430
-				array2string($retval)."\n",3,$this->logfile);
429
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
430
+				array2string($retval)."\n", 3, $this->logfile);
431 431
 		}
432 432
 		// Horde::logMessage("exportVTODO:\n" . print_r($retval, true),
433 433
 		//	__FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 			}
457 457
 			$tz = self::$tz_cache[$tzid];
458 458
 		}
459
-		elseif(is_null($tzid))
459
+		elseif (is_null($tzid))
460 460
 		{
461 461
 			$tz = Api\DateTime::$user_timezone;
462 462
 		}
@@ -464,9 +464,9 @@  discard block
 block discarded – undo
464 464
 		{
465 465
 			$tz = Api\DateTime::$server_timezone;
466 466
 		}
467
-		if (!is_a($time,'DateTime'))
467
+		if (!is_a($time, 'DateTime'))
468 468
 		{
469
-			$time = new Api\DateTime($time,Api\DateTime::$server_timezone);
469
+			$time = new Api\DateTime($time, Api\DateTime::$server_timezone);
470 470
 		}
471 471
 		$time->setTimezone($tz);
472 472
 
@@ -515,16 +515,16 @@  discard block
 block discarded – undo
515 515
      * 	signature array callback($task, $param1, ...)
516 516
 	 * @return int|boolean integer info_id or false on error
517 517
 	 */
518
-	function importVTODO(&$_vcalData, $_taskID=-1, $merge=false, $user=null, $charset=null, $caldav_name=null,
519
-		array $callback_data=null)
518
+	function importVTODO(&$_vcalData, $_taskID = -1, $merge = false, $user = null, $charset = null, $caldav_name = null,
519
+		array $callback_data = null)
520 520
 	{
521
-		unset($merge);	// no longer used, but required by function signature
521
+		unset($merge); // no longer used, but required by function signature
522 522
 
523 523
 		if ($this->tzid)
524 524
 		{
525 525
 			date_default_timezone_set($this->tzid);
526 526
 		}
527
-		$taskData = $this->vtodotoegw($_vcalData,$_taskID, $charset);
527
+		$taskData = $this->vtodotoegw($_vcalData, $_taskID, $charset);
528 528
 		if ($this->tzid)
529 529
 		{
530 530
 			date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
@@ -555,8 +555,8 @@  discard block
 block discarded – undo
555 555
 
556 556
 		if ($this->log)
557 557
 		{
558
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
559
-				array2string($taskData)."\n",3,$this->logfile);
558
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
559
+				array2string($taskData)."\n", 3, $this->logfile);
560 560
 		}
561 561
 
562 562
 		if ($caldav_name)
@@ -565,18 +565,18 @@  discard block
 block discarded – undo
565 565
 		}
566 566
 
567 567
 		// make sure not to empty fields not supported by iCal or not allowed to change by CalDAV
568
-		if ($_taskID > 0 && ($old = $this->read($_taskID,true,'server')))
568
+		if ($_taskID > 0 && ($old = $this->read($_taskID, true, 'server')))
569 569
 		{
570 570
 			// remove all values supported by iCal standard
571 571
 			$old = array_diff_key($old, array_flip(array(
572
-				'info_subject','info_des','info_location','info_cat','info_responsible',
573
-				'info_startdate','info_enddate','info_priority','info_location',
574
-				'info_access','info_status','info_percent','info_datecompleted',
572
+				'info_subject', 'info_des', 'info_location', 'info_cat', 'info_responsible',
573
+				'info_startdate', 'info_enddate', 'info_priority', 'info_location',
574
+				'info_access', 'info_status', 'info_percent', 'info_datecompleted',
575 575
 			)));
576 576
 			// remove all iCal fields not supported by EGroupware (stored like custom fields)
577
-			foreach(array_keys($old) as $name)
577
+			foreach (array_keys($old) as $name)
578 578
 			{
579
-				if (substr($name,0,2) == '##') unset($old[$name]);
579
+				if (substr($name, 0, 2) == '##') unset($old[$name]);
580 580
 			}
581 581
 			// merge in again all infolog fields not supported by iCal or not allowed to change
582 582
 			$taskData = array_merge($taskData, $old);
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 	 *
602 602
 	 * @return array of infolog_ids of matching entries
603 603
 	 */
604
-	function searchVTODO($_vcalData, $contentID=null, $relax=false, $charset=null)
604
+	function searchVTODO($_vcalData, $contentID = null, $relax = false, $charset = null)
605 605
 	{
606 606
 		$result = array();
607 607
 
@@ -646,12 +646,12 @@  discard block
 block discarded – undo
646 646
      *
647 647
 	 * @return array infolog entry or false on error
648 648
 	 */
649
-	function vtodotoegw($_vcalData, $_taskID=-1, $charset=null)
649
+	function vtodotoegw($_vcalData, $_taskID = -1, $charset = null)
650 650
 	{
651 651
 		if ($this->log)
652 652
 		{
653
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($_taskID)\n" .
654
-				array2string($_vcalData)."\n",3,$this->logfile);
653
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($_taskID)\n".
654
+				array2string($_vcalData)."\n", 3, $this->logfile);
655 655
 		}
656 656
 
657 657
 		$vcal = new Horde_Icalendar;
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 			if ($this->log)
665 665
 			{
666 666
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
667
-					"(): No vCalendar Container found!\n",3,$this->logfile);
667
+					"(): No vCalendar Container found!\n", 3, $this->logfile);
668 668
 			}
669 669
 			return false;
670 670
 		}
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 				if ($this->log)
688 688
 				{
689 689
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
690
-						"(): Not a vTODO container, skipping...\n",3,$this->logfile);
690
+						"(): Not a vTODO container, skipping...\n", 3, $this->logfile);
691 691
 				}
692 692
 				continue;
693 693
 			}
@@ -714,24 +714,23 @@  discard block
 block discarded – undo
714 714
 					($this->_status2vtodo[$x_infolog_status] === 'COMPLETED') != is_scalar($completed))
715 715
 				{
716 716
 					$percent_completed = $component->getAttributeDefault('PERCENT-COMPLETE', null);
717
-					$status = $completed && is_scalar($completed) ? 'COMPLETED' :
718
-						($percent_completed && is_scalar($percent_completed) && $percent_completed > 0 ? 'IN-PROCESS' : 'NEEDS-ACTION');
717
+					$status = $completed && is_scalar($completed) ? 'COMPLETED' : ($percent_completed && is_scalar($percent_completed) && $percent_completed > 0 ? 'IN-PROCESS' : 'NEEDS-ACTION');
719 718
 					$component->setAttribute('STATUS', $status);
720 719
 					if (!is_scalar($percent_completed))
721 720
 					{
722 721
 						$component->setAttribute('PERCENT-COMPLETE', $percent_completed = $status == 'COMPLETED' ?
723 722
 							100 : ($status == 'NEEDS-ACTION' ? 0 : 10));
724 723
 					}
725
-					if ($this->log) error_log(__METHOD__."() setting STATUS='$status' and PERCENT-COMPLETE=$percent_completed from COMPLETED and X-INFOLOG-STATUS='$x_infolog_status'\n",3,$this->logfile);
724
+					if ($this->log) error_log(__METHOD__."() setting STATUS='$status' and PERCENT-COMPLETE=$percent_completed from COMPLETED and X-INFOLOG-STATUS='$x_infolog_status'\n", 3, $this->logfile);
726 725
 				}
727 726
 				// new task without status --> set a default status of NEEDS-ACTION, as otherwise task is marked closed
728
-				elseif($_taskID <= 0 && !is_scalar($x_infolog_status) && !is_scalar($completed))
727
+				elseif ($_taskID <= 0 && !is_scalar($x_infolog_status) && !is_scalar($completed))
729 728
 				{
730 729
 					$component->setAttribute('STATUS', 'NEEDS-ACTION');
731 730
 				}
732 731
 				else
733 732
 				{
734
-					if ($this->log) error_log(__METHOD__."() no STATUS, X-INFOLOG-STATUS='$x_infolog_status', COMPLETED".(is_scalar($completed)?'='.$completed:' not set')." --> leaving status and percent unchanged",3,$this->logfile);
733
+					if ($this->log) error_log(__METHOD__."() no STATUS, X-INFOLOG-STATUS='$x_infolog_status', COMPLETED".(is_scalar($completed) ? '='.$completed : ' not set')." --> leaving status and percent unchanged", 3, $this->logfile);
735 734
 				}
736 735
 			}
737 736
 			foreach ($component->getAllAttributes() as $attribute)
@@ -775,7 +774,7 @@  discard block
 block discarded – undo
775 774
 					case 'DURATION':
776 775
 						if (!isset($taskData['info_startdate']))
777 776
 						{
778
-							$taskData['info_startdate']	= $component->getAttributeDefault('DTSTART', null);
777
+							$taskData['info_startdate'] = $component->getAttributeDefault('DTSTART', null);
779 778
 						}
780 779
 						$attribute['value'] += $taskData['info_startdate'];
781 780
 						$taskData['##DURATION'] = $attribute['value'];
@@ -787,11 +786,11 @@  discard block
 block discarded – undo
787 786
 						break;
788 787
 
789 788
 					case 'COMPLETED':
790
-						$taskData['info_datecompleted']	= self::date2ts($attribute['value']);
789
+						$taskData['info_datecompleted'] = self::date2ts($attribute['value']);
791 790
 						break;
792 791
 
793 792
 					case 'DTSTART':
794
-						$taskData['info_startdate']	= self::date2ts($attribute['value']);
793
+						$taskData['info_startdate'] = self::date2ts($attribute['value']);
795 794
 						break;
796 795
 
797 796
 					case 'PRIORITY':
@@ -801,16 +800,16 @@  discard block
 block discarded – undo
801 800
 								(strpos($this->productName, 'outlook') !== false
802 801
 									|| strpos($this->productName, 'pocket pc') !== false))
803 802
 							{
804
-								$taskData['info_priority'] = (int) $this->priority_funambol2egw[$attribute['value']];
803
+								$taskData['info_priority'] = (int)$this->priority_funambol2egw[$attribute['value']];
805 804
 							}
806 805
 							else
807 806
 							{
808
-								$taskData['info_priority'] = (int) $this->priority_ical2egw[$attribute['value']];
807
+								$taskData['info_priority'] = (int)$this->priority_ical2egw[$attribute['value']];
809 808
 							}
810 809
 						}
811 810
 						else
812 811
 						{
813
-							$taskData['info_priority'] = 1;	// default = normal
812
+							$taskData['info_priority'] = 1; // default = normal
814 813
 						}
815 814
 						break;
816 815
 
@@ -833,7 +832,7 @@  discard block
 block discarded – undo
833 832
 					case 'CATEGORIES':
834 833
 						if (!empty($attribute['value']))
835 834
 						{
836
-							$cats = $this->find_or_add_categories(explode(',',$attribute['value']), $_taskID);
835
+							$cats = $this->find_or_add_categories(explode(',', $attribute['value']), $_taskID);
837 836
 							$taskData['info_cat'] = $cats[0];
838 837
 						}
839 838
 						break;
@@ -846,7 +845,7 @@  discard block
 block discarded – undo
846 845
 						break;
847 846
 
848 847
 					case 'PERCENT-COMPLETE':
849
-						$taskData['info_percent'] = (int) $attribute['value'];
848
+						$taskData['info_percent'] = (int)$attribute['value'];
850 849
 						break;
851 850
 
852 851
 					case 'ATTENDEE':
@@ -888,10 +887,10 @@  discard block
 block discarded – undo
888 887
 			break;
889 888
 		}
890 889
 		// store included, but unsupported components like valarm as x-properties
891
-		foreach($component->getComponents() as $comp)
890
+		foreach ($component->getComponents() as $comp)
892 891
 		{
893 892
 			$name = '##:'.strtoupper($comp->getType());
894
-			$compvData = $comp->exportvCalendar($comp,'utf-8');
893
+			$compvData = $comp->exportvCalendar($comp, 'utf-8');
895 894
 			if (isset($taskData[$name]))
896 895
 			{
897 896
 				$taskData[$name] = array($taskData[$name]);
@@ -904,8 +903,8 @@  discard block
 block discarded – undo
904 903
 		}
905 904
 		if ($this->log)
906 905
 		{
907
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($_taskID)\n" .
908
-				($taskData ? array2string($taskData) : 'FALSE') . "\n",3,$this->logfile);
906
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($_taskID)\n".
907
+				($taskData ? array2string($taskData) : 'FALSE')."\n", 3, $this->logfile);
909 908
 		}
910 909
 		return $taskData;
911 910
 	}
@@ -919,14 +918,14 @@  discard block
 block discarded – undo
919 918
 	 *
920 919
 	 * @return string|boolean VNOTE representation of the infolog entry or false on error
921 920
 	 */
922
-	function exportVNOTE($_noteID, $_type, $charset='UTF-8')
921
+	function exportVNOTE($_noteID, $_type, $charset = 'UTF-8')
923 922
 	{
924
-		if(!($note = $this->read($_noteID, true, 'server'))) return false;
923
+		if (!($note = $this->read($_noteID, true, 'server'))) return false;
925 924
 
926 925
 		$note = Api\Translation::convert($note,
927 926
 			Api\Translation::charset(), $charset);
928 927
 
929
-		switch	($_type)
928
+		switch ($_type)
930 929
 		{
931 930
 			case 'text/plain':
932 931
 				$txt = $note['info_subject']."\n\n".$note['info_des'];
@@ -940,10 +939,10 @@  discard block
 block discarded – undo
940 939
 						Api\Translation::charset(), $charset);
941 940
 				}
942 941
 				$vnote = new Horde_Icalendar_Vnote();
943
-				$vnote->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware InfoLog '.$GLOBALS['egw_info']['apps']['infolog']['version'].'//'.
942
+				$vnote->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware InfoLog '.$GLOBALS['egw_info']['apps']['infolog']['version'].'//'.
944 943
 					strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
945 944
 				$vnote->setAttribute('VERSION', '1.1');
946
-				foreach (array(	'SUMMARY'		=> $note['info_subject'],
945
+				foreach (array('SUMMARY'		=> $note['info_subject'],
947 946
 								'BODY'			=> $note['info_des'],
948 947
 								'CATEGORIES'	=> $note['info_cat'],
949 948
 							) as $field => $value)
@@ -951,7 +950,7 @@  discard block
 block discarded – undo
951 950
 					$options = array();
952 951
 					if (preg_match('/[^\x20-\x7F]/', $value))
953 952
 					{
954
-						$options['CHARSET']	= $charset;
953
+						$options['CHARSET'] = $charset;
955 954
 						switch ($this->productManufacturer)
956 955
 						{
957 956
 							case 'groupdav':
@@ -981,21 +980,21 @@  discard block
 block discarded – undo
981 980
 				}
982 981
 				if ($note['info_startdate'])
983 982
 				{
984
-					$vnote->setAttribute('CREATED',$note['info_startdate']);
983
+					$vnote->setAttribute('CREATED', $note['info_startdate']);
985 984
 				}
986 985
 				else
987 986
 				{
988
-					$vnote->setAttribute('CREATED',$GLOBALS['egw']->contenthistory->getTSforAction('infolog_note',$_noteID,'add'));
987
+					$vnote->setAttribute('CREATED', $GLOBALS['egw']->contenthistory->getTSforAction('infolog_note', $_noteID, 'add'));
989 988
 				}
990
-				$vnote->setAttribute('LAST-MODIFIED',$GLOBALS['egw']->contenthistory->getTSforAction('infolog_note',$_noteID,'modify'));
989
+				$vnote->setAttribute('LAST-MODIFIED', $GLOBALS['egw']->contenthistory->getTSforAction('infolog_note', $_noteID, 'modify'));
991 990
 
992 991
 				#$vnote->setAttribute('CLASS',$taskData['info_access'] == 'public' ? 'PUBLIC' : 'PRIVATE');
993 992
 
994 993
 				$retval = $vnote->exportvCalendar();
995 994
 				if ($this->log)
996 995
 				{
997
-					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
998
-						array2string($retval)."\n",3,$this->logfile);
996
+					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
997
+						array2string($retval)."\n", 3, $this->logfile);
999 998
 				}
1000 999
 				return $retval;
1001 1000
 		}
@@ -1014,25 +1013,25 @@  discard block
 block discarded – undo
1014 1013
      *
1015 1014
 	 * @return int|boolean integer info_id or false on error
1016 1015
 	 */
1017
-	function importVNOTE(&$_vcalData, $_type, $_noteID=-1, $merge=false, $charset=null)
1016
+	function importVNOTE(&$_vcalData, $_type, $_noteID = -1, $merge = false, $charset = null)
1018 1017
 	{
1019
-		unset($merge);	// no longer used, but required by function signature
1018
+		unset($merge); // no longer used, but required by function signature
1020 1019
 		if ($this->log)
1021 1020
 		{
1022
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
1023
-				array2string($_vcalData)."\n",3,$this->logfile);
1021
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
1022
+				array2string($_vcalData)."\n", 3, $this->logfile);
1024 1023
 		}
1025 1024
 
1026 1025
 		if (!($note = $this->vnotetoegw($_vcalData, $_type, $_noteID, $charset))) return false;
1027 1026
 
1028
-		if($_noteID > 0) $note['info_id'] = $_noteID;
1027
+		if ($_noteID > 0) $note['info_id'] = $_noteID;
1029 1028
 
1030 1029
 		if (empty($note['info_status'])) $note['info_status'] = 'done';
1031 1030
 
1032 1031
 		if ($this->log)
1033 1032
 		{
1034
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
1035
-				array2string($note)."\n",3,$this->logfile);
1033
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
1034
+				array2string($note)."\n", 3, $this->logfile);
1036 1035
 		}
1037 1036
 
1038 1037
 		return $this->write($note, true, true, false);
@@ -1049,7 +1048,7 @@  discard block
 block discarded – undo
1049 1048
 	 *
1050 1049
 	 * @return infolog_id of a matching entry or false, if nothing was found
1051 1050
 	 */
1052
-	function searchVNOTE($_vcalData, $_type, $contentID=null, $relax=false, $charset=null)
1051
+	function searchVNOTE($_vcalData, $_type, $contentID = null, $relax = false, $charset = null)
1053 1052
 	{
1054 1053
 		if (!($note = $this->vnotetoegw($_vcalData, $_type, $contentID, $charset))) return array();
1055 1054
 
@@ -1071,12 +1070,12 @@  discard block
 block discarded – undo
1071 1070
      *
1072 1071
 	 * @return array infolog entry or false on error
1073 1072
 	 */
1074
-	function vnotetoegw($_data, $_type, $_noteID=-1, $charset=null)
1073
+	function vnotetoegw($_data, $_type, $_noteID = -1, $charset = null)
1075 1074
 	{
1076 1075
 		if ($this->log)
1077 1076
 		{
1078
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($_type, $_noteID)\n" .
1079
-				array2string($_data)."\n",3,$this->logfile);
1077
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($_type, $_noteID)\n".
1078
+				array2string($_data)."\n", 3, $this->logfile);
1080 1079
 		}
1081 1080
 		$note = false;
1082 1081
 
@@ -1130,7 +1129,7 @@  discard block
 block discarded – undo
1130 1129
 								case 'CATEGORIES':
1131 1130
 									if ($attribute['value'])
1132 1131
 									{
1133
-										$cats = $this->find_or_add_categories(explode(',',$attribute['value']), $_noteID);
1132
+										$cats = $this->find_or_add_categories(explode(',', $attribute['value']), $_noteID);
1134 1133
 										$note['info_cat'] = $cats[0];
1135 1134
 									}
1136 1135
 									break;
@@ -1141,8 +1140,8 @@  discard block
 block discarded – undo
1141 1140
 		}
1142 1141
 		if ($this->log)
1143 1142
 		{
1144
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($_type, $_noteID)\n" .
1145
-				($note ? array2string($note) : 'FALSE') ."\n",3,$this->logfile);
1143
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($_type, $_noteID)\n".
1144
+				($note ? array2string($note) : 'FALSE')."\n", 3, $this->logfile);
1146 1145
 		}
1147 1146
 		return $note;
1148 1147
 	}
@@ -1155,7 +1154,7 @@  discard block
 block discarded – undo
1155 1154
 	 * @param string $_productManufacturer
1156 1155
 	 * @param string $_productName
1157 1156
 	 */
1158
-	function setSupportedFields($_productManufacturer='', $_productName='')
1157
+	function setSupportedFields($_productManufacturer = '', $_productName = '')
1159 1158
 	{
1160 1159
 		$state = &$_SESSION['SyncML.state'];
1161 1160
 		if (isset($state))
@@ -1207,10 +1206,10 @@  discard block
 block discarded – undo
1207 1206
 		if ($this->log)
1208 1207
 		{
1209 1208
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1210
-				'(' . $this->productManufacturer .
1211
-				', '. $this->productName .', ' .
1212
-				($this->tzid ? $this->tzid : Api\DateTime::$user_timezone->getName()) .
1213
-				")\n" , 3, $this->logfile);
1209
+				'('.$this->productManufacturer.
1210
+				', '.$this->productName.', '.
1211
+				($this->tzid ? $this->tzid : Api\DateTime::$user_timezone->getName()).
1212
+				")\n", 3, $this->logfile);
1214 1213
 		}
1215 1214
 
1216 1215
 		//Horde::logMessage('setSupportedFields(' . $this->productManufacturer . ', '
Please login to merge, or discard this patch.
Braces   +72 added lines, -18 removed lines patch added patch discarded remove patch
@@ -104,7 +104,10 @@  discard block
 block discarded – undo
104 104
 	function __construct(&$_clientProperties = array())
105 105
 	{
106 106
 		parent::__construct();
107
-		if ($this->log) $this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-infolog-vcal";
107
+		if ($this->log)
108
+		{
109
+			$this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-infolog-vcal";
110
+		}
108 111
 		$this->clientProperties = $_clientProperties;
109 112
 	}
110 113
 
@@ -150,7 +153,10 @@  discard block
 block discarded – undo
150 153
 		}
151 154
 		else
152 155
 		{
153
-			if (!($taskData = $this->read($task, true, 'server'))) return false;
156
+			if (!($taskData = $this->read($task, true, 'server')))
157
+			{
158
+				return false;
159
+			}
154 160
 		}
155 161
 
156 162
 		if ($taskData['info_id_parent'])
@@ -190,11 +196,17 @@  discard block
 block discarded – undo
190 196
 				array2string($taskData)."\n",3,$this->logfile);
191 197
 		}
192 198
 
193
-		if (!isset($vcal)) $vcal = new Horde_Icalendar;
199
+		if (!isset($vcal))
200
+		{
201
+			$vcal = new Horde_Icalendar;
202
+		}
194 203
 		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware InfoLog '.$GLOBALS['egw_info']['apps']['infolog']['version'].'//'.
195 204
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']),array(),false);
196 205
 		$vcal->setAttribute('VERSION',$_version,array(),false);
197
-		if ($_method) $vcal->setAttribute('METHOD',$_method,array(),false);
206
+		if ($_method)
207
+		{
208
+			$vcal->setAttribute('METHOD',$_method,array(),false);
209
+		}
198 210
 
199 211
 		$tzid = $this->tzid;
200 212
 		if ($tzid && $tzid != 'UTC')
@@ -273,7 +285,10 @@  discard block
 block discarded – undo
273 285
 				//	__FILE__, __LINE__, PEAR_LOG_INFO);
274 286
 			}
275 287
 
276
-			if (empty($value) && ($size < 0 || $noTruncate)) continue;
288
+			if (empty($value) && ($size < 0 || $noTruncate))
289
+			{
290
+				continue;
291
+			}
277 292
 
278 293
 			if ($field == 'RELATED-TO')
279 294
 			{
@@ -402,7 +417,10 @@  discard block
 block discarded – undo
402 417
 				{
403 418
 					if ($name[2] == ':')
404 419
 					{
405
-						if (($v = json_php_unserialize($value)) && is_array($v)) $value = $v;
420
+						if (($v = json_php_unserialize($value)) && is_array($v))
421
+						{
422
+							$value = $v;
423
+						}
406 424
 						foreach((array)$value as $compvData)
407 425
 						{
408 426
 							$comp = Horde_Icalendar::newComponent(substr($name,3), $vevent);
@@ -530,7 +548,10 @@  discard block
 block discarded – undo
530 548
 			date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
531 549
 		}
532 550
 
533
-		if (!$taskData) return false;
551
+		if (!$taskData)
552
+		{
553
+			return false;
554
+		}
534 555
 
535 556
 		// keep the dates
536 557
 		$this->time2time($taskData, $this->tzid, false);
@@ -576,7 +597,10 @@  discard block
 block discarded – undo
576 597
 			// remove all iCal fields not supported by EGroupware (stored like custom fields)
577 598
 			foreach(array_keys($old) as $name)
578 599
 			{
579
-				if (substr($name,0,2) == '##') unset($old[$name]);
600
+				if (substr($name,0,2) == '##')
601
+				{
602
+					unset($old[$name]);
603
+				}
580 604
 			}
581 605
 			// merge in again all infolog fields not supported by iCal or not allowed to change
582 606
 			$taskData = array_merge($taskData, $old);
@@ -722,7 +746,10 @@  discard block
 block discarded – undo
722 746
 						$component->setAttribute('PERCENT-COMPLETE', $percent_completed = $status == 'COMPLETED' ?
723 747
 							100 : ($status == 'NEEDS-ACTION' ? 0 : 10));
724 748
 					}
725
-					if ($this->log) error_log(__METHOD__."() setting STATUS='$status' and PERCENT-COMPLETE=$percent_completed from COMPLETED and X-INFOLOG-STATUS='$x_infolog_status'\n",3,$this->logfile);
749
+					if ($this->log)
750
+					{
751
+						error_log(__METHOD__."() setting STATUS='$status' and PERCENT-COMPLETE=$percent_completed from COMPLETED and X-INFOLOG-STATUS='$x_infolog_status'\n",3,$this->logfile);
752
+					}
726 753
 				}
727 754
 				// new task without status --> set a default status of NEEDS-ACTION, as otherwise task is marked closed
728 755
 				elseif($_taskID <= 0 && !is_scalar($x_infolog_status) && !is_scalar($completed))
@@ -731,12 +758,18 @@  discard block
 block discarded – undo
731 758
 				}
732 759
 				else
733 760
 				{
734
-					if ($this->log) error_log(__METHOD__."() no STATUS, X-INFOLOG-STATUS='$x_infolog_status', COMPLETED".(is_scalar($completed)?'='.$completed:' not set')." --> leaving status and percent unchanged",3,$this->logfile);
761
+					if ($this->log)
762
+					{
763
+						error_log(__METHOD__."() no STATUS, X-INFOLOG-STATUS='$x_infolog_status', COMPLETED".(is_scalar($completed)?'='.$completed:' not set')." --> leaving status and percent unchanged",3,$this->logfile);
764
+					}
735 765
 				}
736 766
 			}
737 767
 			foreach ($component->getAllAttributes() as $attribute)
738 768
 			{
739
-				if (!$attribute['value'] && $attribute['value'] !== '0') continue;
769
+				if (!$attribute['value'] && $attribute['value'] !== '0')
770
+				{
771
+					continue;
772
+				}
740 773
 
741 774
 				switch ($attribute['name'])
742 775
 				{
@@ -921,7 +954,10 @@  discard block
 block discarded – undo
921 954
 	 */
922 955
 	function exportVNOTE($_noteID, $_type, $charset='UTF-8')
923 956
 	{
924
-		if(!($note = $this->read($_noteID, true, 'server'))) return false;
957
+		if(!($note = $this->read($_noteID, true, 'server')))
958
+		{
959
+			return false;
960
+		}
925 961
 
926 962
 		$note = Api\Translation::convert($note,
927 963
 			Api\Translation::charset(), $charset);
@@ -1023,11 +1059,20 @@  discard block
 block discarded – undo
1023 1059
 				array2string($_vcalData)."\n",3,$this->logfile);
1024 1060
 		}
1025 1061
 
1026
-		if (!($note = $this->vnotetoegw($_vcalData, $_type, $_noteID, $charset))) return false;
1062
+		if (!($note = $this->vnotetoegw($_vcalData, $_type, $_noteID, $charset)))
1063
+		{
1064
+			return false;
1065
+		}
1027 1066
 
1028
-		if($_noteID > 0) $note['info_id'] = $_noteID;
1067
+		if($_noteID > 0)
1068
+		{
1069
+			$note['info_id'] = $_noteID;
1070
+		}
1029 1071
 
1030
-		if (empty($note['info_status'])) $note['info_status'] = 'done';
1072
+		if (empty($note['info_status']))
1073
+		{
1074
+			$note['info_status'] = 'done';
1075
+		}
1031 1076
 
1032 1077
 		if ($this->log)
1033 1078
 		{
@@ -1051,9 +1096,15 @@  discard block
 block discarded – undo
1051 1096
 	 */
1052 1097
 	function searchVNOTE($_vcalData, $_type, $contentID=null, $relax=false, $charset=null)
1053 1098
 	{
1054
-		if (!($note = $this->vnotetoegw($_vcalData, $_type, $contentID, $charset))) return array();
1099
+		if (!($note = $this->vnotetoegw($_vcalData, $_type, $contentID, $charset)))
1100
+		{
1101
+			return array();
1102
+		}
1055 1103
 
1056
-		if ($contentID)	$note['info_id'] = $contentID;
1104
+		if ($contentID)
1105
+		{
1106
+			$note['info_id'] = $contentID;
1107
+		}
1057 1108
 
1058 1109
 		unset($note['info_startdate']);
1059 1110
 
@@ -1105,7 +1156,10 @@  discard block
 block discarded – undo
1105 1156
 				{
1106 1157
 					$_data = Api\Translation::convert($_data, $charset, 'utf-8');
1107 1158
 				}
1108
-				if (!$vnote->parsevCalendar($_data, 'VCALENDAR'))	return false;
1159
+				if (!$vnote->parsevCalendar($_data, 'VCALENDAR'))
1160
+				{
1161
+					return false;
1162
+				}
1109 1163
 
1110 1164
 				$components = $vnote->getComponent();
1111 1165
 				foreach ($components as $component)
Please login to merge, or discard this patch.
infolog/inc/class.infolog_import_infologs_csv.inc.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -108,8 +108,7 @@  discard block
 block discarded – undo
108 108
 	/**
109 109
 	 * imports entries according to given definition object.
110 110
 	 * @param resource $_stream
111
-	 * @param string $_charset
112
-	 * @param definition $_definition
111
+	 * @param importexport_definition $_definition
113 112
 	 */
114 113
 	public function import( $_stream, importexport_definition $_definition ) {
115 114
 		$import_csv = new importexport_import_csv( $_stream, array(
@@ -527,6 +526,7 @@  discard block
 block discarded – undo
527 526
 	 *
528 527
 	 * This is a copy of what's in importexport_basic_import_csv, and can go
529 528
 	 * away if this is changed to extend it
529
+	 * @param integer $record_num
530 530
 	 */
531 531
 	protected function link_by_cf($record_num, $app, $fieldname, $_value)
532 532
 	{
Please login to merge, or discard this patch.
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
 	private $boinfolog;
75 75
 
76 76
 	/**
77
-	* For figuring out if a record has changed
78
-	*
79
-	* @var infolog_tracking::
80
-	*/
77
+	 * For figuring out if a record has changed
78
+	 *
79
+	 * @var infolog_tracking::
80
+	 */
81 81
 	protected $tracking;
82 82
 
83 83
 	/**
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	protected $errors = array();
102 102
 
103 103
 	/**
104
- 	* List of actions, and how many times that action was taken
104
+	 * List of actions, and how many times that action was taken
105 105
 	 */
106 106
 	protected $results = array();
107 107
 
@@ -466,37 +466,37 @@  discard block
 block discarded – undo
466 466
 	}
467 467
 
468 468
 	/**
469
-	* Returns warnings that were encountered during importing
470
-	* Maximum of one warning message per record, but you can append if you need to
471
-	*
472
-	* @return Array (
473
-	*       record_# => warning message
474
-	*       )
475
-	*/
469
+	 * Returns warnings that were encountered during importing
470
+	 * Maximum of one warning message per record, but you can append if you need to
471
+	 *
472
+	 * @return Array (
473
+	 *       record_# => warning message
474
+	 *       )
475
+	 */
476 476
 	public function get_warnings() {
477 477
 		return $this->warnings;
478 478
 	}
479 479
 
480 480
 	/**
481
-	* Returns errors that were encountered during importing
482
-	* Maximum of one error message per record, but you can append if you need to
483
-	*
484
-	* @return Array (
485
-	*       record_# => error message
486
-	*       )
487
-	*/
481
+	 * Returns errors that were encountered during importing
482
+	 * Maximum of one error message per record, but you can append if you need to
483
+	 *
484
+	 * @return Array (
485
+	 *       record_# => error message
486
+	 *       )
487
+	 */
488 488
 	public function get_errors() {
489 489
 		return $this->errors;
490 490
 	}
491 491
 
492 492
 	/**
493
-	* Returns a list of actions taken, and the number of records for that action.
494
-	* Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
495
-	*
496
-	* @return Array (
497
-	*       action => record count
498
-	* )
499
-	*/
493
+	 * Returns a list of actions taken, and the number of records for that action.
494
+	 * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
495
+	 *
496
+	 * @return Array (
497
+	 *       action => record count
498
+	 * )
499
+	 */
500 500
 	public function get_results() {
501 501
 		return $this->results;
502 502
 	}
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -20,16 +20,16 @@  discard block
 block discarded – undo
20 20
 {
21 21
 
22 22
 	private static $plugin_options = array(
23
-		'fieldsep', 		// char
24
-		'charset', 			// string
25
-		'contact_owner', 	// int
26
-		'update_cats', 			// string {override|add} overides record
23
+		'fieldsep', // char
24
+		'charset', // string
25
+		'contact_owner', // int
26
+		'update_cats', // string {override|add} overides record
27 27
 								// with cat(s) from csv OR add the cat from
28 28
 								// csv file to exeisting cat(s) of record
29 29
 		'num_header_lines', // int number of header lines
30 30
 		'field_conversion', // array( $csv_col_num => conversion)
31
-		'field_mapping',	// array( $csv_col_num => adb_filed)
32
-		'conditions',		/* => array containing condition arrays:
31
+		'field_mapping', // array( $csv_col_num => adb_filed)
32
+		'conditions', /* => array containing condition arrays:
33 33
 				'type' => exists, // exists
34 34
 				'string' => '#kundennummer',
35 35
 				'true' => array(
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
 	/**
56 56
 	 * actions wich could be done to data entries
57 57
 	 */
58
-	protected static $actions = array( 'none', 'update', 'insert', 'delete', );
58
+	protected static $actions = array('none', 'update', 'insert', 'delete',);
59 59
 
60 60
 	/**
61 61
 	 * conditions for actions
62 62
 	 *
63 63
 	 * @var array
64 64
 	 */
65
-	protected static $conditions = array( 'exists' );
65
+	protected static $conditions = array('exists');
66 66
 
67 67
 	/**
68 68
 	 * @var definition
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 	 * @param string $_charset
113 113
 	 * @param definition $_definition
114 114
 	 */
115
-	public function import( $_stream, importexport_definition $_definition ) {
116
-		$import_csv = new importexport_import_csv( $_stream, array(
115
+	public function import($_stream, importexport_definition $_definition) {
116
+		$import_csv = new importexport_import_csv($_stream, array(
117 117
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
118 118
 			'charset' => $_definition->plugin_options['charset'],
119 119
 		));
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
124 124
 
125 125
 		// dry run?
126
-		$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] :  false;
126
+		$this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false;
127 127
 
128 128
 		// fetch the infolog bo
129 129
 		$this->boinfolog = new infolog_bo();
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
 		$import_csv->conversion_class = $this;
145 145
 
146 146
 		//check if file has a header lines
147
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
147
+		if (isset($_definition->plugin_options['num_header_lines']) && $_definition->plugin_options['num_header_lines'] > 0) {
148 148
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
149
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
149
+		} elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
150 150
 			// First method is preferred
151 151
 			$import_csv->skip_records(1);
152 152
 		}
@@ -173,56 +173,56 @@  discard block
 block discarded – undo
173 173
 		$this->errors = array();
174 174
 		$this->warnings = array();
175 175
 
176
-		while ( $record = $import_csv->get_record() )
176
+		while ($record = $import_csv->get_record())
177 177
 		{
178 178
 			$success = false;
179 179
 
180 180
 			// don't import empty records
181
-			if( count( array_unique( $record ) ) < 2 ) continue;
181
+			if (count(array_unique($record)) < 2) continue;
182 182
 
183 183
 			$lookups = $_lookups;
184 184
 
185 185
 			// Early detection of type, to load appropriate statuses
186
-			foreach(array($lookups['info_type'], array_map('strtolower',array_map('lang',$lookups['info_type']))) as $types)
186
+			foreach (array($lookups['info_type'], array_map('strtolower', array_map('lang', $lookups['info_type']))) as $types)
187 187
 			{
188
-				if($record['info_type'] && $key = array_search(strtolower($record['info_type']),$types))
188
+				if ($record['info_type'] && $key = array_search(strtolower($record['info_type']), $types))
189 189
 				{
190 190
 					$lookups['info_status'] = $this->boinfolog->status[$key];
191 191
 				}
192 192
 			}
193 193
 
194 194
 			$result = importexport_import_csv::convert($record, infolog_egw_record::$types, 'infolog', $lookups, $_definition->plugin_options['convert']);
195
-			if($result)
195
+			if ($result)
196 196
 			{
197 197
 				$this->warnings[$import_csv->get_current_position()] = $result;
198 198
 			}
199 199
 
200 200
 			// Make sure type is valid
201
-			if(!$record['info_type'] || $record['info_type'] && !$this->boinfolog->enums['type'][$record['info_type']])
201
+			if (!$record['info_type'] || $record['info_type'] && !$this->boinfolog->enums['type'][$record['info_type']])
202 202
 			{
203 203
 				// Check for translated type
204
-				$un_trans = Api\Translation::get_message_id($record['info_type'],'infolog');
205
-				if($record['info_type'] && $this->boinfolog->enums['type'][$un_trans])
204
+				$un_trans = Api\Translation::get_message_id($record['info_type'], 'infolog');
205
+				if ($record['info_type'] && $this->boinfolog->enums['type'][$un_trans])
206 206
 				{
207 207
 					$record['info_type'] = $un_trans;
208 208
 				}
209 209
 				else
210 210
 				{
211
-					$this->errors[$import_csv->get_current_position()] .= ($this->errors[$import_csv->get_current_position()] ? "\n":'').
211
+					$this->errors[$import_csv->get_current_position()] .= ($this->errors[$import_csv->get_current_position()] ? "\n" : '').
212 212
 						lang('Unknown type: %1', $record['info_type']);
213 213
 				}
214 214
 			}
215 215
 
216 216
 			// Set default status for type, if not specified
217
-			if(!$record['info_status'] && $record['info_type'])
217
+			if (!$record['info_status'] && $record['info_type'])
218 218
 			{
219 219
 				$record['info_status'] = $this->boinfolog->status['defaults'][$record['info_type']];
220 220
 			}
221 221
 
222 222
 			// Set owner, unless it's supposed to come from CSV file
223
-			if($_definition->plugin_options['owner_from_csv'])
223
+			if ($_definition->plugin_options['owner_from_csv'])
224 224
 			{
225
-				if(!is_numeric($record['info_owner']))
225
+				if (!is_numeric($record['info_owner']))
226 226
 				{
227 227
 					$this->errors[$import_csv->get_current_position()] = lang(
228 228
 						'Invalid owner ID: %1.  Might be a bad field translation.  Used %2 instead.',
@@ -239,51 +239,51 @@  discard block
 block discarded – undo
239 239
 			if (!isset($record['info_owner'])) $record['info_owner'] = $GLOBALS['egw_info']['user']['account_id'];
240 240
 
241 241
 			// Responsible has to be an array
242
-			$record['info_responsible'] = $record['info_responsible'] ? explode(',',$record['info_responsible']) : 0;
242
+			$record['info_responsible'] = $record['info_responsible'] ? explode(',', $record['info_responsible']) : 0;
243 243
 
244 244
 			// Special values
245 245
 			if ($record['addressbook'] && !is_numeric($record['addressbook']))
246 246
 			{
247
-				list($lastname,$firstname,$org_name) = explode(',',$record['addressbook']);
248
-				$record['addressbook'] = importexport_basic_import_csv::addr_id($lastname,$firstname,$org_name);
247
+				list($lastname, $firstname, $org_name) = explode(',', $record['addressbook']);
248
+				$record['addressbook'] = importexport_basic_import_csv::addr_id($lastname, $firstname, $org_name);
249 249
 			}
250 250
 			if ($record['projectmanager'] && !is_numeric($record['projectmanager']))
251 251
 			{
252 252
 				$record['projectmanager'] = self::project_id($record['projectmanager']);
253 253
 			}
254 254
 
255
-			if ( $_definition->plugin_options['conditions'] )
255
+			if ($_definition->plugin_options['conditions'])
256 256
 			{
257
-				foreach ( $_definition->plugin_options['conditions'] as $condition )
257
+				foreach ($_definition->plugin_options['conditions'] as $condition)
258 258
 				{
259 259
 					$results = array();
260
-					switch ( $condition['type'] )
260
+					switch ($condition['type'])
261 261
 					{
262 262
 						// exists
263 263
 						case 'exists' :
264
-							if($record[$condition['string']]) {
265
-								$query['col_filter'] = array( $condition['string'] => $record[$condition['string']],);
264
+							if ($record[$condition['string']]) {
265
+								$query['col_filter'] = array($condition['string'] => $record[$condition['string']],);
266 266
 								// Needed to query custom fields
267
-								if($condition['string'][0] == '#') $query['custom_fields'] = true;
267
+								if ($condition['string'][0] == '#') $query['custom_fields'] = true;
268 268
 								$results = $this->boinfolog->search($query);
269 269
 							}
270 270
 
271
-							if ( is_array( $results ) && count( array_keys( $results )) >= 1) {
271
+							if (is_array($results) && count(array_keys($results)) >= 1) {
272 272
 								// apply action to all records matching this exists condition
273 273
 								$action = $condition['true'];
274
-								foreach ( (array)$results as $contact ) {
274
+								foreach ((array)$results as $contact) {
275 275
 									$record['info_id'] = $contact['info_id'];
276 276
 									$record['info_owner'] = $contact['info_owner'];
277
-									if ( $_definition->plugin_options['update_cats'] == 'add' ) {
278
-										if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] );
279
-										if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] );
280
-										$record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $contact['cat_id'] ) ) );
277
+									if ($_definition->plugin_options['update_cats'] == 'add') {
278
+										if (!is_array($contact['cat_id'])) $contact['cat_id'] = explode(',', $contact['cat_id']);
279
+										if (!is_array($record['cat_id'])) $record['cat_id'] = explode(',', $record['cat_id']);
280
+										$record['cat_id'] = implode(',', array_unique(array_merge($record['cat_id'], $contact['cat_id'])));
281 281
 									}
282
-									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
282
+									$success = $this->action($action['action'], $record, $import_csv->get_current_position());
283 283
 								}
284 284
 							} else {
285 285
 								$action = $condition['false'];
286
-								$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
286
+								$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
287 287
 							}
288 288
 							break;
289 289
 
@@ -298,16 +298,16 @@  discard block
 block discarded – undo
298 298
 			else
299 299
 			{
300 300
 				// unconditional insert
301
-				$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
301
+				$success = $this->action('insert', $record, $import_csv->get_current_position());
302 302
 			}
303
-			if($success) $count++;
304
-			if($this->warnings[$import_csv->get_current_position()])
303
+			if ($success) $count++;
304
+			if ($this->warnings[$import_csv->get_current_position()])
305 305
 			{
306
-				$this->warnings[$import_csv->get_current_position()] .= "\nRecord:\n" .array2string($record);
306
+				$this->warnings[$import_csv->get_current_position()] .= "\nRecord:\n".array2string($record);
307 307
 			}
308
-			if($this->errors[$import_csv->get_current_position()])
308
+			if ($this->errors[$import_csv->get_current_position()])
309 309
 			{
310
-				$this->errors[$import_csv->get_current_position()] .= "\nRecord:\n" .array2string($record);
310
+				$this->errors[$import_csv->get_current_position()] .= "\nRecord:\n".array2string($record);
311 311
 			}
312 312
 		}
313 313
 		return $count;
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	 * @param array $_data contact data for the action
321 321
 	 * @return bool success or not
322 322
 	 */
323
-	private function action ( $_action, $_data, $record_num = 0 )
323
+	private function action($_action, $_data, $record_num = 0)
324 324
 	{
325 325
 		$result = true;
326 326
 		switch ($_action) {
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 				// Only update if there are changes
331 331
 				$old = $this->boinfolog->read($_data['info_id']);
332 332
 
333
-				if(!$this->definition->plugin_options['change_owner'])
333
+				if (!$this->definition->plugin_options['change_owner'])
334 334
 				{
335 335
 					// Don't change addressbook of an existing contact
336 336
 					unset($_data['owner']);
@@ -339,21 +339,21 @@  discard block
 block discarded – undo
339 339
 				// Merge to deal with fields not in import record
340 340
 				$_data = array_merge($old, $_data);
341 341
 				$changed = $this->tracking->changed_fields($_data, $old);
342
-				if(count($changed) == 0 && !$this->definition->plugin_options['update_timestamp'])
342
+				if (count($changed) == 0 && !$this->definition->plugin_options['update_timestamp'])
343 343
 				{
344 344
 					break;
345 345
 				}
346 346
 
347 347
 				// Fall through
348 348
 			case 'insert' :
349
-				if ( $this->dry_run )
349
+				if ($this->dry_run)
350 350
 				{
351 351
 					//print_r($_data);
352 352
 
353 353
 					// Check for link during dry run
354
-					if($_data['link_custom'])
354
+					if ($_data['link_custom'])
355 355
 					{
356
-						list($app, $app_id2) = explode(':', $_data['link_custom'],2);
356
+						list($app, $app_id2) = explode(':', $_data['link_custom'], 2);
357 357
 						$app_id = $this->link_by_cf($record_num, $app, $field, $app_id2);
358 358
 					}
359 359
 
@@ -363,12 +363,12 @@  discard block
 block discarded – undo
363 363
 				else
364 364
 				{
365 365
 					$result = $this->boinfolog->write(
366
-						$_data, true, 2,true, 	// 2 = dont touch modification date
366
+						$_data, true, 2, true, // 2 = dont touch modification date
367 367
 						$this->definition->plugin_options['no_notification']
368 368
 					);
369
-					if(!$result)
369
+					if (!$result)
370 370
 					{
371
-						if($result === false)
371
+						if ($result === false)
372 372
 						{
373 373
 							$this->errors[$record_num] = lang('Permissions error - %1 could not %2',
374 374
 								$GLOBALS['egw']->accounts->id2name($_data['info_owner']),
@@ -391,20 +391,20 @@  discard block
 block discarded – undo
391 391
 		}
392 392
 
393 393
 		// Process some additional fields
394
-		if(!is_numeric($result))
394
+		if (!is_numeric($result))
395 395
 		{
396 396
 			return $result;
397 397
 		}
398 398
 		$info_link_id = $_data['info_link_id'];
399
-		foreach(array_keys(self::$special_fields) as $field)
399
+		foreach (array_keys(self::$special_fields) as $field)
400 400
 		{
401
-			if(!$_data[$field]) continue;
402
-			if(strpos($field, 'link') === 0)
401
+			if (!$_data[$field]) continue;
402
+			if (strpos($field, 'link') === 0)
403 403
 			{
404
-				list($app, $app_id) = explode(':', $_data[$field],2);
404
+				list($app, $app_id) = explode(':', $_data[$field], 2);
405 405
 
406 406
 				// Linking to another entry based on matching custom fields
407
-				if($field == 'link_custom')
407
+				if ($field == 'link_custom')
408 408
 				{
409 409
 					$app_id = $this->link_by_cf($record_num, $app, $field, $app_id);
410 410
 				}
@@ -418,14 +418,14 @@  discard block
 block discarded – undo
418 418
 			{
419 419
 				$id = $_data['info_id'] ? $_data['info_id'] : (int)$result;
420 420
 				//echo "<p>linking infolog:$id with $app:$app_id</p>\n";
421
-				$link_id = Link::link('infolog',$id,$app,$app_id);
421
+				$link_id = Link::link('infolog', $id, $app, $app_id);
422 422
 				if ($link_id && !$info_link_id)
423 423
 				{
424 424
 					$to_write = array(
425 425
 						'info_id'      => $id,
426 426
 						'info_link_id' => $link_id,
427 427
 					);
428
-					$this->boinfolog->write($to_write,False,false,true,true);	// last true = no notifications, as no real change
428
+					$this->boinfolog->write($to_write, False, false, true, true); // last true = no notifications, as no real change
429 429
 					$info_link_id = $link_id;
430 430
 				}
431 431
 			}
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 	// Extra conversion functions - must be static
526 526
 	public static function project_id($num_or_title)
527 527
 	{
528
-		static $boprojects=null;
528
+		static $boprojects = null;
529 529
 
530 530
 		if (!$num_or_title) return false;
531 531
 
@@ -552,18 +552,18 @@  discard block
 block discarded – undo
552 552
 	{
553 553
 		$app_id = false;
554 554
 
555
-		list($custom_field, $value) = explode(':',$_value);
555
+		list($custom_field, $value) = explode(':', $_value);
556 556
 		// Find matching entry
557
-		if($app && $custom_field && $value)
557
+		if ($app && $custom_field && $value)
558 558
 		{
559 559
 			$cfs = Api\Storage\Customfields::get($app);
560 560
 			// Error if no custom fields, probably something wrong in definition
561
-			if(!$cfs[$custom_field])
561
+			if (!$cfs[$custom_field])
562 562
 			{
563 563
 				// Check for users specifing label instead of name
564
-				foreach($cfs as $name => $settings)
564
+				foreach ($cfs as $name => $settings)
565 565
 				{
566
-					if(strtolower($settings['label']) == strtolower($custom_field))
566
+					if (strtolower($settings['label']) == strtolower($custom_field))
567 567
 					{
568 568
 						$custom_field = $name;
569 569
 						break;
@@ -572,23 +572,23 @@  discard block
 block discarded – undo
572 572
 			}
573 573
 
574 574
 			// Couldn't find field, give an error - something's wrong
575
-			if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) {
575
+			if (!$cfs[$custom_field] && !$cfs[substr($custom_field, 1)]) {
576 576
 				$this->errors[$record_num] .= lang('No custom field "%1" for %2.',
577 577
 					$custom_field, lang($app));
578 578
 				return false;
579 579
 			}
580
-			if($custom_field[0] != '#') $custom_field = '#' . $custom_field;
580
+			if ($custom_field[0] != '#') $custom_field = '#'.$custom_field;
581 581
 
582 582
 			// Search
583
-			if(Link::get_registry($app, 'query'))
583
+			if (Link::get_registry($app, 'query'))
584 584
 			{
585
-				$options = array('filter' => array("$custom_field = " . $GLOBALS['egw']->db->quote($value)));
585
+				$options = array('filter' => array("$custom_field = ".$GLOBALS['egw']->db->quote($value)));
586 586
 				$result = Link::query($app, '', $options);
587 587
 
588 588
 				// Only one allowed
589
-				if(count($result) != 1)
589
+				if (count($result) != 1)
590 590
 				{
591
-					$this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : '') .
591
+					$this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : '').
592 592
 						lang('Unable to link to %3 by custom field "%1": "%4".  %2 matches.',
593 593
 						$custom_field, count($result), lang($app), $options['filter'][0]
594 594
 					);
Please login to merge, or discard this patch.
Braces   +78 added lines, -28 removed lines patch added patch discarded remove patch
@@ -112,7 +112,8 @@  discard block
 block discarded – undo
112 112
 	 * @param string $_charset
113 113
 	 * @param definition $_definition
114 114
 	 */
115
-	public function import( $_stream, importexport_definition $_definition ) {
115
+	public function import( $_stream, importexport_definition $_definition )
116
+	{
116 117
 		$import_csv = new importexport_import_csv( $_stream, array(
117 118
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
118 119
 			'charset' => $_definition->plugin_options['charset'],
@@ -144,9 +145,12 @@  discard block
 block discarded – undo
144 145
 		$import_csv->conversion_class = $this;
145 146
 
146 147
 		//check if file has a header lines
147
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
148
+		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0)
149
+		{
148 150
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
149
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
151
+		}
152
+		elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line'])
153
+		{
150 154
 			// First method is preferred
151 155
 			$import_csv->skip_records(1);
152 156
 		}
@@ -178,7 +182,10 @@  discard block
 block discarded – undo
178 182
 			$success = false;
179 183
 
180 184
 			// don't import empty records
181
-			if( count( array_unique( $record ) ) < 2 ) continue;
185
+			if( count( array_unique( $record ) ) < 2 )
186
+			{
187
+				continue;
188
+			}
182 189
 
183 190
 			$lookups = $_lookups;
184 191
 
@@ -236,7 +243,10 @@  discard block
 block discarded – undo
236 243
 			{
237 244
 				$record['info_owner'] = $_definition->plugin_options['record_owner'];
238 245
 			}
239
-			if (!isset($record['info_owner'])) $record['info_owner'] = $GLOBALS['egw_info']['user']['account_id'];
246
+			if (!isset($record['info_owner']))
247
+			{
248
+				$record['info_owner'] = $GLOBALS['egw_info']['user']['account_id'];
249
+			}
240 250
 
241 251
 			// Responsible has to be an array
242 252
 			$record['info_responsible'] = $record['info_responsible'] ? explode(',',$record['info_responsible']) : 0;
@@ -261,27 +271,42 @@  discard block
 block discarded – undo
261 271
 					{
262 272
 						// exists
263 273
 						case 'exists' :
264
-							if($record[$condition['string']]) {
274
+							if($record[$condition['string']])
275
+							{
265 276
 								$query['col_filter'] = array( $condition['string'] => $record[$condition['string']],);
266 277
 								// Needed to query custom fields
267
-								if($condition['string'][0] == '#') $query['custom_fields'] = true;
278
+								if($condition['string'][0] == '#')
279
+								{
280
+									$query['custom_fields'] = true;
281
+								}
268 282
 								$results = $this->boinfolog->search($query);
269 283
 							}
270 284
 
271
-							if ( is_array( $results ) && count( array_keys( $results )) >= 1) {
285
+							if ( is_array( $results ) && count( array_keys( $results )) >= 1)
286
+							{
272 287
 								// apply action to all records matching this exists condition
273 288
 								$action = $condition['true'];
274
-								foreach ( (array)$results as $contact ) {
289
+								foreach ( (array)$results as $contact )
290
+								{
275 291
 									$record['info_id'] = $contact['info_id'];
276 292
 									$record['info_owner'] = $contact['info_owner'];
277
-									if ( $_definition->plugin_options['update_cats'] == 'add' ) {
278
-										if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] );
279
-										if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] );
293
+									if ( $_definition->plugin_options['update_cats'] == 'add' )
294
+									{
295
+										if ( !is_array( $contact['cat_id'] ) )
296
+										{
297
+											$contact['cat_id'] = explode( ',', $contact['cat_id'] );
298
+										}
299
+										if ( !is_array( $record['cat_id'] ) )
300
+										{
301
+											$record['cat_id'] = explode( ',', $record['cat_id'] );
302
+										}
280 303
 										$record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $contact['cat_id'] ) ) );
281 304
 									}
282 305
 									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
283 306
 								}
284
-							} else {
307
+							}
308
+							else
309
+							{
285 310
 								$action = $condition['false'];
286 311
 								$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
287 312
 							}
@@ -292,7 +317,10 @@  discard block
 block discarded – undo
292 317
 							die('condition / action not supported!!!');
293 318
 							break;
294 319
 					}
295
-					if ($action['last']) break;
320
+					if ($action['last'])
321
+					{
322
+						break;
323
+					}
296 324
 				}
297 325
 			}
298 326
 			else
@@ -300,7 +328,10 @@  discard block
 block discarded – undo
300 328
 				// unconditional insert
301 329
 				$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
302 330
 			}
303
-			if($success) $count++;
331
+			if($success)
332
+			{
333
+				$count++;
334
+			}
304 335
 			if($this->warnings[$import_csv->get_current_position()])
305 336
 			{
306 337
 				$this->warnings[$import_csv->get_current_position()] .= "\nRecord:\n" .array2string($record);
@@ -323,7 +354,8 @@  discard block
 block discarded – undo
323 354
 	private function action ( $_action, $_data, $record_num = 0 )
324 355
 	{
325 356
 		$result = true;
326
-		switch ($_action) {
357
+		switch ($_action)
358
+		{
327 359
 			case 'none' :
328 360
 				return true;
329 361
 			case 'update' :
@@ -398,7 +430,10 @@  discard block
 block discarded – undo
398 430
 		$info_link_id = $_data['info_link_id'];
399 431
 		foreach(array_keys(self::$special_fields) as $field)
400 432
 		{
401
-			if(!$_data[$field]) continue;
433
+			if(!$_data[$field])
434
+			{
435
+				continue;
436
+			}
402 437
 			if(strpos($field, 'link') === 0)
403 438
 			{
404 439
 				list($app, $app_id) = explode(':', $_data[$field],2);
@@ -438,7 +473,8 @@  discard block
 block discarded – undo
438 473
 	 *
439 474
 	 * @return string name
440 475
 	 */
441
-	public static function get_name() {
476
+	public static function get_name()
477
+	{
442 478
 		return lang('Infolog CSV import');
443 479
 	}
444 480
 
@@ -447,7 +483,8 @@  discard block
 block discarded – undo
447 483
 	 *
448 484
 	 * @return string descriprion
449 485
 	 */
450
-	public static function get_description() {
486
+	public static function get_description()
487
+	{
451 488
 		return lang("Imports entries into the infolog from a CSV File. CSV means 'Comma Separated Values'. However in the options Tab you can also choose other seperators.");
452 489
 	}
453 490
 
@@ -456,7 +493,8 @@  discard block
 block discarded – undo
456 493
 	 *
457 494
 	 * @return string suffix (comma seperated)
458 495
 	 */
459
-	public static function get_filesuffix() {
496
+	public static function get_filesuffix()
497
+	{
460 498
 		return 'csv';
461 499
 	}
462 500
 
@@ -472,7 +510,8 @@  discard block
 block discarded – undo
472 510
 	 * 		preserv		=> array,
473 511
 	 * )
474 512
 	 */
475
-	public function get_options_etpl() {
513
+	public function get_options_etpl()
514
+	{
476 515
 		// lets do it!
477 516
 	}
478 517
 
@@ -481,7 +520,8 @@  discard block
 block discarded – undo
481 520
 	 *
482 521
 	 * @return string etemplate name
483 522
 	 */
484
-	public function get_selectors_etpl() {
523
+	public function get_selectors_etpl()
524
+	{
485 525
 		// lets do it!
486 526
 	}
487 527
 
@@ -493,7 +533,8 @@  discard block
 block discarded – undo
493 533
 	*       record_# => warning message
494 534
 	*       )
495 535
 	*/
496
-	public function get_warnings() {
536
+	public function get_warnings()
537
+	{
497 538
 		return $this->warnings;
498 539
 	}
499 540
 
@@ -505,7 +546,8 @@  discard block
 block discarded – undo
505 546
 	*       record_# => error message
506 547
 	*       )
507 548
 	*/
508
-	public function get_errors() {
549
+	public function get_errors()
550
+	{
509 551
 		return $this->errors;
510 552
 	}
511 553
 
@@ -517,7 +559,8 @@  discard block
 block discarded – undo
517 559
 	*       action => record count
518 560
 	* )
519 561
 	*/
520
-	public function get_results() {
562
+	public function get_results()
563
+	{
521 564
 		return $this->results;
522 565
 	}
523 566
 	// end of iface_export_plugin
@@ -527,7 +570,10 @@  discard block
 block discarded – undo
527 570
 	{
528 571
 		static $boprojects=null;
529 572
 
530
-		if (!$num_or_title) return false;
573
+		if (!$num_or_title)
574
+		{
575
+			return false;
576
+		}
531 577
 
532 578
 		if (!is_object($boprojects))
533 579
 		{
@@ -572,12 +618,16 @@  discard block
 block discarded – undo
572 618
 			}
573 619
 
574 620
 			// Couldn't find field, give an error - something's wrong
575
-			if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) {
621
+			if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)])
622
+			{
576 623
 				$this->errors[$record_num] .= lang('No custom field "%1" for %2.',
577 624
 					$custom_field, lang($app));
578 625
 				return false;
579 626
 			}
580
-			if($custom_field[0] != '#') $custom_field = '#' . $custom_field;
627
+			if($custom_field[0] != '#')
628
+			{
629
+				$custom_field = '#' . $custom_field;
630
+			}
581 631
 
582 632
 			// Search
583 633
 			if(Link::get_registry($app, 'query'))
Please login to merge, or discard this patch.
infolog/inc/class.infolog_tracking.inc.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -125,7 +125,6 @@
 block discarded – undo
125 125
 	/**
126 126
 	 * Constructor
127 127
 	 *
128
-	 * @param botracker $botracker
129 128
 	 * @return tracker_tracking
130 129
 	 */
131 130
 	function __construct(&$infolog_bo)
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	function __construct(&$infolog_bo)
130 130
 	{
131
-		parent::__construct('infolog');	// add custom fields from infolog
131
+		parent::__construct('infolog'); // add custom fields from infolog
132 132
 
133
-		$this->infolog =& $infolog_bo;
133
+		$this->infolog = & $infolog_bo;
134 134
 	}
135 135
 
136 136
 	/**
@@ -142,23 +142,23 @@  discard block
 block discarded – undo
142 142
 	 * @param array $old
143 143
 	 * @return string
144 144
 	 */
145
-	function get_subject($data,$old)
145
+	function get_subject($data, $old)
146 146
 	{
147 147
 		if ($data['prefix'])
148 148
 		{
149
-			$prefix = $data['prefix'];	// async notification
149
+			$prefix = $data['prefix']; // async notification
150 150
 		}
151 151
 		elseif (!$old || $old['info_status'] == 'deleted')
152 152
 		{
153
-			$prefix = lang('New %1',lang($this->infolog->enums['type'][$data['info_type']]));
153
+			$prefix = lang('New %1', lang($this->infolog->enums['type'][$data['info_type']]));
154 154
 		}
155
-		elseif($data['info_status'] == 'deleted')
155
+		elseif ($data['info_status'] == 'deleted')
156 156
 		{
157
-			$prefix = lang('%1 deleted',lang($this->infolog->enums['type'][$data['info_type']]));
157
+			$prefix = lang('%1 deleted', lang($this->infolog->enums['type'][$data['info_type']]));
158 158
 		}
159 159
 		else
160 160
 		{
161
-			$prefix = lang('%1 modified',lang($this->infolog->enums['type'][$data['info_type']]));
161
+			$prefix = lang('%1 modified', lang($this->infolog->enums['type'][$data['info_type']]));
162 162
 		}
163 163
 		return $prefix.': '.$data['info_subject'];
164 164
 	}
@@ -170,22 +170,22 @@  discard block
 block discarded – undo
170 170
 	 * @param array $old
171 171
 	 * @return string
172 172
 	 */
173
-	function get_message($data,$old)
173
+	function get_message($data, $old)
174 174
 	{
175
-		if ($data['message']) return $data['message'];	// async notification
175
+		if ($data['message']) return $data['message']; // async notification
176 176
 
177 177
 		if (!$old || $old['info_status'] == 'deleted')
178 178
 		{
179
-			return lang('New %1 created by %2 at %3',lang($this->infolog->enums['type'][$data['info_type']]),
180
-				Api\Accounts::username($this->infolog->user),$this->datetime('now'));
179
+			return lang('New %1 created by %2 at %3', lang($this->infolog->enums['type'][$data['info_type']]),
180
+				Api\Accounts::username($this->infolog->user), $this->datetime('now'));
181 181
 		}
182
-		elseif($data['info_status'] == 'deleted')
182
+		elseif ($data['info_status'] == 'deleted')
183 183
 		{
184
-			return lang('%1 deleted by %2 at %3',lang($this->infolog->enums['type'][$data['info_type']]),
184
+			return lang('%1 deleted by %2 at %3', lang($this->infolog->enums['type'][$data['info_type']]),
185 185
 				Api\Accounts::username($data['info_modifier']),
186 186
 				$this->datetime($data['info_datemodified']));
187 187
 		}
188
-		return lang('%1 modified by %2 at %3',lang($this->infolog->enums['type'][$data['info_type']]),
188
+		return lang('%1 modified by %2 at %3', lang($this->infolog->enums['type'][$data['info_type']]),
189 189
 			Api\Accounts::username($data['info_modifier']),
190 190
 			$this->datetime($data['info_datemodified']));
191 191
 	}
@@ -197,13 +197,13 @@  discard block
 block discarded – undo
197 197
 	 * @param int|string $receiver nummeric account_id or email address
198 198
 	 * @return array of details as array with values for keys 'label','value','type'
199 199
 	 */
200
-	function get_details($data,$receiver=null)
200
+	function get_details($data, $receiver = null)
201 201
 	{
202 202
 		//error_log(__METHOD__.__LINE__.' Data:'.array2string($data));
203 203
 		$responsible = array();
204 204
 		if ($data['info_responsible'])
205 205
 		{
206
-			foreach($data['info_responsible'] as $uid)
206
+			foreach ($data['info_responsible'] as $uid)
207 207
 			{
208 208
 				$responsible[] = Api\Accounts::username($uid);
209 209
 			}
@@ -212,32 +212,32 @@  discard block
 block discarded – undo
212 212
 		{
213 213
 			$id = ' #'.$data['info_id'];
214 214
 		}
215
-		foreach(array(
215
+		foreach (array(
216 216
 			'info_type'      => lang($this->infolog->enums['type'][$data['info_type']]).$id,
217 217
 			'info_from'      => $data['info_from'],
218 218
 			'info_cat'       => $data['info_cat'] ? $GLOBALS['egw']->categories->id2name($data['info_cat']) : '',
219 219
 			'info_priority'  => lang($this->infolog->enums['priority'][$data['info_priority']]),
220 220
 			'info_owner'     => Api\Accounts::username($data['info_owner']),
221
-			'info_status'    => lang($data['info_status']=='deleted'?'deleted':$this->infolog->status[$data['info_type']][$data['info_status']]),
221
+			'info_status'    => lang($data['info_status'] == 'deleted' ? 'deleted' : $this->infolog->status[$data['info_type']][$data['info_status']]),
222 222
 			'info_percent'   => (int)$data['info_percent'].'%',
223 223
 			'info_datecompleted' => $data['info_datecompleted'] ? $this->datetime($data['info_datecompleted']) : '',
224 224
 			'info_location'  => $data['info_location'],
225
-			'info_startdate' => $data['info_startdate'] ? $this->datetime($data['info_startdate'],null) : '',
226
-			'info_enddate'   => $data['info_enddate'] ? $this->datetime($data['info_enddate'],null) : '',
227
-			'info_responsible' => implode(', ',$responsible),
225
+			'info_startdate' => $data['info_startdate'] ? $this->datetime($data['info_startdate'], null) : '',
226
+			'info_enddate'   => $data['info_enddate'] ? $this->datetime($data['info_enddate'], null) : '',
227
+			'info_responsible' => implode(', ', $responsible),
228 228
 			'info_subject'   => $data['info_subject'],
229 229
 		) as $name => $value)
230 230
 		{
231 231
 			//error_log(__METHOD__.__LINE__.' Key:'.$name.' val:'.array2string($value));
232
-			if ($name=='info_from' && empty($value))
232
+			if ($name == 'info_from' && empty($value))
233 233
 			{
234
-				if(!empty($data['info_contact']) && is_array($data['link_to']['to_id']))
234
+				if (!empty($data['info_contact']) && is_array($data['link_to']['to_id']))
235 235
 				{
236 236
 					$lkeys = array_keys($data['link_to']['to_id']);
237
-					if (in_array($data['info_contact'],$lkeys))
237
+					if (in_array($data['info_contact'], $lkeys))
238 238
 					{
239
-						list($app,$id) = explode(':',$data['info_contact']);
240
-						if (!empty($app)&&!empty($id)) $value = Link::title($app,$id);
239
+						list($app, $id) = explode(':', $data['info_contact']);
240
+						if (!empty($app) && !empty($id)) $value = Link::title($app, $id);
241 241
 					}
242 242
 				}
243 243
 				else if ($data['info_link_id'])
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 	 * @param boolean $skip_notification = false do NOT send any notification
276 276
 	 * @return int|boolean false on error, integer number of changes logged or true for new entries ($old == null)
277 277
 	 */
278
-	public function track(array $data,array $old=null,$user=null,$deleted=null,array $changed_fields=null,$skip_notification=false)
278
+	public function track(array $data, array $old = null, $user = null, $deleted = null, array $changed_fields = null, $skip_notification = false)
279 279
 	{
280 280
 		//error_log(__METHOD__.__LINE__.' notify?'.($skip_notification?'no':'yes').function_backtrace());
281 281
 		$this->user = !is_null($user) ? $user : $GLOBALS['egw_info']['user']['account_id'];
@@ -284,23 +284,23 @@  discard block
 block discarded – undo
284 284
 
285 285
 		if ($old && $this->field2history)
286 286
 		{
287
-			$changes = $this->save_history($data,$old,$deleted,$changed_fields);
287
+			$changes = $this->save_history($data, $old, $deleted, $changed_fields);
288 288
 		}
289 289
 
290 290
 		// Don't notify if the only change was to the modified date
291
-		if(is_null($changed_fields))
291
+		if (is_null($changed_fields))
292 292
 		{
293 293
 			$changed_fields = $this->changed_fields($data, $old);
294 294
 			$changes = count($changed_fields); // we need that since TRUE evaluates to 1
295 295
 		}
296 296
 		//error_log(__METHOD__.__LINE__.array2string($changed_fields));
297
-		if(is_array($changed_fields) && $changes == 1 && in_array('info_datemodified', $changed_fields))
297
+		if (is_array($changed_fields) && $changes == 1 && in_array('info_datemodified', $changed_fields))
298 298
 		{
299 299
 			return count($changes);
300 300
 		}
301 301
 
302 302
 		// do not run do_notifications if we have no changes
303
-		if ($changes && !$skip_notification && !$this->do_notifications($data,$old,$deleted))
303
+		if ($changes && !$skip_notification && !$this->do_notifications($data, $old, $deleted))
304 304
 		{
305 305
 			$changes = false;
306 306
 		}
@@ -318,16 +318,16 @@  discard block
 block discarded – undo
318 318
 	 * @param array $old = null old/last state of the entry or null for a new entry
319 319
 	 * @return mixed
320 320
 	 */
321
-	function get_config($name,$data,$old=null)
321
+	function get_config($name, $data, $old = null)
322 322
 	{
323
-		unset($old);	// not used, but required function signature
324
-		switch($name)
323
+		unset($old); // not used, but required function signature
324
+		switch ($name)
325 325
 		{
326 326
 			case 'copy':	// include the info_cc addresses
327
-				if ($data['info_access'] == 'private') return array();	// no copies for private entries
327
+				if ($data['info_access'] == 'private') return array(); // no copies for private entries
328 328
 				if ($data['info_cc'])
329 329
 				{
330
-					$config = preg_split('/, ?/',$data['info_cc']);
330
+					$config = preg_split('/, ?/', $data['info_cc']);
331 331
 				}
332 332
 				else
333 333
 				{
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 				break;
337 337
 			case self::CUSTOM_NOTIFICATION:
338 338
 				$info_config = Api\Config::read('infolog');
339
-				if(!$info_config[self::CUSTOM_NOTIFICATION])
339
+				if (!$info_config[self::CUSTOM_NOTIFICATION])
340 340
 				{
341 341
 					return '';
342 342
 				}
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 				$global = $info_config[self::CUSTOM_NOTIFICATION]['~global~'];
346 346
 
347 347
 				// Disabled
348
-				if(!$type_config['use_custom'] && !$global['use_custom']) return '';
348
+				if (!$type_config['use_custom'] && !$global['use_custom']) return '';
349 349
 
350 350
 				// Type or globabl
351 351
 				$config = trim(strip_tags($type_config['message'])) != '' && $type_config['use_custom'] ? $type_config['message'] : $global['message'];
Please login to merge, or discard this patch.
Braces   +26 added lines, -6 removed lines patch added patch discarded remove patch
@@ -172,7 +172,11 @@  discard block
 block discarded – undo
172 172
 	 */
173 173
 	function get_message($data,$old)
174 174
 	{
175
-		if ($data['message']) return $data['message'];	// async notification
175
+		if ($data['message'])
176
+		{
177
+			return $data['message'];
178
+		}
179
+		// async notification
176 180
 
177 181
 		if (!$old || $old['info_status'] == 'deleted')
178 182
 		{
@@ -237,20 +241,29 @@  discard block
 block discarded – undo
237 241
 					if (in_array($data['info_contact'],$lkeys))
238 242
 					{
239 243
 						list($app,$id) = explode(':',$data['info_contact']);
240
-						if (!empty($app)&&!empty($id)) $value = Link::title($app,$id);
244
+						if (!empty($app)&&!empty($id))
245
+						{
246
+							$value = Link::title($app,$id);
247
+						}
241 248
 					}
242 249
 				}
243 250
 				else if ($data['info_link_id'])
244 251
 				{
245 252
 					$this->infolog->link_id2from($data);
246
-					if (is_array($data['info_contact'])) $value = $data['info_contact']['title'];
253
+					if (is_array($data['info_contact']))
254
+					{
255
+						$value = $data['info_contact']['title'];
256
+					}
247 257
 				}
248 258
 			}
249 259
 			$details[$name] = array(
250 260
 				'label' => lang($this->field2label[$name]),
251 261
 				'value' => $value,
252 262
 			);
253
-			if ($name == 'info_subject') $details[$name]['type'] = 'summary';
263
+			if ($name == 'info_subject')
264
+			{
265
+				$details[$name]['type'] = 'summary';
266
+			}
254 267
 		}
255 268
 		$details['info_des'] = array(
256 269
 			'value' => $data['info_des'],
@@ -324,7 +337,11 @@  discard block
 block discarded – undo
324 337
 		switch($name)
325 338
 		{
326 339
 			case 'copy':	// include the info_cc addresses
327
-				if ($data['info_access'] == 'private') return array();	// no copies for private entries
340
+				if ($data['info_access'] == 'private')
341
+				{
342
+					return array();
343
+				}
344
+				// no copies for private entries
328 345
 				if ($data['info_cc'])
329 346
 				{
330 347
 					$config = preg_split('/, ?/',$data['info_cc']);
@@ -345,7 +362,10 @@  discard block
 block discarded – undo
345 362
 				$global = $info_config[self::CUSTOM_NOTIFICATION]['~global~'];
346 363
 
347 364
 				// Disabled
348
-				if(!$type_config['use_custom'] && !$global['use_custom']) return '';
365
+				if(!$type_config['use_custom'] && !$global['use_custom'])
366
+				{
367
+					return '';
368
+				}
349 369
 
350 370
 				// Type or globabl
351 371
 				$config = trim(strip_tags($type_config['message'])) != '' && $type_config['use_custom'] ? $type_config['message'] : $global['message'];
Please login to merge, or discard this patch.