Passed
Push — 17.1 ( 431f3f...4dae72 )
by Ralf
01:23 queued 12s
created
importexport/inc/class.importexport_export_csv.inc.php 4 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 *
97 97
 	 * @param stram $_stream resource where records are exported to.
98 98
 	 * @param array _options options for specific backends
99
-	 * @return bool
99
+	 * @return boolean|null
100 100
 	 */
101 101
 	public function __construct( $_stream, array $_options ) {
102 102
 		if (!is_object($GLOBALS['egw']->translation)) {
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 * exports a record into resource of handle
152 152
 	 *
153 153
 	 * @param importexport_iface_egw_record record
154
-	 * @return bool
154
+	 * @return boolean|null
155 155
 	 */
156 156
 	public function export_record( importexport_iface_egw_record $_record ) {
157 157
 		$this->record = $_record;
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 *
285 285
 	 * Uses the static variable $types to convert various datatypes.
286 286
 	 *
287
-	 * @param record Record to be converted
287
+	 * @param record importexport_iface_egw_record to be converted
288 288
 	 * @parem fields List of field types => field names to be converted
289 289
 	 * @param appname Current appname if you want to do custom fields too
290 290
 	 */
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	 * @parem fields List of field types => field names to be converted
289 289
 	 * @param appname Current appname if you want to do custom fields too
290 290
 	 */
291
-	public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array()) {
291
+	public static function convert(importexport_iface_egw_record &$record, array $fields = array(), $appname = null, $selects = array()) {
292 292
 		if($appname) {
293 293
 			if(!self::$cf_parse_cache[$appname]) {
294 294
 				$c_fields = self::convert_parse_custom_fields($appname, $selects, $links, $methods);
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 	 * @param char $delimiter
453 453
 	 * @param char $enclosure
454 454
 	 */
455
-	protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure){
455
+	protected function fputcsv($filePointer, array $dataArray, $delimiter, $enclosure){
456 456
 		$string = "";
457 457
 		$writeDelimiter = false;
458 458
 		foreach($dataArray as $dataElement) {
Please login to merge, or discard this patch.
Braces   +178 added lines, -70 removed lines patch added patch discarded remove patch
@@ -98,22 +98,32 @@  discard block
 block discarded – undo
98 98
 	 * @param array _options options for specific backends
99 99
 	 * @return bool
100 100
 	 */
101
-	public function __construct( $_stream, array $_options ) {
102
-		if (!is_object($GLOBALS['egw']->translation)) {
101
+	public function __construct( $_stream, array $_options )
102
+	{
103
+		if (!is_object($GLOBALS['egw']->translation))
104
+		{
103 105
 			$GLOBALS['egw']->translation = new Api\Translation();
104 106
 		}
105 107
 		$this->translation = &$GLOBALS['egw']->translation;
106 108
 		$this->handle = $_stream;
107
-		if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
109
+		if($_options['charset'] == 'user')
110
+		{
111
+			$_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
112
+		}
108 113
 		$this->csv_charset = $_options['charset'] ? $_options['charset'] : 'utf-8';
109
-		if ( !empty( $_options ) ) {
114
+		if ( !empty( $_options ) )
115
+		{
110 116
 			$this->csv_options = array_merge( $this->csv_options, $_options );
111 117
 		}
112 118
 		//error_log(__METHOD__.__LINE__.array2string($_options['appname']));
113
-		if(!Api\Storage\Merge::is_export_limit_excepted()) {
119
+		if(!Api\Storage\Merge::is_export_limit_excepted())
120
+		{
114 121
 			$this->export_limit = Api\Storage\Merge::getExportLimit($_options['appname']);
115 122
 			//error_log(__METHOD__.__LINE__.' app:'.$_options['appname'].' limit:'.$this->export_limit);
116
-			if($this->export_limit == 'no') throw new Api\Exception\NoPermission\Admin('Export disabled');
123
+			if($this->export_limit == 'no')
124
+			{
125
+				throw new Api\Exception\NoPermission\Admin('Export disabled');
126
+			}
117 127
 		}
118 128
 	}
119 129
 	
@@ -122,15 +132,19 @@  discard block
 block discarded – undo
122 132
 	 *
123 133
 	 * @param array $_mapping egw_field_name => csv_field_name
124 134
 	 */
125
-	public function set_mapping( array &$_mapping) {
126
-		if ($this->num_of_records > 0) {
135
+	public function set_mapping( array &$_mapping)
136
+	{
137
+		if ($this->num_of_records > 0)
138
+		{
127 139
 			throw new Exception('Error: Field mapping can\'t be set during ongoing export!');
128 140
 		}
129
-		if($_mapping['all_custom_fields']) {
141
+		if($_mapping['all_custom_fields'])
142
+		{
130 143
 			// Field value is the appname, so we can pull the fields
131 144
 			$custom = Api\Storage\Customfields::get($_mapping['all_custom_fields']);
132 145
 			unset($_mapping['all_custom_fields']);
133
-			foreach($custom as $field => $info) {
146
+			foreach($custom as $field => $info)
147
+			{
134 148
 				$_mapping['#'.$field] = $this->csv_options['begin_with_fieldnames'] == 'label' ? $info['label'] : $field;
135 149
 			}
136 150
 		}
@@ -143,7 +157,8 @@  discard block
 block discarded – undo
143 157
 	 *
144 158
 	 * @param array $_conversion
145 159
 	 */
146
-	public function set_conversion( array $_conversion) {
160
+	public function set_conversion( array $_conversion)
161
+	{
147 162
 		$this->conversion = $_conversion;
148 163
 	}
149 164
 	
@@ -153,16 +168,23 @@  discard block
 block discarded – undo
153 168
 	 * @param importexport_iface_egw_record record
154 169
 	 * @return bool
155 170
 	 */
156
-	public function export_record( importexport_iface_egw_record $_record ) {
171
+	public function export_record( importexport_iface_egw_record $_record )
172
+	{
157 173
 		$this->record = $_record;
158 174
 		$this->record_array = $_record->get_record_array();
159 175
 		
160 176
 		// begin with fieldnames ?
161
-		if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames'] ) {
162
-			if($this->csv_options['begin_with_fieldnames'] == 'label') {
177
+		if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames'] )
178
+		{
179
+			if($this->csv_options['begin_with_fieldnames'] == 'label')
180
+			{
163 181
 				// Load translations for app
164 182
 				list($appname, $part2) = explode('_', get_class($_record));
165
-				if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name
183
+				if(!$GLOBALS['egw_info']['apps'][$appname])
184
+				{
185
+					$appname .= $part2;
186
+				}
187
+				// Handle apps with _ in the name
166 188
 
167 189
 				// Get translations from wizard, if possible
168 190
 				if(!$this->csv_options['no_header_translation'])
@@ -180,11 +202,16 @@  discard block
 block discarded – undo
180 202
 								$label = $label != $fields[$field] ? $fields[$field] : lang($label);
181 203
 							}
182 204
 							// Make sure no *
183
-							if(substr($label,-1) == '*') $label = substr($label,0,-1);
205
+							if(substr($label,-1) == '*')
206
+							{
207
+								$label = substr($label,0,-1);
208
+							}
184 209
 						}
185
-					} catch (Exception $e) {
210
+					}
211
+					catch (Exception $e) {
186 212
 						Api\Translation::add_app($appname);
187
-						foreach($this->mapping as $field => &$label) {
213
+						foreach($this->mapping as $field => &$label)
214
+						{
188 215
 							$label = lang($label);
189 216
 						}
190 217
 					}
@@ -195,20 +222,24 @@  discard block
 block discarded – undo
195 222
 		}
196 223
 
197 224
 		// Check for limit
198
-		if($this->export_limit && $this->num_of_records >= $this->export_limit) {
225
+		if($this->export_limit && $this->num_of_records >= $this->export_limit)
226
+		{
199 227
 			return;
200 228
 		}
201 229
 		
202 230
 		// do conversions
203
-		if ( !empty( $this->conversion )) {
231
+		if ( !empty( $this->conversion ))
232
+		{
204 233
 			$this->record_array = importexport_helper_functions::conversion( $this->record_array, $this->conversion );
205 234
 		}
206 235
 		
207 236
 		// do fieldmapping
208
-		if ( !empty( $this->mapping ) ) {
237
+		if ( !empty( $this->mapping ) )
238
+		{
209 239
 			$record_data = $this->record_array;
210 240
 			$this->record_array = array();
211
-			foreach ($this->mapping as $egw_field => $csv_field) {
241
+			foreach ($this->mapping as $egw_field => $csv_field)
242
+			{
212 243
 				$this->record_array[$csv_field] = $record_data[$egw_field];
213 244
 			}
214 245
 		}
@@ -222,7 +253,8 @@  discard block
 block discarded – undo
222 253
 	 *
223 254
 	 * @return int
224 255
 	 */
225
-	public function get_num_of_records() {
256
+	public function get_num_of_records()
257
+	{
226 258
 		return $this->num_of_records;
227 259
 	}
228 260
 
@@ -236,14 +268,20 @@  discard block
 block discarded – undo
236 268
 	 *
237 269
 	 * @return Array of fields to be added to list of fields needing conversion
238 270
 	 */
239
-	public static function convert_parse_custom_fields($appname, &$selects = array(), &$links = array(), &$methods = array()) {
240
-		if(!$appname) return;
271
+	public static function convert_parse_custom_fields($appname, &$selects = array(), &$links = array(), &$methods = array())
272
+	{
273
+		if(!$appname)
274
+		{
275
+			return;
276
+		}
241 277
 
242 278
 		$fields = array();
243 279
 		$custom = Api\Storage\Customfields::get($appname);
244
-		foreach($custom as $name => $c_field) {
280
+		foreach($custom as $name => $c_field)
281
+		{
245 282
 			$name = '#' . $name;
246
-			switch($c_field['type']) {
283
+			switch($c_field['type'])
284
+			{
247 285
 				case 'date':
248 286
 					$fields['date'][] = $name;
249 287
 					break;
@@ -254,7 +292,8 @@  discard block
 block discarded – undo
254 292
 					$fields['select-account'][] = $name;
255 293
 					break;
256 294
 				case 'ajax_select':
257
-					if($c_field['values']['get_title']) {
295
+					if($c_field['values']['get_title'])
296
+					{
258 297
 						$methods[$name] = $c_field['values']['get_title'];
259 298
 						break;
260 299
 					}
@@ -269,7 +308,8 @@  discard block
 block discarded – undo
269 308
 					break;
270 309
 				default:
271 310
 					list($type) = explode('-',$c_field['type'],2);
272
-					if(in_array($type, array_keys($GLOBALS['egw_info']['apps']))) {
311
+					if(in_array($type, array_keys($GLOBALS['egw_info']['apps'])))
312
+					{
273 313
 						$fields['links'][] = $name;
274 314
 						$links[$name] = $c_field['type'];
275 315
 					}
@@ -288,9 +328,12 @@  discard block
 block discarded – undo
288 328
 	 * @parem fields List of field types => field names to be converted
289 329
 	 * @param appname Current appname if you want to do custom fields too
290 330
 	 */
291
-	public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array()) {
292
-		if($appname) {
293
-			if(!self::$cf_parse_cache[$appname]) {
331
+	public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array())
332
+	{
333
+		if($appname)
334
+		{
335
+			if(!self::$cf_parse_cache[$appname])
336
+			{
294 337
 				$c_fields = self::convert_parse_custom_fields($appname, $selects, $links, $methods);
295 338
 				self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods);
296 339
 			}
@@ -299,7 +342,10 @@  discard block
 block discarded – undo
299 342
 			// Add in any fields that are keys to another app
300 343
 			foreach((array)$fields['links'] as $link_field => $app)
301 344
 			{
302
-				if(is_numeric($link_field)) continue;
345
+				if(is_numeric($link_field))
346
+				{
347
+					continue;
348
+				}
303 349
 				$links[$link_field] = $app;
304 350
 				// Set it as a normal link field
305 351
 				$fields['links'][] = $link_field;
@@ -307,8 +353,10 @@  discard block
 block discarded – undo
307 353
 			}
308 354
 
309 355
 			// Not quite a recursive merge, since only one level
310
-			foreach($fields as $type => &$list) {
311
-				if($c_fields[$type]) {
356
+			foreach($fields as $type => &$list)
357
+			{
358
+				if($c_fields[$type])
359
+				{
312 360
 					$list = array_merge($c_fields[$type], $list);
313 361
 					unset($c_fields[$type]);
314 362
 				}
@@ -316,16 +364,22 @@  discard block
 block discarded – undo
316 364
 			$fields += $c_fields;
317 365
 			$selects += $c_selects;
318 366
 		}
319
-		foreach((array)$fields['select'] as $name) {
320
-			if($record->$name != null && is_array($selects) && $selects[$name]) {
367
+		foreach((array)$fields['select'] as $name)
368
+		{
369
+			if($record->$name != null && is_array($selects) && $selects[$name])
370
+			{
321 371
 				$record->$name = is_string($record->$name) ? explode(',', $record->$name) : $record->$name;
322
-				if(is_array($record->$name)) {
372
+				if(is_array($record->$name))
373
+				{
323 374
 					$names = array();
324
-					foreach($record->$name as $_name) {
375
+					foreach($record->$name as $_name)
376
+					{
325 377
 						$names[] = lang($selects[$name][$_name]);
326 378
 					}
327 379
 					$record->$name = implode(', ', $names);
328
-				} else {
380
+				}
381
+				else
382
+				{
329 383
 					$record->$name = lang($selects[$name][$record->$name]);
330 384
 				}
331 385
 			}
@@ -334,9 +388,12 @@  discard block
 block discarded – undo
334 388
 				$record->$name = '';
335 389
 			}
336 390
 		}
337
-		foreach((array)$fields['links'] as $name) {
338
-			if($record->$name) {
339
-				if(is_numeric($record->$name) && !$links[$name]) {
391
+		foreach((array)$fields['links'] as $name)
392
+		{
393
+			if($record->$name)
394
+			{
395
+				if(is_numeric($record->$name) && !$links[$name])
396
+				{
340 397
 					$link = Link::get_link($record->$name);
341 398
 					$links[$name] = ($link['link_app1'] == $appname ? $link['link_app2'] : $link['link_app1']);
342 399
 					$record->$name = ($link['link_app1'] == $appname ? $link['link_id2'] : $link['link_id1']);
@@ -355,16 +412,22 @@  discard block
 block discarded – undo
355 412
 				$record->$name = '';
356 413
 			}
357 414
 		}
358
-		foreach((array)$fields['select-account'] as $name) {
415
+		foreach((array)$fields['select-account'] as $name)
416
+		{
359 417
 			// Compare against null to deal with empty arrays
360
-			if ($record->$name !== null) {
361
-				if(is_array($record->$name)) {
418
+			if ($record->$name !== null)
419
+			{
420
+				if(is_array($record->$name))
421
+				{
362 422
 					$names = array();
363
-					foreach($record->$name as $_name) {
423
+					foreach($record->$name as $_name)
424
+					{
364 425
 						$names[] = Api\Accounts::username($_name);
365 426
 					}
366 427
 					$record->$name = implode(', ', $names);
367
-				} else {
428
+				}
429
+				else
430
+				{
368 431
 					$record->$name = Api\Accounts::username($record->$name);
369 432
 				}
370 433
 			}
@@ -373,23 +436,49 @@  discard block
 block discarded – undo
373 436
 				$record->$name = '';
374 437
 			}
375 438
 		}
376
-		foreach((array)$fields['select-bool'] as $name) {
377
-			if($record->$name !== null) {
439
+		foreach((array)$fields['select-bool'] as $name)
440
+		{
441
+			if($record->$name !== null)
442
+			{
378 443
 				$record->$name = $record->$name ? lang('Yes') : lang('No');
379 444
 			}
380 445
 		}
381
-		foreach((array)$fields['date-time'] as $name) {
446
+		foreach((array)$fields['date-time'] as $name)
447
+		{
382 448
 			//if ($record->$name) $record->$name = date('Y-m-d H:i:s',$record->$name); // Standard date format
383
-			if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string
384
-			if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] . ' '.
385
-				($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'),$record->$name); // User date format
386
-			if (!$record->$name) $record->$name = '';
449
+			if ($record->$name && !is_numeric($record->$name))
450
+			{
451
+				$record->$name = strtotime($record->$name);
452
+			}
453
+			// Custom fields stored as string
454
+			if ($record->$name && is_numeric($record->$name))
455
+			{
456
+				$record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] . ' '.
457
+				($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'),$record->$name);
458
+			}
459
+			// User date format
460
+			if (!$record->$name)
461
+			{
462
+				$record->$name = '';
463
+			}
387 464
 		}
388
-		foreach((array)$fields['date'] as $name) {
465
+		foreach((array)$fields['date'] as $name)
466
+		{
389 467
 			//if ($record->$name) $record->$name = date('Y-m-d',$record->$name); // Standard date format
390
-			if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string
391
-			if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $record->$name); // User date format
392
-			if (!$record->$name) $record->$name = '';
468
+			if ($record->$name && !is_numeric($record->$name))
469
+			{
470
+				$record->$name = strtotime($record->$name);
471
+			}
472
+			// Custom fields stored as string
473
+			if ($record->$name && is_numeric($record->$name))
474
+			{
475
+				$record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $record->$name);
476
+			}
477
+			// User date format
478
+			if (!$record->$name)
479
+			{
480
+				$record->$name = '';
481
+			}
393 482
 		}
394 483
 		foreach((array)$fields['float'] as $name)
395 484
 		{
@@ -397,7 +486,10 @@  discard block
 block discarded – undo
397 486
 			if (is_null($dec_separator))
398 487
 			{
399 488
 				$dec_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0];
400
-				if (empty($dec_separator)) $dec_separator = '.';
489
+				if (empty($dec_separator))
490
+				{
491
+					$dec_separator = '.';
492
+				}
401 493
 				$thousands_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][1];
402 494
 			}
403 495
 			if($record->$name && (string)$record->$name != '')
@@ -413,17 +505,27 @@  discard block
 block discarded – undo
413 505
 		}
414 506
 
415 507
 		// Some custom methods for conversion
416
-		foreach((array)$methods as $name => $method) {
417
-			if($record->$name) $record->$name = ExecMethod($method, $record->$name);
508
+		foreach((array)$methods as $name => $method)
509
+		{
510
+			if($record->$name)
511
+			{
512
+				$record->$name = ExecMethod($method, $record->$name);
513
+			}
418 514
 		}
419 515
 
420 516
 		static $cat_object;
421
-		if(is_null($cat_object)) $cat_object = new Api\Categories(false,$appname);
422
-		foreach((array)$fields['select-cat'] as $name) {
423
-			if($record->$name) {
517
+		if(is_null($cat_object))
518
+		{
519
+			$cat_object = new Api\Categories(false,$appname);
520
+		}
521
+		foreach((array)$fields['select-cat'] as $name)
522
+		{
523
+			if($record->$name)
524
+			{
424 525
 				$cats = array();
425 526
 				$ids = is_array($record->$name) ? $record->$name : explode(',', $record->$name);
426
-				foreach($ids as $n => $cat_id) {
527
+				foreach($ids as $n => $cat_id)
528
+				{
427 529
 
428 530
 					if ($cat_id && $cat_object->check_perms(Acl::READ,$cat_id))
429 531
 					{
@@ -444,7 +546,8 @@  discard block
 block discarded – undo
444 546
 	 *
445 547
 	 * @return
446 548
 	 */
447
-	public function __destruct() {
549
+	public function __destruct()
550
+	{
448 551
 		
449 552
 	}
450 553
 
@@ -457,11 +560,16 @@  discard block
 block discarded – undo
457 560
 	 * @param char $delimiter
458 561
 	 * @param char $enclosure
459 562
 	 */
460
-	protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure){
563
+	protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure)
564
+	{
461 565
 		$string = "";
462 566
 		$writeDelimiter = false;
463
-		foreach($dataArray as $dataElement) {
464
-			if($writeDelimiter) $string .= $delimiter;
567
+		foreach($dataArray as $dataElement)
568
+		{
569
+			if($writeDelimiter)
570
+			{
571
+				$string .= $delimiter;
572
+			}
465 573
 			$string .= $enclosure . str_replace(array("\r\n", '"'), array("\n",'""'), $dataElement) . $enclosure;
466 574
 			$writeDelimiter = true;
467 575
 		}
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -98,22 +98,22 @@  discard block
 block discarded – undo
98 98
 	 * @param array _options options for specific backends
99 99
 	 * @return bool
100 100
 	 */
101
-	public function __construct( $_stream, array $_options ) {
101
+	public function __construct($_stream, array $_options) {
102 102
 		if (!is_object($GLOBALS['egw']->translation)) {
103 103
 			$GLOBALS['egw']->translation = new Api\Translation();
104 104
 		}
105 105
 		$this->translation = &$GLOBALS['egw']->translation;
106 106
 		$this->handle = $_stream;
107
-		if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
107
+		if ($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
108 108
 		$this->csv_charset = $_options['charset'] ? $_options['charset'] : 'utf-8';
109
-		if ( !empty( $_options ) ) {
110
-			$this->csv_options = array_merge( $this->csv_options, $_options );
109
+		if (!empty($_options)) {
110
+			$this->csv_options = array_merge($this->csv_options, $_options);
111 111
 		}
112 112
 		//error_log(__METHOD__.__LINE__.array2string($_options['appname']));
113
-		if(!Api\Storage\Merge::is_export_limit_excepted()) {
113
+		if (!Api\Storage\Merge::is_export_limit_excepted()) {
114 114
 			$this->export_limit = Api\Storage\Merge::getExportLimit($_options['appname']);
115 115
 			//error_log(__METHOD__.__LINE__.' app:'.$_options['appname'].' limit:'.$this->export_limit);
116
-			if($this->export_limit == 'no') throw new Api\Exception\NoPermission\Admin('Export disabled');
116
+			if ($this->export_limit == 'no') throw new Api\Exception\NoPermission\Admin('Export disabled');
117 117
 		}
118 118
 	}
119 119
 	
@@ -122,15 +122,15 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @param array $_mapping egw_field_name => csv_field_name
124 124
 	 */
125
-	public function set_mapping( array &$_mapping) {
125
+	public function set_mapping(array &$_mapping) {
126 126
 		if ($this->num_of_records > 0) {
127 127
 			throw new Exception('Error: Field mapping can\'t be set during ongoing export!');
128 128
 		}
129
-		if($_mapping['all_custom_fields']) {
129
+		if ($_mapping['all_custom_fields']) {
130 130
 			// Field value is the appname, so we can pull the fields
131 131
 			$custom = Api\Storage\Customfields::get($_mapping['all_custom_fields']);
132 132
 			unset($_mapping['all_custom_fields']);
133
-			foreach($custom as $field => $info) {
133
+			foreach ($custom as $field => $info) {
134 134
 				$_mapping['#'.$field] = $this->csv_options['begin_with_fieldnames'] == 'label' ? $info['label'] : $field;
135 135
 			}
136 136
 		}
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 *
144 144
 	 * @param array $_conversion
145 145
 	 */
146
-	public function set_conversion( array $_conversion) {
146
+	public function set_conversion(array $_conversion) {
147 147
 		$this->conversion = $_conversion;
148 148
 	}
149 149
 	
@@ -153,59 +153,59 @@  discard block
 block discarded – undo
153 153
 	 * @param importexport_iface_egw_record record
154 154
 	 * @return bool
155 155
 	 */
156
-	public function export_record( importexport_iface_egw_record $_record ) {
156
+	public function export_record(importexport_iface_egw_record $_record) {
157 157
 		$this->record = $_record;
158 158
 		$this->record_array = $_record->get_record_array();
159 159
 		
160 160
 		// begin with fieldnames ?
161
-		if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames'] ) {
162
-			if($this->csv_options['begin_with_fieldnames'] == 'label') {
161
+		if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames']) {
162
+			if ($this->csv_options['begin_with_fieldnames'] == 'label') {
163 163
 				// Load translations for app
164 164
 				list($appname, $part2) = explode('_', get_class($_record));
165
-				if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name
165
+				if (!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name
166 166
 
167 167
 				// Get translations from wizard, if possible
168
-				if(!$this->csv_options['no_header_translation'])
168
+				if (!$this->csv_options['no_header_translation'])
169 169
 				{
170 170
 					$backtrace = debug_backtrace();
171 171
 					$plugin = $backtrace[1]['class'];
172
-					$wizard_name = $appname . '_wizard_' . str_replace($appname . '_', '', $plugin);
172
+					$wizard_name = $appname.'_wizard_'.str_replace($appname.'_', '', $plugin);
173 173
 					try {
174 174
 						$wizard = new $wizard_name;
175 175
 						$fields = $wizard->get_export_fields();
176
-						foreach($this->mapping as $field => &$label)
176
+						foreach ($this->mapping as $field => &$label)
177 177
 						{
178
-							if($fields[$field])
178
+							if ($fields[$field])
179 179
 							{
180 180
 								$label = $label != $fields[$field] ? $fields[$field] : lang($label);
181 181
 							}
182 182
 							// Make sure no *
183
-							if(substr($label,-1) == '*') $label = substr($label,0,-1);
183
+							if (substr($label, -1) == '*') $label = substr($label, 0, -1);
184 184
 						}
185 185
 					} catch (Exception $e) {
186 186
 						Api\Translation::add_app($appname);
187
-						foreach($this->mapping as $field => &$label) {
187
+						foreach ($this->mapping as $field => &$label) {
188 188
 							$label = lang($label);
189 189
 						}
190 190
 					}
191 191
 				}
192 192
 			}
193
-			$mapping = ! empty( $this->mapping ) ? $this->mapping : array_keys ( $this->record_array );
194
-			self::fputcsv( $this->handle ,$mapping ,$this->csv_options['delimiter'], $this->csv_options['enclosure'] );
193
+			$mapping = !empty($this->mapping) ? $this->mapping : array_keys($this->record_array);
194
+			self::fputcsv($this->handle, $mapping, $this->csv_options['delimiter'], $this->csv_options['enclosure']);
195 195
 		}
196 196
 
197 197
 		// Check for limit
198
-		if($this->export_limit && $this->num_of_records >= $this->export_limit) {
198
+		if ($this->export_limit && $this->num_of_records >= $this->export_limit) {
199 199
 			return;
200 200
 		}
201 201
 		
202 202
 		// do conversions
203
-		if ( !empty( $this->conversion )) {
204
-			$this->record_array = importexport_helper_functions::conversion( $this->record_array, $this->conversion );
203
+		if (!empty($this->conversion)) {
204
+			$this->record_array = importexport_helper_functions::conversion($this->record_array, $this->conversion);
205 205
 		}
206 206
 		
207 207
 		// do fieldmapping
208
-		if ( !empty( $this->mapping ) ) {
208
+		if (!empty($this->mapping)) {
209 209
 			$record_data = $this->record_array;
210 210
 			$this->record_array = array();
211 211
 			foreach ($this->mapping as $egw_field => $csv_field) {
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 			}
214 214
 		}
215 215
 		
216
-		self::fputcsv( $this->handle, $this->record_array, $this->csv_options['delimiter'], $this->csv_options['enclosure'] );
216
+		self::fputcsv($this->handle, $this->record_array, $this->csv_options['delimiter'], $this->csv_options['enclosure']);
217 217
 		$this->num_of_records++;
218 218
 	}
219 219
 
@@ -237,13 +237,13 @@  discard block
 block discarded – undo
237 237
 	 * @return Array of fields to be added to list of fields needing conversion
238 238
 	 */
239 239
 	public static function convert_parse_custom_fields($appname, &$selects = array(), &$links = array(), &$methods = array()) {
240
-		if(!$appname) return;
240
+		if (!$appname) return;
241 241
 
242 242
 		$fields = array();
243 243
 		$custom = Api\Storage\Customfields::get($appname);
244
-		foreach($custom as $name => $c_field) {
245
-			$name = '#' . $name;
246
-			switch($c_field['type']) {
244
+		foreach ($custom as $name => $c_field) {
245
+			$name = '#'.$name;
246
+			switch ($c_field['type']) {
247 247
 				case 'date':
248 248
 					$fields['date'][] = $name;
249 249
 					break;
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 					$fields['select-account'][] = $name;
255 255
 					break;
256 256
 				case 'ajax_select':
257
-					if($c_field['values']['get_title']) {
257
+					if ($c_field['values']['get_title']) {
258 258
 						$methods[$name] = $c_field['values']['get_title'];
259 259
 						break;
260 260
 					}
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 					$selects[$name] = $c_field['values'];
269 269
 					break;
270 270
 				default:
271
-					list($type) = explode('-',$c_field['type'],2);
272
-					if(in_array($type, array_keys($GLOBALS['egw_info']['apps']))) {
271
+					list($type) = explode('-', $c_field['type'], 2);
272
+					if (in_array($type, array_keys($GLOBALS['egw_info']['apps']))) {
273 273
 						$fields['links'][] = $name;
274 274
 						$links[$name] = $c_field['type'];
275 275
 					}
@@ -289,17 +289,17 @@  discard block
 block discarded – undo
289 289
 	 * @param appname Current appname if you want to do custom fields too
290 290
 	 */
291 291
 	public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array()) {
292
-		if($appname) {
293
-			if(!self::$cf_parse_cache[$appname]) {
292
+		if ($appname) {
293
+			if (!self::$cf_parse_cache[$appname]) {
294 294
 				$c_fields = self::convert_parse_custom_fields($appname, $selects, $links, $methods);
295 295
 				self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods);
296 296
 			}
297 297
 			list($c_fields, $c_selects, $links, $methods) = self::$cf_parse_cache[$appname];
298 298
 
299 299
 			// Add in any fields that are keys to another app
300
-			foreach((array)$fields['links'] as $link_field => $app)
300
+			foreach ((array)$fields['links'] as $link_field => $app)
301 301
 			{
302
-				if(is_numeric($link_field)) continue;
302
+				if (is_numeric($link_field)) continue;
303 303
 				$links[$link_field] = $app;
304 304
 				// Set it as a normal link field
305 305
 				$fields['links'][] = $link_field;
@@ -307,8 +307,8 @@  discard block
 block discarded – undo
307 307
 			}
308 308
 
309 309
 			// Not quite a recursive merge, since only one level
310
-			foreach($fields as $type => &$list) {
311
-				if($c_fields[$type]) {
310
+			foreach ($fields as $type => &$list) {
311
+				if ($c_fields[$type]) {
312 312
 					$list = array_merge($c_fields[$type], $list);
313 313
 					unset($c_fields[$type]);
314 314
 				}
@@ -316,12 +316,12 @@  discard block
 block discarded – undo
316 316
 			$fields += $c_fields;
317 317
 			$selects += $c_selects;
318 318
 		}
319
-		foreach((array)$fields['select'] as $name) {
320
-			if($record->$name != null && is_array($selects) && $selects[$name]) {
319
+		foreach ((array)$fields['select'] as $name) {
320
+			if ($record->$name != null && is_array($selects) && $selects[$name]) {
321 321
 				$record->$name = is_string($record->$name) ? explode(',', $record->$name) : $record->$name;
322
-				if(is_array($record->$name)) {
322
+				if (is_array($record->$name)) {
323 323
 					$names = array();
324
-					foreach($record->$name as $_name) {
324
+					foreach ($record->$name as $_name) {
325 325
 						$names[] = lang($selects[$name][$_name]);
326 326
 					}
327 327
 					$record->$name = implode(', ', $names);
@@ -334,18 +334,18 @@  discard block
 block discarded – undo
334 334
 				$record->$name = '';
335 335
 			}
336 336
 		}
337
-		foreach((array)$fields['links'] as $name) {
338
-			if($record->$name) {
339
-				if(is_numeric($record->$name) && !$links[$name]) {
337
+		foreach ((array)$fields['links'] as $name) {
338
+			if ($record->$name) {
339
+				if (is_numeric($record->$name) && !$links[$name]) {
340 340
 					$link = Link::get_link($record->$name);
341 341
 					$links[$name] = ($link['link_app1'] == $appname ? $link['link_app2'] : $link['link_app1']);
342 342
 					$record->$name = ($link['link_app1'] == $appname ? $link['link_id2'] : $link['link_id1']);
343 343
 				}
344
-				if($links[$name])
344
+				if ($links[$name])
345 345
 				{
346 346
 					$record->$name = Link::title($links[$name], $record->$name);
347 347
 				}
348
-				else if ( is_array($record->$name) && $record->$name['app'] && $record->$name['id'])
348
+				else if (is_array($record->$name) && $record->$name['app'] && $record->$name['id'])
349 349
 				{
350 350
 					$record->$name = Link::title($record->$name['app'], $record->$name['id']);
351 351
 				}
@@ -355,12 +355,12 @@  discard block
 block discarded – undo
355 355
 				$record->$name = '';
356 356
 			}
357 357
 		}
358
-		foreach((array)$fields['select-account'] as $name) {
358
+		foreach ((array)$fields['select-account'] as $name) {
359 359
 			// Compare against null to deal with empty arrays
360 360
 			if ($record->$name !== null) {
361
-				if(is_array($record->$name)) {
361
+				if (is_array($record->$name)) {
362 362
 					$names = array();
363
-					foreach($record->$name as $_name) {
363
+					foreach ($record->$name as $_name) {
364 364
 						$names[] = Api\Accounts::username($_name);
365 365
 					}
366 366
 					$record->$name = implode(', ', $names);
@@ -373,64 +373,64 @@  discard block
 block discarded – undo
373 373
 				$record->$name = '';
374 374
 			}
375 375
 		}
376
-		foreach((array)$fields['select-bool'] as $name) {
377
-			if($record->$name !== null) {
376
+		foreach ((array)$fields['select-bool'] as $name) {
377
+			if ($record->$name !== null) {
378 378
 				$record->$name = $record->$name ? lang('Yes') : lang('No');
379 379
 			}
380 380
 		}
381
-		foreach((array)$fields['date-time'] as $name) {
381
+		foreach ((array)$fields['date-time'] as $name) {
382 382
 			//if ($record->$name) $record->$name = date('Y-m-d H:i:s',$record->$name); // Standard date format
383 383
 			if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string
384
-			if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] . ' '.
385
-				($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'),$record->$name); // User date format
384
+			if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].' '.
385
+				($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'), $record->$name); // User date format
386 386
 			if (!$record->$name) $record->$name = '';
387 387
 		}
388
-		foreach((array)$fields['date'] as $name) {
388
+		foreach ((array)$fields['date'] as $name) {
389 389
 			//if ($record->$name) $record->$name = date('Y-m-d',$record->$name); // Standard date format
390 390
 			if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string
391 391
 			if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $record->$name); // User date format
392 392
 			if (!$record->$name) $record->$name = '';
393 393
 		}
394
-		foreach((array)$fields['float'] as $name)
394
+		foreach ((array)$fields['float'] as $name)
395 395
 		{
396
-			static $dec_separator,$thousands_separator;
396
+			static $dec_separator, $thousands_separator;
397 397
 			if (is_null($dec_separator))
398 398
 			{
399 399
 				$dec_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0];
400 400
 				if (empty($dec_separator)) $dec_separator = '.';
401 401
 				$thousands_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][1];
402 402
 			}
403
-			if($record->$name && (string)$record->$name != '')
403
+			if ($record->$name && (string)$record->$name != '')
404 404
 			{
405
-				if(!is_numeric($record->$name))
405
+				if (!is_numeric($record->$name))
406 406
 				{
407 407
 					$record->$name = floatval(str_replace($dec_separator, '.', preg_replace('/[^\d'.preg_quote($dec_separator).']/', '', $record->$name)));
408 408
 				}
409
-				$record->$name = number_format(str_replace(' ','',$record->$name), 2,
410
-					$dec_separator,$thousands_separator
409
+				$record->$name = number_format(str_replace(' ', '', $record->$name), 2,
410
+					$dec_separator, $thousands_separator
411 411
 				);
412 412
 			}
413 413
 		}
414 414
 
415 415
 		// Some custom methods for conversion
416
-		foreach((array)$methods as $name => $method) {
417
-			if($record->$name) $record->$name = ExecMethod($method, $record->$name);
416
+		foreach ((array)$methods as $name => $method) {
417
+			if ($record->$name) $record->$name = ExecMethod($method, $record->$name);
418 418
 		}
419 419
 
420 420
 		static $cat_object;
421
-		if(is_null($cat_object)) $cat_object = new Api\Categories(false,$appname);
422
-		foreach((array)$fields['select-cat'] as $name) {
423
-			if($record->$name) {
421
+		if (is_null($cat_object)) $cat_object = new Api\Categories(false, $appname);
422
+		foreach ((array)$fields['select-cat'] as $name) {
423
+			if ($record->$name) {
424 424
 				$cats = array();
425 425
 				$ids = is_array($record->$name) ? $record->$name : explode(',', $record->$name);
426
-				foreach($ids as $n => $cat_id) {
426
+				foreach ($ids as $n => $cat_id) {
427 427
 
428
-					if ($cat_id && $cat_object->check_perms(Acl::READ,$cat_id))
428
+					if ($cat_id && $cat_object->check_perms(Acl::READ, $cat_id))
429 429
 					{
430 430
 						$cats[] = $cat_object->id2name($cat_id);
431 431
 					}
432 432
 				}
433
-				$record->$name = implode(', ',$cats);
433
+				$record->$name = implode(', ', $cats);
434 434
 			}
435 435
 			else
436 436
 			{
@@ -457,18 +457,18 @@  discard block
 block discarded – undo
457 457
 	 * @param char $delimiter
458 458
 	 * @param char $enclosure
459 459
 	 */
460
-	protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure){
460
+	protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure) {
461 461
 		$string = "";
462 462
 		$writeDelimiter = false;
463
-		foreach($dataArray as $dataElement) {
464
-			if($writeDelimiter) $string .= $delimiter;
465
-			$string .= $enclosure . str_replace(array("\r\n", '"'), array("\n",'""'), $dataElement) . $enclosure;
463
+		foreach ($dataArray as $dataElement) {
464
+			if ($writeDelimiter) $string .= $delimiter;
465
+			$string .= $enclosure.str_replace(array("\r\n", '"'), array("\n", '""'), $dataElement).$enclosure;
466 466
 			$writeDelimiter = true;
467 467
 		}
468 468
 		$string .= "\n";
469 469
 		
470 470
 		// do charset translation
471
-		$string = $this->translation->convert( $string, $this->translation->charset(), $this->csv_charset );
471
+		$string = $this->translation->convert($string, $this->translation->charset(), $this->csv_charset);
472 472
 		
473 473
 		fwrite($filePointer, $string);
474 474
 			
Please login to merge, or discard this patch.
importexport/inc/class.importexport_helper_functions.inc.php 5 patches
Doc Comments   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	/**
124 124
 	 * converts accound_lid to account_id
125 125
 	 *
126
-	 * @param mixed $_account_lid comma seperated list or array with lids
126
+	 * @param mixed $_account_lids comma seperated list or array with lids
127 127
 	 * @return mixed comma seperated list or array with ids
128 128
 	 */
129 129
 	public static function account_name2id( &$_account_lids ) {
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	/**
204 204
 	 * converts account_ids to account_lids
205 205
 	 *
206
-	 * @param mixed $_account_ids comma seperated list or array with ids
206
+	 * @param mixed $_account_id comma seperated list or array with ids
207 207
 	 * @return mixed comma seperated list or array with lids
208 208
 	 */
209 209
 	public static function account_id2name( $_account_id ) {
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	/**
420 420
 	 * returns a list of importexport plugins
421 421
 	 *
422
-	 * @param string $_tpye {import | export | all}
422
+	 * @param string $_type {import | export | all}
423 423
 	 * @param string $_appname {<appname> | all}
424 424
 	 * @return array(<appname> => array( <type> => array(<plugin> => <title>)))
425 425
 	 */
@@ -591,6 +591,7 @@  discard block
 block discarded – undo
591 591
 	 *
592 592
 	 * @param $app_name String name of app
593 593
 	 * @param $plugin_name Name of the plugin
594
+	 * @param importexport_wizard_basic_export_csv $wizard_plugin
594 595
 	 *
595 596
 	 * @return Array ([fieldname] => array(widget settings), ...)
596 597
 	 */
Please login to merge, or discard this patch.
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -32,25 +32,25 @@  discard block
 block discarded – undo
32 32
 	 * Relative date ranges for filtering
33 33
 	 */
34 34
 	public static $relative_dates = array(      // Start: year,month,day,week, End: year,month,day,week
35
-                'Today'       => array(0,0,0,0,  0,0,1,0),
36
-                'Yesterday'   => array(0,0,-1,0, 0,0,0,0),
37
-                'This week'   => array(0,0,0,0,  0,0,0,1),
38
-                'Last week'   => array(0,0,0,-1, 0,0,0,0),
39
-                'This month'  => array(0,0,0,0,  0,1,0,0),
40
-                'Last month'  => array(0,-1,0,0, 0,0,0,0),
41
-                'Last 3 months' => array(0,-3,0,0, 0,0,0,0),
42
-                'This quarter'=> array(0,0,0,0,  0,0,0,0),      // Just a marker, needs special handling
43
-                'Last quarter'=> array(0,-4,0,0, 0,-4,0,0),     // Just a marker
44
-                'This year'   => array(0,0,0,0,  1,0,0,0),
45
-                'Last year'   => array(-1,0,0,0, 0,0,0,0),
46
-                '2 years ago' => array(-2,0,0,0, -1,0,0,0),
47
-                '3 years ago' => array(-3,0,0,0, -2,0,0,0),
48
-        );
35
+				'Today'       => array(0,0,0,0,  0,0,1,0),
36
+				'Yesterday'   => array(0,0,-1,0, 0,0,0,0),
37
+				'This week'   => array(0,0,0,0,  0,0,0,1),
38
+				'Last week'   => array(0,0,0,-1, 0,0,0,0),
39
+				'This month'  => array(0,0,0,0,  0,1,0,0),
40
+				'Last month'  => array(0,-1,0,0, 0,0,0,0),
41
+				'Last 3 months' => array(0,-3,0,0, 0,0,0,0),
42
+				'This quarter'=> array(0,0,0,0,  0,0,0,0),      // Just a marker, needs special handling
43
+				'Last quarter'=> array(0,-4,0,0, 0,-4,0,0),     // Just a marker
44
+				'This year'   => array(0,0,0,0,  1,0,0,0),
45
+				'Last year'   => array(-1,0,0,0, 0,0,0,0),
46
+				'2 years ago' => array(-2,0,0,0, -1,0,0,0),
47
+				'3 years ago' => array(-3,0,0,0, -2,0,0,0),
48
+		);
49 49
 
50 50
 	/**
51
-	* Files known to cause problems, and will be skipped in a plugin scan
52
-	* If you put appname => true, the whole app will be skipped.
53
-	*/
51
+	 * Files known to cause problems, and will be skipped in a plugin scan
52
+	 * If you put appname => true, the whole app will be skipped.
53
+	 */
54 54
 	protected static $blacklist_files = array(
55 55
 		'api' => true,
56 56
 		'etemplate' => true,
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
 	);
65 65
 
66 66
 	/**
67
-	* Class used to provide extra conversion functions
68
-	*
69
-	* Passed in as a param to conversion()
70
-	*/
67
+	 * Class used to provide extra conversion functions
68
+	 *
69
+	 * Passed in as a param to conversion()
70
+	 */
71 71
 	protected static $cclass = null;
72 72
 
73 73
 	/**
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 		return $plugins;
446 446
 	}
447 447
 
448
-	public static function _get_plugins(Array $appnames, Array $types) {
448
+	public static function _get_plugins(array $appnames, array $types) {
449 449
 		$plugins = array();
450 450
 		foreach ($appnames as $appname) {
451 451
 			if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue;
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 	}
563 563
 
564 564
 	// Api\Cache needs this public
565
-	public static function _has_definitions(Array $appnames, Array $types) {
565
+	public static function _has_definitions(array $appnames, array $types) {
566 566
 		$def = new importexport_definitions_bo(array('application'=>$appnames, 'type' => $types));
567 567
 		$list = array();
568 568
 		foreach((array)$def->get_definitions() as $id) {
Please login to merge, or discard this patch.
Spacing   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -32,19 +32,19 @@  discard block
 block discarded – undo
32 32
 	 * Relative date ranges for filtering
33 33
 	 */
34 34
 	public static $relative_dates = array(      // Start: year,month,day,week, End: year,month,day,week
35
-                'Today'       => array(0,0,0,0,  0,0,1,0),
36
-                'Yesterday'   => array(0,0,-1,0, 0,0,0,0),
37
-                'This week'   => array(0,0,0,0,  0,0,0,1),
38
-                'Last week'   => array(0,0,0,-1, 0,0,0,0),
39
-                'This month'  => array(0,0,0,0,  0,1,0,0),
40
-                'Last month'  => array(0,-1,0,0, 0,0,0,0),
41
-                'Last 3 months' => array(0,-3,0,0, 0,0,0,0),
42
-                'This quarter'=> array(0,0,0,0,  0,0,0,0),      // Just a marker, needs special handling
43
-                'Last quarter'=> array(0,-4,0,0, 0,-4,0,0),     // Just a marker
44
-                'This year'   => array(0,0,0,0,  1,0,0,0),
45
-                'Last year'   => array(-1,0,0,0, 0,0,0,0),
46
-                '2 years ago' => array(-2,0,0,0, -1,0,0,0),
47
-                '3 years ago' => array(-3,0,0,0, -2,0,0,0),
35
+                'Today'       => array(0, 0, 0, 0, 0, 0, 1, 0),
36
+                'Yesterday'   => array(0, 0, -1, 0, 0, 0, 0, 0),
37
+                'This week'   => array(0, 0, 0, 0, 0, 0, 0, 1),
38
+                'Last week'   => array(0, 0, 0, -1, 0, 0, 0, 0),
39
+                'This month'  => array(0, 0, 0, 0, 0, 1, 0, 0),
40
+                'Last month'  => array(0, -1, 0, 0, 0, 0, 0, 0),
41
+                'Last 3 months' => array(0, -3, 0, 0, 0, 0, 0, 0),
42
+                'This quarter'=> array(0, 0, 0, 0, 0, 0, 0, 0), // Just a marker, needs special handling
43
+                'Last quarter'=> array(0, -4, 0, 0, 0, -4, 0, 0), // Just a marker
44
+                'This year'   => array(0, 0, 0, 0, 1, 0, 0, 0),
45
+                'Last year'   => array(-1, 0, 0, 0, 0, 0, 0, 0),
46
+                '2 years ago' => array(-2, 0, 0, 0, -1, 0, 0, 0),
47
+                '3 years ago' => array(-3, 0, 0, 0, -2, 0, 0, 0),
48 48
         );
49 49
 
50 50
 	/**
@@ -85,22 +85,22 @@  discard block
 block discarded – undo
85 85
 	 * @param string $_format format of time string e.g.: d.m.Y H:i
86 86
 	 * @param int $_is_dst is day light saving time? 0 = no, 1 = yes, -1 = system default
87 87
 	 */
88
-	public static function custom_strtotime( $_string, $_format='', $_is_dst = -1) {
89
-		if ( empty( $_format ) ) return strtotime( $_string );
90
-		$fparams = explode( ',', chunk_split( $_format, 1, ',' ) );
88
+	public static function custom_strtotime($_string, $_format = '', $_is_dst = -1) {
89
+		if (empty($_format)) return strtotime($_string);
90
+		$fparams = explode(',', chunk_split($_format, 1, ','));
91 91
 		$spos = 0;
92
-		foreach ( $fparams as $fparam ) {
93
-
94
-			switch ( $fparam ) {
95
-				case 'd': (int)$day = substr( $_string, $spos, 2 ); $spos += 2; break;
96
-				case 'm': (int)$mon = substr( $_string, $spos, 2 ); $spos += 2; break;
97
-				case 'y': (int)$year = substr( $_string, $spos, 2 ); $spos += 2; break;
98
-				case 'Y': (int)$year = substr( $_string, $spos, 4 ); $spos += 4; break;
99
-				case 'H': (int)$hour = substr( $_string, $spos, 2 ); $spos += 2; break;
100
-				case 'h': (int)$hour = substr( $_string, $spos, 2 ); $spos += 2; break;
101
-				case 'i': (int)$min =  substr( $_string, $spos, 2 ); $spos += 2; break;
102
-				case 's': (int)$sec =  substr( $_string, $spos, 2 ); $spos += 2; break;
103
-				case 'O': (int)$offset = $year = substr( $_string, $spos, 5 ); $spos += 5; break;
92
+		foreach ($fparams as $fparam) {
93
+
94
+			switch ($fparam) {
95
+				case 'd': (int)$day = substr($_string, $spos, 2); $spos += 2; break;
96
+				case 'm': (int)$mon = substr($_string, $spos, 2); $spos += 2; break;
97
+				case 'y': (int)$year = substr($_string, $spos, 2); $spos += 2; break;
98
+				case 'Y': (int)$year = substr($_string, $spos, 4); $spos += 4; break;
99
+				case 'H': (int)$hour = substr($_string, $spos, 2); $spos += 2; break;
100
+				case 'h': (int)$hour = substr($_string, $spos, 2); $spos += 2; break;
101
+				case 'i': (int)$min = substr($_string, $spos, 2); $spos += 2; break;
102
+				case 's': (int)$sec = substr($_string, $spos, 2); $spos += 2; break;
103
+				case 'O': (int)$offset = $year = substr($_string, $spos, 5); $spos += 5; break;
104 104
 				case 'a': (int)$hour = $fparam == 'am' ? $hour : $hour + 12; break;
105 105
 				case 'A': (int)$hour = $fparam == 'AM' ? $hour : $hour + 12; break;
106 106
 				default: $spos++; // seperator
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 		$timestamp = mktime($hour, $min, $sec, $mon, $day, $year, $_is_dst);
112 112
 
113 113
 		// offset given?
114
-		if ( isset( $offset ) && strlen( $offset == 5 ) ) {
114
+		if (isset($offset) && strlen($offset == 5)) {
115 115
 			$operator = $offset{0};
116
-			$ohour = 60 * 60 * (int)substr( $offset, 1, 2 );
117
-			$omin = 60 * (int)substr( $offset, 3, 2 );
118
-			if ( $operator == '+' ) $timestamp += $ohour + $omin;
116
+			$ohour = 60 * 60 * (int)substr($offset, 1, 2);
117
+			$omin = 60 * (int)substr($offset, 3, 2);
118
+			if ($operator == '+') $timestamp += $ohour + $omin;
119 119
 			else $timestamp -= $ohour + $omin;
120 120
 		}
121 121
 		return $timestamp;
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 	 * @param mixed $_account_lid comma seperated list or array with lids
127 127
 	 * @return mixed comma seperated list or array with ids
128 128
 	 */
129
-	public static function account_name2id( &$_account_lids ) {
130
-		$account_lids = is_array( $_account_lids ) ? $_account_lids : explode( ',', $_account_lids );
129
+	public static function account_name2id(&$_account_lids) {
130
+		$account_lids = is_array($_account_lids) ? $_account_lids : explode(',', $_account_lids);
131 131
 		$skip = false;
132
-		foreach ( $account_lids as $key => $account_lid ) {
133
-			if($skip) {
132
+		foreach ($account_lids as $key => $account_lid) {
133
+			if ($skip) {
134 134
 				unset($account_lids[$key]);
135 135
 				$skip = false;
136 136
 				continue;
@@ -138,15 +138,15 @@  discard block
 block discarded – undo
138 138
 			$account_lid = trim($account_lid);
139 139
 
140 140
 			// Handle any IDs that slip in
141
-			if(is_numeric($account_lid) && $GLOBALS['egw']->accounts->id2name($account_lid)) {
141
+			if (is_numeric($account_lid) && $GLOBALS['egw']->accounts->id2name($account_lid)) {
142 142
 				unset($account_lids[$key]);
143 143
 				$account_ids[] = (int)$account_lid;
144 144
 				continue;
145 145
 			}
146 146
 			// Check for [username]
147
-			if(strpos($account_lid,'[') !== false)
147
+			if (strpos($account_lid, '[') !== false)
148 148
 			{
149
-				if(preg_match('/\[(.+)\]/',$account_lid,$matches))
149
+				if (preg_match('/\[(.+)\]/', $account_lid, $matches))
150 150
 				{
151 151
 					$account_id = $GLOBALS['egw']->accounts->name2id($matches[1]);
152 152
 					unset($account_lids[$key]);
@@ -157,59 +157,59 @@  discard block
 block discarded – undo
157 157
 
158 158
 			// Handle users listed as Lastname, Firstname instead of login ID
159 159
 			// Do this first, in case their first name matches a username
160
-			if ( $account_lids[$key+1][0] == ' ')
160
+			if ($account_lids[$key + 1][0] == ' ')
161 161
 			{
162 162
 				$query = array('type' => 'accounts', 'query_type' => 'exact');
163
-				$given = $GLOBALS['egw']->accounts->search($query + array('query' => trim($account_lids[$key+1])));
163
+				$given = $GLOBALS['egw']->accounts->search($query + array('query' => trim($account_lids[$key + 1])));
164 164
 				$family = $GLOBALS['egw']->accounts->search($query + array('query' => trim($account_lid)));
165 165
 				$ids = array_intersect_key($family, $given);
166
-				if($ids)
166
+				if ($ids)
167 167
 				{
168 168
 					$account_ids[] = key($ids);
169 169
 					unset($account_lids[$key]);
170 170
 					$skip = true; // Skip the next one, it's the first name
171
-					continue ;
171
+					continue;
172 172
 				}
173 173
 			}
174 174
 
175 175
 			// Deal with groups listed as <name> Group, remove the Group
176
-			if(substr(trim($account_lid),-strlen(lang('Group'))) == lang('Group'))
176
+			if (substr(trim($account_lid), -strlen(lang('Group'))) == lang('Group'))
177 177
 			{
178 178
 				$account_lid = trim(substr(trim($account_lid), 0, -strlen(lang('Group'))));
179 179
 			}
180 180
 			// Group <name> (no comma)
181
-			else if(strpos($account_lid, lang('Group')) === 0)
181
+			else if (strpos($account_lid, lang('Group')) === 0)
182 182
 			{
183 183
 				$account_lid = trim(substr(trim($account_lid), strlen(lang('Group'))));
184 184
 			}
185 185
 
186
-			if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid )) {
186
+			if ($account_id = $GLOBALS['egw']->accounts->name2id($account_lid)) {
187 187
 				$account_ids[] = $account_id;
188 188
 				unset($account_lids[$key]);
189 189
 				continue;
190 190
 			}
191
-			if ( $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lid), 'account_fullname' )) {
191
+			if ($account_id = $GLOBALS['egw']->accounts->name2id(trim($account_lid), 'account_fullname')) {
192 192
 				$account_ids[] = $account_id;
193 193
 				unset($account_lids[$key]);
194 194
 				continue;
195 195
 			}
196 196
 
197 197
 			// Handle groups listed as Group, <name>
198
-			if ( $account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid)) {
198
+			if ($account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id($account_lid)) {
199 199
 				$account_ids[] = $account_id;
200
-				unset($account_lids[$key-1]);
200
+				unset($account_lids[$key - 1]);
201 201
 				unset($account_lids[$key]);
202 202
 				continue;
203 203
 			}
204 204
 			// Group, <name> - remove the Group part
205
-			if($account_lid == lang('Group'))
205
+			if ($account_lid == lang('Group'))
206 206
 			{
207 207
 				unset($account_lids[$key]);
208 208
 				continue;
209 209
 			}
210 210
 		}
211
-		$_account_lids = (is_array($_account_lids) ? $account_lids : implode(',',array_unique($account_lids)));
212
-		return is_array( $_account_lids ) ? array_unique($account_ids) : implode( ',', array_unique((array)$account_ids ));
211
+		$_account_lids = (is_array($_account_lids) ? $account_lids : implode(',', array_unique($account_lids)));
212
+		return is_array($_account_lids) ? array_unique($account_ids) : implode(',', array_unique((array)$account_ids));
213 213
 
214 214
 	} // end of member function account_lid2id
215 215
 
@@ -219,14 +219,14 @@  discard block
 block discarded – undo
219 219
 	 * @param mixed $_account_ids comma seperated list or array with ids
220 220
 	 * @return mixed comma seperated list or array with lids
221 221
 	 */
222
-	public static function account_id2name( $_account_id ) {
223
-		$account_ids = is_array( $_account_id ) ? $_account_id : explode( ',', $_account_id );
224
-		foreach ( $account_ids as $account_id ) {
225
-			if ( $account_lid = $GLOBALS['egw']->accounts->id2name( $account_id )) {
222
+	public static function account_id2name($_account_id) {
223
+		$account_ids = is_array($_account_id) ? $_account_id : explode(',', $_account_id);
224
+		foreach ($account_ids as $account_id) {
225
+			if ($account_lid = $GLOBALS['egw']->accounts->id2name($account_id)) {
226 226
 				$account_lids[] = $account_lid;
227 227
 			}
228 228
 		}
229
-		return is_array( $_account_id ) ? $account_lids : implode( ',', (array)$account_lids );
229
+		return is_array($_account_id) ? $account_lids : implode(',', (array)$account_lids);
230 230
 	} // end of member function account_id2lid
231 231
 
232 232
 	/**
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
 	 * @param mixed _cat_ids comma seperated list or array
236 236
 	 * @return mixed comma seperated list or array with cat_names
237 237
 	 */
238
-	public static function cat_id2name( $_cat_ids ) {
239
-		$cat_ids = is_array( $_cat_ids ) ? $_cat_ids : explode( ',', $_cat_ids );
240
-		foreach ( $cat_ids as $cat_id ) {
241
-			$cat_names[] = Api\Categories::id2name( (int)$cat_id );
238
+	public static function cat_id2name($_cat_ids) {
239
+		$cat_ids = is_array($_cat_ids) ? $_cat_ids : explode(',', $_cat_ids);
240
+		foreach ($cat_ids as $cat_id) {
241
+			$cat_names[] = Api\Categories::id2name((int)$cat_id);
242 242
 		}
243
-		return is_array( $_cat_ids ) ? $cat_names : implode(',',(array)$cat_names);
243
+		return is_array($_cat_ids) ? $cat_names : implode(',', (array)$cat_names);
244 244
 	} // end of member function category_id2name
245 245
 
246 246
 	/**
@@ -251,24 +251,24 @@  discard block
 block discarded – undo
251 251
 	 * @param int $parent Optional parent ID to use for new categories
252 252
 	 * @return mixed comma seperated list or array with cat_ids
253 253
 	 */
254
-	public static function cat_name2id( $_cat_names, $parent = 0 ) {
255
-		$cats = new Api\Categories();	// uses current user and app (egw_info[flags][currentapp])
254
+	public static function cat_name2id($_cat_names, $parent = 0) {
255
+		$cats = new Api\Categories(); // uses current user and app (egw_info[flags][currentapp])
256 256
 
257
-		$cat_names = is_array( $_cat_names ) ? $_cat_names : explode( ',', $_cat_names );
258
-		foreach ( $cat_names as $cat_name ) {
257
+		$cat_names = is_array($_cat_names) ? $_cat_names : explode(',', $_cat_names);
258
+		foreach ($cat_names as $cat_name) {
259 259
 			$cat_name = trim($cat_name);
260
-			if ( $cat_name == '' ) continue;
261
-			if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 && !self::$dry_run) {
262
-				$cat_id = $cats->add( array(
260
+			if ($cat_name == '') continue;
261
+			if (($cat_id = $cats->name2id($cat_name)) == 0 && !self::$dry_run) {
262
+				$cat_id = $cats->add(array(
263 263
 					'name' => $cat_name,
264 264
 					'parent' => $parent,
265 265
 					'access' => 'public',
266
-					'descr' => $cat_name. ' ('. lang('Automatically created by importexport'). ')'
266
+					'descr' => $cat_name.' ('.lang('Automatically created by importexport').')'
267 267
 				));
268 268
 			}
269 269
 			$cat_ids[] = $cat_id;
270 270
 		}
271
-		return is_array( $_cat_names ) ? $cat_ids : implode( ',', (array)$cat_ids );
271
+		return is_array($_cat_names) ? $cat_ids : implode(',', (array)$cat_ids);
272 272
 
273 273
 	} // end of member function category_name2id
274 274
 
@@ -307,76 +307,76 @@  discard block
 block discarded – undo
307 307
 	 * @param object &$cclass calling class to process the '@ evals'
308 308
 	 * @return bool
309 309
 	 */
310
-	public static function conversion( &$_record,  $_conversion, &$_cclass = null ) {
311
-		if (empty( $_conversion ) ) return $_record;
310
+	public static function conversion(&$_record, $_conversion, &$_cclass = null) {
311
+		if (empty($_conversion)) return $_record;
312 312
 
313
-		self::$cclass =& $_cclass;
313
+		self::$cclass = & $_cclass;
314 314
 
315 315
 		$PSep = '||'; // Pattern-Separator, separats the pattern-replacement-pairs in conversion
316 316
 		$ASep = '|>'; // Assignment-Separator, separats pattern and replacesment
317
-		$CPre = '|['; $CPos = ']';  // |[_record-idx] is expanded to the corespondig value
317
+		$CPre = '|['; $CPos = ']'; // |[_record-idx] is expanded to the corespondig value
318 318
 		$TPre = '|T{'; $TPos = '}'; // |{_record-idx} is trimmed
319
-		$CntlPre = '|TC{';		    // Filter all cntl-chars \x01-\x1f and trim
320
-		$CntlnCLPre  = '|TCnCL{';   // Like |C{ but allowes CR and LF
321
-		$INE = '|INE{';             // Only insert if stuff in ^^ is not empty
319
+		$CntlPre = '|TC{'; // Filter all cntl-chars \x01-\x1f and trim
320
+		$CntlnCLPre = '|TCnCL{'; // Like |C{ but allowes CR and LF
321
+		$INE = '|INE{'; // Only insert if stuff in ^^ is not empty
322 322
 
323
-		foreach ( $_conversion as $idx => $conversion_string ) {
324
-			if ( empty( $conversion_string ) ) continue;
323
+		foreach ($_conversion as $idx => $conversion_string) {
324
+			if (empty($conversion_string)) continue;
325 325
 
326 326
 			// fetch patterns ($rvalues)
327 327
 			$rvalues = array();
328
-			$pat_reps = explode( $PSep, stripslashes( $conversion_string ) );
329
-			foreach( $pat_reps as $k => $pat_rep ) {
330
-				list( $pattern, $replace ) = explode( $ASep, $pat_rep, 2 );
331
-				if( $replace == '' ) {
328
+			$pat_reps = explode($PSep, stripslashes($conversion_string));
329
+			foreach ($pat_reps as $k => $pat_rep) {
330
+				list($pattern, $replace) = explode($ASep, $pat_rep, 2);
331
+				if ($replace == '') {
332 332
 					$replace = $pattern; $pattern = '^.*$';
333 333
 				}
334
-				$rvalues[$pattern] = $replace;	// replace two with only one, added by the form
334
+				$rvalues[$pattern] = $replace; // replace two with only one, added by the form
335 335
 			}
336 336
 
337 337
 			// conversion list may be longer than $_record aka (no_csv)
338
-			$val = array_key_exists( $idx, $_record ) ? $_record[$idx] : '';
338
+			$val = array_key_exists($idx, $_record) ? $_record[$idx] : '';
339 339
 
340 340
 			$c_functions = array('cat', 'account', 'strtotime', 'list');
341
-			if($_cclass) {
341
+			if ($_cclass) {
342 342
 				// Add in additional methods
343 343
 				$reflection = new ReflectionClass(get_class($_cclass));
344 344
 				$methods = $reflection->getMethods(ReflectionMethod::IS_STATIC);
345
-				foreach($methods as $method) {
345
+				foreach ($methods as $method) {
346 346
 					$c_functions[] = $method->name;
347 347
 				}
348 348
 			}
349 349
 			$c_functions = implode('|', $c_functions);
350
-			foreach ( $rvalues as $pattern => $replace ) {
350
+			foreach ($rvalues as $pattern => $replace) {
351 351
 				// Allow to include record indexes in pattern
352 352
 				$reg = '/\|\[([0-9]+)\]/';
353
-				while( preg_match( $reg, $pattern, $vars ) ) {
353
+				while (preg_match($reg, $pattern, $vars)) {
354 354
 					// expand all _record fields
355 355
 					$pattern = str_replace(
356
-						$CPre . $vars[1] . $CPos,
356
+						$CPre.$vars[1].$CPos,
357 357
 						$_record[array_search($vars[1], array_keys($_record))],
358 358
 						$pattern
359 359
 					);
360 360
 				}
361
-				if( preg_match('/'. (string)$pattern.'/', $val) ) {
361
+				if (preg_match('/'.(string)$pattern.'/', $val)) {
362 362
 
363
-					$val = preg_replace( '/'.(string)$pattern.'/', $replace, (string)$val );
363
+					$val = preg_replace('/'.(string)$pattern.'/', $replace, (string)$val);
364 364
 
365 365
 					$reg = '/\|\[([a-zA-Z_0-9]+)\]/';
366
-					while( preg_match( $reg, $val, $vars ) ) {
366
+					while (preg_match($reg, $val, $vars)) {
367 367
 						// expand all _record fields
368 368
 						$val = str_replace(
369
-							$CPre . $vars[1] . $CPos,
369
+							$CPre.$vars[1].$CPos,
370 370
 							$_record[array_search($vars[1], array_keys($_record))],
371 371
 							$val
372 372
 						);
373 373
 					}
374
-					$val = preg_replace_callback( "/($c_functions)\(([^)]*)\)/i", array( self, 'c2_dispatcher') , $val );
374
+					$val = preg_replace_callback("/($c_functions)\(([^)]*)\)/i", array(self, 'c2_dispatcher'), $val);
375 375
 					break;
376 376
 				}
377 377
 			}
378 378
 			// clean each field
379
-			$val = preg_replace_callback("/(\|T\{|\|TC\{|\|TCnCL\{|\|INE\{)(.*)\}/", array( self, 'strclean'), $val );
379
+			$val = preg_replace_callback("/(\|T\{|\|TC\{|\|TCnCL\{|\|INE\{)(.*)\}/", array(self, 'strclean'), $val);
380 380
 
381 381
 			$_record[$idx] = $val;
382 382
 		}
@@ -390,42 +390,42 @@  discard block
 block discarded – undo
390 390
 	 *
391 391
 	 * @param array $_matches
392 392
 	 */
393
-	private static function c2_dispatcher( $_matches ) {
393
+	private static function c2_dispatcher($_matches) {
394 394
 		$action = &$_matches[1]; // cat or account ...
395
-		$data = &$_matches[2];   // datas for action
395
+		$data = &$_matches[2]; // datas for action
396 396
 
397
-		switch ( $action ) {
397
+		switch ($action) {
398 398
 			case 'strtotime' :
399
-				list( $string, $format ) = explode( ',', $data );
400
-				return self::custom_strtotime( trim( $string ), trim( $format ) );
399
+				list($string, $format) = explode(',', $data);
400
+				return self::custom_strtotime(trim($string), trim($format));
401 401
 			case 'list':
402
-				list( $split, $data, $index) = explode(',',$data);
402
+				list($split, $data, $index) = explode(',', $data);
403 403
 				$exploded = explode($split, $data);
404 404
 				// 1 based indexing for user ease
405 405
 				return $exploded[$index - 1];
406 406
 			default :
407
-				if(self::$cclass && method_exists(self::$cclass, $action)) {
407
+				if (self::$cclass && method_exists(self::$cclass, $action)) {
408 408
 					$class = get_class(self::$cclass);
409 409
 					return call_user_func("$class::$action", $data);
410 410
 				}
411
-				$method = (string)$action. ( is_int( $data ) ? '_id2name' : '_name2id' );
412
-				if(self::$cclass && method_exists(self::$cclass, $method)) {
411
+				$method = (string)$action.(is_int($data) ? '_id2name' : '_name2id');
412
+				if (self::$cclass && method_exists(self::$cclass, $method)) {
413 413
 					$class = get_class(self::$cclass);
414 414
 					return call_user_func("$class::$action", $data);
415 415
 				} else {
416
-					return self::$method( $data );
416
+					return self::$method($data);
417 417
 				}
418 418
 		}
419 419
 	}
420 420
 
421
-	private static function strclean( $_matches ) {
422
-		switch( $_matches[1] ) {
423
-			case '|T{' : return trim( $_matches[2] );
424
-			case '|TC{' : return trim( preg_replace( '/[\x01-\x1F]+/', '', $_matches[2] ) );
425
-			case '|TCnCL{' : return trim( preg_replace( '/[\x01-\x09\x11\x12\x14-\x1F]+/', '', $_matches[2] ) );
426
-			case '|INE{' : return preg_match( '/\^.+\^/', $_matches[2] ) ? $_matches[2] : '';
421
+	private static function strclean($_matches) {
422
+		switch ($_matches[1]) {
423
+			case '|T{' : return trim($_matches[2]);
424
+			case '|TC{' : return trim(preg_replace('/[\x01-\x1F]+/', '', $_matches[2]));
425
+			case '|TCnCL{' : return trim(preg_replace('/[\x01-\x09\x11\x12\x14-\x1F]+/', '', $_matches[2]));
426
+			case '|INE{' : return preg_match('/\^.+\^/', $_matches[2]) ? $_matches[2] : '';
427 427
 			default:
428
-				throw new Exception('Error in conversion string! "'. substr( $_matches[1], 0, -1 ). '" is not valid!');
428
+				throw new Exception('Error in conversion string! "'.substr($_matches[1], 0, -1).'" is not valid!');
429 429
 		}
430 430
 	}
431 431
 
@@ -436,23 +436,23 @@  discard block
 block discarded – undo
436 436
 	 * @param string $_appname {<appname> | all}
437 437
 	 * @return array(<appname> => array( <type> => array(<plugin> => <title>)))
438 438
 	 */
439
-	public static function get_plugins( $_appname = 'all', $_type = 'all' ) {
439
+	public static function get_plugins($_appname = 'all', $_type = 'all') {
440 440
 		$plugins = Api\Cache::getTree(
441 441
 			__CLASS__,
442 442
 			'plugins',
443
-			array('importexport_helper_functions','_get_plugins'),
443
+			array('importexport_helper_functions', '_get_plugins'),
444 444
 			array(array_keys($GLOBALS['egw_info']['apps']), array('import', 'export')),
445 445
 			self::CACHE_EXPIRATION
446 446
 		);
447 447
 		$appnames = $_appname == 'all' ? array_keys($GLOBALS['egw_info']['apps']) : (array)$_appname;
448
-		$types = $_type == 'all' ? array('import','export') : (array)$_type;
448
+		$types = $_type == 'all' ? array('import', 'export') : (array)$_type;
449 449
 
450 450
 		// Testing: comment out Api\Cache call, use this
451 451
 		//$plugins = self::_get_plugins($appnames, $types);
452
-		foreach($plugins as $appname => $_types) {
453
-			if(!in_array($appname, $appnames)) unset($plugins[$appname]);
452
+		foreach ($plugins as $appname => $_types) {
453
+			if (!in_array($appname, $appnames)) unset($plugins[$appname]);
454 454
 		}
455
-		foreach($plugins as $appname => $types) {
455
+		foreach ($plugins as $appname => $types) {
456 456
 			$plugins[$appname] = array_intersect_key($plugins[$appname], $types);
457 457
 		}
458 458
 		return $plugins;
@@ -461,25 +461,25 @@  discard block
 block discarded – undo
461 461
 	public static function _get_plugins(Array $appnames, Array $types) {
462 462
 		$plugins = array();
463 463
 		foreach ($appnames as $appname) {
464
-			if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue;
464
+			if (array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue;
465 465
 
466
-			$appdir = EGW_INCLUDE_ROOT. "/$appname/inc";
467
-			if(!is_dir($appdir)) continue;
466
+			$appdir = EGW_INCLUDE_ROOT."/$appname/inc";
467
+			if (!is_dir($appdir)) continue;
468 468
 			$d = dir($appdir);
469 469
 
470 470
 			// step through each file in appdir
471 471
 			while (false !== ($entry = $d->read())) {
472 472
 				// Blacklisted?
473
-				if(is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname]))  continue;
473
+				if (is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname]))  continue;
474 474
 				if (!preg_match('/^class\.([^.]+)\.inc\.php$/', $entry, $matches)) continue;
475 475
 				$classname = $matches[1];
476
-				$file = $appdir. '/'. $entry;
476
+				$file = $appdir.'/'.$entry;
477 477
 
478 478
 				foreach ($types as $type) {
479
-					if( !is_file($file) || strpos($entry, $type) === false || strpos($entry,'wizard') !== false) continue;
479
+					if (!is_file($file) || strpos($entry, $type) === false || strpos($entry, 'wizard') !== false) continue;
480 480
 					require_once($file);
481 481
 					$reflectionClass = new ReflectionClass($classname);
482
-					if($reflectionClass->IsInstantiable() &&
482
+					if ($reflectionClass->IsInstantiable() &&
483 483
 							$reflectionClass->implementsInterface('importexport_iface_'.$type.'_plugin')) {
484 484
 						try {
485 485
 							$plugin_object = new $classname;
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 			$d->close();
496 496
 
497 497
 			$config = Api\Config::read('importexport');
498
-			if($config['update'] == 'auto') {
498
+			if ($config['update'] == 'auto') {
499 499
 				self::load_defaults($appname);
500 500
 			}
501 501
 		}
@@ -510,37 +510,37 @@  discard block
 block discarded – undo
510 510
 	 * @return array $num => $appname
511 511
 	 */
512 512
 	public static function get_apps($_type, $ignore_acl = false) {
513
-		$apps = array_keys(self::get_plugins('all',$_type));
514
-		if($ignore_acl) return $apps;
513
+		$apps = array_keys(self::get_plugins('all', $_type));
514
+		if ($ignore_acl) return $apps;
515 515
 
516
-		foreach($apps as $key => $app) {
517
-			if(!self::has_definitions($app, $_type)) unset($apps[$key]);
516
+		foreach ($apps as $key => $app) {
517
+			if (!self::has_definitions($app, $_type)) unset($apps[$key]);
518 518
 		}
519 519
 		return $apps;
520 520
 	}
521 521
 
522 522
 	public static function load_defaults($appname) {
523 523
 		// Check for new definitions to import from $appname/setup/*.xml
524
-		$appdir = EGW_INCLUDE_ROOT. "/$appname/setup";
525
-		if(!is_dir($appdir)) return;
524
+		$appdir = EGW_INCLUDE_ROOT."/$appname/setup";
525
+		if (!is_dir($appdir)) return;
526 526
 		$d = dir($appdir);
527 527
 
528 528
 		// step through each file in app's setup
529 529
 		while (false !== ($entry = $d->read())) {
530
-			$file = $appdir. '/'. $entry;
531
-			list( $filename, $extension) = explode('.',$entry);
532
-			if ( $extension != 'xml' ) continue;
530
+			$file = $appdir.'/'.$entry;
531
+			list($filename, $extension) = explode('.', $entry);
532
+			if ($extension != 'xml') continue;
533 533
 			try {
534 534
 				// import will skip invalid files
535
-				importexport_definitions_bo::import( $file );
535
+				importexport_definitions_bo::import($file);
536 536
 			} catch (Exception $e) {
537
-				error_log(__CLASS__.__FUNCTION__. " import $appname definitions: " . $e->getMessage());
537
+				error_log(__CLASS__.__FUNCTION__." import $appname definitions: ".$e->getMessage());
538 538
 			}
539 539
 		}
540 540
 		$d->close();
541 541
 	}
542 542
 
543
-	public static function guess_filetype( $_file ) {
543
+	public static function guess_filetype($_file) {
544 544
 
545 545
 	}
546 546
 
@@ -551,24 +551,24 @@  discard block
 block discarded – undo
551 551
 	 * @param string $_type {import | export | all}
552 552
 	 * @return boolean
553 553
 	 */
554
-	public static function has_definitions( $_appname = 'all', $_type = 'all' ) {
554
+	public static function has_definitions($_appname = 'all', $_type = 'all') {
555 555
 		$definitions = Api\Cache::getSession(
556 556
 			__CLASS__,
557 557
 			'has_definitions',
558
-			array('importexport_helper_functions','_has_definitions'),
558
+			array('importexport_helper_functions', '_has_definitions'),
559 559
 			array(array_keys($GLOBALS['egw_info']['apps']), array('import', 'export')),
560 560
 			self::CACHE_EXPIRATION
561 561
 		);
562 562
 		$appnames = $_appname == 'all' ? array_keys($GLOBALS['egw_info']['apps']) : (array)$_appname;
563
-		$types = $_type == 'all' ? array('import','export') : (array)$_type;
563
+		$types = $_type == 'all' ? array('import', 'export') : (array)$_type;
564 564
 
565 565
 		// Testing: Comment out cache call above, use this
566 566
 		//$definitions = self::_has_definitions($appnames, $types);
567 567
 
568
-		foreach($definitions as $appname => $_types) {
569
-			if(!in_array($appname, $appnames)) unset($definitions[$appname]);
568
+		foreach ($definitions as $appname => $_types) {
569
+			if (!in_array($appname, $appnames)) unset($definitions[$appname]);
570 570
 		}
571
-		foreach($definitions as $appname => $_types) {
571
+		foreach ($definitions as $appname => $_types) {
572 572
 			$definitions[$appname] = array_intersect_key($definitions[$appname], array_flip($types));
573 573
 		}
574 574
 		return !empty($definitions[$appname]);
@@ -578,11 +578,11 @@  discard block
 block discarded – undo
578 578
 	public static function _has_definitions(Array $appnames, Array $types) {
579 579
 		$def = new importexport_definitions_bo(array('application'=>$appnames, 'type' => $types));
580 580
 		$list = array();
581
-		foreach((array)$def->get_definitions() as $id) {
581
+		foreach ((array)$def->get_definitions() as $id) {
582 582
 			// Need to instanciate it to check, but if the user doesn't have permission, it throws an exception
583 583
 			try {
584 584
 				$definition = new importexport_definition($id);
585
-				if($def->is_permitted($definition->get_record_array())) {
585
+				if ($def->is_permitted($definition->get_record_array())) {
586 586
 					$list[$definition->application][$definition->type][] = $id;
587 587
 				}
588 588
 			} catch (Exception $e) {
@@ -614,13 +614,13 @@  discard block
 block discarded – undo
614 614
 			$plugin = is_object($plugin_name) ? $plugin_name : new $plugin_name();
615 615
 			$plugin_name = get_class($plugin);
616 616
 
617
-			if($record_classname == null) $record_classname = $plugin::get_egw_record_class();
618
-			if(!class_exists($record_classname)) throw new Exception('Bad class name ' . $record_classname);
617
+			if ($record_classname == null) $record_classname = $plugin::get_egw_record_class();
618
+			if (!class_exists($record_classname)) throw new Exception('Bad class name '.$record_classname);
619 619
 
620
-			if(!$wizard_plugin)
620
+			if (!$wizard_plugin)
621 621
 			{
622
-				$wizard_name = $app_name . '_wizard_' . str_replace($app_name . '_', '', $plugin_name);
623
-				if(!class_exists($wizard_name)) throw new Exception('Bad wizard name ' . $wizard_name);
622
+				$wizard_name = $app_name.'_wizard_'.str_replace($app_name.'_', '', $plugin_name);
623
+				if (!class_exists($wizard_name)) throw new Exception('Bad wizard name '.$wizard_name);
624 624
 				$wizard_plugin = new $wizard_name;
625 625
 			}
626 626
 		}
@@ -632,16 +632,16 @@  discard block
 block discarded – undo
632 632
 
633 633
 		// Get field -> label map and initialize fields using wizard field order
634 634
 		$fields = $export_fields = array();
635
-		if(method_exists($wizard_plugin, 'get_export_fields'))
635
+		if (method_exists($wizard_plugin, 'get_export_fields'))
636 636
 		{
637 637
 			$fields = $export_fields = $wizard_plugin->get_export_fields();
638 638
 		}
639 639
 
640
-		foreach($record_classname::$types as $type => $type_fields)
640
+		foreach ($record_classname::$types as $type => $type_fields)
641 641
 		{
642 642
 			// Only these for now, until filter methods for others are figured out
643
-			if(!in_array($type, array('select','select-cat','select-account','date','date-time'))) continue;
644
-			foreach($type_fields as $field_name)
643
+			if (!in_array($type, array('select', 'select-cat', 'select-account', 'date', 'date-time'))) continue;
644
+			foreach ($type_fields as $field_name)
645 645
 			{
646 646
 				$fields[$field_name] = array(
647 647
 					'name' => $field_name,
@@ -652,21 +652,21 @@  discard block
 block discarded – undo
652 652
 		}
653 653
 		// Add custom fields
654 654
 		$custom = Api\Storage\Customfields::get($app_name);
655
-		foreach($custom as $field_name => $settings)
655
+		foreach ($custom as $field_name => $settings)
656 656
 		{
657 657
 			$settings['name'] = '#'.$field_name;
658 658
 			$fields['#'.$field_name] = $settings;
659 659
 		}
660 660
 
661
-		foreach($fields as $field_name => &$settings) {
661
+		foreach ($fields as $field_name => &$settings) {
662 662
 			// Can't really filter on these (or at least no generic, sane way figured out yet)
663
-			if(!is_array($settings) || in_array($settings['type'], array('text','button', 'label','url','url-email','url-phone','htmlarea')))
663
+			if (!is_array($settings) || in_array($settings['type'], array('text', 'button', 'label', 'url', 'url-email', 'url-phone', 'htmlarea')))
664 664
 			{
665 665
 				unset($fields[$field_name]);
666 666
 				continue;
667 667
 			}
668
-			if($settings['type'] == 'radio') $settings['type'] = 'select';
669
-			switch($settings['type'])
668
+			if ($settings['type'] == 'radio') $settings['type'] = 'select';
669
+			switch ($settings['type'])
670 670
 			{
671 671
 				case 'checkbox':
672 672
 					// This isn't quite right - there's only 2 options and you can select both
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 			}
690 690
 		}
691 691
 
692
-		if(method_exists($plugin, 'get_filter_fields'))
692
+		if (method_exists($plugin, 'get_filter_fields'))
693 693
 		{
694 694
 			$plugin->get_filter_fields($fields);
695 695
 		}
@@ -705,65 +705,65 @@  discard block
 block discarded – undo
705 705
 	 */
706 706
 	public static function date_rel2abs($value)
707 707
 	{
708
-		if(is_array($value))
708
+		if (is_array($value))
709 709
 		{
710 710
 			$abs = array();
711
-			foreach($value as $key => $val)
711
+			foreach ($value as $key => $val)
712 712
 			{
713 713
 				$abs[$key] = self::date_rel2abs($val);
714 714
 			}
715 715
 			return $abs;
716 716
 		}
717
-		if($date = self::$relative_dates[$value])
717
+		if ($date = self::$relative_dates[$value])
718 718
 		{
719
-			$year  = (int) date('Y');
720
-			$month = (int) date('m');
721
-			$day   = (int) date('d');
722
-			$today = mktime(0,0,0,date('m'),date('d'),date('Y'));
719
+			$year  = (int)date('Y');
720
+			$month = (int)date('m');
721
+			$day   = (int)date('d');
722
+			$today = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
723 723
 
724
-			list($syear,$smonth,$sday,$sweek,$eyear,$emonth,$eday,$eweek) = $date;
724
+			list($syear, $smonth, $sday, $sweek, $eyear, $emonth, $eday, $eweek) = $date;
725 725
 
726
-			if(stripos($value, 'quarter') !== false)
726
+			if (stripos($value, 'quarter') !== false)
727 727
 			{
728 728
 				// Handle quarters
729
-				$start = mktime(0,0,0,((int)floor(($smonth+$month) / 3.1)) * 3 + 1, 1, $year);
730
-				$end = mktime(0,0,0,((int)floor(($emonth+$month) / 3.1)+1) * 3 + 1, 1, $year);
729
+				$start = mktime(0, 0, 0, ((int)floor(($smonth + $month) / 3.1)) * 3 + 1, 1, $year);
730
+				$end = mktime(0, 0, 0, ((int)floor(($emonth + $month) / 3.1) + 1) * 3 + 1, 1, $year);
731 731
 			}
732 732
 			elseif ($syear || $eyear)
733 733
 			{
734
-				$start = mktime(0,0,0,1,1,$syear+$year);
735
-				$end   = mktime(0,0,0,1,1,$eyear+$year);
734
+				$start = mktime(0, 0, 0, 1, 1, $syear + $year);
735
+				$end   = mktime(0, 0, 0, 1, 1, $eyear + $year);
736 736
 			}
737 737
 			elseif ($smonth || $emonth)
738 738
 			{
739
-				$start = mktime(0,0,0,$smonth+$month,1,$year);
740
-				$end   = mktime(0,0,0,$emonth+$month,1,$year);
739
+				$start = mktime(0, 0, 0, $smonth + $month, 1, $year);
740
+				$end   = mktime(0, 0, 0, $emonth + $month, 1, $year);
741 741
 			}
742 742
 			elseif ($sday || $eday)
743 743
 			{
744
-				$start = mktime(0,0,0,$month,$sday+$day,$year);
745
-				$end   = mktime(0,0,0,$month,$eday+$day,$year);
744
+				$start = mktime(0, 0, 0, $month, $sday + $day, $year);
745
+				$end   = mktime(0, 0, 0, $month, $eday + $day, $year);
746 746
 			}
747 747
 			elseif ($sweek || $eweek)
748 748
 			{
749
-				$wday = (int) date('w'); // 0=sun, ..., 6=sat
750
-				switch($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'])
749
+				$wday = (int)date('w'); // 0=sun, ..., 6=sat
750
+				switch ($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'])
751 751
 				{
752 752
 					case 'Sunday':
753
-						$weekstart = $today - $wday * 24*60*60;
753
+						$weekstart = $today - $wday * 24 * 60 * 60;
754 754
 						break;
755 755
 					case 'Saturday':
756
-						$weekstart = $today - (6-$wday) * 24*60*60;
756
+						$weekstart = $today - (6 - $wday) * 24 * 60 * 60;
757 757
 						break;
758 758
 					case 'Moday':
759 759
 					default:
760
-						$weekstart = $today - ($wday ? $wday-1 : 6) * 24*60*60;
760
+						$weekstart = $today - ($wday ? $wday - 1 : 6) * 24 * 60 * 60;
761 761
 						break;
762 762
 				}
763
-				$start = $weekstart + $sweek*7*24*60*60;
764
-				$end   = $weekstart + $eweek*7*24*60*60;
763
+				$start = $weekstart + $sweek * 7 * 24 * 60 * 60;
764
+				$end   = $weekstart + $eweek * 7 * 24 * 60 * 60;
765 765
 			}
766
-			$end_param = $end - 24*60*60;
766
+			$end_param = $end - 24 * 60 * 60;
767 767
 
768 768
 			// Take 1 second off end to provide an inclusive range.for filtering
769 769
 			$end -= 1;
Please login to merge, or discard this patch.
Braces   +208 added lines, -82 removed lines patch added patch discarded remove patch
@@ -16,7 +16,8 @@  discard block
 block discarded – undo
16 16
  * class importexport_helper_functions (only static methods)
17 17
  * use importexport_helper_functions::method
18 18
  */
19
-class importexport_helper_functions {
19
+class importexport_helper_functions
20
+{
20 21
 
21 22
 	/**
22 23
 	 * Plugins are scanned and cached for all instances using this source path for given time (in seconds)
@@ -85,13 +86,19 @@  discard block
 block discarded – undo
85 86
 	 * @param string $_format format of time string e.g.: d.m.Y H:i
86 87
 	 * @param int $_is_dst is day light saving time? 0 = no, 1 = yes, -1 = system default
87 88
 	 */
88
-	public static function custom_strtotime( $_string, $_format='', $_is_dst = -1) {
89
-		if ( empty( $_format ) ) return strtotime( $_string );
89
+	public static function custom_strtotime( $_string, $_format='', $_is_dst = -1)
90
+	{
91
+		if ( empty( $_format ) )
92
+		{
93
+			return strtotime( $_string );
94
+		}
90 95
 		$fparams = explode( ',', chunk_split( $_format, 1, ',' ) );
91 96
 		$spos = 0;
92
-		foreach ( $fparams as $fparam ) {
97
+		foreach ( $fparams as $fparam )
98
+		{
93 99
 
94
-			switch ( $fparam ) {
100
+			switch ( $fparam )
101
+			{
95 102
 				case 'd': (int)$day = substr( $_string, $spos, 2 ); $spos += 2; break;
96 103
 				case 'm': (int)$mon = substr( $_string, $spos, 2 ); $spos += 2; break;
97 104
 				case 'y': (int)$year = substr( $_string, $spos, 2 ); $spos += 2; break;
@@ -111,12 +118,18 @@  discard block
 block discarded – undo
111 118
 		$timestamp = mktime($hour, $min, $sec, $mon, $day, $year, $_is_dst);
112 119
 
113 120
 		// offset given?
114
-		if ( isset( $offset ) && strlen( $offset == 5 ) ) {
121
+		if ( isset( $offset ) && strlen( $offset == 5 ) )
122
+		{
115 123
 			$operator = $offset{0};
116 124
 			$ohour = 60 * 60 * (int)substr( $offset, 1, 2 );
117 125
 			$omin = 60 * (int)substr( $offset, 3, 2 );
118
-			if ( $operator == '+' ) $timestamp += $ohour + $omin;
119
-			else $timestamp -= $ohour + $omin;
126
+			if ( $operator == '+' )
127
+			{
128
+				$timestamp += $ohour + $omin;
129
+			}
130
+			else {
131
+				$timestamp -= $ohour + $omin;
132
+			}
120 133
 		}
121 134
 		return $timestamp;
122 135
 	}
@@ -126,11 +139,14 @@  discard block
 block discarded – undo
126 139
 	 * @param mixed $_account_lid comma seperated list or array with lids
127 140
 	 * @return mixed comma seperated list or array with ids
128 141
 	 */
129
-	public static function account_name2id( &$_account_lids ) {
142
+	public static function account_name2id( &$_account_lids )
143
+	{
130 144
 		$account_lids = is_array( $_account_lids ) ? $_account_lids : explode( ',', $_account_lids );
131 145
 		$skip = false;
132
-		foreach ( $account_lids as $key => $account_lid ) {
133
-			if($skip) {
146
+		foreach ( $account_lids as $key => $account_lid )
147
+		{
148
+			if($skip)
149
+			{
134 150
 				unset($account_lids[$key]);
135 151
 				$skip = false;
136 152
 				continue;
@@ -138,7 +154,8 @@  discard block
 block discarded – undo
138 154
 			$account_lid = trim($account_lid);
139 155
 
140 156
 			// Handle any IDs that slip in
141
-			if(is_numeric($account_lid) && $GLOBALS['egw']->accounts->id2name($account_lid)) {
157
+			if(is_numeric($account_lid) && $GLOBALS['egw']->accounts->id2name($account_lid))
158
+			{
142 159
 				unset($account_lids[$key]);
143 160
 				$account_ids[] = (int)$account_lid;
144 161
 				continue;
@@ -183,19 +200,22 @@  discard block
 block discarded – undo
183 200
 				$account_lid = trim(substr(trim($account_lid), strlen(lang('Group'))));
184 201
 			}
185 202
 
186
-			if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid )) {
203
+			if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid ))
204
+			{
187 205
 				$account_ids[] = $account_id;
188 206
 				unset($account_lids[$key]);
189 207
 				continue;
190 208
 			}
191
-			if ( $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lid), 'account_fullname' )) {
209
+			if ( $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lid), 'account_fullname' ))
210
+			{
192 211
 				$account_ids[] = $account_id;
193 212
 				unset($account_lids[$key]);
194 213
 				continue;
195 214
 			}
196 215
 
197 216
 			// Handle groups listed as Group, <name>
198
-			if ( $account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid)) {
217
+			if ( $account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid))
218
+			{
199 219
 				$account_ids[] = $account_id;
200 220
 				unset($account_lids[$key-1]);
201 221
 				unset($account_lids[$key]);
@@ -219,10 +239,13 @@  discard block
 block discarded – undo
219 239
 	 * @param mixed $_account_ids comma seperated list or array with ids
220 240
 	 * @return mixed comma seperated list or array with lids
221 241
 	 */
222
-	public static function account_id2name( $_account_id ) {
242
+	public static function account_id2name( $_account_id )
243
+	{
223 244
 		$account_ids = is_array( $_account_id ) ? $_account_id : explode( ',', $_account_id );
224
-		foreach ( $account_ids as $account_id ) {
225
-			if ( $account_lid = $GLOBALS['egw']->accounts->id2name( $account_id )) {
245
+		foreach ( $account_ids as $account_id )
246
+		{
247
+			if ( $account_lid = $GLOBALS['egw']->accounts->id2name( $account_id ))
248
+			{
226 249
 				$account_lids[] = $account_lid;
227 250
 			}
228 251
 		}
@@ -235,9 +258,11 @@  discard block
 block discarded – undo
235 258
 	 * @param mixed _cat_ids comma seperated list or array
236 259
 	 * @return mixed comma seperated list or array with cat_names
237 260
 	 */
238
-	public static function cat_id2name( $_cat_ids ) {
261
+	public static function cat_id2name( $_cat_ids )
262
+	{
239 263
 		$cat_ids = is_array( $_cat_ids ) ? $_cat_ids : explode( ',', $_cat_ids );
240
-		foreach ( $cat_ids as $cat_id ) {
264
+		foreach ( $cat_ids as $cat_id )
265
+		{
241 266
 			$cat_names[] = Api\Categories::id2name( (int)$cat_id );
242 267
 		}
243 268
 		return is_array( $_cat_ids ) ? $cat_names : implode(',',(array)$cat_names);
@@ -251,14 +276,20 @@  discard block
 block discarded – undo
251 276
 	 * @param int $parent Optional parent ID to use for new categories
252 277
 	 * @return mixed comma seperated list or array with cat_ids
253 278
 	 */
254
-	public static function cat_name2id( $_cat_names, $parent = 0 ) {
279
+	public static function cat_name2id( $_cat_names, $parent = 0 )
280
+	{
255 281
 		$cats = new Api\Categories();	// uses current user and app (egw_info[flags][currentapp])
256 282
 
257 283
 		$cat_names = is_array( $_cat_names ) ? $_cat_names : explode( ',', $_cat_names );
258
-		foreach ( $cat_names as $cat_name ) {
284
+		foreach ( $cat_names as $cat_name )
285
+		{
259 286
 			$cat_name = trim($cat_name);
260
-			if ( $cat_name == '' ) continue;
261
-			if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 && !self::$dry_run) {
287
+			if ( $cat_name == '' )
288
+			{
289
+				continue;
290
+			}
291
+			if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 && !self::$dry_run)
292
+			{
262 293
 				$cat_id = $cats->add( array(
263 294
 					'name' => $cat_name,
264 295
 					'parent' => $parent,
@@ -307,8 +338,12 @@  discard block
 block discarded – undo
307 338
 	 * @param object &$cclass calling class to process the '@ evals'
308 339
 	 * @return bool
309 340
 	 */
310
-	public static function conversion( &$_record,  $_conversion, &$_cclass = null ) {
311
-		if (empty( $_conversion ) ) return $_record;
341
+	public static function conversion( &$_record,  $_conversion, &$_cclass = null )
342
+	{
343
+		if (empty( $_conversion ) )
344
+		{
345
+			return $_record;
346
+		}
312 347
 
313 348
 		self::$cclass =& $_cclass;
314 349
 
@@ -320,15 +355,21 @@  discard block
 block discarded – undo
320 355
 		$CntlnCLPre  = '|TCnCL{';   // Like |C{ but allowes CR and LF
321 356
 		$INE = '|INE{';             // Only insert if stuff in ^^ is not empty
322 357
 
323
-		foreach ( $_conversion as $idx => $conversion_string ) {
324
-			if ( empty( $conversion_string ) ) continue;
358
+		foreach ( $_conversion as $idx => $conversion_string )
359
+		{
360
+			if ( empty( $conversion_string ) )
361
+			{
362
+				continue;
363
+			}
325 364
 
326 365
 			// fetch patterns ($rvalues)
327 366
 			$rvalues = array();
328 367
 			$pat_reps = explode( $PSep, stripslashes( $conversion_string ) );
329
-			foreach( $pat_reps as $k => $pat_rep ) {
368
+			foreach( $pat_reps as $k => $pat_rep )
369
+			{
330 370
 				list( $pattern, $replace ) = explode( $ASep, $pat_rep, 2 );
331
-				if( $replace == '' ) {
371
+				if( $replace == '' )
372
+				{
332 373
 					$replace = $pattern; $pattern = '^.*$';
333 374
 				}
334 375
 				$rvalues[$pattern] = $replace;	// replace two with only one, added by the form
@@ -338,19 +379,23 @@  discard block
 block discarded – undo
338 379
 			$val = array_key_exists( $idx, $_record ) ? $_record[$idx] : '';
339 380
 
340 381
 			$c_functions = array('cat', 'account', 'strtotime', 'list');
341
-			if($_cclass) {
382
+			if($_cclass)
383
+			{
342 384
 				// Add in additional methods
343 385
 				$reflection = new ReflectionClass(get_class($_cclass));
344 386
 				$methods = $reflection->getMethods(ReflectionMethod::IS_STATIC);
345
-				foreach($methods as $method) {
387
+				foreach($methods as $method)
388
+				{
346 389
 					$c_functions[] = $method->name;
347 390
 				}
348 391
 			}
349 392
 			$c_functions = implode('|', $c_functions);
350
-			foreach ( $rvalues as $pattern => $replace ) {
393
+			foreach ( $rvalues as $pattern => $replace )
394
+			{
351 395
 				// Allow to include record indexes in pattern
352 396
 				$reg = '/\|\[([0-9]+)\]/';
353
-				while( preg_match( $reg, $pattern, $vars ) ) {
397
+				while( preg_match( $reg, $pattern, $vars ) )
398
+				{
354 399
 					// expand all _record fields
355 400
 					$pattern = str_replace(
356 401
 						$CPre . $vars[1] . $CPos,
@@ -358,12 +403,14 @@  discard block
 block discarded – undo
358 403
 						$pattern
359 404
 					);
360 405
 				}
361
-				if( preg_match('/'. (string)$pattern.'/', $val) ) {
406
+				if( preg_match('/'. (string)$pattern.'/', $val) )
407
+				{
362 408
 
363 409
 					$val = preg_replace( '/'.(string)$pattern.'/', $replace, (string)$val );
364 410
 
365 411
 					$reg = '/\|\[([a-zA-Z_0-9]+)\]/';
366
-					while( preg_match( $reg, $val, $vars ) ) {
412
+					while( preg_match( $reg, $val, $vars ) )
413
+					{
367 414
 						// expand all _record fields
368 415
 						$val = str_replace(
369 416
 							$CPre . $vars[1] . $CPos,
@@ -390,11 +437,13 @@  discard block
 block discarded – undo
390 437
 	 *
391 438
 	 * @param array $_matches
392 439
 	 */
393
-	private static function c2_dispatcher( $_matches ) {
440
+	private static function c2_dispatcher( $_matches )
441
+	{
394 442
 		$action = &$_matches[1]; // cat or account ...
395 443
 		$data = &$_matches[2];   // datas for action
396 444
 
397
-		switch ( $action ) {
445
+		switch ( $action )
446
+		{
398 447
 			case 'strtotime' :
399 448
 				list( $string, $format ) = explode( ',', $data );
400 449
 				return self::custom_strtotime( trim( $string ), trim( $format ) );
@@ -404,22 +453,28 @@  discard block
 block discarded – undo
404 453
 				// 1 based indexing for user ease
405 454
 				return $exploded[$index - 1];
406 455
 			default :
407
-				if(self::$cclass && method_exists(self::$cclass, $action)) {
456
+				if(self::$cclass && method_exists(self::$cclass, $action))
457
+				{
408 458
 					$class = get_class(self::$cclass);
409 459
 					return call_user_func("$class::$action", $data);
410 460
 				}
411 461
 				$method = (string)$action. ( is_int( $data ) ? '_id2name' : '_name2id' );
412
-				if(self::$cclass && method_exists(self::$cclass, $method)) {
462
+				if(self::$cclass && method_exists(self::$cclass, $method))
463
+				{
413 464
 					$class = get_class(self::$cclass);
414 465
 					return call_user_func("$class::$action", $data);
415
-				} else {
466
+				}
467
+				else
468
+				{
416 469
 					return self::$method( $data );
417 470
 				}
418 471
 		}
419 472
 	}
420 473
 
421
-	private static function strclean( $_matches ) {
422
-		switch( $_matches[1] ) {
474
+	private static function strclean( $_matches )
475
+	{
476
+		switch( $_matches[1] )
477
+		{
423 478
 			case '|T{' : return trim( $_matches[2] );
424 479
 			case '|TC{' : return trim( preg_replace( '/[\x01-\x1F]+/', '', $_matches[2] ) );
425 480
 			case '|TCnCL{' : return trim( preg_replace( '/[\x01-\x09\x11\x12\x14-\x1F]+/', '', $_matches[2] ) );
@@ -436,7 +491,8 @@  discard block
 block discarded – undo
436 491
 	 * @param string $_appname {<appname> | all}
437 492
 	 * @return array(<appname> => array( <type> => array(<plugin> => <title>)))
438 493
 	 */
439
-	public static function get_plugins( $_appname = 'all', $_type = 'all' ) {
494
+	public static function get_plugins( $_appname = 'all', $_type = 'all' )
495
+	{
440 496
 		$plugins = Api\Cache::getTree(
441 497
 			__CLASS__,
442 498
 			'plugins',
@@ -449,38 +505,63 @@  discard block
 block discarded – undo
449 505
 
450 506
 		// Testing: comment out Api\Cache call, use this
451 507
 		//$plugins = self::_get_plugins($appnames, $types);
452
-		foreach($plugins as $appname => $_types) {
453
-			if(!in_array($appname, $appnames)) unset($plugins[$appname]);
508
+		foreach($plugins as $appname => $_types)
509
+		{
510
+			if(!in_array($appname, $appnames))
511
+			{
512
+				unset($plugins[$appname]);
513
+			}
454 514
 		}
455
-		foreach($plugins as $appname => $types) {
515
+		foreach($plugins as $appname => $types)
516
+		{
456 517
 			$plugins[$appname] = array_intersect_key($plugins[$appname], $types);
457 518
 		}
458 519
 		return $plugins;
459 520
 	}
460 521
 
461
-	public static function _get_plugins(Array $appnames, Array $types) {
522
+	public static function _get_plugins(Array $appnames, Array $types)
523
+	{
462 524
 		$plugins = array();
463
-		foreach ($appnames as $appname) {
464
-			if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue;
525
+		foreach ($appnames as $appname)
526
+		{
527
+			if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true)
528
+			{
529
+				continue;
530
+			}
465 531
 
466 532
 			$appdir = EGW_INCLUDE_ROOT. "/$appname/inc";
467
-			if(!is_dir($appdir)) continue;
533
+			if(!is_dir($appdir))
534
+			{
535
+				continue;
536
+			}
468 537
 			$d = dir($appdir);
469 538
 
470 539
 			// step through each file in appdir
471
-			while (false !== ($entry = $d->read())) {
540
+			while (false !== ($entry = $d->read()))
541
+			{
472 542
 				// Blacklisted?
473
-				if(is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname]))  continue;
474
-				if (!preg_match('/^class\.([^.]+)\.inc\.php$/', $entry, $matches)) continue;
543
+				if(is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname]))
544
+				{
545
+					continue;
546
+				}
547
+				if (!preg_match('/^class\.([^.]+)\.inc\.php$/', $entry, $matches))
548
+				{
549
+					continue;
550
+				}
475 551
 				$classname = $matches[1];
476 552
 				$file = $appdir. '/'. $entry;
477 553
 
478
-				foreach ($types as $type) {
479
-					if( !is_file($file) || strpos($entry, $type) === false || strpos($entry,'wizard') !== false) continue;
554
+				foreach ($types as $type)
555
+				{
556
+					if( !is_file($file) || strpos($entry, $type) === false || strpos($entry,'wizard') !== false)
557
+					{
558
+						continue;
559
+					}
480 560
 					require_once($file);
481 561
 					$reflectionClass = new ReflectionClass($classname);
482 562
 					if($reflectionClass->IsInstantiable() &&
483
-							$reflectionClass->implementsInterface('importexport_iface_'.$type.'_plugin')) {
563
+							$reflectionClass->implementsInterface('importexport_iface_'.$type.'_plugin'))
564
+					{
484 565
 						try {
485 566
 							$plugin_object = new $classname;
486 567
 						}
@@ -495,7 +576,8 @@  discard block
 block discarded – undo
495 576
 			$d->close();
496 577
 
497 578
 			$config = Api\Config::read('importexport');
498
-			if($config['update'] == 'auto') {
579
+			if($config['update'] == 'auto')
580
+			{
499 581
 				self::load_defaults($appname);
500 582
 			}
501 583
 		}
@@ -509,38 +591,56 @@  discard block
 block discarded – undo
509 591
 	 * @param string $_type
510 592
 	 * @return array $num => $appname
511 593
 	 */
512
-	public static function get_apps($_type, $ignore_acl = false) {
594
+	public static function get_apps($_type, $ignore_acl = false)
595
+	{
513 596
 		$apps = array_keys(self::get_plugins('all',$_type));
514
-		if($ignore_acl) return $apps;
597
+		if($ignore_acl)
598
+		{
599
+			return $apps;
600
+		}
515 601
 
516
-		foreach($apps as $key => $app) {
517
-			if(!self::has_definitions($app, $_type)) unset($apps[$key]);
602
+		foreach($apps as $key => $app)
603
+		{
604
+			if(!self::has_definitions($app, $_type))
605
+			{
606
+				unset($apps[$key]);
607
+			}
518 608
 		}
519 609
 		return $apps;
520 610
 	}
521 611
 
522
-	public static function load_defaults($appname) {
612
+	public static function load_defaults($appname)
613
+	{
523 614
 		// Check for new definitions to import from $appname/setup/*.xml
524 615
 		$appdir = EGW_INCLUDE_ROOT. "/$appname/setup";
525
-		if(!is_dir($appdir)) return;
616
+		if(!is_dir($appdir))
617
+		{
618
+			return;
619
+		}
526 620
 		$d = dir($appdir);
527 621
 
528 622
 		// step through each file in app's setup
529
-		while (false !== ($entry = $d->read())) {
623
+		while (false !== ($entry = $d->read()))
624
+		{
530 625
 			$file = $appdir. '/'. $entry;
531 626
 			list( $filename, $extension) = explode('.',$entry);
532
-			if ( $extension != 'xml' ) continue;
627
+			if ( $extension != 'xml' )
628
+			{
629
+				continue;
630
+			}
533 631
 			try {
534 632
 				// import will skip invalid files
535 633
 				importexport_definitions_bo::import( $file );
536
-			} catch (Exception $e) {
634
+			}
635
+			catch (Exception $e) {
537 636
 				error_log(__CLASS__.__FUNCTION__. " import $appname definitions: " . $e->getMessage());
538 637
 			}
539 638
 		}
540 639
 		$d->close();
541 640
 	}
542 641
 
543
-	public static function guess_filetype( $_file ) {
642
+	public static function guess_filetype( $_file )
643
+	{
544 644
 
545 645
 	}
546 646
 
@@ -551,7 +651,8 @@  discard block
 block discarded – undo
551 651
 	 * @param string $_type {import | export | all}
552 652
 	 * @return boolean
553 653
 	 */
554
-	public static function has_definitions( $_appname = 'all', $_type = 'all' ) {
654
+	public static function has_definitions( $_appname = 'all', $_type = 'all' )
655
+	{
555 656
 		$definitions = Api\Cache::getSession(
556 657
 			__CLASS__,
557 658
 			'has_definitions',
@@ -565,27 +666,36 @@  discard block
 block discarded – undo
565 666
 		// Testing: Comment out cache call above, use this
566 667
 		//$definitions = self::_has_definitions($appnames, $types);
567 668
 
568
-		foreach($definitions as $appname => $_types) {
569
-			if(!in_array($appname, $appnames)) unset($definitions[$appname]);
669
+		foreach($definitions as $appname => $_types)
670
+		{
671
+			if(!in_array($appname, $appnames))
672
+			{
673
+				unset($definitions[$appname]);
674
+			}
570 675
 		}
571
-		foreach($definitions as $appname => $_types) {
676
+		foreach($definitions as $appname => $_types)
677
+		{
572 678
 			$definitions[$appname] = array_intersect_key($definitions[$appname], array_flip($types));
573 679
 		}
574 680
 		return !empty($definitions[$appname]);
575 681
 	}
576 682
 
577 683
 	// Api\Cache needs this public
578
-	public static function _has_definitions(Array $appnames, Array $types) {
684
+	public static function _has_definitions(Array $appnames, Array $types)
685
+	{
579 686
 		$def = new importexport_definitions_bo(array('application'=>$appnames, 'type' => $types));
580 687
 		$list = array();
581
-		foreach((array)$def->get_definitions() as $id) {
688
+		foreach((array)$def->get_definitions() as $id)
689
+		{
582 690
 			// Need to instanciate it to check, but if the user doesn't have permission, it throws an exception
583 691
 			try {
584 692
 				$definition = new importexport_definition($id);
585
-				if($def->is_permitted($definition->get_record_array())) {
693
+				if($def->is_permitted($definition->get_record_array()))
694
+				{
586 695
 					$list[$definition->application][$definition->type][] = $id;
587 696
 				}
588
-			} catch (Exception $e) {
697
+			}
698
+			catch (Exception $e) {
589 699
 				// That one doesn't work, keep going
590 700
 			}
591 701
 			$definition = null;
@@ -614,13 +724,22 @@  discard block
 block discarded – undo
614 724
 			$plugin = is_object($plugin_name) ? $plugin_name : new $plugin_name();
615 725
 			$plugin_name = get_class($plugin);
616 726
 
617
-			if($record_classname == null) $record_classname = $plugin::get_egw_record_class();
618
-			if(!class_exists($record_classname)) throw new Exception('Bad class name ' . $record_classname);
727
+			if($record_classname == null)
728
+			{
729
+				$record_classname = $plugin::get_egw_record_class();
730
+			}
731
+			if(!class_exists($record_classname))
732
+			{
733
+				throw new Exception('Bad class name ' . $record_classname);
734
+			}
619 735
 
620 736
 			if(!$wizard_plugin)
621 737
 			{
622 738
 				$wizard_name = $app_name . '_wizard_' . str_replace($app_name . '_', '', $plugin_name);
623
-				if(!class_exists($wizard_name)) throw new Exception('Bad wizard name ' . $wizard_name);
739
+				if(!class_exists($wizard_name))
740
+				{
741
+					throw new Exception('Bad wizard name ' . $wizard_name);
742
+				}
624 743
 				$wizard_plugin = new $wizard_name;
625 744
 			}
626 745
 		}
@@ -640,7 +759,10 @@  discard block
 block discarded – undo
640 759
 		foreach($record_classname::$types as $type => $type_fields)
641 760
 		{
642 761
 			// Only these for now, until filter methods for others are figured out
643
-			if(!in_array($type, array('select','select-cat','select-account','date','date-time'))) continue;
762
+			if(!in_array($type, array('select','select-cat','select-account','date','date-time')))
763
+			{
764
+				continue;
765
+			}
644 766
 			foreach($type_fields as $field_name)
645 767
 			{
646 768
 				$fields[$field_name] = array(
@@ -658,14 +780,18 @@  discard block
 block discarded – undo
658 780
 			$fields['#'.$field_name] = $settings;
659 781
 		}
660 782
 
661
-		foreach($fields as $field_name => &$settings) {
783
+		foreach($fields as $field_name => &$settings)
784
+		{
662 785
 			// Can't really filter on these (or at least no generic, sane way figured out yet)
663 786
 			if(!is_array($settings) || in_array($settings['type'], array('text','button', 'label','url','url-email','url-phone','htmlarea')))
664 787
 			{
665 788
 				unset($fields[$field_name]);
666 789
 				continue;
667 790
 			}
668
-			if($settings['type'] == 'radio') $settings['type'] = 'select';
791
+			if($settings['type'] == 'radio')
792
+			{
793
+				$settings['type'] = 'select';
794
+			}
669 795
 			switch($settings['type'])
670 796
 			{
671 797
 				case 'checkbox':
Please login to merge, or discard this patch.
importexport/inc/class.importexport_iface_egw_record.inc.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -35,6 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * reads record from backend if identifier is given.
36 36
 	 *
37 37
 	 * @param string $_identifier
38
+	 * @return void
38 39
 	 */
39 40
 	public function __construct( $_identifier='' );
40 41
 	
@@ -50,6 +51,7 @@  discard block
 block discarded – undo
50 51
 	 *
51 52
 	 * @param string $_attribute_name
52 53
 	 * @param data $data
54
+	 * @return void
53 55
 	 */
54 56
 	public function __set($_attribute_name, $data);
55 57
 	
@@ -126,6 +128,7 @@  discard block
 block discarded – undo
126 128
 	/**
127 129
 	 * destructor
128 130
 	 *
131
+	 * @return void
129 132
 	 */
130 133
 	public function __destruct();
131 134
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @param string $_identifier
38 38
 	 */
39
-	public function __construct( $_identifier='' );
39
+	public function __construct($_identifier = '');
40 40
 	
41 41
 	/**
42 42
 	 * magic method to set attributes of record
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @return string identifier
99 99
 	 */
100
-	public function save ( $_dst_identifier );
100
+	public function save($_dst_identifier);
101 101
 	
102 102
 	/**
103 103
 	 * copys current record to record identified by $_dst_identifier
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 * @param string $_dst_identifier
106 106
 	 * @return string dst_identifier
107 107
 	 */
108
-	public function copy ( $_dst_identifier );
108
+	public function copy($_dst_identifier);
109 109
 	
110 110
 	/**
111 111
 	 * moves current record to record identified by $_dst_identifier
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
 	 * @param string $_dst_identifier
115 115
 	 * @return string dst_identifier
116 116
 	 */
117
-	public function move ( $_dst_identifier );
117
+	public function move($_dst_identifier);
118 118
 	
119 119
 	/**
120 120
 	 * delets current record from backend
121 121
 	 * @return void
122 122
 	 *
123 123
 	 */
124
-	public function delete ();
124
+	public function delete();
125 125
 	
126 126
 	/**
127 127
 	 * destructor
Please login to merge, or discard this patch.
importexport/inc/class.importexport_iface_export_record.inc.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
 	 * destructor
55 55
 	 *
56 56
 	 * @return 
57
-	 */
57
+	 void
58 58
 	public function __destruct( );
59 59
 
60 60
 } // end of iface_export_record
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 * @param array $_options options for specific backends
34 34
 	 * @return bool
35 35
 	 */
36
-	public function __construct( $_stream, array $_options );
36
+	public function __construct($_stream, array $_options);
37 37
 	
38 38
 	/**
39 39
 	 * exports a record into resource of handle
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 * @param object of interface egw_record _record
42 42
 	 * @return bool
43 43
 	 */
44
-	public function export_record( importexport_iface_egw_record $_record );
44
+	public function export_record(importexport_iface_egw_record $_record);
45 45
 
46 46
 	/**
47 47
 	 * Retruns total number of exported records.
Please login to merge, or discard this patch.
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.
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.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 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
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 * 		preserv		=> array,
80 80
 	 * )
81 81
 	 */
82
-	public function get_options_etpl(importexport_definition &$definition=null);
82
+	public function get_options_etpl(importexport_definition &$definition = null);
83 83
 
84 84
 	/**
85 85
 	 * returns etemplate name for slectors of this plugin
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.
Spacing   +80 added lines, -80 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,29 +52,29 @@  discard block
 block discarded – undo
52 52
 			$template = new Etemplate('importexport.import_dialog');
53 53
 			$preserve = array();
54 54
 
55
-			if($definition)
55
+			if ($definition)
56 56
 			{
57 57
 				$definition_obj = new importexport_definition($content['definition']);
58 58
 			}
59 59
 
60 60
 			// Load application's translations
61
-			if($appname)
61
+			if ($appname)
62 62
 			{
63 63
 				Api\Translation::add_app($appname);
64 64
 			}
65
-			if($content['import'] && $definition) {
65
+			if ($content['import'] && $definition) {
66 66
 				try {
67
-					if($content['dry-run']) {
67
+					if ($content['dry-run']) {
68 68
 						// Set this so plugin doesn't do any data changes
69 69
 						$definition_obj->plugin_options = (array)$definition_obj->plugin_options + array('dry_run' => true);
70 70
 					}
71
-					$options =& $definition_obj->plugin_options;
71
+					$options = & $definition_obj->plugin_options;
72 72
 					$options['no_notification'] = $content['no_notifications'];
73
-					if($content['delimiter']) {
73
+					if ($content['delimiter']) {
74 74
 						$options['fieldsep'] =
75 75
 							$content['delimiter'] == 'other' ? $content['other_delimiter'] : $content['delimiter'];
76 76
 					}
77
-					$options = array_merge($options, array_diff_key($content, array_flip(array('dry-run','file','import'))));
77
+					$options = array_merge($options, array_diff_key($content, array_flip(array('dry-run', 'file', 'import'))));
78 78
 					$definition_obj->plugin_options = $options;
79 79
 
80 80
 					$plugin = new $definition_obj->plugin;
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 					// Check file encoding matches import
83 83
 					$sample = mb_substr(file_get_contents($content['file']['tmp_name'], false, null, 0, 2048), 1024);
84 84
 
85
-					if($appname == 'addressbook' && $definition_obj->plugin == 'addressbook_import_vcard')
85
+					if ($appname == 'addressbook' && $definition_obj->plugin == 'addressbook_import_vcard')
86 86
 					{
87 87
 						$preference = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset'];
88 88
 					}
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 					}
93 93
 					$required = $options['charset'] == 'user' || !$options['charset'] ? $preference : $options['charset'];
94 94
 					$encoding = Api\Translation::detect_encoding($sample, $required);
95
-					if($encoding && strtoupper($required) != strtoupper($encoding))
95
+					if ($encoding && strtoupper($required) != strtoupper($encoding))
96 96
 					{
97 97
 						$this->message = lang("Encoding mismatch.  Expected %1 file, you uploaded %2.<br />\n",
98 98
 							$required,
@@ -107,37 +107,37 @@  discard block
 block discarded – undo
107 107
 					$GLOBALS['egw_info']['flags']['currentapp'] = $appname;
108 108
 
109 109
 					// Destination if we need to hold the file
110
-					if($file)
110
+					if ($file)
111 111
 					{
112 112
 						$cachefile = new Api\Cache\Files(array());
113 113
 						$dst_file = $cachefile->filename(Api\Cache::keys(Api\Cache::INSTANCE, 'importexport',
114
-							'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id']), true),true);
114
+							'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id']), true), true);
115 115
 						// Keep file
116
-						if($dst_file)
116
+						if ($dst_file)
117 117
 						{
118
-							if($content['file']['name'] && copy($content['file']['tmp_name'],$dst_file)) {
118
+							if ($content['file']['name'] && copy($content['file']['tmp_name'], $dst_file)) {
119 119
 								$preserve['file']['tmp_name'] = $dst_file;
120 120
 							}
121 121
 						}
122 122
 
123 123
 						// Check on matching columns
124 124
 						$check_message = array();
125
-						if(!self::check_file($file, $definition_obj, $check_message, $dst_file))
125
+						if (!self::check_file($file, $definition_obj, $check_message, $dst_file))
126 126
 						{
127 127
 							// Set this so plugin doesn't do any data changes
128 128
 							$content['dry-run'] = true;
129 129
 							importexport_helper_functions::$dry_run = true;
130
-							$this->message .= '<b>' . lang('Import aborted').":</b><br />\n";
130
+							$this->message .= '<b>'.lang('Import aborted').":</b><br />\n";
131 131
 							$definition_obj->plugin_options = (array)$definition_obj->plugin_options + array('dry_run' => true);
132 132
 						}
133
-						if(count($check_message))
133
+						if (count($check_message))
134 134
 						{
135
-							$this->message .= implode($check_message, "<br />\n") . "<br />\n";
135
+							$this->message .= implode($check_message, "<br />\n")."<br />\n";
136 136
 						}
137
-						if($content['dry-run'])
137
+						if ($content['dry-run'])
138 138
 						{
139 139
 							$preview = $this->preview($plugin, $file, $definition_obj);
140
-							if(trim($this->message) == '')
140
+							if (trim($this->message) == '')
141 141
 							{
142 142
 								// Clear first, to prevent request from being collected if the result is the same
143 143
 								$template->setElementAttribute('preview', 'value', '');
@@ -156,34 +156,34 @@  discard block
 block discarded – undo
156 156
 						$this->message .= lang('please select file to import'."<br />\n");
157 157
 					}
158 158
 
159
-					if($content['dry-run'])
159
+					if ($content['dry-run'])
160 160
 					{
161
-						$this->message .= '<b>' . lang('test only').":</b><br />\n";
161
+						$this->message .= '<b>'.lang('test only').":</b><br />\n";
162 162
 					}
163 163
 					$this->message .= lang('%1 records processed', $count);
164 164
 
165 165
 					// Refresh opening window
166
-					if(!$content['dry-run'])
166
+					if (!$content['dry-run'])
167 167
 					{
168
-						Framework::refresh_opener(lang('%1 records processed',$count), $appname, null,null,$appname);
168
+						Framework::refresh_opener(lang('%1 records processed', $count), $appname, null, null, $appname);
169 169
 					}
170 170
 					$total_processed = 0;
171
-					foreach($plugin->get_results() as $action => $a_count) {
172
-						$this->message .= "<br />\n" . lang($action) . ": $a_count";
171
+					foreach ($plugin->get_results() as $action => $a_count) {
172
+						$this->message .= "<br />\n".lang($action).": $a_count";
173 173
 						$total_processed += $a_count;
174 174
 					}
175
-					if(count($plugin->get_warnings())) {
175
+					if (count($plugin->get_warnings())) {
176 176
 						$this->message .= "<br />\n".lang('Warnings').':';
177
-						foreach($plugin->get_warnings() as $record => $message) {
177
+						foreach ($plugin->get_warnings() as $record => $message) {
178 178
 							$this->message .= "<br />\n$record: $message";
179 179
 						}
180 180
 					}
181
-					if(count($plugin->get_errors())) {
181
+					if (count($plugin->get_errors())) {
182 182
 						$this->message .= "<br />\n".lang('Problems during import:');
183
-						foreach($plugin->get_errors() as $record => $message) {
183
+						foreach ($plugin->get_errors() as $record => $message) {
184 184
 							$this->message .= "<br />\n$record: $message";
185 185
 						}
186
-						if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported');
186
+						if ($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported');
187 187
 					}
188 188
 					if ($dst_file && $content['file']['tmp_name'] == $dst_file) {
189 189
 						// Remove file
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 					$this->message .= $e->getMessage();
199 199
 				}
200 200
 			}
201
-			elseif($content['cancel'])
201
+			elseif ($content['cancel'])
202 202
 			{
203 203
 				egw_framework::set_onload('window.close();');
204 204
 			}
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 				);
212 212
 			}
213 213
 
214
-			if(!array_key_exists('dry-run',$content))
214
+			if (!array_key_exists('dry-run', $content))
215 215
 			{
216 216
 				$data['dry-run'] = true;
217 217
 			}
@@ -219,20 +219,20 @@  discard block
 block discarded – undo
219 219
 			$data['appname'] = $preserve['appname'] = $appname ? $appname : ($definition_obj ? $definition_obj->application : '');
220 220
 			$data['definition'] = $definition;
221 221
 			$data['delimiter'] = $definition_obj->plugin_options['delimiter'];
222
-			$data['no_notifications'] = true;	// switch notifications off by default
222
+			$data['no_notifications'] = true; // switch notifications off by default
223 223
 
224 224
 			$sel_options = self::get_select_options($data);
225 225
 			$readonlys = array();
226 226
 
227
-			if(!$definition_obj && $sel_options['definition'] && !$data['definition'])
227
+			if (!$definition_obj && $sel_options['definition'] && !$data['definition'])
228 228
 			{
229 229
 				$definition_obj = new importexport_definition(key($sel_options['definition']));
230 230
 			}
231
-			if($definition_obj)
231
+			if ($definition_obj)
232 232
 			{
233 233
 				$plugin = new $definition_obj->plugin;
234 234
 				$options = $plugin->get_options_etpl($definition_obj);
235
-				if(is_array($options))
235
+				if (is_array($options))
236 236
 				{
237 237
 					$data['plugin_options_template'] = $options['name'];
238 238
 					$data += (array)$options['content'];
@@ -249,9 +249,9 @@  discard block
 block discarded – undo
249 249
 			}
250 250
 
251 251
 			$data['message'] = $this->message;
252
-			Framework::includeJS('.','importexport','importexport');
252
+			Framework::includeJS('.', 'importexport', 'importexport');
253 253
 
254
-			if($_GET['appname']) $readonlys['appname'] = true;
254
+			if ($_GET['appname']) $readonlys['appname'] = true;
255 255
 
256 256
 			$template->exec('importexport.importexport_import_ui.import_dialog', $data, $sel_options, $readonlys, $preserve, 2);
257 257
 		}
@@ -273,12 +273,12 @@  discard block
 block discarded – undo
273 273
 			);
274 274
 
275 275
 			(array)$apps = importexport_helper_functions::get_apps('import');
276
-			$options['appname'] = array('' => lang('Select one')) + array_combine($apps,$apps);
276
+			$options['appname'] = array('' => lang('Select one')) + array_combine($apps, $apps);
277 277
 
278
-			if($data['appname']) {
278
+			if ($data['appname']) {
279 279
 				$options['definition'] = array();
280 280
 
281
-				if($data['file'] && !is_array($data['file'])) {
281
+				if ($data['file'] && !is_array($data['file'])) {
282 282
 					$extension = substr($data['file'], -3);
283 283
 				}
284 284
 				$definitions = new importexport_definitions_bo(array(
@@ -318,26 +318,26 @@  discard block
 block discarded – undo
318 318
 		 */
319 319
 		protected function preview(importexport_iface_import_plugin &$plugin, &$stream, importexport_definition &$definition_obj)
320 320
 		{
321
-			if(method_exists($plugin, 'preview'))
321
+			if (method_exists($plugin, 'preview'))
322 322
 			{
323 323
 				$preview = $plugin->preview($stream, $definition_obj);
324 324
 			}
325
-			elseif($definition_obj->plugin_options['csv_fields'])
325
+			elseif ($definition_obj->plugin_options['csv_fields'])
326 326
 			{
327
-				$import_csv = new importexport_import_csv( $stream, array(
327
+				$import_csv = new importexport_import_csv($stream, array(
328 328
 					'fieldsep' => $definition_obj->plugin_options['fieldsep'],
329 329
 					'charset' => $definition_obj->plugin_options['charset'],
330 330
 				));
331 331
 				// set FieldMapping.
332 332
 				$import_csv->mapping = $definition_obj->plugin_options['field_mapping'];
333 333
 
334
-				$rows = array('h1'=>array(),'f1'=>array(),'.h1'=>'class=th');
335
-				for($row = 0; $row < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; $row++)
334
+				$rows = array('h1'=>array(), 'f1'=>array(), '.h1'=>'class=th');
335
+				for ($row = 0; $row < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; $row++)
336 336
 				{
337 337
 					$row_data = $import_csv->get_record();
338
-					if($row_data === false) break;
338
+					if ($row_data === false) break;
339 339
 					$rows[$import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines'] ? 'h1' : $row] = $row_data;
340
-					if($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) $row--;
340
+					if ($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) $row--;
341 341
 				}
342 342
 				$preview = Api\Html::table($rows);
343 343
 				rewind($stream);
@@ -346,22 +346,22 @@  discard block
 block discarded – undo
346 346
 			{
347 347
 				$preview = lang('Preview not supported by %1', $plugin->get_name());
348 348
 			}
349
-			if(count($plugin->get_warnings())) {
349
+			if (count($plugin->get_warnings())) {
350 350
 				$this->message .= "<br />\n".lang('Warnings').':';
351
-				foreach($plugin->get_warnings() as $record => $message) {
351
+				foreach ($plugin->get_warnings() as $record => $message) {
352 352
 					$this->message .= "\n$record: $message";
353 353
 				}
354 354
 				$this->message .= "<br />\n";
355 355
 			};
356
-			if(count($plugin->get_errors())) {
356
+			if (count($plugin->get_errors())) {
357 357
 				$this->message .= "<br />\n".lang('Problems during import:');
358
-				foreach($plugin->get_errors() as $record => $message) {
358
+				foreach ($plugin->get_errors() as $record => $message) {
359 359
 					$this->message .= "<br />\n$record: $message";
360 360
 				}
361
-				if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported');
361
+				if ($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported');
362 362
 				$this->message .= "<br />\n";
363 363
 			}
364
-			return '<div class="header">' . lang('Preview') . ' - ' . $plugin->get_name() . '</div>' . $preview;
364
+			return '<div class="header">'.lang('Preview').' - '.$plugin->get_name().'</div>'.$preview;
365 365
 		}
366 366
 
367 367
 		/**
@@ -379,24 +379,24 @@  discard block
 block discarded – undo
379 379
 		 */
380 380
 		public static function check_file(&$file, &$definition, &$message = array(), $dst_file = false)
381 381
 		{
382
-			$options =& $definition->plugin_options;
382
+			$options = & $definition->plugin_options;
383 383
 			$message_count = count($message);
384 384
 
385 385
 			// Only CSV files
386
-			if(!$options['csv_fields']) return true;
386
+			if (!$options['csv_fields']) return true;
387 387
 
388 388
 			// Can't check if definition has no header
389
-			if($options['num_header_lines'] == 0) return true;
389
+			if ($options['num_header_lines'] == 0) return true;
390 390
 
391 391
 			$preference = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
392 392
 			$charset = $options['charset'] == 'user' || !$options['charset'] ? $preference : $options['charset'];
393 393
 
394 394
 			$data = fgetcsv($file, 8000, $options['fieldsep']);
395 395
 			rewind($file);
396
-			$data = Api\Translation::convert($data,$charset);
396
+			$data = Api\Translation::convert($data, $charset);
397 397
 
398 398
 			$ok = true;
399
-			if(count($data) != count($options['csv_fields']) && max(array_keys($data)) != max(array_keys($options['csv_fields'])))
399
+			if (count($data) != count($options['csv_fields']) && max(array_keys($data)) != max(array_keys($options['csv_fields'])))
400 400
 			{
401 401
 				$message[] = lang("Column mismatch.  Expected %1 columns, your file has %2.",
402 402
 					count($options['field_mapping']),
@@ -404,9 +404,9 @@  discard block
 block discarded – undo
404 404
 				);
405 405
 				$ok = false;
406 406
 			}
407
-			foreach($data as $index => $header)
407
+			foreach ($data as $index => $header)
408 408
 			{
409
-				if($index < count($options['csv_fields']) && !$options['field_mapping'][$index])
409
+				if ($index < count($options['csv_fields']) && !$options['field_mapping'][$index])
410 410
 				{
411 411
 					// Skipped column in definition
412 412
 					continue;
@@ -418,16 +418,16 @@  discard block
 block discarded – undo
418 418
 				}
419 419
 
420 420
 				// Check for matching headers
421
-				if($options['csv_fields'][$index] == $header)
421
+				if ($options['csv_fields'][$index] == $header)
422 422
 				{
423 423
 					// Simple match
424 424
 					continue;
425 425
 				}
426 426
 				// Check column headers, taking into account different translations - make sure no *
427
-				$lang_defn = mb_strtoupper(Api\Translation::translate($options['csv_fields'][$index],false,''));
428
-				$lang_file = mb_strtoupper(Api\Translation::translate($header,false,''));
427
+				$lang_defn = mb_strtoupper(Api\Translation::translate($options['csv_fields'][$index], false, ''));
428
+				$lang_file = mb_strtoupper(Api\Translation::translate($header, false, ''));
429 429
 
430
-				if($lang_defn == $lang_file ||
430
+				if ($lang_defn == $lang_file ||
431 431
 					$lang_defn == mb_strtoupper($header) ||
432 432
 					$lang_file == mb_strtoupper($options['csv_fields'][$index])
433 433
 				)
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 				$file_message_id = Api\Translation::get_message_id($header, $definition->application);
440 440
 				$defn_message_id = Api\Translation::get_message_id($options['csv_fields'][$index], $definition->application);
441 441
 
442
-				if($file_message_id && $defn_message_id && $file_message_id == $defn_message_id)
442
+				if ($file_message_id && $defn_message_id && $file_message_id == $defn_message_id)
443 443
 				{
444 444
 					continue;
445 445
 				}
@@ -447,19 +447,19 @@  discard block
 block discarded – undo
447 447
 
448 448
 				// Problem
449 449
 				$message[] = lang("Column mismatch: %1 should be %2, not %3",
450
-					$index,$options['csv_fields'][$index], $header);
450
+					$index, $options['csv_fields'][$index], $header);
451 451
 				// But can still continue
452 452
 				// $ok = false;
453 453
 			}
454
-			if(!$ok || count($message) != $message_count)
454
+			if (!$ok || count($message) != $message_count)
455 455
 			{
456 456
 				// Add links for new / edit definition
457 457
 				$config = Api\Config::read('importexport');
458
-				if($GLOBALS['egw_info']['user']['apps']['admin'] || $config['users_create_definitions'])
458
+				if ($GLOBALS['egw_info']['user']['apps']['admin'] || $config['users_create_definitions'])
459 459
 				{
460 460
 					$actions = [];
461 461
 					// New definition
462
-					$add_link = Egw::link('/index.php',array(
462
+					$add_link = Egw::link('/index.php', array(
463 463
 						'menuaction' => 'importexport.importexport_definitions_ui.edit',
464 464
 						'application' => $definition->application,
465 465
 						'plugin' => $definition->plugin,
@@ -471,13 +471,13 @@  discard block
 block discarded – undo
471 471
 							'menuaction' => 'importexport.importexport_import_ui.import_dialog',
472 472
 							// Don't set appname, or user won't be able to select & see their new definition
473 473
 							//'appname' => $definition->application,
474
-						)) . "';
474
+						))."';
475 475
 						egw_openWindowCentered2('$add_link','_blank',500,500,'yes');
476 476
 					";
477 477
 					$actions[] = lang('Create a <a href="%1">new definition</a> for this file', $add_link);
478 478
 
479 479
 					// Edit selected definition, if allowed
480
-					if($definition->owner == $GLOBALS['egw_info']['user']['account_id'] ||
480
+					if ($definition->owner == $GLOBALS['egw_info']['user']['account_id'] ||
481 481
 						!$definition->owner && $GLOBALS['egw_info']['user']['apps']['admin'])
482 482
 					{
483 483
 						$edit_link = array(
@@ -486,20 +486,20 @@  discard block
 block discarded – undo
486 486
 							// Jump to file step
487 487
 							'step' => 'wizard_step21'
488 488
 						);
489
-						if($dst_file)
489
+						if ($dst_file)
490 490
 						{
491 491
 							// Still have uploaded file, jump there
492
-							Api\Cache::setSession($definition->application,'csvfile',$dst_file);
492
+							Api\Cache::setSession($definition->application, 'csvfile', $dst_file);
493 493
 							$edit_link['step'] = 'wizard_step30';
494 494
 						}
495
-						$edit_link = Egw::link('/index.php',$edit_link);
495
+						$edit_link = Egw::link('/index.php', $edit_link);
496 496
 						$edit_link = "javascript:egw_openWindowCentered2('$edit_link','_blank',500,500,'yes')";
497 497
 						$actions[] = lang('Edit definition <a href="%1">%2</a> to match your file',
498
-							$edit_link, $definition->name );
498
+							$edit_link, $definition->name);
499 499
 					}
500
-					$actions[] = lang('Edit your file to match the definition:') . ' '
501
-					. implode(array_map('lang',array_intersect_key($options['csv_fields'],$options['field_mapping'])),', ');
502
-					$message[] = "\n<li>".implode($actions,"\n<li>");
500
+					$actions[] = lang('Edit your file to match the definition:').' '
501
+					. implode(array_map('lang', array_intersect_key($options['csv_fields'], $options['field_mapping'])), ', ');
502
+					$message[] = "\n<li>".implode($actions, "\n<li>");
503 503
 				}
504 504
 			}
505 505
 			return $ok;
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
 
@@ -62,15 +65,18 @@  discard block
 block discarded – undo
62 65
 			{
63 66
 				Api\Translation::add_app($appname);
64 67
 			}
65
-			if($content['import'] && $definition) {
68
+			if($content['import'] && $definition)
69
+			{
66 70
 				try {
67
-					if($content['dry-run']) {
71
+					if($content['dry-run'])
72
+					{
68 73
 						// Set this so plugin doesn't do any data changes
69 74
 						$definition_obj->plugin_options = (array)$definition_obj->plugin_options + array('dry_run' => true);
70 75
 					}
71 76
 					$options =& $definition_obj->plugin_options;
72 77
 					$options['no_notification'] = $content['no_notifications'];
73
-					if($content['delimiter']) {
78
+					if($content['delimiter'])
79
+					{
74 80
 						$options['fieldsep'] =
75 81
 							$content['delimiter'] == 'other' ? $content['other_delimiter'] : $content['delimiter'];
76 82
 					}
@@ -115,7 +121,8 @@  discard block
 block discarded – undo
115 121
 						// Keep file
116 122
 						if($dst_file)
117 123
 						{
118
-							if($content['file']['name'] && copy($content['file']['tmp_name'],$dst_file)) {
124
+							if($content['file']['name'] && copy($content['file']['tmp_name'],$dst_file))
125
+							{
119 126
 								$preserve['file']['tmp_name'] = $dst_file;
120 127
 							}
121 128
 						}
@@ -168,33 +175,44 @@  discard block
 block discarded – undo
168 175
 						Framework::refresh_opener(lang('%1 records processed',$count), $appname, null,null,$appname);
169 176
 					}
170 177
 					$total_processed = 0;
171
-					foreach($plugin->get_results() as $action => $a_count) {
178
+					foreach($plugin->get_results() as $action => $a_count)
179
+					{
172 180
 						$this->message .= "<br />\n" . lang($action) . ": $a_count";
173 181
 						$total_processed += $a_count;
174 182
 					}
175
-					if(count($plugin->get_warnings())) {
183
+					if(count($plugin->get_warnings()))
184
+					{
176 185
 						$this->message .= "<br />\n".lang('Warnings').':';
177
-						foreach($plugin->get_warnings() as $record => $message) {
186
+						foreach($plugin->get_warnings() as $record => $message)
187
+						{
178 188
 							$this->message .= "<br />\n$record: $message";
179 189
 						}
180 190
 					}
181
-					if(count($plugin->get_errors())) {
191
+					if(count($plugin->get_errors()))
192
+					{
182 193
 						$this->message .= "<br />\n".lang('Problems during import:');
183
-						foreach($plugin->get_errors() as $record => $message) {
194
+						foreach($plugin->get_errors() as $record => $message)
195
+						{
184 196
 							$this->message .= "<br />\n$record: $message";
185 197
 						}
186
-						if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported');
198
+						if($count != $total_processed)
199
+						{
200
+							$this->message .= "<br />\n".lang('Some records may not have been imported');
201
+						}
187 202
 					}
188
-					if ($dst_file && $content['file']['tmp_name'] == $dst_file) {
203
+					if ($dst_file && $content['file']['tmp_name'] == $dst_file)
204
+					{
189 205
 						// Remove file
190 206
 						$cachefile->delete(Api\Cache::keys(Api\Cache::INSTANCE, 'importexport',
191 207
 							'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id'])));
192 208
 						unset($dst_file);
193 209
 					}
194 210
 
195
-				} catch (Api\Db\Exception $db_ex) {
211
+				}
212
+				catch (Api\Db\Exception $db_ex) {
196 213
 					$this->message .= lang('Database error');
197
-				} catch (Exception $e) {
214
+				}
215
+				catch (Exception $e) {
198 216
 					$this->message .= $e->getMessage();
199 217
 				}
200 218
 			}
@@ -251,7 +269,10 @@  discard block
 block discarded – undo
251 269
 			$data['message'] = $this->message;
252 270
 			Framework::includeJS('.','importexport','importexport');
253 271
 
254
-			if($_GET['appname']) $readonlys['appname'] = true;
272
+			if($_GET['appname'])
273
+			{
274
+				$readonlys['appname'] = true;
275
+			}
255 276
 
256 277
 			$template->exec('importexport.importexport_import_ui.import_dialog', $data, $sel_options, $readonlys, $preserve, 2);
257 278
 		}
@@ -259,7 +280,8 @@  discard block
 block discarded – undo
259 280
 		/**
260 281
 		* Get options for select boxes
261 282
 		*/
262
-		public static function get_select_options(Array $data) {
283
+		public static function get_select_options(Array $data)
284
+		{
263 285
 			$options = array(
264 286
 				'delimiter' => array(
265 287
 					''	=>	lang('From definition'),
@@ -275,17 +297,20 @@  discard block
 block discarded – undo
275 297
 			(array)$apps = importexport_helper_functions::get_apps('import');
276 298
 			$options['appname'] = array('' => lang('Select one')) + array_combine($apps,$apps);
277 299
 
278
-			if($data['appname']) {
300
+			if($data['appname'])
301
+			{
279 302
 				$options['definition'] = array();
280 303
 
281
-				if($data['file'] && !is_array($data['file'])) {
304
+				if($data['file'] && !is_array($data['file']))
305
+				{
282 306
 					$extension = substr($data['file'], -3);
283 307
 				}
284 308
 				$definitions = new importexport_definitions_bo(array(
285 309
 					'type' => 'import',
286 310
 					'application' => $data['appname']
287 311
 				));
288
-				foreach ((array)$definitions->get_definitions() as $identifier) {
312
+				foreach ((array)$definitions->get_definitions() as $identifier)
313
+				{
289 314
 					try
290 315
 					{
291 316
 						$definition = new importexport_definition($identifier);
@@ -295,7 +320,8 @@  discard block
 block discarded – undo
295 320
 						// Permission error
296 321
 						continue;
297 322
 					}
298
-					if ($title = $definition->get_title()) {
323
+					if ($title = $definition->get_title())
324
+					{
299 325
 						$options['definition'][$title] = $title;
300 326
 					}
301 327
 					unset($definition);
@@ -335,9 +361,15 @@  discard block
 block discarded – undo
335 361
 				for($row = 0; $row < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; $row++)
336 362
 				{
337 363
 					$row_data = $import_csv->get_record();
338
-					if($row_data === false) break;
364
+					if($row_data === false)
365
+					{
366
+						break;
367
+					}
339 368
 					$rows[$import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines'] ? 'h1' : $row] = $row_data;
340
-					if($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) $row--;
369
+					if($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines'])
370
+					{
371
+						$row--;
372
+					}
341 373
 				}
342 374
 				$preview = Api\Html::table($rows);
343 375
 				rewind($stream);
@@ -346,19 +378,26 @@  discard block
 block discarded – undo
346 378
 			{
347 379
 				$preview = lang('Preview not supported by %1', $plugin->get_name());
348 380
 			}
349
-			if(count($plugin->get_warnings())) {
381
+			if(count($plugin->get_warnings()))
382
+			{
350 383
 				$this->message .= "<br />\n".lang('Warnings').':';
351
-				foreach($plugin->get_warnings() as $record => $message) {
384
+				foreach($plugin->get_warnings() as $record => $message)
385
+				{
352 386
 					$this->message .= "\n$record: $message";
353 387
 				}
354 388
 				$this->message .= "<br />\n";
355 389
 			};
356
-			if(count($plugin->get_errors())) {
390
+			if(count($plugin->get_errors()))
391
+			{
357 392
 				$this->message .= "<br />\n".lang('Problems during import:');
358
-				foreach($plugin->get_errors() as $record => $message) {
393
+				foreach($plugin->get_errors() as $record => $message)
394
+				{
359 395
 					$this->message .= "<br />\n$record: $message";
360 396
 				}
361
-				if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported');
397
+				if($count != $total_processed)
398
+				{
399
+					$this->message .= "<br />\n".lang('Some records may not have been imported');
400
+				}
362 401
 				$this->message .= "<br />\n";
363 402
 			}
364 403
 			return '<div class="header">' . lang('Preview') . ' - ' . $plugin->get_name() . '</div>' . $preview;
@@ -383,10 +422,16 @@  discard block
 block discarded – undo
383 422
 			$message_count = count($message);
384 423
 
385 424
 			// Only CSV files
386
-			if(!$options['csv_fields']) return true;
425
+			if(!$options['csv_fields'])
426
+			{
427
+				return true;
428
+			}
387 429
 
388 430
 			// Can't check if definition has no header
389
-			if($options['num_header_lines'] == 0) return true;
431
+			if($options['num_header_lines'] == 0)
432
+			{
433
+				return true;
434
+			}
390 435
 
391 436
 			$preference = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
392 437
 			$charset = $options['charset'] == 'user' || !$options['charset'] ? $preference : $options['charset'];
@@ -430,8 +475,7 @@  discard block
 block discarded – undo
430 475
 				if($lang_defn == $lang_file ||
431 476
 					$lang_defn == mb_strtoupper($header) ||
432 477
 					$lang_file == mb_strtoupper($options['csv_fields'][$index])
433
-				)
434
-				{
478
+				) {
435 479
 					continue;
436 480
 				}
437 481
 
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   +254 added lines, -255 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,9 +2046,9 @@  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
-						continue 2;	// +1 for switch
2051
+						continue 2; // +1 for switch
2053 2052
 					}
2054 2053
 				default:
2055 2054
 					if (!empty($egwData['info_des']))
@@ -2064,9 +2063,9 @@  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
-						continue 2;	// +1 for switch
2068
+						continue 2; // +1 for switch
2070 2069
 					}
2071 2070
 					// no further criteria to match
2072 2071
 					$foundInfoLogs[$egwData['info_id']] = $egwData['info_id'];
@@ -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.